@cortexkit/anthropic-auth-core 2.14.0 → 2.14.1
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/dist/index.js +205 -122
- package/dist/internal-types/setup/enroll.d.ts +2 -1
- package/dist/internal-types/setup/process-fence.d.ts +9 -0
- package/dist/internal-types/setup/process-guard.d.ts +12 -0
- package/dist/internal-types/setup/register.d.ts +2 -1
- package/dist/native-migration.d.ts +4 -0
- package/dist/pool-authority.d.ts +3 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -8543,7 +8543,20 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
8543
8543
|
import { writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
|
|
8544
8544
|
|
|
8545
8545
|
// ../../node_modules/@cortexkit/common-auth/dist/setup/process-fence.js
|
|
8546
|
+
import { statSync as statSync3 } from "node:fs";
|
|
8547
|
+
import { win32 as win322 } from "node:path";
|
|
8546
8548
|
var WINDOWS_CIM_TIMEOUT_MS = 45000;
|
|
8549
|
+
var WINDOWS_ARM_POWERSHELL_TIMEOUT_MS = 90000;
|
|
8550
|
+
function isFile(file) {
|
|
8551
|
+
try {
|
|
8552
|
+
return statSync3(file).isFile();
|
|
8553
|
+
} catch {
|
|
8554
|
+
return false;
|
|
8555
|
+
}
|
|
8556
|
+
}
|
|
8557
|
+
function windowsEnv(env, name) {
|
|
8558
|
+
return Object.entries(env).find(([key]) => key.toUpperCase() === name.toUpperCase())?.[1];
|
|
8559
|
+
}
|
|
8547
8560
|
var HOSTS = new Set(["opencode", "litecode", "opencode2", "pi"]);
|
|
8548
8561
|
var RUNTIMES = new Set(["node", "bun"]);
|
|
8549
8562
|
var WINDOWS_FENCE_FILTER = [...HOSTS, ...RUNTIMES].map((name) => `Name LIKE '${name}%'`).join(" OR ");
|
|
@@ -8616,6 +8629,7 @@ function hostName(command) {
|
|
|
8616
8629
|
class ProcessInspectionError extends Error {
|
|
8617
8630
|
code = "process-inspection-failed";
|
|
8618
8631
|
step;
|
|
8632
|
+
program;
|
|
8619
8633
|
exitCode;
|
|
8620
8634
|
signal;
|
|
8621
8635
|
timedOut;
|
|
@@ -8624,6 +8638,7 @@ class ProcessInspectionError extends Error {
|
|
|
8624
8638
|
super("Process inspection failed; setup cannot prove hosts are stopped.");
|
|
8625
8639
|
this.name = "ProcessInspectionError";
|
|
8626
8640
|
this.step = details.step;
|
|
8641
|
+
this.program = details.program;
|
|
8627
8642
|
this.exitCode = details.exitCode;
|
|
8628
8643
|
this.signal = details.signal;
|
|
8629
8644
|
this.timedOut = details.timedOut;
|
|
@@ -8653,6 +8668,8 @@ Please quit all OpenCode, LiteCode, and Pi processes before running setup.`);
|
|
|
8653
8668
|
}
|
|
8654
8669
|
async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
8655
8670
|
const windows = (options.platform ?? process.platform) === "win32";
|
|
8671
|
+
const env = options.env ?? process.env;
|
|
8672
|
+
const system32 = windows ? win322.resolve(windowsEnv(env, "SystemRoot") ?? windowsEnv(env, "windir") ?? "C:\\Windows", "System32") : "";
|
|
8656
8673
|
const selfPid = options.selfPid ?? process.pid;
|
|
8657
8674
|
let inspection = {
|
|
8658
8675
|
step: windows ? "tasklist" : "ps",
|
|
@@ -8661,10 +8678,11 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8661
8678
|
timedOut: false,
|
|
8662
8679
|
durationMs: 0
|
|
8663
8680
|
};
|
|
8664
|
-
const inspect = async (step, file, args, timeoutMs) => {
|
|
8681
|
+
const inspect = async (step, file, args, timeoutMs, program) => {
|
|
8665
8682
|
const started = performance.now();
|
|
8666
8683
|
inspection = {
|
|
8667
8684
|
step,
|
|
8685
|
+
...program && { program },
|
|
8668
8686
|
exitCode: null,
|
|
8669
8687
|
signal: null,
|
|
8670
8688
|
timedOut: false,
|
|
@@ -8677,6 +8695,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8677
8695
|
});
|
|
8678
8696
|
inspection = {
|
|
8679
8697
|
step,
|
|
8698
|
+
...program && { program },
|
|
8680
8699
|
exitCode: result.exitCode,
|
|
8681
8700
|
signal: result.signal ?? null,
|
|
8682
8701
|
timedOut: result.timedOut ?? false,
|
|
@@ -8689,9 +8708,23 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8689
8708
|
options.onStep?.({ ...inspection });
|
|
8690
8709
|
}
|
|
8691
8710
|
};
|
|
8711
|
+
const inspectCim = (args) => {
|
|
8712
|
+
const pwsh = win322.resolve(windowsEnv(env, "ProgramFiles") ?? "C:\\Program Files", "PowerShell", "7", "pwsh.exe");
|
|
8713
|
+
const program = (options.isFile ?? isFile)(pwsh) ? "pwsh" : "powershell";
|
|
8714
|
+
const arm64 = (windowsEnv(env, "PROCESSOR_ARCHITEW6432") ?? windowsEnv(env, "PROCESSOR_ARCHITECTURE"))?.toUpperCase() === "ARM64";
|
|
8715
|
+
const slow = program === "powershell" && arm64;
|
|
8716
|
+
if (slow)
|
|
8717
|
+
options.onProgress?.("Checking that OpenCode and Pi are not running. Without PowerShell 7 this can take up to a minute on Windows ARM; installing PowerShell 7 makes it fast.");
|
|
8718
|
+
return inspect("CIM", program === "pwsh" ? pwsh : win322.resolve(system32, "WindowsPowerShell", "v1.0", "powershell.exe"), args, slow ? WINDOWS_ARM_POWERSHELL_TIMEOUT_MS : WINDOWS_CIM_TIMEOUT_MS, program);
|
|
8719
|
+
};
|
|
8692
8720
|
try {
|
|
8693
8721
|
if (windows && options.hostImagesOnly) {
|
|
8694
|
-
const details = await
|
|
8722
|
+
const details = await inspectCim([
|
|
8723
|
+
"-NoProfile",
|
|
8724
|
+
"-NonInteractive",
|
|
8725
|
+
"-Command",
|
|
8726
|
+
WINDOWS_FENCE_QUERY
|
|
8727
|
+
]);
|
|
8695
8728
|
if (details.exitCode !== 0)
|
|
8696
8729
|
throw new ProcessInspectionError(inspection);
|
|
8697
8730
|
const value = JSON.parse(details.stdout);
|
|
@@ -8713,7 +8746,7 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8713
8746
|
}
|
|
8714
8747
|
return processes2;
|
|
8715
8748
|
}
|
|
8716
|
-
const result = await inspect(windows ? "tasklist" : "ps", windows ? "tasklist.exe" : "ps", windows ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
8749
|
+
const result = await inspect(windows ? "tasklist" : "ps", windows ? win322.resolve(system32, "tasklist.exe") : "ps", windows ? ["/fo", "csv", "/nh"] : ["-eo", "pid,command"]);
|
|
8717
8750
|
if (result.exitCode !== 0)
|
|
8718
8751
|
throw new ProcessInspectionError(inspection);
|
|
8719
8752
|
const processes = [];
|
|
@@ -8747,12 +8780,12 @@ async function listSetupProcesses(runner = defaultCommandRunner, options = {}) {
|
|
|
8747
8780
|
throw new ProcessInspectionError(inspection);
|
|
8748
8781
|
const runtimes = processes.filter((entry) => entry.pid !== selfPid && /^(?:node|bun)\.exe$/i.test(entry.command));
|
|
8749
8782
|
if (windows && runtimes.length && options.inspectRuntimes !== false) {
|
|
8750
|
-
const details = await
|
|
8783
|
+
const details = await inspectCim([
|
|
8751
8784
|
"-NoProfile",
|
|
8752
8785
|
"-NonInteractive",
|
|
8753
8786
|
"-Command",
|
|
8754
8787
|
`$ErrorActionPreference = 'Stop'; Get-CimInstance Win32_Process -Filter "Name = 'node.exe' OR Name = 'bun.exe'" | Select-Object ProcessId,CommandLine | ConvertTo-Json -Compress`
|
|
8755
|
-
]
|
|
8788
|
+
]);
|
|
8756
8789
|
if (details.exitCode !== 0)
|
|
8757
8790
|
throw new ProcessInspectionError(inspection);
|
|
8758
8791
|
const value = JSON.parse(details.stdout || "null");
|
|
@@ -8808,6 +8841,35 @@ async function assertHostsStopped(fence, env) {
|
|
|
8808
8841
|
throw new ProcessFenceViolationError(active);
|
|
8809
8842
|
}
|
|
8810
8843
|
|
|
8844
|
+
// ../../node_modules/@cortexkit/common-auth/dist/setup/process-guard.js
|
|
8845
|
+
class SetupProcessGuard {
|
|
8846
|
+
inspect;
|
|
8847
|
+
now;
|
|
8848
|
+
#checkedAt;
|
|
8849
|
+
constructor(inspect, now = () => performance.now()) {
|
|
8850
|
+
this.inspect = inspect;
|
|
8851
|
+
this.now = now;
|
|
8852
|
+
}
|
|
8853
|
+
async check(options = {}) {
|
|
8854
|
+
if (options.reuse && this.#checkedAt !== undefined) {
|
|
8855
|
+
const age = this.now() - this.#checkedAt;
|
|
8856
|
+
if (age >= 0 && age < 5000)
|
|
8857
|
+
return;
|
|
8858
|
+
}
|
|
8859
|
+
this.#checkedAt = undefined;
|
|
8860
|
+
await this.inspect();
|
|
8861
|
+
this.#checkedAt = this.now();
|
|
8862
|
+
}
|
|
8863
|
+
async step(run) {
|
|
8864
|
+
this.#checkedAt = undefined;
|
|
8865
|
+
try {
|
|
8866
|
+
return await run();
|
|
8867
|
+
} finally {
|
|
8868
|
+
this.#checkedAt = undefined;
|
|
8869
|
+
}
|
|
8870
|
+
}
|
|
8871
|
+
}
|
|
8872
|
+
|
|
8811
8873
|
// ../../node_modules/@cortexkit/common-auth/dist/setup/enroll.js
|
|
8812
8874
|
var ENROLLMENT_INCOMPLETE_MESSAGE = "Claustrum enrollment did not complete. Inspect and approve with ck, then rerun setup.";
|
|
8813
8875
|
var UNSUPPORTED_VAULT_MESSAGE = 'This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read "Upgrading from v0.1.3" in its release notes first), or run setup without --claustrum to use local accounts.';
|
|
@@ -8837,7 +8899,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
8837
8899
|
throw new Error(VAULT_HOST_CONNECT_REFUSAL);
|
|
8838
8900
|
const { name, displayName, requestedGrants, grantFallback, paths: input } = plugin.vault.hosts[host];
|
|
8839
8901
|
const paths = hostEnrollmentPaths(input);
|
|
8840
|
-
|
|
8902
|
+
const guard = typeof fence === "function" ? new SetupProcessGuard(fence, io.now) : fence;
|
|
8903
|
+
await guard.check({ reuse: true });
|
|
8841
8904
|
const client = await (io.connect ?? connectClaustrumEnrollmentClient)({
|
|
8842
8905
|
connectionFile: plugin.vault.connectionFile,
|
|
8843
8906
|
handshakeTimeoutMs: 2000
|
|
@@ -8854,11 +8917,10 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
8854
8917
|
paths,
|
|
8855
8918
|
client,
|
|
8856
8919
|
writeTokenFile: async (path, file) => {
|
|
8857
|
-
await
|
|
8858
|
-
await writeEnrollmentTokenFile2(path, file);
|
|
8920
|
+
await guard.check();
|
|
8921
|
+
await guard.step(() => writeEnrollmentTokenFile2(path, file));
|
|
8859
8922
|
}
|
|
8860
8923
|
});
|
|
8861
|
-
await fence();
|
|
8862
8924
|
const initial = await manager.status();
|
|
8863
8925
|
if (initial.state === "approved") {
|
|
8864
8926
|
printLine(terminal, `Already connected as ${initial.approvedName ?? initial.proposedName}.`);
|
|
@@ -8875,7 +8937,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
8875
8937
|
let reportedCode;
|
|
8876
8938
|
let failedProposals = 0;
|
|
8877
8939
|
for (;; ) {
|
|
8878
|
-
|
|
8940
|
+
await guard.check({ reuse: true });
|
|
8941
|
+
const status = await guard.step(() => manager.reconcile());
|
|
8879
8942
|
if (status.state === "approved") {
|
|
8880
8943
|
printLine(terminal, `Connected ${host} to Claustrum.`);
|
|
8881
8944
|
const access = await confirmEnrollmentAccess(client, status, paths.tokenPath, requestedGrants);
|
|
@@ -8923,8 +8986,8 @@ async function connectSetupHost(plugin, host, io, terminal, fence) {
|
|
|
8923
8986
|
const remaining = deadline - now();
|
|
8924
8987
|
if (remaining <= 0)
|
|
8925
8988
|
break;
|
|
8926
|
-
await wait(Math.min(pause, remaining));
|
|
8927
|
-
await
|
|
8989
|
+
await guard.step(() => wait(Math.min(pause, remaining)));
|
|
8990
|
+
await guard.check();
|
|
8928
8991
|
}
|
|
8929
8992
|
if (printedRequest)
|
|
8930
8993
|
throw new HostNotEnrolledError(`Claustrum approval is still pending. In another terminal, run: ${approveCommand(printedRequest, name)} and then rerun setup.`, {
|
|
@@ -9084,6 +9147,8 @@ async function selectSetupHosts(terminal, found) {
|
|
|
9084
9147
|
}
|
|
9085
9148
|
|
|
9086
9149
|
// ../../node_modules/@cortexkit/common-auth/dist/setup/register.js
|
|
9150
|
+
import { rename as rename6 } from "node:fs/promises";
|
|
9151
|
+
import { setTimeout as delay3 } from "node:timers/promises";
|
|
9087
9152
|
import { domainToUnicode } from "node:url";
|
|
9088
9153
|
import { applyEdits, createScanner, findNodeAtLocation, modify, parse as parse2, parseTree } from "jsonc-parser";
|
|
9089
9154
|
|
|
@@ -9295,12 +9360,14 @@ function planOpenCodeRegistration(plugin, generation, io = {}) {
|
|
|
9295
9360
|
});
|
|
9296
9361
|
}
|
|
9297
9362
|
async function registerOpenCode(writes, beforeWrite) {
|
|
9363
|
+
const guard = typeof beforeWrite === "function" ? new SetupProcessGuard(beforeWrite) : beforeWrite;
|
|
9298
9364
|
for (const write of writes) {
|
|
9299
9365
|
if (!write.changed)
|
|
9300
9366
|
continue;
|
|
9301
|
-
await beforeWrite?.();
|
|
9302
9367
|
await writeHostConfigAtomic(write.path, write.content, {
|
|
9303
|
-
beforeRename:
|
|
9368
|
+
beforeRename: guard ? () => guard.check({ reuse: true }) : undefined,
|
|
9369
|
+
rename: guard ? (from, to) => guard.step(() => rename6(from, to)) : undefined,
|
|
9370
|
+
wait: guard ? (ms) => guard.step(() => delay3(ms)) : undefined
|
|
9304
9371
|
});
|
|
9305
9372
|
}
|
|
9306
9373
|
}
|
|
@@ -9401,7 +9468,11 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
9401
9468
|
return { hosts, dryRun: options.dryRun, mode: "local", detection };
|
|
9402
9469
|
}
|
|
9403
9470
|
const { env, platform } = setupPaths(io);
|
|
9404
|
-
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
9471
|
+
const fence = io.fence ?? createProcessFence(io.runner ?? defaultCommandRunner, {
|
|
9472
|
+
platform,
|
|
9473
|
+
isFile: io.fs?.isFile.bind(io.fs),
|
|
9474
|
+
onProgress: (line) => printLine(terminal, line)
|
|
9475
|
+
});
|
|
9405
9476
|
const stopped = async () => {
|
|
9406
9477
|
try {
|
|
9407
9478
|
await assertHostsStopped(fence, env);
|
|
@@ -9411,6 +9482,7 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
9411
9482
|
throw error;
|
|
9412
9483
|
}
|
|
9413
9484
|
};
|
|
9485
|
+
const guard = new SetupProcessGuard(stopped, io.now);
|
|
9414
9486
|
printLine(terminal, "Checking that OpenCode and Pi are not running…");
|
|
9415
9487
|
if (options.dryRun) {
|
|
9416
9488
|
try {
|
|
@@ -9426,16 +9498,17 @@ async function runSetup(plugin, argv = [], io = {}) {
|
|
|
9426
9498
|
if (error instanceof ProcessInspectionError)
|
|
9427
9499
|
printLine(terminal, error.refusalText);
|
|
9428
9500
|
}
|
|
9429
|
-
} else
|
|
9430
|
-
await
|
|
9501
|
+
} else {
|
|
9502
|
+
await guard.check();
|
|
9503
|
+
}
|
|
9431
9504
|
if ((options.claustrum || options.enrollOnly) && !detection.claustrum.available)
|
|
9432
9505
|
throw new Error("Claustrum is not available. Start ck, or omit vault-only flags and use --no-claustrum for local sign-in.");
|
|
9433
9506
|
let useVault = options.claustrum || options.enrollOnly;
|
|
9434
9507
|
if (!useVault && !options.login && !options.noClaustrum && !assumeYes && detection.claustrum.available && isInteractive(terminal)) {
|
|
9435
|
-
const choice = await select(terminal, [
|
|
9508
|
+
const choice = await guard.step(() => select(terminal, [
|
|
9436
9509
|
{ label: "No", value: false },
|
|
9437
9510
|
{ label: "Yes", value: true }
|
|
9438
|
-
], { message: "Connect these hosts to the Claustrum vault?" });
|
|
9511
|
+
], { message: "Connect these hosts to the Claustrum vault?" }));
|
|
9439
9512
|
if (choice === null) {
|
|
9440
9513
|
printLine(terminal, "Setup cancelled. Nothing was changed.");
|
|
9441
9514
|
return { hosts: [], dryRun: options.dryRun, mode: "local", detection };
|
|
@@ -9486,13 +9559,14 @@ ${write.content}`);
|
|
|
9486
9559
|
const enrollmentAccess = new Map;
|
|
9487
9560
|
try {
|
|
9488
9561
|
for (const host of hosts) {
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9562
|
+
if (plugin.beforeSignIn) {
|
|
9563
|
+
await guard.check({ reuse: true });
|
|
9564
|
+
await guard.step(() => plugin.beforeSignIn?.(host, context));
|
|
9565
|
+
}
|
|
9492
9566
|
if (useVault) {
|
|
9493
9567
|
enrollment.set(host, "unknown");
|
|
9494
9568
|
try {
|
|
9495
|
-
const access = await connectSetupHost(plugin, host, io, terminal,
|
|
9569
|
+
const access = await connectSetupHost(plugin, host, io, terminal, guard);
|
|
9496
9570
|
if (access)
|
|
9497
9571
|
enrollmentAccess.set(host, access);
|
|
9498
9572
|
} catch (error) {
|
|
@@ -9501,19 +9575,26 @@ ${write.content}`);
|
|
|
9501
9575
|
throw error;
|
|
9502
9576
|
}
|
|
9503
9577
|
enrollment.set(host, "enrolled");
|
|
9504
|
-
} else
|
|
9505
|
-
await
|
|
9506
|
-
|
|
9578
|
+
} else {
|
|
9579
|
+
await guard.check({ reuse: true });
|
|
9580
|
+
await guard.step(() => plugin.signInLocal(host, context));
|
|
9581
|
+
}
|
|
9507
9582
|
if (options.enrollOnly)
|
|
9508
9583
|
continue;
|
|
9509
|
-
|
|
9510
|
-
|
|
9584
|
+
if (plugin.beforeRegister) {
|
|
9585
|
+
await guard.check({ reuse: true });
|
|
9586
|
+
await guard.step(() => plugin.beforeRegister?.(host, mode, context));
|
|
9587
|
+
}
|
|
9511
9588
|
if (host === "opencode")
|
|
9512
|
-
await registerOpenCode(writes,
|
|
9513
|
-
else
|
|
9514
|
-
await
|
|
9515
|
-
|
|
9516
|
-
|
|
9589
|
+
await registerOpenCode(writes, guard);
|
|
9590
|
+
else {
|
|
9591
|
+
await guard.check({ reuse: true });
|
|
9592
|
+
await guard.step(() => registerPi(plugin, detection.pi.executable, io));
|
|
9593
|
+
}
|
|
9594
|
+
if (plugin.migrate) {
|
|
9595
|
+
await guard.check({ reuse: true });
|
|
9596
|
+
await guard.step(() => plugin.migrate?.(host, context));
|
|
9597
|
+
}
|
|
9517
9598
|
}
|
|
9518
9599
|
} catch (error) {
|
|
9519
9600
|
if (enrollment.size === 0)
|
|
@@ -9537,12 +9618,12 @@ ${write.content}`);
|
|
|
9537
9618
|
}
|
|
9538
9619
|
// src/accounts.ts
|
|
9539
9620
|
import { createHash as createHash4, randomUUID as randomUUID8 } from "node:crypto";
|
|
9540
|
-
import { mkdir as mkdir6, readFile as readFile7, rename as
|
|
9621
|
+
import { mkdir as mkdir6, readFile as readFile7, rename as rename8, rm as rm4, stat as stat10, writeFile } from "node:fs/promises";
|
|
9541
9622
|
import { homedir as homedir3 } from "node:os";
|
|
9542
9623
|
import { join as join13 } from "node:path";
|
|
9543
9624
|
|
|
9544
9625
|
// src/claustrum.ts
|
|
9545
|
-
import { readdirSync, statSync as
|
|
9626
|
+
import { readdirSync, statSync as statSync4 } from "node:fs";
|
|
9546
9627
|
import * as fs from "node:fs/promises";
|
|
9547
9628
|
import { tmpdir as tmpdir3, userInfo } from "node:os";
|
|
9548
9629
|
import { join as join9 } from "node:path";
|
|
@@ -9554,7 +9635,7 @@ var CLAUSTRUM_TEMP_PREFIX = "subc-";
|
|
|
9554
9635
|
var CLAUSTRUM_TEMP_SUFFIX = ".connection.json";
|
|
9555
9636
|
function safeIsFile(path) {
|
|
9556
9637
|
try {
|
|
9557
|
-
return
|
|
9638
|
+
return statSync4(path).isFile();
|
|
9558
9639
|
} catch {
|
|
9559
9640
|
return false;
|
|
9560
9641
|
}
|
|
@@ -10323,8 +10404,8 @@ async function refreshClaudeOAuthToken(input) {
|
|
|
10323
10404
|
for (let attempt = 0;attempt <= maxRetries; attempt++) {
|
|
10324
10405
|
try {
|
|
10325
10406
|
if (attempt > 0) {
|
|
10326
|
-
const
|
|
10327
|
-
await new Promise((resolve12) => setTimeoutImpl(resolve12,
|
|
10407
|
+
const delay4 = baseDelayMs * 2 ** (attempt - 1);
|
|
10408
|
+
await new Promise((resolve12) => setTimeoutImpl(resolve12, delay4));
|
|
10328
10409
|
}
|
|
10329
10410
|
const signal = auxiliaryRequestSignal();
|
|
10330
10411
|
const response = await raceWithSignal(signal, () => fetchImpl(TOKEN_URL, {
|
|
@@ -10497,7 +10578,7 @@ function hostRetryResponse(response, now = Date.now()) {
|
|
|
10497
10578
|
// src/path-options.ts
|
|
10498
10579
|
import { realpath as realpath3 } from "node:fs/promises";
|
|
10499
10580
|
import { homedir as homedir2 } from "node:os";
|
|
10500
|
-
import { posix as posix3, win32 as
|
|
10581
|
+
import { posix as posix3, win32 as win324 } from "node:path";
|
|
10501
10582
|
|
|
10502
10583
|
// ../../node_modules/@cortexkit/common-auth/dist/settings/descriptors.js
|
|
10503
10584
|
function boolean() {
|
|
@@ -10611,7 +10692,7 @@ function isOverrideKeyAllowed(overrides, key) {
|
|
|
10611
10692
|
import { join as join11, resolve as resolve13 } from "node:path";
|
|
10612
10693
|
|
|
10613
10694
|
// ../../node_modules/@cortexkit/common-auth/dist/tui-prefs/watcher.js
|
|
10614
|
-
import { lstatSync, readFileSync as readFileSync2, readlinkSync, realpathSync as realpathSync2, statSync as
|
|
10695
|
+
import { lstatSync, readFileSync as readFileSync2, readlinkSync, realpathSync as realpathSync2, statSync as statSync5, watch } from "node:fs";
|
|
10615
10696
|
import { readFile as readFile5, stat as stat8 } from "node:fs/promises";
|
|
10616
10697
|
import { basename as basename5, dirname as dirname9, join as join10, resolve as resolve12 } from "node:path";
|
|
10617
10698
|
import { clearTimeout as clearTimeout2, setTimeout as setTimeout2 } from "node:timers";
|
|
@@ -10655,7 +10736,7 @@ function watchFile(file, onChange, options, settings) {
|
|
|
10655
10736
|
let lastSeen = null;
|
|
10656
10737
|
if (settings || !windowsPrivateFiles)
|
|
10657
10738
|
try {
|
|
10658
|
-
const metadata = identity2((options.fs?.statSync ??
|
|
10739
|
+
const metadata = identity2((options.fs?.statSync ?? statSync5)(path), settings);
|
|
10659
10740
|
lastSeen = (options.fs?.readFileSync ?? ((file2) => readFileSync2(file2, "utf8")))(path);
|
|
10660
10741
|
lastMetadata = metadata;
|
|
10661
10742
|
} catch {}
|
|
@@ -12096,7 +12177,7 @@ async function moveSettingsOnce(options) {
|
|
|
12096
12177
|
}
|
|
12097
12178
|
}
|
|
12098
12179
|
// ../../node_modules/@cortexkit/common-auth/dist/settings/paths.js
|
|
12099
|
-
import { posix as posix2, win32 as
|
|
12180
|
+
import { posix as posix2, win32 as win323 } from "node:path";
|
|
12100
12181
|
function isAbsoluteForPlatform(path, platform) {
|
|
12101
12182
|
if (platform !== "win32")
|
|
12102
12183
|
return path.startsWith("/");
|
|
@@ -12107,7 +12188,7 @@ function isAbsoluteForPlatform(path, platform) {
|
|
|
12107
12188
|
return /^[\\/]{2}[^\\/]+[\\/][^\\/]+/.test(path);
|
|
12108
12189
|
}
|
|
12109
12190
|
function cortexkitConfigDir({ env, platform, homedir: homedir2 }) {
|
|
12110
|
-
const paths = platform === "win32" ?
|
|
12191
|
+
const paths = platform === "win32" ? win323 : posix2;
|
|
12111
12192
|
const absolute = (value) => value !== undefined && isAbsoluteForPlatform(value, platform);
|
|
12112
12193
|
let base;
|
|
12113
12194
|
if (absolute(env.XDG_CONFIG_HOME)) {
|
|
@@ -12130,7 +12211,7 @@ function settingsFilePath({ plugin, override, ...options }) {
|
|
|
12130
12211
|
if (override && isAbsoluteForPlatform(override, options.platform)) {
|
|
12131
12212
|
return override;
|
|
12132
12213
|
}
|
|
12133
|
-
const paths = options.platform === "win32" ?
|
|
12214
|
+
const paths = options.platform === "win32" ? win323 : posix2;
|
|
12134
12215
|
return paths.join(cortexkitConfigDir(options), `${plugin}.jsonc`);
|
|
12135
12216
|
}
|
|
12136
12217
|
// src/path-options.ts
|
|
@@ -12144,7 +12225,7 @@ function resolvePathOptions(options = {}) {
|
|
|
12144
12225
|
home,
|
|
12145
12226
|
platform,
|
|
12146
12227
|
realpath: options.realpath ?? realpath3,
|
|
12147
|
-
paths: platform === "win32" ?
|
|
12228
|
+
paths: platform === "win32" ? win324 : posix3
|
|
12148
12229
|
};
|
|
12149
12230
|
}
|
|
12150
12231
|
|
|
@@ -12591,7 +12672,7 @@ async function acquireRefreshFileLock2(options) {
|
|
|
12591
12672
|
await options.onStep?.("stale-marker-stat");
|
|
12592
12673
|
const claimedPath = `${evictPath}.${randomUUID8()}`;
|
|
12593
12674
|
try {
|
|
12594
|
-
await
|
|
12675
|
+
await rename8(evictPath, claimedPath);
|
|
12595
12676
|
} catch (renameError) {
|
|
12596
12677
|
if (renameError.code === "ENOENT") {
|
|
12597
12678
|
await backoff();
|
|
@@ -12720,15 +12801,15 @@ function buildRefreshOperationError(input) {
|
|
|
12720
12801
|
const previousRetryCount = input.previous?.accountIdentity === input.accountIdentity && input.previous?.refreshTokenFingerprint === input.refreshTokenFingerprint ? input.previous?.retryCount ?? 0 : 0;
|
|
12721
12802
|
const retryCount = previousRetryCount + 1;
|
|
12722
12803
|
const retryAfterFromError = input.error.retryAfter;
|
|
12723
|
-
let
|
|
12804
|
+
let delay4;
|
|
12724
12805
|
if (typeof retryAfterFromError === "number" && retryAfterFromError > 0) {
|
|
12725
|
-
|
|
12806
|
+
delay4 = retryAfterFromError * 1000;
|
|
12726
12807
|
} else if (isTransientNetworkError(input.error)) {
|
|
12727
|
-
|
|
12808
|
+
delay4 = MIN_REFRESH_RETRY_DELAY_MS;
|
|
12728
12809
|
} else if (isTransientRefreshError(input.error)) {
|
|
12729
|
-
|
|
12810
|
+
delay4 = Math.min(MAX_REFRESH_RETRY_DELAY_MS, MIN_REFRESH_RETRY_DELAY_MS * 2 ** Math.min(retryCount - 1, 6));
|
|
12730
12811
|
} else {
|
|
12731
|
-
|
|
12812
|
+
delay4 = NON_TRANSIENT_REFRESH_RETRY_DELAY_MS;
|
|
12732
12813
|
}
|
|
12733
12814
|
const statusFromError = input.error.status;
|
|
12734
12815
|
const status = typeof statusFromError === "number" && Number.isFinite(statusFromError) ? statusFromError : undefined;
|
|
@@ -12738,7 +12819,7 @@ function buildRefreshOperationError(input) {
|
|
|
12738
12819
|
return {
|
|
12739
12820
|
message,
|
|
12740
12821
|
checkedAt: input.now,
|
|
12741
|
-
nextRetryAt: input.now +
|
|
12822
|
+
nextRetryAt: input.now + delay4,
|
|
12742
12823
|
retryCount,
|
|
12743
12824
|
accountIdentity: input.accountIdentity,
|
|
12744
12825
|
refreshTokenFingerprint: input.refreshTokenFingerprint,
|
|
@@ -12800,11 +12881,11 @@ function isQuotaPolicyAuthError(error) {
|
|
|
12800
12881
|
function buildQuotaOperationError(input) {
|
|
12801
12882
|
const previousRetryCount = input.previous?.accountIdentity === input.accountIdentity ? input.previous?.retryCount ?? 0 : 0;
|
|
12802
12883
|
const retryCount = previousRetryCount + 1;
|
|
12803
|
-
const
|
|
12884
|
+
const delay4 = isTransientQuotaError(input.error) ? Math.min(MAX_QUOTA_RETRY_DELAY_MS, MIN_QUOTA_RETRY_DELAY_MS * 2 ** Math.min(retryCount - 1, 6)) : NON_TRANSIENT_QUOTA_RETRY_DELAY_MS;
|
|
12804
12885
|
return {
|
|
12805
12886
|
message: formatErrorMessage(input.error),
|
|
12806
12887
|
checkedAt: input.now,
|
|
12807
|
-
nextRetryAt: input.now +
|
|
12888
|
+
nextRetryAt: input.now + delay4,
|
|
12808
12889
|
retryCount,
|
|
12809
12890
|
...input.accountIdentity !== undefined && {
|
|
12810
12891
|
accountIdentity: input.accountIdentity
|
|
@@ -14752,16 +14833,16 @@ class CacheKeepManager {
|
|
|
14752
14833
|
return;
|
|
14753
14834
|
target.failures += 1;
|
|
14754
14835
|
const now = this.now();
|
|
14755
|
-
let
|
|
14836
|
+
let delay4 = typeof this.backoff === "function" ? this.backoff({ sessionKey, failures: target.failures }) : this.backoff ?? DEFAULT_BACKOFF_MS;
|
|
14756
14837
|
const deadline = this.lastRetryStart(target);
|
|
14757
14838
|
const fastRetry = this.backoff === undefined && transient && now < deadline;
|
|
14758
14839
|
if (fastRetry) {
|
|
14759
|
-
|
|
14840
|
+
delay4 = Math.min(TRANSIENT_RETRY_STEP_MS * target.failures, TRANSIENT_RETRY_MAX_MS, deadline - now);
|
|
14760
14841
|
}
|
|
14761
|
-
target.backoffUntil = now + (Number.isFinite(
|
|
14842
|
+
target.backoffUntil = now + (Number.isFinite(delay4) && delay4 > 0 ? delay4 : 0);
|
|
14762
14843
|
this.clearRetry(target);
|
|
14763
14844
|
if (fastRetry)
|
|
14764
|
-
this.scheduleRetry(sessionKey, target,
|
|
14845
|
+
this.scheduleRetry(sessionKey, target, delay4);
|
|
14765
14846
|
else if (target.plan) {
|
|
14766
14847
|
this.schedulePlan(sessionKey, target, target.backoffUntil);
|
|
14767
14848
|
}
|
|
@@ -14786,7 +14867,7 @@ class CacheKeepManager {
|
|
|
14786
14867
|
this.clearIntervalImpl(target.retryTimer);
|
|
14787
14868
|
target.retryTimer = undefined;
|
|
14788
14869
|
}
|
|
14789
|
-
scheduleRetry(sessionKey, target,
|
|
14870
|
+
scheduleRetry(sessionKey, target, delay4) {
|
|
14790
14871
|
target.retryTimer = this.setIntervalImpl(() => {
|
|
14791
14872
|
this.clearRetry(target);
|
|
14792
14873
|
return (async () => {
|
|
@@ -14796,7 +14877,7 @@ class CacheKeepManager {
|
|
|
14796
14877
|
})().catch((error) => {
|
|
14797
14878
|
this.log?.warn("cachekeep tick failed", classifyFailure(error, "send"));
|
|
14798
14879
|
});
|
|
14799
|
-
},
|
|
14880
|
+
}, delay4);
|
|
14800
14881
|
if (typeof target.retryTimer === "object" && "unref" in target.retryTimer) {
|
|
14801
14882
|
target.retryTimer.unref();
|
|
14802
14883
|
}
|
|
@@ -14984,7 +15065,7 @@ import {
|
|
|
14984
15065
|
mkdir as mkdir7,
|
|
14985
15066
|
open as open8,
|
|
14986
15067
|
realpath as realpath4,
|
|
14987
|
-
rename as
|
|
15068
|
+
rename as rename9,
|
|
14988
15069
|
stat as stat11,
|
|
14989
15070
|
unlink as unlink6
|
|
14990
15071
|
} from "node:fs/promises";
|
|
@@ -15577,7 +15658,7 @@ async function writeStateAtomic2(path2, state, beforeRename) {
|
|
|
15577
15658
|
descriptor = undefined;
|
|
15578
15659
|
await chmod2(temporary, 384);
|
|
15579
15660
|
await beforeRename();
|
|
15580
|
-
await
|
|
15661
|
+
await rename9(temporary, path2);
|
|
15581
15662
|
} finally {
|
|
15582
15663
|
await descriptor?.close().catch(() => {});
|
|
15583
15664
|
await unlink6(temporary).catch(() => {});
|
|
@@ -15588,7 +15669,7 @@ async function writeTokenAtomic(path2, value, writeTokenFile, beforeRename) {
|
|
|
15588
15669
|
try {
|
|
15589
15670
|
await writeTokenFile(staged, value);
|
|
15590
15671
|
await beforeRename();
|
|
15591
|
-
await
|
|
15672
|
+
await rename9(staged, path2);
|
|
15592
15673
|
} finally {
|
|
15593
15674
|
await unlink6(staged).catch(() => {});
|
|
15594
15675
|
}
|
|
@@ -16049,14 +16130,14 @@ function createNativeCustody(options) {
|
|
|
16049
16130
|
let probe;
|
|
16050
16131
|
const setTimer = options.setTimeout ?? setTimeout;
|
|
16051
16132
|
const clearTimer = options.clearTimeout ?? clearTimeout;
|
|
16052
|
-
const guardedTimer = (callback,
|
|
16133
|
+
const guardedTimer = (callback, delay4, ...args) => setTimer(() => {
|
|
16053
16134
|
try {
|
|
16054
16135
|
check();
|
|
16055
16136
|
} catch {
|
|
16056
16137
|
return;
|
|
16057
16138
|
}
|
|
16058
16139
|
callback(...args);
|
|
16059
|
-
},
|
|
16140
|
+
}, delay4);
|
|
16060
16141
|
function closeProbe(held) {
|
|
16061
16142
|
if (held.closed || held.promoted)
|
|
16062
16143
|
return;
|
|
@@ -17154,7 +17235,7 @@ import {
|
|
|
17154
17235
|
mkdir as mkdir8,
|
|
17155
17236
|
readdir as readdir4,
|
|
17156
17237
|
readFile as readFile9,
|
|
17157
|
-
rename as
|
|
17238
|
+
rename as rename10,
|
|
17158
17239
|
unlink as unlink7,
|
|
17159
17240
|
writeFile as writeFile2
|
|
17160
17241
|
} from "node:fs/promises";
|
|
@@ -17164,7 +17245,7 @@ import { join as join17, resolve as resolve17 } from "node:path";
|
|
|
17164
17245
|
// src/gateway.ts
|
|
17165
17246
|
import { execFile } from "node:child_process";
|
|
17166
17247
|
import { readFile as readFile8, realpath as realpath5 } from "node:fs/promises";
|
|
17167
|
-
import { posix as posix4, resolve as resolve16, win32 as
|
|
17248
|
+
import { posix as posix4, resolve as resolve16, win32 as win325 } from "node:path";
|
|
17168
17249
|
|
|
17169
17250
|
// src/custom-headers.ts
|
|
17170
17251
|
var ANTHROPIC_CUSTOM_HEADERS_ENV = "ANTHROPIC_CUSTOM_HEADERS";
|
|
@@ -17495,7 +17576,7 @@ async function posixAccountHome(dependencies) {
|
|
|
17495
17576
|
return passwdHome(await dependencies.readFile("/etc/passwd"), uid);
|
|
17496
17577
|
}
|
|
17497
17578
|
async function windowsAppData(dependencies) {
|
|
17498
|
-
const output = await dependencies.run(
|
|
17579
|
+
const output = await dependencies.run(win325.join(WINDOWS_ROOT, "System32", "reg.exe"), ["query", WINDOWS_SHELL_FOLDERS, "/v", "AppData"], { SystemRoot: WINDOWS_ROOT });
|
|
17499
17580
|
const value = /^\s*AppData\s+REG_SZ\s+(.+?)\s*$/im.exec(output)?.[1];
|
|
17500
17581
|
return value && !value.includes("%") ? value : undefined;
|
|
17501
17582
|
}
|
|
@@ -17503,7 +17584,7 @@ async function lookupGatewaySettingsFile(dependencies) {
|
|
|
17503
17584
|
try {
|
|
17504
17585
|
if (dependencies.platform === "win32") {
|
|
17505
17586
|
const appData = await windowsAppData(dependencies);
|
|
17506
|
-
return appData &&
|
|
17587
|
+
return appData && win325.isAbsolute(appData) ? win325.join(appData, "cortexkit", "anthropic-auth.jsonc") : undefined;
|
|
17507
17588
|
}
|
|
17508
17589
|
const home = await posixAccountHome(dependencies);
|
|
17509
17590
|
return home && posix4.isAbsolute(home) ? posix4.join(home, ".config", "cortexkit", "anthropic-auth.jsonc") : undefined;
|
|
@@ -17518,11 +17599,11 @@ function registryPath(output, name) {
|
|
|
17518
17599
|
return value && !value.includes("%") ? value : undefined;
|
|
17519
17600
|
}
|
|
17520
17601
|
async function windowsAccountSid(dependencies) {
|
|
17521
|
-
const output = await dependencies.run(
|
|
17602
|
+
const output = await dependencies.run(win325.join(WINDOWS_ROOT, "System32", "whoami.exe"), ["/user", "/fo", "csv", "/nh"], { SystemRoot: WINDOWS_ROOT });
|
|
17522
17603
|
return /"(S-1-\d+(?:-\d+)+)"\s*$/m.exec(output)?.[1];
|
|
17523
17604
|
}
|
|
17524
17605
|
async function windowsProfile(dependencies) {
|
|
17525
|
-
const reg =
|
|
17606
|
+
const reg = win325.join(WINDOWS_ROOT, "System32", "reg.exe");
|
|
17526
17607
|
const env = { SystemRoot: WINDOWS_ROOT };
|
|
17527
17608
|
const fromProfileList = await windowsAccountSid(dependencies).then(async (sid) => sid ? registryPath(await dependencies.run(reg, [
|
|
17528
17609
|
"query",
|
|
@@ -17540,7 +17621,7 @@ async function lookupAccountHome(dependencies) {
|
|
|
17540
17621
|
try {
|
|
17541
17622
|
if (dependencies.platform === "win32") {
|
|
17542
17623
|
const profile = await windowsProfile(dependencies);
|
|
17543
|
-
return profile &&
|
|
17624
|
+
return profile && win325.isAbsolute(profile) ? profile : undefined;
|
|
17544
17625
|
}
|
|
17545
17626
|
const home = await posixAccountHome(dependencies);
|
|
17546
17627
|
return home && posix4.isAbsolute(home) ? home : undefined;
|
|
@@ -17687,7 +17768,7 @@ async function writeDumpFile(path2, contents) {
|
|
|
17687
17768
|
try {
|
|
17688
17769
|
await writeFile2(partialPath, contents, { encoding: "utf8", flag: "wx" });
|
|
17689
17770
|
created = true;
|
|
17690
|
-
await
|
|
17771
|
+
await rename10(partialPath, path2);
|
|
17691
17772
|
return true;
|
|
17692
17773
|
} catch (error) {
|
|
17693
17774
|
if (error.code === "EEXIST")
|
|
@@ -21284,8 +21365,8 @@ class CacheKeepManager2 {
|
|
|
21284
21365
|
}
|
|
21285
21366
|
target.consecutiveFailures += 1;
|
|
21286
21367
|
const backoff = cacheKeepRetryDelayMs(target.id, target.consecutiveFailures);
|
|
21287
|
-
const
|
|
21288
|
-
target.nextPrewarmAt = Math.min(now +
|
|
21368
|
+
const delay4 = transient ? Math.min(backoff, CACHE_KEEP_TRANSIENT_RETRY_STEP_MS * target.consecutiveFailures, CACHE_KEEP_TRANSIENT_RETRY_MAX_MS) : backoff;
|
|
21369
|
+
target.nextPrewarmAt = Math.min(now + delay4, deadline);
|
|
21289
21370
|
}
|
|
21290
21371
|
async sendPrewarm(target, onAccepted) {
|
|
21291
21372
|
const generation = this.schedulerGeneration;
|
|
@@ -21705,7 +21786,7 @@ import {
|
|
|
21705
21786
|
mkdir as mkdir12,
|
|
21706
21787
|
readdir as readdir5,
|
|
21707
21788
|
readFile as readFile15,
|
|
21708
|
-
rename as
|
|
21789
|
+
rename as rename14,
|
|
21709
21790
|
rm as rm7,
|
|
21710
21791
|
writeFile as writeFile4
|
|
21711
21792
|
} from "node:fs/promises";
|
|
@@ -21771,7 +21852,7 @@ import { basename as basename11, dirname as dirname17, join as join21 } from "no
|
|
|
21771
21852
|
|
|
21772
21853
|
// src/sticky-routing.ts
|
|
21773
21854
|
import { createHash as createHash17, randomUUID as randomUUID15 } from "node:crypto";
|
|
21774
|
-
import { mkdir as mkdir10, readFile as readFile11, rename as
|
|
21855
|
+
import { mkdir as mkdir10, readFile as readFile11, rename as rename13, rm as rm6, stat as stat12, writeFile as writeFile3 } from "node:fs/promises";
|
|
21775
21856
|
import { basename as basename10, dirname as dirname16, join as join20 } from "node:path";
|
|
21776
21857
|
|
|
21777
21858
|
// src/native-vault-seed.ts
|
|
@@ -24556,11 +24637,11 @@ class PoolQuotaWriter {
|
|
|
24556
24637
|
overlay(rows) {
|
|
24557
24638
|
return rows.map((row) => this.overlayRow(row));
|
|
24558
24639
|
}
|
|
24559
|
-
schedule(
|
|
24640
|
+
schedule(delay4) {
|
|
24560
24641
|
if (this.running || this.timer || !this.pending.size || this.stopped)
|
|
24561
24642
|
return;
|
|
24562
24643
|
const remaining = this.closed ? 0 : (this.committedAt ?? -Infinity) + QUOTA_COMMIT_INTERVAL_MS - this.clock.now();
|
|
24563
|
-
this.timer = this.clock.schedule(Math.max(
|
|
24644
|
+
this.timer = this.clock.schedule(Math.max(delay4, remaining), () => {
|
|
24564
24645
|
this.timer = undefined;
|
|
24565
24646
|
return this.flush();
|
|
24566
24647
|
});
|
|
@@ -24658,8 +24739,8 @@ class PoolQuotaWriter {
|
|
|
24658
24739
|
this.running = undefined;
|
|
24659
24740
|
for (const wake of this.wake)
|
|
24660
24741
|
wake();
|
|
24661
|
-
const
|
|
24662
|
-
this.schedule(
|
|
24742
|
+
const delay4 = this.failures ? Math.min(5000, 100 * 2 ** Math.min(this.failures, 6)) * (0.5 + Math.random()) : COALESCE_MS2;
|
|
24743
|
+
this.schedule(delay4);
|
|
24663
24744
|
}
|
|
24664
24745
|
})();
|
|
24665
24746
|
return this.running;
|
|
@@ -25655,7 +25736,7 @@ var nativeQuotaCodec = {
|
|
|
25655
25736
|
// src/native-runtime.ts
|
|
25656
25737
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
25657
25738
|
import { constants as constants2 } from "node:fs";
|
|
25658
|
-
import { lstat as lstat8, mkdir as mkdir9, open as open9, rename as
|
|
25739
|
+
import { lstat as lstat8, mkdir as mkdir9, open as open9, rename as rename12, rm as rm5 } from "node:fs/promises";
|
|
25659
25740
|
import { basename as basename9, dirname as dirname15, isAbsolute as isAbsolute4, join as join19 } from "node:path";
|
|
25660
25741
|
import { types as utilTypes5 } from "node:util";
|
|
25661
25742
|
|
|
@@ -25831,7 +25912,7 @@ function openNativePoolStore(options) {
|
|
|
25831
25912
|
}
|
|
25832
25913
|
|
|
25833
25914
|
// src/publication-rename.ts
|
|
25834
|
-
import { rename as
|
|
25915
|
+
import { rename as rename11 } from "node:fs/promises";
|
|
25835
25916
|
import { types as utilTypes4 } from "node:util";
|
|
25836
25917
|
function capturePublicationOptions(options = {}) {
|
|
25837
25918
|
return {
|
|
@@ -25854,7 +25935,7 @@ function sharingViolation(error) {
|
|
|
25854
25935
|
return fields2.win32Code !== undefined ? fields2.win32Code === 32 || fields2.win32Code === 33 : ["EBUSY", "EPERM", "EACCES"].includes(fields2.code) && !fields2.reason;
|
|
25855
25936
|
}
|
|
25856
25937
|
async function renameWithWindowsSharingRetry(from, to, options = {}, beforeRetry) {
|
|
25857
|
-
const move = options.rename ??
|
|
25938
|
+
const move = options.rename ?? rename11;
|
|
25858
25939
|
if ((options.platform ?? process.platform) !== "win32") {
|
|
25859
25940
|
await move(from, to);
|
|
25860
25941
|
return "published";
|
|
@@ -25871,11 +25952,11 @@ async function renameWithWindowsSharingRetry(from, to, options = {}, beforeRetry
|
|
|
25871
25952
|
throw error;
|
|
25872
25953
|
original = error;
|
|
25873
25954
|
}
|
|
25874
|
-
for (const
|
|
25955
|
+
for (const delay4 of [10, 20, 40, 80, 100]) {
|
|
25875
25956
|
const remaining = 500 - (now() - start);
|
|
25876
25957
|
if (remaining <= 0)
|
|
25877
25958
|
break;
|
|
25878
|
-
await sleep(Math.min(
|
|
25959
|
+
await sleep(Math.min(delay4, remaining));
|
|
25879
25960
|
if (now() - start >= 500)
|
|
25880
25961
|
break;
|
|
25881
25962
|
if (await beforeRetry?.() === "skip")
|
|
@@ -28067,7 +28148,7 @@ async function writeNativeRuntimeOutcome(path2, storageId, change, hooks, firstI
|
|
|
28067
28148
|
} catch {
|
|
28068
28149
|
throw new NativeRuntimeError("publication-refused");
|
|
28069
28150
|
}
|
|
28070
|
-
return (publication2.rename ??
|
|
28151
|
+
return (publication2.rename ?? rename12)(from, to);
|
|
28071
28152
|
};
|
|
28072
28153
|
try {
|
|
28073
28154
|
await mkdir9(dirname15(path2), { recursive: true, mode: 448 });
|
|
@@ -29841,7 +29922,7 @@ class StickySessionRouter {
|
|
|
29841
29922
|
await writeFile3(tempPath, `${JSON.stringify(state)}
|
|
29842
29923
|
`, { mode: 384 });
|
|
29843
29924
|
await beforeRename();
|
|
29844
|
-
await
|
|
29925
|
+
await rename13(tempPath, this.options.path);
|
|
29845
29926
|
} finally {
|
|
29846
29927
|
await rm6(tempPath, { force: true }).catch(() => {});
|
|
29847
29928
|
}
|
|
@@ -31674,7 +31755,7 @@ class CacheKeepSessionRegistry {
|
|
|
31674
31755
|
}
|
|
31675
31756
|
const sweptPath = `${recordPath}.${randomUUID18()}.sweep`;
|
|
31676
31757
|
try {
|
|
31677
|
-
await
|
|
31758
|
+
await rename14(recordPath, sweptPath);
|
|
31678
31759
|
} catch {
|
|
31679
31760
|
return;
|
|
31680
31761
|
}
|
|
@@ -32028,8 +32109,8 @@ class CacheKeepStore {
|
|
|
32028
32109
|
this.pending.set(entry2.id, entry2);
|
|
32029
32110
|
if (this.timers.has(entry2.id))
|
|
32030
32111
|
return;
|
|
32031
|
-
const
|
|
32032
|
-
const timer = (this.options.setTimeoutImpl ?? setTimeout)(() => this.flush(entry2.id),
|
|
32112
|
+
const delay4 = Math.max(250, (this.lastWrite.get(entry2.id) ?? 0) + 5000 - (this.options.now?.() ?? Date.now()));
|
|
32113
|
+
const timer = (this.options.setTimeoutImpl ?? setTimeout)(() => this.flush(entry2.id), delay4);
|
|
32033
32114
|
timer.unref?.();
|
|
32034
32115
|
this.timers.set(entry2.id, timer);
|
|
32035
32116
|
}
|
|
@@ -36379,7 +36460,7 @@ async function beginNativeEmptyInit(paths, hooks = {}) {
|
|
|
36379
36460
|
host: "opencode",
|
|
36380
36461
|
phase: "committed"
|
|
36381
36462
|
};
|
|
36382
|
-
await hooks.assertOwned?.();
|
|
36463
|
+
await (hooks.validate ?? hooks.assertOwned)?.();
|
|
36383
36464
|
await writeJournal(paths, initial, () => lock.assertOwned(), hooks);
|
|
36384
36465
|
return initial;
|
|
36385
36466
|
});
|
|
@@ -43274,7 +43355,7 @@ function relayGeneration(input) {
|
|
|
43274
43355
|
}
|
|
43275
43356
|
// src/native-host-auth-write.ts
|
|
43276
43357
|
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
43277
|
-
import { lstat as lstat19, open as open13, rename as
|
|
43358
|
+
import { lstat as lstat19, open as open13, rename as rename15, unlink as unlink9 } from "node:fs/promises";
|
|
43278
43359
|
import { dirname as dirname22, isAbsolute as isAbsolute6, join as join28 } from "node:path";
|
|
43279
43360
|
class NativeHostAuthWriteError extends Error {
|
|
43280
43361
|
code;
|
|
@@ -43371,7 +43452,7 @@ async function writeNativeHostAuth(input, hooks = {}) {
|
|
|
43371
43452
|
return "publish";
|
|
43372
43453
|
});
|
|
43373
43454
|
} else
|
|
43374
|
-
await (publication2.rename ??
|
|
43455
|
+
await (publication2.rename ?? rename15)(stage, authPath);
|
|
43375
43456
|
ownedStage = undefined;
|
|
43376
43457
|
effect = outcome;
|
|
43377
43458
|
await barrier(afterRename, "hook-failed", effect);
|
|
@@ -43467,7 +43548,8 @@ async function publishNativeEmptyInit(input, hooks = {}) {
|
|
|
43467
43548
|
const env = { ...input.env };
|
|
43468
43549
|
const routingDestinationPath = input.routingDestinationPath;
|
|
43469
43550
|
const processFence = input.processFence;
|
|
43470
|
-
|
|
43551
|
+
const validate = input.validate ?? processFence;
|
|
43552
|
+
await validate();
|
|
43471
43553
|
requireNoSupervisedAuthContentSnapshot(env);
|
|
43472
43554
|
return withLock(paths2.journal, {
|
|
43473
43555
|
name: "native-migration",
|
|
@@ -43476,9 +43558,9 @@ async function publishNativeEmptyInit(input, hooks = {}) {
|
|
|
43476
43558
|
...hooks.lockOptions,
|
|
43477
43559
|
renew: true
|
|
43478
43560
|
}, async (lease) => {
|
|
43479
|
-
await
|
|
43480
|
-
const checkDestinations = async () => {
|
|
43481
|
-
await processFence();
|
|
43561
|
+
await validate();
|
|
43562
|
+
const checkDestinations = async (publication2 = true) => {
|
|
43563
|
+
await (publication2 ? processFence : validate)();
|
|
43482
43564
|
try {
|
|
43483
43565
|
await lease.assertOwned();
|
|
43484
43566
|
} catch {
|
|
@@ -43519,6 +43601,7 @@ async function publishNativeEmptyInit(input, hooks = {}) {
|
|
|
43519
43601
|
return beginNativeEmptyInit(paths2, {
|
|
43520
43602
|
lockOptions: hooks.lockOptions,
|
|
43521
43603
|
assertOwned: checkDestinations,
|
|
43604
|
+
validate: () => checkDestinations(false),
|
|
43522
43605
|
onWriteStep: async (step) => hooks.onStep?.(`${step}:journal:committed`)
|
|
43523
43606
|
});
|
|
43524
43607
|
});
|
|
@@ -43537,7 +43620,7 @@ function releaseNativeMigrationPreflight(token2) {
|
|
|
43537
43620
|
}
|
|
43538
43621
|
async function capture2(input, checkPool = false) {
|
|
43539
43622
|
requireNoSupervisedAuthContentSnapshot(input.env);
|
|
43540
|
-
await input.processFence();
|
|
43623
|
+
await (input.validate ?? input.processFence)();
|
|
43541
43624
|
const resolved = await resolveNativePoolPaths(input.paths.legacyConfig, input.paths.legacyState, processStateLayout(input.paths.legacyConfig));
|
|
43542
43625
|
for (const key of Object.keys(resolved))
|
|
43543
43626
|
if (input.paths[key] !== resolved[key])
|
|
@@ -43991,13 +44074,13 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
43991
44074
|
const projection = captured.projection;
|
|
43992
44075
|
if (!projection)
|
|
43993
44076
|
refuse3();
|
|
43994
|
-
const beforeMutator = async () => {
|
|
44077
|
+
const beforeMutator = async (publication2 = true) => {
|
|
43995
44078
|
await checkPaths(operation, captured);
|
|
43996
44079
|
await checkLegacy(captured);
|
|
43997
|
-
await operation.processFence();
|
|
44080
|
+
await (publication2 ? operation.processFence : operation.validate ?? operation.processFence)();
|
|
43998
44081
|
await assertMigration();
|
|
43999
44082
|
};
|
|
44000
|
-
await beforeMutator();
|
|
44083
|
+
await beforeMutator(false);
|
|
44001
44084
|
await store.initialize();
|
|
44002
44085
|
for (const account of [...projection.accounts].filter((account2) => account2.credential).sort((a, b) => Number(a.enabled) - Number(b.enabled))) {
|
|
44003
44086
|
const current = (await publicRows(store)).find((row) => row.id === account.id);
|
|
@@ -44013,7 +44096,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44013
44096
|
]
|
|
44014
44097
|
}, [current], false);
|
|
44015
44098
|
else {
|
|
44016
|
-
await beforeMutator();
|
|
44099
|
+
await beforeMutator(false);
|
|
44017
44100
|
if (!account.credential)
|
|
44018
44101
|
refuse3();
|
|
44019
44102
|
const result = await store.add({
|
|
@@ -44026,7 +44109,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44026
44109
|
refuse3();
|
|
44027
44110
|
await step(`after:add:${account.id}`);
|
|
44028
44111
|
}
|
|
44029
|
-
await beforeMutator();
|
|
44112
|
+
await beforeMutator(false);
|
|
44030
44113
|
if (!account.enabled)
|
|
44031
44114
|
await store.disable(account.id, "user-disabled");
|
|
44032
44115
|
else
|
|
@@ -44035,21 +44118,21 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44035
44118
|
const row = (await publicRows(store)).find((row2) => row2.id === account.id);
|
|
44036
44119
|
if (!row?.credentialEpoch)
|
|
44037
44120
|
refuse3();
|
|
44038
|
-
await beforeMutator();
|
|
44121
|
+
await beforeMutator(false);
|
|
44039
44122
|
await store.recordQuota(account.id, {
|
|
44040
44123
|
credentialEpoch: row.credentialEpoch,
|
|
44041
44124
|
...row.identity !== undefined ? { identity: row.identity } : {}
|
|
44042
44125
|
}, account.quota);
|
|
44043
44126
|
}
|
|
44044
44127
|
}
|
|
44045
|
-
await beforeMutator();
|
|
44128
|
+
await beforeMutator(false);
|
|
44046
44129
|
await store.reorder(projection.accounts.filter((account) => account.credential).map((account) => account.id));
|
|
44047
44130
|
if (journal.kind !== "legacy-import") {
|
|
44048
|
-
await beforeMutator();
|
|
44131
|
+
await beforeMutator(false);
|
|
44049
44132
|
await store.updateSettings(() => projection.settings);
|
|
44050
44133
|
}
|
|
44051
44134
|
if (captured.seedInput) {
|
|
44052
|
-
await beforeMutator();
|
|
44135
|
+
await beforeMutator(false);
|
|
44053
44136
|
await step("before:roster");
|
|
44054
44137
|
if (!operation.custody)
|
|
44055
44138
|
refuse3();
|
|
@@ -44062,7 +44145,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44062
44145
|
const rows = await publicRows(store);
|
|
44063
44146
|
requireNativeMigrationSourceRows(projection, rows);
|
|
44064
44147
|
const projected = projectNativeMigrationRuntime(paths2, projection, rows, seed);
|
|
44065
|
-
await beforeMutator();
|
|
44148
|
+
await beforeMutator(false);
|
|
44066
44149
|
await step("before:runtime");
|
|
44067
44150
|
if (captured.seedInput) {
|
|
44068
44151
|
if (!operation.custody)
|
|
@@ -44144,13 +44227,13 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44144
44227
|
}
|
|
44145
44228
|
requireNativeMigrationPreparedProof(journal.preparedProof, rows, runtime2);
|
|
44146
44229
|
const authoritative = journal;
|
|
44147
|
-
const recheck = async () => {
|
|
44230
|
+
const recheck = async (publication2 = true) => {
|
|
44148
44231
|
await checkPaths(operation, captured);
|
|
44149
44232
|
await checkLegacy(captured);
|
|
44150
44233
|
rows = await publicRows(store);
|
|
44151
44234
|
runtime2 = await importedRuntimeProjection(paths2, store, rows);
|
|
44152
44235
|
requireNativeMigrationPreparedProof(authoritative.preparedProof, rows, runtime2);
|
|
44153
|
-
await operation.processFence();
|
|
44236
|
+
await (publication2 ? operation.processFence : operation.validate ?? operation.processFence)();
|
|
44154
44237
|
await assertOwned();
|
|
44155
44238
|
};
|
|
44156
44239
|
await withLock(operation.routingDestinationPath, { name: "write", ttlMs: 30000, timeoutMs: 15000, renew: true }, async (routingLease) => {
|
|
@@ -44181,7 +44264,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44181
44264
|
if (authoritative.phase === "activation-installed" && entry2.digest !== authoritative.expectedHostAuth)
|
|
44182
44265
|
refuse3();
|
|
44183
44266
|
await step("before:host");
|
|
44184
|
-
await recheck();
|
|
44267
|
+
await recheck(false);
|
|
44185
44268
|
await mkdir15(dirname23(operation.hostAuthPath), {
|
|
44186
44269
|
recursive: true,
|
|
44187
44270
|
mode: 448
|
|
@@ -44200,7 +44283,7 @@ async function runNativeMigration(input, hooks = {}) {
|
|
|
44200
44283
|
}
|
|
44201
44284
|
}, hooks.hostWrite);
|
|
44202
44285
|
await step("after:host");
|
|
44203
|
-
await recheck();
|
|
44286
|
+
await recheck(false);
|
|
44204
44287
|
const effect = await readNativeMigrationSource("hostAuth", operation.hostAuthPath);
|
|
44205
44288
|
if (inspectNativeHostAuthEntry(operation.host, effect.data).digest !== authoritative.expectedHostAuth)
|
|
44206
44289
|
refuse3();
|
|
@@ -47070,7 +47153,7 @@ import { dirname as dirname24, resolve as resolve23 } from "node:path";
|
|
|
47070
47153
|
import { setTimeout as sleep } from "node:timers/promises";
|
|
47071
47154
|
|
|
47072
47155
|
// ../../node_modules/@cortexkit/common-auth/dist/pi-slot/lock.js
|
|
47073
|
-
import { rmdirSync, statSync as
|
|
47156
|
+
import { rmdirSync, statSync as statSync7, utimesSync } from "node:fs";
|
|
47074
47157
|
import { mkdir as mkdir16, rmdir, stat as stat13, utimes } from "node:fs/promises";
|
|
47075
47158
|
var STALE = 30000;
|
|
47076
47159
|
var RENEWAL_STALE = 1e4;
|
|
@@ -47082,7 +47165,7 @@ process.once("exit", () => {
|
|
|
47082
47165
|
try {
|
|
47083
47166
|
if (identity5.renewedAt + RENEWAL_STALE < Date.now())
|
|
47084
47167
|
continue;
|
|
47085
|
-
const observed =
|
|
47168
|
+
const observed = statSync7(path2);
|
|
47086
47169
|
if (sameDirectory(observed, identity5) && observed.mtime.getTime() === identity5.mtime)
|
|
47087
47170
|
rmdirSync(path2);
|
|
47088
47171
|
} catch {}
|
|
@@ -47174,12 +47257,12 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
47174
47257
|
if (!released && lastUpdate + RENEWAL_STALE < Date.now())
|
|
47175
47258
|
compromise();
|
|
47176
47259
|
}
|
|
47177
|
-
function schedule2(
|
|
47260
|
+
function schedule2(delay4 = UPDATE) {
|
|
47178
47261
|
if (released)
|
|
47179
47262
|
return;
|
|
47180
47263
|
timer = setTimeout(() => {
|
|
47181
47264
|
update();
|
|
47182
|
-
},
|
|
47265
|
+
}, delay4);
|
|
47183
47266
|
timer.unref();
|
|
47184
47267
|
}
|
|
47185
47268
|
function retry(error) {
|
|
@@ -47196,7 +47279,7 @@ async function acquirePiLock(authPath, onCompromised, onRenew) {
|
|
|
47196
47279
|
return;
|
|
47197
47280
|
let observed;
|
|
47198
47281
|
try {
|
|
47199
|
-
observed =
|
|
47282
|
+
observed = statSync7(path2);
|
|
47200
47283
|
} catch (error) {
|
|
47201
47284
|
retry(error);
|
|
47202
47285
|
return;
|
|
@@ -48498,7 +48581,7 @@ import {
|
|
|
48498
48581
|
mkdir as mkdir19,
|
|
48499
48582
|
readdir as readdir8,
|
|
48500
48583
|
readFile as readFile18,
|
|
48501
|
-
rename as
|
|
48584
|
+
rename as rename16,
|
|
48502
48585
|
rm as rm11,
|
|
48503
48586
|
stat as stat15,
|
|
48504
48587
|
writeFile as writeFile7
|
|
@@ -48711,7 +48794,7 @@ class QuotaHeaderFeedRegistry {
|
|
|
48711
48794
|
await writeFile7(tempPath, `${JSON.stringify({ version: QUOTA_HEADER_FEED_SCHEMA_VERSION, lease_horizon_ms: this.options.leaseMs ?? QUOTA_HEADER_FEED_LEASE_MS, entries })}
|
|
48712
48795
|
`, { mode: 384 });
|
|
48713
48796
|
await chmod3(tempPath, 384);
|
|
48714
|
-
await
|
|
48797
|
+
await rename16(tempPath, this.filePath);
|
|
48715
48798
|
} finally {
|
|
48716
48799
|
await rm11(tempPath, { force: true });
|
|
48717
48800
|
}
|
|
@@ -48937,7 +49020,7 @@ function buildClaudeQuotaSummary(input) {
|
|
|
48937
49020
|
`).trimEnd();
|
|
48938
49021
|
}
|
|
48939
49022
|
// src/request-gzip.ts
|
|
48940
|
-
import { mkdir as mkdir20, readFile as readFile19, rename as
|
|
49023
|
+
import { mkdir as mkdir20, readFile as readFile19, rename as rename17, rm as rm12, writeFile as writeFile8 } from "node:fs/promises";
|
|
48941
49024
|
import { basename as basename14, dirname as dirname26, join as join32 } from "node:path";
|
|
48942
49025
|
import { promisify as promisify2 } from "node:util";
|
|
48943
49026
|
import { gzip as gzip2 } from "node:zlib";
|
|
@@ -49065,7 +49148,7 @@ class RequestGzipLatch {
|
|
|
49065
49148
|
await mkdir20(dirname26(this.path), { recursive: true });
|
|
49066
49149
|
await writeFile8(temporary, `${JSON.stringify({ latchedAt: this.now(), status })}
|
|
49067
49150
|
`, { mode: 384 });
|
|
49068
|
-
await
|
|
49151
|
+
await rename17(temporary, this.path);
|
|
49069
49152
|
} catch {
|
|
49070
49153
|
await rm12(temporary, { force: true }).catch(() => {});
|
|
49071
49154
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type MenuTerminal } from '../auth-menu/terminal.js';
|
|
2
|
+
import { SetupProcessGuard } from './process-guard.js';
|
|
2
3
|
import type { SetupEnrollmentAccess, SetupHost, SetupIO, SetupPlugin } from './types.js';
|
|
3
4
|
/** Fixed text: no version, host or account detail, so it is safe to print anywhere. */
|
|
4
5
|
export declare const UNSUPPORTED_VAULT_MESSAGE = "This Claustrum vault is too old to connect plugins. Run ck upgrade to move to Claustrum v0.2.0 or newer (read \"Upgrading from v0.1.3\" in its release notes first), or run setup without --claustrum to use local accounts.";
|
|
@@ -31,4 +32,4 @@ export declare class HostNotEnrolledError extends Error {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
/** Enroll an independently revocable host; plugin callbacks choose its credential store and account permissions. */
|
|
34
|
-
export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: () => Promise<void>): Promise<SetupEnrollmentAccess | undefined>;
|
|
35
|
+
export declare function connectSetupHost(plugin: SetupPlugin, host: SetupHost, io: SetupIO, terminal: MenuTerminal, fence: (() => Promise<void>) | SetupProcessGuard): Promise<SetupEnrollmentAccess | undefined>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CommandRunner, ProcessFence, SetupEnvironment } from './types.js';
|
|
2
2
|
export interface ProcessInspectionStep {
|
|
3
3
|
step: 'tasklist' | 'CIM' | 'ps';
|
|
4
|
+
/** The selected CIM interpreter; absent for tasklist and ps. */
|
|
5
|
+
program?: 'pwsh' | 'powershell';
|
|
4
6
|
exitCode: number | null;
|
|
5
7
|
signal: NodeJS.Signals | null;
|
|
6
8
|
timedOut: boolean;
|
|
@@ -9,6 +11,7 @@ export interface ProcessInspectionStep {
|
|
|
9
11
|
export declare class ProcessInspectionError extends Error implements ProcessInspectionStep {
|
|
10
12
|
readonly code = "process-inspection-failed";
|
|
11
13
|
readonly step: ProcessInspectionStep['step'];
|
|
14
|
+
readonly program?: ProcessInspectionStep['program'];
|
|
12
15
|
readonly exitCode: number | null;
|
|
13
16
|
readonly signal: NodeJS.Signals | null;
|
|
14
17
|
readonly timedOut: boolean;
|
|
@@ -30,6 +33,10 @@ export declare class ProcessFenceViolationError extends Error {
|
|
|
30
33
|
export declare function listSetupProcesses(runner?: CommandRunner, options?: {
|
|
31
34
|
platform?: string;
|
|
32
35
|
env?: SetupEnvironment;
|
|
36
|
+
/** Tests can replace the regular-file check for the fixed pwsh location. */
|
|
37
|
+
isFile?: (file: string) => boolean;
|
|
38
|
+
/** Reports before each slow Windows ARM PowerShell 5.1 check. */
|
|
39
|
+
onProgress?: (line: string) => void;
|
|
33
40
|
onStep?: (details: ProcessInspectionStep) => void;
|
|
34
41
|
/** False skips the Windows PowerShell query for Node and Bun command lines. */
|
|
35
42
|
inspectRuntimes?: boolean;
|
|
@@ -53,5 +60,7 @@ export declare function listSetupProcesses(runner?: CommandRunner, options?: {
|
|
|
53
60
|
export declare function createProcessFence(runner?: CommandRunner, options?: {
|
|
54
61
|
platform?: string;
|
|
55
62
|
selfPid?: number;
|
|
63
|
+
isFile?: (file: string) => boolean;
|
|
64
|
+
onProgress?: (line: string) => void;
|
|
56
65
|
}): ProcessFence;
|
|
57
66
|
export declare function assertHostsStopped(fence: ProcessFence, env?: SetupEnvironment): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Reuse an inspection only while setup has done nothing a running host could observe. */
|
|
2
|
+
export declare class SetupProcessGuard {
|
|
3
|
+
#private;
|
|
4
|
+
private readonly inspect;
|
|
5
|
+
private readonly now;
|
|
6
|
+
constructor(inspect: () => Promise<void>, now?: () => number);
|
|
7
|
+
check(options?: {
|
|
8
|
+
reuse?: boolean;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
/** Callbacks, writes and waits can all make an earlier inspection stale. */
|
|
11
|
+
step<T>(run: () => T | Promise<T>): Promise<T>;
|
|
12
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SetupProcessGuard } from './process-guard.js';
|
|
1
2
|
import type { OpenCodeGeneration, SetupIO, SetupPlugin } from './types.js';
|
|
2
3
|
export interface PlannedWrite {
|
|
3
4
|
path: string;
|
|
@@ -9,5 +10,5 @@ export interface PlannedWrite {
|
|
|
9
10
|
/** Edit only array entries so unrelated JSONC text, including comments, survives. */
|
|
10
11
|
export declare function updatePluginConfig(text: string, key: 'plugin' | 'plugins', pkg: string, version: string): string;
|
|
11
12
|
export declare function planOpenCodeRegistration(plugin: SetupPlugin, generation: OpenCodeGeneration, io?: SetupIO): PlannedWrite[];
|
|
12
|
-
export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: () => Promise<void>): Promise<void>;
|
|
13
|
+
export declare function registerOpenCode(writes: readonly PlannedWrite[], beforeWrite?: (() => Promise<void>) | SetupProcessGuard): Promise<void>;
|
|
13
14
|
export declare function registerPi(plugin: SetupPlugin, executable: string, io?: SetupIO): Promise<void>;
|
|
@@ -39,6 +39,8 @@ export interface NativeMigrationOptions {
|
|
|
39
39
|
routingDestinationPath: string;
|
|
40
40
|
env: NodeJS.ProcessEnv;
|
|
41
41
|
processFence: () => Promise<void>;
|
|
42
|
+
/** Read-only safety checks; defaults to processFence for existing callers. */
|
|
43
|
+
validate?: () => Promise<void>;
|
|
42
44
|
removePiAnthropicAuth: boolean;
|
|
43
45
|
custody?: NativeMigrationCustody;
|
|
44
46
|
preflight?: NativeMigrationPreflight;
|
|
@@ -80,6 +82,8 @@ export interface NativeEmptyInitOptions {
|
|
|
80
82
|
paths: NativePoolPaths;
|
|
81
83
|
routingDestinationPath: string;
|
|
82
84
|
processFence: () => Promise<void>;
|
|
85
|
+
/** Read-only safety checks; defaults to processFence for existing callers. */
|
|
86
|
+
validate?: () => Promise<void>;
|
|
83
87
|
env: NodeJS.ProcessEnv;
|
|
84
88
|
}
|
|
85
89
|
export interface NativeEmptyInitHooks extends Pick<NativeMigrationHooks, 'onStep'> {
|
package/dist/pool-authority.d.ts
CHANGED
|
@@ -189,5 +189,7 @@ export declare function recordNativeCustodyActivation(paths: NativePoolPaths, pl
|
|
|
189
189
|
/** Advance a recorded activation one phase; never backwards or across a phase. */
|
|
190
190
|
export declare function advanceNativeCustodyActivation(paths: NativePoolPaths, expected: NativeCustodyActivationPhase, next: NativeCustodyActivationPhase, hooks?: JournalHooks): Promise<NativeLegacyMigrationJournal>;
|
|
191
191
|
/** Publish local authority without inventing migration inputs or creating a pool. */
|
|
192
|
-
export declare function beginNativeEmptyInit(paths: NativePoolPaths, hooks?: JournalHooks
|
|
192
|
+
export declare function beginNativeEmptyInit(paths: NativePoolPaths, hooks?: JournalHooks & {
|
|
193
|
+
validate?: () => Promise<void>;
|
|
194
|
+
}): Promise<NativeEmptyInitJournal>;
|
|
193
195
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cortexkit/anthropic-auth-core",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepublishOnly": "bun run build"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cortexkit/common-auth": "0.
|
|
34
|
+
"@cortexkit/common-auth": "0.52.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@cortexkit/claustrum-client": "0.18.0",
|