@indigoai-us/hq-cli 5.345.223 → 5.345.226
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 +98 -0
- package/assets/bot-workers/setup/context/quick-reference.md +2 -2
- package/assets/mesh-daemon/README.md +11 -12
- package/dist/command-catalog.generated.d.ts +156 -4
- package/dist/command-catalog.generated.js +191 -4
- package/dist/commands/cloud-provision.d.ts +4 -1
- package/dist/commands/cloud-provision.js +7 -3
- package/dist/commands/cloud-retire.js +1 -1
- package/dist/commands/core-delegate-w1b.js +3 -1
- package/dist/commands/core-delegate.d.ts +5 -0
- package/dist/commands/core-dm-bind-native.d.ts +5 -1
- package/dist/commands/core-dm-bind-native.js +4 -0
- package/dist/commands/core-job-notify-native.d.ts +5 -1
- package/dist/commands/core-job-notify-native.js +8 -2
- package/dist/commands/core-jobs-native.d.ts +27 -1
- package/dist/commands/core-jobs-native.js +49 -28
- package/dist/commands/core-pipeline-conductor-native.js +7 -7
- package/dist/commands/core-pipeline-driver-native.js +5 -5
- package/dist/commands/core-refresh-vault-access-native.d.ts +5 -0
- package/dist/commands/core-refresh-vault-access-native.js +3 -1
- package/dist/commands/core-work-mesh-bind-trusted-native.js +1 -1
- package/dist/commands/daemon.d.ts +2 -0
- package/dist/commands/daemon.js +68 -2
- package/dist/commands/deploy-domains.js +38 -2
- package/dist/commands/lanes-accounts.d.ts +14 -0
- package/dist/commands/lanes-accounts.js +119 -0
- package/dist/commands/lanes-hold.d.ts +2 -27
- package/dist/commands/lanes-hold.js +3 -75
- package/dist/commands/lanes-loop.js +1 -1
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-session-start.js +2 -2
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.js +137 -12
- package/dist/commands/mesh.d.ts +12 -0
- package/dist/commands/mesh.js +13 -4
- package/dist/commands/monitor.js +1 -1
- package/dist/commands/packs.js +1 -1
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/commands/whoami.d.ts +10 -17
- package/dist/commands/whoami.js +7 -79
- package/dist/data/command-states.json +13 -0
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/capacity/accounts.d.ts +4 -0
- package/dist/lib/capacity/accounts.js +4 -0
- package/dist/lib/capacity/route.js +14 -0
- package/dist/lib/capacity/sign-in.d.ts +18 -0
- package/dist/lib/capacity/sign-in.js +34 -1
- package/dist/lib/daemon/catalog.d.ts +9 -5
- package/dist/lib/daemon/catalog.js +14 -8
- package/dist/lib/daemon/config.d.ts +5 -0
- package/dist/lib/daemon/config.js +6 -0
- package/dist/lib/daemon/hook-requests.d.ts +76 -0
- package/dist/lib/daemon/hook-requests.js +481 -0
- package/dist/lib/daemon/lanes-monitor-state.d.ts +55 -0
- package/dist/lib/daemon/lanes-monitor-state.js +129 -0
- package/dist/lib/daemon/lanes-reconcile-loader.d.ts +7 -0
- package/dist/lib/daemon/lanes-reconcile-loader.js +13 -0
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
- package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
- package/dist/lib/daemon/merge-sections.d.ts +165 -0
- package/dist/lib/daemon/merge-sections.js +556 -0
- package/dist/lib/daemon/ops/policy.d.ts +2 -2
- package/dist/lib/daemon/ops/policy.js +44 -5
- package/dist/lib/daemon/protocol.d.ts +1 -1
- package/dist/lib/daemon/protocol.js +0 -6
- package/dist/lib/daemon/run.js +110 -5
- package/dist/lib/daemon/selfcheck.js +2 -2
- package/dist/lib/daemon/server.d.ts +2 -4
- package/dist/lib/daemon/server.js +11 -49
- package/dist/lib/daemon/state-file.d.ts +74 -4
- package/dist/lib/daemon/state-file.js +159 -19
- package/dist/lib/daemon/supervisor.d.ts +3 -1
- package/dist/lib/daemon/updater.d.ts +2 -6
- package/dist/lib/daemon/updater.js +4 -11
- package/dist/lib/daemon/whoami-cache.d.ts +96 -0
- package/dist/lib/daemon/whoami-cache.js +244 -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/hook-engine/coverage.d.ts +2 -0
- package/dist/lib/hook-engine/coverage.js +71 -0
- package/dist/lib/hook-engine/native-precompact-compatibility.json +449 -0
- package/dist/lib/hook-engine/reconcile.js +14 -8
- package/dist/lib/install/hook-target.d.ts +13 -3
- package/dist/lib/install/hook-target.js +14 -11
- package/dist/lib/lanes/account-company.d.ts +7 -1
- package/dist/lib/lanes/account-company.js +22 -4
- package/dist/lib/lanes/account-ownership.d.ts +65 -0
- package/dist/lib/lanes/account-ownership.js +134 -0
- package/dist/lib/lanes/accounts.js +9 -2
- package/dist/lib/lanes/claude-balance.js +9 -3
- package/dist/lib/lanes/config.js +17 -0
- package/dist/lib/lanes/envelope-repair-dispatch.js +1 -1
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/monitor.d.ts +2 -0
- package/dist/lib/lanes/monitor.js +2 -1
- package/dist/lib/lanes/reconcile.js +44 -3
- package/dist/lib/lanes/registry-flag.d.ts +6 -0
- package/dist/lib/lanes/registry-flag.js +3 -2
- package/dist/lib/lanes/repo-merge-hold.d.ts +39 -0
- package/dist/lib/lanes/repo-merge-hold.js +90 -0
- package/dist/lib/lanes/spawn.d.ts +0 -10
- package/dist/lib/lanes/spawn.js +51 -1
- package/dist/lib/lanes/types.d.ts +12 -0
- package/dist/lib/lanes/watcher-main.js +3 -3
- package/dist/lib/mesh/live/daemon/doctor.js +1 -1
- package/dist/lib/mesh/live/daemon/install.js +2 -2
- package/dist/lib/windows/install-followup.js +1 -1
- package/dist/utils/client-health-contract.d.ts +1 -0
- package/dist/utils/client-health-contract.js +5 -0
- package/dist/utils/client-health.d.ts +2 -0
- package/dist/utils/client-health.js +40 -0
- package/dist/utils/cognito-session.d.ts +2 -14
- package/dist/utils/cognito-session.js +2 -40
- package/dist/utils/daemon-cli-version.d.ts +13 -0
- package/dist/utils/daemon-cli-version.js +47 -0
- package/dist/utils/duplicate-command-usage.js +1 -1
- package/dist/utils/machine-token-cache.d.ts +21 -0
- package/dist/utils/machine-token-cache.js +49 -0
- package/dist/utils/resident-package-preload.js +4 -0
- package/dist/utils/whoami-identity.d.ts +54 -0
- package/dist/utils/whoami-identity.js +108 -0
- package/package.json +8 -8
- package/dist/lib/daemon/ops/memory.d.ts +0 -18
- package/dist/lib/daemon/ops/memory.js +0 -65
- package/dist/lib/daemon/ops/mesh.d.ts +0 -38
- package/dist/lib/daemon/ops/mesh.js +0 -70
|
@@ -26,40 +26,67 @@ export function fenceExports(mod = hqCloud) {
|
|
|
26
26
|
const release = mod.releasePushIdentityFences;
|
|
27
27
|
if (typeof list !== "function" || typeof release !== "function")
|
|
28
28
|
return undefined;
|
|
29
|
+
const corrupt = mod.corruptPushIdentityHold;
|
|
30
|
+
const recover = mod.recoverCorruptPushIdentity;
|
|
31
|
+
const readOwner = mod.readPersonalVaultOwnerUid;
|
|
29
32
|
return {
|
|
30
33
|
listPushIdentityFences: list,
|
|
31
34
|
releasePushIdentityFences: release,
|
|
35
|
+
...(typeof corrupt === "function" ? { corruptPushIdentityHold: corrupt } : {}),
|
|
36
|
+
...(typeof recover === "function" ? { recoverCorruptPushIdentity: recover } : {}),
|
|
37
|
+
...(typeof readOwner === "function" ? { readPersonalVaultOwnerUid: readOwner } : {}),
|
|
32
38
|
};
|
|
33
39
|
}
|
|
34
40
|
export function scopeLabel(slug) {
|
|
35
41
|
return slug === PERSONAL_VAULT_JOURNAL_SLUG || slug === "personal" ? "personal vault" : `company ${slug}`;
|
|
36
42
|
}
|
|
43
|
+
/** A sync has written the files this hold would upload. A count of zero is a real empty list. */
|
|
44
|
+
function hasFileList(scope) {
|
|
45
|
+
const held = scope.held;
|
|
46
|
+
if (!held || !Array.isArray(held.samplePaths))
|
|
47
|
+
return false;
|
|
48
|
+
if (held.samplePaths.length > 0)
|
|
49
|
+
return true;
|
|
50
|
+
return held.count === 0;
|
|
51
|
+
}
|
|
37
52
|
function describe(scope) {
|
|
38
53
|
const since = new Date(scope.sinceMs).toISOString();
|
|
39
54
|
const lines = [` ${scopeLabel(scope.slug)}: held since ${since}`];
|
|
40
55
|
if (scope.held) {
|
|
56
|
+
const samples = scope.held.samplePaths;
|
|
41
57
|
lines.push(` ${scope.held.count} file${scope.held.count === 1 ? "" : "s"} waiting to upload (last checked ${scope.held.at})`);
|
|
42
|
-
for (const sample of
|
|
58
|
+
for (const sample of samples)
|
|
43
59
|
lines.push(` ${sample}`);
|
|
44
|
-
if (scope.held.count >
|
|
45
|
-
lines.push(
|
|
60
|
+
if (scope.held.count > samples.length)
|
|
61
|
+
lines.push(` and ${scope.held.count - samples.length} more`);
|
|
46
62
|
}
|
|
47
63
|
return lines;
|
|
48
64
|
}
|
|
65
|
+
function unnamedHoldMessage(scopes) {
|
|
66
|
+
const names = scopes.map((scope) => scopeLabel(scope.slug)).join(", ");
|
|
67
|
+
const single = scopes.length === 1;
|
|
68
|
+
return `${names} ${single ? "is" : "are"} held, but this computer has not listed the files yet, so ${single ? "that hold stays" : "those holds stay"}. Run \`hq sync\` once, then run \`hq sync release-held\` again and confirm the files it names.`;
|
|
69
|
+
}
|
|
49
70
|
export async function runSyncHeld(deps, json = false) {
|
|
50
71
|
if (!deps.exports) {
|
|
51
72
|
deps.log(`${chalk.red("✗")} ${HELD_UNAVAILABLE_MESSAGE}`);
|
|
52
73
|
return 1;
|
|
53
74
|
}
|
|
54
75
|
const scopes = deps.exports.listPushIdentityFences(deps.stateDir);
|
|
76
|
+
const corrupt = deps.exports.corruptPushIdentityHold?.(deps.stateDir) === true;
|
|
55
77
|
if (json) {
|
|
56
|
-
deps.log(JSON.stringify({ scopes }));
|
|
78
|
+
deps.log(JSON.stringify({ scopes, ...(corrupt ? { corruptIdentity: true } : {}) }));
|
|
57
79
|
return 0;
|
|
58
80
|
}
|
|
59
|
-
if (scopes.length === 0) {
|
|
81
|
+
if (scopes.length === 0 && !corrupt) {
|
|
60
82
|
deps.log("No uploads are held on this computer.");
|
|
61
83
|
return 0;
|
|
62
84
|
}
|
|
85
|
+
if (corrupt) {
|
|
86
|
+
deps.log("Uploads are held because the identity file on this computer can't be read. Run `hq sync release-held` to restore it from the account you are signed in as.");
|
|
87
|
+
}
|
|
88
|
+
if (scopes.length === 0)
|
|
89
|
+
return 0;
|
|
63
90
|
// First install also writes this hold (feedback_baa82c96). Do not say
|
|
64
91
|
// another account was signed in; that is often false and reads as a
|
|
65
92
|
// security scare. The hold is still a confirmation before upload.
|
|
@@ -68,9 +95,16 @@ export async function runSyncHeld(deps, json = false) {
|
|
|
68
95
|
for (const line of describe(scope))
|
|
69
96
|
deps.log(line);
|
|
70
97
|
deps.log("");
|
|
71
|
-
|
|
98
|
+
const unlisted = scopes.filter((scope) => !hasFileList(scope));
|
|
99
|
+
if (scopes.some(hasFileList)) {
|
|
100
|
+
deps.log("Nothing has been uploaded or deleted in the cloud. If these files are yours, run `hq sync release-held`.");
|
|
101
|
+
}
|
|
102
|
+
if (unlisted.length > 0)
|
|
103
|
+
deps.log(unnamedHoldMessage(unlisted));
|
|
72
104
|
return 0;
|
|
73
105
|
}
|
|
106
|
+
/** Next step on this computer when saved history names nobody or more than one person. */
|
|
107
|
+
export const CONFIRM_UNPROVEN_COMMAND = "hq sync release-held --confirm-unproven";
|
|
74
108
|
export async function runReleaseHeld(deps, options) {
|
|
75
109
|
if (!deps.exports) {
|
|
76
110
|
deps.log(`${chalk.red("✗")} ${HELD_UNAVAILABLE_MESSAGE}`);
|
|
@@ -81,28 +115,55 @@ export async function runReleaseHeld(deps, options) {
|
|
|
81
115
|
scopes = scopes.filter((scope) => scope.slug === PERSONAL_VAULT_JOURNAL_SLUG || scope.slug === "personal");
|
|
82
116
|
if (options.company)
|
|
83
117
|
scopes = scopes.filter((scope) => scope.slug === options.company);
|
|
84
|
-
|
|
118
|
+
const corrupt = corruptHoldRequested(deps, options);
|
|
119
|
+
if (scopes.length === 0 && !corrupt) {
|
|
85
120
|
deps.log(options.json ? JSON.stringify({ released: [] }) : "No held uploads match.");
|
|
86
121
|
return 0;
|
|
87
122
|
}
|
|
88
|
-
const needPersonal = scopes.some((scope) => scope.slug === PERSONAL_VAULT_JOURNAL_SLUG || scope.slug === "personal");
|
|
123
|
+
const needPersonal = corrupt || scopes.some((scope) => scope.slug === PERSONAL_VAULT_JOURNAL_SLUG || scope.slug === "personal");
|
|
89
124
|
const snapshot = await deps.identity({ needPersonal, interactive: true });
|
|
90
125
|
const identities = [snapshot.sub, ...(snapshot.personalUid ? [snapshot.personalUid] : [])];
|
|
91
126
|
const mine = scopes.filter((scope) => identities.includes(scope.uid));
|
|
92
|
-
|
|
127
|
+
const listed = mine.filter(hasFileList);
|
|
128
|
+
const unlisted = mine.filter((scope) => !hasFileList(scope));
|
|
129
|
+
if (mine.length === 0 && !corrupt) {
|
|
93
130
|
deps.log(options.json
|
|
94
131
|
? JSON.stringify({ released: [], reason: "not-yours" })
|
|
95
132
|
: "These held uploads belong to a different signed-in person. Sign in as that person to release them.");
|
|
96
133
|
return 1;
|
|
97
134
|
}
|
|
98
135
|
if (!options.json) {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
for (const
|
|
102
|
-
|
|
136
|
+
if (listed.length > 0 && options.confirmUnproven) {
|
|
137
|
+
deps.log("These uploads stay held until you confirm which files are yours:");
|
|
138
|
+
for (const scope of listed)
|
|
139
|
+
for (const line of describe(scope))
|
|
140
|
+
deps.log(line);
|
|
141
|
+
}
|
|
142
|
+
else if (listed.length > 0) {
|
|
143
|
+
deps.log("Releasing these uploads sends the files below to the cloud as yours:");
|
|
144
|
+
for (const scope of listed)
|
|
145
|
+
for (const line of describe(scope))
|
|
146
|
+
deps.log(line);
|
|
147
|
+
}
|
|
148
|
+
if (corrupt) {
|
|
149
|
+
deps.log("The identity file on this computer can't be read. Restoring it keeps the uploads held until you review them.");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
// A recovered corrupt scope is a hold with no file list until a sync records one.
|
|
153
|
+
// Releasing it would upload whatever is on disk, including another person's edits.
|
|
154
|
+
if (listed.length === 0 && !corrupt) {
|
|
155
|
+
const unnamed = unnamedHoldMessage(unlisted);
|
|
156
|
+
deps.log(options.json ? JSON.stringify({ released: [], reason: "no-file-list", message: unnamed }) : unnamed);
|
|
157
|
+
return 1;
|
|
103
158
|
}
|
|
159
|
+
if (!options.json && unlisted.length > 0)
|
|
160
|
+
deps.log(unnamedHoldMessage(unlisted));
|
|
104
161
|
if (!options.yes) {
|
|
105
|
-
const ok = await deps.confirm(
|
|
162
|
+
const ok = await deps.confirm(options.confirmUnproven
|
|
163
|
+
? "Restore the identity file and keep every upload held until you confirm which files are yours? [y/N] "
|
|
164
|
+
: corrupt && listed.length === 0
|
|
165
|
+
? "Restore the identity file from the account you are signed in as? [y/N] "
|
|
166
|
+
: "Are these files yours to upload? [y/N] ");
|
|
106
167
|
if (!ok) {
|
|
107
168
|
deps.log(options.json ? JSON.stringify({ released: [] }) : "Nothing released.");
|
|
108
169
|
return 1;
|
|
@@ -118,12 +179,99 @@ export async function runReleaseHeld(deps, options) {
|
|
|
118
179
|
: "The signed-in account changed while releasing. Nothing was released; run the command again.");
|
|
119
180
|
return 1;
|
|
120
181
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
182
|
+
// The confirm-unproven prompt keeps every upload held. It is not agreement
|
|
183
|
+
// to release the listed scopes, and --yes only skips that prompt. Release
|
|
184
|
+
// those scopes only when the person agreed to upload these exact files.
|
|
185
|
+
const withheldListed = options.confirmUnproven === true && listed.length > 0;
|
|
186
|
+
const released = listed.length === 0 || withheldListed
|
|
187
|
+
? []
|
|
188
|
+
: deps.exports.releasePushIdentityFences(deps.stateDir, identities, listed.map((scope) => scope.slug));
|
|
189
|
+
const recovery = corrupt ? restoreCorruptIdentity(deps, identities, options) : undefined;
|
|
190
|
+
// "none" means the unreadable file was already gone. That is not a refusal.
|
|
191
|
+
if (recovery && !recovery.recovered && recovery.reason !== "none") {
|
|
192
|
+
if (!options.json && released.length > 0) {
|
|
193
|
+
deps.log(`Released ${released.map(scopeLabel).join(", ")}.`);
|
|
194
|
+
}
|
|
195
|
+
deps.log(options.json
|
|
196
|
+
? JSON.stringify({ released, identityRestored: false, reason: recovery.reason })
|
|
197
|
+
: corruptRefusal(recovery.reason, released.length > 0));
|
|
198
|
+
return 1;
|
|
199
|
+
}
|
|
200
|
+
const restored = recovery?.recovered === true;
|
|
201
|
+
const heldScopeFiles = recovery?.heldScopeFiles ?? 0;
|
|
202
|
+
const stayHeld = heldScopeFiles > 0 || recovery?.uploadsStayHeld === true || withheldListed;
|
|
203
|
+
const reportCorrupt = corrupt && recovery?.reason !== "none";
|
|
204
|
+
const needsSync = unlisted.length > 0 ? unlisted.map((scope) => scope.slug) : undefined;
|
|
205
|
+
if (options.json) {
|
|
206
|
+
deps.log(JSON.stringify({
|
|
207
|
+
released,
|
|
208
|
+
...(reportCorrupt ? { identityRestored: restored } : {}),
|
|
209
|
+
...(recovery?.uploadsStayHeld === true || withheldListed ? { uploadsStayHeld: true } : {}),
|
|
210
|
+
...(needsSync ? { needsSync, ...(released.length === 0 && !withheldListed ? { reason: "no-file-list" } : {}) } : {}),
|
|
211
|
+
}));
|
|
212
|
+
}
|
|
213
|
+
else if (restored && stayHeld && released.length === 0) {
|
|
214
|
+
deps.log(withheldListed
|
|
215
|
+
? "Restored the identity file and kept the uploads held. Run `hq sync release-held` again without `--confirm-unproven` and confirm the files it names."
|
|
216
|
+
: "Restored the identity file and kept the uploads held. Run `hq sync` once so the held files are listed, then run `hq sync release-held` again and confirm the files it names.");
|
|
217
|
+
}
|
|
218
|
+
else if (restored && stayHeld) {
|
|
219
|
+
deps.log(`Released ${released.map(scopeLabel).join(", ")}. Restored the identity file and kept the uploads held. Run \`hq sync\` once so the held files are listed, then run \`hq sync release-held\` again and confirm the files it names.`);
|
|
220
|
+
}
|
|
221
|
+
else if (restored && released.length === 0) {
|
|
222
|
+
deps.log("Restored the identity file from the account you are signed in as. The next sync can upload.");
|
|
223
|
+
}
|
|
224
|
+
else if (restored) {
|
|
225
|
+
deps.log(`Released ${released.map(scopeLabel).join(", ")} and restored the identity file. The next sync uploads these files.`);
|
|
226
|
+
}
|
|
227
|
+
else if (withheldListed) {
|
|
228
|
+
deps.log("Kept the uploads held. Run `hq sync release-held` without `--confirm-unproven` and confirm the files it names.");
|
|
229
|
+
}
|
|
230
|
+
else if (released.length === 0) {
|
|
231
|
+
deps.log("No held uploads match.");
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
deps.log(`Released ${released.map(scopeLabel).join(", ")}. The next sync uploads these files.`);
|
|
235
|
+
}
|
|
125
236
|
return 0;
|
|
126
237
|
}
|
|
238
|
+
function corruptHoldRequested(deps, options) {
|
|
239
|
+
const probe = deps.exports?.corruptPushIdentityHold;
|
|
240
|
+
if (!probe || !deps.exports?.recoverCorruptPushIdentity)
|
|
241
|
+
return false;
|
|
242
|
+
if (options.company)
|
|
243
|
+
return probe(deps.stateDir, options.company);
|
|
244
|
+
if (options.personal)
|
|
245
|
+
return probe(deps.stateDir, PERSONAL_VAULT_JOURNAL_SLUG) || probe(deps.stateDir, "personal");
|
|
246
|
+
return probe(deps.stateDir);
|
|
247
|
+
}
|
|
248
|
+
function restoreCorruptIdentity(deps, identities, options) {
|
|
249
|
+
const recover = deps.exports?.recoverCorruptPushIdentity;
|
|
250
|
+
if (!recover)
|
|
251
|
+
return { recovered: false, reason: "unproven", clearedMarker: false, clearedScopeFiles: 0 };
|
|
252
|
+
const personalOwnerUid = deps.exports?.readPersonalVaultOwnerUid?.() ?? null;
|
|
253
|
+
const slugs = options.company
|
|
254
|
+
? [options.company]
|
|
255
|
+
: options.personal
|
|
256
|
+
? [PERSONAL_VAULT_JOURNAL_SLUG, "personal"]
|
|
257
|
+
: undefined;
|
|
258
|
+
return recover(deps.stateDir, identities, {
|
|
259
|
+
personalOwnerUid,
|
|
260
|
+
...(slugs ? { slugs, limitToSlugs: true } : {}),
|
|
261
|
+
...(options.confirmUnproven ? { confirmUnproven: true } : {}),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function corruptRefusal(reason, released) {
|
|
265
|
+
const tail = released ? "The identity file was left unchanged." : "Nothing was changed.";
|
|
266
|
+
const confirm = `Run \`${CONFIRM_UNPROVEN_COMMAND}\` on this computer. It restores the file and keeps every upload held until you confirm which files are yours.`;
|
|
267
|
+
if (reason === "several-people") {
|
|
268
|
+
return `The identity file on this computer can't be read, and this computer's history names more than one person. ${tail} ${confirm}`;
|
|
269
|
+
}
|
|
270
|
+
if (reason === "different-person") {
|
|
271
|
+
return `The identity file on this computer can't be read, and the signed-in account is not the one this computer's history names. ${tail} Sign in as that account and run \`hq sync release-held\`.`;
|
|
272
|
+
}
|
|
273
|
+
return `The identity file on this computer can't be read, and no saved history on this computer names an account for it. ${tail} ${confirm}`;
|
|
274
|
+
}
|
|
127
275
|
async function confirmOnTty(question) {
|
|
128
276
|
if (process.stdin.isTTY !== true || process.stdout.isTTY !== true)
|
|
129
277
|
return false;
|
|
@@ -186,6 +334,7 @@ export function registerSyncHeldCommands(syncCmd) {
|
|
|
186
334
|
.option("--company <slug>", "Release only this company")
|
|
187
335
|
.option("--personal", "Release only the personal vault")
|
|
188
336
|
.option("--yes", "Do not ask for confirmation")
|
|
337
|
+
.option("--confirm-unproven", "Restore an unreadable identity file and keep every upload held until you confirm which files are yours")
|
|
189
338
|
.option("--json", "Print the result as JSON")
|
|
190
339
|
.action(async (options) => {
|
|
191
340
|
process.exitCode = await runReleaseHeld(createDefaultSyncHeldDeps(), options);
|
|
@@ -2,25 +2,10 @@
|
|
|
2
2
|
* hq whoami — displays current user or 'not logged in'
|
|
3
3
|
*/
|
|
4
4
|
import { Command } from 'commander';
|
|
5
|
+
import { type WhoamiTokenIdentity } from "../utils/whoami-identity.js";
|
|
5
6
|
import { type PlanLimitStatus } from "../lib/billing/plan-lock.js";
|
|
7
|
+
export { resolveWhoamiIdentity, type WhoamiDisplayIdentity, type WhoamiTokenIdentity, } from "../utils/whoami-identity.js";
|
|
6
8
|
export declare const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
|
|
7
|
-
export interface WhoamiTokenIdentity {
|
|
8
|
-
email?: string;
|
|
9
|
-
sub?: string;
|
|
10
|
-
delegatedEmail?: string;
|
|
11
|
-
delegatedSub?: string;
|
|
12
|
-
entityType?: string;
|
|
13
|
-
entityUid?: string;
|
|
14
|
-
}
|
|
15
|
-
export interface WhoamiDisplayIdentity {
|
|
16
|
-
email?: string;
|
|
17
|
-
sub?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Resolves the person represented by an ID token without pairing a delegated
|
|
21
|
-
* email with the token subject of the delegating machine.
|
|
22
|
-
*/
|
|
23
|
-
export declare function resolveWhoamiIdentity(identity: WhoamiTokenIdentity): WhoamiDisplayIdentity;
|
|
24
9
|
/**
|
|
25
10
|
* Bound on the person-uid lookup, so `--json` callers with short timeouts still
|
|
26
11
|
* get an answer. Kept at 1s: with every endpoint stalled, a whole `whoami
|
|
@@ -28,6 +13,14 @@ export declare function resolveWhoamiIdentity(identity: WhoamiTokenIdentity): Wh
|
|
|
28
13
|
* (foreground-network-budget.test.ts); 3s overran it.
|
|
29
14
|
*/
|
|
30
15
|
export declare const PERSON_UID_LOOKUP_TIMEOUT_MS = 1000;
|
|
16
|
+
/**
|
|
17
|
+
* The signed-in person's canonical `prs_*` uid for `whoami --json`. Person ID
|
|
18
|
+
* tokens carry no `custom:entityType`/`custom:entityUid` claims, so the token
|
|
19
|
+
* alone almost never has it; the vault's person-entity lookup does (the same
|
|
20
|
+
* rule `hq secrets --personal` uses). Best-effort: no session, a timeout or a
|
|
21
|
+
* network failure resolve to null and the rest of the identity still prints.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readPersonUid(identity: WhoamiTokenIdentity): Promise<string | null>;
|
|
31
24
|
export declare function renderWhoamiPlanBlock(status: PlanLimitStatus, opts?: {
|
|
32
25
|
inviteTeammateEnabled?: boolean;
|
|
33
26
|
}): string | null;
|
package/dist/commands/whoami.js
CHANGED
|
@@ -3,51 +3,17 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import { loadCachedTokens, isExpiring, loadMachineCreds, } from '@indigoai-us/hq-cloud';
|
|
6
|
-
import {
|
|
6
|
+
import { buildWhoamiIdentity, peekWhoamiTokenIdentity as peekIdToken, resolveWhoamiIdentity, } from "../utils/whoami-identity.js";
|
|
7
7
|
import { ensureCognitoToken, loadMachineCachedTokens, resolveCognitoTokenSource, } from "../utils/cognito-session.js";
|
|
8
8
|
import { colorizePlanLimitNotice, fetchPlanLimitStatus, renderPlanLine, renderPlanLimitNotice, } from "../lib/billing/plan-lock.js";
|
|
9
9
|
import { resolveCompanyFlagGate, } from "../lib/flag-registry.js";
|
|
10
10
|
import { queuePlanLimitInviteTeammateExposure } from "../utils/cli-telemetry.js";
|
|
11
11
|
import { resolveCallerPersonUid } from "../utils/vault-api.js";
|
|
12
12
|
import { printDeletedCompanyNotices } from "../utils/deleted-company-notice.js";
|
|
13
|
-
import {
|
|
13
|
+
import { formatAuthExpiry } from "../utils/auth-expiry.js";
|
|
14
14
|
import { authStatusExitCode } from "../utils/auth-session-check.js";
|
|
15
|
+
export { resolveWhoamiIdentity, } from "../utils/whoami-identity.js";
|
|
15
16
|
export const CLI_LIMIT_INVITE_TEAMMATE_FLAG = "cli.limit-invite-teammate-v1";
|
|
16
|
-
/**
|
|
17
|
-
* Resolves the person represented by an ID token without pairing a delegated
|
|
18
|
-
* email with the token subject of the delegating machine.
|
|
19
|
-
*/
|
|
20
|
-
export function resolveWhoamiIdentity(identity) {
|
|
21
|
-
if (identity.email !== undefined && identity.sub !== undefined) {
|
|
22
|
-
return { email: identity.email, sub: identity.sub };
|
|
23
|
-
}
|
|
24
|
-
if (identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined) {
|
|
25
|
-
return { email: identity.delegatedEmail, sub: identity.delegatedSub };
|
|
26
|
-
}
|
|
27
|
-
if (identity.email !== undefined || identity.sub !== undefined) {
|
|
28
|
-
return { email: identity.email, sub: identity.sub };
|
|
29
|
-
}
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
function peekIdToken(idToken) {
|
|
33
|
-
const decoded = decodeIdToken(idToken);
|
|
34
|
-
return {
|
|
35
|
-
email: typeof decoded.email === "string" ? decoded.email : undefined,
|
|
36
|
-
sub: typeof decoded.sub === "string" ? decoded.sub : undefined,
|
|
37
|
-
delegatedEmail: typeof decoded["custom:delegatedEmail"] === "string"
|
|
38
|
-
? decoded["custom:delegatedEmail"]
|
|
39
|
-
: undefined,
|
|
40
|
-
delegatedSub: typeof decoded["custom:delegatedSub"] === "string"
|
|
41
|
-
? decoded["custom:delegatedSub"]
|
|
42
|
-
: undefined,
|
|
43
|
-
entityType: typeof decoded["custom:entityType"] === "string"
|
|
44
|
-
? decoded["custom:entityType"]
|
|
45
|
-
: undefined,
|
|
46
|
-
entityUid: typeof decoded["custom:entityUid"] === "string"
|
|
47
|
-
? decoded["custom:entityUid"]
|
|
48
|
-
: undefined,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
17
|
/**
|
|
52
18
|
* Bound on the person-uid lookup, so `--json` callers with short timeouts still
|
|
53
19
|
* get an answer. Kept at 1s: with every endpoint stalled, a whole `whoami
|
|
@@ -62,7 +28,7 @@ export const PERSON_UID_LOOKUP_TIMEOUT_MS = 1_000;
|
|
|
62
28
|
* rule `hq secrets --personal` uses). Best-effort: no session, a timeout or a
|
|
63
29
|
* network failure resolve to null and the rest of the identity still prints.
|
|
64
30
|
*/
|
|
65
|
-
async function readPersonUid(identity) {
|
|
31
|
+
export async function readPersonUid(identity) {
|
|
66
32
|
if (identity.entityType === 'person' && identity.entityUid)
|
|
67
33
|
return identity.entityUid;
|
|
68
34
|
try {
|
|
@@ -170,7 +136,7 @@ export function registerWhoamiCommand(program) {
|
|
|
170
136
|
.description('Show signed-in user and session expiry')
|
|
171
137
|
.option('--json', 'Output identity metadata as JSON (never tokens)')
|
|
172
138
|
.option('--company <slug>', 'Also report this company\'s billing and usage notice')
|
|
173
|
-
.option('--check', 'Exit 1 when there is no usable session,
|
|
139
|
+
.option('--check', 'Exit 1 when there is no usable session, so a script can test the exit status')
|
|
174
140
|
.action(async (opts) => {
|
|
175
141
|
try {
|
|
176
142
|
// Effective source (same as auth status / ensureCognitoToken): env
|
|
@@ -199,48 +165,10 @@ export function registerWhoamiCommand(program) {
|
|
|
199
165
|
}
|
|
200
166
|
async function printWhoami(opts, machine, cached) {
|
|
201
167
|
if (opts.json) {
|
|
202
|
-
const machineCreds = machine ? loadMachineCreds() : null;
|
|
203
|
-
const identityCache = machine ? loadMachineCachedTokens() : cached;
|
|
204
|
-
const identity = identityCache ? peekIdToken(identityCache.idToken) : {};
|
|
205
|
-
const displayedIdentity = resolveWhoamiIdentity(identity);
|
|
206
|
-
const claims = identityCache ? decodeIdToken(identityCache.idToken) : {};
|
|
207
|
-
// Modern credentials carry the canonical UID. Legacy caches may only
|
|
208
|
-
// supply a UID when their subject is bound to the selected username.
|
|
209
|
-
const boundLegacyAgent = machineCreds && identity.entityType === 'agent'
|
|
210
|
-
&& (claims['cognito:username'] === machineCreds.username
|
|
211
|
-
|| claims.username === machineCreds.username || claims.sub === machineCreds.username)
|
|
212
|
-
? identity.entityUid ?? null : null;
|
|
213
|
-
const agentUid = machineCreds?.entityUid !== undefined
|
|
214
|
-
? (machineCreds.entityUid.startsWith('agt_') ? machineCreds.entityUid : null)
|
|
215
|
-
: boundLegacyAgent;
|
|
216
168
|
// planLimits is additive: absent-or-null means UNKNOWN.
|
|
217
169
|
const planLimits = await readPlanLimits(opts.company);
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
console.log(JSON.stringify({
|
|
221
|
-
schemaVersion: 1,
|
|
222
|
-
authenticated,
|
|
223
|
-
tokenSource: machine ? 'machine' : 'person',
|
|
224
|
-
email: machine ? null : displayedIdentity.email ?? null,
|
|
225
|
-
// Cognito subject of the person shown in `email` (null for machine
|
|
226
|
-
// identities). Outpost jobs record owners by this id.
|
|
227
|
-
sub: machine ? null : displayedIdentity.sub ?? null,
|
|
228
|
-
// The human an Outpost session acts for, from the token's
|
|
229
|
-
// delegated claims, for machine and person sources alike.
|
|
230
|
-
delegatedEmail: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
231
|
-
? identity.delegatedEmail : null,
|
|
232
|
-
delegatedSub: identity.delegatedEmail !== undefined && identity.delegatedSub !== undefined
|
|
233
|
-
? identity.delegatedSub : null,
|
|
234
|
-
personUid,
|
|
235
|
-
agentUid,
|
|
236
|
-
username: machineCreds?.username ?? null,
|
|
237
|
-
// Additive (what `hq auth status` reported): when the cached
|
|
238
|
-
// session expires, and whether it is inside the refresh window.
|
|
239
|
-
// Both are null when no session is cached.
|
|
240
|
-
sessionExpiresAt: identityCache ? authExpiryIso(identityCache.expiresAt) : null,
|
|
241
|
-
sessionExpiring: identityCache ? isExpiring(identityCache) : null,
|
|
242
|
-
planLimits,
|
|
243
|
-
}, null, 2));
|
|
170
|
+
const identity = await buildWhoamiIdentity(machine, cached, readPersonUid, () => loadMachineCachedTokens());
|
|
171
|
+
console.log(JSON.stringify({ ...identity, planLimits }, null, 2));
|
|
244
172
|
return;
|
|
245
173
|
}
|
|
246
174
|
if (machine) {
|
|
@@ -3,13 +3,26 @@
|
|
|
3
3
|
"commands": {
|
|
4
4
|
"auth login": { "state": "retiring", "replacedBy": "hq login" },
|
|
5
5
|
"auth logout": { "state": "retiring", "replacedBy": "hq logout" },
|
|
6
|
+
"auth status": { "state": "retiring", "replacedBy": "hq whoami --check" },
|
|
7
|
+
"bot set-model": { "state": "retiring", "replacedBy": "hq bot set --model" },
|
|
6
8
|
"crm entity get": { "state": "retiring" },
|
|
7
9
|
"crm entity list": { "state": "retiring" },
|
|
10
|
+
"mesh blocked": { "state": "retiring", "replacedBy": "hq mesh session blocked" },
|
|
11
|
+
"mesh daemon doctor": { "state": "retiring", "replacedBy": "hq daemon doctor" },
|
|
12
|
+
"mesh daemon install": { "state": "retiring", "replacedBy": "hq daemon install" },
|
|
13
|
+
"mesh daemon run": { "state": "retiring", "replacedBy": "hq daemon run" },
|
|
14
|
+
"mesh daemon status": { "state": "retiring", "replacedBy": "hq daemon status" },
|
|
15
|
+
"mesh daemon uninstall": { "state": "retiring", "replacedBy": "hq daemon disable mesh" },
|
|
16
|
+
"mesh done": { "state": "retiring", "replacedBy": "hq mesh session task-status --status done" },
|
|
17
|
+
"mesh note": { "state": "retiring", "replacedBy": "hq mesh session note" },
|
|
18
|
+
"mesh progress": { "state": "retiring", "replacedBy": "hq mesh session note" },
|
|
19
|
+
"mesh start": { "state": "retiring", "replacedBy": "hq mesh session task-status --status in_progress" },
|
|
8
20
|
"packages install": { "state": "retiring", "replacedBy": "hq install" },
|
|
9
21
|
"packages packs list": { "state": "retiring", "replacedBy": "hq packs list" },
|
|
10
22
|
"packages packs uninstall": { "state": "retiring", "replacedBy": "hq packs uninstall" },
|
|
11
23
|
"packages packs update": { "state": "retiring", "replacedBy": "hq packs update" },
|
|
12
24
|
"packages remove": { "state": "retiring", "replacedBy": "hq remove" },
|
|
25
|
+
"packages update": { "state": "retiring", "replacedBy": "hq packs update --registry" },
|
|
13
26
|
"report access": { "state": "retiring" },
|
|
14
27
|
"report discard-draft": { "state": "retiring" },
|
|
15
28
|
"report promote": { "state": "retiring" },
|