@moneysiren/cli 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +6 -3
- package/dist/apps/cli/src/cli.d.ts +4 -1
- package/dist/apps/cli/src/cli.js +11 -3
- package/dist/apps/cli/src/commands/install.js +125 -6
- package/dist/apps/cli/src/commands/modes.js +15 -10
- package/dist/apps/cli/src/commands/runtime.d.ts +2 -0
- package/dist/apps/cli/src/commands/runtime.js +167 -0
- package/dist/apps/cli/src/desktop-runtime.d.ts +31 -0
- package/dist/apps/cli/src/desktop-runtime.js +441 -0
- package/dist/apps/cli/src/home.js +16 -0
- package/dist/apps/cli/src/index.js +0 -0
- package/dist/apps/cli/src/postinstall.js +1 -1
- package/dist/apps/cli/src/release-installer.d.ts +54 -0
- package/dist/apps/cli/src/release-installer.js +393 -0
- package/dist/apps/cli/src/slash.js +12 -0
- package/dist/apps/cli/src/version.d.ts +2 -0
- package/dist/apps/cli/src/version.js +2 -0
- package/dist/packages/config/src/load.js +3 -0
- package/dist/packages/config/src/schema.d.ts +3 -0
- package/dist/packages/config/src/schema.js +3 -0
- package/dist/packages/local-api/src/server.js +1 -1
- package/dist/packages/view-model/src/hud-model.d.ts +74 -0
- package/dist/packages/view-model/src/hud-model.js +295 -0
- package/dist/packages/view-model/src/index.d.ts +5 -2
- package/dist/packages/view-model/src/index.js +4 -1
- package/dist/packages/view-model/src/notification-preferences-model.d.ts +30 -2
- package/dist/packages/view-model/src/notification-preferences-model.js +183 -1
- package/dist/packages/view-model/src/notification-preferences.d.ts +1 -1
- package/dist/packages/view-model/src/notification-preferences.js +1 -1
- package/dist/packages/view-model/src/sync-state.d.ts +47 -0
- package/dist/packages/view-model/src/sync-state.js +140 -0
- package/dist/packages/view-model/src/usage-progress.d.ts +22 -0
- package/dist/packages/view-model/src/usage-progress.js +57 -0
- package/dist/packages/view-model/src/view-model.d.ts +22 -0
- package/dist/packages/view-model/src/view-model.js +142 -0
- package/package.json +3 -2
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { execFile } from "node:child_process";
|
|
3
|
+
import { mkdir, unlink, writeFile } from "node:fs/promises";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { basename, isAbsolute, join, posix, resolve, win32 } from "node:path";
|
|
6
|
+
import { promisify } from "node:util";
|
|
7
|
+
const execFileAsync = promisify(execFile);
|
|
8
|
+
export const DEFAULT_RELEASE_REPOSITORY = "ztwz11/moneysiren";
|
|
9
|
+
// Keep the source-free installer pinned to the latest published desktop/web release tag.
|
|
10
|
+
export const DEFAULT_RELEASE_TAG = "v0.1.0-alpha.2";
|
|
11
|
+
const RELEASE_REPOSITORY_ENV_KEY = "MONEYSIREN_RELEASE_REPOSITORY";
|
|
12
|
+
const RELEASE_TAG_ENV_KEY = "MONEYSIREN_RELEASE_TAG";
|
|
13
|
+
const RELEASE_INSTALL_DIR_ENV_KEY = "MONEYSIREN_RELEASE_INSTALL_DIR";
|
|
14
|
+
const RELEASE_PLATFORM_ENV_KEY = "MONEYSIREN_RELEASE_PLATFORM";
|
|
15
|
+
const WINDOWS_SIGNER_THUMBPRINTS_ENV_KEY = "MONEYSIREN_WINDOWS_SIGNER_THUMBPRINTS";
|
|
16
|
+
export async function installReleaseAssets(options) {
|
|
17
|
+
const env = options.env ?? process.env;
|
|
18
|
+
const repository = normalizeRepository(options.repository ?? env[RELEASE_REPOSITORY_ENV_KEY] ?? DEFAULT_RELEASE_REPOSITORY);
|
|
19
|
+
const tag = normalizeTag(options.tag ?? env[RELEASE_TAG_ENV_KEY] ?? DEFAULT_RELEASE_TAG);
|
|
20
|
+
const platform = normalizePlatform(options.platform ?? env[RELEASE_PLATFORM_ENV_KEY] ?? process.platform);
|
|
21
|
+
const configuredInstallDir = options.installDir ?? env[RELEASE_INSTALL_DIR_ENV_KEY];
|
|
22
|
+
const installDir = resolveReleaseInstallDir({
|
|
23
|
+
env,
|
|
24
|
+
...(configuredInstallDir === undefined ? {} : { installDir: configuredInstallDir }),
|
|
25
|
+
platform,
|
|
26
|
+
tag,
|
|
27
|
+
});
|
|
28
|
+
const release = await fetchRelease({
|
|
29
|
+
fetchImpl: options.fetchImpl,
|
|
30
|
+
repository,
|
|
31
|
+
tag,
|
|
32
|
+
});
|
|
33
|
+
const releaseAssets = parseReleaseAssets(release.assets);
|
|
34
|
+
const checksumAssets = releaseAssets.filter((asset) => asset.name.toLowerCase().includes("sha256sums"));
|
|
35
|
+
const requestedSurfaces = options.selectedSurfaces.filter((surface) => surface === "web" || surface === "hud");
|
|
36
|
+
const installedAssets = [];
|
|
37
|
+
await mkdir(installDir, { recursive: true });
|
|
38
|
+
for (const surface of requestedSurfaces) {
|
|
39
|
+
const asset = selectSurfaceAsset(surface, platform, releaseAssets);
|
|
40
|
+
if (asset === null) {
|
|
41
|
+
throw new Error(`No ${surface} release asset found for ${platform} in ${repository}@${tag}.`);
|
|
42
|
+
}
|
|
43
|
+
const downloaded = await downloadAsset(options.fetchImpl, asset.browser_download_url);
|
|
44
|
+
const sha256 = sha256Hex(downloaded);
|
|
45
|
+
const checksum = await findChecksum({
|
|
46
|
+
assetName: asset.name,
|
|
47
|
+
checksumAssets,
|
|
48
|
+
fetchImpl: options.fetchImpl,
|
|
49
|
+
});
|
|
50
|
+
if (checksumAssets.length > 0 && checksum === null) {
|
|
51
|
+
throw new Error(`SHA256 checksum entry missing for ${asset.name}.`);
|
|
52
|
+
}
|
|
53
|
+
if (checksum !== null && checksum.toLowerCase() !== sha256) {
|
|
54
|
+
throw new Error(`SHA256 mismatch for ${asset.name}.`);
|
|
55
|
+
}
|
|
56
|
+
const outputPath = join(installDir, sanitizeAssetFileName(asset.name));
|
|
57
|
+
await writeFile(outputPath, downloaded);
|
|
58
|
+
let signature;
|
|
59
|
+
try {
|
|
60
|
+
signature = await verifyReleaseAssetSignature({
|
|
61
|
+
assetName: asset.name,
|
|
62
|
+
env,
|
|
63
|
+
fetchImpl: options.fetchImpl,
|
|
64
|
+
path: outputPath,
|
|
65
|
+
platform,
|
|
66
|
+
releaseAssets,
|
|
67
|
+
surface,
|
|
68
|
+
...(options.signatureVerifier === undefined ? {} : { signatureVerifier: options.signatureVerifier }),
|
|
69
|
+
...(options.trustedWindowsSignerThumbprints === undefined
|
|
70
|
+
? {}
|
|
71
|
+
: { trustedWindowsSignerThumbprints: options.trustedWindowsSignerThumbprints }),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
await unlink(outputPath).catch(() => undefined);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
if (!signature.verified) {
|
|
79
|
+
await unlink(outputPath).catch(() => undefined);
|
|
80
|
+
throw new Error(`Release asset signature verification failed for ${asset.name}: ${signature.status} ${signature.message}`.trim());
|
|
81
|
+
}
|
|
82
|
+
installedAssets.push({
|
|
83
|
+
surface,
|
|
84
|
+
name: asset.name,
|
|
85
|
+
path: outputPath,
|
|
86
|
+
size: downloaded.byteLength,
|
|
87
|
+
sha256,
|
|
88
|
+
checksumVerified: checksum !== null,
|
|
89
|
+
signatureVerified: signature.status !== "not-required",
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
await writeFile(join(installDir, "install-manifest.json"), `${JSON.stringify({
|
|
93
|
+
version: 1,
|
|
94
|
+
repository,
|
|
95
|
+
tag,
|
|
96
|
+
releaseUrl: typeof release.html_url === "string" ? release.html_url : releaseUrl(repository, tag),
|
|
97
|
+
installedAt: (options.now ?? (() => new Date()))().toISOString(),
|
|
98
|
+
selectedSurfaces: options.selectedSurfaces,
|
|
99
|
+
assets: installedAssets.map((asset) => ({
|
|
100
|
+
surface: asset.surface,
|
|
101
|
+
name: asset.name,
|
|
102
|
+
path: asset.path,
|
|
103
|
+
size: asset.size,
|
|
104
|
+
sha256: asset.sha256,
|
|
105
|
+
checksumVerified: asset.checksumVerified,
|
|
106
|
+
signatureVerified: asset.signatureVerified,
|
|
107
|
+
})),
|
|
108
|
+
}, null, 2)}\n`, "utf8");
|
|
109
|
+
return {
|
|
110
|
+
repository,
|
|
111
|
+
tag,
|
|
112
|
+
installDir,
|
|
113
|
+
releaseUrl: typeof release.html_url === "string" ? release.html_url : releaseUrl(repository, tag),
|
|
114
|
+
assets: installedAssets,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export function resolveReleaseInstallDir(input = {}) {
|
|
118
|
+
const env = input.env ?? process.env;
|
|
119
|
+
const platform = input.platform ?? process.platform;
|
|
120
|
+
const tag = input.tag ?? DEFAULT_RELEASE_TAG;
|
|
121
|
+
const configured = trimToNull(input.installDir);
|
|
122
|
+
if (configured !== null) {
|
|
123
|
+
return isAbsolute(configured) ? configured : resolve(process.cwd(), configured);
|
|
124
|
+
}
|
|
125
|
+
const root = platform === "win32"
|
|
126
|
+
? joinForPlatform(platform, trimToNull(env.APPDATA) ?? win32.join(resolveHomeDirectory(env), "AppData", "Roaming"), "MoneySiren")
|
|
127
|
+
: platform === "darwin"
|
|
128
|
+
? joinForPlatform(platform, resolveHomeDirectory(env), "Library", "Application Support", "MoneySiren")
|
|
129
|
+
: joinForPlatform(platform, trimToNull(env.XDG_DATA_HOME) ?? joinForPlatform(platform, resolveHomeDirectory(env), ".local", "share"), "moneysiren");
|
|
130
|
+
return joinForPlatform(platform, root, "releases", sanitizePathSegment(tag));
|
|
131
|
+
}
|
|
132
|
+
function normalizeRepository(repository) {
|
|
133
|
+
const normalized = repository.trim();
|
|
134
|
+
if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(normalized)) {
|
|
135
|
+
throw new Error("Release repository must be in owner/name form.");
|
|
136
|
+
}
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
function normalizeTag(tag) {
|
|
140
|
+
const normalized = tag.trim();
|
|
141
|
+
if (normalized.length === 0 || normalized.length > 128) {
|
|
142
|
+
throw new Error("Release tag is empty or too long.");
|
|
143
|
+
}
|
|
144
|
+
return normalized;
|
|
145
|
+
}
|
|
146
|
+
function normalizePlatform(platform) {
|
|
147
|
+
if (platform === "win32" || platform === "darwin" || platform === "linux") {
|
|
148
|
+
return platform;
|
|
149
|
+
}
|
|
150
|
+
return process.platform;
|
|
151
|
+
}
|
|
152
|
+
async function fetchRelease(input) {
|
|
153
|
+
const response = await input.fetchImpl(`https://api.github.com/repos/${input.repository}/releases/tags/${encodeURIComponent(input.tag)}`, {
|
|
154
|
+
headers: {
|
|
155
|
+
Accept: "application/vnd.github+json",
|
|
156
|
+
"User-Agent": "moneysiren-cli-release-installer",
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
if (!response.ok) {
|
|
160
|
+
throw new Error(`Could not read GitHub Release ${input.repository}@${input.tag}: ${response.status} ${response.statusText}`);
|
|
161
|
+
}
|
|
162
|
+
const body = await response.json();
|
|
163
|
+
if (!isRecord(body)) {
|
|
164
|
+
throw new Error("GitHub Release response was not an object.");
|
|
165
|
+
}
|
|
166
|
+
return body;
|
|
167
|
+
}
|
|
168
|
+
function parseReleaseAssets(value) {
|
|
169
|
+
if (!Array.isArray(value)) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
return value
|
|
173
|
+
.filter(isRecord)
|
|
174
|
+
.flatMap((asset) => {
|
|
175
|
+
const name = asset.name;
|
|
176
|
+
const browserDownloadUrl = asset.browser_download_url;
|
|
177
|
+
if (typeof name !== "string" || typeof browserDownloadUrl !== "string") {
|
|
178
|
+
return [];
|
|
179
|
+
}
|
|
180
|
+
return [{
|
|
181
|
+
name,
|
|
182
|
+
browser_download_url: browserDownloadUrl,
|
|
183
|
+
...(typeof asset.size === "number" ? { size: asset.size } : {}),
|
|
184
|
+
}];
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function selectSurfaceAsset(surface, platform, assets) {
|
|
188
|
+
const candidates = assets.filter((asset) => !asset.name.toLowerCase().includes("sha256sums"));
|
|
189
|
+
if (surface === "web") {
|
|
190
|
+
return candidates.find((asset) => /^moneysiren-web-runtime-.+\.tar\.gz$/i.test(asset.name)) ?? null;
|
|
191
|
+
}
|
|
192
|
+
if (platform === "win32") {
|
|
193
|
+
return candidates.find((asset) => /\.(exe|msi)$/i.test(asset.name)) ?? null;
|
|
194
|
+
}
|
|
195
|
+
if (platform === "darwin") {
|
|
196
|
+
return candidates.find((asset) => /macos/i.test(asset.name) && /\.(tar\.gz|dmg)$/i.test(asset.name)) ?? null;
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
async function findChecksum(input) {
|
|
201
|
+
for (const checksumAsset of input.checksumAssets) {
|
|
202
|
+
const content = await downloadAsset(input.fetchImpl, checksumAsset.browser_download_url);
|
|
203
|
+
const checksum = parseChecksumFile(content.toString("utf8"), input.assetName);
|
|
204
|
+
if (checksum !== null) {
|
|
205
|
+
return checksum;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
async function downloadAsset(fetchImpl, url) {
|
|
211
|
+
const parsed = new URL(url);
|
|
212
|
+
if (parsed.protocol !== "https:") {
|
|
213
|
+
throw new Error("Refusing to download a non-HTTPS release asset.");
|
|
214
|
+
}
|
|
215
|
+
const response = await fetchImpl(url, {
|
|
216
|
+
headers: {
|
|
217
|
+
"User-Agent": "moneysiren-cli-release-installer",
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
if (!response.ok) {
|
|
221
|
+
throw new Error(`Could not download release asset: ${response.status} ${response.statusText}`);
|
|
222
|
+
}
|
|
223
|
+
return Buffer.from(await response.arrayBuffer());
|
|
224
|
+
}
|
|
225
|
+
function parseChecksumFile(content, assetName) {
|
|
226
|
+
for (const line of content.split(/\r?\n/)) {
|
|
227
|
+
const match = /^([a-f0-9]{64})\s+\*?(.+)$/i.exec(line.trim());
|
|
228
|
+
if (match !== null && basename(match[2] ?? "") === assetName) {
|
|
229
|
+
return match[1] ?? null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
function sha256Hex(content) {
|
|
235
|
+
return createHash("sha256").update(content).digest("hex");
|
|
236
|
+
}
|
|
237
|
+
async function verifyReleaseAssetSignature(input) {
|
|
238
|
+
const verifier = input.signatureVerifier ?? defaultReleaseAssetSignatureVerifier;
|
|
239
|
+
const expectedSignerThumbprints = await findExpectedSignerThumbprints({
|
|
240
|
+
assetName: input.assetName,
|
|
241
|
+
env: input.env,
|
|
242
|
+
fetchImpl: input.fetchImpl,
|
|
243
|
+
platform: input.platform,
|
|
244
|
+
releaseAssets: input.releaseAssets,
|
|
245
|
+
surface: input.surface,
|
|
246
|
+
...(input.trustedWindowsSignerThumbprints === undefined
|
|
247
|
+
? {}
|
|
248
|
+
: { trustedWindowsSignerThumbprints: input.trustedWindowsSignerThumbprints }),
|
|
249
|
+
});
|
|
250
|
+
return verifier.verify({
|
|
251
|
+
assetName: input.assetName,
|
|
252
|
+
...(expectedSignerThumbprints === null ? {} : { expectedSignerThumbprints }),
|
|
253
|
+
path: input.path,
|
|
254
|
+
platform: input.platform,
|
|
255
|
+
surface: input.surface,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
const defaultReleaseAssetSignatureVerifier = {
|
|
259
|
+
async verify(input) {
|
|
260
|
+
if (input.surface !== "hud" || input.platform !== "win32") {
|
|
261
|
+
return {
|
|
262
|
+
verified: true,
|
|
263
|
+
status: "not-required",
|
|
264
|
+
message: "No platform signature check is required for this release asset.",
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
if (!/\.(exe|msi)$/i.test(input.assetName)) {
|
|
268
|
+
return {
|
|
269
|
+
verified: false,
|
|
270
|
+
status: "unsupported",
|
|
271
|
+
message: "Windows HUD release assets must be .exe or .msi installers.",
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
if (input.expectedSignerThumbprints === undefined || input.expectedSignerThumbprints.length === 0) {
|
|
275
|
+
return {
|
|
276
|
+
verified: false,
|
|
277
|
+
status: "missing-signature-metadata",
|
|
278
|
+
message: `Windows HUD release assets require ${WINDOWS_SIGNER_THUMBPRINTS_ENV_KEY} or moneysiren-tray-windows-SIGNATURE.json metadata.`,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
return verifyWindowsAuthenticodeSignature(input.path, input.expectedSignerThumbprints);
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
async function findExpectedSignerThumbprints(input) {
|
|
285
|
+
if (input.surface !== "hud" || input.platform !== "win32") {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
const trustedThumbprints = normalizeThumbprintList([
|
|
289
|
+
...(input.trustedWindowsSignerThumbprints ?? []),
|
|
290
|
+
...parseThumbprintEnv(input.env[WINDOWS_SIGNER_THUMBPRINTS_ENV_KEY]),
|
|
291
|
+
]);
|
|
292
|
+
if (trustedThumbprints.length > 0) {
|
|
293
|
+
return trustedThumbprints;
|
|
294
|
+
}
|
|
295
|
+
const metadataAsset = input.releaseAssets.find((asset) => /^moneysiren-tray-windows-SIGNATURE\.json$/i.test(asset.name));
|
|
296
|
+
if (metadataAsset === undefined) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
const metadata = JSON.parse((await downloadAsset(input.fetchImpl, metadataAsset.browser_download_url)).toString("utf8"));
|
|
300
|
+
const entries = Array.isArray(metadata) ? metadata : [metadata];
|
|
301
|
+
for (const entry of entries) {
|
|
302
|
+
if (!isRecord(entry) || entry.assetName !== input.assetName || typeof entry.signerThumbprint !== "string") {
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
return [normalizeThumbprint(entry.signerThumbprint)];
|
|
306
|
+
}
|
|
307
|
+
return null;
|
|
308
|
+
}
|
|
309
|
+
async function verifyWindowsAuthenticodeSignature(path, expectedSignerThumbprints) {
|
|
310
|
+
const literalPath = powerShellSingleQuotedString(path);
|
|
311
|
+
try {
|
|
312
|
+
const { stdout } = await execFileAsync("powershell.exe", [
|
|
313
|
+
"-NoProfile",
|
|
314
|
+
"-NonInteractive",
|
|
315
|
+
"-Command",
|
|
316
|
+
[
|
|
317
|
+
`$signature = Get-AuthenticodeSignature -LiteralPath ${literalPath}`,
|
|
318
|
+
"$status = [string]$signature.Status",
|
|
319
|
+
"$message = [string]$signature.StatusMessage",
|
|
320
|
+
"if ($signature.Status -ne 'Valid' -or $null -eq $signature.SignerCertificate) {",
|
|
321
|
+
" Write-Output ($status + \"|\" + $message)",
|
|
322
|
+
" exit 1",
|
|
323
|
+
"}",
|
|
324
|
+
"Write-Output ($status + \"|\" + $signature.SignerCertificate.Thumbprint + \"|\" + $signature.SignerCertificate.Subject)",
|
|
325
|
+
].join("; "),
|
|
326
|
+
], {
|
|
327
|
+
windowsHide: true,
|
|
328
|
+
timeout: 30_000,
|
|
329
|
+
});
|
|
330
|
+
const [status, signerThumbprint, ...messageParts] = stdout.trim().split("|");
|
|
331
|
+
const normalizedSignerThumbprint = normalizeThumbprint(signerThumbprint ?? "");
|
|
332
|
+
const normalizedExpectedSignerThumbprints = expectedSignerThumbprints.map(normalizeThumbprint);
|
|
333
|
+
if (!normalizedExpectedSignerThumbprints.includes(normalizedSignerThumbprint)) {
|
|
334
|
+
return {
|
|
335
|
+
verified: false,
|
|
336
|
+
status: "signer-mismatch",
|
|
337
|
+
message: `Expected signer ${normalizedExpectedSignerThumbprints.join(", ")}, got ${normalizedSignerThumbprint || "unknown"}.`,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
verified: true,
|
|
342
|
+
status: status ?? "Valid",
|
|
343
|
+
message: messageParts.join("|"),
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
const output = isRecord(error) && typeof error.stdout === "string" ? error.stdout.trim() : "";
|
|
348
|
+
const [status, ...messageParts] = output.split("|");
|
|
349
|
+
return {
|
|
350
|
+
verified: false,
|
|
351
|
+
status: status && status.length > 0 ? status : "Unknown",
|
|
352
|
+
message: messageParts.join("|") || (error instanceof Error ? error.message : String(error)),
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function normalizeThumbprint(value) {
|
|
357
|
+
return value.replaceAll(/\s/g, "").toUpperCase();
|
|
358
|
+
}
|
|
359
|
+
function normalizeThumbprintList(values) {
|
|
360
|
+
return Array.from(new Set(values.map(normalizeThumbprint).filter((value) => value.length > 0)));
|
|
361
|
+
}
|
|
362
|
+
function parseThumbprintEnv(value) {
|
|
363
|
+
if (value === undefined) {
|
|
364
|
+
return [];
|
|
365
|
+
}
|
|
366
|
+
return value.split(/[,\s;]+/).map((part) => part.trim()).filter((part) => part.length > 0);
|
|
367
|
+
}
|
|
368
|
+
function powerShellSingleQuotedString(value) {
|
|
369
|
+
return `'${value.replaceAll("'", "''")}'`;
|
|
370
|
+
}
|
|
371
|
+
function sanitizeAssetFileName(name) {
|
|
372
|
+
return basename(name).replace(/[^A-Za-z0-9._ -]/g, "_");
|
|
373
|
+
}
|
|
374
|
+
function sanitizePathSegment(value) {
|
|
375
|
+
return value.replace(/[^A-Za-z0-9._-]/g, "_");
|
|
376
|
+
}
|
|
377
|
+
function releaseUrl(repository, tag) {
|
|
378
|
+
return `https://github.com/${repository}/releases/tag/${encodeURIComponent(tag)}`;
|
|
379
|
+
}
|
|
380
|
+
function resolveHomeDirectory(env) {
|
|
381
|
+
return trimToNull(env.HOME) ?? trimToNull(env.USERPROFILE) ?? homedir();
|
|
382
|
+
}
|
|
383
|
+
function trimToNull(value) {
|
|
384
|
+
const trimmed = value?.trim();
|
|
385
|
+
return trimmed === undefined || trimmed.length === 0 ? null : trimmed;
|
|
386
|
+
}
|
|
387
|
+
function joinForPlatform(platform, ...segments) {
|
|
388
|
+
return platform === "win32" ? win32.join(...segments) : posix.join(...segments);
|
|
389
|
+
}
|
|
390
|
+
function isRecord(value) {
|
|
391
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
392
|
+
}
|
|
393
|
+
//# sourceMappingURL=release-installer.js.map
|
|
@@ -34,6 +34,18 @@ export function resolveSlashCommand(args) {
|
|
|
34
34
|
if (command === "/modes") {
|
|
35
35
|
return noExtraArgs(command, rest, ["modes"]);
|
|
36
36
|
}
|
|
37
|
+
if (command === "/start") {
|
|
38
|
+
return {
|
|
39
|
+
kind: "dispatch",
|
|
40
|
+
args: ["start", ...rest],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (command === "/hud") {
|
|
44
|
+
return {
|
|
45
|
+
kind: "dispatch",
|
|
46
|
+
args: ["hud", ...rest],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
37
49
|
if (command === "/init") {
|
|
38
50
|
return noExtraArgs(command, rest, ["init"]);
|
|
39
51
|
}
|
|
@@ -57,7 +57,10 @@ function loadProviders(env) {
|
|
|
57
57
|
datadog: loadProviderConfig("datadog", env),
|
|
58
58
|
sentry: loadProviderConfig("sentry", env),
|
|
59
59
|
"codex-cli": loadProviderConfig("codex-cli", env),
|
|
60
|
+
"codex-app": loadProviderConfig("codex-app", env),
|
|
60
61
|
"claude-cli": loadProviderConfig("claude-cli", env),
|
|
62
|
+
"claude-app": loadProviderConfig("claude-app", env),
|
|
63
|
+
antigravity: loadProviderConfig("antigravity", env),
|
|
61
64
|
};
|
|
62
65
|
}
|
|
63
66
|
function loadProviderConfig(provider, env) {
|
|
@@ -20,7 +20,10 @@ export declare const PROVIDER_ENV_KEYS: {
|
|
|
20
20
|
readonly datadog: readonly ["DATADOG_API_KEY", "DATADOG_APP_KEY", "DATADOG_SITE"];
|
|
21
21
|
readonly sentry: readonly ["SENTRY_AUTH_TOKEN", "SENTRY_ORG"];
|
|
22
22
|
readonly "codex-cli": readonly [];
|
|
23
|
+
readonly "codex-app": readonly [];
|
|
23
24
|
readonly "claude-cli": readonly [];
|
|
25
|
+
readonly "claude-app": readonly [];
|
|
26
|
+
readonly antigravity: readonly [];
|
|
24
27
|
};
|
|
25
28
|
export type ConfiguredProvider = keyof typeof PROVIDER_ENV_KEYS;
|
|
26
29
|
export interface ProviderConfig {
|
|
@@ -20,6 +20,9 @@ export const PROVIDER_ENV_KEYS = {
|
|
|
20
20
|
datadog: ["DATADOG_API_KEY", "DATADOG_APP_KEY", "DATADOG_SITE"],
|
|
21
21
|
sentry: ["SENTRY_AUTH_TOKEN", "SENTRY_ORG"],
|
|
22
22
|
"codex-cli": [],
|
|
23
|
+
"codex-app": [],
|
|
23
24
|
"claude-cli": [],
|
|
25
|
+
"claude-app": [],
|
|
26
|
+
antigravity: [],
|
|
24
27
|
};
|
|
25
28
|
//# sourceMappingURL=schema.js.map
|
|
@@ -3,7 +3,7 @@ import { parseNotificationPreferences, readNotificationDigest, readNotificationP
|
|
|
3
3
|
import { assertLoopbackHost, isLoopbackHost, removeRuntimeLock, writeRuntimeLock, } from "../../runtime/src/index.js";
|
|
4
4
|
const DEFAULT_HOST = "127.0.0.1";
|
|
5
5
|
const DEFAULT_PORT = 47831;
|
|
6
|
-
const DEFAULT_VERSION = "0.1.0-alpha.
|
|
6
|
+
const DEFAULT_VERSION = "0.1.0-alpha.2";
|
|
7
7
|
export async function startLocalApiServer(options = {}) {
|
|
8
8
|
const host = options.host ?? DEFAULT_HOST;
|
|
9
9
|
const requestedPort = options.port ?? DEFAULT_PORT;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type AggregateSyncStatus, type ItemSyncView, type RiskSeverity } from "./sync-state.js";
|
|
2
|
+
import { type UsageProgressView } from "./usage-progress.js";
|
|
3
|
+
import type { TodayLiveProviderView, TodayLiveView } from "./view-model.js";
|
|
4
|
+
import type { NotificationWidgetKey } from "./notification-preferences-model.js";
|
|
5
|
+
export type CreditAccuracy = "exact" | "estimated" | "bounded" | "unknown";
|
|
6
|
+
export interface CreditItemView {
|
|
7
|
+
itemKey: string;
|
|
8
|
+
expiresAt: string | null;
|
|
9
|
+
estimatedEarliestAt: string | null;
|
|
10
|
+
estimatedLatestAt: string | null;
|
|
11
|
+
accuracy: CreditAccuracy;
|
|
12
|
+
status: "active" | "expiring_soon" | "expired" | "unknown";
|
|
13
|
+
}
|
|
14
|
+
export interface CreditPoolView {
|
|
15
|
+
kind: "credit_pool";
|
|
16
|
+
id: string;
|
|
17
|
+
providerKey: "codex-app" | "codex-cli";
|
|
18
|
+
variant: "count" | "expiry";
|
|
19
|
+
availableCount: number | null;
|
|
20
|
+
totalEarnedCount: number | null;
|
|
21
|
+
credits: readonly CreditItemView[];
|
|
22
|
+
unresolvedCount: number;
|
|
23
|
+
nearestExpiryAt: string | null;
|
|
24
|
+
accuracy: CreditAccuracy;
|
|
25
|
+
sync: ItemSyncView;
|
|
26
|
+
riskSeverity: RiskSeverity;
|
|
27
|
+
target: {
|
|
28
|
+
type: "service";
|
|
29
|
+
providerKey: "codex-app" | "codex-cli";
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export interface QuotaItemView {
|
|
33
|
+
kind: "quota";
|
|
34
|
+
id: string;
|
|
35
|
+
providerKey: string;
|
|
36
|
+
window: "five_hour" | "weekly" | "context" | "budget";
|
|
37
|
+
progress: UsageProgressView;
|
|
38
|
+
resetAt: string | null;
|
|
39
|
+
sync: ItemSyncView;
|
|
40
|
+
riskSeverity: RiskSeverity;
|
|
41
|
+
target: {
|
|
42
|
+
type: "service" | "dashboard";
|
|
43
|
+
providerKey?: string;
|
|
44
|
+
routeKey?: string;
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export type HudItemView = QuotaItemView | CreditPoolView;
|
|
48
|
+
export interface HudViewModel {
|
|
49
|
+
generatedAt: string;
|
|
50
|
+
localOnly: true;
|
|
51
|
+
secretsReturned: false;
|
|
52
|
+
dataRevision: string;
|
|
53
|
+
sync: {
|
|
54
|
+
status: AggregateSyncStatus;
|
|
55
|
+
freshCount: number;
|
|
56
|
+
staleCount: number;
|
|
57
|
+
errorCount: number;
|
|
58
|
+
neutralCount: number;
|
|
59
|
+
lastSuccessAt: string | null;
|
|
60
|
+
};
|
|
61
|
+
risk: {
|
|
62
|
+
severity: RiskSeverity;
|
|
63
|
+
warningCount: number;
|
|
64
|
+
criticalCount: number;
|
|
65
|
+
};
|
|
66
|
+
items: readonly HudItemView[];
|
|
67
|
+
}
|
|
68
|
+
export declare const CODEX_APP_PROVIDER_KEY = "codex-app";
|
|
69
|
+
export declare const CODEX_CLI_PROVIDER_KEY = "codex-cli";
|
|
70
|
+
export declare function buildHudViewModel(todayLive: TodayLiveView): HudViewModel;
|
|
71
|
+
export declare function filterHudViewModelByWidgets(model: HudViewModel, selectedWidgets: readonly NotificationWidgetKey[]): HudViewModel;
|
|
72
|
+
export declare function buildCreditPoolFromProvider(provider: TodayLiveProviderView, generatedAt: string): CreditPoolView | null;
|
|
73
|
+
export declare function buildCreditPoolsFromProvider(provider: TodayLiveProviderView, generatedAt: string): CreditPoolView[];
|
|
74
|
+
//# sourceMappingURL=hud-model.d.ts.map
|