@indigoai-us/hq-cli 5.345.204 → 5.345.205
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 +25 -0
- package/dist/command-catalog.generated.d.ts +51 -1
- package/dist/command-catalog.generated.js +63 -1
- package/dist/commands/bot.d.ts +67 -0
- package/dist/commands/bot.js +301 -39
- package/dist/commands/cloud-off-gate.d.ts +9 -2
- package/dist/commands/cloud-off-gate.js +49 -13
- package/dist/commands/feedback.d.ts +26 -0
- package/dist/commands/feedback.js +91 -5
- package/dist/commands/install-global.d.ts +3 -1
- package/dist/commands/install-global.js +15 -4
- package/dist/commands/lanes.d.ts +2 -0
- package/dist/commands/lanes.js +9 -3
- package/dist/commands/mcp-serve.d.ts +5 -2
- package/dist/commands/mcp-serve.js +45 -3
- package/dist/commands/mcp-status.d.ts +3 -1
- package/dist/commands/mcp-status.js +24 -14
- package/dist/commands/secrets.js +11 -1
- package/dist/commands/sources.js +10 -15
- package/dist/index.js +7 -2
- package/dist/lib/bot/executive-settings.d.ts +13 -0
- package/dist/lib/bot/executive-settings.js +20 -17
- package/dist/lib/bot/executive-sync.d.ts +12 -0
- package/dist/lib/bot/executive-sync.js +36 -0
- package/dist/lib/bot/executive.d.ts +51 -0
- package/dist/lib/bot/executive.js +144 -0
- package/dist/lib/bot/fleet-cron.d.ts +7 -0
- package/dist/lib/bot/fleet-cron.js +2 -1
- package/dist/lib/bot/jobs/executive-handover.d.ts +6 -0
- package/dist/lib/bot/jobs/executive-handover.js +33 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +47 -0
- package/dist/lib/bot/listed-running.d.ts +16 -0
- package/dist/lib/bot/listed-running.js +16 -0
- package/dist/lib/bot/pending-switch.d.ts +51 -0
- package/dist/lib/bot/pending-switch.js +103 -0
- package/dist/lib/bot/run.js +27 -3
- package/dist/lib/bot/runtime-failure.js +19 -3
- package/dist/lib/bot/status.d.ts +20 -0
- package/dist/lib/company-skill-wrapper.js +29 -0
- package/dist/lib/daemon/hq-child-bootstrap.mjs +197 -2
- package/dist/lib/daemon/resolver.d.ts +14 -0
- package/dist/lib/daemon/resolver.js +96 -0
- package/dist/lib/daemon/run.d.ts +11 -0
- package/dist/lib/daemon/run.js +58 -6
- package/dist/lib/daemon/server.d.ts +2 -9
- package/dist/lib/daemon/server.js +3 -89
- package/dist/lib/doctor/checks/claude-wiring.js +41 -0
- package/dist/lib/doctor/checks/sync-health.d.ts +8 -0
- package/dist/lib/doctor/checks/sync-health.js +34 -2
- package/dist/lib/doctor/duplicate-hook-registrations.d.ts +34 -0
- package/dist/lib/doctor/duplicate-hook-registrations.js +130 -0
- package/dist/lib/doctor/fix/apply.js +79 -3
- package/dist/lib/doctor/fix/remediation.d.ts +1 -1
- package/dist/lib/doctor/fix/remediation.js +15 -0
- package/dist/lib/doctor/types.d.ts +1 -1
- package/dist/lib/doctor/types.js +1 -0
- package/dist/lib/mcp/local-native-tools.d.ts +40 -0
- package/dist/lib/mcp/local-native-tools.js +111 -0
- package/dist/lib/mcp/tools.d.ts +2 -0
- package/dist/lib/mcp/tools.js +2 -0
- package/dist/lib/signals/steps/extract.d.ts +1 -1
- package/dist/lib/signals/steps/extract.js +4 -16
- package/dist/sentry-init.js +6 -0
- package/dist/utils/cli-network-lifecycle.d.ts +11 -1
- package/dist/utils/cli-network-lifecycle.js +36 -2
- package/dist/utils/daemon-helper-lifetime.d.ts +39 -0
- package/dist/utils/daemon-helper-lifetime.js +209 -0
- package/dist/utils/daemon-helper-markers.d.ts +24 -0
- package/dist/utils/daemon-helper-markers.js +53 -0
- package/dist/utils/mcp-launcher.d.ts +28 -0
- package/dist/utils/mcp-launcher.js +117 -0
- package/dist/utils/package-use-lease.d.ts +10 -0
- package/dist/utils/package-use-lease.js +31 -0
- package/dist/utils/resident-package-preload.js +4 -1
- package/docs/anywhere-runtime.md +7 -0
- package/package.json +7 -7
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
* background sync is paused is expected to run.
|
|
26
26
|
*/
|
|
27
27
|
import * as fs from "node:fs";
|
|
28
|
+
import * as os from "node:os";
|
|
28
29
|
import * as path from "node:path";
|
|
29
30
|
import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
31
|
+
import { readSyncCoreRolloutState } from "../lib/sync-core/rollout-state.js";
|
|
30
32
|
import { readVaultSyncSwitches, unreadableSwitchesWarning, vaultSkipEnv, } from "../lib/vault-sync-switches.js";
|
|
31
33
|
export { readVaultSyncSwitches, vaultSkipEnv };
|
|
32
34
|
/**
|
|
@@ -43,6 +45,34 @@ export function isCloudOff(home) {
|
|
|
43
45
|
export function isCompanyVaultOff(switches, company) {
|
|
44
46
|
return switches.offCompanies.has(company.trim().toLowerCase());
|
|
45
47
|
}
|
|
48
|
+
export const NO_ENGINE_VAULTS = {
|
|
49
|
+
personal: false,
|
|
50
|
+
companies: new Set(),
|
|
51
|
+
uidSlugs: new Map(),
|
|
52
|
+
};
|
|
53
|
+
export function readEngineOwnedVaults(home = os.homedir()) {
|
|
54
|
+
const state = readSyncCoreRolloutState(home);
|
|
55
|
+
if (!state)
|
|
56
|
+
return NO_ENGINE_VAULTS;
|
|
57
|
+
const held = new Set((state.held ?? []).map((h) => h.uid.toLowerCase()));
|
|
58
|
+
let personal = false;
|
|
59
|
+
const companies = new Set();
|
|
60
|
+
const uidSlugs = new Map();
|
|
61
|
+
for (const vault of state.vaults) {
|
|
62
|
+
if (vault.phase !== "full" || held.has(vault.uid.toLowerCase()))
|
|
63
|
+
continue;
|
|
64
|
+
if (vault.kind === "personal") {
|
|
65
|
+
personal = true;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
const slug = vault.slug?.trim().toLowerCase();
|
|
69
|
+
if (!slug)
|
|
70
|
+
continue;
|
|
71
|
+
companies.add(slug);
|
|
72
|
+
uidSlugs.set(vault.uid.toLowerCase(), slug);
|
|
73
|
+
}
|
|
74
|
+
return { personal, companies, uidSlugs };
|
|
75
|
+
}
|
|
46
76
|
const HOW_TO_TURN_ON = "To turn it back on, open HQ and go to Settings > Sync.";
|
|
47
77
|
const NOTHING_MOVED = "Nothing was uploaded or downloaded. Your local files are unchanged.";
|
|
48
78
|
/**
|
|
@@ -112,21 +142,27 @@ export function resolveVaultRef(ref, hqRoot) {
|
|
|
112
142
|
}
|
|
113
143
|
return { kind: "unknown", ref: trimmed };
|
|
114
144
|
}
|
|
115
|
-
function refusalForVault(command, vault, switches) {
|
|
145
|
+
function refusalForVault(command, vault, switches, engine) {
|
|
146
|
+
const enginePush = command === "push";
|
|
116
147
|
switch (vault.kind) {
|
|
117
148
|
case "personal":
|
|
118
|
-
return switches.personalOff
|
|
149
|
+
return switches.personalOff && !(enginePush && engine.personal)
|
|
119
150
|
? { message: vaultOffMessage(command, "your personal vault"), vault: "personal" }
|
|
120
151
|
: null;
|
|
121
152
|
case "company":
|
|
122
|
-
return isCompanyVaultOff(switches, vault.slug)
|
|
153
|
+
return isCompanyVaultOff(switches, vault.slug) &&
|
|
154
|
+
!(enginePush && engine.companies.has(vault.slug.trim().toLowerCase()))
|
|
123
155
|
? { message: vaultOffMessage(command, vault.slug), vault: vault.slug }
|
|
124
156
|
: null;
|
|
125
|
-
case "unknown":
|
|
157
|
+
case "unknown": {
|
|
158
|
+
const engineSlug = engine.uidSlugs.get(vault.ref.toLowerCase());
|
|
159
|
+
if (engineSlug)
|
|
160
|
+
return refusalForVault(command, { kind: "company", slug: engineSlug }, switches, engine);
|
|
126
161
|
// Fail closed: with any company vault off, an unmapped uid may be it.
|
|
127
162
|
return switches.offCompanies.size > 0
|
|
128
163
|
? { message: unresolvedVaultMessage(command, vault.ref), vault: vault.ref }
|
|
129
164
|
: null;
|
|
165
|
+
}
|
|
130
166
|
}
|
|
131
167
|
}
|
|
132
168
|
/**
|
|
@@ -135,35 +171,35 @@ function refusalForVault(command, vault, switches) {
|
|
|
135
171
|
* With `--creds-from-stdin` and no `--company`, the target is unknown until
|
|
136
172
|
* stdin is parsed; {@link refusalForEntity} checks it then.
|
|
137
173
|
*/
|
|
138
|
-
export function refusalFor(command, selection, switches) {
|
|
174
|
+
export function refusalFor(command, selection, switches, engine = NO_ENGINE_VAULTS) {
|
|
139
175
|
if (switches.allOff)
|
|
140
176
|
return { message: cloudOffMessage(command), vault: "all" };
|
|
141
177
|
if (selection.all)
|
|
142
178
|
return null;
|
|
143
179
|
if (selection.personal === true) {
|
|
144
|
-
return refusalForVault(command, { kind: "personal" }, switches);
|
|
180
|
+
return refusalForVault(command, { kind: "personal" }, switches, engine);
|
|
145
181
|
}
|
|
146
182
|
const ref = selection.company ?? (selection.credsFromStdin ? undefined : readActiveCompanyRef(selection.hqRoot));
|
|
147
183
|
if (!ref)
|
|
148
184
|
return null;
|
|
149
|
-
return refusalForVault(command, resolveVaultRef(ref, selection.hqRoot), switches);
|
|
185
|
+
return refusalForVault(command, resolveVaultRef(ref, selection.hqRoot), switches, engine);
|
|
150
186
|
}
|
|
151
187
|
/**
|
|
152
188
|
* The refusal for a pre-vended EntityContext read from stdin. A `prs_*` uid
|
|
153
189
|
* is the personal vault; otherwise the slug (or the uid, through the
|
|
154
190
|
* manifest) names the company.
|
|
155
191
|
*/
|
|
156
|
-
export function refusalForEntity(command, entity, hqRoot, switches) {
|
|
192
|
+
export function refusalForEntity(command, entity, hqRoot, switches, engine = NO_ENGINE_VAULTS) {
|
|
157
193
|
if (switches.allOff)
|
|
158
194
|
return { message: cloudOffMessage(command), vault: "all" };
|
|
159
195
|
const uid = typeof entity.uid === "string" ? entity.uid : "";
|
|
160
196
|
const slug = typeof entity.slug === "string" ? entity.slug : "";
|
|
161
197
|
if (PERSON_UID.test(uid))
|
|
162
|
-
return refusalForVault(command, { kind: "personal" }, switches);
|
|
198
|
+
return refusalForVault(command, { kind: "personal" }, switches, engine);
|
|
163
199
|
if (slug.trim())
|
|
164
|
-
return refusalForVault(command, { kind: "company", slug }, switches);
|
|
200
|
+
return refusalForVault(command, { kind: "company", slug }, switches, engine);
|
|
165
201
|
if (uid.trim())
|
|
166
|
-
return refusalForVault(command, resolveVaultRef(uid, hqRoot), switches);
|
|
202
|
+
return refusalForVault(command, resolveVaultRef(uid, hqRoot), switches, engine);
|
|
167
203
|
return null;
|
|
168
204
|
}
|
|
169
205
|
/** The vaults an `--all` run leaves out. */
|
|
@@ -215,7 +251,7 @@ function warnIfUnreadable(switches, deps) {
|
|
|
215
251
|
export function refuseSyncForOffVaults(command, selection, deps = {}) {
|
|
216
252
|
const switches = readVaultSyncSwitches(deps.home);
|
|
217
253
|
warnIfUnreadable(switches, deps);
|
|
218
|
-
const refusal = refusalFor(command, selection, switches);
|
|
254
|
+
const refusal = refusalFor(command, selection, switches, readEngineOwnedVaults(deps.home));
|
|
219
255
|
if (refusal) {
|
|
220
256
|
writeVaultRefusal(refusal, deps);
|
|
221
257
|
(deps.exit ?? ((code) => process.exit(code)))(CLOUD_OFF_EXIT_CODE);
|
|
@@ -227,7 +263,7 @@ export function refuseSyncForOffVaults(command, selection, deps = {}) {
|
|
|
227
263
|
* EntityContext targets an off vault. The caller writes it and exits 3.
|
|
228
264
|
*/
|
|
229
265
|
export function assertEntityVaultSyncAllowed(command, entity, hqRoot, home) {
|
|
230
|
-
const refusal = refusalForEntity(command, entity, hqRoot, readVaultSyncSwitches(home));
|
|
266
|
+
const refusal = refusalForEntity(command, entity, hqRoot, readVaultSyncSwitches(home), readEngineOwnedVaults(home));
|
|
231
267
|
if (refusal)
|
|
232
268
|
throw new VaultSyncOffError(refusal);
|
|
233
269
|
}
|
|
@@ -50,6 +50,11 @@ export interface FeedbackSubmitOptions {
|
|
|
50
50
|
logsEnabled?: boolean;
|
|
51
51
|
/** Optional one-way override: callers can mark human sessions as agent. */
|
|
52
52
|
reporterOverride?: "agent";
|
|
53
|
+
/**
|
|
54
|
+
* File the report even when the server would refuse an outdated install.
|
|
55
|
+
* Sent only when true, so existing request bodies stay byte-for-byte.
|
|
56
|
+
*/
|
|
57
|
+
fileAnyway?: boolean;
|
|
53
58
|
}
|
|
54
59
|
export interface FeedbackReporterMark {
|
|
55
60
|
reporter_kind: "agent" | "human";
|
|
@@ -57,6 +62,27 @@ export interface FeedbackReporterMark {
|
|
|
57
62
|
}
|
|
58
63
|
/** Resolve a safe reporter classification without returning any env values. */
|
|
59
64
|
export declare function resolveFeedbackReporter(env?: NodeJS.ProcessEnv, isTTY?: boolean, override?: string): FeedbackReporterMark;
|
|
65
|
+
/** One install the server says is behind the latest release. */
|
|
66
|
+
export interface FeedbackOutdatedPiece {
|
|
67
|
+
piece: string;
|
|
68
|
+
label: string;
|
|
69
|
+
installed: string;
|
|
70
|
+
latest: string;
|
|
71
|
+
update: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* HTTP 409 from POST /v1/feedback when a human bug report comes from an
|
|
75
|
+
* install behind the latest release. `message` is the server `error` string.
|
|
76
|
+
* `outdated` is the server list after dropping entries that are not objects
|
|
77
|
+
* with string fields; a missing or bad list is empty.
|
|
78
|
+
*/
|
|
79
|
+
export declare class FeedbackClientOutdatedError extends Error {
|
|
80
|
+
readonly code = "CLIENT_OUTDATED";
|
|
81
|
+
readonly outdated: FeedbackOutdatedPiece[];
|
|
82
|
+
constructor(message: string, outdated: FeedbackOutdatedPiece[]);
|
|
83
|
+
}
|
|
84
|
+
/** Human text for a CLIENT_OUTDATED refusal. Empty `outdated` returns the server message. */
|
|
85
|
+
export declare function formatClientOutdatedError(err: FeedbackClientOutdatedError): string;
|
|
60
86
|
export declare function readBodyFile(bodyFile: string, stdin?: NodeJS.ReadableStream): Promise<string>;
|
|
61
87
|
/**
|
|
62
88
|
* Attach redacted `~/.hq` log tails to `diagnostics` if, and only if, they fit
|
|
@@ -99,8 +99,78 @@ function buildFeedbackRequestBody(opts) {
|
|
|
99
99
|
}
|
|
100
100
|
if (opts.logBundle)
|
|
101
101
|
requestBody.logBundle = opts.logBundle;
|
|
102
|
+
if (opts.fileAnyway === true)
|
|
103
|
+
requestBody.fileAnyway = true;
|
|
102
104
|
return requestBody;
|
|
103
105
|
}
|
|
106
|
+
const OUTDATED_PIECE_FIELDS = ["piece", "label", "installed", "latest", "update"];
|
|
107
|
+
/**
|
|
108
|
+
* HTTP 409 from POST /v1/feedback when a human bug report comes from an
|
|
109
|
+
* install behind the latest release. `message` is the server `error` string.
|
|
110
|
+
* `outdated` is the server list after dropping entries that are not objects
|
|
111
|
+
* with string fields; a missing or bad list is empty.
|
|
112
|
+
*/
|
|
113
|
+
export class FeedbackClientOutdatedError extends Error {
|
|
114
|
+
code = "CLIENT_OUTDATED";
|
|
115
|
+
outdated;
|
|
116
|
+
constructor(message, outdated) {
|
|
117
|
+
super(message);
|
|
118
|
+
this.name = "FeedbackClientOutdatedError";
|
|
119
|
+
this.outdated = outdated;
|
|
120
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function isClientOutdatedResponse(status, data) {
|
|
124
|
+
if (status !== 409 || data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
125
|
+
return false;
|
|
126
|
+
}
|
|
127
|
+
return data.code === "CLIENT_OUTDATED";
|
|
128
|
+
}
|
|
129
|
+
function parseOutdatedPieces(data) {
|
|
130
|
+
if (!data || typeof data !== "object" || Array.isArray(data))
|
|
131
|
+
return [];
|
|
132
|
+
const raw = data.outdated;
|
|
133
|
+
if (!Array.isArray(raw))
|
|
134
|
+
return [];
|
|
135
|
+
const pieces = [];
|
|
136
|
+
for (const entry of raw) {
|
|
137
|
+
if (!entry || typeof entry !== "object" || Array.isArray(entry))
|
|
138
|
+
continue;
|
|
139
|
+
const record = entry;
|
|
140
|
+
if (!OUTDATED_PIECE_FIELDS.every((key) => typeof record[key] === "string"))
|
|
141
|
+
continue;
|
|
142
|
+
pieces.push({
|
|
143
|
+
piece: record.piece,
|
|
144
|
+
label: record.label,
|
|
145
|
+
installed: record.installed,
|
|
146
|
+
latest: record.latest,
|
|
147
|
+
update: record.update,
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
return pieces;
|
|
151
|
+
}
|
|
152
|
+
/** Human text for a CLIENT_OUTDATED refusal. Empty `outdated` returns the server message. */
|
|
153
|
+
export function formatClientOutdatedError(err) {
|
|
154
|
+
if (err.outdated.length === 0)
|
|
155
|
+
return err.message;
|
|
156
|
+
const details = err.outdated.map((entry) => ` ${entry.label}: installed ${entry.installed}, latest ${entry.latest} -> ${entry.update}`);
|
|
157
|
+
return [
|
|
158
|
+
"Not filed: your HQ install is behind the latest release.",
|
|
159
|
+
...details,
|
|
160
|
+
"Update, try the same steps again, and if the bug is still there re-run with --file-anyway.",
|
|
161
|
+
].join("\n");
|
|
162
|
+
}
|
|
163
|
+
function writeClientOutdatedError(err) {
|
|
164
|
+
console.error("HQ_FEEDBACK_CLIENT_OUTDATED");
|
|
165
|
+
const text = formatClientOutdatedError(err);
|
|
166
|
+
const splitAt = text.indexOf("\n");
|
|
167
|
+
if (splitAt === -1) {
|
|
168
|
+
console.error(chalk.yellow(text));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
console.error(chalk.yellow(text.slice(0, splitAt)));
|
|
172
|
+
console.error(text.slice(splitAt + 1));
|
|
173
|
+
}
|
|
104
174
|
export async function readBodyFile(bodyFile, stdin) {
|
|
105
175
|
if (bodyFile === "-") {
|
|
106
176
|
const stream = stdin ?? process.stdin;
|
|
@@ -179,6 +249,7 @@ export async function submitFeedback(opts) {
|
|
|
179
249
|
screenshots: opts.screenshots,
|
|
180
250
|
logBundle: opts.logBundle,
|
|
181
251
|
reporterMark,
|
|
252
|
+
fileAnyway: opts.fileAnyway,
|
|
182
253
|
});
|
|
183
254
|
// Direct callers can supply attachment references; ensure the complete base
|
|
184
255
|
// envelope still fits before adding optional inline logs or making a request.
|
|
@@ -207,6 +278,9 @@ export async function submitFeedback(opts) {
|
|
|
207
278
|
typeof data.error === "string"
|
|
208
279
|
? data.error
|
|
209
280
|
: res.statusText;
|
|
281
|
+
if (isClientOutdatedResponse(res.status, data)) {
|
|
282
|
+
throw new FeedbackClientOutdatedError(errMsg, parseOutdatedPieces(data));
|
|
283
|
+
}
|
|
210
284
|
throw new Error(`Failed to submit feedback: ${errMsg}`);
|
|
211
285
|
}
|
|
212
286
|
const data = (await res.json());
|
|
@@ -608,7 +682,7 @@ function registerUpdateSubcommand(feedbackCmd) {
|
|
|
608
682
|
});
|
|
609
683
|
}
|
|
610
684
|
function registerSubcommand(feedbackCmd, type) {
|
|
611
|
-
feedbackCmd
|
|
685
|
+
const sub = feedbackCmd
|
|
612
686
|
.command(type)
|
|
613
687
|
.description(type === "bug" ? "Report a bug" : "Request a feature")
|
|
614
688
|
.requiredOption("--title <text>", "Short title for the report")
|
|
@@ -618,8 +692,11 @@ function registerSubcommand(feedbackCmd, type) {
|
|
|
618
692
|
.option("--screenshot <path>", `Attach a screenshot (repeatable, up to ${MAX_SCREENSHOTS}; .png/.jpg/.jpeg/.webp/.gif)`, (value, prev) => [...prev, value], [])
|
|
619
693
|
// Commander turns `--no-logs` into a boolean `logs` that defaults to true,
|
|
620
694
|
// so the default is "attach logs" and the flag is the opt-out.
|
|
621
|
-
.option("--no-logs", "Do not attach redacted tails of your ~/.hq log files (also: HQ_FEEDBACK_LOGS=0)")
|
|
622
|
-
|
|
695
|
+
.option("--no-logs", "Do not attach redacted tails of your ~/.hq log files (also: HQ_FEEDBACK_LOGS=0)");
|
|
696
|
+
if (type === "bug") {
|
|
697
|
+
sub.option("--file-anyway", "File the report even if this HQ install is behind the latest release (the row is stamped as filed on an outdated client)");
|
|
698
|
+
}
|
|
699
|
+
sub.action(async (opts) => {
|
|
623
700
|
try {
|
|
624
701
|
if (opts.reporter !== undefined && (opts.reporter !== "agent" || type !== "bug")) {
|
|
625
702
|
throw new Error("Invalid --reporter value: only bug reports may use 'agent'.");
|
|
@@ -641,6 +718,7 @@ function registerSubcommand(feedbackCmd, type) {
|
|
|
641
718
|
const reporterMark = type === "bug" && resolveProcessFlagGate(FEEDBACK_REPORTER_KIND_FLAG, { fallback: FEEDBACK_REPORTER_KIND_FLAG_FALLBACK }, () => FEEDBACK_REPORTER_KIND_FLAG_FALLBACK)
|
|
642
719
|
? resolveFeedbackReporter(process.env, process.stdin.isTTY === true, opts.reporter)
|
|
643
720
|
: undefined;
|
|
721
|
+
const fileAnyway = type === "bug" && opts.fileAnyway === true ? true : undefined;
|
|
644
722
|
// Validate the serialized server request envelope before screenshots
|
|
645
723
|
// or the log bundle can create remote objects. Attachment references
|
|
646
724
|
// are added and checked again inside submitFeedback after upload.
|
|
@@ -651,6 +729,7 @@ function registerSubcommand(feedbackCmd, type) {
|
|
|
651
729
|
company: opts.company,
|
|
652
730
|
diagnostics,
|
|
653
731
|
reporterMark,
|
|
732
|
+
fileAnyway,
|
|
654
733
|
}));
|
|
655
734
|
// vaultApiFetch can reject an hqk_ token or an invalid API base URL
|
|
656
735
|
// locally before fetch. Check the mandatory POST, and the screenshot
|
|
@@ -688,14 +767,21 @@ function registerSubcommand(feedbackCmd, type) {
|
|
|
688
767
|
diagnostics,
|
|
689
768
|
reporterOverride: opts.reporter === "agent" ? "agent" : undefined,
|
|
690
769
|
logsEnabled,
|
|
770
|
+
fileAnyway,
|
|
691
771
|
});
|
|
692
772
|
console.log(`Submitted: ${result.id}`);
|
|
693
773
|
if (result.publicUrl)
|
|
694
774
|
console.log(`Track: ${result.publicUrl}`);
|
|
695
775
|
}
|
|
696
776
|
catch (err) {
|
|
697
|
-
|
|
698
|
-
|
|
777
|
+
if (type === "bug" && err instanceof FeedbackClientOutdatedError) {
|
|
778
|
+
writeClientOutdatedError(err);
|
|
779
|
+
process.exit(1);
|
|
780
|
+
}
|
|
781
|
+
else {
|
|
782
|
+
console.error(chalk.red("Error:"), err instanceof Error ? err.message : String(err));
|
|
783
|
+
process.exit(1);
|
|
784
|
+
}
|
|
699
785
|
}
|
|
700
786
|
});
|
|
701
787
|
}
|
|
@@ -11,8 +11,10 @@ export interface GlobalInstallOptions {
|
|
|
11
11
|
env?: NodeJS.ProcessEnv;
|
|
12
12
|
/** Absolute node binary for the MCP server command (default process.execPath). */
|
|
13
13
|
nodePath?: string;
|
|
14
|
-
/** Absolute hq CLI entry script (default
|
|
14
|
+
/** Absolute hq CLI entry script (default: stable unversioned path of the running CLI). */
|
|
15
15
|
cliEntry?: string;
|
|
16
|
+
/** Running CLI script for stable-entry discovery (default process.argv[1]); test seam. */
|
|
17
|
+
argv1?: string;
|
|
16
18
|
/** Registry file override (default ~/.hq/registry.json under `home`). */
|
|
17
19
|
registryFile?: string;
|
|
18
20
|
log?: (line: string) => void;
|
|
@@ -15,6 +15,7 @@ import * as path from 'path';
|
|
|
15
15
|
import { spawnSync } from 'node:child_process';
|
|
16
16
|
import { buildCodexServerDef, claudeConfigFormat, codexConfigFormat, codexRemovalFormat, isCodexInstalled, jsonFormat, mergeCodexServer, removeCodexServer, registerCodexServer, unregisterCodexServer, mergeClaudeServer, readConfigDoc, realpathOrSelf, registerClaudeServer, resolveEnv, unregisterClaudeServer, writeConfigAtomic, } from './mcp-registration.js';
|
|
17
17
|
import { seedRegistryFromHqRoot } from './link.js';
|
|
18
|
+
import { resolveMcpLaunch } from '../utils/mcp-launcher.js';
|
|
18
19
|
import { resolveHqRoot } from './doctor.js';
|
|
19
20
|
import { anywhereRuntimeEnabled, AnywhereRuntimeDisabledError } from './anywhere-runtime-flag.js';
|
|
20
21
|
import { resolveHqMcpEndpoint } from '../lib/daemon/mcp-endpoint.js';
|
|
@@ -30,7 +31,7 @@ import { assertProviderWrappersInstallable, installProviderWrappers, providerWra
|
|
|
30
31
|
import { checkShimOnPath, ensureShimOnUserPath, npmShimDir, shimPathWarning } from '../lib/windows/user-path.js';
|
|
31
32
|
import { removeHqCliPs1Shims } from '../lib/windows/ps1-shims.js';
|
|
32
33
|
import { addAgentsMdBlock, addCodexHooks, classifyLegacySkills, codexAdapterPath, codexCharterSource, codexHookTrustKeys, codexTargets, hasAllCodexHooks, HQ_OWNED_MARKER, LEGACY_BACKUP_NAME, LEGACY_SKILLS_NAME, removeAgentsMdBlock, removeCodexHooks, } from '../lib/install/codex-targets.js';
|
|
33
|
-
import { addClaudeMdBlock, addHqHooks, charterPath, claudeTargets, hasAllHqHooks, HQ_ANYWHERE_PACK, HQ_MCP_SERVER_NAME, hqSkillsSource, lineDiff, masterHookPath, shimPath,
|
|
34
|
+
import { addClaudeMdBlock, addHqHooks, charterPath, claudeTargets, hasAllHqHooks, HQ_ANYWHERE_PACK, HQ_MCP_SERVER_NAME, hqSkillsSource, lineDiff, masterHookPath, shimPath, removeClaudeMdBlock, removeHqHooks, SKILL_LINK_PREFIX, } from '../lib/install/claude-targets.js';
|
|
34
35
|
export { hookTargetFor, isDaemonInstalled } from '../lib/install/hook-target.js';
|
|
35
36
|
const HQ_PACKAGES_MARKETPLACE_REPOSITORY = 'indigoai-us/hq-packages';
|
|
36
37
|
/** Resolve local overrides first, then the published HQ marketplace. */
|
|
@@ -179,13 +180,23 @@ function restoringRemovalFormat(original, stillPresent) {
|
|
|
179
180
|
};
|
|
180
181
|
}
|
|
181
182
|
function mcpManifest(opts) {
|
|
182
|
-
|
|
183
|
-
|
|
183
|
+
// Absolute node + an unversioned entry path of the running CLI: a realpath'd
|
|
184
|
+
// entry points into a version-pinned store directory that runs an old CLI
|
|
185
|
+
// after the next update, and a bare/shim `hq` needs PATH and a shell.
|
|
186
|
+
const launch = resolveMcpLaunch({
|
|
187
|
+
execPath: opts.nodePath ?? process.execPath,
|
|
188
|
+
argv1: opts.argv1 ?? process.argv[1] ?? '',
|
|
189
|
+
env: opts.env ?? process.env,
|
|
190
|
+
platform: opts.platform ?? process.platform,
|
|
191
|
+
home: opts.home,
|
|
192
|
+
});
|
|
193
|
+
const command = opts.nodePath ?? launch.command;
|
|
194
|
+
const entry = opts.cliEntry ?? launch.entry;
|
|
184
195
|
for (const p of [command, entry]) {
|
|
185
196
|
if (!path.isAbsolute(p))
|
|
186
197
|
throw new Error(`HQ MCP server path must be absolute: ${p}`);
|
|
187
198
|
}
|
|
188
|
-
return { type: 'stdio', command, args: [entry, 'mcp', 'serve'], env: { PATH:
|
|
199
|
+
return { type: 'stdio', command, args: [entry, 'mcp', 'serve'], env: { PATH: launch.path } };
|
|
189
200
|
}
|
|
190
201
|
/**
|
|
191
202
|
* The folder an HQ skill entry stands for: a link's resolved target, or the
|
package/dist/commands/lanes.d.ts
CHANGED
|
@@ -174,6 +174,8 @@ export declare function createLaneFromSignal(input: {
|
|
|
174
174
|
lane_id: string;
|
|
175
175
|
existing: boolean;
|
|
176
176
|
}>;
|
|
177
|
+
/** Project label for lanes created with --no-story and no --project. */
|
|
178
|
+
export declare const NO_STORY_DEFAULT_PROJECT = "standing";
|
|
177
179
|
/** @internal Exported for regression tests of the profile-refresh company check. */
|
|
178
180
|
export declare function applyResumeProfileAndEffort(hqRoot: string, current: LaneRecord, next: LaneRecord, input: {
|
|
179
181
|
profile?: ResolvedResumeProfile;
|
package/dist/commands/lanes.js
CHANGED
|
@@ -3478,6 +3478,8 @@ export async function createLaneFromSignal(input, deps = {}) {
|
|
|
3478
3478
|
noStory: `signal:${input.signal_id}`, freshThread: true, quiet: true }));
|
|
3479
3479
|
return { lane_id: result.lane.lane_id, existing: result.existing };
|
|
3480
3480
|
}
|
|
3481
|
+
/** Project label for lanes created with --no-story and no --project. */
|
|
3482
|
+
export const NO_STORY_DEFAULT_PROJECT = "standing";
|
|
3481
3483
|
async function runCreate(ctx, opts) {
|
|
3482
3484
|
if (opts.signal !== undefined) {
|
|
3483
3485
|
if (!opts.company?.trim())
|
|
@@ -3514,9 +3516,11 @@ async function runCreate(ctx, opts) {
|
|
|
3514
3516
|
}
|
|
3515
3517
|
const companyFlag = opts.company?.trim();
|
|
3516
3518
|
const meshCompanyFlag = opts.meshCompany?.trim();
|
|
3517
|
-
const project = opts.project?.trim();
|
|
3518
3519
|
const story = opts.story?.trim();
|
|
3519
3520
|
const noStoryReason = opts.noStory?.trim();
|
|
3521
|
+
// A story-less lane (conduct standing lanes) has no project to attribute
|
|
3522
|
+
// to, so it falls back to a shared project label instead of failing.
|
|
3523
|
+
const project = opts.project?.trim() || (!story && noStoryReason ? NO_STORY_DEFAULT_PROJECT : undefined);
|
|
3520
3524
|
const additionalStories = (opts.additionalStory ?? []).map((value) => value.trim());
|
|
3521
3525
|
const briefFile = opts.briefFile?.trim();
|
|
3522
3526
|
if (!project) {
|
|
@@ -9152,9 +9156,11 @@ async function runCreateSubagent(ctx, opts) {
|
|
|
9152
9156
|
}
|
|
9153
9157
|
}
|
|
9154
9158
|
const hqRoot = ctx.hqRoot();
|
|
9155
|
-
const project = opts.project?.trim();
|
|
9156
9159
|
const story = opts.story?.trim();
|
|
9157
9160
|
const noStoryReason = opts.noStory?.trim();
|
|
9161
|
+
// A story-less lane (conduct standing lanes) has no project to attribute
|
|
9162
|
+
// to, so it falls back to a shared project label instead of failing.
|
|
9163
|
+
const project = opts.project?.trim() || (!story && noStoryReason ? NO_STORY_DEFAULT_PROJECT : undefined);
|
|
9158
9164
|
const additionalStories = (opts.additionalStory ?? []).map((value) => value.trim());
|
|
9159
9165
|
const briefFile = opts.briefFile?.trim();
|
|
9160
9166
|
if (!project)
|
|
@@ -10527,7 +10533,7 @@ export function registerLanesCommand(parent, deps = {}) {
|
|
|
10527
10533
|
.description("Register a lane, run admission, and return immediately")
|
|
10528
10534
|
.option("--company <slug|uid>", "Company slug or cloud uid; omit for a core/personal lane")
|
|
10529
10535
|
.option("--mesh-company <slug|uid>", "Explicit Work Mesh company for a personal lane; membership is verified")
|
|
10530
|
-
.option("--project <slug>", "HQ project slug (executive-bot for --signal)")
|
|
10536
|
+
.option("--project <slug>", "HQ project slug (executive-bot for --signal; defaults to standing with --no-story)")
|
|
10531
10537
|
.option("--signal <id>", "Create one lane for a company signal")
|
|
10532
10538
|
.option("--rules-file <path>", "Standing rules for a signal lane")
|
|
10533
10539
|
.option("--any-type", "Allow signal types other than action_item")
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* under 100ms. The MCP SDK is not loaded either: the stdio transport is
|
|
9
9
|
* newline-delimited JSON-RPC 2.0 and is handled here directly.
|
|
10
10
|
*
|
|
11
|
-
* When hqd is
|
|
12
|
-
*
|
|
11
|
+
* When hqd is not running, hq_resolve_company, hq_policy_check and
|
|
12
|
+
* hq_journal_append are answered in process with the same checks
|
|
13
|
+
* (src/lib/mcp/local-native-tools.ts), provided an HQ root is known. Every
|
|
14
|
+
* other tool call returns an isError result naming `hq daemon status`, and
|
|
15
|
+
* the server keeps running.
|
|
13
16
|
*/
|
|
14
17
|
export declare const MCP_PROTOCOL_VERSIONS: readonly ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
15
18
|
export interface McpServeOptions {
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
* under 100ms. The MCP SDK is not loaded either: the stdio transport is
|
|
9
9
|
* newline-delimited JSON-RPC 2.0 and is handled here directly.
|
|
10
10
|
*
|
|
11
|
-
* When hqd is
|
|
12
|
-
*
|
|
11
|
+
* When hqd is not running, hq_resolve_company, hq_policy_check and
|
|
12
|
+
* hq_journal_append are answered in process with the same checks
|
|
13
|
+
* (src/lib/mcp/local-native-tools.ts), provided an HQ root is known. Every
|
|
14
|
+
* other tool call returns an isError result naming `hq daemon status`, and
|
|
15
|
+
* the server keeps running.
|
|
13
16
|
*/
|
|
14
17
|
import * as fs from "node:fs";
|
|
15
18
|
import * as os from "node:os";
|
|
@@ -21,6 +24,9 @@ import { releaseCurrentPackageUseLease, releasePackageUseLeaseAfterResidentPrelo
|
|
|
21
24
|
import { preloadResidentPackageModules, reportResidentPackagePreloadFailure, RESIDENT_PACKAGE_MODULES } from "../utils/resident-package-preload.js";
|
|
22
25
|
export const MCP_PROTOCOL_VERSIONS = ["2025-06-18", "2025-03-26", "2024-11-05"];
|
|
23
26
|
const UNREACHABLE_CODES = new Set(["ENOENT", "ECONNREFUSED", "ECONNRESET", "EPIPE", "ETIMEDOUT", "ESOCKET", "EACCES"]);
|
|
27
|
+
/** hqd is not running, so the request never reached it and a local answer cannot repeat a write. */
|
|
28
|
+
const NOT_RUNNING_CODES = new Set(["ENOENT", "ECONNREFUSED"]);
|
|
29
|
+
const LOCAL_GATE_TTL_MS = 60_000;
|
|
24
30
|
function hasPersonTokenCache(env, home) {
|
|
25
31
|
// Mirrors personTokenCacheFile() in utils/cognito-session.ts; duplicated so this path does not load that module.
|
|
26
32
|
const stateDir = env.HQ_STATE_DIR?.trim() || path.join(home, ".hq");
|
|
@@ -101,6 +107,39 @@ export async function runMcpServe(opts = {}) {
|
|
|
101
107
|
};
|
|
102
108
|
const reply = (id, result) => send({ id, result });
|
|
103
109
|
const replyError = (id, code, message) => send({ id, error: { code, message } });
|
|
110
|
+
// hqd keeps a gate decision for at most 60 seconds; the local fallback does the same.
|
|
111
|
+
let gateAllowedAt;
|
|
112
|
+
const localRuntimeEnabled = async () => {
|
|
113
|
+
if (gateAllowedAt !== undefined && Date.now() - gateAllowedAt < LOCAL_GATE_TTL_MS)
|
|
114
|
+
return true;
|
|
115
|
+
gateAllowedAt = undefined;
|
|
116
|
+
const allowed = await runtimeAllowed();
|
|
117
|
+
if (allowed)
|
|
118
|
+
gateAllowedAt = Date.now();
|
|
119
|
+
return allowed;
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* Answer a local-only native tool in process when hqd is unreachable.
|
|
123
|
+
* Returns undefined when the tool needs hqd or no HQ root is known.
|
|
124
|
+
*/
|
|
125
|
+
const callLocally = async (name, args) => {
|
|
126
|
+
const local = await import("../lib/mcp/local-native-tools.js");
|
|
127
|
+
if (!local.LOCAL_NATIVE_TOOL_NAMES.has(name))
|
|
128
|
+
return undefined;
|
|
129
|
+
const hqRoot = readHqRoot(env, home);
|
|
130
|
+
if (!hqRoot)
|
|
131
|
+
return undefined;
|
|
132
|
+
try {
|
|
133
|
+
const value = await local.callLocalNativeTool(name, args, { hqRoot, home, env, cwd, runtimeEnabled: localRuntimeEnabled });
|
|
134
|
+
return { content: [{ type: "text", text: JSON.stringify(value, null, 2) }], structuredContent: value };
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
const code = local.localToolErrorCode(err);
|
|
138
|
+
if (code === null)
|
|
139
|
+
return toolError("internal", err instanceof Error ? err.message : String(err));
|
|
140
|
+
return toolError(code, err.message);
|
|
141
|
+
}
|
|
142
|
+
};
|
|
104
143
|
const callTool = async (params) => {
|
|
105
144
|
const { tools } = await getPackageHandlers();
|
|
106
145
|
const name = params.name;
|
|
@@ -115,6 +154,9 @@ export async function runMcpServe(opts = {}) {
|
|
|
115
154
|
if (!(err instanceof HqdClientError))
|
|
116
155
|
throw err;
|
|
117
156
|
if (UNREACHABLE_CODES.has(err.code)) {
|
|
157
|
+
const local = NOT_RUNNING_CODES.has(err.code) ? await callLocally(name, args) : undefined;
|
|
158
|
+
if (local !== undefined)
|
|
159
|
+
return local;
|
|
118
160
|
return toolError("hqd_unreachable", `The HQ daemon (hqd) is not reachable at ${socketPath}. Run \`hq daemon status\` to check it, and \`hq daemon install\` if it is not installed. (${err.code})`);
|
|
119
161
|
}
|
|
120
162
|
return toolError(err.code, err.message);
|
|
@@ -132,7 +174,7 @@ export async function runMcpServe(opts = {}) {
|
|
|
132
174
|
protocolVersion,
|
|
133
175
|
capabilities: { tools: { listChanged: false }, prompts: { listChanged: false } },
|
|
134
176
|
serverInfo: { name: "hq", version: CLI_VERSION },
|
|
135
|
-
instructions: "HQ tools, answered by the local HQ daemon. hq_resolve_company tells you which company the current repo belongs to; call it before company-scoped tools. If a tool returns hqd_unreachable, ask the user to run `hq daemon status`.",
|
|
177
|
+
instructions: "HQ tools, answered by the local HQ daemon. hq_resolve_company tells you which company the current repo belongs to; call it before company-scoped tools. hq_resolve_company, hq_policy_check and hq_journal_append still work when hqd is stopped. If a tool returns hqd_unreachable, ask the user to run `hq daemon status`.",
|
|
136
178
|
});
|
|
137
179
|
return;
|
|
138
180
|
}
|
|
@@ -93,7 +93,9 @@ export interface McpStatusReport {
|
|
|
93
93
|
* differ). A malformed config marks that runtime `parses:false`/`unparseable`
|
|
94
94
|
* rather than throwing. Header VALUES are never read into the report.
|
|
95
95
|
*/
|
|
96
|
-
export declare function computeMcpStatus(env: SafeWriteEnv
|
|
96
|
+
export declare function computeMcpStatus(env: SafeWriteEnv, opts?: {
|
|
97
|
+
runningCliEntry?: string;
|
|
98
|
+
}): McpStatusReport;
|
|
97
99
|
/**
|
|
98
100
|
* Render the report as human-readable text. Per server: name, pack, transport,
|
|
99
101
|
* target, and a per-runtime line. PARTIAL servers are marked loudly with the
|