@indigoai-us/hq-cli 5.345.231 → 5.345.233
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 +48 -0
- package/README.md +3 -2
- package/assets/lanes-reconcile/hq-lanes-reconcile.service +1 -1
- package/assets/scaffold/core/scripts/pipeline-conductor.sh +14 -14
- package/assets/scaffold/core/scripts/pipeline-driver.sh +7 -7
- package/assets/scaffold/core/scripts/session-project.sh +19 -4
- package/dist/command-catalog.generated.d.ts +213 -177
- package/dist/command-catalog.generated.js +263 -212
- package/dist/command-registration-plan.d.ts +6 -24
- package/dist/command-registration-plan.js +4 -8
- package/dist/commands/auth.js +3 -2
- package/dist/commands/core-handoff.d.ts +1 -0
- package/dist/commands/core-handoff.js +2 -28
- package/dist/commands/core-pipeline-conductor-command.js +1 -1
- package/dist/commands/core-pipeline-conductor-native.js +5 -5
- package/dist/commands/core-pipeline-driver-native.js +5 -5
- package/dist/commands/daemon.js +7 -36
- package/dist/commands/deploy-access.js +6 -13
- package/dist/commands/deploy-comments.js +5 -13
- package/dist/commands/deploy-domains.js +6 -13
- package/dist/commands/deploy-list.js +25 -11
- package/dist/commands/deploy-mutations.d.ts +3 -0
- package/dist/commands/deploy-mutations.js +147 -0
- package/dist/commands/link.js +29 -0
- package/dist/commands/mcp-serve-gate.d.ts +22 -0
- package/dist/commands/mcp-serve-gate.js +37 -0
- package/dist/commands/mcp-serve.js +2 -8
- package/dist/commands/mesh.js +3 -1
- package/dist/commands/report.js +8 -9
- package/dist/data/command-states.json +10 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +257 -214
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +6 -1
- package/dist/lib/bot/fleet-bots-update-pass.d.ts +8 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +40 -0
- package/dist/lib/bot/fleet-bots-update-task.d.ts +12 -0
- package/dist/lib/bot/fleet-bots-update-task.js +52 -0
- package/dist/lib/bot/fleet-bots-update-worker-v1.d.ts +2 -0
- package/dist/lib/bot/fleet-bots-update-worker-v1.js +5 -0
- package/dist/lib/daemon/catalog.d.ts +8 -5
- package/dist/lib/daemon/catalog.js +15 -8
- package/dist/lib/daemon/flag.d.ts +2 -0
- package/dist/lib/daemon/flag.js +6 -4
- package/dist/lib/daemon/lock.js +33 -37
- package/dist/lib/daemon/ops/skill-command.d.ts +99 -0
- package/dist/lib/daemon/ops/skill-command.js +260 -0
- package/dist/lib/daemon/protocol.d.ts +1 -1
- package/dist/lib/daemon/protocol.js +1 -0
- package/dist/lib/daemon/run.js +10 -18
- package/dist/lib/daemon/server.js +7 -0
- package/dist/lib/daemon/shared-flag-reads.d.ts +70 -0
- package/dist/lib/daemon/shared-flag-reads.js +173 -0
- package/dist/lib/daemon/supervisor.d.ts +5 -0
- package/dist/lib/daemon/supervisor.js +17 -2
- package/dist/lib/db/app-ref.js +10 -15
- package/dist/lib/deploy-apps.d.ts +29 -0
- package/dist/lib/deploy-apps.js +37 -0
- package/dist/lib/doctor/checks/search-index.d.ts +16 -0
- package/dist/lib/doctor/checks/search-index.js +61 -0
- package/dist/lib/doctor/checks/stranded-lanes.js +1 -1
- package/dist/lib/doctor/registry.js +4 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/lanes/accounts.js +3 -3
- package/dist/lib/lanes/admission-host.js +1 -1
- package/dist/lib/lanes/admission.js +4 -4
- package/dist/lib/lanes/autopilot.js +2 -2
- package/dist/lib/lanes/blocker-freshness.js +1 -1
- package/dist/lib/lanes/compaction.js +5 -5
- package/dist/lib/lanes/delivery.js +1 -1
- package/dist/lib/lanes/depth-cap.js +1 -1
- package/dist/lib/lanes/disk-guard.js +1 -1
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/hooks-install.js +1 -1
- package/dist/lib/lanes/imported-question.js +1 -1
- package/dist/lib/lanes/keep-alive.d.ts +2 -2
- package/dist/lib/lanes/keep-alive.js +3 -3
- package/dist/lib/lanes/kr-freshness.js +1 -1
- package/dist/lib/lanes/links.js +4 -4
- package/dist/lib/lanes/loop.js +2 -2
- package/dist/lib/lanes/machine-identity.js +3 -3
- package/dist/lib/lanes/models.js +6 -6
- package/dist/lib/lanes/quota.js +1 -1
- package/dist/lib/lanes/reconcile-install.js +3 -3
- package/dist/lib/lanes/reconcile.js +16 -16
- package/dist/lib/lanes/remote-control-lane.js +6 -6
- package/dist/lib/lanes/reviews.js +2 -2
- package/dist/lib/lanes/spawn.js +24 -24
- package/dist/lib/lanes/status-fields.js +4 -4
- package/dist/lib/lanes/wait.js +4 -4
- package/dist/lib/lanes/watch.js +2 -2
- package/dist/lib/lanes/watcher-main.js +1 -1
- package/dist/lib/lanes/watcher.js +38 -38
- package/dist/lib/lanes/worker-process.js +5 -5
- package/dist/lib/mesh/live/daemon/pid-lock.d.ts +2 -4
- package/dist/lib/mesh/live/daemon/pid-lock.js +38 -55
- package/dist/utils/cognito-session.d.ts +2 -56
- package/dist/utils/cognito-session.js +6 -164
- package/dist/utils/exclusive-lock.d.ts +60 -0
- package/dist/utils/exclusive-lock.js +65 -0
- package/package.json +9 -8
- package/dist/commands/staff/listings.d.ts +0 -41
- package/dist/commands/staff/listings.js +0 -160
- package/dist/commands/staff/reset-test-account.d.ts +0 -121
- package/dist/commands/staff/reset-test-account.js +0 -285
- package/dist/commands/staff/test-account.d.ts +0 -51
- package/dist/commands/staff/test-account.js +0 -196
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { deployApiRequest } from "../lib/deploy-api.js";
|
|
4
|
+
import { ensureCognitoToken } from "../utils/cognito-session.js";
|
|
5
|
+
import { displayText } from "./deploy-comments.js";
|
|
6
|
+
class DeployMutationError extends Error {
|
|
7
|
+
}
|
|
8
|
+
function headers(options) {
|
|
9
|
+
if (Boolean(options.company) === Boolean(options.personal))
|
|
10
|
+
throw new DeployMutationError("Choose exactly one of --company <slug> or --personal.");
|
|
11
|
+
if (options.company && !/^[a-z0-9][a-z0-9-]{0,62}$/.test(options.company))
|
|
12
|
+
throw new DeployMutationError("Invalid company slug.");
|
|
13
|
+
return options.company ? { "X-Org-Slug": options.company } : { "X-HQ-Deploy-Scope": "personal" };
|
|
14
|
+
}
|
|
15
|
+
function id(value) {
|
|
16
|
+
if (!/^[A-Za-z0-9_-]+$/.test(value))
|
|
17
|
+
throw new DeployMutationError("Invalid app or deployment identifier.");
|
|
18
|
+
return encodeURIComponent(value);
|
|
19
|
+
}
|
|
20
|
+
async function signIn() {
|
|
21
|
+
try {
|
|
22
|
+
return await ensureCognitoToken();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw new DeployMutationError("Could not get an HQ sign-in for hq-deploy. Run hq login and retry.");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async function readLocal(path, what) {
|
|
29
|
+
try {
|
|
30
|
+
return await readFile(path);
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
throw new DeployMutationError(`Could not read the ${what} at ${path}. Nothing was sent.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function request(token, route, method, body, scope) {
|
|
37
|
+
let response;
|
|
38
|
+
try {
|
|
39
|
+
response = await deployApiRequest(token, route, method, body, scope);
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
throw new DeployMutationError("Could not reach hq-deploy. Retry the operation.");
|
|
43
|
+
}
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
if (response.status === 401)
|
|
46
|
+
throw new DeployMutationError("hq-deploy rejected your sign-in. Run hq login and retry.");
|
|
47
|
+
throw new DeployMutationError(`hq-deploy rejected the operation (HTTP ${response.status}).`);
|
|
48
|
+
}
|
|
49
|
+
if (response.status === 204)
|
|
50
|
+
return {};
|
|
51
|
+
try {
|
|
52
|
+
return await response.json();
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new DeployMutationError("hq-deploy returned an invalid response.");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function requiredText(record, key) {
|
|
59
|
+
if (typeof record[key] !== "string" || !record[key])
|
|
60
|
+
throw new DeployMutationError(`hq-deploy response is missing ${key}.`);
|
|
61
|
+
return record[key];
|
|
62
|
+
}
|
|
63
|
+
function output(value, options, text = "Deploy operation completed.") {
|
|
64
|
+
console.log(options.json ? JSON.stringify(value) : text);
|
|
65
|
+
}
|
|
66
|
+
function scope(command) {
|
|
67
|
+
return command.option("--company <slug>", "company owning the app").option("--personal", "use personal scope").option("--json", "print JSON");
|
|
68
|
+
}
|
|
69
|
+
function action(fn) {
|
|
70
|
+
return async (...args) => {
|
|
71
|
+
try {
|
|
72
|
+
await fn(...args);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
console.error(error instanceof DeployMutationError ? error.message : "Deploy operation failed.");
|
|
76
|
+
process.exitCode = 1;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function registerDeployMutationsCommand(deploy) {
|
|
81
|
+
scope(deploy.command("inspect <app>").description("Read app access mode, password protection and private mode state"))
|
|
82
|
+
.action(action(async (app, options) => {
|
|
83
|
+
const context = headers(options);
|
|
84
|
+
const record = await request(await signIn(), `/api/apps/${id(app)}`, "GET", undefined, context);
|
|
85
|
+
output({ id: app, accessMode: record.accessMode ?? null, passwordProtected: record.passwordProtected === true, privateMode: record.privateMode === true }, options);
|
|
86
|
+
}));
|
|
87
|
+
scope(deploy.command("create <name>").description("Create a deploy app").option("--type <type>", "static, app or ssr", "static"))
|
|
88
|
+
.action(action(async (name, options) => {
|
|
89
|
+
const context = headers(options);
|
|
90
|
+
if (!name.trim() || !["static", "app", "ssr"].includes(options.type))
|
|
91
|
+
throw new DeployMutationError("Provide a name and type static, app or ssr.");
|
|
92
|
+
const created = await request(await signIn(), "/api/apps", "POST", { name, type: options.type }, context);
|
|
93
|
+
const appId = requiredText(created, "id");
|
|
94
|
+
const appUrl = typeof created.url === "string" && created.url ? created.url : "not returned";
|
|
95
|
+
output(created, options, `Created app ${displayText(appId)}. URL: ${displayText(appUrl)}`);
|
|
96
|
+
}));
|
|
97
|
+
scope(deploy.command("takedown <app>").description("Deactivate a deploy app"))
|
|
98
|
+
.action(action(async (app, options) => {
|
|
99
|
+
const context = headers(options);
|
|
100
|
+
await request(await signIn(), `/api/apps/${id(app)}`, "PATCH", { active: false }, context);
|
|
101
|
+
output({ app, active: false }, options);
|
|
102
|
+
}));
|
|
103
|
+
scope(deploy.command("password-gate <app>").description("Set a password gate using a file").requiredOption("--password-file <path>", "file containing the password"))
|
|
104
|
+
.action(action(async (app, options) => {
|
|
105
|
+
const context = headers(options);
|
|
106
|
+
const password = (await readLocal(options.passwordFile, "password file")).toString("utf8").replace(/\r?\n$/, "");
|
|
107
|
+
if (!password || password.length > 4096)
|
|
108
|
+
throw new DeployMutationError("Password file must contain 1–4096 characters.");
|
|
109
|
+
await request(await signIn(), `/api/apps/${id(app)}/access-mode`, "POST", { mode: "password", password }, context);
|
|
110
|
+
output({ app, mode: "password" }, options);
|
|
111
|
+
}));
|
|
112
|
+
scope(deploy.command("private-gate <app>").description("Set a private gate and grant email patterns").option("--email <pattern>", "email pattern to grant", (value, values) => [...values, value], []))
|
|
113
|
+
.action(action(async (app, options) => {
|
|
114
|
+
const context = headers(options);
|
|
115
|
+
const token = await signIn();
|
|
116
|
+
const route = `/api/apps/${id(app)}`;
|
|
117
|
+
await request(token, `${route}/access-mode`, "POST", { mode: "private" }, context);
|
|
118
|
+
for (const email of options.email)
|
|
119
|
+
await request(token, `${route}/allowed-emails`, "POST", { email }, context);
|
|
120
|
+
output({ app, mode: "private" }, options);
|
|
121
|
+
}));
|
|
122
|
+
scope(deploy.command("upload <app> <archive>").description("Upload an existing gzip deployment archive").option("--manifest-org", "include the legacy informational org field in the manifest request"))
|
|
123
|
+
.action(action(async (app, archive, options) => {
|
|
124
|
+
const context = headers(options);
|
|
125
|
+
id(app);
|
|
126
|
+
const bytes = await readLocal(archive, "archive file");
|
|
127
|
+
const token = await signIn();
|
|
128
|
+
const initialized = await request(token, "/api/deploys", "POST", { appSlug: app, ...(options.manifestOrg ? { org: options.company ?? "" } : {}), manifest: { files: [], size: bytes.length, sha256: createHash("sha256").update(bytes).digest("hex") } }, context);
|
|
129
|
+
const deployment = id(requiredText(initialized, "deployId"));
|
|
130
|
+
const signed = new URL(requiredText(initialized, "presignedUrl"));
|
|
131
|
+
if (signed.protocol !== "https:" || signed.username || signed.password)
|
|
132
|
+
throw new DeployMutationError("hq-deploy returned an invalid upload URL.");
|
|
133
|
+
let uploaded;
|
|
134
|
+
try {
|
|
135
|
+
uploaded = await fetch(signed, { method: "PUT", headers: { "Content-Type": "application/gzip" }, body: bytes, redirect: "error", signal: AbortSignal.timeout(30_000) });
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new DeployMutationError("Archive upload failed. Deployment was not completed.");
|
|
139
|
+
}
|
|
140
|
+
if (!uploaded.ok)
|
|
141
|
+
throw new DeployMutationError(`Archive upload failed (HTTP ${uploaded.status}). Deployment was not completed.`);
|
|
142
|
+
const completed = await request(token, `/api/deploys/${deployment}/complete`, "POST", { appSlug: app }, context);
|
|
143
|
+
const liveUrl = requiredText(completed, "url");
|
|
144
|
+
output({ ...completed, deployId: decodeURIComponent(deployment) }, options, `Deployed app ${displayText(app)} (deployment ${displayText(decodeURIComponent(deployment))}). Live URL: ${displayText(liveUrl)}`);
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=deploy-mutations.js.map
|
package/dist/commands/link.js
CHANGED
|
@@ -15,6 +15,8 @@ import { createResolver } from "../lib/daemon/resolver.js";
|
|
|
15
15
|
import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
16
16
|
import { canonicalDir, keyForDir, readRegistry, registryDir, registryFile, removeEntriesForDir, seedFromManifest, setEntry, wouldBindEnclosingRemote, writeRegistry, } from "../lib/registry/registry.js";
|
|
17
17
|
import { readHqRoot } from "./mcp-serve.js";
|
|
18
|
+
import { resolveCompany as resolveActiveCompany } from "./core-resolve-company-native.js";
|
|
19
|
+
import { resolveLiveRoot } from "../utils/hq-roots.js";
|
|
18
20
|
async function requireAnywhereRuntime(deps) {
|
|
19
21
|
if (!(await (deps.runtimeAllowed ?? (() => anywhereRuntimeAllowed()))())) {
|
|
20
22
|
throw new Error("HQ Anywhere is disabled until both the runtime flag and your person setting are on.");
|
|
@@ -172,7 +174,34 @@ export function registerResolveCompanyCommand(program, deps = {}) {
|
|
|
172
174
|
.description("Print the HQ company linked to this folder (never guesses)")
|
|
173
175
|
.option("--path <dir>", "Folder to resolve (default: current directory)")
|
|
174
176
|
.option("--json", "Print JSON output")
|
|
177
|
+
.option("--prompt <text>", "Resolve the active company for skills and routing: whole-token manifest slug in <text>, then session, then device default; prints JSON and exits 0")
|
|
178
|
+
.option("--root <dir>", "HQ root for --prompt (default: the live HQ root)")
|
|
175
179
|
.action(async (opts) => {
|
|
180
|
+
if (opts.prompt !== undefined) {
|
|
181
|
+
if (opts.path !== undefined) {
|
|
182
|
+
console.error("hq resolve-company: --prompt and --path cannot be used together");
|
|
183
|
+
process.exitCode = 1;
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// US-030 c1: one resolver. This is the same function behind
|
|
187
|
+
// `hq core resolve-company --prompt`; it reads no anywhere registry,
|
|
188
|
+
// so it is not behind the anywhere runtime gate.
|
|
189
|
+
let hqRoot;
|
|
190
|
+
try {
|
|
191
|
+
hqRoot = resolveLiveRoot({ hqRoot: opts.root });
|
|
192
|
+
}
|
|
193
|
+
catch (err) {
|
|
194
|
+
fail(err);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const result = await resolveActiveCompany(opts.root !== undefined ? ["--root", opts.root, "--prompt", opts.prompt] : ["--prompt", opts.prompt], { cwd: process.cwd(), hqRoot, stdinIsTty: true });
|
|
198
|
+
process.stdout.write(result.stdout);
|
|
199
|
+
if (result.stderr.length)
|
|
200
|
+
process.stderr.write(result.stderr);
|
|
201
|
+
if (result.code !== 0)
|
|
202
|
+
process.exitCode = result.code;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
176
205
|
try {
|
|
177
206
|
await requireAnywhereRuntime(deps);
|
|
178
207
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first check of `hq mcp serve`, kept in its own small module so that the
|
|
3
|
+
* fast route in src/index.ts can deny a fresh install before it loads
|
|
4
|
+
* commands/mcp-serve.js and that module's hqd protocol, package lease and
|
|
5
|
+
* resident preload imports. Builtins and the flag key only.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MCP_SERVE_DISABLED_MESSAGE = "HQ Anywhere is not enabled. The hq-anywhere-runtime flag and your HQ Anywhere person setting must both be on.\n";
|
|
8
|
+
/**
|
|
9
|
+
* A person token is required to read the opt-in setting, so without the token
|
|
10
|
+
* cache the server is denied. Mirrors personTokenCacheFile() in
|
|
11
|
+
* utils/cognito-session.ts; duplicated so this path does not load that module.
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasPersonTokenCache(env: NodeJS.ProcessEnv, home: string): boolean;
|
|
14
|
+
/** Write the denial and set exit code 1, as runMcpServe does. */
|
|
15
|
+
export declare function denyMcpServe(stderr?: NodeJS.WritableStream): void;
|
|
16
|
+
/**
|
|
17
|
+
* The fast route's check: true when there is no person token cache, after the
|
|
18
|
+
* denial was written. runMcpServe makes the same check first, so the result
|
|
19
|
+
* and output are the same with or without this step.
|
|
20
|
+
*/
|
|
21
|
+
export declare function denyMcpServeWithoutTokenCache(env?: NodeJS.ProcessEnv, home?: string): boolean;
|
|
22
|
+
//# sourceMappingURL=mcp-serve-gate.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first check of `hq mcp serve`, kept in its own small module so that the
|
|
3
|
+
* fast route in src/index.ts can deny a fresh install before it loads
|
|
4
|
+
* commands/mcp-serve.js and that module's hqd protocol, package lease and
|
|
5
|
+
* resident preload imports. Builtins and the flag key only.
|
|
6
|
+
*/
|
|
7
|
+
import * as fs from "node:fs";
|
|
8
|
+
import * as os from "node:os";
|
|
9
|
+
import * as path from "node:path";
|
|
10
|
+
import { HQ_ANYWHERE_RUNTIME_FLAG } from "../lib/anywhere-runtime-flag-key.js";
|
|
11
|
+
export const MCP_SERVE_DISABLED_MESSAGE = `HQ Anywhere is not enabled. The ${HQ_ANYWHERE_RUNTIME_FLAG} flag and your HQ Anywhere person setting must both be on.\n`;
|
|
12
|
+
/**
|
|
13
|
+
* A person token is required to read the opt-in setting, so without the token
|
|
14
|
+
* cache the server is denied. Mirrors personTokenCacheFile() in
|
|
15
|
+
* utils/cognito-session.ts; duplicated so this path does not load that module.
|
|
16
|
+
*/
|
|
17
|
+
export function hasPersonTokenCache(env, home) {
|
|
18
|
+
const stateDir = env.HQ_STATE_DIR?.trim() || path.join(home, ".hq");
|
|
19
|
+
return fs.existsSync(path.join(stateDir, "cognito-tokens.json"));
|
|
20
|
+
}
|
|
21
|
+
/** Write the denial and set exit code 1, as runMcpServe does. */
|
|
22
|
+
export function denyMcpServe(stderr = process.stderr) {
|
|
23
|
+
stderr.write(MCP_SERVE_DISABLED_MESSAGE);
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The fast route's check: true when there is no person token cache, after the
|
|
28
|
+
* denial was written. runMcpServe makes the same check first, so the result
|
|
29
|
+
* and output are the same with or without this step.
|
|
30
|
+
*/
|
|
31
|
+
export function denyMcpServeWithoutTokenCache(env = process.env, home = os.homedir()) {
|
|
32
|
+
if (hasPersonTokenCache(env, home))
|
|
33
|
+
return false;
|
|
34
|
+
denyMcpServe();
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=mcp-serve-gate.js.map
|
|
@@ -18,7 +18,7 @@ import * as fs from "node:fs";
|
|
|
18
18
|
import * as os from "node:os";
|
|
19
19
|
import * as path from "node:path";
|
|
20
20
|
import { CLI_VERSION } from "../cli-version.js";
|
|
21
|
-
import {
|
|
21
|
+
import { denyMcpServe, hasPersonTokenCache } from "./mcp-serve-gate.js";
|
|
22
22
|
import { createLineSplitter, HqdClientError, hqdRequest, hqdSocketPath } from "../lib/daemon/protocol.js";
|
|
23
23
|
import { releaseCurrentPackageUseLease, releasePackageUseLeaseAfterResidentPreload } from "../utils/package-use-lease.js";
|
|
24
24
|
import { preloadResidentPackageModules, reportResidentPackagePreloadFailure, RESIDENT_PACKAGE_MODULES } from "../utils/resident-package-preload.js";
|
|
@@ -27,11 +27,6 @@ const UNREACHABLE_CODES = new Set(["ENOENT", "ECONNREFUSED", "ECONNRESET", "EPIP
|
|
|
27
27
|
/** hqd is not running, so the request never reached it and a local answer cannot repeat a write. */
|
|
28
28
|
const NOT_RUNNING_CODES = new Set(["ENOENT", "ECONNREFUSED"]);
|
|
29
29
|
const LOCAL_GATE_TTL_MS = 60_000;
|
|
30
|
-
function hasPersonTokenCache(env, home) {
|
|
31
|
-
// Mirrors personTokenCacheFile() in utils/cognito-session.ts; duplicated so this path does not load that module.
|
|
32
|
-
const stateDir = env.HQ_STATE_DIR?.trim() || path.join(home, ".hq");
|
|
33
|
-
return fs.existsSync(path.join(stateDir, "cognito-tokens.json"));
|
|
34
|
-
}
|
|
35
30
|
/** HQ root for prompts: HQ_ROOT, else the ~/.hq/root pointer written by `hq install --global`. */
|
|
36
31
|
export function readHqRoot(env, home) {
|
|
37
32
|
const fromEnv = env.HQ_ROOT?.trim();
|
|
@@ -76,8 +71,7 @@ export async function runMcpServe(opts = {}) {
|
|
|
76
71
|
});
|
|
77
72
|
});
|
|
78
73
|
if (!(await runtimeAllowed())) {
|
|
79
|
-
|
|
80
|
-
process.exitCode = 1;
|
|
74
|
+
denyMcpServe();
|
|
81
75
|
return;
|
|
82
76
|
}
|
|
83
77
|
let packageHandlers;
|
package/dist/commands/mesh.js
CHANGED
|
@@ -65,6 +65,7 @@ import { requeueQuarantinedOutbox } from "../lib/work-context/outbox.js";
|
|
|
65
65
|
import { handOffInstallHere } from "../lib/daemon/handoff.js";
|
|
66
66
|
import { repairServiceUnitsFromOtherHome } from "../lib/daemon/mesh-owner.js";
|
|
67
67
|
import { runResidentCommandWithPackageLease } from "../utils/resident-package-preload.js";
|
|
68
|
+
import { exitCli } from "../utils/exit-after-worker.js";
|
|
68
69
|
export function formatCheckLines(threads, company, projectId) {
|
|
69
70
|
if (threads.length === 0) {
|
|
70
71
|
return ["Work mesh: no active project threads found."];
|
|
@@ -2801,7 +2802,8 @@ function wrap(action) {
|
|
|
2801
2802
|
await action();
|
|
2802
2803
|
}
|
|
2803
2804
|
catch (err) {
|
|
2804
|
-
|
|
2805
|
+
console.error(chalk.red(err instanceof Error ? err.message : String(err)));
|
|
2806
|
+
return await exitCli(1);
|
|
2805
2807
|
}
|
|
2806
2808
|
};
|
|
2807
2809
|
}
|
package/dist/commands/report.js
CHANGED
|
@@ -6,7 +6,7 @@ import * as path from "node:path";
|
|
|
6
6
|
import { ensureCognitoToken, } from "../utils/cognito-session.js";
|
|
7
7
|
import { vaultApiFetch } from "../utils/vault-api.js";
|
|
8
8
|
import { DEPLOY_API_URL, deployApiRequest, deployHeaders } from "../lib/deploy-api.js";
|
|
9
|
-
import {
|
|
9
|
+
import { listAllDeployApps, matchDeployApp } from "../lib/deploy-apps.js";
|
|
10
10
|
import { listReportTemplates } from "../lib/report-templates.js";
|
|
11
11
|
import { stopFlagRegistryWorker } from "../lib/flag-registry.js";
|
|
12
12
|
import { adoptReport, buildReportTarball, conventionReportDir, deployOrgContext, ReportPublishError, plainFailureReason, publishReport, } from "../lib/report-publish.js";
|
|
@@ -263,16 +263,15 @@ async function orgFor(token, report) {
|
|
|
263
263
|
return deployOrgContext(report, slug);
|
|
264
264
|
}
|
|
265
265
|
export async function findOrCreateApp(token, slug, org) {
|
|
266
|
-
const apps = await
|
|
267
|
-
const route = cursor ? `/api/apps?cursor=${encodeURIComponent(cursor)}` : "/api/apps";
|
|
268
|
-
return deployJson(token, route, "GET", undefined, org.headers);
|
|
269
|
-
});
|
|
270
|
-
const mine = (name) => apps.find((app) => !!app && typeof app === "object" && (app.subdomain === name || app.name === name));
|
|
266
|
+
const apps = await listAllDeployApps((route) => deployJson(token, route, "GET", undefined, org.headers));
|
|
271
267
|
let app;
|
|
272
268
|
for (const name of candidateSlugs(slug)) {
|
|
273
|
-
const existing =
|
|
274
|
-
if (existing) {
|
|
275
|
-
app
|
|
269
|
+
const existing = matchDeployApp(apps, name, { exact: true });
|
|
270
|
+
if (existing.kind === "many") {
|
|
271
|
+
throw new ReportPublishError(`More than one hq-deploy app is called '${name}'. Remove the extra app and retry.`);
|
|
272
|
+
}
|
|
273
|
+
if (existing.kind === "found") {
|
|
274
|
+
app = existing.record;
|
|
276
275
|
break;
|
|
277
276
|
}
|
|
278
277
|
try {
|
|
@@ -27,12 +27,15 @@
|
|
|
27
27
|
"report discard-draft": { "state": "retiring" },
|
|
28
28
|
"report promote": { "state": "retiring" },
|
|
29
29
|
"report templates": { "state": "retiring" },
|
|
30
|
-
"staff
|
|
31
|
-
"staff listings
|
|
32
|
-
"staff listings
|
|
33
|
-
"staff
|
|
34
|
-
"staff
|
|
35
|
-
"staff test-account
|
|
36
|
-
"staff test-account
|
|
30
|
+
"staff": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
31
|
+
"staff listings": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
32
|
+
"staff listings approve": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
33
|
+
"staff listings queue": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
34
|
+
"staff listings reject": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
35
|
+
"staff reset-test-account": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
36
|
+
"staff test-account": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
37
|
+
"staff test-account add": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
38
|
+
"staff test-account list": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" },
|
|
39
|
+
"staff test-account remove": { "state": "removed", "replacedBy": "the staff-only hq-staff tool outside the public CLI (hq-core-rust US-053)" }
|
|
37
40
|
}
|
|
38
41
|
}
|