@indigoai-us/hq-cli 5.345.222 → 5.345.225
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 +89 -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 +79 -5
- package/dist/command-catalog.generated.js +95 -5
- package/dist/commands/bot.d.ts +1 -1
- package/dist/commands/bot.js +34 -33
- 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 +210 -188
- 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 +67 -1
- 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-session-start.js +2 -2
- 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 +14 -3
- package/dist/commands/sync-core.js +31 -12
- 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/index.js +1 -1
- package/dist/lib/bot/fleet-cron.d.ts +26 -3
- package/dist/lib/bot/fleet-cron.js +44 -4
- package/dist/lib/bot/run.d.ts +4 -4
- package/dist/lib/bot/run.js +5 -3
- package/dist/lib/bot/signals-engine-flag.d.ts +53 -13
- package/dist/lib/bot/signals-engine-flag.js +202 -9
- package/dist/lib/daemon/catalog.d.ts +8 -5
- package/dist/lib/daemon/catalog.js +13 -7
- package/dist/lib/daemon/config.d.ts +5 -0
- package/dist/lib/daemon/config.js +6 -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/machine-checks.d.ts +45 -0
- package/dist/lib/daemon/machine-checks.js +95 -11
- package/dist/lib/daemon/merge-sections.d.ts +165 -0
- package/dist/lib/daemon/merge-sections.js +556 -0
- package/dist/lib/daemon/native-notice-ledger.d.ts +9 -0
- package/dist/lib/daemon/native-notice-ledger.js +43 -0
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +1 -1
- package/dist/lib/daemon/protocol.d.ts +1 -1
- package/dist/lib/daemon/protocol.js +0 -6
- package/dist/lib/daemon/run.js +76 -3
- package/dist/lib/daemon/selfcheck.js +2 -2
- package/dist/lib/daemon/server.d.ts +2 -4
- package/dist/lib/daemon/server.js +5 -48
- 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 +11 -1
- package/dist/lib/daemon/supervisor.js +86 -0
- 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/flag-registry-worker.js +33 -3
- package/dist/lib/flag-registry.js +13 -0
- 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/envelope-repair-dispatch.js +1 -1
- package/dist/lib/lanes/monitor.d.ts +2 -0
- package/dist/lib/lanes/monitor.js +2 -1
- 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/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/scan-packages/index.js +8 -9
- package/dist/lib/signals/engine.d.ts +8 -0
- package/dist/lib/signals/engine.js +15 -5
- package/dist/lib/sync-core/flag.d.ts +18 -0
- package/dist/lib/sync-core/flag.js +66 -0
- package/dist/lib/sync-core/reconcile.d.ts +6 -0
- package/dist/lib/sync-core/reconcile.js +15 -0
- package/dist/lib/sync-core/rollout-state.d.ts +2 -0
- package/dist/lib/sync-core/rollout-state.js +7 -0
- package/dist/lib/sync-core/vault-settings.d.ts +12 -1
- package/dist/lib/sync-core/vault-settings.js +23 -7
- 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/pack-contributions.d.ts +14 -2
- package/dist/utils/pack-contributions.js +31 -5
- 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 +7 -7
- package/scripts/bench-core.mjs +34 -3
- 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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
3
|
import { isSyncCoreVaultUid } from "./vault-uid.js";
|
|
4
|
+
import { SYNC_CORE_DOWNLOAD_STREAMS_MAX } from "./vault-settings.js";
|
|
4
5
|
const FIRST_CYCLE_COUNTS = [
|
|
5
6
|
"planned",
|
|
6
7
|
"completed",
|
|
@@ -63,6 +64,11 @@ function vault(value) {
|
|
|
63
64
|
const cycle = v.firstCycle === undefined ? undefined : firstCycle(v.firstCycle);
|
|
64
65
|
if (cycle === null)
|
|
65
66
|
return null;
|
|
67
|
+
// An invalid company value is dropped rather than failing the whole state.
|
|
68
|
+
const streams = typeof v.downloadStreams === "number" && Number.isInteger(v.downloadStreams)
|
|
69
|
+
&& v.downloadStreams >= 1 && v.downloadStreams <= SYNC_CORE_DOWNLOAD_STREAMS_MAX
|
|
70
|
+
? v.downloadStreams
|
|
71
|
+
: undefined;
|
|
66
72
|
return {
|
|
67
73
|
uid: v.uid,
|
|
68
74
|
kind: v.kind,
|
|
@@ -72,6 +78,7 @@ function vault(value) {
|
|
|
72
78
|
...(typeof v.legacyOffSince === "string" ? { legacyOffSince: v.legacyOffSince } : {}),
|
|
73
79
|
...(v.legacyAlreadyOff === true ? { legacyAlreadyOff: true } : {}),
|
|
74
80
|
...(cycle ? { firstCycle: cycle } : {}),
|
|
81
|
+
...(streams !== undefined ? { downloadStreams: streams } : {}),
|
|
75
82
|
};
|
|
76
83
|
}
|
|
77
84
|
export function readSyncCoreRolloutState(home) {
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One computer's setting for one vault. `parallelDownloads: false` is an
|
|
3
|
+
* explicit off on this computer, which outranks the company flag; no entry at
|
|
4
|
+
* all follows the company (see effectiveEngineSettings).
|
|
5
|
+
*/
|
|
1
6
|
export interface SyncCoreVaultSettings {
|
|
2
7
|
parallelDownloads?: boolean;
|
|
3
8
|
downloadStreams?: number;
|
|
@@ -12,10 +17,16 @@ export declare function readSyncCoreVaultSettings(home: string, opts?: {
|
|
|
12
17
|
strict?: boolean;
|
|
13
18
|
}): Map<string, SyncCoreVaultSettings>;
|
|
14
19
|
export declare function parseSyncCoreVaultSetting(key: string, value: string): {
|
|
15
|
-
parallelDownloads: boolean;
|
|
20
|
+
parallelDownloads: boolean | undefined;
|
|
16
21
|
} | {
|
|
17
22
|
downloadStreams: number | undefined;
|
|
18
23
|
};
|
|
19
24
|
export declare function setSyncCoreVaultSetting(home: string, vaultUid: string, key: string, value: string): SyncCoreVaultSettings | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* What one vault's engine runs with: this computer's setting when it has one
|
|
27
|
+
* (on or an explicit off), otherwise the company's stream count from the flag
|
|
28
|
+
* registry, otherwise nothing (the engine default, off).
|
|
29
|
+
*/
|
|
30
|
+
export declare function effectiveEngineSettings(local: SyncCoreVaultSettings | undefined, companyStreams: number | undefined): SyncCoreVaultSettings | undefined;
|
|
20
31
|
export declare function engineSettingsEnv(settings: SyncCoreVaultSettings | undefined): Record<string, string>;
|
|
21
32
|
//# sourceMappingURL=vault-settings.d.ts.map
|
|
@@ -15,6 +15,8 @@ function cleanSettings(raw) {
|
|
|
15
15
|
return undefined;
|
|
16
16
|
const record = raw;
|
|
17
17
|
const settings = {};
|
|
18
|
+
if (record.parallel_downloads === false)
|
|
19
|
+
return { parallelDownloads: false };
|
|
18
20
|
if (record.parallel_downloads !== true)
|
|
19
21
|
return undefined;
|
|
20
22
|
settings.parallelDownloads = true;
|
|
@@ -64,7 +66,7 @@ function writeAll(home, all) {
|
|
|
64
66
|
const vaults = {};
|
|
65
67
|
for (const [uid, settings] of [...all.entries()].sort(([a], [b]) => a.localeCompare(b))) {
|
|
66
68
|
vaults[uid] = {
|
|
67
|
-
|
|
69
|
+
parallel_downloads: settings.parallelDownloads === true,
|
|
68
70
|
...(settings.downloadStreams !== undefined ? { download_streams: settings.downloadStreams } : {}),
|
|
69
71
|
};
|
|
70
72
|
}
|
|
@@ -79,7 +81,9 @@ export function parseSyncCoreVaultSetting(key, value) {
|
|
|
79
81
|
return { parallelDownloads: true };
|
|
80
82
|
if (value === "off")
|
|
81
83
|
return { parallelDownloads: false };
|
|
82
|
-
|
|
84
|
+
if (value === "default")
|
|
85
|
+
return { parallelDownloads: undefined };
|
|
86
|
+
throw new SyncCoreVaultSettingError(`parallel-downloads takes on or off, or default to follow the company setting, not ${JSON.stringify(value)}`);
|
|
83
87
|
}
|
|
84
88
|
if (key === "download-streams") {
|
|
85
89
|
if (value === "default")
|
|
@@ -95,12 +99,12 @@ export function parseSyncCoreVaultSetting(key, value) {
|
|
|
95
99
|
export function setSyncCoreVaultSetting(home, vaultUid, key, value) {
|
|
96
100
|
const change = parseSyncCoreVaultSetting(key, value);
|
|
97
101
|
const all = readSyncCoreVaultSettings(home, { strict: true });
|
|
98
|
-
|
|
102
|
+
let next = { ...all.get(vaultUid) };
|
|
99
103
|
if ("parallelDownloads" in change) {
|
|
100
|
-
if (change.parallelDownloads)
|
|
101
|
-
next
|
|
104
|
+
if (change.parallelDownloads === undefined)
|
|
105
|
+
next = {};
|
|
102
106
|
else
|
|
103
|
-
|
|
107
|
+
next.parallelDownloads = change.parallelDownloads;
|
|
104
108
|
}
|
|
105
109
|
else if (change.downloadStreams === undefined) {
|
|
106
110
|
delete next.downloadStreams;
|
|
@@ -113,13 +117,25 @@ export function setSyncCoreVaultSetting(home, vaultUid, key, value) {
|
|
|
113
117
|
}
|
|
114
118
|
if (!next.parallelDownloads)
|
|
115
119
|
delete next.downloadStreams;
|
|
116
|
-
if (
|
|
120
|
+
if (next.parallelDownloads === undefined)
|
|
117
121
|
all.delete(vaultUid);
|
|
118
122
|
else
|
|
119
123
|
all.set(vaultUid, next);
|
|
120
124
|
writeAll(home, all);
|
|
121
125
|
return all.get(vaultUid);
|
|
122
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* What one vault's engine runs with: this computer's setting when it has one
|
|
129
|
+
* (on or an explicit off), otherwise the company's stream count from the flag
|
|
130
|
+
* registry, otherwise nothing (the engine default, off).
|
|
131
|
+
*/
|
|
132
|
+
export function effectiveEngineSettings(local, companyStreams) {
|
|
133
|
+
if (local?.parallelDownloads !== undefined)
|
|
134
|
+
return local;
|
|
135
|
+
if (companyStreams === undefined)
|
|
136
|
+
return undefined;
|
|
137
|
+
return { parallelDownloads: true, downloadStreams: companyStreams };
|
|
138
|
+
}
|
|
123
139
|
export function engineSettingsEnv(settings) {
|
|
124
140
|
if (!settings?.parallelDownloads)
|
|
125
141
|
return {};
|
|
@@ -20,7 +20,7 @@ export function isInstallFollowupSkipped(argv, env) {
|
|
|
20
20
|
const args = argv.slice(2).filter((arg) => arg !== "--verbose");
|
|
21
21
|
if (args[0] === "mesh" && args[1] === "daemon")
|
|
22
22
|
return true;
|
|
23
|
-
if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install"))
|
|
23
|
+
if (args[0] === "daemon" && (args[1] === "run" || args[1] === "install" || args[1] === "service"))
|
|
24
24
|
return true;
|
|
25
25
|
return false;
|
|
26
26
|
}
|
|
@@ -157,6 +157,7 @@ export interface ClientHealthHeartbeat {
|
|
|
157
157
|
daemonHqCloudUpdateOutcome?: ClientHealthDaemonHqCloudUpdateOutcome;
|
|
158
158
|
daemonHqCloudUpdateTarget?: string;
|
|
159
159
|
daemonHqCloudUpdateErrorClass?: ClientHealthDaemonHqCloudUpdateErrorClass;
|
|
160
|
+
daemonCliVersion?: string;
|
|
160
161
|
/** Absent on older clients / non-sync-outcome events. See {@link ClientHealthLocalFilesOverview}. */
|
|
161
162
|
localFilesOverview?: ClientHealthLocalFilesOverview;
|
|
162
163
|
}
|
|
@@ -328,6 +328,11 @@ export function parseClientHealthHeartbeat(input) {
|
|
|
328
328
|
heartbeat.daemonHqCloudUpdateTarget = target;
|
|
329
329
|
}
|
|
330
330
|
copyKnownOptionalEnum(heartbeat, "daemonHqCloudUpdateErrorClass", raw.daemonHqCloudUpdateErrorClass, CLIENT_HEALTH_DAEMON_HQ_CLOUD_UPDATE_ERROR_CLASSES);
|
|
331
|
+
if (raw.daemonCliVersion !== undefined) {
|
|
332
|
+
const daemonCliVersion = copyValidOptionalDiagnostic("daemonCliVersion", raw.daemonCliVersion, assertVersion);
|
|
333
|
+
if (daemonCliVersion !== undefined)
|
|
334
|
+
heartbeat.daemonCliVersion = daemonCliVersion;
|
|
335
|
+
}
|
|
331
336
|
if (raw.localFilesOverview !== undefined) {
|
|
332
337
|
heartbeat.localFilesOverview = parseClientHealthLocalFilesOverview("localFilesOverview", raw.localFilesOverview);
|
|
333
338
|
}
|
|
@@ -179,6 +179,7 @@ export interface BuildCliHeartbeatInput {
|
|
|
179
179
|
*/
|
|
180
180
|
localFilesOverview?: ClientHealthLocalFilesOverview | null;
|
|
181
181
|
syncEngine?: CliSyncEngine | null;
|
|
182
|
+
daemonCliVersion?: string | null;
|
|
182
183
|
}
|
|
183
184
|
export interface CliSyncEngine {
|
|
184
185
|
release: string;
|
|
@@ -212,6 +213,7 @@ export interface ClientHealthDeps {
|
|
|
212
213
|
/** US-016: overridable for tests; defaults to {@link collectLocalFilesOverview}. */
|
|
213
214
|
localFilesOverview?: () => ClientHealthLocalFilesOverview;
|
|
214
215
|
syncEngine?: () => CliSyncEngine | null;
|
|
216
|
+
daemonCliVersion?: () => Promise<string | null>;
|
|
215
217
|
/** Override for {@link JOURNAL_OBSERVATION_TTL_MS}. */
|
|
216
218
|
journalObservationTtlMs?: number;
|
|
217
219
|
/** Override for {@link JOURNAL_OBSERVATION_LOCK_STALE_MS}. */
|
|
@@ -40,6 +40,7 @@ import { getStateDir, listJournals } from "@indigoai-us/hq-cloud";
|
|
|
40
40
|
import { isExpiring, isMachineIdentity, loadCachedTokens, } from "./cognito-session.js";
|
|
41
41
|
import { vaultApiFetch } from "./vault-api.js";
|
|
42
42
|
import { collectVersions } from "./feedback-versions.js";
|
|
43
|
+
import { resolveDaemonCliVersion } from "./daemon-cli-version.js";
|
|
43
44
|
import { isAuthError } from "./auth-error.js";
|
|
44
45
|
import { CLIENT_HEALTH_CONTRACT_VERSION, CLIENT_HEALTH_MAX_SYNC_ENGINE_VAULTS, parseClientHealthHeartbeat, } from "./client-health-contract.js";
|
|
45
46
|
import { collectLocalFilesOverview } from "./local-files-overview.js";
|
|
@@ -508,6 +509,9 @@ export function buildCliHeartbeat(input) {
|
|
|
508
509
|
if (SEMVER.test(engineVersion))
|
|
509
510
|
versions.syncEngine = engineVersion;
|
|
510
511
|
}
|
|
512
|
+
if (input.daemonCliVersion && SEMVER.test(input.daemonCliVersion)) {
|
|
513
|
+
heartbeat.daemonCliVersion = input.daemonCliVersion;
|
|
514
|
+
}
|
|
511
515
|
return heartbeat;
|
|
512
516
|
}
|
|
513
517
|
const defaultPoster = (heartbeat, token, signal) => vaultApiFetch({
|
|
@@ -674,6 +678,16 @@ async function contributeClientHealthUnbounded(kind, deps, failureReason) {
|
|
|
674
678
|
catch {
|
|
675
679
|
syncEngine = null;
|
|
676
680
|
}
|
|
681
|
+
// Bounded on its own budget so a slow parent-process lookup (up to 2 s on
|
|
682
|
+
// Windows) leaves the field off instead of using up the whole
|
|
683
|
+
// contribution bound and dropping the heartbeat.
|
|
684
|
+
let daemonCliVersion = null;
|
|
685
|
+
try {
|
|
686
|
+
daemonCliVersion = await valueWithin((deps.daemonCliVersion ?? processDaemonCliVersion)(), DAEMON_CLI_VERSION_BUDGET_MS);
|
|
687
|
+
}
|
|
688
|
+
catch {
|
|
689
|
+
daemonCliVersion = null;
|
|
690
|
+
}
|
|
677
691
|
const heartbeat = buildCliHeartbeat({
|
|
678
692
|
kind,
|
|
679
693
|
state,
|
|
@@ -684,6 +698,7 @@ async function contributeClientHealthUnbounded(kind, deps, failureReason) {
|
|
|
684
698
|
localFilesOverview,
|
|
685
699
|
failureReason,
|
|
686
700
|
syncEngine,
|
|
701
|
+
daemonCliVersion,
|
|
687
702
|
});
|
|
688
703
|
if (!heartbeat)
|
|
689
704
|
return;
|
|
@@ -706,6 +721,31 @@ async function contributeClientHealthUnbounded(kind, deps, failureReason) {
|
|
|
706
721
|
// Health contribution is best effort and must never affect a CLI command.
|
|
707
722
|
}
|
|
708
723
|
}
|
|
724
|
+
/**
|
|
725
|
+
* How long one heartbeat waits for the daemon CLI version. Well inside
|
|
726
|
+
* {@link CLIENT_HEALTH_TIMEOUT_MS}. The lookup is memoised per process, so a
|
|
727
|
+
* value that misses this budget is still used by later heartbeats.
|
|
728
|
+
*/
|
|
729
|
+
const DAEMON_CLI_VERSION_BUDGET_MS = 300;
|
|
730
|
+
/** Resolve with `work`'s value, or null if it rejects or takes longer than `ms`. */
|
|
731
|
+
function valueWithin(work, ms) {
|
|
732
|
+
return new Promise((resolve) => {
|
|
733
|
+
const timer = setTimeout(() => resolve(null), ms);
|
|
734
|
+
timer.unref?.();
|
|
735
|
+
work.then((value) => {
|
|
736
|
+
clearTimeout(timer);
|
|
737
|
+
resolve(value);
|
|
738
|
+
}, () => {
|
|
739
|
+
clearTimeout(timer);
|
|
740
|
+
resolve(null);
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
let daemonCliVersionPromise;
|
|
745
|
+
function processDaemonCliVersion() {
|
|
746
|
+
daemonCliVersionPromise ??= resolveDaemonCliVersion().catch(() => null);
|
|
747
|
+
return daemonCliVersionPromise;
|
|
748
|
+
}
|
|
709
749
|
// ─── Command wiring ──────────────────────────────────────────────────────────
|
|
710
750
|
let invocationPromise;
|
|
711
751
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
import { isExpiring, isMachineIdentity, type CognitoAuthConfig, type CognitoTokens, type ClientInfo, type VaultServiceConfig } from "@indigoai-us/hq-cloud";
|
|
22
22
|
import { hasPersonCachedSession, isMachineCredsFileEnvSet, wantsMachineCognitoTokens, type CognitoTokenSource } from "./machine-principal-state.js";
|
|
23
|
+
import { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir } from "./machine-token-cache.js";
|
|
24
|
+
export { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir };
|
|
23
25
|
import { HQ_NO_BROWSER_LOGIN_ENV, type InteractiveCallerInput } from "./interactive-caller.js";
|
|
24
26
|
import { loadCachedTokens, personTokenCacheFile, readPersonTokenFile } from "./person-token-cache.js";
|
|
25
27
|
export { loadCachedTokens, personTokenCacheFile, readPersonTokenFile };
|
|
@@ -33,7 +35,6 @@ export type CognitoActorKind = "human" | "agent" | "unknown";
|
|
|
33
35
|
* Default: the work-mesh daemon state dir (`~/.hq/work-mesh/daemon`), so a
|
|
34
36
|
* machine mint never overwrites a person's `~/.hq/cognito-tokens.json`.
|
|
35
37
|
*/
|
|
36
|
-
export declare const HQ_MACHINE_TOKEN_STATE_DIR_ENV = "HQ_MACHINE_TOKEN_STATE_DIR";
|
|
37
38
|
export declare const DEFAULT_COGNITO: CognitoAuthConfig;
|
|
38
39
|
export declare const DEFAULT_VAULT_API_URL: string;
|
|
39
40
|
/**
|
|
@@ -93,14 +94,6 @@ export declare function resolveDefaultHqRoot(opts?: {
|
|
|
93
94
|
platform?: NodeJS.Platform;
|
|
94
95
|
}): string;
|
|
95
96
|
export declare const DEFAULT_HQ_ROOT: string;
|
|
96
|
-
/**
|
|
97
|
-
* Directory used as `HQ_STATE_DIR` while minting/caching machine Cognito
|
|
98
|
-
* tokens. Never the person's `~/.hq` — agent boxes write under the daemon
|
|
99
|
-
* state dir so a mint cannot clobber a human login cache.
|
|
100
|
-
*/
|
|
101
|
-
export declare function machineTokenStateDir(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
102
|
-
/** Absolute path of the machine-token cache file (daemon state dir). */
|
|
103
|
-
export declare function machineTokenCacheFile(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
104
97
|
/** Default machine-creds path hq-cloud also checks when the env is unset. */
|
|
105
98
|
export declare function defaultMachineCredsFile(home?: string): string;
|
|
106
99
|
export type EnsureCognitoTokenOptions = {
|
|
@@ -181,11 +174,6 @@ export declare function refreshActivePersonTokens(cached: CognitoTokens, env?: N
|
|
|
181
174
|
export declare function refreshActivePersonTokensForClientHealth(cached: CognitoTokens, signal: AbortSignal): Promise<CognitoTokens>;
|
|
182
175
|
/** Derive actor kind from an ID token's custom:entity* claims (no verify). */
|
|
183
176
|
export declare function actorKindFromIdToken(idToken: string | undefined): CognitoActorKind;
|
|
184
|
-
/**
|
|
185
|
-
* Peek the machine-token cache under the daemon state dir without minting.
|
|
186
|
-
* Used by doctor; never logs token material.
|
|
187
|
-
*/
|
|
188
|
-
export declare function loadMachineCachedTokens(home?: string, env?: NodeJS.ProcessEnv): CognitoTokens | null;
|
|
189
177
|
/**
|
|
190
178
|
* Report token source + actor kind for `hq mesh daemon doctor`. Does not mint
|
|
191
179
|
* or hit the network. Machine identity without a readable cache still reports
|
|
@@ -28,8 +28,8 @@ import chalk from "chalk";
|
|
|
28
28
|
import { isExpiring, refreshTokens, saveCachedTokens, browserLogin, detectHqCoreVersion, isMachineIdentity, getValidMachineTokens, CognitoRefreshError, accessTokenFingerprint, invalidateCachedTokensByFingerprint, } from "@indigoai-us/hq-cloud";
|
|
29
29
|
import { hasPersonCachedSession, isMachineCredsFileEnvSet, probeMachineIdentity, wantsMachineCognitoTokens, } from "./machine-principal-state.js";
|
|
30
30
|
import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
|
|
31
|
-
import {
|
|
32
|
-
|
|
31
|
+
import { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir, } from "./machine-token-cache.js";
|
|
32
|
+
export { HQ_MACHINE_TOKEN_STATE_DIR_ENV, loadMachineCachedTokens, machineTokenCacheFile, machineTokenStateDir };
|
|
33
33
|
import { defaultHqRootFallback, hqDiscoveryCandidates, pathForPlatform, } from "./hq-root-resolver.js";
|
|
34
34
|
import { acquireLockFileExclusively } from "./exclusive-lock.js";
|
|
35
35
|
import { interactiveLoginConfig, resolveCognitoCallbackPort } from "./cognito-callback-port.js";
|
|
@@ -46,7 +46,6 @@ export { hasPersonCachedSession, isMachineCredsFileEnvSet, wantsMachineCognitoTo
|
|
|
46
46
|
* Default: the work-mesh daemon state dir (`~/.hq/work-mesh/daemon`), so a
|
|
47
47
|
* machine mint never overwrites a person's `~/.hq/cognito-tokens.json`.
|
|
48
48
|
*/
|
|
49
|
-
export const HQ_MACHINE_TOKEN_STATE_DIR_ENV = "HQ_MACHINE_TOKEN_STATE_DIR";
|
|
50
49
|
export const DEFAULT_COGNITO = {
|
|
51
50
|
region: process.env.AWS_REGION ?? "us-east-1",
|
|
52
51
|
userPoolDomain: process.env.HQ_COGNITO_DOMAIN ?? "vault-indigo-hq-prod",
|
|
@@ -230,21 +229,6 @@ function isHqRoot(dir, p = path) {
|
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
231
|
export const DEFAULT_HQ_ROOT = resolveDefaultHqRoot();
|
|
233
|
-
/**
|
|
234
|
-
* Directory used as `HQ_STATE_DIR` while minting/caching machine Cognito
|
|
235
|
-
* tokens. Never the person's `~/.hq` — agent boxes write under the daemon
|
|
236
|
-
* state dir so a mint cannot clobber a human login cache.
|
|
237
|
-
*/
|
|
238
|
-
export function machineTokenStateDir(home = os.homedir(), env = process.env) {
|
|
239
|
-
const override = env[HQ_MACHINE_TOKEN_STATE_DIR_ENV]?.trim();
|
|
240
|
-
if (override)
|
|
241
|
-
return override;
|
|
242
|
-
return daemonDir(workMeshRoot(home, env), home, env);
|
|
243
|
-
}
|
|
244
|
-
/** Absolute path of the machine-token cache file (daemon state dir). */
|
|
245
|
-
export function machineTokenCacheFile(home = os.homedir(), env = process.env) {
|
|
246
|
-
return path.join(machineTokenStateDir(home, env), "cognito-tokens.json");
|
|
247
|
-
}
|
|
248
232
|
/** Default machine-creds path hq-cloud also checks when the env is unset. */
|
|
249
233
|
export function defaultMachineCredsFile(home = os.homedir()) {
|
|
250
234
|
return path.join(home, ".hq-agent", "machine-creds.json");
|
|
@@ -662,28 +646,6 @@ export function actorKindFromIdToken(idToken) {
|
|
|
662
646
|
}
|
|
663
647
|
return "human";
|
|
664
648
|
}
|
|
665
|
-
/**
|
|
666
|
-
* Peek the machine-token cache under the daemon state dir without minting.
|
|
667
|
-
* Used by doctor; never logs token material.
|
|
668
|
-
*/
|
|
669
|
-
export function loadMachineCachedTokens(home = os.homedir(), env = process.env) {
|
|
670
|
-
const file = machineTokenCacheFile(home, env);
|
|
671
|
-
try {
|
|
672
|
-
if (!fs.existsSync(file))
|
|
673
|
-
return null;
|
|
674
|
-
const raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
675
|
-
if (typeof raw.accessToken !== "string" ||
|
|
676
|
-
typeof raw.idToken !== "string" ||
|
|
677
|
-
raw.accessToken.length === 0 ||
|
|
678
|
-
raw.idToken.length === 0) {
|
|
679
|
-
return null;
|
|
680
|
-
}
|
|
681
|
-
return raw;
|
|
682
|
-
}
|
|
683
|
-
catch {
|
|
684
|
-
return null;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
649
|
/**
|
|
688
650
|
* Report token source + actor kind for `hq mesh daemon doctor`. Does not mint
|
|
689
651
|
* or hit the network. Machine identity without a readable cache still reports
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const PARENT_COMMAND_LINE_TIMEOUT_MS = 2000;
|
|
2
|
+
export interface DaemonCliVersionDeps {
|
|
3
|
+
env?: NodeJS.ProcessEnv;
|
|
4
|
+
parentCommandLine?: () => Promise<string | null>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The version a daemon handed to the staged child bootstrap that started this
|
|
8
|
+
* unit: `<node> <...>/hq-child-bootstrap.mjs <prefix> <version> [args]`.
|
|
9
|
+
* Daemons have started units this way since 2026-10-05 (#1541).
|
|
10
|
+
*/
|
|
11
|
+
export declare function daemonVersionFromBootstrapCommandLine(line: string | null): string | null;
|
|
12
|
+
export declare function resolveDaemonCliVersion(deps?: DaemonCliVersionDeps): Promise<string | null>;
|
|
13
|
+
//# sourceMappingURL=daemon-cli-version.d.ts.map
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
const SEMVER = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
3
|
+
export const PARENT_COMMAND_LINE_TIMEOUT_MS = 2_000;
|
|
4
|
+
function readParentCommandLine() {
|
|
5
|
+
const pid = Math.trunc(process.ppid);
|
|
6
|
+
const [cmd, args] = process.platform === "win32"
|
|
7
|
+
? [
|
|
8
|
+
"powershell.exe",
|
|
9
|
+
[
|
|
10
|
+
"-NoProfile",
|
|
11
|
+
"-NonInteractive",
|
|
12
|
+
"-Command",
|
|
13
|
+
`(Get-CimInstance Win32_Process -Filter "ProcessId=${pid}").CommandLine`,
|
|
14
|
+
],
|
|
15
|
+
]
|
|
16
|
+
: ["ps", ["-ww", "-o", "args=", "-p", String(pid)]];
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const child = execFile(cmd, args, { encoding: "utf8", windowsHide: true, timeout: PARENT_COMMAND_LINE_TIMEOUT_MS }, (error, stdout) => {
|
|
19
|
+
const line = error ? "" : String(stdout).trim();
|
|
20
|
+
resolve(line || null);
|
|
21
|
+
});
|
|
22
|
+
child.unref?.();
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The version a daemon handed to the staged child bootstrap that started this
|
|
27
|
+
* unit: `<node> <...>/hq-child-bootstrap.mjs <prefix> <version> [args]`.
|
|
28
|
+
* Daemons have started units this way since 2026-10-05 (#1541).
|
|
29
|
+
*/
|
|
30
|
+
export function daemonVersionFromBootstrapCommandLine(line) {
|
|
31
|
+
if (!line)
|
|
32
|
+
return null;
|
|
33
|
+
const match = /hq-child-bootstrap\.m?js\s.*?(?:^|\s)(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)(?=\s|$)/.exec(line);
|
|
34
|
+
return match?.[1] ?? null;
|
|
35
|
+
}
|
|
36
|
+
export async function resolveDaemonCliVersion(deps = {}) {
|
|
37
|
+
const env = deps.env ?? process.env;
|
|
38
|
+
if (!env.HQ_DAEMON_UNIT?.trim())
|
|
39
|
+
return null;
|
|
40
|
+
const fromEnv = env.HQ_DAEMON_CLI_VERSION?.trim();
|
|
41
|
+
if (fromEnv)
|
|
42
|
+
return SEMVER.test(fromEnv) ? fromEnv : null;
|
|
43
|
+
const line = await (deps.parentCommandLine ?? readParentCommandLine)();
|
|
44
|
+
const fromBootstrap = daemonVersionFromBootstrapCommandLine(line);
|
|
45
|
+
return fromBootstrap !== null && SEMVER.test(fromBootstrap) ? fromBootstrap : null;
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=daemon-cli-version.js.map
|
|
@@ -31,7 +31,7 @@ export const DUPLICATE_COMMANDS = [
|
|
|
31
31
|
{ command: "sync mode", countedAs: ["sync mode"], owner: "daemon sync mode" },
|
|
32
32
|
{ command: "packages install", countedAs: ["packages install"], owner: "install" },
|
|
33
33
|
{ command: "packages list", countedAs: ["packages list", "packages ls"], owner: "packs list" },
|
|
34
|
-
{ command: "packages update", countedAs: ["packages update"], owner:
|
|
34
|
+
{ command: "packages update", countedAs: ["packages update"], owner: "packs update" },
|
|
35
35
|
{ command: "packages remove", countedAs: ["packages remove"], owner: "remove" },
|
|
36
36
|
];
|
|
37
37
|
/** Default window. */
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine-token cache location and reader, without any network code, so
|
|
3
|
+
* network-free callers (the daemon's cached whoami check in native commands)
|
|
4
|
+
* can read it. Re-exported by cognito-session.ts.
|
|
5
|
+
*/
|
|
6
|
+
import type { CognitoTokens } from "@indigoai-us/hq-cloud";
|
|
7
|
+
export declare const HQ_MACHINE_TOKEN_STATE_DIR_ENV = "HQ_MACHINE_TOKEN_STATE_DIR";
|
|
8
|
+
/**
|
|
9
|
+
* Directory used as `HQ_STATE_DIR` while minting/caching machine Cognito
|
|
10
|
+
* tokens. Never the person's `~/.hq` — agent boxes write under the daemon
|
|
11
|
+
* state dir so a mint cannot clobber a human login cache.
|
|
12
|
+
*/
|
|
13
|
+
export declare function machineTokenStateDir(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
14
|
+
/** Absolute path of the machine-token cache file (daemon state dir). */
|
|
15
|
+
export declare function machineTokenCacheFile(home?: string, env?: NodeJS.ProcessEnv): string;
|
|
16
|
+
/**
|
|
17
|
+
* Peek the machine-token cache under the daemon state dir without minting.
|
|
18
|
+
* Used by doctor; never logs token material.
|
|
19
|
+
*/
|
|
20
|
+
export declare function loadMachineCachedTokens(home?: string, env?: NodeJS.ProcessEnv): CognitoTokens | null;
|
|
21
|
+
//# sourceMappingURL=machine-token-cache.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The machine-token cache location and reader, without any network code, so
|
|
3
|
+
* network-free callers (the daemon's cached whoami check in native commands)
|
|
4
|
+
* can read it. Re-exported by cognito-session.ts.
|
|
5
|
+
*/
|
|
6
|
+
import * as fs from "node:fs";
|
|
7
|
+
import * as os from "node:os";
|
|
8
|
+
import * as path from "node:path";
|
|
9
|
+
import { daemonDir } from "../lib/mesh/live/daemon/paths.js";
|
|
10
|
+
import { workMeshRoot } from "../lib/mesh/live/paths.js";
|
|
11
|
+
export const HQ_MACHINE_TOKEN_STATE_DIR_ENV = "HQ_MACHINE_TOKEN_STATE_DIR";
|
|
12
|
+
/**
|
|
13
|
+
* Directory used as `HQ_STATE_DIR` while minting/caching machine Cognito
|
|
14
|
+
* tokens. Never the person's `~/.hq` — agent boxes write under the daemon
|
|
15
|
+
* state dir so a mint cannot clobber a human login cache.
|
|
16
|
+
*/
|
|
17
|
+
export function machineTokenStateDir(home = os.homedir(), env = process.env) {
|
|
18
|
+
const override = env[HQ_MACHINE_TOKEN_STATE_DIR_ENV]?.trim();
|
|
19
|
+
if (override)
|
|
20
|
+
return override;
|
|
21
|
+
return daemonDir(workMeshRoot(home, env), home, env);
|
|
22
|
+
}
|
|
23
|
+
/** Absolute path of the machine-token cache file (daemon state dir). */
|
|
24
|
+
export function machineTokenCacheFile(home = os.homedir(), env = process.env) {
|
|
25
|
+
return path.join(machineTokenStateDir(home, env), "cognito-tokens.json");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Peek the machine-token cache under the daemon state dir without minting.
|
|
29
|
+
* Used by doctor; never logs token material.
|
|
30
|
+
*/
|
|
31
|
+
export function loadMachineCachedTokens(home = os.homedir(), env = process.env) {
|
|
32
|
+
const file = machineTokenCacheFile(home, env);
|
|
33
|
+
try {
|
|
34
|
+
if (!fs.existsSync(file))
|
|
35
|
+
return null;
|
|
36
|
+
const raw = JSON.parse(fs.readFileSync(file, "utf8"));
|
|
37
|
+
if (typeof raw.accessToken !== "string" ||
|
|
38
|
+
typeof raw.idToken !== "string" ||
|
|
39
|
+
raw.accessToken.length === 0 ||
|
|
40
|
+
raw.idToken.length === 0) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return raw;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=machine-token-cache.js.map
|
|
@@ -117,9 +117,21 @@ export interface UnwireResult {
|
|
|
117
117
|
* uninstall from leaving dangling symlinks behind.
|
|
118
118
|
*
|
|
119
119
|
* Also removes the namespaced skill host (`<pack>:<item>`) reindex writes
|
|
120
|
-
* next to the unprefixed table dest.
|
|
120
|
+
* next to the unprefixed table dest, unless `keepNamespacedSkills` is set.
|
|
121
|
+
* `hq packs update` sets it: the pack directory is replaced in place, so the
|
|
122
|
+
* namespaced links stay valid, and removing them would hide `/<pack>:<skill>`
|
|
123
|
+
* until the next reindex. Update removes the hosts of skills the new version
|
|
124
|
+
* dropped with `unwireNamespacedSkills` once the new manifest is on disk.
|
|
121
125
|
*/
|
|
122
|
-
export declare function unwirePack(hqRoot: string, packDir: string, contributes: Partial<Record<PackContributeKey, string[]
|
|
126
|
+
export declare function unwirePack(hqRoot: string, packDir: string, contributes: Partial<Record<PackContributeKey, string[]>>, options?: {
|
|
127
|
+
keepNamespacedSkills?: boolean;
|
|
128
|
+
}): UnwireResult;
|
|
129
|
+
/**
|
|
130
|
+
* Remove the namespaced skill hosts (`<pack>:<item>`) for `items`, with the
|
|
131
|
+
* same ownership rules as `unwirePack`: only links into this pack's directory,
|
|
132
|
+
* and wrapper directories only once removing those links leaves them empty.
|
|
133
|
+
*/
|
|
134
|
+
export declare function unwireNamespacedSkills(hqRoot: string, packDir: string, items: readonly unknown[]): UnwireResult;
|
|
123
135
|
/** The result of {@link unwirePackMcp}: the per-server un-registration outcomes (empty when no `mcp` keys). */
|
|
124
136
|
export interface UnwireMcpResult {
|
|
125
137
|
/** One {@link UnregisterServerResult} per declared `contributes.mcp` server, in declaration order. */
|
|
@@ -85,11 +85,18 @@ export function mergeKeys(contributes) {
|
|
|
85
85
|
* macOS `/var` ↔ `/private/var` so equivalent paths compare equal.
|
|
86
86
|
*/
|
|
87
87
|
function canonicalPath(p) {
|
|
88
|
+
const absolute = path.resolve(p);
|
|
88
89
|
try {
|
|
89
|
-
return fs.realpathSync.native(
|
|
90
|
+
return fs.realpathSync.native(absolute);
|
|
90
91
|
}
|
|
91
92
|
catch {
|
|
92
|
-
|
|
93
|
+
// The path itself is gone (a broken link's target). Canonicalize its
|
|
94
|
+
// nearest existing ancestor so `/var` vs `/private/var` style aliases still
|
|
95
|
+
// compare equal against an existing pack directory.
|
|
96
|
+
const parent = path.dirname(absolute);
|
|
97
|
+
if (parent === absolute)
|
|
98
|
+
return absolute;
|
|
99
|
+
return path.join(canonicalPath(parent), path.basename(absolute));
|
|
93
100
|
}
|
|
94
101
|
}
|
|
95
102
|
/** True when `candidate` resolves under `packDir` (pack directory containment). */
|
|
@@ -333,19 +340,38 @@ function unwireNamespacedSkillHost(dst, packDir, item, result) {
|
|
|
333
340
|
* uninstall from leaving dangling symlinks behind.
|
|
334
341
|
*
|
|
335
342
|
* Also removes the namespaced skill host (`<pack>:<item>`) reindex writes
|
|
336
|
-
* next to the unprefixed table dest.
|
|
343
|
+
* next to the unprefixed table dest, unless `keepNamespacedSkills` is set.
|
|
344
|
+
* `hq packs update` sets it: the pack directory is replaced in place, so the
|
|
345
|
+
* namespaced links stay valid, and removing them would hide `/<pack>:<skill>`
|
|
346
|
+
* until the next reindex. Update removes the hosts of skills the new version
|
|
347
|
+
* dropped with `unwireNamespacedSkills` once the new manifest is on disk.
|
|
337
348
|
*/
|
|
338
|
-
export function unwirePack(hqRoot, packDir, contributes) {
|
|
349
|
+
export function unwirePack(hqRoot, packDir, contributes, options = {}) {
|
|
339
350
|
const result = { unlinked: [], skipped: [] };
|
|
340
351
|
for (const link of contributionLinks(hqRoot, packDir, contributes)) {
|
|
341
352
|
unlinkContribution(result, link, packDir);
|
|
342
353
|
}
|
|
354
|
+
if (!options.keepNamespacedSkills) {
|
|
355
|
+
unwireNamespacedSkillsInto(result, hqRoot, packDir, contributes.skills ?? []);
|
|
356
|
+
}
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
function unwireNamespacedSkillsInto(result, hqRoot, packDir, items) {
|
|
343
360
|
const packName = path.basename(packDir);
|
|
344
|
-
for (const item of
|
|
361
|
+
for (const item of items) {
|
|
345
362
|
if (typeof item !== 'string' || item.length === 0)
|
|
346
363
|
continue;
|
|
347
364
|
unwireNamespacedSkillHost(path.join(hqRoot, '.claude', 'skills', `${packName}:${item}`), packDir, item, result);
|
|
348
365
|
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Remove the namespaced skill hosts (`<pack>:<item>`) for `items`, with the
|
|
369
|
+
* same ownership rules as `unwirePack`: only links into this pack's directory,
|
|
370
|
+
* and wrapper directories only once removing those links leaves them empty.
|
|
371
|
+
*/
|
|
372
|
+
export function unwireNamespacedSkills(hqRoot, packDir, items) {
|
|
373
|
+
const result = { unlinked: [], skipped: [] };
|
|
374
|
+
unwireNamespacedSkillsInto(result, hqRoot, packDir, items);
|
|
349
375
|
return result;
|
|
350
376
|
}
|
|
351
377
|
/**
|
|
@@ -64,6 +64,8 @@ export const RESIDENT_PACKAGE_MODULES = {
|
|
|
64
64
|
"../utils/plan-gate-error.js", "../utils/deleted-company-notice.js",
|
|
65
65
|
"../lib/daemon/mcp-oauth.js",
|
|
66
66
|
"../commands/lanes.js",
|
|
67
|
+
"../utils/whoami-identity.js",
|
|
68
|
+
"../commands/whoami.js",
|
|
67
69
|
"commander",
|
|
68
70
|
"@modelcontextprotocol/sdk/client/index.js",
|
|
69
71
|
"@modelcontextprotocol/sdk/client/streamableHttp.js",
|
|
@@ -271,6 +273,8 @@ const LOADERS = {
|
|
|
271
273
|
() => import("../utils/deleted-company-notice.js"),
|
|
272
274
|
() => import("../lib/daemon/mcp-oauth.js"),
|
|
273
275
|
() => import("../commands/lanes.js"),
|
|
276
|
+
() => import("../utils/whoami-identity.js"),
|
|
277
|
+
() => import("../commands/whoami.js"),
|
|
274
278
|
() => import("commander"),
|
|
275
279
|
() => import("@modelcontextprotocol/sdk/client/index.js"),
|
|
276
280
|
() => import("@modelcontextprotocol/sdk/client/streamableHttp.js"),
|