@indigoai-us/hq-cli 5.345.251 → 5.345.253
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 +153 -0
- package/assets/scaffold/core/scripts/hq-session.sh +9 -0
- package/contracts/host-canary-release.json +9 -3
- package/dist/command-catalog.generated.d.ts +269 -1
- package/dist/command-catalog.generated.js +330 -1
- package/dist/command-registration-plan.d.ts +6 -0
- package/dist/command-registration-plan.js +1 -0
- package/dist/commands/bot.js +7 -2
- package/dist/commands/ci-intake.d.ts +15 -0
- package/dist/commands/ci-intake.js +252 -0
- package/dist/commands/ci-metrics.d.ts +8 -0
- package/dist/commands/ci-metrics.js +55 -0
- package/dist/commands/ci.d.ts +13 -0
- package/dist/commands/ci.js +10 -0
- package/dist/commands/core-bucket-c-work-mesh-offer-native.js +1 -1
- package/dist/commands/core-hq-session-binding.d.ts +140 -0
- package/dist/commands/core-hq-session-binding.js +363 -0
- package/dist/commands/core-hq-session-native.d.ts +23 -0
- package/dist/commands/core-hq-session-native.js +59 -9
- package/dist/commands/core-stop-autosave.js +1 -1
- package/dist/commands/core.js +10 -0
- package/dist/commands/doctor.d.ts +5 -1
- package/dist/commands/doctor.js +42 -5
- package/dist/commands/files.d.ts +62 -0
- package/dist/commands/files.js +250 -9
- package/dist/commands/install-global.js +4 -2
- package/dist/commands/logout.js +4 -0
- package/dist/commands/ontology-graph.d.ts +2 -0
- package/dist/commands/ontology-graph.js +33 -0
- package/dist/commands/report.js +35 -2
- package/dist/commands/storage-gate.js +1 -1
- package/dist/commands/vault-retention-flag.js +2 -1
- package/dist/commands/whoami.js +1 -1
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +238 -221
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/agent-kit/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +48 -0
- package/dist/lib/bot/fleet-bots-update-pass.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +50 -0
- package/dist/lib/bot/fleet-cron.js +173 -32
- package/dist/lib/bot/fleet-local.d.ts +18 -0
- package/dist/lib/bot/fleet-local.js +51 -5
- package/dist/lib/bot/inbox-poll-backoff-flag.js +1 -1
- package/dist/lib/bot/signals-engine-flag.d.ts +1 -1
- package/dist/lib/bot/signals-engine-flag.js +1 -1
- package/dist/lib/cli-invite-nudge.js +1 -1
- package/dist/lib/client-version.d.ts +2 -0
- package/dist/lib/client-version.js +24 -0
- package/dist/lib/company-flag-gate.d.ts +30 -0
- package/dist/lib/company-flag-gate.js +104 -0
- package/dist/lib/core-utils/hook-timeout-debug-context-flag.js +1 -1
- package/dist/lib/daemon/flag.js +2 -1
- package/dist/lib/daemon/legacy-journal-gate.js +3 -1
- package/dist/lib/daemon/run.js +4 -3
- package/dist/lib/daemon/shared-flag-reads.js +1 -1
- package/dist/lib/delivery/migrations.d.ts +32 -1
- package/dist/lib/delivery/migrations.js +69 -8
- package/dist/lib/doctor/checks/host-core.js +22 -4
- package/dist/lib/doctor/checks/jq.d.ts +27 -6
- package/dist/lib/doctor/checks/jq.js +46 -8
- package/dist/lib/doctor/client-health-reason-codes-flag.js +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.d.ts +1 -1
- package/dist/lib/doctor/fix/refresh-sync-handoff.js +1 -1
- package/dist/lib/flag-client-gate-headers.d.ts +38 -0
- package/dist/lib/flag-client-gate-headers.js +62 -0
- package/dist/lib/flag-client-headers.d.ts +15 -0
- package/dist/lib/flag-client-headers.js +25 -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/flag-registry-worker.js +35 -0
- package/dist/lib/flag-registry.d.ts +1 -20
- package/dist/lib/flag-registry.js +5 -81
- package/dist/lib/hook-engine/adapter-core-pin.d.ts +30 -0
- package/dist/lib/hook-engine/adapter-core-pin.js +30 -0
- package/dist/lib/hook-engine/coverage.d.ts +65 -1
- package/dist/lib/hook-engine/coverage.js +173 -8
- package/dist/lib/hook-engine/reconcile.js +3 -2
- package/dist/lib/hot-channels/prompts/signals-pass.md +20 -0
- package/dist/lib/hot-channels/signal-changes.d.ts +228 -0
- package/dist/lib/hot-channels/signal-changes.js +683 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +24 -0
- package/dist/lib/hot-channels/signals-pass.js +232 -12
- package/dist/lib/lanes/outpost-worktree-pruner-flag.d.ts +1 -1
- package/dist/lib/lanes/outpost-worktree-pruner-flag.js +1 -1
- package/dist/lib/lanes/registry-flag.js +2 -1
- package/dist/lib/lanes/spawn.js +11 -1
- package/dist/lib/mesh/live/binding-intent.d.ts +61 -0
- package/dist/lib/mesh/live/binding-intent.js +201 -0
- package/dist/lib/mesh/live/binding-receipt.d.ts +157 -0
- package/dist/lib/mesh/live/binding-receipt.js +365 -0
- package/dist/lib/mesh/live/company-flag-refresh.js +1 -1
- package/dist/lib/mesh/live/daemon/doctor-telemetry.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/doctor-telemetry.js +58 -0
- package/dist/lib/mesh/live/daemon/install.js +2 -1
- package/dist/lib/mesh/live/daemon/presence.js +9 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +3 -0
- package/dist/lib/mesh/live/daemon/run.js +33 -1
- package/dist/lib/ontology-graph/lineage/index.d.ts +401 -0
- package/dist/lib/ontology-graph/lineage/index.js +1027 -0
- package/dist/lib/ontology-graph/model/index.d.ts +54 -0
- package/dist/lib/ontology-graph/model/index.js +112 -0
- package/dist/lib/ontology-graph/model/pass-tasks.d.ts +75 -0
- package/dist/lib/ontology-graph/model/pass-tasks.js +166 -0
- package/dist/lib/ontology-graph/model/pass.d.ts +6 -0
- package/dist/lib/ontology-graph/model/pass.js +9 -2
- package/dist/lib/ontology-graph/model/pending-items.d.ts +8 -0
- package/dist/lib/ontology-graph/model/pending-items.js +24 -1
- package/dist/lib/ontology-graph/model/step.d.ts +1 -1
- package/dist/lib/ontology-graph/model/tasks.d.ts +11 -3
- package/dist/lib/ontology-graph/model/tasks.js +20 -7
- package/dist/lib/ontology-graph/read/brief.js +41 -6
- package/dist/lib/ontology-graph/read/index.d.ts +4 -0
- package/dist/lib/ontology-graph/read/index.js +173 -29
- package/dist/lib/ontology-graph/read/lineage.d.ts +101 -0
- package/dist/lib/ontology-graph/read/lineage.js +262 -0
- package/dist/lib/ontology-graph/replay/buffered-store.js +17 -0
- package/dist/lib/ontology-graph/replay/engine.d.ts +32 -1
- package/dist/lib/ontology-graph/replay/engine.js +213 -8
- package/dist/lib/ontology-graph/replay/extractors.d.ts +26 -0
- package/dist/lib/ontology-graph/replay/extractors.js +25 -1
- package/dist/lib/ontology-graph/replay/index.d.ts +2 -0
- package/dist/lib/ontology-graph/replay/index.js +9 -3
- package/dist/lib/ontology-graph/replay/signal-changes.d.ts +118 -0
- package/dist/lib/ontology-graph/replay/signal-changes.js +687 -0
- package/dist/lib/ontology-graph/schema/decision-status.d.ts +18 -0
- package/dist/lib/ontology-graph/schema/decision-status.js +20 -0
- package/dist/lib/ontology-graph/schema/index.d.ts +1 -0
- package/dist/lib/ontology-graph/schema/index.js +1 -0
- package/dist/lib/ontology-graph/setup/index.js +13 -3
- package/dist/lib/search-index/index.d.ts +33 -1
- package/dist/lib/search-index/index.js +180 -25
- package/dist/lib/search-index/qmd-exit-diagnostics.d.ts +7 -0
- package/dist/lib/search-index/qmd-exit-diagnostics.js +25 -1
- package/dist/lib/signals/adapters-catalog.js +1 -1
- package/dist/lib/smart-ci/cost.d.ts +72 -0
- package/dist/lib/smart-ci/cost.js +120 -0
- package/dist/lib/smart-ci/github.d.ts +112 -0
- package/dist/lib/smart-ci/github.js +267 -0
- package/dist/lib/smart-ci/intake.d.ts +288 -0
- package/dist/lib/smart-ci/intake.js +1078 -0
- package/dist/lib/smart-ci/ledger.d.ts +218 -0
- package/dist/lib/smart-ci/ledger.js +527 -0
- package/dist/lib/smart-ci/metrics.d.ts +137 -0
- package/dist/lib/smart-ci/metrics.js +249 -0
- package/dist/lib/smart-ci/records.d.ts +265 -0
- package/dist/lib/smart-ci/records.js +281 -0
- package/dist/lib/smart-ci/reducer.d.ts +67 -0
- package/dist/lib/smart-ci/reducer.js +261 -0
- package/dist/lib/sync-core/engine-holds.d.ts +15 -0
- package/dist/lib/sync-core/engine-holds.js +104 -11
- package/dist/lib/sync-core/engine-home.d.ts +3 -0
- package/dist/lib/sync-core/engine-home.js +41 -1
- package/dist/lib/sync-core/flag.js +2 -1
- package/dist/lib/sync-core/hand-back.d.ts +1 -0
- package/dist/lib/sync-core/hand-back.js +7 -2
- package/dist/lib/sync-core/legacy-journal-export-child.js +5 -3
- package/dist/lib/sync-core/legacy-journal-export.d.ts +23 -4
- package/dist/lib/sync-core/legacy-journal-export.js +120 -55
- package/dist/lib/sync-core/reconcile.d.ts +2 -1
- package/dist/lib/sync-core/reconcile.js +40 -7
- package/dist/lib/sync-invalid-entity-warning.js +2 -1
- package/dist/lib/windows/install-followup.d.ts +41 -0
- package/dist/lib/windows/install-followup.js +87 -0
- package/dist/lib/windows/jq.d.ts +59 -0
- package/dist/lib/windows/jq.js +154 -3
- package/dist/lib/windows/user-path.d.ts +5 -0
- package/dist/lib/windows/user-path.js +1 -1
- package/dist/lib/work-context/auto-bind.d.ts +12 -0
- package/dist/lib/work-context/auto-bind.js +49 -3
- package/dist/lib/work-context/organize.d.ts +4 -2
- package/dist/lib/work-context/organize.js +18 -8
- package/dist/lib/work-context/reconcile.js +16 -1
- package/dist/main.js +12 -1
- package/dist/utils/client-health-contract.d.ts +30 -0
- package/dist/utils/client-health-contract.js +111 -0
- package/dist/utils/client-health.d.ts +5 -2
- package/dist/utils/client-health.js +74 -5
- package/dist/utils/exclusive-lock.d.ts +5 -1
- package/dist/utils/exclusive-lock.js +9 -2
- package/dist/utils/host-registration.d.ts +7 -0
- package/dist/utils/host-registration.js +10 -1
- package/dist/utils/pid.d.ts +31 -0
- package/dist/utils/pid.js +65 -0
- package/dist/utils/resident-package-preload.js +12 -4
- package/dist/utils/sentry-fingerprint.js +3 -0
- package/package.json +10 -8
- package/scripts/install-hook-engine.mjs +5 -3
package/dist/commands/doctor.js
CHANGED
|
@@ -33,7 +33,8 @@ import { DEEP_FAMILY_ID, DEEP_FAMILY_TITLE, runDeepGuardTests, } from "../lib/do
|
|
|
33
33
|
import { PARITY_FAMILY_ID, PARITY_FAMILY_TITLE, runParityReplay, } from "../lib/doctor/deep/parity.js";
|
|
34
34
|
import { applyFixes } from "../lib/doctor/fix/apply.js";
|
|
35
35
|
import { renderDoctorFixJson } from "../lib/doctor/fix/json-output.js";
|
|
36
|
-
import {
|
|
36
|
+
import { verifyJqForNewSessions } from "../lib/doctor/checks/jq.js";
|
|
37
|
+
import { ensureWindowsJq, jqRemainingStep } from "../lib/windows/jq.js";
|
|
37
38
|
import { clientHealthCheckStatusEnabled as isActiveCompanyClientHealthCheckStatusEnabled, clientHealthCheckStatusEnabledForCompany, clientHealthReasonCodesEnabled as isActiveCompanyClientHealthReasonCodesEnabled, clientHealthReasonCodesEnabledForCompany, } from "../lib/doctor/client-health-reason-codes-flag.js";
|
|
38
39
|
import { clientHealthCompanyScopeFromCheckId } from "../lib/doctor/checks/sync-health.js";
|
|
39
40
|
import { readCompaniesManifestMap } from "../lib/work-context/repo-remote.js";
|
|
@@ -356,7 +357,7 @@ export function registerDoctorCommand(program, deps = {}) {
|
|
|
356
357
|
.option("--company <slug>", "Company slug for integrations checks (otherwise resolves your single active company).")
|
|
357
358
|
.option("--only <families>", "Run only these comma-separated check families (e.g. hooks). Unknown names are rejected; --json then records the scope.")
|
|
358
359
|
.option("--fix", "Apply the allowlisted safe repairs (backs up first; read-only without this flag).")
|
|
359
|
-
.option("--fix-jq", "Install the verified jq required by HQ hooks on Windows.")
|
|
360
|
+
.option("--fix-jq", "Install the verified jq required by HQ hooks on Windows, add it to your PATH, and check it.")
|
|
360
361
|
.addOption(new Option("--client-health-report", "Resolve the opt-in hq-flags gate used by the client-health report hook.").hideHelp())
|
|
361
362
|
.option("--sweep-temp-homes", "Delete idle temp homes (90+ minutes untouched, not in use): tmp.* folders holding .rustup or .cargo, and hq-temp-home.* folders left by the wrapper. Reports GB freed.")
|
|
362
363
|
.option("--dry-run", "With --sweep-temp-homes, list what would be removed and delete nothing.")
|
|
@@ -370,10 +371,46 @@ export function registerDoctorCommand(program, deps = {}) {
|
|
|
370
371
|
return;
|
|
371
372
|
}
|
|
372
373
|
try {
|
|
373
|
-
const
|
|
374
|
-
if (!
|
|
374
|
+
const ensured = await (deps.ensureWindowsJq ?? ensureWindowsJq)();
|
|
375
|
+
if (!ensured)
|
|
375
376
|
throw new Error("The managed jq repair is only available on Windows.");
|
|
376
|
-
|
|
377
|
+
// Installed is not repaired (hq-cli #3716): finish with the same
|
|
378
|
+
// check `hq doctor` runs, against the PATH a new session will get.
|
|
379
|
+
const check = (deps.verifyJq ?? verifyJqForNewSessions)()[0] ?? {
|
|
380
|
+
status: "FAIL",
|
|
381
|
+
checkId: "jq.on-path",
|
|
382
|
+
message: "The jq check returned no result.",
|
|
383
|
+
};
|
|
384
|
+
const ok = check.status === "PASS";
|
|
385
|
+
const remaining = ok ? undefined : jqRemainingStep(ensured, check);
|
|
386
|
+
if (opts.json) {
|
|
387
|
+
process.stdout.write(`${JSON.stringify({
|
|
388
|
+
target: ensured.target,
|
|
389
|
+
...(ensured.sessionTarget === undefined ? {} : { sessionTarget: ensured.sessionTarget }),
|
|
390
|
+
onPath: ok,
|
|
391
|
+
userPath: ensured.path,
|
|
392
|
+
check: { status: check.status, message: check.message },
|
|
393
|
+
...(remaining === undefined ? {} : { remaining }),
|
|
394
|
+
})}\n`);
|
|
395
|
+
}
|
|
396
|
+
else if (ok) {
|
|
397
|
+
// The check can pass through another jq, or the copy beside
|
|
398
|
+
// hq.cmd, when the PATH step did not happen: say which it was.
|
|
399
|
+
const pathLine = ensured.path === "written"
|
|
400
|
+
? `Added ${ensured.dir} to your user PATH.`
|
|
401
|
+
: ensured.path === "present"
|
|
402
|
+
? `${ensured.dir} is already on your user PATH.`
|
|
403
|
+
: `HQ did not add ${ensured.dir} to your user PATH (${ensured.path}); hooks find jq at the path above.`;
|
|
404
|
+
const sessionLine = ensured.sessionTarget
|
|
405
|
+
? `Also placed at ${ensured.sessionTarget}, which terminals and Claude Code sessions that are already open can find.\n`
|
|
406
|
+
: "";
|
|
407
|
+
process.stdout.write(`Verified jq is ready at ${check.target ?? ensured.target}.\n${pathLine}\n${sessionLine}If a terminal or Claude Code session that was already open still reports jq missing, restart it.\n`);
|
|
408
|
+
}
|
|
409
|
+
else {
|
|
410
|
+
process.stderr.write(`hq doctor --fix-jq: jq is installed at ${ensured.target}, but HQ hooks will not find it yet. ${check.message}\n${remaining}\n`);
|
|
411
|
+
}
|
|
412
|
+
if (!ok)
|
|
413
|
+
process.exitCode = 1;
|
|
377
414
|
}
|
|
378
415
|
catch (error) {
|
|
379
416
|
const message = error instanceof Error ? error.message : String(error);
|
package/dist/commands/files.d.ts
CHANGED
|
@@ -156,12 +156,59 @@ export interface FilesDeleteResponse {
|
|
|
156
156
|
tombstoned: number;
|
|
157
157
|
keys: string[];
|
|
158
158
|
keysTruncated: boolean;
|
|
159
|
+
/** Delete-ceiling usage the server reports on a dry run, when it has a ceiling. */
|
|
160
|
+
deleteCeiling?: DeleteCeilingUsage;
|
|
159
161
|
}
|
|
162
|
+
export interface DeleteCeilingUsage {
|
|
163
|
+
limit: number;
|
|
164
|
+
confirmLimit: number;
|
|
165
|
+
windowSeconds: number;
|
|
166
|
+
usedInWindow: number;
|
|
167
|
+
requested: number;
|
|
168
|
+
basis?: string;
|
|
169
|
+
/** Server mode (hq-pro #5656): "shadow" only watches, "enforce" stops deletes. */
|
|
170
|
+
mode?: "shadow" | "enforce";
|
|
171
|
+
/**
|
|
172
|
+
* False when the server only watches: a real delete over the limit still
|
|
173
|
+
* goes through. Absent on servers older than hq-pro #5656's mode field.
|
|
174
|
+
*/
|
|
175
|
+
enforced?: boolean;
|
|
176
|
+
}
|
|
177
|
+
export declare const DELETE_CEILING_EXCEEDED_CODE = "FILES_DELETE_CEILING_EXCEEDED";
|
|
178
|
+
export declare const DELETE_CEILING_APPROVAL_REQUIRED_CODE = "FILES_DELETE_CEILING_APPROVAL_REQUIRED";
|
|
179
|
+
export declare const DELETE_CONFIRMATION_INVALID_CODE = "FILES_DELETE_CONFIRMATION_INVALID";
|
|
180
|
+
export declare const DELETE_CONFIRMATION_FIELD = "deleteConfirmation";
|
|
181
|
+
/**
|
|
182
|
+
* Structured 409 refusal from the hq-pro per-company delete ceiling
|
|
183
|
+
* (hq-pro #5656). Field names must match the server.
|
|
184
|
+
*/
|
|
185
|
+
export interface FilesDeleteCeilingRefusal {
|
|
186
|
+
code: typeof DELETE_CEILING_EXCEEDED_CODE | typeof DELETE_CEILING_APPROVAL_REQUIRED_CODE;
|
|
187
|
+
error?: string;
|
|
188
|
+
deleteCeiling?: DeleteCeilingUsage;
|
|
189
|
+
confirmation: {
|
|
190
|
+
token: string;
|
|
191
|
+
expiresAt: string;
|
|
192
|
+
sufficient: boolean;
|
|
193
|
+
} | null;
|
|
194
|
+
approval: {
|
|
195
|
+
required: boolean;
|
|
196
|
+
roles: string[];
|
|
197
|
+
};
|
|
198
|
+
confirmationRejected?: string;
|
|
199
|
+
}
|
|
200
|
+
export declare function isWellFormedConfirmationToken(v: unknown): v is string;
|
|
201
|
+
export declare function parseCeilingRefusal(body: unknown): FilesDeleteCeilingRefusal | undefined;
|
|
202
|
+
export declare function describeCeilingRefusal(r: FilesDeleteCeilingRefusal): string;
|
|
160
203
|
export declare class FilesDeleteHttpError extends Error {
|
|
161
204
|
readonly status: number;
|
|
162
205
|
readonly code?: string | undefined;
|
|
163
206
|
constructor(status: number, message: string, code?: string | undefined);
|
|
164
207
|
}
|
|
208
|
+
export declare class FilesDeleteCeilingError extends FilesDeleteHttpError {
|
|
209
|
+
readonly refusal: FilesDeleteCeilingRefusal;
|
|
210
|
+
constructor(status: number, refusal: FilesDeleteCeilingRefusal);
|
|
211
|
+
}
|
|
165
212
|
/** Client-side ceiling: more objects than this in one delete needs a typed confirmation. */
|
|
166
213
|
export declare const DELETE_CEILING_COUNT = 1000;
|
|
167
214
|
/** Why a previewed delete is over the client-side ceiling, or undefined. */
|
|
@@ -187,6 +234,7 @@ export declare function callDeleteEndpoint(params: {
|
|
|
187
234
|
personal?: boolean;
|
|
188
235
|
prefix: string;
|
|
189
236
|
dryRun: boolean;
|
|
237
|
+
deleteConfirmation?: string;
|
|
190
238
|
}): Promise<FilesDeleteResponse>;
|
|
191
239
|
interface RunFilesDeleteParams {
|
|
192
240
|
prefix: string;
|
|
@@ -195,6 +243,8 @@ interface RunFilesDeleteParams {
|
|
|
195
243
|
/** Target the caller's personal vault instead of a company vault. */
|
|
196
244
|
personal?: boolean;
|
|
197
245
|
companySlug: string | undefined;
|
|
246
|
+
/** An approved delete confirmation token to send with the real delete. */
|
|
247
|
+
confirmation?: string;
|
|
198
248
|
}
|
|
199
249
|
/**
|
|
200
250
|
* The vault bucket is already company-scoped, so a delete prefix must be
|
|
@@ -226,10 +276,22 @@ export declare function stripRedundantCompanyScope(prefix: string): {
|
|
|
226
276
|
* `--company` (or is refused), or BECOMES the company when none was given.
|
|
227
277
|
*/
|
|
228
278
|
export declare function companySlugFromAnchor(prefix: string, personal?: boolean): string | undefined;
|
|
279
|
+
/**
|
|
280
|
+
* Handle the server's delete-ceiling refusal. The confirmation token is sent
|
|
281
|
+
* only after the person types the confirmation in a terminal; --yes alone
|
|
282
|
+
* never sends it. Returns the token to send, or undefined when the person
|
|
283
|
+
* declined. Exits 1 when the delete cannot be confirmed here.
|
|
284
|
+
*/
|
|
285
|
+
export declare function confirmServerCeiling(refusal: FilesDeleteCeilingRefusal, deps: {
|
|
286
|
+
prompt: PromptFn;
|
|
287
|
+
isInteractive: () => boolean;
|
|
288
|
+
now: () => Date;
|
|
289
|
+
}): Promise<string | undefined>;
|
|
229
290
|
export interface RunFilesDeleteDeps {
|
|
230
291
|
confirm?: ConfirmFn;
|
|
231
292
|
prompt?: PromptFn;
|
|
232
293
|
isInteractive?: () => boolean;
|
|
294
|
+
now?: () => Date;
|
|
233
295
|
}
|
|
234
296
|
export declare function runFilesDelete(params: RunFilesDeleteParams, deps?: RunFilesDeleteDeps): Promise<void>;
|
|
235
297
|
export interface FileVersionRow {
|
package/dist/commands/files.js
CHANGED
|
@@ -14,7 +14,7 @@ import { suggestChannels, withChannelSuggestions } from "./channel-suggest.js";
|
|
|
14
14
|
import { resolveCompanySlug, resolvePersonWithRosterFallback, } from "./people.js";
|
|
15
15
|
import { findHqRoot } from "../utils/manifest.js";
|
|
16
16
|
import { maxLength } from "../utils/table-width.js";
|
|
17
|
-
import { resolveCompanyFlagGate } from "../lib/flag-
|
|
17
|
+
import { resolveCompanyFlagGate } from "../lib/company-flag-gate.js";
|
|
18
18
|
import { raiseAccessRefresh } from "../lib/sync-core/access-refresh.js";
|
|
19
19
|
const PERSON_UID_PATTERN = /^(prs|agt)_[A-Za-z0-9_-]+$/;
|
|
20
20
|
const AGENT_UID_PATTERN = /^agt_[A-Za-z0-9_-]+$/;
|
|
@@ -678,6 +678,7 @@ export function registerFilesCommand(program) {
|
|
|
678
678
|
.option("--dry-run", "List what WOULD be deleted without deleting anything")
|
|
679
679
|
.option("--personal", "Target your own personal vault instead of a company vault (mutually exclusive with --company)")
|
|
680
680
|
.option("-y, --yes", "Skip the confirmation prompt (for scripts); not above 1000 objects")
|
|
681
|
+
.option("--confirmation <token>", "Send an hqdc_ delete confirmation token with a real company-vault delete; asks you to type the confirmation in a terminal first (not with --dry-run or --personal)")
|
|
681
682
|
.action(async (prefix, opts) => {
|
|
682
683
|
try {
|
|
683
684
|
const companySlug = files.opts().company;
|
|
@@ -692,6 +693,7 @@ export function registerFilesCommand(program) {
|
|
|
692
693
|
yes: opts.yes === true,
|
|
693
694
|
personal,
|
|
694
695
|
companySlug,
|
|
696
|
+
...(opts.confirmation !== undefined ? { confirmation: opts.confirmation } : {}),
|
|
695
697
|
});
|
|
696
698
|
}
|
|
697
699
|
catch (err) {
|
|
@@ -1350,6 +1352,112 @@ async function runShareSession(params) {
|
|
|
1350
1352
|
console.log(chalk.dim(" --no-open: copy the URL above to share manually."));
|
|
1351
1353
|
}
|
|
1352
1354
|
}
|
|
1355
|
+
export const DELETE_CEILING_EXCEEDED_CODE = "FILES_DELETE_CEILING_EXCEEDED";
|
|
1356
|
+
export const DELETE_CEILING_APPROVAL_REQUIRED_CODE = "FILES_DELETE_CEILING_APPROVAL_REQUIRED";
|
|
1357
|
+
export const DELETE_CONFIRMATION_INVALID_CODE = "FILES_DELETE_CONFIRMATION_INVALID";
|
|
1358
|
+
export const DELETE_CONFIRMATION_FIELD = "deleteConfirmation";
|
|
1359
|
+
function readUsage(v) {
|
|
1360
|
+
if (!v || typeof v !== "object")
|
|
1361
|
+
return undefined;
|
|
1362
|
+
const u = v;
|
|
1363
|
+
const n = (x) => (typeof x === "number" && Number.isFinite(x) ? x : undefined);
|
|
1364
|
+
const limit = n(u.limit);
|
|
1365
|
+
const requested = n(u.requested);
|
|
1366
|
+
const usedInWindow = n(u.usedInWindow);
|
|
1367
|
+
const windowSeconds = n(u.windowSeconds);
|
|
1368
|
+
if (limit === undefined || requested === undefined || usedInWindow === undefined || windowSeconds === undefined) {
|
|
1369
|
+
return undefined;
|
|
1370
|
+
}
|
|
1371
|
+
return {
|
|
1372
|
+
limit,
|
|
1373
|
+
requested,
|
|
1374
|
+
usedInWindow,
|
|
1375
|
+
windowSeconds,
|
|
1376
|
+
confirmLimit: n(u.confirmLimit) ?? limit,
|
|
1377
|
+
...(typeof u.basis === "string" ? { basis: u.basis } : {}),
|
|
1378
|
+
...(u.mode === "shadow" || u.mode === "enforce" ? { mode: u.mode } : {}),
|
|
1379
|
+
...(typeof u.enforced === "boolean" ? { enforced: u.enforced } : {}),
|
|
1380
|
+
};
|
|
1381
|
+
}
|
|
1382
|
+
function safeText(v, max) {
|
|
1383
|
+
if (typeof v !== "string" || v.trim() === "")
|
|
1384
|
+
return undefined;
|
|
1385
|
+
if ([...v].some((c) => c.charCodeAt(0) < 0x20 || c.charCodeAt(0) === 0x7f))
|
|
1386
|
+
return undefined;
|
|
1387
|
+
return v.trim().slice(0, max);
|
|
1388
|
+
}
|
|
1389
|
+
export function isWellFormedConfirmationToken(v) {
|
|
1390
|
+
return typeof v === "string" && /^hqdc_[A-Za-z0-9_-]{32,123}$/.test(v);
|
|
1391
|
+
}
|
|
1392
|
+
export function parseCeilingRefusal(body) {
|
|
1393
|
+
if (!body || typeof body !== "object")
|
|
1394
|
+
return undefined;
|
|
1395
|
+
const b = body;
|
|
1396
|
+
if (b.code !== DELETE_CEILING_EXCEEDED_CODE && b.code !== DELETE_CEILING_APPROVAL_REQUIRED_CODE)
|
|
1397
|
+
return undefined;
|
|
1398
|
+
const c = b.confirmation && typeof b.confirmation === "object" ? b.confirmation : undefined;
|
|
1399
|
+
const a = b.approval && typeof b.approval === "object" ? b.approval : undefined;
|
|
1400
|
+
const expiresAt = safeText(c?.expiresAt, 64);
|
|
1401
|
+
const confirmation = c && isWellFormedConfirmationToken(c.token) && expiresAt !== undefined
|
|
1402
|
+
? { token: c.token, expiresAt, sufficient: c.sufficient === true }
|
|
1403
|
+
: null;
|
|
1404
|
+
const roles = Array.isArray(a?.roles) ? a.roles.filter((r) => typeof r === "string").slice(0, 5) : [];
|
|
1405
|
+
const usage = readUsage(b.deleteCeiling);
|
|
1406
|
+
const rejected = safeText(b.confirmationRejected, 32);
|
|
1407
|
+
const error = safeText(b.error, 600);
|
|
1408
|
+
return {
|
|
1409
|
+
code: b.code,
|
|
1410
|
+
...(error !== undefined ? { error } : {}),
|
|
1411
|
+
...(usage ? { deleteCeiling: usage } : {}),
|
|
1412
|
+
confirmation,
|
|
1413
|
+
approval: {
|
|
1414
|
+
required: a?.required === true || b.code === DELETE_CEILING_APPROVAL_REQUIRED_CODE,
|
|
1415
|
+
roles: roles.map((r) => r.slice(0, 20)),
|
|
1416
|
+
},
|
|
1417
|
+
...(rejected !== undefined ? { confirmationRejected: rejected } : {}),
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
function describeUsage(u) {
|
|
1421
|
+
const minutes = Math.max(1, Math.round(u.windowSeconds / 60));
|
|
1422
|
+
return (`This delete would remove ${u.requested} objects, and ${u.usedInWindow} were already deleted in this vault ` +
|
|
1423
|
+
`in the last ${minutes} minutes. The company's delete limit is ${u.limit} per ${minutes} minutes.`);
|
|
1424
|
+
}
|
|
1425
|
+
/**
|
|
1426
|
+
* The way forward that works today when a delete needs another admin's
|
|
1427
|
+
* approval: no HQ command can send that approval yet. The server's window
|
|
1428
|
+
* total includes the requested count, so when one delete alone is over the
|
|
1429
|
+
* approval tier, waiting never helps and the only path without approval is
|
|
1430
|
+
* chunks no bigger than the limit, one window apart. Otherwise waiting for
|
|
1431
|
+
* the window to pass is the way forward.
|
|
1432
|
+
*/
|
|
1433
|
+
function ceilingWaysForward(u) {
|
|
1434
|
+
const window = u
|
|
1435
|
+
? `the ${Math.max(1, Math.round(u.windowSeconds / 60))}-minute window`
|
|
1436
|
+
: "the delete limit's time window";
|
|
1437
|
+
if (u && u.requested > u.confirmLimit) {
|
|
1438
|
+
return (`This one delete of ${u.requested} objects is over the ${u.confirmLimit}-object approval limit by itself, ` +
|
|
1439
|
+
"so waiting will not let it through. To go ahead without approval, split it into chunks of no more than " +
|
|
1440
|
+
`${u.limit} objects and wait for ${window} to pass between chunks.`);
|
|
1441
|
+
}
|
|
1442
|
+
return (`To go ahead, wait for ${window} to pass so earlier deletes stop counting. ` +
|
|
1443
|
+
"Splitting the delete into smaller prefixes does not help here, because the limit counts every delete in the window.");
|
|
1444
|
+
}
|
|
1445
|
+
function needsApproval(r) {
|
|
1446
|
+
return r.approval.required || (r.confirmation !== null && !r.confirmation.sufficient);
|
|
1447
|
+
}
|
|
1448
|
+
export function describeCeilingRefusal(r) {
|
|
1449
|
+
const parts = ["The server stopped this delete. Nothing was deleted."];
|
|
1450
|
+
if (r.deleteCeiling)
|
|
1451
|
+
parts.push(describeUsage(r.deleteCeiling));
|
|
1452
|
+
if (r.confirmationRejected)
|
|
1453
|
+
parts.push(`The confirmation sent was not accepted (${r.confirmationRejected}).`);
|
|
1454
|
+
if (needsApproval(r)) {
|
|
1455
|
+
const roles = r.approval.roles.length > 0 ? r.approval.roles.join(" or ") : "owner or admin";
|
|
1456
|
+
parts.push(`Another company ${roles} must approve this delete before it can run, and no HQ command can give that approval yet.`);
|
|
1457
|
+
parts.push(ceilingWaysForward(r.deleteCeiling));
|
|
1458
|
+
}
|
|
1459
|
+
return parts.join(" ");
|
|
1460
|
+
}
|
|
1353
1461
|
export class FilesDeleteHttpError extends Error {
|
|
1354
1462
|
status;
|
|
1355
1463
|
code;
|
|
@@ -1360,6 +1468,14 @@ export class FilesDeleteHttpError extends Error {
|
|
|
1360
1468
|
this.name = "FilesDeleteHttpError";
|
|
1361
1469
|
}
|
|
1362
1470
|
}
|
|
1471
|
+
export class FilesDeleteCeilingError extends FilesDeleteHttpError {
|
|
1472
|
+
refusal;
|
|
1473
|
+
constructor(status, refusal) {
|
|
1474
|
+
super(status, describeCeilingRefusal(refusal), refusal.code);
|
|
1475
|
+
this.refusal = refusal;
|
|
1476
|
+
this.name = "FilesDeleteCeilingError";
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1363
1479
|
/** Client-side ceiling: more objects than this in one delete needs a typed confirmation. */
|
|
1364
1480
|
export const DELETE_CEILING_COUNT = 1000;
|
|
1365
1481
|
/** Why a previewed delete is over the client-side ceiling, or undefined. */
|
|
@@ -1371,6 +1487,11 @@ export function clientCeilingReason(preview) {
|
|
|
1371
1487
|
}
|
|
1372
1488
|
/** Map a FilesDeleteHttpError to user-facing copy. */
|
|
1373
1489
|
export function formatFilesDeleteError(err, prefix) {
|
|
1490
|
+
if (err instanceof FilesDeleteCeilingError)
|
|
1491
|
+
return err.message;
|
|
1492
|
+
if (err.code === DELETE_CONFIRMATION_INVALID_CODE) {
|
|
1493
|
+
return `${err.message || "The delete confirmation was not accepted."} Nothing was deleted.`;
|
|
1494
|
+
}
|
|
1374
1495
|
if (err.status === 401) {
|
|
1375
1496
|
return "Not authenticated — please run `hq login`";
|
|
1376
1497
|
}
|
|
@@ -1420,6 +1541,7 @@ function realPrompt(message) {
|
|
|
1420
1541
|
* `personal` flag — so there is nothing for the client to get wrong or spoof.
|
|
1421
1542
|
*/
|
|
1422
1543
|
export async function callDeleteEndpoint(params) {
|
|
1544
|
+
const confirm = params.deleteConfirmation !== undefined ? { [DELETE_CONFIRMATION_FIELD]: params.deleteConfirmation } : {};
|
|
1423
1545
|
const res = await vaultApiFetch({
|
|
1424
1546
|
token: params.token,
|
|
1425
1547
|
path: "/v1/files/delete",
|
|
@@ -1429,15 +1551,20 @@ export async function callDeleteEndpoint(params) {
|
|
|
1429
1551
|
personal: true,
|
|
1430
1552
|
prefix: params.prefix,
|
|
1431
1553
|
dryRun: params.dryRun,
|
|
1554
|
+
...confirm,
|
|
1432
1555
|
}
|
|
1433
1556
|
: {
|
|
1434
1557
|
company: params.companyUid,
|
|
1435
1558
|
prefix: params.prefix,
|
|
1436
1559
|
dryRun: params.dryRun,
|
|
1560
|
+
...confirm,
|
|
1437
1561
|
},
|
|
1438
1562
|
});
|
|
1439
1563
|
if (!res.ok) {
|
|
1440
1564
|
const body = (await res.json().catch(() => ({})));
|
|
1565
|
+
const refusal = res.status === 409 ? parseCeilingRefusal(body) : undefined;
|
|
1566
|
+
if (refusal)
|
|
1567
|
+
throw new FilesDeleteCeilingError(res.status, refusal);
|
|
1441
1568
|
throw new FilesDeleteHttpError(res.status, body.message ?? body.error ?? res.statusText, body.code);
|
|
1442
1569
|
}
|
|
1443
1570
|
return (await res.json());
|
|
@@ -1624,10 +1751,63 @@ function normalizeCompanyFilePrefix(prefix, options = {}) {
|
|
|
1624
1751
|
`is already company-scoped; using bucket-relative '${scope.prefix}'.`));
|
|
1625
1752
|
return normalizeFilePrefix(scope.prefix);
|
|
1626
1753
|
}
|
|
1754
|
+
/**
|
|
1755
|
+
* Handle the server's delete-ceiling refusal. The confirmation token is sent
|
|
1756
|
+
* only after the person types the confirmation in a terminal; --yes alone
|
|
1757
|
+
* never sends it. Returns the token to send, or undefined when the person
|
|
1758
|
+
* declined. Exits 1 when the delete cannot be confirmed here.
|
|
1759
|
+
*/
|
|
1760
|
+
export async function confirmServerCeiling(refusal, deps) {
|
|
1761
|
+
const summary = describeCeilingRefusal(refusal);
|
|
1762
|
+
const confirmation = refusal.confirmation;
|
|
1763
|
+
if (needsApproval(refusal)) {
|
|
1764
|
+
console.error(chalk.red(summary));
|
|
1765
|
+
process.exit(1);
|
|
1766
|
+
}
|
|
1767
|
+
if (confirmation === null) {
|
|
1768
|
+
console.error(chalk.red(`${summary} The server did not issue a confirmation. Run the command again to get one.`));
|
|
1769
|
+
process.exit(1);
|
|
1770
|
+
}
|
|
1771
|
+
if (!deps.isInteractive()) {
|
|
1772
|
+
console.error(chalk.red(`${summary} Going ahead needs the confirmation typed in a terminal; --yes does not apply.`));
|
|
1773
|
+
process.exit(1);
|
|
1774
|
+
}
|
|
1775
|
+
const expiresAt = Date.parse(confirmation.expiresAt);
|
|
1776
|
+
const expired = () => !Number.isFinite(expiresAt) || deps.now().getTime() >= expiresAt;
|
|
1777
|
+
const expiredMessage = "The confirmation has expired or has no readable expiry time. Nothing was deleted. Run the command again.";
|
|
1778
|
+
if (expired()) {
|
|
1779
|
+
console.error(chalk.red(`${summary} ${expiredMessage}`));
|
|
1780
|
+
process.exit(1);
|
|
1781
|
+
}
|
|
1782
|
+
console.log(chalk.yellow(summary));
|
|
1783
|
+
const count = refusal.deleteCeiling?.requested;
|
|
1784
|
+
const phrase = count !== undefined ? `delete ${count} over the limit` : "delete over the limit";
|
|
1785
|
+
const answer = await deps.prompt(`Type '${phrase}' to go ahead (the confirmation expires at ${confirmation.expiresAt}): `);
|
|
1786
|
+
if (answer.trim() !== phrase) {
|
|
1787
|
+
console.log(chalk.dim("Aborted — nothing was deleted."));
|
|
1788
|
+
return undefined;
|
|
1789
|
+
}
|
|
1790
|
+
if (expired()) {
|
|
1791
|
+
console.error(chalk.red(expiredMessage));
|
|
1792
|
+
process.exit(1);
|
|
1793
|
+
}
|
|
1794
|
+
return confirmation.token;
|
|
1795
|
+
}
|
|
1627
1796
|
export async function runFilesDelete(params, deps = {}) {
|
|
1628
1797
|
const confirm = deps.confirm ?? realConfirm;
|
|
1629
1798
|
const prompt = deps.prompt ?? realPrompt;
|
|
1630
1799
|
const isInteractive = deps.isInteractive ?? (() => process.stdin.isTTY === true && process.stdout.isTTY === true);
|
|
1800
|
+
const now = deps.now ?? (() => new Date());
|
|
1801
|
+
if (params.dryRun && params.confirmation !== undefined) {
|
|
1802
|
+
console.error(chalk.red("--confirmation cannot be used with --dry-run: a dry run deletes nothing and never sends the confirmation. " +
|
|
1803
|
+
"Drop --dry-run to send it, or drop --confirmation to preview. Nothing was deleted."));
|
|
1804
|
+
process.exit(1);
|
|
1805
|
+
}
|
|
1806
|
+
if (params.personal === true && params.confirmation !== undefined) {
|
|
1807
|
+
console.error(chalk.red("--confirmation cannot be used with --personal: the delete confirmation applies only to company vaults. " +
|
|
1808
|
+
"Drop --confirmation to delete from your personal vault. Nothing was deleted."));
|
|
1809
|
+
process.exit(1);
|
|
1810
|
+
}
|
|
1631
1811
|
// Strip the local company anchor before preview/confirmation (HQ-8F/HQ-CA).
|
|
1632
1812
|
// Personal keys are already bucket-relative and must keep any such anchor.
|
|
1633
1813
|
// Deletion intentionally expands a folder spelling to a recursive glob, then
|
|
@@ -1695,6 +1875,26 @@ export async function runFilesDelete(params, deps = {}) {
|
|
|
1695
1875
|
if (overCeiling) {
|
|
1696
1876
|
console.log(chalk.yellow(`A real delete would stop here: ${overCeiling}. It needs the confirmation typed in a terminal; --yes does not skip it.`));
|
|
1697
1877
|
}
|
|
1878
|
+
const usage = readUsage(preview.deleteCeiling);
|
|
1879
|
+
if (usage && usage.usedInWindow + usage.requested > usage.limit) {
|
|
1880
|
+
const overConfirmLimit = usage.usedInWindow + usage.requested > usage.confirmLimit;
|
|
1881
|
+
if (usage.enforced === false) {
|
|
1882
|
+
// hq-pro #5656 watch-only mode: the server records the over-limit
|
|
1883
|
+
// delete but lets it through, so do not say it would be stopped.
|
|
1884
|
+
console.log(chalk.yellow("The company delete limit is in watch-only mode on the server, so a real delete would go through. " +
|
|
1885
|
+
`${describeUsage(usage)} ` +
|
|
1886
|
+
(overConfirmLimit
|
|
1887
|
+
? "Once the server enforces the limit, a delete like this would be stopped until another owner or admin approves it."
|
|
1888
|
+
: "Once the server enforces the limit, a delete like this would need a confirmation typed in a terminal.")));
|
|
1889
|
+
}
|
|
1890
|
+
else {
|
|
1891
|
+
console.log(chalk.yellow(`A real delete would be stopped by the company delete limit: ${describeUsage(usage)} ` +
|
|
1892
|
+
(overConfirmLimit
|
|
1893
|
+
? "Going ahead needs another owner or admin's approval. No HQ command can give that approval yet. " +
|
|
1894
|
+
ceilingWaysForward(usage)
|
|
1895
|
+
: "Going ahead needs a confirmation typed in a terminal.")));
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1698
1898
|
console.log(chalk.dim("Nothing was deleted (--dry-run)."));
|
|
1699
1899
|
return;
|
|
1700
1900
|
}
|
|
@@ -1730,22 +1930,63 @@ export async function runFilesDelete(params, deps = {}) {
|
|
|
1730
1930
|
return;
|
|
1731
1931
|
}
|
|
1732
1932
|
}
|
|
1933
|
+
let approvedToken;
|
|
1934
|
+
if (params.confirmation !== undefined) {
|
|
1935
|
+
if (!isWellFormedConfirmationToken(params.confirmation)) {
|
|
1936
|
+
console.error(chalk.red("--confirmation must be a delete confirmation from HQ (it starts with hqdc_). Nothing was deleted."));
|
|
1937
|
+
process.exit(1);
|
|
1938
|
+
}
|
|
1939
|
+
if (!isInteractive()) {
|
|
1940
|
+
console.error(chalk.red("--confirmation is sent only after you type the confirmation in a terminal. Nothing was deleted."));
|
|
1941
|
+
process.exit(1);
|
|
1942
|
+
}
|
|
1943
|
+
const phrase = `delete ${preview.matched} with approval`;
|
|
1944
|
+
const answer = await prompt(`Type '${phrase}' to send the approved confirmation and delete: `);
|
|
1945
|
+
if (answer.trim() !== phrase) {
|
|
1946
|
+
console.log(chalk.dim("Aborted — nothing was deleted."));
|
|
1947
|
+
return;
|
|
1948
|
+
}
|
|
1949
|
+
approvedToken = params.confirmation;
|
|
1950
|
+
}
|
|
1733
1951
|
// 3. Execute the delete.
|
|
1952
|
+
const realDelete = (deleteConfirmation) => callDeleteEndpoint({
|
|
1953
|
+
token,
|
|
1954
|
+
...scopeArgs,
|
|
1955
|
+
prefix: normalized,
|
|
1956
|
+
dryRun: false,
|
|
1957
|
+
...(deleteConfirmation !== undefined ? { deleteConfirmation } : {}),
|
|
1958
|
+
});
|
|
1734
1959
|
let result;
|
|
1735
1960
|
try {
|
|
1736
|
-
result = await
|
|
1737
|
-
token,
|
|
1738
|
-
...scopeArgs,
|
|
1739
|
-
prefix: normalized,
|
|
1740
|
-
dryRun: false,
|
|
1741
|
-
});
|
|
1961
|
+
result = await realDelete(approvedToken);
|
|
1742
1962
|
}
|
|
1743
1963
|
catch (err) {
|
|
1744
|
-
if (err instanceof
|
|
1964
|
+
if (err instanceof FilesDeleteCeilingError && approvedToken !== undefined) {
|
|
1965
|
+
console.error(chalk.red(err.message));
|
|
1966
|
+
process.exit(1);
|
|
1967
|
+
}
|
|
1968
|
+
else if (err instanceof FilesDeleteCeilingError) {
|
|
1969
|
+
const confirmed = await confirmServerCeiling(err.refusal, { prompt, isInteractive, now });
|
|
1970
|
+
if (confirmed === undefined)
|
|
1971
|
+
return;
|
|
1972
|
+
try {
|
|
1973
|
+
result = await realDelete(confirmed);
|
|
1974
|
+
}
|
|
1975
|
+
catch (retryErr) {
|
|
1976
|
+
if (retryErr instanceof FilesDeleteHttpError) {
|
|
1977
|
+
console.error(chalk.red(formatFilesDeleteError(retryErr, normalized)));
|
|
1978
|
+
process.exit(1);
|
|
1979
|
+
}
|
|
1980
|
+
throw retryErr;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
else if (err instanceof FilesDeleteHttpError) {
|
|
1745
1984
|
console.error(chalk.red(formatFilesDeleteError(err, normalized)));
|
|
1746
1985
|
process.exit(1);
|
|
1747
1986
|
}
|
|
1748
|
-
|
|
1987
|
+
else {
|
|
1988
|
+
throw err;
|
|
1989
|
+
}
|
|
1749
1990
|
}
|
|
1750
1991
|
const deletedNoun = result.deleted === 1 ? "object" : "objects";
|
|
1751
1992
|
console.log(chalk.green(`Deleted ${result.deleted} ${deletedNoun} under '${normalized}'.`));
|
|
@@ -31,7 +31,7 @@ import { trustCodexUserHooks } from '../utils/hook-trust.js';
|
|
|
31
31
|
import { assertProviderWrappersInstallable, installProviderWrappers, providerWrapperInstallPaths, removeProviderWrappers } from '../lib/install/provider-wrappers.js';
|
|
32
32
|
import { checkShimOnPath, ensureShimOnUserPath, npmShimDir, shimPathWarning } from '../lib/windows/user-path.js';
|
|
33
33
|
import { removeHqCliPs1Shims } from '../lib/windows/ps1-shims.js';
|
|
34
|
-
import {
|
|
34
|
+
import { ensureWindowsJq, WINDOWS_JQ_REPAIR } from '../lib/windows/jq.js';
|
|
35
35
|
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';
|
|
36
36
|
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';
|
|
37
37
|
export { hookTargetFor, isDaemonInstalled } from '../lib/install/hook-target.js';
|
|
@@ -1291,7 +1291,9 @@ export async function runInstallGlobal(opts) {
|
|
|
1291
1291
|
const install = runtime === 'codex' ? installGlobalCodex : installGlobalClaude;
|
|
1292
1292
|
if (process.platform === 'win32' && !opts.dryRun) {
|
|
1293
1293
|
try {
|
|
1294
|
-
|
|
1294
|
+
// Installs jq and puts it where hooks find it; a home that is not the
|
|
1295
|
+
// signed-in profile gets the file but no user PATH entry.
|
|
1296
|
+
await ensureWindowsJq({ home: opts.home });
|
|
1295
1297
|
}
|
|
1296
1298
|
catch (error) {
|
|
1297
1299
|
const message = error instanceof Error ? error.message : String(error);
|
package/dist/commands/logout.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import chalk from 'chalk';
|
|
14
14
|
import { clearCachedTokens, loadCachedTokens } from '@indigoai-us/hq-cloud';
|
|
15
|
+
import { clearBindingReceipts } from '../lib/mesh/live/binding-receipt.js';
|
|
15
16
|
import { retainUsageAttributionForPerson } from '../lib/work-context/config.js';
|
|
16
17
|
import { workContextRoot } from '../lib/work-context/paths.js';
|
|
17
18
|
import { DEFAULT_COGNITO } from '../utils/cognito-config.js';
|
|
@@ -30,6 +31,9 @@ export async function runLogout() {
|
|
|
30
31
|
catch (error) {
|
|
31
32
|
console.error(chalk.yellow('Could not withdraw the usage opt-in:'), error instanceof Error ? error.message : 'Unknown error');
|
|
32
33
|
}
|
|
34
|
+
// Binding receipts record which company this person bound each session
|
|
35
|
+
// to. They belong to the person signing out.
|
|
36
|
+
clearBindingReceipts();
|
|
33
37
|
const existing = loadCachedTokens();
|
|
34
38
|
if (!existing) {
|
|
35
39
|
console.log(chalk.yellow('No cached HQ session'));
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* hq ontology status | reader [graph|entities] | model [<model>] (setup: what this machine reads and builds with)
|
|
9
9
|
* hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--max-input-tokens N] [--max-output-tokens N] [--no-model] [--dry-run]
|
|
10
10
|
* hq ontology update --company <slug> [--input <path>] [--budget-tokens N] [--no-model]
|
|
11
|
+
* hq ontology lineage backfill --company <slug> [--from D --to D] [--restart] [--retry-unanswered] [--allow-unanswered] [--max-input-tokens N] [--max-output-tokens N] [--dry-run]
|
|
12
|
+
* hq ontology lineage undo --company <slug> [--graph-root <dir>] [--dry-run]
|
|
11
13
|
* hq ontology lookup <name> [--page] | neighbors <id> [--depth N] | search <text> | traverse <from> [<to>]
|
|
12
14
|
* hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
|
|
13
15
|
* hq ontology org-chart draft | confirm --from <file> [--yes] | show
|
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
* hq ontology status | reader [graph|entities] | model [<model>] (setup: what this machine reads and builds with)
|
|
9
9
|
* hq ontology rebuild --company <slug> [--from D --to D] [--resume] [--budget-tokens N] [--max-input-tokens N] [--max-output-tokens N] [--no-model] [--dry-run]
|
|
10
10
|
* hq ontology update --company <slug> [--input <path>] [--budget-tokens N] [--no-model]
|
|
11
|
+
* hq ontology lineage backfill --company <slug> [--from D --to D] [--restart] [--retry-unanswered] [--allow-unanswered] [--max-input-tokens N] [--max-output-tokens N] [--dry-run]
|
|
12
|
+
* hq ontology lineage undo --company <slug> [--graph-root <dir>] [--dry-run]
|
|
11
13
|
* hq ontology lookup <name> [--page] | neighbors <id> [--depth N] | search <text> | traverse <from> [<to>]
|
|
12
14
|
* hq ontology lint [--strict] [--coverage] | proposals list|accept|nope|undo [--set <name>] | brief [--style map|full]
|
|
13
15
|
* hq ontology org-chart draft | confirm --from <file> [--yes] | show
|
|
@@ -314,6 +316,37 @@ export function registerOntologyCommand(program, deps = {}) {
|
|
|
314
316
|
throw error;
|
|
315
317
|
}
|
|
316
318
|
}));
|
|
319
|
+
const lineage = ontology.command("lineage").description("Decision lineage: which decision replaced an earlier one");
|
|
320
|
+
scoped(lineage.command("backfill"))
|
|
321
|
+
.description("Ask the model, day by day from the oldest, whether each decision with no stated change replaces or reverses an earlier open one, and write a link for each that holds (model authority, no status row; each written link is listed in .state/lineage-backfill.jsonl, and `hq ontology lineage undo` removes exactly those). A day with a decision that got no usable reply is not written: the next run sends it again, and after 3 runs it is recorded as unanswered. Exit code 2 when the walk stopped early, 3 when it finished with a decision unanswered in this run. Runs whenever it is invoked, whatever model_tasks says")
|
|
322
|
+
.option("--from <date>", "first decision day to ask about (YYYY-MM-DD)", isoDateArg)
|
|
323
|
+
.option("--to <date>", "last decision day to ask about (YYYY-MM-DD)", isoDateArg)
|
|
324
|
+
.option("--restart", "forget what earlier runs settled, their attempt counts and their unanswered decisions, and walk from the first day; answers already given cost nothing")
|
|
325
|
+
.option("--retry-unanswered", "send the decisions earlier runs recorded as unanswered again")
|
|
326
|
+
.option("--allow-unanswered", "record a decision with no usable reply as unanswered at once instead of holding its day for the next run, and do not exit non-zero for it")
|
|
327
|
+
.option("--max-input-tokens <n>", "model input tokens allowed per day for this run, counting the day's earlier runs (default 150000)", capArg)
|
|
328
|
+
.option("--max-output-tokens <n>", "model output tokens allowed per day for this run (default 20000)", capArg)
|
|
329
|
+
.option("--dry-run", "count the decisions and batches and estimate the tokens and the list-price cost as ranges, with the flags that let the estimate through the daily cap; call no model and write nothing")
|
|
330
|
+
.action(run(async (context, options) => {
|
|
331
|
+
const { lineageBackfillCommand } = await import("../lib/ontology-graph/lineage/index.js");
|
|
332
|
+
return lineageBackfillCommand(context, {
|
|
333
|
+
...(options.from ? { from: options.from } : {}),
|
|
334
|
+
...(options.to ? { to: options.to } : {}),
|
|
335
|
+
...(options.restart ? { restart: true } : {}),
|
|
336
|
+
...(options.retryUnanswered ? { retryUnanswered: true } : {}),
|
|
337
|
+
...(options.allowUnanswered ? { allowUnanswered: true } : {}),
|
|
338
|
+
...(options.maxInputTokens !== undefined ? { maxInputTokens: options.maxInputTokens } : {}),
|
|
339
|
+
...(options.maxOutputTokens !== undefined ? { maxOutputTokens: options.maxOutputTokens } : {}),
|
|
340
|
+
dryRun: Boolean(options.dryRun),
|
|
341
|
+
});
|
|
342
|
+
}));
|
|
343
|
+
scoped(lineage.command("undo"))
|
|
344
|
+
.description("Take back what `hq ontology lineage backfill` wrote: remove the rows .state/lineage-backfill.jsonl lists (each link's edge and its inverse) and clear the walk's state, so a later backfill starts from the first day. A row is removed only when the graph still holds it as the backfill wrote it; a row changed since is left and counted. No other row is touched, and no model is called")
|
|
345
|
+
.option("--dry-run", "count what would be removed and left; write nothing")
|
|
346
|
+
.action(run(async (context, options) => {
|
|
347
|
+
const { lineageUndoCommand } = await import("../lib/ontology-graph/lineage/index.js");
|
|
348
|
+
return lineageUndoCommand(context, { dryRun: Boolean(options.dryRun) });
|
|
349
|
+
}));
|
|
317
350
|
scoped(ontology.command("lookup"))
|
|
318
351
|
.description("Find an entity by name and print its facts, each with a source and date")
|
|
319
352
|
.argument("<name>", "name, alias, email or <type>/<slug>")
|