@indigoai-us/hq-cli 5.345.244 → 5.345.246
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 +87 -0
- package/dist/command-catalog.generated.d.ts +93 -6
- package/dist/command-catalog.generated.js +114 -6
- package/dist/commands/bot.js +1 -1
- package/dist/commands/core-checkpoint-native.d.ts +5 -1
- package/dist/commands/core-checkpoint-native.js +13 -5
- package/dist/commands/deploy-comments.js +139 -0
- package/dist/commands/deploy-list.d.ts +5 -0
- package/dist/commands/deploy-list.js +8 -0
- package/dist/commands/dm.d.ts +4 -1
- package/dist/commands/dm.js +11 -2
- package/dist/commands/files.d.ts +11 -2
- package/dist/commands/files.js +48 -3
- package/dist/commands/lanes-loop.js +4 -1
- package/dist/commands/lanes.js +16 -5
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +26 -6
- package/dist/commands/reindex.js +2 -1
- package/dist/commands/rescue.d.ts +22 -1
- package/dist/commands/rescue.js +56 -9
- package/dist/commands/sources.d.ts +1 -1
- package/dist/commands/sources.js +1 -1
- package/dist/commands/storage.d.ts +15 -2
- package/dist/commands/storage.js +74 -7
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +2033 -1829
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/agent-kit/mcp/tools.js +22 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +4 -1
- package/dist/lib/daemon/fleet-members-cache.d.ts +55 -0
- package/dist/lib/daemon/fleet-members-cache.js +266 -0
- package/dist/lib/daemon/handoff.d.ts +4 -0
- package/dist/lib/daemon/handoff.js +2 -1
- package/dist/lib/daemon/hook-requests.d.ts +2 -1
- package/dist/lib/daemon/hook-requests.js +19 -2
- package/dist/lib/daemon/install.d.ts +9 -1
- package/dist/lib/daemon/install.js +11 -2
- package/dist/lib/daemon/ops/policy.d.ts +23 -3
- package/dist/lib/daemon/ops/policy.js +62 -15
- package/dist/lib/daemon/run.js +12 -0
- package/dist/lib/daemon/server.d.ts +5 -0
- package/dist/lib/daemon/server.js +1 -1
- package/dist/lib/daemon/supervisor.d.ts +6 -0
- package/dist/lib/daemon/supervisor.js +31 -2
- package/dist/lib/doctor/checks/sync-runtime.js +8 -1
- 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/hook-engine/coverage.d.ts +68 -0
- package/dist/lib/hook-engine/coverage.js +163 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +52 -2
- package/dist/lib/hot-channels/signals-pass.js +65 -3
- package/dist/lib/install/claude-targets.d.ts +6 -0
- package/dist/lib/install/claude-targets.js +9 -1
- package/dist/lib/lanes/reconcile-result.d.ts +1 -1
- package/dist/lib/lanes/reconcile.js +19 -4
- package/dist/lib/lanes/remote-control-lane.d.ts +6 -0
- package/dist/lib/lanes/remote-control-lane.js +10 -1
- package/dist/lib/lanes/spawn.d.ts +2 -0
- package/dist/lib/lanes/spawn.js +19 -3
- package/dist/lib/lanes/worker-env-scrub.d.ts +48 -0
- package/dist/lib/lanes/worker-env-scrub.js +146 -0
- package/dist/lib/lanes/worker-process.js +4 -1
- package/dist/lib/mesh/client.js +5 -1
- package/dist/lib/mesh/live/daemon/doctor.d.ts +9 -0
- package/dist/lib/mesh/live/daemon/doctor.js +51 -6
- package/dist/lib/mesh/live/daemon/install.d.ts +39 -0
- package/dist/lib/mesh/live/daemon/install.js +70 -0
- package/dist/lib/mesh/live/daemon/outbox-company.d.ts +47 -0
- package/dist/lib/mesh/live/daemon/outbox-company.js +77 -0
- package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
- package/dist/lib/mesh/live/daemon/run.js +48 -3
- package/dist/lib/mesh/live/daemon/state.d.ts +5 -0
- package/dist/lib/mesh/live/daemon/system-unit.d.ts +21 -0
- package/dist/lib/mesh/live/daemon/system-unit.js +80 -0
- package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -1
- package/dist/lib/mesh/live/daemon/transcript-watch.js +42 -38
- package/dist/lib/mesh/live/direct-drain.js +3 -1
- package/dist/lib/mesh/live/emit.js +4 -2
- package/dist/lib/mesh/live/flush.d.ts +61 -0
- package/dist/lib/mesh/live/flush.js +434 -114
- package/dist/lib/mesh/live/paths.d.ts +10 -0
- package/dist/lib/mesh/live/paths.js +14 -0
- package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -1
- package/dist/lib/mesh/live/reporting-privacy.js +81 -7
- package/dist/lib/mesh/live/spool.d.ts +171 -17
- package/dist/lib/mesh/live/spool.js +777 -62
- package/dist/lib/signals/engine.d.ts +82 -2
- package/dist/lib/signals/engine.js +389 -53
- package/dist/lib/signals/steps/extract.js +5 -0
- package/dist/lib/sync-core/engine-holds.d.ts +17 -1
- package/dist/lib/sync-core/engine-holds.js +73 -3
- package/dist/lib/sync-core/reconcile.js +10 -2
- package/dist/lib/work-context/organize.d.ts +22 -4
- package/dist/lib/work-context/organize.js +50 -21
- package/dist/lib/work-context/paths.d.ts +6 -0
- package/dist/lib/work-context/paths.js +9 -0
- package/dist/lib/work-context/reconcile.d.ts +1 -1
- package/dist/lib/work-context/reconcile.js +1 -1
- package/dist/startup-registration.d.ts +14 -0
- package/dist/startup-registration.js +26 -0
- package/dist/utils/cli-telemetry.d.ts +6 -0
- package/dist/utils/cli-telemetry.js +154 -9
- package/dist/utils/github-tag-fallback.d.ts +7 -2
- package/dist/utils/github-tag-fallback.js +17 -8
- package/dist/utils/hq-core-source.d.ts +31 -0
- package/dist/utils/hq-core-source.js +144 -0
- package/dist/utils/interactive-caller.d.ts +6 -0
- package/dist/utils/interactive-caller.js +8 -0
- package/dist/utils/shipped-codex-hooks.d.ts +6 -4
- package/dist/utils/shipped-codex-hooks.js +22 -10
- package/dist/utils/vault-api.js +1 -0
- package/dist/utils/version-report.d.ts +3 -1
- package/dist/utils/version-report.js +13 -5
- package/docs/anywhere-runtime.md +2 -2
- package/package.json +8 -8
- package/scripts/check-function-manifest.mjs +99 -18
|
@@ -5,6 +5,76 @@ const HOLD_FILE_MAX_BYTES = 16 * 1024 * 1024;
|
|
|
5
5
|
function record(value) {
|
|
6
6
|
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* hq-cloud's runner reads this file and never applies a delete it lists: the
|
|
10
|
+
* server copy stays (and downloads again when the local file is missing) and
|
|
11
|
+
* the local copy stays. The runner drops a path after a later positive signal.
|
|
12
|
+
*/
|
|
13
|
+
export function handbackKeepFile(home) {
|
|
14
|
+
return path.join(home, ".hq", "sync-core", "handback-keep.json");
|
|
15
|
+
}
|
|
16
|
+
const HANDBACK_KEEP_VERSION = 1;
|
|
17
|
+
/**
|
|
18
|
+
* Adds a vault's held deletes to the hand-back keep list, merged with any
|
|
19
|
+
* paths already listed for it. Throws when the file cannot be written.
|
|
20
|
+
*/
|
|
21
|
+
export function writeHandbackKeep(home, vault, held, at,
|
|
22
|
+
/** Test seam: runs after the temp file is written, before the re-read that guards the rename. */
|
|
23
|
+
beforeRename) {
|
|
24
|
+
const file = handbackKeepFile(home);
|
|
25
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
26
|
+
for (let attempt = 0; attempt < HANDBACK_KEEP_WRITE_ATTEMPTS; attempt++) {
|
|
27
|
+
const text = readTextOrNull(file);
|
|
28
|
+
let current;
|
|
29
|
+
try {
|
|
30
|
+
current = text === null ? {} : record(JSON.parse(text)) ?? {};
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
current = {};
|
|
34
|
+
}
|
|
35
|
+
const vaults = { ...(record(current.vaults) ?? {}) };
|
|
36
|
+
const before = record(vaults[vault.uid]);
|
|
37
|
+
const paths = new Map();
|
|
38
|
+
for (const value of Array.isArray(before?.paths) ? before.paths : []) {
|
|
39
|
+
const entry = record(value);
|
|
40
|
+
if (entry && typeof entry.path === "string")
|
|
41
|
+
paths.set(entry.path, entry);
|
|
42
|
+
}
|
|
43
|
+
for (const entry of held.deletes) {
|
|
44
|
+
const known = paths.get(entry.path);
|
|
45
|
+
paths.set(entry.path, known?.direction === entry.direction ? known : { path: entry.path, direction: entry.direction });
|
|
46
|
+
}
|
|
47
|
+
vaults[vault.uid] = {
|
|
48
|
+
...(vault.slug ? { slug: vault.slug } : {}),
|
|
49
|
+
...(held.holdId ? { holdId: held.holdId } : {}),
|
|
50
|
+
writtenAt: at,
|
|
51
|
+
paths: [...paths.values()],
|
|
52
|
+
};
|
|
53
|
+
const version = typeof current.version === "number" && current.version > HANDBACK_KEEP_VERSION ? current.version : HANDBACK_KEEP_VERSION;
|
|
54
|
+
const temp = `${file}.${process.pid}.${attempt}.tmp`;
|
|
55
|
+
fs.writeFileSync(temp, `${JSON.stringify({ ...current, version, vaults }, null, 2)}\n`, { mode: 0o600 });
|
|
56
|
+
// The runner also rewrites this file: rename only over the version just read.
|
|
57
|
+
beforeRename?.(attempt);
|
|
58
|
+
if (readTextOrNull(file) !== text) {
|
|
59
|
+
fs.rmSync(temp, { force: true });
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
fs.renameSync(temp, file);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
throw new Error(`${file} kept changing while it was written`);
|
|
66
|
+
}
|
|
67
|
+
const HANDBACK_KEEP_WRITE_ATTEMPTS = 5;
|
|
68
|
+
function readTextOrNull(file) {
|
|
69
|
+
try {
|
|
70
|
+
return fs.readFileSync(file, "utf8");
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
if (error.code === "ENOENT")
|
|
74
|
+
return null;
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
8
78
|
export function engineHoldFile(engineHome, vaultUid) {
|
|
9
79
|
return path.join(engineHome, ".hq", "sync-core", "holds", `${vaultUid}.json`);
|
|
10
80
|
}
|
|
@@ -48,13 +118,13 @@ export function readEngineHeldDeletes(engineHome, vaultUid) {
|
|
|
48
118
|
function printable(value) {
|
|
49
119
|
return JSON.stringify(value);
|
|
50
120
|
}
|
|
51
|
-
export function heldDeletesHandoverLine(vaultUid, held, engineHome) {
|
|
121
|
+
export function heldDeletesHandoverLine(vaultUid, held, engineHome, home) {
|
|
52
122
|
if (held === "unreadable") {
|
|
53
|
-
return `${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} could not be read;
|
|
123
|
+
return `${vaultUid}: the new sync engine's hold file ${engineHoldFile(engineHome, vaultUid)} could not be read; nothing it held is passed to the current sync, which decides each path again from its own journal and delete checks`;
|
|
54
124
|
}
|
|
55
125
|
const shown = held.deletes.slice(0, HELD_DELETE_LOG_LIMIT).map((entry) => `${entry.direction === "delete_local" ? "local copy of" : "server copy of"} ${printable(entry.path)}`);
|
|
56
126
|
const more = held.count > shown.length ? `; and ${held.count - shown.length} more` : "";
|
|
57
127
|
const id = held.holdId ? ` (hold ${/^[A-Za-z0-9_-]{1,64}$/.test(held.holdId) ? held.holdId : printable(held.holdId)})` : "";
|
|
58
|
-
return `${vaultUid}: switching back with ${held.count} delete${held.count === 1 ? "" : "s"} the new sync engine held${id}; the current sync
|
|
128
|
+
return `${vaultUid}: switching back with ${held.count} delete${held.count === 1 ? "" : "s"} the new sync engine held${id}; the current sync keeps these files and does not apply those deletes (listed in ${handbackKeepFile(home)}): ${shown.join(", ")}${more}`;
|
|
59
129
|
}
|
|
60
130
|
//# sourceMappingURL=engine-holds.js.map
|
|
@@ -7,7 +7,7 @@ import { clearEngineStatus, engineFirstCycle, isSyncCoreVaultUid, removeEngineOw
|
|
|
7
7
|
import { SYNC_CORE_FULL_RELEASE, SYNC_CORE_RELEASE, compareSyncCoreReleases, fullModeAllowed, installedSyncCoreRelease, syncCoreBinaryPath, windowsFullRelease, } from "./release.js";
|
|
8
8
|
import { readSyncCoreSkips } from "./skip.js";
|
|
9
9
|
import { isLiveCompanyEntity, joinedCompanySlug, setUpJoinedCompany } from "./company-adoption.js";
|
|
10
|
-
import { heldDeletesHandoverLine, readEngineHeldDeletes } from "./engine-holds.js";
|
|
10
|
+
import { heldDeletesHandoverLine, readEngineHeldDeletes, writeHandbackKeep } from "./engine-holds.js";
|
|
11
11
|
import { SYNC_RUST_ENGINE_ROLLOUT_FLAG } from "./flag.js";
|
|
12
12
|
import { readSyncCoreRolloutState, syncCoreRolloutStatePath, writeSyncCoreRolloutState, } from "./rollout-state.js";
|
|
13
13
|
function message(error) {
|
|
@@ -336,8 +336,16 @@ export async function reconcileSyncCore(deps) {
|
|
|
336
336
|
continue;
|
|
337
337
|
const engineHome = syncCoreEngineHome(deps.home, vault.uid);
|
|
338
338
|
const heldDeletes = readEngineHeldDeletes(engineHome, vault.uid);
|
|
339
|
+
if (heldDeletes && heldDeletes !== "unreadable") {
|
|
340
|
+
try {
|
|
341
|
+
writeHandbackKeep(deps.home, vault, heldDeletes, at);
|
|
342
|
+
}
|
|
343
|
+
catch (error) {
|
|
344
|
+
warnings.push(`could not record the ${heldDeletes.count} deletes the new sync engine held for ${vault.uid}; the current sync may apply them: ${message(error)}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
339
347
|
if (heldDeletes)
|
|
340
|
-
handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome));
|
|
348
|
+
handover.push(heldDeletesHandoverLine(vault.uid, heldDeletes, engineHome, deps.home));
|
|
341
349
|
handedBack.push(vault);
|
|
342
350
|
}
|
|
343
351
|
const handingBack = [
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* CLI only presents server candidates and submits structured decisions.
|
|
5
5
|
* Ranking is server-owned. Success is reported only from the server receipt.
|
|
6
|
-
* Cancel / timeout / incapable surface
|
|
7
|
-
*
|
|
6
|
+
* Cancel / timeout / incapable surface settles the ask: a session with its
|
|
7
|
+
* company stays needs_project, one without stays as it is or becomes
|
|
8
|
+
* unresolved; the CLI never invents a project or adhoc target and never
|
|
9
|
+
* repeats the ask.
|
|
8
10
|
*/
|
|
9
11
|
import { type SessionDecision, type SessionStateFile } from "./state.js";
|
|
10
12
|
interface OrganizeCandidate {
|
|
@@ -126,8 +128,24 @@ export declare function isLocalDecisionExpired(expiresAt: string | undefined, no
|
|
|
126
128
|
export declare function formatOrganizeList(result: OrganizeListResult): string[];
|
|
127
129
|
/**
|
|
128
130
|
* Mark that the ask was cancelled / timed out / surface incapable.
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
+
* Clears askAfter so the CLI never repeats the ask, drops any project and
|
|
132
|
+
* task, and never invents one.
|
|
133
|
+
*
|
|
134
|
+
* A session that already has its company (`needs_project`, `needs_task`)
|
|
135
|
+
* stays `needs_project`: settling the project ask does not undo the company
|
|
136
|
+
* binding. Moving it to `unresolved` dropped the session out of
|
|
137
|
+
* `hasWorkMeshCompanyBinding`, so a Work Mesh off switch set afterwards
|
|
138
|
+
* stopped its company reporting (rq_20261121230415_a0cdf53a75). A session
|
|
139
|
+
* without its company stays `needs_company` or `company_conflict`, and any
|
|
140
|
+
* other status becomes `unresolved`.
|
|
141
|
+
*
|
|
142
|
+
* The written file is the whole state less the project, the task, and what
|
|
143
|
+
* describes that project (its gate, bind authority and hint). It keeps the
|
|
144
|
+
* markers that say how far the company can be trusted
|
|
145
|
+
* (`companyConfidence: "device_default"`, `ownerMismatch`), the pending
|
|
146
|
+
* `presenceLeave`, the state `version`, `bindingEpisodeId` and the rest. Without them a guessed
|
|
147
|
+
* device-default company, or one another actor reports, would read as a
|
|
148
|
+
* verified binding once the status stays `needs_project`.
|
|
131
149
|
*/
|
|
132
150
|
export declare function settleOrganizeAskWithoutBind(input: {
|
|
133
151
|
sessionId: string;
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* CLI only presents server candidates and submits structured decisions.
|
|
5
5
|
* Ranking is server-owned. Success is reported only from the server receipt.
|
|
6
|
-
* Cancel / timeout / incapable surface
|
|
7
|
-
*
|
|
6
|
+
* Cancel / timeout / incapable surface settles the ask: a session with its
|
|
7
|
+
* company stays needs_project, one without stays as it is or becomes
|
|
8
|
+
* unresolved; the CLI never invents a project or adhoc target and never
|
|
9
|
+
* repeats the ask.
|
|
8
10
|
*/
|
|
9
11
|
import * as crypto from "node:crypto";
|
|
10
12
|
import { WORK_CONTEXT_CONTRACT_VERSION } from "./contract.js";
|
|
@@ -265,8 +267,24 @@ export function formatOrganizeList(result) {
|
|
|
265
267
|
}
|
|
266
268
|
/**
|
|
267
269
|
* Mark that the ask was cancelled / timed out / surface incapable.
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
+
* Clears askAfter so the CLI never repeats the ask, drops any project and
|
|
271
|
+
* task, and never invents one.
|
|
272
|
+
*
|
|
273
|
+
* A session that already has its company (`needs_project`, `needs_task`)
|
|
274
|
+
* stays `needs_project`: settling the project ask does not undo the company
|
|
275
|
+
* binding. Moving it to `unresolved` dropped the session out of
|
|
276
|
+
* `hasWorkMeshCompanyBinding`, so a Work Mesh off switch set afterwards
|
|
277
|
+
* stopped its company reporting (rq_20261121230415_a0cdf53a75). A session
|
|
278
|
+
* without its company stays `needs_company` or `company_conflict`, and any
|
|
279
|
+
* other status becomes `unresolved`.
|
|
280
|
+
*
|
|
281
|
+
* The written file is the whole state less the project, the task, and what
|
|
282
|
+
* describes that project (its gate, bind authority and hint). It keeps the
|
|
283
|
+
* markers that say how far the company can be trusted
|
|
284
|
+
* (`companyConfidence: "device_default"`, `ownerMismatch`), the pending
|
|
285
|
+
* `presenceLeave`, the state `version`, `bindingEpisodeId` and the rest. Without them a guessed
|
|
286
|
+
* device-default company, or one another actor reports, would read as a
|
|
287
|
+
* verified binding once the status stays `needs_project`.
|
|
270
288
|
*/
|
|
271
289
|
export function settleOrganizeAskWithoutBind(input) {
|
|
272
290
|
const state = readSessionState(input.sessionId, input.root);
|
|
@@ -288,36 +306,47 @@ export function settleOrganizeAskWithoutBind(input) {
|
|
|
288
306
|
};
|
|
289
307
|
const next = mergeLocalSessionFields({
|
|
290
308
|
...state,
|
|
309
|
+
// The project and task are dropped below, so a session that had its
|
|
310
|
+
// company keeps it as needs_project.
|
|
291
311
|
contextStatus: state.contextStatus === "needs_company" ||
|
|
292
312
|
state.contextStatus === "company_conflict"
|
|
293
313
|
? state.contextStatus
|
|
294
|
-
: "
|
|
314
|
+
: state.contextStatus === "needs_project" || state.contextStatus === "needs_task"
|
|
315
|
+
? "needs_project"
|
|
316
|
+
: "unresolved",
|
|
295
317
|
decision,
|
|
296
318
|
// Drop any speculative project/task — never invent.
|
|
297
319
|
projectId: undefined,
|
|
298
320
|
taskId: undefined,
|
|
299
321
|
updatedAt: now,
|
|
300
322
|
}, state);
|
|
301
|
-
//
|
|
323
|
+
// Write the whole next state with the project and task removed, so every
|
|
324
|
+
// other field survives the settle: bindingEpisodeId, the migration record,
|
|
325
|
+
// the device-default and owner-mismatch markers, a pending presenceLeave,
|
|
326
|
+
// the project reason and candidates (shown by `hq mesh doctor`, never used
|
|
327
|
+
// to bind), and the local labels (rq_20261122033331_a2dcffa5d0).
|
|
328
|
+
// What describes the dropped project goes with it:
|
|
329
|
+
// - projectGate holds the session's events until a project is chosen, and
|
|
330
|
+
// the settled ask is never asked again, so it would hold them for good;
|
|
331
|
+
// - projectBindAuthority "trusted" stops PRD sync from binding the session
|
|
332
|
+
// to a project again (prd-sync.ts), so it would stay without one;
|
|
333
|
+
// - projectHint is the first source the next prompt binds from
|
|
334
|
+
// (prompt-rebind.ts), so it would bind the project the member just
|
|
335
|
+
// cancelled. Dropping it stops only that: a prompt from the project's
|
|
336
|
+
// folder, or with HQ_SPAWN_PROJECT or a session meta file naming the
|
|
337
|
+
// project, still binds it.
|
|
338
|
+
const { projectId: _projectId, taskId: _taskId, projectGate: _projectGate, projectBindAuthority: _projectBindAuthority, projectHint: _projectHint, ...kept } = next;
|
|
339
|
+
void _projectId;
|
|
340
|
+
void _taskId;
|
|
341
|
+
void _projectGate;
|
|
342
|
+
void _projectBindAuthority;
|
|
343
|
+
void _projectHint;
|
|
302
344
|
const written = {
|
|
345
|
+
...kept,
|
|
303
346
|
contractVersion: WORK_CONTEXT_CONTRACT_VERSION,
|
|
304
|
-
sessionId: next.sessionId,
|
|
305
|
-
contextStatus: next.contextStatus,
|
|
306
347
|
updatedAt: now,
|
|
307
348
|
decision,
|
|
308
349
|
};
|
|
309
|
-
if (next.companyUid)
|
|
310
|
-
written.companyUid = next.companyUid;
|
|
311
|
-
if (next.companySlug)
|
|
312
|
-
written.companySlug = next.companySlug;
|
|
313
|
-
if (typeof next.toolWrites === "number")
|
|
314
|
-
written.toolWrites = next.toolWrites;
|
|
315
|
-
if (next.startedAt)
|
|
316
|
-
written.startedAt = next.startedAt;
|
|
317
|
-
if (next.hasTurn)
|
|
318
|
-
written.hasTurn = true;
|
|
319
|
-
if (next.source)
|
|
320
|
-
written.source = next.source;
|
|
321
350
|
writeSessionState(written, input.root);
|
|
322
351
|
return written;
|
|
323
352
|
}
|
|
@@ -335,7 +364,7 @@ export async function submitOrganizeDecision(input) {
|
|
|
335
364
|
}
|
|
336
365
|
if (input.untracked) {
|
|
337
366
|
// A session with a verified company binding cannot be marked untracked.
|
|
338
|
-
if (hasWorkMeshCompanyBinding(state)) {
|
|
367
|
+
if (hasWorkMeshCompanyBinding(state, undefined, input.root)) {
|
|
339
368
|
return { ok: false, errorCode: COMPANY_BOUND, message: untrackedRefusedMessage(input.sessionId) };
|
|
340
369
|
}
|
|
341
370
|
const now = (input.now ?? (() => new Date()))().toISOString();
|
|
@@ -13,7 +13,13 @@ export declare function workContextSessionPath(sessionId: string, root?: string)
|
|
|
13
13
|
* directory for session state (doctor state-file health) must skip them.
|
|
14
14
|
*/
|
|
15
15
|
export declare const WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX = ".prd-snapshot.json";
|
|
16
|
+
/**
|
|
17
|
+
* Which fleet runtime ran the session, written by the session's own hook
|
|
18
|
+
* (crates/hq-hook/src/mesh_session_policy.rs FLEET_RUNTIME_SIDECAR_SUFFIX).
|
|
19
|
+
*/
|
|
20
|
+
export declare const WORK_CONTEXT_FLEET_RUNTIME_SUFFIX = ".fleet-runtime.json";
|
|
16
21
|
export declare const WORK_CONTEXT_SESSION_SIDECAR_SUFFIXES: readonly string[];
|
|
22
|
+
export declare function workContextFleetRuntimePath(sessionId: string, root?: string): string;
|
|
17
23
|
/** True for `<sessionId>.json`, false for sidecars and non-JSON entries. */
|
|
18
24
|
export declare function isWorkContextSessionStateFileName(name: string): boolean;
|
|
19
25
|
export declare function workContextOutboxDir(root?: string): string;
|
|
@@ -26,9 +26,18 @@ export function workContextSessionPath(sessionId, root) {
|
|
|
26
26
|
* directory for session state (doctor state-file health) must skip them.
|
|
27
27
|
*/
|
|
28
28
|
export const WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX = ".prd-snapshot.json";
|
|
29
|
+
/**
|
|
30
|
+
* Which fleet runtime ran the session, written by the session's own hook
|
|
31
|
+
* (crates/hq-hook/src/mesh_session_policy.rs FLEET_RUNTIME_SIDECAR_SUFFIX).
|
|
32
|
+
*/
|
|
33
|
+
export const WORK_CONTEXT_FLEET_RUNTIME_SUFFIX = ".fleet-runtime.json";
|
|
29
34
|
export const WORK_CONTEXT_SESSION_SIDECAR_SUFFIXES = [
|
|
30
35
|
WORK_CONTEXT_PRD_SNAPSHOT_SUFFIX,
|
|
36
|
+
WORK_CONTEXT_FLEET_RUNTIME_SUFFIX,
|
|
31
37
|
];
|
|
38
|
+
export function workContextFleetRuntimePath(sessionId, root) {
|
|
39
|
+
return path.join(workContextSessionsDir(root), `${sessionId}${WORK_CONTEXT_FLEET_RUNTIME_SUFFIX}`);
|
|
40
|
+
}
|
|
32
41
|
/** True for `<sessionId>.json`, false for sidecars and non-JSON entries. */
|
|
33
42
|
export function isWorkContextSessionStateFileName(name) {
|
|
34
43
|
if (!name.endsWith(".json"))
|
|
@@ -100,7 +100,7 @@ export declare function loadObservationFromFile(filePath: string): ReconcileObse
|
|
|
100
100
|
/**
|
|
101
101
|
* Mark a session untracked (user origin only). Local receipt; no server write.
|
|
102
102
|
*/
|
|
103
|
-
export declare function markUntracked(sessionId: string, deps: Pick<ReconcileDeps, "root" | "now">, clientOperationId?: string): ReconcileOutcome;
|
|
103
|
+
export declare function markUntracked(sessionId: string, deps: Pick<ReconcileDeps, "root" | "now" | "env">, clientOperationId?: string): ReconcileOutcome;
|
|
104
104
|
export declare function reconcileObservation(obs: ReconcileObservation, deps: ReconcileDeps): Promise<ReconcileOutcome>;
|
|
105
105
|
export { replayOutbox };
|
|
106
106
|
//# sourceMappingURL=reconcile.d.ts.map
|
|
@@ -90,7 +90,7 @@ export function markUntracked(sessionId, deps, clientOperationId = `untracked_${
|
|
|
90
90
|
// with a verified company binding cannot be marked untracked. Its state is
|
|
91
91
|
// left as it is and nothing is written.
|
|
92
92
|
const prior = readSessionState(sessionId, deps.root);
|
|
93
|
-
if (hasWorkMeshCompanyBinding(prior)) {
|
|
93
|
+
if (hasWorkMeshCompanyBinding(prior, deps.env, deps.root)) {
|
|
94
94
|
return {
|
|
95
95
|
result: resultOf({
|
|
96
96
|
kind: "error",
|
|
@@ -56,6 +56,20 @@ export declare const DEFAULT_INSTALL_SETTLE_LOCK_TIMEOUT_MS: number;
|
|
|
56
56
|
export declare const INSTALL_TREE_LOCK_WAIT_NOTICE = "hq: another hq updater is still installing hq-cli; waiting for it to finish\u2026";
|
|
57
57
|
/** Resolve the lock ceiling from the environment (0 = do not extend; default on invalid). */
|
|
58
58
|
export declare function resolveSettleLockTimeoutMs(env: NodeJS.ProcessEnv): number;
|
|
59
|
+
/** Operator override for the settle wait's stale-tree observation window. */
|
|
60
|
+
export declare const INSTALL_SETTLE_STALE_PROBE_ENV = "HQ_INSTALL_SETTLE_STALE_PROBE_MS";
|
|
61
|
+
/**
|
|
62
|
+
* Resolve the stale-tree observation window from the environment. Returns
|
|
63
|
+
* undefined (the wait's own default) on absent, blank, or non-numeric values.
|
|
64
|
+
*/
|
|
65
|
+
export declare function resolveSettleStaleProbeMs(env: NodeJS.ProcessEnv): number | undefined;
|
|
66
|
+
/** Operator override for how long a healed tree must stay ready before the wait settles. */
|
|
67
|
+
export declare const INSTALL_SETTLE_QUIET_ENV = "HQ_INSTALL_SETTLE_QUIET_MS";
|
|
68
|
+
/**
|
|
69
|
+
* Resolve the settle wait's quiet window from the environment. Returns
|
|
70
|
+
* undefined (the wait's own default) on absent, blank, or non-numeric values.
|
|
71
|
+
*/
|
|
72
|
+
export declare function resolveSettleQuietMs(env: NodeJS.ProcessEnv): number | undefined;
|
|
59
73
|
/** Minimal view of a `spawnSync` result the seam relies on. */
|
|
60
74
|
export interface RecoverySpawnResult {
|
|
61
75
|
status: number | null;
|
|
@@ -72,6 +72,30 @@ export function resolveSettleLockTimeoutMs(env) {
|
|
|
72
72
|
return DEFAULT_INSTALL_SETTLE_LOCK_TIMEOUT_MS;
|
|
73
73
|
return Number.parseInt(raw.trim(), 10);
|
|
74
74
|
}
|
|
75
|
+
/** Operator override for the settle wait's stale-tree observation window. */
|
|
76
|
+
export const INSTALL_SETTLE_STALE_PROBE_ENV = "HQ_INSTALL_SETTLE_STALE_PROBE_MS";
|
|
77
|
+
/**
|
|
78
|
+
* Resolve the stale-tree observation window from the environment. Returns
|
|
79
|
+
* undefined (the wait's own default) on absent, blank, or non-numeric values.
|
|
80
|
+
*/
|
|
81
|
+
export function resolveSettleStaleProbeMs(env) {
|
|
82
|
+
const raw = env[INSTALL_SETTLE_STALE_PROBE_ENV];
|
|
83
|
+
if (typeof raw !== "string" || !/^\d+$/.test(raw.trim()))
|
|
84
|
+
return undefined;
|
|
85
|
+
return Number.parseInt(raw.trim(), 10);
|
|
86
|
+
}
|
|
87
|
+
/** Operator override for how long a healed tree must stay ready before the wait settles. */
|
|
88
|
+
export const INSTALL_SETTLE_QUIET_ENV = "HQ_INSTALL_SETTLE_QUIET_MS";
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the settle wait's quiet window from the environment. Returns
|
|
91
|
+
* undefined (the wait's own default) on absent, blank, or non-numeric values.
|
|
92
|
+
*/
|
|
93
|
+
export function resolveSettleQuietMs(env) {
|
|
94
|
+
const raw = env[INSTALL_SETTLE_QUIET_ENV];
|
|
95
|
+
if (typeof raw !== "string" || !/^\d+$/.test(raw.trim()))
|
|
96
|
+
return undefined;
|
|
97
|
+
return Number.parseInt(raw.trim(), 10);
|
|
98
|
+
}
|
|
75
99
|
/**
|
|
76
100
|
* Register commands, recovering once from a torn-install module-resolution
|
|
77
101
|
* failure. On a clean registration this returns `{}` and touches nothing else.
|
|
@@ -143,6 +167,8 @@ export async function registerCommandsWithRecovery(args) {
|
|
|
143
167
|
lockPath,
|
|
144
168
|
deadlineMs: resolveSettleTimeoutMs(env),
|
|
145
169
|
lockWaitMs: resolveSettleLockTimeoutMs(env),
|
|
170
|
+
staleProbeMs: resolveSettleStaleProbeMs(env),
|
|
171
|
+
quietMs: resolveSettleQuietMs(env),
|
|
146
172
|
onLockExtended: () => stderr.write(`${INSTALL_TREE_LOCK_WAIT_NOTICE}\n`),
|
|
147
173
|
});
|
|
148
174
|
if (!result.settled) {
|
|
@@ -81,6 +81,12 @@ export declare function withCliFeatureUsed<T>(kind: CliFeatureKind, action: () =
|
|
|
81
81
|
export declare function isCliTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
|
|
82
82
|
/** Feature-use collection stays off until the HQ flag is explicitly enabled. */
|
|
83
83
|
export declare function isCliFeatureUsedTelemetryEnabled(): boolean;
|
|
84
|
+
export declare const CLI_TELEMETRY_CONSENT_TTL_MS: number;
|
|
85
|
+
/**
|
|
86
|
+
* Whether this principal may be sent consent-gated CLI telemetry. Never
|
|
87
|
+
* throws. Only `true` allows a send.
|
|
88
|
+
*/
|
|
89
|
+
export declare function hasCliTelemetryConsent(token: string, machineIdentity: boolean, signal: AbortSignal): Promise<boolean>;
|
|
84
90
|
export declare function telemetryDisclosureMarkerPath(): string;
|
|
85
91
|
/**
|
|
86
92
|
* Print the one-line disclosure at most once per machine. Returns whether
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
3
|
import * as os from "node:os";
|
|
4
4
|
import * as path from "node:path";
|
|
5
5
|
import { CLI_VERSION } from "../cli-version.js";
|
|
6
|
-
import { isExpiring, isMachineIdentity, loadCachedTokens, loadMachineCachedTokens, } from "./cognito-session.js";
|
|
6
|
+
import { cognitoCachePrincipalUid, isExpiring, isMachineIdentity, loadCachedTokens, loadMachineCachedTokens, } from "./cognito-session.js";
|
|
7
7
|
import { resolveProcessFlagCompanyContext, resolveProcessFlagGate, } from "../lib/flag-registry.js";
|
|
8
8
|
import { vaultApiFetch } from "./vault-api.js";
|
|
9
9
|
import { firstSyncStepTelemetryProperties, isHumanInteractiveCliSession, } from "../lib/first-sync-next-step.js";
|
|
@@ -106,11 +106,13 @@ export async function emitCliInviteNudgeEvent(event, timeoutMs = TELEMETRY_TIMEO
|
|
|
106
106
|
machineIdentity: isMachineIdentity(),
|
|
107
107
|
}) || process.stdin.isTTY !== true)
|
|
108
108
|
return;
|
|
109
|
-
if (!maybeDiscloseInviteNudgeTelemetry())
|
|
110
|
-
return;
|
|
111
109
|
const controller = new AbortController();
|
|
112
110
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
113
111
|
try {
|
|
112
|
+
if (!(await hasCliTelemetryConsent(cached.accessToken, false, controller.signal)))
|
|
113
|
+
return;
|
|
114
|
+
if (!maybeDiscloseInviteNudgeTelemetry())
|
|
115
|
+
return;
|
|
114
116
|
const response = await vaultApiFetch({
|
|
115
117
|
token: cached.accessToken,
|
|
116
118
|
path: "/v1/telemetry/events",
|
|
@@ -181,13 +183,15 @@ export async function emitCliFeatureUsed(usage, timeoutMs = TELEMETRY_TIMEOUT_MS
|
|
|
181
183
|
const token = machineIdentity ? cached.idToken : cached.accessToken;
|
|
182
184
|
if (!token)
|
|
183
185
|
return;
|
|
184
|
-
const consentBasis = maybeDiscloseFeatureUsedTelemetry() ? "disclosed" : "no-consent";
|
|
185
186
|
const controller = new AbortController();
|
|
186
187
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
187
188
|
const companyUid = usage.companyUid && COMPANY_UID_PATTERN.test(usage.companyUid)
|
|
188
189
|
? usage.companyUid
|
|
189
190
|
: undefined;
|
|
190
191
|
try {
|
|
192
|
+
if (!(await hasCliTelemetryConsent(token, machineIdentity, controller.signal)))
|
|
193
|
+
return;
|
|
194
|
+
const consentBasis = maybeDiscloseFeatureUsedTelemetry() ? "disclosed" : "no-consent";
|
|
191
195
|
await vaultApiFetch({
|
|
192
196
|
token,
|
|
193
197
|
path: "/v1/telemetry/events",
|
|
@@ -262,6 +266,135 @@ function hqConfigDir() {
|
|
|
262
266
|
const home = process.env.HOME?.trim() || os.homedir();
|
|
263
267
|
return path.join(home, ".hq");
|
|
264
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Person consent for the CLI's product events (owner decision 2026-11-21,
|
|
271
|
+
* "Gate on opt-in"). `cli_session_started` in all its variants,
|
|
272
|
+
* `cli_feature_used` and the plan-limit prompt events are sent only when the
|
|
273
|
+
* person's `telemetryOptIn`, read through `GET /v1/usage/opt-in`, is true.
|
|
274
|
+
* Never answered, opted out, and unreadable (no token, network error, timeout,
|
|
275
|
+
* non-2xx, malformed body) all mean "do not send". Agents and machine
|
|
276
|
+
* identities are always collected (the server answers `agent-required`).
|
|
277
|
+
* `HQ_TELEMETRY=0` stays an extra off switch and is checked first.
|
|
278
|
+
*
|
|
279
|
+
* The answer is cached per principal in `~/.hq` for a short TTL so most
|
|
280
|
+
* commands make no consent request. The request shares the emitter's own
|
|
281
|
+
* abort signal, so it stays inside the bounded telemetry allowance and never
|
|
282
|
+
* slows or fails a command.
|
|
283
|
+
*/
|
|
284
|
+
const CLI_TELEMETRY_CONSENT_PATH = "/v1/usage/opt-in";
|
|
285
|
+
export const CLI_TELEMETRY_CONSENT_TTL_MS = 5 * 60_000;
|
|
286
|
+
const CLI_TELEMETRY_CONSENT_CACHE_FILE = "cli-telemetry-consent.json";
|
|
287
|
+
const CLI_TELEMETRY_CONSENT_CACHE_VERSION = 1;
|
|
288
|
+
const pendingConsentReads = new Map();
|
|
289
|
+
function cliTelemetryConsentCachePath() {
|
|
290
|
+
return path.join(hqConfigDir(), CLI_TELEMETRY_CONSENT_CACHE_FILE);
|
|
291
|
+
}
|
|
292
|
+
function consentSubjectKey(token) {
|
|
293
|
+
try {
|
|
294
|
+
const principal = cognitoCachePrincipalUid(token);
|
|
295
|
+
if (!principal)
|
|
296
|
+
return null;
|
|
297
|
+
return createHash("sha256").update(principal).digest("hex");
|
|
298
|
+
}
|
|
299
|
+
catch {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function readCachedConsent(subject, now) {
|
|
304
|
+
try {
|
|
305
|
+
const parsed = JSON.parse(fs.readFileSync(cliTelemetryConsentCachePath(), "utf8"));
|
|
306
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
307
|
+
return null;
|
|
308
|
+
const entry = parsed;
|
|
309
|
+
if (entry.version !== CLI_TELEMETRY_CONSENT_CACHE_VERSION ||
|
|
310
|
+
entry.subject !== subject ||
|
|
311
|
+
typeof entry.enabled !== "boolean" ||
|
|
312
|
+
typeof entry.checkedAt !== "number" ||
|
|
313
|
+
!Number.isFinite(entry.checkedAt) ||
|
|
314
|
+
entry.checkedAt > now ||
|
|
315
|
+
now - entry.checkedAt >= CLI_TELEMETRY_CONSENT_TTL_MS)
|
|
316
|
+
return null;
|
|
317
|
+
return entry.enabled;
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function writeCachedConsent(subject, enabled, now) {
|
|
324
|
+
try {
|
|
325
|
+
// Do not create ~/.hq. Signed-in runs already have it (cached tokens).
|
|
326
|
+
if (!fs.existsSync(hqConfigDir()))
|
|
327
|
+
return;
|
|
328
|
+
fs.writeFileSync(cliTelemetryConsentCachePath(), JSON.stringify({
|
|
329
|
+
version: CLI_TELEMETRY_CONSENT_CACHE_VERSION,
|
|
330
|
+
subject,
|
|
331
|
+
enabled,
|
|
332
|
+
checkedAt: now,
|
|
333
|
+
}), { mode: 0o600 });
|
|
334
|
+
}
|
|
335
|
+
catch {
|
|
336
|
+
// The cache is an optimization; the next command asks again.
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
/** One opt-in read. `null` means the answer could not be read. */
|
|
340
|
+
async function fetchCliTelemetryConsent(token, signal) {
|
|
341
|
+
try {
|
|
342
|
+
const response = await vaultApiFetch({
|
|
343
|
+
token,
|
|
344
|
+
path: CLI_TELEMETRY_CONSENT_PATH,
|
|
345
|
+
method: "GET",
|
|
346
|
+
signal,
|
|
347
|
+
});
|
|
348
|
+
if (!response.ok)
|
|
349
|
+
return null;
|
|
350
|
+
const body = await response.json();
|
|
351
|
+
if (typeof body !== "object" || body === null)
|
|
352
|
+
return null;
|
|
353
|
+
const enabled = body.enabled;
|
|
354
|
+
return typeof enabled === "boolean" ? enabled : null;
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
return null;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Whether this principal may be sent consent-gated CLI telemetry. Never
|
|
362
|
+
* throws. Only `true` allows a send.
|
|
363
|
+
*/
|
|
364
|
+
export async function hasCliTelemetryConsent(token, machineIdentity, signal) {
|
|
365
|
+
try {
|
|
366
|
+
// Agents and machine identities are always collected; the server answers
|
|
367
|
+
// `agent-required` for them, so no request is needed.
|
|
368
|
+
if (machineIdentity)
|
|
369
|
+
return true;
|
|
370
|
+
if (signal.aborted)
|
|
371
|
+
return false;
|
|
372
|
+
const subject = consentSubjectKey(token);
|
|
373
|
+
if (subject) {
|
|
374
|
+
const cached = readCachedConsent(subject, Date.now());
|
|
375
|
+
if (cached !== null)
|
|
376
|
+
return cached;
|
|
377
|
+
}
|
|
378
|
+
// Emitters in one finalization flush share a single in-flight read. It is
|
|
379
|
+
// dropped once settled: the file cache, not process memory, holds the
|
|
380
|
+
// answer, so a long-lived process still re-reads after the TTL.
|
|
381
|
+
const key = subject ?? `unkeyed:${createHash("sha256").update(token).digest("hex")}`;
|
|
382
|
+
let pending = pendingConsentReads.get(key);
|
|
383
|
+
if (!pending) {
|
|
384
|
+
pending = fetchCliTelemetryConsent(token, signal).then((answer) => {
|
|
385
|
+
pendingConsentReads.delete(key);
|
|
386
|
+
if (answer !== null && subject)
|
|
387
|
+
writeCachedConsent(subject, answer, Date.now());
|
|
388
|
+
return answer;
|
|
389
|
+
});
|
|
390
|
+
pendingConsentReads.set(key, pending);
|
|
391
|
+
}
|
|
392
|
+
return (await pending) === true;
|
|
393
|
+
}
|
|
394
|
+
catch {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
265
398
|
/**
|
|
266
399
|
* Limit only session-start telemetry per machine. Local state is best effort:
|
|
267
400
|
* damaged or unwritable state must never suppress the event or affect a command.
|
|
@@ -448,16 +581,22 @@ async function emitCachedCliSessionStarted(timeoutMs) {
|
|
|
448
581
|
const cached = loadCachedTokens();
|
|
449
582
|
if (!cached || isExpiring(cached, 120))
|
|
450
583
|
return;
|
|
451
|
-
const
|
|
584
|
+
const machineIdentity = isMachineIdentity();
|
|
585
|
+
const token = machineIdentity ? cached.idToken : cached.accessToken;
|
|
452
586
|
if (!token)
|
|
453
587
|
return;
|
|
588
|
+
// The machine budget is local and synchronous, so it runs before the
|
|
589
|
+
// consent read: a run over budget makes no request at all, and the
|
|
590
|
+
// budget's own diagnostics do not depend on how the network answers.
|
|
454
591
|
if (!allowCliSessionStartedBudget())
|
|
455
592
|
return;
|
|
456
|
-
const disclosed = maybeDiscloseCliTelemetry();
|
|
457
|
-
const consentBasis = disclosed ? "disclosed" : "no-consent";
|
|
458
593
|
const controller = new AbortController();
|
|
459
594
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
460
595
|
try {
|
|
596
|
+
if (!(await hasCliTelemetryConsent(token, machineIdentity, controller.signal)))
|
|
597
|
+
return;
|
|
598
|
+
const disclosed = maybeDiscloseCliTelemetry();
|
|
599
|
+
const consentBasis = disclosed ? "disclosed" : "no-consent";
|
|
461
600
|
const response = await vaultApiFetch({
|
|
462
601
|
token,
|
|
463
602
|
path: "/v1/telemetry/events",
|
|
@@ -510,10 +649,12 @@ export async function emitCliFirstSyncNextStepOutcome(outcome, timeoutMs = TELEM
|
|
|
510
649
|
const token = cached.accessToken;
|
|
511
650
|
if (!token)
|
|
512
651
|
return;
|
|
513
|
-
const consentBasis = maybeDiscloseFirstSyncTelemetry() ? "disclosed" : "no-consent";
|
|
514
652
|
const controller = new AbortController();
|
|
515
653
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
516
654
|
try {
|
|
655
|
+
if (!(await hasCliTelemetryConsent(token, machineIdentity, controller.signal)))
|
|
656
|
+
return;
|
|
657
|
+
const consentBasis = maybeDiscloseFirstSyncTelemetry() ? "disclosed" : "no-consent";
|
|
517
658
|
const response = await vaultApiFetch({
|
|
518
659
|
token,
|
|
519
660
|
path: "/v1/telemetry/events",
|
|
@@ -579,6 +720,8 @@ export async function emitPlanLimitInviteTeammateExposure(companyUid, timeoutMs
|
|
|
579
720
|
const controller = new AbortController();
|
|
580
721
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
581
722
|
try {
|
|
723
|
+
if (!(await hasCliTelemetryConsent(token, machineIdentity, controller.signal)))
|
|
724
|
+
return;
|
|
582
725
|
const response = await vaultApiFetch({
|
|
583
726
|
token,
|
|
584
727
|
path: "/v1/telemetry/events",
|
|
@@ -644,6 +787,8 @@ async function emitCliLimitNoticeEvent(exposure, eventName, action, timeoutMs =
|
|
|
644
787
|
const controller = new AbortController();
|
|
645
788
|
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
646
789
|
try {
|
|
790
|
+
if (!(await hasCliTelemetryConsent(token, machineIdentity, controller.signal)))
|
|
791
|
+
return;
|
|
647
792
|
await vaultApiFetch({
|
|
648
793
|
token,
|
|
649
794
|
path: "/v1/telemetry/events",
|