@adea-ai/app-framework 0.30.0 → 0.32.0
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 +26 -11
- package/dist/app/application.js +4 -2
- package/dist/app/create-application.js +4 -3
- package/dist/app/serial-queue.d.ts +5 -0
- package/dist/app/serial-queue.js +14 -0
- package/dist/app/value-guards.d.ts +15 -0
- package/dist/app/value-guards.js +29 -0
- package/dist/appearance/appearance-host.js +6 -0
- package/dist/appearance/appearance-preferences.js +6 -2
- package/dist/appearance/composition.d.ts +1 -1
- package/dist/appearance/custom-theme-import.js +12 -19
- package/dist/appearance/custom-theme-library.d.ts +5 -4
- package/dist/appearance/custom-theme-library.js +20 -2
- package/dist/appearance/editor.js +4 -1
- package/dist/appearance/legacy-imported-theme-token-projection.d.ts +84 -0
- package/dist/appearance/legacy-imported-theme-token-projection.js +142 -0
- package/dist/appearance/theme-record-adapter.js +37 -9
- package/dist/ci/toolchain-identity.js +1 -1
- package/dist/desktop/channel-proof.js +2 -1
- package/dist/desktop/client-asset-stream.js +6 -12
- package/dist/desktop/desktop-host.d.ts +25 -5
- package/dist/desktop/desktop-host.js +75 -20
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.js +4 -3
- package/dist/installer/command-qualification-command.js +6 -5
- package/dist/installer/hosted-runner.d.ts +9 -2
- package/dist/installer/hosted-runner.js +18 -5
- package/dist/installer/installed-payload.js +20 -46
- package/dist/installer/installer-archive.d.ts +33 -0
- package/dist/installer/installer-archive.js +116 -0
- package/dist/installer/installer-ci-bootstrap.js +10 -6
- package/dist/installer/installer-extraction.js +54 -120
- package/dist/installer/installer-identity.js +33 -111
- package/dist/installer/installer-observation.js +3 -2
- package/dist/installer/installer-process-cleanup.js +7 -46
- package/dist/installer/installer-qualification-command.js +6 -5
- package/dist/installer/installer-upgrade-command.js +5 -5
- package/dist/installer/installer-worker-guard.js +2 -1
- package/dist/native/canonical-path.d.ts +5 -0
- package/dist/native/canonical-path.js +10 -0
- package/dist/native/cef-helper.js +5 -4
- package/dist/native/electrobun-source-patch.js +3 -2
- package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
- package/dist/native/native-rename.js +126 -0
- package/dist/native/native-secret-store.js +2 -6
- package/dist/native/native-utilities.js +4 -4
- package/dist/native/posix-launcher-build.js +1 -1
- package/dist/native/posix-tree-removal.js +2 -2
- package/dist/native/windows-process.d.ts +9 -0
- package/dist/native/windows-process.js +60 -0
- package/dist/release/feed-release-cut.js +2 -1
- package/dist/release/framework-package-publish.js +1 -1
- package/dist/release/framework-update-lock.js +2 -1
- package/dist/release/github-cli.d.ts +18 -0
- package/dist/release/github-cli.js +13 -1
- package/dist/release/github-release-cut.js +3 -2
- package/dist/release/github-release-provenance.js +2 -1
- package/dist/release/github-release-publisher.js +2 -1
- package/dist/release/local-provenance.js +3 -2
- package/dist/release/local-release.js +6 -6
- package/dist/release/qualification-run.d.ts +25 -0
- package/dist/release/qualification-run.js +43 -0
- package/dist/release/release-artifact.js +3 -11
- package/dist/release/release-assets-plan.js +16 -6
- package/dist/release/release-config.js +14 -14
- package/dist/release/release-cut-command.js +14 -4
- package/dist/release/release-cut.js +3 -2
- package/dist/release/release-descriptor-staging.js +13 -27
- package/dist/release/release-finalize.js +2 -1
- package/dist/release/release-publication.js +3 -11
- package/dist/release/release-publish-command.js +15 -6
- package/dist/release/release-qualification.js +3 -2
- package/dist/release/retained-release-build.js +12 -12
- package/dist/shell/app-shell.js +76 -48
- package/dist/shell/app-utilities.d.ts +5 -3
- package/dist/shell/app-utilities.js +15 -7
- package/dist/shell/help-shortcuts.d.ts +4 -0
- package/dist/shell/help-shortcuts.js +38 -7
- package/dist/shell/keyboard-target.d.ts +2 -0
- package/dist/shell/keyboard-target.js +54 -0
- package/dist/shell/settings-sections.d.ts +5 -0
- package/dist/shell/settings-shortcuts.d.ts +10 -0
- package/dist/shell/settings-shortcuts.js +67 -0
- package/dist/update-helper.bundle.js +250 -190
- package/dist/updates/desktop-updater.js +53 -58
- package/dist/updates/packaged-launch-admission.js +3 -2
- package/dist/updates/packaged-release-config.js +6 -5
- package/dist/updates/release-feed.js +9 -9
- package/dist/updates/signed-release.js +5 -5
- package/dist/updates/stable-file.d.ts +18 -0
- package/dist/updates/stable-file.js +54 -1
- package/dist/updates/update-adapter.d.ts +2 -13
- package/dist/updates/update-arm.js +7 -5
- package/dist/updates/update-channel-store.js +7 -9
- package/dist/updates/update-discovery.js +30 -34
- package/dist/updates/update-download-cleanup.js +2 -1
- package/dist/updates/update-download.js +2 -4
- package/dist/updates/update-extraction.js +1 -1
- package/dist/updates/update-generation-lease.js +4 -3
- package/dist/updates/update-handoff-plan.js +3 -2
- package/dist/updates/update-helper.js +8 -6
- package/dist/updates/update-instance-lease.js +3 -2
- package/dist/updates/update-launch-gate.js +12 -25
- package/dist/updates/update-launch.js +3 -2
- package/dist/updates/update-lock.js +3 -2
- package/dist/updates/update-marker.js +3 -2
- package/dist/updates/update-process-fence.js +10 -39
- package/dist/updates/update-process-liveness.js +2 -1
- package/dist/updates/update-resume.js +26 -22
- package/dist/updates/update-retention-marker.js +7 -5
- package/dist/updates/update-retention-plan.js +2 -2
- package/dist/updates/update-retirement.js +40 -39
- package/dist/updates/update-state-store.js +29 -37
- package/dist/updates/update-state.d.ts +8 -3
- package/dist/updates/update-swap-stage.js +6 -5
- package/dist/updates/update-swap.d.ts +1 -1
- package/dist/updates/update-swap.js +8 -6
- package/dist/views/app-help.js +2 -1
- package/dist/views/app-settings.js +5 -2
- package/dist/views/appearance-surface.js +33 -19
- package/package.json +7 -13
- package/src/app/application.tsx +3 -1
- package/src/appearance/appearance-host.tsx +6 -0
- package/src/appearance/appearance-preferences.ts +7 -1
- package/src/appearance/composition.ts +3 -1
- package/src/appearance/custom-theme-import.ts +21 -37
- package/src/appearance/custom-theme-library.ts +21 -5
- package/src/appearance/editor.ts +7 -6
- package/src/appearance/legacy-imported-theme-token-projection.ts +51 -0
- package/src/appearance/theme-record-adapter.ts +58 -11
- package/src/desktop/client-asset-stream.ts +6 -12
- package/src/shell/app-shell.tsx +88 -58
- package/src/shell/app-utilities.tsx +29 -17
- package/src/shell/help-shortcuts.ts +77 -6
- package/src/shell/keyboard-target.ts +74 -0
- package/src/shell/settings-sections.ts +5 -0
- package/src/shell/settings-shortcuts.ts +116 -0
- package/src/updates/update-adapter.ts +2 -14
- package/src/updates/update-state.ts +11 -2
- package/src/views/app-settings.tsx +5 -3
- package/src/views/appearance-surface.tsx +63 -27
- package/dist/native/directory-exchange.js +0 -90
- package/dist/native/exclusive-rename.d.ts +0 -2
- package/dist/native/exclusive-rename.js +0 -52
- package/dist/release/retention-dry-run.d.ts +0 -46
- package/dist/release/retention-dry-run.js +0 -94
- package/dist/updates/update-exclusive-rename.d.ts +0 -3
- package/dist/updates/update-exclusive-rename.js +0 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { assertInstallerContext } from "./installer-layout.js";
|
|
2
|
+
import { windowsProcessImage } from "../native/windows-process.js";
|
|
2
3
|
import { realpath } from "node:fs/promises";
|
|
3
|
-
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
4
4
|
import { execFile } from "node:child_process";
|
|
5
5
|
import { promisify } from "node:util";
|
|
6
6
|
// src/installer/installer-process-cleanup.ts
|
|
@@ -106,53 +106,14 @@ async function runningExecutable(pid, platform, env) {
|
|
|
106
106
|
}
|
|
107
107
|
return windowsRunningExecutable(pid);
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
var STILL_ACTIVE = 259;
|
|
111
|
-
/** Ask the kernel directly: an exited process keeps no STILL_ACTIVE exit code even while
|
|
112
|
-
* another process holds a handle to it. */
|
|
109
|
+
/** The executable of a still-running process, or undefined once it has exited. */
|
|
113
110
|
async function windowsRunningExecutable(pid) {
|
|
114
|
-
|
|
115
|
-
OpenProcess: {
|
|
116
|
-
args: [
|
|
117
|
-
FFIType.u32,
|
|
118
|
-
FFIType.i32,
|
|
119
|
-
FFIType.u32
|
|
120
|
-
],
|
|
121
|
-
returns: FFIType.ptr
|
|
122
|
-
},
|
|
123
|
-
GetExitCodeProcess: {
|
|
124
|
-
args: [FFIType.ptr, FFIType.ptr],
|
|
125
|
-
returns: FFIType.i32
|
|
126
|
-
},
|
|
127
|
-
QueryFullProcessImageNameW: {
|
|
128
|
-
args: [
|
|
129
|
-
FFIType.ptr,
|
|
130
|
-
FFIType.u32,
|
|
131
|
-
FFIType.ptr,
|
|
132
|
-
FFIType.ptr
|
|
133
|
-
],
|
|
134
|
-
returns: FFIType.i32
|
|
135
|
-
},
|
|
136
|
-
CloseHandle: {
|
|
137
|
-
args: [FFIType.ptr],
|
|
138
|
-
returns: FFIType.i32
|
|
139
|
-
}
|
|
140
|
-
});
|
|
111
|
+
let image;
|
|
141
112
|
try {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const code = /* @__PURE__ */ new Uint32Array(1);
|
|
146
|
-
if (!kernel.symbols.GetExitCodeProcess(handle, ptr(code))) throw new Error("Unable to query guarded process state");
|
|
147
|
-
if (code[0] !== STILL_ACTIVE) return void 0;
|
|
148
|
-
const name = /* @__PURE__ */ new Uint16Array(32768), length = new Uint32Array([name.length]);
|
|
149
|
-
if (!kernel.symbols.QueryFullProcessImageNameW(handle, 0, ptr(name), ptr(length))) throw new Error("Unable to query guarded process executable");
|
|
150
|
-
return realpath(Buffer.from(name.buffer, 0, length[0] * 2).toString("utf16le"));
|
|
151
|
-
} finally {
|
|
152
|
-
kernel.symbols.CloseHandle(handle);
|
|
153
|
-
}
|
|
154
|
-
} finally {
|
|
155
|
-
kernel.close();
|
|
113
|
+
image = windowsProcessImage(pid, { requireRunning: true });
|
|
114
|
+
} catch (error) {
|
|
115
|
+
throw new Error("Unable to query guarded process executable", { cause: error });
|
|
156
116
|
}
|
|
117
|
+
return image === "missing" ? void 0 : realpath(image);
|
|
157
118
|
}
|
|
158
119
|
export { macosProcess, macosWorkerExited, terminateGuardedWorker };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { errorCode } from "../app/value-guards.js";
|
|
1
2
|
import { validateInstallerReceipt } from "../release/release-qualification.js";
|
|
2
3
|
import { parseReleaseConfig } from "../release/release-config.js";
|
|
3
|
-
import {
|
|
4
|
+
import { planQualificationRun } from "../release/qualification-run.js";
|
|
4
5
|
import { observeInstalledApp } from "./installer-observation.js";
|
|
5
6
|
import { lstat, writeFile } from "node:fs/promises";
|
|
6
7
|
import { join, resolve } from "node:path";
|
|
@@ -15,7 +16,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
15
16
|
"linux-arm64"
|
|
16
17
|
].includes(platform) || !["native", "cef"].includes(renderer) || typeof config !== "object" || config === null || Array.isArray(config) || typeof config.appName !== "string" || typeof config.appId !== "string") throw new Error("Invalid installer qualification context");
|
|
17
18
|
if (env.RELEASE_TAG !== tag) throw new Error("Installer release tag mismatch");
|
|
18
|
-
const plan = await
|
|
19
|
+
const plan = await planQualificationRun({
|
|
19
20
|
env,
|
|
20
21
|
config,
|
|
21
22
|
tag
|
|
@@ -28,7 +29,7 @@ async function qualifyInstallerCommand(options) {
|
|
|
28
29
|
await lstat(destination);
|
|
29
30
|
throw new Error("Installer receipt already exists");
|
|
30
31
|
} catch (error) {
|
|
31
|
-
if (error
|
|
32
|
+
if (errorCode(error) !== "ENOENT") throw error;
|
|
32
33
|
}
|
|
33
34
|
const app = config;
|
|
34
35
|
const result = await observeInstalledApp({
|
|
@@ -49,8 +50,8 @@ async function qualifyInstallerCommand(options) {
|
|
|
49
50
|
tag,
|
|
50
51
|
sourceSha: plan.sourceSha,
|
|
51
52
|
workflowSha: plan.workflowSha,
|
|
52
|
-
runId:
|
|
53
|
-
runAttempt:
|
|
53
|
+
runId: plan.runId,
|
|
54
|
+
runAttempt: plan.runAttempt
|
|
54
55
|
};
|
|
55
56
|
const receipt = {
|
|
56
57
|
schema: 2,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorCode, isRecord } from "../app/value-guards.js";
|
|
1
2
|
import { verifyReleaseDescriptor } from "../updates/signed-release.js";
|
|
2
3
|
import { feedUrl } from "../updates/release-feed.js";
|
|
3
4
|
import { parseReleaseConfig } from "../release/release-config.js";
|
|
@@ -18,15 +19,14 @@ var targets = {
|
|
|
18
19
|
"linux-x64": ["linux", "x64"],
|
|
19
20
|
"linux-arm64": ["linux", "arm64"]
|
|
20
21
|
};
|
|
21
|
-
var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
22
|
/** The channel descriptor the app discovers for `platform`, as the release config names it. */
|
|
23
23
|
function discoveryName(config, channel, platform) {
|
|
24
24
|
const names = config[`${channel}DiscoveryAssets`], policies = config.descriptors;
|
|
25
|
-
if (!Array.isArray(names) || !
|
|
25
|
+
if (!Array.isArray(names) || !isRecord(policies)) throw new Error("Invalid discovery policy");
|
|
26
26
|
const [os, arch] = targets[platform];
|
|
27
27
|
const matches = names.filter((name) => {
|
|
28
28
|
const policy = typeof name === "string" ? policies[name] : void 0;
|
|
29
|
-
return
|
|
29
|
+
return isRecord(policy) && policy.channel === channel && policy.platform === os && policy.arch === arch;
|
|
30
30
|
});
|
|
31
31
|
if (matches.length !== 1 || matches[0].includes("{tag}")) throw new Error("Invalid discovery policy");
|
|
32
32
|
return matches[0];
|
|
@@ -49,7 +49,7 @@ async function readBounded(path, maximum) {
|
|
|
49
49
|
*/
|
|
50
50
|
async function qualifyUpgradeCommand(options) {
|
|
51
51
|
const { env, config, tag, platform, renderer } = options;
|
|
52
|
-
if (!Object.hasOwn(targets, platform) || !["native", "cef"].includes(renderer) || !
|
|
52
|
+
if (!Object.hasOwn(targets, platform) || !["native", "cef"].includes(renderer) || !isRecord(config) || typeof config.appName !== "string" || typeof config.appId !== "string" || !isRecord(config.releaseSigningKeys) || typeof env.GITHUB_REPOSITORY !== "string") throw new Error("Invalid upgrade qualification context");
|
|
53
53
|
if (env.RELEASE_TAG !== tag) throw new Error("Upgrade release tag mismatch");
|
|
54
54
|
const plan = await planReleaseAssets({
|
|
55
55
|
env,
|
|
@@ -64,7 +64,7 @@ async function qualifyUpgradeCommand(options) {
|
|
|
64
64
|
await lstat(destination);
|
|
65
65
|
throw new Error("Upgrade receipt already exists");
|
|
66
66
|
} catch (error) {
|
|
67
|
-
if (error
|
|
67
|
+
if (errorCode(error) !== "ENOENT") throw error;
|
|
68
68
|
}
|
|
69
69
|
const keys = /* @__PURE__ */ new Map();
|
|
70
70
|
for (const [id, value] of Object.entries(config.releaseSigningKeys)) if (typeof value === "string") keys.set(id, value);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorCode } from "../app/value-guards.js";
|
|
1
2
|
import { assertHostedRunner } from "./hosted-runner.js";
|
|
2
3
|
import { lstat, open, writeFile } from "node:fs/promises";
|
|
3
4
|
import { resolve } from "node:path";
|
|
@@ -63,7 +64,7 @@ async function awaitInstallerWorkerPermit(options) {
|
|
|
63
64
|
if (!expected.startsWith(contents)) throw new Error("Invalid worker permit");
|
|
64
65
|
if (contents === expected) return pathToFileURL(resolve(entry)).href;
|
|
65
66
|
} catch (error) {
|
|
66
|
-
if (error
|
|
67
|
+
if (errorCode(error) !== "ENOENT") throw error;
|
|
67
68
|
}
|
|
68
69
|
await new Promise((done) => setTimeout(done, Math.min(100, Math.max(1, deadline - Date.now()))));
|
|
69
70
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isAbsolute, resolve } from "node:path";
|
|
2
|
+
// src/native/canonical-path.ts
|
|
3
|
+
/**
|
|
4
|
+
* True for an absolute, already-normalized path with no NUL byte: the form every
|
|
5
|
+
* filesystem boundary in the framework accepts before touching disk.
|
|
6
|
+
*/
|
|
7
|
+
function isCanonicalPath(value) {
|
|
8
|
+
return typeof value === "string" && isAbsolute(value) && resolve(value) === value && !value.includes("\0");
|
|
9
|
+
}
|
|
10
|
+
export { isCanonicalPath };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { errorCode } from "../app/value-guards.js";
|
|
1
2
|
import { downloadCefHelperInput } from "./cef-helper-download.js";
|
|
2
3
|
import { CEF_BRIDGE_PATCH_PATH, CEF_HELPER_SOURCES, ELECTROBUN_COMMIT, PINNED_CEF_BRIDGE_PATCH, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
3
4
|
import { chmod, lstat, mkdir, mkdtemp, open, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import { dirname, isAbsolute, join } from "node:path";
|
|
5
|
-
import { spawnSync } from "node:child_process";
|
|
6
6
|
import { createHash, randomUUID } from "node:crypto";
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
7
8
|
import { availableParallelism, homedir } from "node:os";
|
|
8
9
|
// src/native/cef-helper.ts
|
|
9
10
|
/** The CEF build Electrobun 2.0.5 pins (its src/shared/cef-version.ts). */
|
|
@@ -147,7 +148,7 @@ async function verifyCachedHelper(entry, output, key) {
|
|
|
147
148
|
...actual
|
|
148
149
|
}) + "\n") throw new Error("Invalid cached CEF helper");
|
|
149
150
|
} catch (error) {
|
|
150
|
-
if (error
|
|
151
|
+
if (errorCode(error) === "ENOENT") throw new Error("Invalid cached CEF helper", { cause: error });
|
|
151
152
|
throw error;
|
|
152
153
|
}
|
|
153
154
|
}
|
|
@@ -161,7 +162,7 @@ async function ensurePatchedCefHelper(env, os, arch, build = buildPatchedCefHelp
|
|
|
161
162
|
try {
|
|
162
163
|
await lstat(entry);
|
|
163
164
|
} catch (error) {
|
|
164
|
-
if (error
|
|
165
|
+
if (errorCode(error) !== "ENOENT") throw error;
|
|
165
166
|
await mkdir(root, { recursive: true });
|
|
166
167
|
const work = await mkdtemp(join(root, ".build-"));
|
|
167
168
|
try {
|
|
@@ -181,7 +182,7 @@ async function ensurePatchedCefHelper(env, os, arch, build = buildPatchedCefHelp
|
|
|
181
182
|
"EEXIST",
|
|
182
183
|
"ENOTEMPTY",
|
|
183
184
|
"EPERM"
|
|
184
|
-
].includes(publishError
|
|
185
|
+
].includes(errorCode(publishError) ?? "")) throw publishError;
|
|
185
186
|
}
|
|
186
187
|
} finally {
|
|
187
188
|
await rm(work, {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { errorCode } from "../app/value-guards.js";
|
|
1
2
|
import { dirname, isAbsolute, join, normalize } from "node:path";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
2
4
|
import { lstatSync, readFileSync } from "node:fs";
|
|
3
5
|
import { execFileSync } from "node:child_process";
|
|
4
|
-
import { createHash } from "node:crypto";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
// src/native/electrobun-source-patch.ts
|
|
7
8
|
/** Electrobun 2.0.5 (MIT), tag v2.0.5: the only source these patches target. */
|
|
@@ -67,7 +68,7 @@ function sourceDigest(root, path) {
|
|
|
67
68
|
try {
|
|
68
69
|
info = lstatSync(full);
|
|
69
70
|
} catch (error) {
|
|
70
|
-
if (error
|
|
71
|
+
if (errorCode(error) === "ENOENT") return null;
|
|
71
72
|
throw error;
|
|
72
73
|
}
|
|
73
74
|
if (!info.isFile() || info.isSymbolicLink()) throw new Error("Unexpected Electrobun source type");
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Rename without replacing an existing destination on supported desktop platforms. */
|
|
2
|
+
export declare function renameExclusive(source: string, destination: string): void;
|
|
1
3
|
/** Atomically exchange two existing paths on supported Darwin and Linux filesystems. */
|
|
2
4
|
export declare function exchangeDirectories(source: string, destination: string): void;
|
|
3
5
|
/**
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { isCanonicalPath } from "./canonical-path.js";
|
|
2
|
+
import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { randomUUID } from "node:crypto";
|
|
5
|
+
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
6
|
+
// src/native/native-rename.ts
|
|
7
|
+
var DARWIN_RENAME_SWAP = 2;
|
|
8
|
+
var DARWIN_RENAME_EXCL = 4;
|
|
9
|
+
var LINUX_RENAME_NOREPLACE = 1;
|
|
10
|
+
var LINUX_RENAME_EXCHANGE = 2;
|
|
11
|
+
var AT_FDCWD = -100;
|
|
12
|
+
var library;
|
|
13
|
+
/** Open the platform rename entry point once; the process keeps it for its lifetime. */
|
|
14
|
+
function renameLibrary() {
|
|
15
|
+
if (library) return library;
|
|
16
|
+
if (process.platform === "darwin") {
|
|
17
|
+
const { symbols } = dlopen("libSystem.B.dylib", { renamex_np: {
|
|
18
|
+
args: [
|
|
19
|
+
FFIType.ptr,
|
|
20
|
+
FFIType.ptr,
|
|
21
|
+
FFIType.u32
|
|
22
|
+
],
|
|
23
|
+
returns: FFIType.i32
|
|
24
|
+
} });
|
|
25
|
+
library = {
|
|
26
|
+
platform: "darwin",
|
|
27
|
+
rename: (from, to, flags) => symbols.renamex_np(ptr(from), ptr(to), flags) === 0
|
|
28
|
+
};
|
|
29
|
+
} else if (process.platform === "linux") {
|
|
30
|
+
const { symbols } = dlopen("libc.so.6", { renameat2: {
|
|
31
|
+
args: [
|
|
32
|
+
FFIType.i32,
|
|
33
|
+
FFIType.ptr,
|
|
34
|
+
FFIType.i32,
|
|
35
|
+
FFIType.ptr,
|
|
36
|
+
FFIType.u32
|
|
37
|
+
],
|
|
38
|
+
returns: FFIType.i32
|
|
39
|
+
} });
|
|
40
|
+
library = {
|
|
41
|
+
platform: "linux",
|
|
42
|
+
rename: (from, to, flags) => symbols.renameat2(AT_FDCWD, ptr(from), AT_FDCWD, ptr(to), flags) === 0
|
|
43
|
+
};
|
|
44
|
+
} else if (process.platform === "win32") {
|
|
45
|
+
const { symbols } = dlopen("kernel32.dll", { MoveFileW: {
|
|
46
|
+
args: [FFIType.ptr, FFIType.ptr],
|
|
47
|
+
returns: FFIType.i32
|
|
48
|
+
} });
|
|
49
|
+
library = {
|
|
50
|
+
platform: "win32",
|
|
51
|
+
move: (from, to) => symbols.MoveFileW(ptr(from), ptr(to)) !== 0
|
|
52
|
+
};
|
|
53
|
+
} else throw new Error("Unsupported native rename platform");
|
|
54
|
+
return library;
|
|
55
|
+
}
|
|
56
|
+
function renamePaths(source, destination) {
|
|
57
|
+
return isCanonicalPath(source) && isCanonicalPath(destination) && source !== destination;
|
|
58
|
+
}
|
|
59
|
+
var cString = (path) => Buffer.from(path + "\0");
|
|
60
|
+
/** Rename without replacing an existing destination on supported desktop platforms. */
|
|
61
|
+
function renameExclusive(source, destination) {
|
|
62
|
+
if (!renamePaths(source, destination)) throw new Error("Invalid exclusive rename paths");
|
|
63
|
+
let native;
|
|
64
|
+
try {
|
|
65
|
+
native = renameLibrary();
|
|
66
|
+
} catch {
|
|
67
|
+
throw new Error("Unsupported exclusive rename platform");
|
|
68
|
+
}
|
|
69
|
+
if (!(native.platform === "win32" ? native.move(Buffer.from(source + "\0", "utf16le"), Buffer.from(destination + "\0", "utf16le")) : native.rename(cString(source), cString(destination), native.platform === "darwin" ? DARWIN_RENAME_EXCL : LINUX_RENAME_NOREPLACE))) throw new Error("Exclusive rename failed");
|
|
70
|
+
}
|
|
71
|
+
/** Atomically exchange two existing paths on supported Darwin and Linux filesystems. */
|
|
72
|
+
function exchangeDirectories(source, destination) {
|
|
73
|
+
if (!renamePaths(source, destination)) throw new Error("Invalid atomic directory exchange paths");
|
|
74
|
+
if (process.platform !== "darwin" && process.platform !== "linux") throw new Error("Atomic directory exchange is unsupported on this platform");
|
|
75
|
+
const native = renameLibrary();
|
|
76
|
+
if (native.platform === "win32") throw new Error("Atomic directory exchange is unsupported on this platform");
|
|
77
|
+
const flags = native.platform === "darwin" ? DARWIN_RENAME_SWAP : LINUX_RENAME_EXCHANGE;
|
|
78
|
+
if (!native.rename(cString(source), cString(destination), flags)) throw new Error("Atomic directory exchange is unsupported or failed");
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Exercise the actual volume using two disposable directories before exchanging
|
|
82
|
+
* an install tree. This qualifies only that same-volume probe pair; it cannot
|
|
83
|
+
* prove a provider will behave identically for every later object or survive a
|
|
84
|
+
* power failure. The caller also verifies the real trees' versions and inode
|
|
85
|
+
* identities immediately after the exchange.
|
|
86
|
+
*/
|
|
87
|
+
async function probeDirectoryExchange(parent, exchange = exchangeDirectories) {
|
|
88
|
+
if (!isCanonicalPath(parent)) throw new Error("Invalid directory exchange probe parent");
|
|
89
|
+
const id = randomUUID();
|
|
90
|
+
const first = join(parent, `.framework-exchange-probe-${id}-a`);
|
|
91
|
+
const second = join(parent, `.framework-exchange-probe-${id}-b`);
|
|
92
|
+
const marker = "exchange-probe";
|
|
93
|
+
const firstValue = `${id}:first`;
|
|
94
|
+
const secondValue = `${id}:second`;
|
|
95
|
+
let firstCreated = false;
|
|
96
|
+
let secondCreated = false;
|
|
97
|
+
try {
|
|
98
|
+
await mkdir(first, { mode: 448 });
|
|
99
|
+
firstCreated = true;
|
|
100
|
+
await mkdir(second, { mode: 448 });
|
|
101
|
+
secondCreated = true;
|
|
102
|
+
await writeFile(join(first, marker), firstValue, {
|
|
103
|
+
flag: "wx",
|
|
104
|
+
mode: 384
|
|
105
|
+
});
|
|
106
|
+
await writeFile(join(second, marker), secondValue, {
|
|
107
|
+
flag: "wx",
|
|
108
|
+
mode: 384
|
|
109
|
+
});
|
|
110
|
+
exchange(first, second);
|
|
111
|
+
const [firstAfter, secondAfter] = await Promise.all([readFile(join(first, marker), "utf8"), readFile(join(second, marker), "utf8")]);
|
|
112
|
+
if (firstAfter !== secondValue || secondAfter !== firstValue) throw new Error("Directory exchange did not exchange both probe trees");
|
|
113
|
+
} finally {
|
|
114
|
+
const cleanup = [];
|
|
115
|
+
if (firstCreated) cleanup.push(rm(first, {
|
|
116
|
+
recursive: true,
|
|
117
|
+
force: true
|
|
118
|
+
}));
|
|
119
|
+
if (secondCreated) cleanup.push(rm(second, {
|
|
120
|
+
recursive: true,
|
|
121
|
+
force: true
|
|
122
|
+
}));
|
|
123
|
+
await Promise.all(cleanup);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export { exchangeDirectories, probeDirectoryExchange, renameExclusive };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createSerialQueue } from "../app/serial-queue.js";
|
|
1
2
|
// src/native/native-secret-store.ts
|
|
2
3
|
var identifier = (value) => typeof value === "string" && value.length > 0 && value.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(value);
|
|
3
4
|
/** Native credentials only. Apps choose the service namespace and own authorization and migration. */
|
|
@@ -7,16 +8,11 @@ function createNativeSecretStore(options) {
|
|
|
7
8
|
if (!identifier(service) || !Number.isSafeInteger(maxBytes) || maxBytes < 1 || maxBytes > 2048) throw new Error("Invalid credential store configuration");
|
|
8
9
|
const backend = options.backend ?? Bun.secrets;
|
|
9
10
|
if (!backend || typeof backend.get !== "function" || typeof backend.set !== "function" || typeof backend.delete !== "function") throw new Error("Credential store unavailable");
|
|
10
|
-
|
|
11
|
+
const ordered = createSerialQueue();
|
|
11
12
|
const name = (value) => {
|
|
12
13
|
if (!identifier(value)) throw new Error("Invalid credential name");
|
|
13
14
|
return value;
|
|
14
15
|
};
|
|
15
|
-
function ordered(task) {
|
|
16
|
-
const result = queue.then(task);
|
|
17
|
-
queue = result.then(() => {}, () => {});
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
16
|
async function read(account) {
|
|
21
17
|
try {
|
|
22
18
|
const value = await backend.get({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { isRecord } from "../app/value-guards.js";
|
|
1
2
|
import { containsAsciiControl } from "../desktop/string-policy.js";
|
|
2
3
|
import { isAbsolute } from "node:path";
|
|
3
4
|
// src/native/native-utilities.ts
|
|
4
5
|
var MAX_PICKED_FILES = 1e3;
|
|
5
|
-
var object = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6
6
|
var path = (value) => typeof value === "string" && value.length > 0 && value.length <= 4096 && !containsAsciiControl(value) && isAbsolute(value) && (process.platform !== "win32" || /^[A-Za-z]:[\\/]/.test(value) || /^\\\\[A-Za-z0-9][A-Za-z0-9._-]*\\[^\\/?]+(?:\\|$)/.test(value));
|
|
7
7
|
/** Register shared native utilities behind the host's authenticated principal and policy. */
|
|
8
8
|
function registerNativeUtilities(options) {
|
|
@@ -32,7 +32,7 @@ function registerNativeUtilities(options) {
|
|
|
32
32
|
}));
|
|
33
33
|
unregister.push(services.register("shell.open-external", {
|
|
34
34
|
parse(value) {
|
|
35
|
-
if (!
|
|
35
|
+
if (!isRecord(value) || Object.keys(value).length !== 1 || typeof value.url !== "string" || value.url.length > 2048 || containsAsciiControl(value.url, true)) throw new Error("Invalid URL");
|
|
36
36
|
const url = new URL(value.url);
|
|
37
37
|
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) throw new Error("Invalid URL");
|
|
38
38
|
return url.href;
|
|
@@ -46,7 +46,7 @@ function registerNativeUtilities(options) {
|
|
|
46
46
|
}));
|
|
47
47
|
unregister.push(services.register("shell.pick-folder", {
|
|
48
48
|
parse(value) {
|
|
49
|
-
if (!
|
|
49
|
+
if (!isRecord(value) || Object.keys(value).some((key) => key !== "startingFolder") || value.startingFolder !== void 0 && !path(value.startingFolder)) throw new Error("Invalid folder request");
|
|
50
50
|
return value.startingFolder;
|
|
51
51
|
},
|
|
52
52
|
authorize: (principal) => authorize(principal, "pick-folder"),
|
|
@@ -58,7 +58,7 @@ function registerNativeUtilities(options) {
|
|
|
58
58
|
}));
|
|
59
59
|
if (pickFiles) unregister.push(services.register("shell.pick-files", {
|
|
60
60
|
parse(value) {
|
|
61
|
-
if (!
|
|
61
|
+
if (!isRecord(value) || Object.keys(value).some((key) => ![
|
|
62
62
|
"startingFolder",
|
|
63
63
|
"extensions",
|
|
64
64
|
"multiple"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ELECTROBUN_COMMIT, PINNED_POSIX_LAUNCH_LEASE_PATCH, POSIX_LAUNCH_LEASE_PATCH_PATH, applyElectrobunPatch } from "./electrobun-source-patch.js";
|
|
2
2
|
import { chmod, copyFile, lstat, mkdir, mkdtemp, open, readFile, rename, rm } from "node:fs/promises";
|
|
3
3
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
4
|
-
import { execFileSync, spawnSync } from "node:child_process";
|
|
5
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
5
|
+
import { execFileSync, spawnSync } from "node:child_process";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
7
|
// src/native/posix-launcher-build.ts
|
|
8
8
|
var POSIX_LAUNCH_LEASE_OPT_IN = "ADEA_ENABLE_POSIX_LAUNCH_LEASE";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { isCanonicalPath } from "./canonical-path.js";
|
|
1
2
|
import { lstat, open } from "node:fs/promises";
|
|
2
|
-
import { isAbsolute, resolve } from "node:path";
|
|
3
3
|
import { FFIType, dlopen, ptr, read } from "bun:ffi";
|
|
4
4
|
import { constants as constants$1 } from "node:fs";
|
|
5
5
|
// src/native/posix-tree-removal.ts
|
|
@@ -371,7 +371,7 @@ async function removeDirectoryContentsChunk(options) {
|
|
|
371
371
|
const { root, expectedRootIdentity, maxOperations, prioritizeVersionMarker, testOnlyFailBarrierAtCall } = options;
|
|
372
372
|
const darwin = process.platform === "darwin";
|
|
373
373
|
if (!darwin || process.arch !== "arm64") throw new Error("Safe directory-relative removal is unsupported on this platform");
|
|
374
|
-
if (
|
|
374
|
+
if (!isCanonicalPath(root) || !expectedRootIdentity || !/^[1-9]\d{0,19}$/.test(expectedRootIdentity.device) || !/^[1-9]\d{0,19}$/.test(expectedRootIdentity.inode) || !Number.isSafeInteger(maxOperations) || maxOperations < 1 || maxOperations > 4096 || testOnlyFailBarrierAtCall !== void 0 && (!Number.isSafeInteger(testOnlyFailBarrierAtCall) || testOnlyFailBarrierAtCall < 1)) throw new Error("Invalid bounded tree removal request");
|
|
375
375
|
const rootInfo = await lstat(root, { bigint: true });
|
|
376
376
|
if (!rootInfo.isDirectory() || rootInfo.isSymbolicLink()) throw new Error("Tree removal root is not a directory");
|
|
377
377
|
if (rootInfo.dev.toString() !== expectedRootIdentity.device || rootInfo.ino.toString() !== expectedRootIdentity.inode) throw new Error("Tree removal root identity changed");
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ask the Windows kernel for a process's executable image path. `missing` means
|
|
3
|
+
* the process id could not be opened. With `requireRunning`, a process that has
|
|
4
|
+
* already exited reports `missing` too: an exited process keeps no STILL_ACTIVE
|
|
5
|
+
* exit code even while another process holds a handle to it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function windowsProcessImage(pid: number, options: {
|
|
8
|
+
requireRunning: boolean;
|
|
9
|
+
}): string | 'missing';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { FFIType, dlopen, ptr } from "bun:ffi";
|
|
2
|
+
// src/native/windows-process.ts
|
|
3
|
+
var PROCESS_QUERY_LIMITED_INFORMATION = 4096;
|
|
4
|
+
var STILL_ACTIVE = 259;
|
|
5
|
+
var MAX_PATH_CHARS = 32768;
|
|
6
|
+
function kernel32() {
|
|
7
|
+
return dlopen("kernel32.dll", {
|
|
8
|
+
OpenProcess: {
|
|
9
|
+
args: [
|
|
10
|
+
FFIType.u32,
|
|
11
|
+
FFIType.i32,
|
|
12
|
+
FFIType.u32
|
|
13
|
+
],
|
|
14
|
+
returns: FFIType.ptr
|
|
15
|
+
},
|
|
16
|
+
GetExitCodeProcess: {
|
|
17
|
+
args: [FFIType.ptr, FFIType.ptr],
|
|
18
|
+
returns: FFIType.i32
|
|
19
|
+
},
|
|
20
|
+
QueryFullProcessImageNameW: {
|
|
21
|
+
args: [
|
|
22
|
+
FFIType.ptr,
|
|
23
|
+
FFIType.u32,
|
|
24
|
+
FFIType.ptr,
|
|
25
|
+
FFIType.ptr
|
|
26
|
+
],
|
|
27
|
+
returns: FFIType.i32
|
|
28
|
+
},
|
|
29
|
+
CloseHandle: {
|
|
30
|
+
args: [FFIType.ptr],
|
|
31
|
+
returns: FFIType.i32
|
|
32
|
+
}
|
|
33
|
+
}).symbols;
|
|
34
|
+
}
|
|
35
|
+
var symbols;
|
|
36
|
+
/**
|
|
37
|
+
* Ask the Windows kernel for a process's executable image path. `missing` means
|
|
38
|
+
* the process id could not be opened. With `requireRunning`, a process that has
|
|
39
|
+
* already exited reports `missing` too: an exited process keeps no STILL_ACTIVE
|
|
40
|
+
* exit code even while another process holds a handle to it.
|
|
41
|
+
*/
|
|
42
|
+
function windowsProcessImage(pid, options) {
|
|
43
|
+
symbols ??= kernel32();
|
|
44
|
+
const handle = symbols.OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid);
|
|
45
|
+
if (!handle) return "missing";
|
|
46
|
+
try {
|
|
47
|
+
if (options.requireRunning) {
|
|
48
|
+
const code = /* @__PURE__ */ new Uint32Array(1);
|
|
49
|
+
if (!symbols.GetExitCodeProcess(handle, ptr(code))) throw new Error("Unable to query process state");
|
|
50
|
+
if (code[0] !== STILL_ACTIVE) return "missing";
|
|
51
|
+
}
|
|
52
|
+
const name = new Uint16Array(MAX_PATH_CHARS), length = new Uint32Array([MAX_PATH_CHARS]);
|
|
53
|
+
if (!symbols.QueryFullProcessImageNameW(handle, 0, ptr(name), ptr(length))) throw new Error("Unable to query process executable");
|
|
54
|
+
if (!length[0] || length[0] >= MAX_PATH_CHARS) throw new Error("Invalid process executable path");
|
|
55
|
+
return Buffer.from(name.buffer, 0, length[0] * 2).toString("utf16le");
|
|
56
|
+
} finally {
|
|
57
|
+
symbols.CloseHandle(handle);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export { windowsProcessImage };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isGitSha } from "../app/value-guards.js";
|
|
1
2
|
import { gitIsAncestor } from "./local-provenance.js";
|
|
2
3
|
// src/release/feed-release-cut.ts
|
|
3
4
|
function checkVersion(version) {
|
|
@@ -26,7 +27,7 @@ async function commitTree(git, sha) {
|
|
|
26
27
|
"--verify",
|
|
27
28
|
`${sha}^{tree}`
|
|
28
29
|
]);
|
|
29
|
-
if (
|
|
30
|
+
if (!isGitSha(tree)) throw new Error("Invalid commit tree");
|
|
30
31
|
return tree;
|
|
31
32
|
}
|
|
32
33
|
async function hasCommit(git, sha) {
|
|
@@ -2,8 +2,8 @@ import { readPackageFile } from "./framework-update.js";
|
|
|
2
2
|
import { gitCli, resolveLocalProvenance } from "./local-provenance.js";
|
|
3
3
|
import { lstat, mkdtemp, open, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { basename, join, resolve } from "node:path";
|
|
5
|
-
import { execFile } from "node:child_process";
|
|
6
5
|
import { createHash } from "node:crypto";
|
|
6
|
+
import { execFile } from "node:child_process";
|
|
7
7
|
import { tmpdir } from "node:os";
|
|
8
8
|
// src/release/framework-package-publish.ts
|
|
9
9
|
var packageName = "@adea-ai/app-framework";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { errorCode } from "../app/value-guards.js";
|
|
1
2
|
import { lstat, mkdir, rmdir } from "node:fs/promises";
|
|
2
3
|
// src/release/framework-update-lock.ts
|
|
3
4
|
/** Serialize cooperating framework updates in one Git worktree. */
|
|
@@ -5,7 +6,7 @@ async function withFrameworkUpdateLock(path, run) {
|
|
|
5
6
|
try {
|
|
6
7
|
await mkdir(path);
|
|
7
8
|
} catch (error) {
|
|
8
|
-
if (error
|
|
9
|
+
if (errorCode(error) === "EEXIST") throw new Error("A framework update is running or its lock remains; inspect the worktree lock", { cause: error });
|
|
9
10
|
throw error;
|
|
10
11
|
}
|
|
11
12
|
let owner;
|
|
@@ -3,4 +3,22 @@ type GitHubRun = (args: string[], input?: string) => Promise<string>;
|
|
|
3
3
|
/** The `gh` CLI runner every release command shares. A failure rejects with
|
|
4
4
|
* 'GitHub request failed', carrying stderr and whether GitHub answered 404. */
|
|
5
5
|
export declare function githubCli(env?: NodeJS.ProcessEnv): GitHubRun;
|
|
6
|
+
/**
|
|
7
|
+
* Fetch this exact workflow attempt from GitHub and require it to match the
|
|
8
|
+
* runner's environment and the expected workflow identity. Release commands use
|
|
9
|
+
* it so a forged or re-pointed environment cannot borrow another run's rights.
|
|
10
|
+
*/
|
|
11
|
+
export declare function verifyWorkflowAttempt(options: {
|
|
12
|
+
run: GitHubRun;
|
|
13
|
+
repository: string;
|
|
14
|
+
env: Record<string, string | undefined>;
|
|
15
|
+
expected: {
|
|
16
|
+
headSha: string;
|
|
17
|
+
event: string;
|
|
18
|
+
path: string;
|
|
19
|
+
headBranch?: string;
|
|
20
|
+
displayTitle?: string;
|
|
21
|
+
};
|
|
22
|
+
mismatch: string;
|
|
23
|
+
}): Promise<void>;
|
|
6
24
|
export {};
|
|
@@ -13,4 +13,16 @@ function githubCli(env) {
|
|
|
13
13
|
})) : resolve(stdout)).stdin?.end(input);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Fetch this exact workflow attempt from GitHub and require it to match the
|
|
18
|
+
* runner's environment and the expected workflow identity. Release commands use
|
|
19
|
+
* it so a forged or re-pointed environment cannot borrow another run's rights.
|
|
20
|
+
*/
|
|
21
|
+
async function verifyWorkflowAttempt(options) {
|
|
22
|
+
const { run, repository, env, expected } = options;
|
|
23
|
+
const response = JSON.parse(await run(["api", `repos/${repository}/actions/runs/${env.GITHUB_RUN_ID}/attempts/${env.GITHUB_RUN_ATTEMPT}`]));
|
|
24
|
+
if (typeof response !== "object" || response === null || Array.isArray(response)) throw new Error(options.mismatch);
|
|
25
|
+
const workflow = response;
|
|
26
|
+
if (String(workflow.id) !== env.GITHUB_RUN_ID || String(workflow.run_attempt) !== env.GITHUB_RUN_ATTEMPT || workflow.head_sha !== expected.headSha || workflow.event !== expected.event || workflow.path !== expected.path || expected.headBranch !== void 0 && workflow.head_branch !== expected.headBranch || expected.displayTitle !== void 0 && workflow.display_title !== expected.displayTitle || workflow.repository?.full_name !== repository) throw new Error(options.mismatch);
|
|
27
|
+
}
|
|
28
|
+
export { githubCli, verifyWorkflowAttempt };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isGitSha } from "../app/value-guards.js";
|
|
1
2
|
import { containsAsciiControl } from "../desktop/string-policy.js";
|
|
2
3
|
import { githubCli } from "./github-cli.js";
|
|
3
4
|
import { verifyReleaseProvenance } from "./github-release-provenance.js";
|
|
@@ -20,12 +21,12 @@ function createGitHubReleaseCutProvider(options) {
|
|
|
20
21
|
includeDraft: true
|
|
21
22
|
});
|
|
22
23
|
const isMainAncestor = async (sha) => {
|
|
23
|
-
if (
|
|
24
|
+
if (!isGitSha(sha)) return false;
|
|
24
25
|
const result = await read(`${base}/compare/${sha}...main`);
|
|
25
26
|
return ["ahead", "identical"].includes(String(result?.status));
|
|
26
27
|
};
|
|
27
28
|
const isAncestor = async (older, newer) => {
|
|
28
|
-
if (
|
|
29
|
+
if (!isGitSha(older) || !isGitSha(newer)) return false;
|
|
29
30
|
return (await read(`${base}/compare/${older}...${newer}`))?.status === "ahead";
|
|
30
31
|
};
|
|
31
32
|
async function tagExists(tag) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { isGitSha } from "../app/value-guards.js";
|
|
1
2
|
// src/release/github-release-provenance.ts
|
|
2
3
|
/** Check the tag and source independently; legacy release notes are never rewritten. */
|
|
3
4
|
async function verifyReleaseProvenance(options) {
|
|
4
5
|
const { tag, sourceSha, body, releasePleaseManifestPath, read, base } = options;
|
|
5
|
-
if (
|
|
6
|
+
if (!isGitSha(sourceSha)) return false;
|
|
6
7
|
const lines = body.split(/\r?\n/);
|
|
7
8
|
const markers = lines.filter((line) => line.startsWith("adea-channel:"));
|
|
8
9
|
const sources = lines.filter((line) => line.startsWith("Source: "));
|