@phren/cli 0.3.64 → 0.3.66
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/bridge/changes.d.ts +22 -0
- package/dist/bridge/changes.js +323 -82
- package/dist/bridge/usage.d.ts +7 -0
- package/dist/bridge/usage.js +18 -1
- package/dist/bridge-hook.mjs +346 -132
- package/dist/governance/policy.js +4 -3
- package/dist/governance/scores.js +2 -1
- package/package.json +1 -1
package/dist/bridge-hook.mjs
CHANGED
|
@@ -27899,7 +27899,8 @@ var init_projects = __esm({
|
|
|
27899
27899
|
|
|
27900
27900
|
// src/bridge/changes.ts
|
|
27901
27901
|
import { execFile as execFile2 } from "node:child_process";
|
|
27902
|
-
import {
|
|
27902
|
+
import { randomBytes } from "node:crypto";
|
|
27903
|
+
import { appendFile, copyFile, mkdir as mkdir5, readdir as readdir2, readFile as readFile7, realpath as realpath2, rm as rm2, stat as stat5, unlink as unlink2, utimes } from "node:fs/promises";
|
|
27903
27904
|
import path18 from "node:path";
|
|
27904
27905
|
import { promisify as promisify2 } from "node:util";
|
|
27905
27906
|
function capturesChanges(tool, input2) {
|
|
@@ -27936,55 +27937,30 @@ async function git2(cwd, args, extra = {}, signal) {
|
|
|
27936
27937
|
env: { ...checkoutGitEnv(), ...extra }
|
|
27937
27938
|
})).stdout;
|
|
27938
27939
|
}
|
|
27939
|
-
|
|
27940
|
-
const
|
|
27941
|
-
|
|
27942
|
-
while (!await stat5(existing).catch(() => void 0)) {
|
|
27943
|
-
const parent = path18.dirname(existing);
|
|
27944
|
-
if (parent === existing) return void 0;
|
|
27945
|
-
existing = parent;
|
|
27946
|
-
}
|
|
27947
|
-
const real2 = await realpath2(existing);
|
|
27948
|
-
home = await realpath2(home);
|
|
27949
|
-
if (real2 !== home && !real2.startsWith(home + path18.sep)) return void 0;
|
|
27950
|
-
const dir = (await stat5(real2)).isDirectory() ? real2 : path18.dirname(real2);
|
|
27951
|
-
try {
|
|
27952
|
-
return await realpath2((await git2(dir, ["rev-parse", "--show-toplevel"], {}, signal)).replace(/\r?\n$/, ""));
|
|
27953
|
-
} catch (error62) {
|
|
27954
|
-
if (/not a git repository/.test(String(error62.stderr))) return void 0;
|
|
27955
|
-
throw error62;
|
|
27956
|
-
}
|
|
27940
|
+
function timedOut(error62) {
|
|
27941
|
+
const failure2 = error62;
|
|
27942
|
+
return error62 instanceof CaptureTimeout || failure2?.name === "AbortError" || failure2?.code === "ABORT_ERR" || failure2?.killed === true;
|
|
27957
27943
|
}
|
|
27958
|
-
|
|
27959
|
-
|
|
27960
|
-
|
|
27961
|
-
const scratch = await mkdtemp(path18.join(dir, "repo-"));
|
|
27962
|
-
try {
|
|
27963
|
-
const objects2 = await realpath2(path18.resolve(root, (await git2(root, ["rev-parse", "--git-path", "objects"], {}, signal)).trim()));
|
|
27964
|
-
await mkdir5(path18.join(scratch, "objects"), { mode: 448 });
|
|
27965
|
-
const env = { GIT_OBJECT_DIRECTORY: path18.join(scratch, "objects"), GIT_ALTERNATE_OBJECT_DIRECTORIES: JSON.stringify(objects2), GIT_INDEX_FILE: path18.join(scratch, "index") };
|
|
27966
|
-
return { hash: await treeHash(root, env, signal), scratch, env };
|
|
27967
|
-
} catch (error62) {
|
|
27968
|
-
await rm2(scratch, { recursive: true, force: true });
|
|
27969
|
-
throw error62;
|
|
27970
|
-
}
|
|
27944
|
+
function failedIn(error62, root) {
|
|
27945
|
+
if (error62 && (typeof error62 === "object" || typeof error62 === "function")) error62[failedRepository] = root;
|
|
27946
|
+
return error62;
|
|
27971
27947
|
}
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
27975
|
-
|
|
27976
|
-
|
|
27977
|
-
|
|
27978
|
-
|
|
27948
|
+
function failureRoot(error62) {
|
|
27949
|
+
return error62 && (typeof error62 === "object" || typeof error62 === "function") ? error62[failedRepository] : void 0;
|
|
27950
|
+
}
|
|
27951
|
+
function until(work, signal) {
|
|
27952
|
+
if (signal.aborted) return Promise.reject(signal.reason);
|
|
27953
|
+
return new Promise((resolve17, reject) => {
|
|
27954
|
+
const abort = () => reject(signal.reason);
|
|
27955
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
27956
|
+
work.then(resolve17, reject).finally(() => signal.removeEventListener("abort", abort));
|
|
27979
27957
|
});
|
|
27980
|
-
|
|
27981
|
-
|
|
27982
|
-
|
|
27983
|
-
|
|
27984
|
-
|
|
27958
|
+
}
|
|
27959
|
+
async function checkoutOf(dir) {
|
|
27960
|
+
for (let at2 = dir; ; at2 = path18.dirname(at2)) {
|
|
27961
|
+
if (await stat5(path18.join(at2, ".git")).then(() => true, () => false)) return at2;
|
|
27962
|
+
if (path18.dirname(at2) === at2) return void 0;
|
|
27985
27963
|
}
|
|
27986
|
-
await git2(root, ["add", "-A", "--", "."], env, signal);
|
|
27987
|
-
return (await git2(root, ["write-tree"], env, signal)).trim();
|
|
27988
27964
|
}
|
|
27989
27965
|
async function treeDiff(root, before, after2, env, signal) {
|
|
27990
27966
|
if (before === after2) return [];
|
|
@@ -28000,8 +27976,14 @@ async function treeDiff(root, before, after2, env, signal) {
|
|
|
28000
27976
|
const counts = (await git2(root, [...NO_DIFF, "--numstat", before, after2, "--", ...specs], env, signal)).split(" ");
|
|
28001
27977
|
const binary = counts[0] === "-" || counts[1] === "-";
|
|
28002
27978
|
const redacted = secretName(original) || secretName(file4) || binary;
|
|
28003
|
-
let
|
|
28004
|
-
|
|
27979
|
+
let overflowed = false;
|
|
27980
|
+
let patch = redacted ? "" : await git2(root, [...NO_DIFF, before, after2, "--", ...specs], env, signal).catch((error62) => {
|
|
27981
|
+
const failure2 = error62;
|
|
27982
|
+
if (failure2.code !== "ERR_CHILD_PROCESS_STDIO_MAXBUFFER") throw error62;
|
|
27983
|
+
overflowed = true;
|
|
27984
|
+
return String(failure2.stdout ?? "");
|
|
27985
|
+
});
|
|
27986
|
+
const truncated = overflowed || patch.length > 2e5;
|
|
28005
27987
|
if (truncated) patch = patch.slice(0, 2e5) + "\n\u2026 (truncated)\n";
|
|
28006
27988
|
const added = Number(counts[0]) || 0, removed = Number(counts[1]) || 0;
|
|
28007
27989
|
files.push({ root, path: file4, status, patch, added, removed, binary, truncated, ...redacted ? { redacted: true } : {} });
|
|
@@ -28044,6 +28026,11 @@ async function pruneChanges(now = Date.now()) {
|
|
|
28044
28026
|
if (now - file4.at > 30 * DAY || size + file4.size > 268435456) await unlink2(file4.file).catch(() => void 0);
|
|
28045
28027
|
else size += file4.size;
|
|
28046
28028
|
}
|
|
28029
|
+
const scratch = path18.join(bridgeRoot(), "changes-scratch");
|
|
28030
|
+
for (const entry2 of await readdir2(scratch, { withFileTypes: true }).catch(() => [])) {
|
|
28031
|
+
const dir2 = path18.join(scratch, entry2.name), info = await stat5(dir2).catch(() => void 0);
|
|
28032
|
+
if (info && now - info.mtimeMs > DAY) await rm2(dir2, { recursive: true, force: true }).catch(() => void 0);
|
|
28033
|
+
}
|
|
28047
28034
|
}
|
|
28048
28035
|
async function startChangeRetention() {
|
|
28049
28036
|
await pruneChanges();
|
|
@@ -28067,7 +28054,7 @@ function outputCallIds(raw, source) {
|
|
|
28067
28054
|
if (!Array.isArray(content)) return [];
|
|
28068
28055
|
return content.flatMap((block) => block && typeof block === "object" && block.type === "tool_result" ? ids(block.tool_use_id) : []);
|
|
28069
28056
|
}
|
|
28070
|
-
var exec2, changedFileSchema, changeRowSchema, secretName, capturePool, SHELL_TOOLS, NAMED, FILE_TOOLS, NO_DIFF, CLAIM_RETENTION, PENDING_FOR, BUDGET, DAY, ToolChanges;
|
|
28057
|
+
var exec2, changedFileSchema, changeRowSchema, secretName, capturePool, SHELL_TOOLS, NAMED, FILE_TOOLS, CaptureTimeout, failedRepository, Scratch, SCRATCH_AGE, REPOSITORY_TTL, NO_DIFF, CLAIM_RETENTION, PENDING_FOR, BUDGET, DAY, ToolChanges;
|
|
28071
28058
|
var init_changes = __esm({
|
|
28072
28059
|
"src/bridge/changes.ts"() {
|
|
28073
28060
|
"use strict";
|
|
@@ -28096,6 +28083,104 @@ var init_changes = __esm({
|
|
|
28096
28083
|
SHELL_TOOLS = /* @__PURE__ */ new Set(["Bash", "bash", "shell", "Shell", "exec_command", "shell_command", "local_shell", "write_stdin"]);
|
|
28097
28084
|
NAMED = /(?<![\w@:/])(?:~\/|\.\/|\/)[\w.@+~-]+(?:\/[\w.@+~-]+)*/g;
|
|
28098
28085
|
FILE_TOOLS = /* @__PURE__ */ new Set(["write", "edit", "multiedit", "notebookedit", "apply_patch", "str_replace_editor", "create_file", "replace_string_in_file", "multi_replace_string_in_file"]);
|
|
28086
|
+
CaptureTimeout = class extends Error {
|
|
28087
|
+
};
|
|
28088
|
+
failedRepository = /* @__PURE__ */ Symbol("failed-repository");
|
|
28089
|
+
Scratch = class {
|
|
28090
|
+
constructor(repo, dir, closing, settled4) {
|
|
28091
|
+
this.repo = repo;
|
|
28092
|
+
this.dir = dir;
|
|
28093
|
+
this.closing = closing;
|
|
28094
|
+
this.settled = settled4;
|
|
28095
|
+
this.env = { GIT_OBJECT_DIRECTORY: path18.join(dir, "objects"), GIT_ALTERNATE_OBJECT_DIRECTORIES: JSON.stringify(repo.objects), GIT_INDEX_FILE: path18.join(dir, "index") };
|
|
28096
|
+
}
|
|
28097
|
+
repo;
|
|
28098
|
+
dir;
|
|
28099
|
+
closing;
|
|
28100
|
+
settled;
|
|
28101
|
+
env;
|
|
28102
|
+
born = Date.now();
|
|
28103
|
+
/** Snapshots holding a tree whose objects live here. */
|
|
28104
|
+
users = 0;
|
|
28105
|
+
retired = false;
|
|
28106
|
+
created;
|
|
28107
|
+
reads = 0;
|
|
28108
|
+
running;
|
|
28109
|
+
next;
|
|
28110
|
+
get busy() {
|
|
28111
|
+
return !!(this.running || this.next);
|
|
28112
|
+
}
|
|
28113
|
+
/** The working tree as read no earlier than this call: the read already
|
|
28114
|
+
* running may have started before the caller's tool ran or finished, so a
|
|
28115
|
+
* caller arriving then waits for the next one, shared with later arrivals.
|
|
28116
|
+
* A read every caller gave up on is stopped. */
|
|
28117
|
+
tree(signal) {
|
|
28118
|
+
let read = this.next;
|
|
28119
|
+
if (!read && this.running) {
|
|
28120
|
+
const queued = this.next = { waiting: 0, controller: new AbortController(), result: this.running.result.then(() => {
|
|
28121
|
+
}, () => {
|
|
28122
|
+
}).then(() => {
|
|
28123
|
+
this.next = void 0;
|
|
28124
|
+
return this.start(queued);
|
|
28125
|
+
}) };
|
|
28126
|
+
read = queued;
|
|
28127
|
+
}
|
|
28128
|
+
if (!read) {
|
|
28129
|
+
read = { waiting: 0, controller: new AbortController() };
|
|
28130
|
+
this.start(read);
|
|
28131
|
+
}
|
|
28132
|
+
if (read.controller.signal.aborted && read === this.next) read.controller = new AbortController();
|
|
28133
|
+
read.waiting++;
|
|
28134
|
+
return until(read.result, signal).catch((error62) => {
|
|
28135
|
+
if (signal.aborted && --read.waiting === 0) read.controller.abort();
|
|
28136
|
+
throw error62;
|
|
28137
|
+
});
|
|
28138
|
+
}
|
|
28139
|
+
start(read) {
|
|
28140
|
+
const signal = AbortSignal.any([this.closing, read.controller.signal]);
|
|
28141
|
+
this.running = read;
|
|
28142
|
+
const env = { ...this.env, GIT_INDEX_FILE: path18.join(this.dir, `index-${++this.reads}`) };
|
|
28143
|
+
read.result = capturePool.run(signal, async () => {
|
|
28144
|
+
await (this.created ??= mkdir5(path18.join(this.dir, "objects"), { recursive: true, mode: 448 }));
|
|
28145
|
+
try {
|
|
28146
|
+
await this.seed(env.GIT_INDEX_FILE);
|
|
28147
|
+
await git2(this.repo.root, ["add", "-A", "--", "."], env, signal);
|
|
28148
|
+
return (await git2(this.repo.root, ["write-tree"], env, signal)).trim();
|
|
28149
|
+
} finally {
|
|
28150
|
+
await unlink2(env.GIT_INDEX_FILE).catch(() => void 0);
|
|
28151
|
+
}
|
|
28152
|
+
}).catch((error62) => {
|
|
28153
|
+
if (!timedOut(error62)) this.retired = true;
|
|
28154
|
+
throw error62;
|
|
28155
|
+
}).finally(() => {
|
|
28156
|
+
if (this.running === read) this.running = void 0;
|
|
28157
|
+
this.settled();
|
|
28158
|
+
});
|
|
28159
|
+
read.result.catch(() => {
|
|
28160
|
+
});
|
|
28161
|
+
return read.result;
|
|
28162
|
+
}
|
|
28163
|
+
/** Both the index and all new blobs/trees stay in scratch storage. The real
|
|
28164
|
+
* object store is a read-only alternate, including for linked worktrees.
|
|
28165
|
+
* Every read starts from a fresh copy of the real index: one kept from the
|
|
28166
|
+
* last read would trust its own stat data, and miss a same-size rewrite that
|
|
28167
|
+
* restored the file's mtime within the second its ctime was recorded. */
|
|
28168
|
+
async seed(temp) {
|
|
28169
|
+
const index2 = this.repo.index;
|
|
28170
|
+
const real2 = await stat5(index2).catch((error62) => {
|
|
28171
|
+
if (error62.code !== "ENOENT") throw error62;
|
|
28172
|
+
return void 0;
|
|
28173
|
+
});
|
|
28174
|
+
if (real2 && await copyFile(index2, temp).then(() => true, (error62) => {
|
|
28175
|
+
if (error62.code !== "ENOENT") throw error62;
|
|
28176
|
+
return false;
|
|
28177
|
+
})) {
|
|
28178
|
+
await utimes(temp, real2.atimeMs / 1e3, real2.mtimeMs / 1e3 - 1);
|
|
28179
|
+
}
|
|
28180
|
+
}
|
|
28181
|
+
};
|
|
28182
|
+
SCRATCH_AGE = 10 * 6e4;
|
|
28183
|
+
REPOSITORY_TTL = 5 * 6e4;
|
|
28099
28184
|
NO_DIFF = ["diff", "--no-ext-diff", "--no-textconv", "--no-color"];
|
|
28100
28185
|
CLAIM_RETENTION = 10 * 6e4;
|
|
28101
28186
|
PENDING_FOR = 6e3;
|
|
@@ -28110,8 +28195,29 @@ var init_changes = __esm({
|
|
|
28110
28195
|
controllers = /* @__PURE__ */ new Set();
|
|
28111
28196
|
claims = [];
|
|
28112
28197
|
failures = /* @__PURE__ */ new Map();
|
|
28113
|
-
|
|
28114
|
-
|
|
28198
|
+
/** Conversation and repository root pairs already shown that Git could not capture changes. */
|
|
28199
|
+
reported = /* @__PURE__ */ new Set();
|
|
28200
|
+
repositories = /* @__PURE__ */ new Map();
|
|
28201
|
+
scratches = /* @__PURE__ */ new Map();
|
|
28202
|
+
closing = new AbortController();
|
|
28203
|
+
/** The failure to show on this call's row, if any. A capture that ran out of
|
|
28204
|
+
* time shows no changes rather than an error: a busy machine is not
|
|
28205
|
+
* something to act on per call, and repository Changes still has the
|
|
28206
|
+
* status. A broken capture (Git missing, a corrupt repository) shows on the
|
|
28207
|
+
* first call it hits in a conversation, not on every later one. A per-call
|
|
28208
|
+
* limit (too many files) shows on its own call. */
|
|
28209
|
+
failed(conversation, key4, error62, roots = []) {
|
|
28210
|
+
if (timedOut(error62)) return void 0;
|
|
28211
|
+
const failure2 = error62 instanceof BridgeError ? error62 : new BridgeError(503, "Git change capture failed. Refresh repository Changes for the current status.", { code: "git-capture-failed" });
|
|
28212
|
+
if (failure2.details?.code === "git-capture-failed") {
|
|
28213
|
+
const root = failureRoot(error62);
|
|
28214
|
+
const marks = root ? [`${conversation}\0${root}`] : roots.length ? [...new Set(roots)].map((entry2) => `${conversation}\0${entry2}`) : [`${conversation}\0`];
|
|
28215
|
+
if (marks.every((mark) => this.reported.has(mark))) return void 0;
|
|
28216
|
+
for (const mark of marks) {
|
|
28217
|
+
if (this.reported.size >= 512) this.reported.delete(this.reported.keys().next().value);
|
|
28218
|
+
this.reported.add(mark);
|
|
28219
|
+
}
|
|
28220
|
+
}
|
|
28115
28221
|
if (this.failures.size >= 512) this.failures.delete(this.failures.keys().next().value);
|
|
28116
28222
|
this.failures.set(key4, failure2);
|
|
28117
28223
|
return failure2;
|
|
@@ -28132,23 +28238,100 @@ var init_changes = __esm({
|
|
|
28132
28238
|
const timer = setTimeout(() => controller.abort(), this.budgetMs);
|
|
28133
28239
|
try {
|
|
28134
28240
|
return await work(controller.signal);
|
|
28241
|
+
} catch (error62) {
|
|
28242
|
+
throw controller.signal.aborted ? new CaptureTimeout() : error62;
|
|
28135
28243
|
} finally {
|
|
28136
28244
|
clearTimeout(timer);
|
|
28137
28245
|
this.controllers.delete(controller);
|
|
28246
|
+
controller.abort();
|
|
28138
28247
|
}
|
|
28139
28248
|
}
|
|
28140
28249
|
async discard(snapshot2) {
|
|
28141
28250
|
clearTimeout(snapshot2.expiry);
|
|
28142
|
-
|
|
28251
|
+
const trees = [...snapshot2.trees.values()];
|
|
28252
|
+
snapshot2.trees.clear();
|
|
28253
|
+
for (const tree of trees) {
|
|
28254
|
+
tree.scratch.users--;
|
|
28255
|
+
await this.sweep(tree.scratch);
|
|
28256
|
+
}
|
|
28143
28257
|
}
|
|
28144
28258
|
async close() {
|
|
28145
28259
|
for (const controller of this.controllers) controller.abort();
|
|
28260
|
+
for (const { lookup: lookup2 } of this.repositories.values()) lookup2.controller.abort();
|
|
28261
|
+
this.repositories.clear();
|
|
28262
|
+
this.closing.abort();
|
|
28146
28263
|
for (const snapshot2 of this.snapshots.values()) {
|
|
28147
28264
|
await snapshot2.result?.catch(() => {
|
|
28148
28265
|
});
|
|
28149
28266
|
await this.discard(snapshot2);
|
|
28150
28267
|
}
|
|
28151
28268
|
this.snapshots.clear();
|
|
28269
|
+
for (const scratch of this.scratches.values()) scratch.retired = true;
|
|
28270
|
+
await Promise.all([...this.scratches.values()].map((scratch) => this.sweep(scratch)));
|
|
28271
|
+
}
|
|
28272
|
+
/** The repository holding `target` (a file, a folder, or something not yet
|
|
28273
|
+
* created), confined to the user's home; undefined otherwise. Git is asked
|
|
28274
|
+
* once per checkout every few minutes, not once per path a command names. */
|
|
28275
|
+
async repositoryOf(target2, cwd, signal, home = homeDir()) {
|
|
28276
|
+
const absolute = target2 === "~" || target2.startsWith("~/") ? path18.join(home, target2.slice(1)) : path18.resolve(cwd, target2);
|
|
28277
|
+
let existing = absolute;
|
|
28278
|
+
while (!await stat5(existing).catch(() => void 0)) {
|
|
28279
|
+
const parent = path18.dirname(existing);
|
|
28280
|
+
if (parent === existing) return void 0;
|
|
28281
|
+
existing = parent;
|
|
28282
|
+
}
|
|
28283
|
+
const real2 = await realpath2(existing);
|
|
28284
|
+
home = await realpath2(home);
|
|
28285
|
+
if (real2 !== home && !real2.startsWith(home + path18.sep)) return void 0;
|
|
28286
|
+
const dir = (await stat5(real2)).isDirectory() ? real2 : path18.dirname(real2), checkout = await checkoutOf(dir);
|
|
28287
|
+
if (!checkout) return void 0;
|
|
28288
|
+
const now = Date.now(), known2 = this.repositories.get(checkout);
|
|
28289
|
+
if (known2 && now - known2.at < REPOSITORY_TTL && !known2.lookup.controller.signal.aborted) return this.awaitRepository(known2.lookup, signal);
|
|
28290
|
+
if (this.repositories.size >= 256) this.repositories.clear();
|
|
28291
|
+
const lookup2 = { waiting: 0, controller: new AbortController(), result: Promise.resolve(void 0) };
|
|
28292
|
+
this.repositories.set(checkout, { at: now, lookup: lookup2 });
|
|
28293
|
+
const repository6 = capturePool.run(lookup2.controller.signal, async () => {
|
|
28294
|
+
const [root, objects2, index2] = (await git2(dir, ["rev-parse", "--show-toplevel", "--git-path", "objects", "--git-path", "index"], {}, lookup2.controller.signal)).split(/\r?\n/);
|
|
28295
|
+
return { root: await realpath2(root), objects: await realpath2(path18.resolve(dir, objects2)), index: path18.resolve(dir, index2) };
|
|
28296
|
+
}).catch((error62) => {
|
|
28297
|
+
if (/not a git repository/.test(String(error62.stderr))) return void 0;
|
|
28298
|
+
if (this.repositories.get(checkout)?.lookup === lookup2) this.repositories.delete(checkout);
|
|
28299
|
+
throw error62;
|
|
28300
|
+
});
|
|
28301
|
+
lookup2.result = repository6;
|
|
28302
|
+
repository6.catch(() => {
|
|
28303
|
+
});
|
|
28304
|
+
return this.awaitRepository(lookup2, signal);
|
|
28305
|
+
}
|
|
28306
|
+
/** Wait for a shared repository lookup, dropping this caller's interest when
|
|
28307
|
+
* it gives up; the lookup is stopped only when no caller is left. */
|
|
28308
|
+
awaitRepository(lookup2, signal) {
|
|
28309
|
+
lookup2.waiting++;
|
|
28310
|
+
return until(lookup2.result, signal).finally(() => {
|
|
28311
|
+
if (--lookup2.waiting === 0 && signal.aborted) lookup2.controller.abort();
|
|
28312
|
+
});
|
|
28313
|
+
}
|
|
28314
|
+
/** The scratch a new snapshot of `repository` reads into. */
|
|
28315
|
+
scratchFor(repository6) {
|
|
28316
|
+
const now = Date.now();
|
|
28317
|
+
for (const scratch2 of this.scratches.values()) {
|
|
28318
|
+
if (scratch2.retired || now - scratch2.born > SCRATCH_AGE) {
|
|
28319
|
+
scratch2.retired = true;
|
|
28320
|
+
void this.sweep(scratch2);
|
|
28321
|
+
}
|
|
28322
|
+
}
|
|
28323
|
+
const current2 = this.scratches.get(repository6.root);
|
|
28324
|
+
if (current2 && !current2.retired) return current2;
|
|
28325
|
+
const dir = path18.join(bridgeRoot(), "changes-scratch", `repo-${randomBytes(8).toString("hex")}`);
|
|
28326
|
+
const scratch = new Scratch(repository6, dir, this.closing.signal, () => void this.sweep(scratch));
|
|
28327
|
+
this.scratches.set(repository6.root, scratch);
|
|
28328
|
+
return scratch;
|
|
28329
|
+
}
|
|
28330
|
+
/** Delete a retired scratch once nothing reads it or holds a tree in it. */
|
|
28331
|
+
async sweep(scratch) {
|
|
28332
|
+
if (!scratch.retired || scratch.users > 0 || scratch.busy) return;
|
|
28333
|
+
if (this.scratches.get(scratch.repo.root) === scratch) this.scratches.delete(scratch.repo.root);
|
|
28334
|
+
await rm2(scratch.dir, { recursive: true, force: true }).catch(() => void 0);
|
|
28152
28335
|
}
|
|
28153
28336
|
async before(conversation, toolUseId, cwd, command, input2 = {}) {
|
|
28154
28337
|
const key4 = `${conversation}\0${toolUseId}`;
|
|
@@ -28156,23 +28339,29 @@ var init_changes = __esm({
|
|
|
28156
28339
|
const claimed = await Promise.all(claimedPaths(input2, cwd).map(realPathOf));
|
|
28157
28340
|
this.claim(conversation, toolUseId, claimed);
|
|
28158
28341
|
if (this.snapshots.size >= 64 || this.snapshots.has(key4)) return;
|
|
28159
|
-
const snapshot2 = { at: Date.now(), conversation, own: new Set(claimed), trees: /* @__PURE__ */ new Map(), taking: true };
|
|
28342
|
+
const snapshot2 = { at: Date.now(), conversation, own: new Set(claimed), trees: /* @__PURE__ */ new Map(), roots: [], taking: true };
|
|
28160
28343
|
this.snapshots.set(key4, snapshot2);
|
|
28161
28344
|
try {
|
|
28162
|
-
await this.budget(
|
|
28345
|
+
await this.budget(async (signal) => {
|
|
28163
28346
|
await realpath2(cwd);
|
|
28164
|
-
const
|
|
28347
|
+
const repositories = /* @__PURE__ */ new Map();
|
|
28165
28348
|
for (const target2 of [cwd, phrenStoreRoot(), ...namedPaths(command, input2)]) {
|
|
28166
28349
|
signal.throwIfAborted();
|
|
28167
|
-
if (
|
|
28168
|
-
const
|
|
28169
|
-
if (
|
|
28170
|
-
}
|
|
28171
|
-
for (const root of roots) {
|
|
28172
|
-
snapshot2.trees.set(root, await scratchTree(root, signal));
|
|
28350
|
+
if (repositories.size >= 6) break;
|
|
28351
|
+
const repository6 = await this.repositoryOf(target2, cwd, signal);
|
|
28352
|
+
if (repository6) repositories.set(repository6.root, repository6);
|
|
28173
28353
|
}
|
|
28354
|
+
snapshot2.roots = [...repositories.keys()];
|
|
28355
|
+
await Promise.all([...repositories.values()].map(async (repository6) => {
|
|
28356
|
+
const tree = { scratch: this.scratchFor(repository6) };
|
|
28357
|
+
tree.scratch.users++;
|
|
28358
|
+
snapshot2.trees.set(repository6.root, tree);
|
|
28359
|
+
tree.hash = await tree.scratch.tree(signal).catch((error62) => {
|
|
28360
|
+
throw failedIn(error62, repository6.root);
|
|
28361
|
+
});
|
|
28362
|
+
}));
|
|
28174
28363
|
signal.throwIfAborted();
|
|
28175
|
-
})
|
|
28364
|
+
});
|
|
28176
28365
|
snapshot2.taking = false;
|
|
28177
28366
|
if (snapshot2.dropped) {
|
|
28178
28367
|
await this.discard(snapshot2);
|
|
@@ -28191,7 +28380,7 @@ var init_changes = __esm({
|
|
|
28191
28380
|
}, 30 * 6e4);
|
|
28192
28381
|
snapshot2.expiry.unref();
|
|
28193
28382
|
} catch (error62) {
|
|
28194
|
-
this.failed(key4, error62);
|
|
28383
|
+
this.failed(conversation, key4, error62, snapshot2.roots);
|
|
28195
28384
|
if (this.snapshots.get(key4) === snapshot2) this.snapshots.delete(key4);
|
|
28196
28385
|
await this.discard(snapshot2);
|
|
28197
28386
|
}
|
|
@@ -28213,8 +28402,8 @@ var init_changes = __esm({
|
|
|
28213
28402
|
if (paths.length && this.claims.length < 512) this.claims.push({ conversation, toolUseId, paths: new Set(paths), start: now });
|
|
28214
28403
|
}
|
|
28215
28404
|
/** Whether another conversation's call named this file while `snapshot` ran. */
|
|
28216
|
-
claimedElsewhere(snapshot2, file4,
|
|
28217
|
-
return this.claims.some((claim2) => claim2.conversation !== snapshot2.conversation && claim2.paths.has(file4) && claim2.start <=
|
|
28405
|
+
claimedElsewhere(snapshot2, file4, until2) {
|
|
28406
|
+
return this.claims.some((claim2) => claim2.conversation !== snapshot2.conversation && claim2.paths.has(file4) && claim2.start <= until2 && (claim2.end ?? until2) >= snapshot2.at);
|
|
28218
28407
|
}
|
|
28219
28408
|
async after(conversation, toolUseId) {
|
|
28220
28409
|
const key4 = `${conversation}\0${toolUseId}`, snapshot2 = this.snapshots.get(key4);
|
|
@@ -28229,29 +28418,43 @@ var init_changes = __esm({
|
|
|
28229
28418
|
try {
|
|
28230
28419
|
files = await snapshot2.result;
|
|
28231
28420
|
} catch (error62) {
|
|
28232
|
-
this.snapshots.
|
|
28233
|
-
|
|
28421
|
+
if (this.snapshots.get(key4) === snapshot2) {
|
|
28422
|
+
this.snapshots.delete(key4);
|
|
28423
|
+
this.failed(conversation, key4, error62, snapshot2.roots);
|
|
28424
|
+
}
|
|
28425
|
+
const failure2 = this.failures.get(key4);
|
|
28426
|
+
if (failure2) throw failure2;
|
|
28427
|
+
return;
|
|
28234
28428
|
}
|
|
28235
28429
|
if (this.snapshots.get(key4) === snapshot2) {
|
|
28236
28430
|
this.snapshots.delete(key4);
|
|
28237
28431
|
await this.record(conversation, toolUseId, files);
|
|
28432
|
+
for (const root of snapshot2.roots) this.reported.delete(`${conversation}\0${root}`);
|
|
28238
28433
|
}
|
|
28239
28434
|
}
|
|
28240
28435
|
async compute(snapshot2) {
|
|
28241
28436
|
try {
|
|
28242
28437
|
return await this.budget(async (signal) => {
|
|
28438
|
+
const trees = [...snapshot2.trees.entries()];
|
|
28439
|
+
const after2 = await Promise.all(trees.map(([root, tree]) => tree.scratch.tree(signal).catch((error62) => {
|
|
28440
|
+
throw failedIn(error62, root);
|
|
28441
|
+
})));
|
|
28243
28442
|
const files = await capturePool.run(signal, async () => {
|
|
28244
28443
|
const found = [];
|
|
28245
|
-
for (const [root,
|
|
28246
|
-
|
|
28444
|
+
for (const [i, [root, tree]] of trees.entries()) {
|
|
28445
|
+
try {
|
|
28446
|
+
found.push(...await treeDiff(root, tree.hash, after2[i], tree.scratch.env, signal));
|
|
28447
|
+
} catch (error62) {
|
|
28448
|
+
throw failedIn(error62, root);
|
|
28449
|
+
}
|
|
28247
28450
|
}
|
|
28248
28451
|
return found;
|
|
28249
28452
|
});
|
|
28250
|
-
const
|
|
28453
|
+
const until2 = Date.now();
|
|
28251
28454
|
const kept = [];
|
|
28252
28455
|
for (const file4 of files) {
|
|
28253
28456
|
const absolute = await realPathOf(path18.resolve(file4.root, file4.path));
|
|
28254
|
-
if (snapshot2.own.size ? snapshot2.own.has(absolute) : !this.claimedElsewhere(snapshot2, absolute,
|
|
28457
|
+
if (snapshot2.own.size ? snapshot2.own.has(absolute) : !this.claimedElsewhere(snapshot2, absolute, until2)) kept.push(file4);
|
|
28255
28458
|
}
|
|
28256
28459
|
return kept;
|
|
28257
28460
|
});
|
|
@@ -33507,7 +33710,7 @@ var require_websocket = __commonJS({
|
|
|
33507
33710
|
var http = __require("http");
|
|
33508
33711
|
var net2 = __require("net");
|
|
33509
33712
|
var tls = __require("tls");
|
|
33510
|
-
var { randomBytes:
|
|
33713
|
+
var { randomBytes: randomBytes12, createHash: createHash36 } = __require("crypto");
|
|
33511
33714
|
var { Duplex: Duplex2, Readable: Readable2 } = __require("stream");
|
|
33512
33715
|
var { URL: URL2 } = __require("url");
|
|
33513
33716
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -34058,7 +34261,7 @@ var require_websocket = __commonJS({
|
|
|
34058
34261
|
}
|
|
34059
34262
|
}
|
|
34060
34263
|
const defaultPort = isSecure ? 443 : 80;
|
|
34061
|
-
const key4 =
|
|
34264
|
+
const key4 = randomBytes12(16).toString("base64");
|
|
34062
34265
|
const request10 = isSecure ? https.request : http.request;
|
|
34063
34266
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
34064
34267
|
let perMessageDeflate;
|
|
@@ -35369,9 +35572,9 @@ __export(codex_servers_exports, {
|
|
|
35369
35572
|
serversInService: () => serversInService,
|
|
35370
35573
|
serviceCgroup: () => serviceCgroup
|
|
35371
35574
|
});
|
|
35372
|
-
import { randomBytes } from "node:crypto";
|
|
35575
|
+
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
35373
35576
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
35374
|
-
import { mkdir as mkdir8, mkdtemp
|
|
35577
|
+
import { mkdir as mkdir8, mkdtemp, readdir as readdir8, readFile as readFile14, rm as rm5 } from "node:fs/promises";
|
|
35375
35578
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
35376
35579
|
import path29 from "node:path";
|
|
35377
35580
|
function serviceCgroup(pid = "self") {
|
|
@@ -35535,7 +35738,7 @@ var init_codex_servers = __esm({
|
|
|
35535
35738
|
* flags) and the Hook learns it from `thread/started` (`awaitThread`). The
|
|
35536
35739
|
* caller `stop`s the server if the pane cannot start. */
|
|
35537
35740
|
async launch(place, options) {
|
|
35538
|
-
const serverId =
|
|
35741
|
+
const serverId = randomBytes2(6).toString("hex");
|
|
35539
35742
|
const directory = path29.join(codexServersRoot(), serverId);
|
|
35540
35743
|
const socket = path29.join(directory, "app.sock");
|
|
35541
35744
|
if (Buffer.byteLength(socket) > MAX_SOCKET_PATH) throw new Error(`The Codex server socket path is too long: ${socket}`);
|
|
@@ -35742,7 +35945,7 @@ var init_codex_servers = __esm({
|
|
|
35742
35945
|
await client.request("account/read", { refreshToken: true });
|
|
35743
35946
|
return;
|
|
35744
35947
|
}
|
|
35745
|
-
const directory = await
|
|
35948
|
+
const directory = await mkdtemp(path29.join(tmpdir2(), "phren-codex-auth-"));
|
|
35746
35949
|
const socket = path29.join(directory, "app.sock");
|
|
35747
35950
|
try {
|
|
35748
35951
|
const handle = await this.deps.spawn({ socketPath: socket, cwd: directory, replaceEnv: true, env: serverEnvironment(process.env, {}) });
|
|
@@ -37438,7 +37641,7 @@ var init_package_metadata = __esm({
|
|
|
37438
37641
|
__dirname = path35.dirname(fileURLToPath2(import.meta.url));
|
|
37439
37642
|
ROOT = path35.join(__dirname, "..");
|
|
37440
37643
|
PACKAGE_JSON_PATH = path35.join(ROOT, "package.json");
|
|
37441
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
37644
|
+
BUNDLED_VERSION = true ? "0.3.66" : "0.0.0";
|
|
37442
37645
|
PACKAGE_JSON = readPackageJson();
|
|
37443
37646
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
37444
37647
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -38287,6 +38490,7 @@ var init_scores = __esm({
|
|
|
38287
38490
|
init_governance();
|
|
38288
38491
|
init_utils();
|
|
38289
38492
|
init_logger();
|
|
38493
|
+
init_phren_paths();
|
|
38290
38494
|
}
|
|
38291
38495
|
});
|
|
38292
38496
|
|
|
@@ -41106,7 +41310,7 @@ var init_task_receipts = __esm({
|
|
|
41106
41310
|
// src/data/tasks.ts
|
|
41107
41311
|
import * as fs28 from "fs";
|
|
41108
41312
|
import * as path51 from "path";
|
|
41109
|
-
import { createHash as createHash14, randomBytes as
|
|
41313
|
+
import { createHash as createHash14, randomBytes as randomBytes3, randomUUID as randomUUID12 } from "crypto";
|
|
41110
41314
|
function formatClaim(claim2) {
|
|
41111
41315
|
return `Claimed: ${claim2.computer} ${claim2.at}${claim2.session ? ` session:${claim2.session}` : ""}`;
|
|
41112
41316
|
}
|
|
@@ -41219,7 +41423,7 @@ function parseContinuation(lines, idx) {
|
|
|
41219
41423
|
};
|
|
41220
41424
|
}
|
|
41221
41425
|
function newBid() {
|
|
41222
|
-
return
|
|
41426
|
+
return randomBytes3(4).toString("hex");
|
|
41223
41427
|
}
|
|
41224
41428
|
function stripBid(text5) {
|
|
41225
41429
|
const m = text5.match(METADATA_PATTERN);
|
|
@@ -43276,7 +43480,7 @@ function writeJsonFileUnlocked(filePath, data) {
|
|
|
43276
43480
|
fs34.mkdirSync(dir, { recursive: true });
|
|
43277
43481
|
const tmpPath = path57.join(dir, `.tmp-${crypto10.randomUUID()}`);
|
|
43278
43482
|
fs34.writeFileSync(tmpPath, JSON.stringify(data, null, 2) + "\n");
|
|
43279
|
-
|
|
43483
|
+
renameOverSync(tmpPath, filePath);
|
|
43280
43484
|
}
|
|
43281
43485
|
function getRuntimeHealth(phrenPath) {
|
|
43282
43486
|
const parsed = readJsonFile2(runtimeHealthFile(phrenPath), {});
|
|
@@ -43311,6 +43515,7 @@ var init_policy = __esm({
|
|
|
43311
43515
|
init_project_config();
|
|
43312
43516
|
init_profile_store();
|
|
43313
43517
|
init_hooks();
|
|
43518
|
+
init_phren_paths();
|
|
43314
43519
|
init_metadata();
|
|
43315
43520
|
init_citation();
|
|
43316
43521
|
init_policy_constants();
|
|
@@ -43493,7 +43698,7 @@ var init_client = __esm({
|
|
|
43493
43698
|
|
|
43494
43699
|
// src/bridge/peers.ts
|
|
43495
43700
|
import { spawn as spawn4 } from "node:child_process";
|
|
43496
|
-
import { lstat as lstat8, mkdtemp as
|
|
43701
|
+
import { lstat as lstat8, mkdtemp as mkdtemp2, readdir as readdir10, readFile as readFile17, rm as rm7, writeFile as writeFile3 } from "node:fs/promises";
|
|
43497
43702
|
import path58 from "node:path";
|
|
43498
43703
|
import { Duplex } from "node:stream";
|
|
43499
43704
|
async function hookPeers(root = bridgeRoot()) {
|
|
@@ -43627,7 +43832,7 @@ async function peerRequest(peer, route2, data, timeout) {
|
|
|
43627
43832
|
const info = await lstat8(key4).catch(() => void 0);
|
|
43628
43833
|
if (!info?.isFile() || info.isSymbolicLink() || info.mode & 63) throw new BridgeError(409, "Run phren bridge enroll-computer on this computer first (private key mode 0600).", { code: "dispatch-key-missing" });
|
|
43629
43834
|
sweepPeerTempsSometimes(root);
|
|
43630
|
-
const temporary = await
|
|
43835
|
+
const temporary = await mkdtemp2(path58.join(root, "peer-"));
|
|
43631
43836
|
let child, stream;
|
|
43632
43837
|
try {
|
|
43633
43838
|
const knownHosts = path58.join(temporary, "known_hosts");
|
|
@@ -43766,9 +43971,9 @@ var init_computer_names = __esm({
|
|
|
43766
43971
|
});
|
|
43767
43972
|
|
|
43768
43973
|
// src/bridge/schedule-format.ts
|
|
43769
|
-
import { randomBytes as
|
|
43974
|
+
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
43770
43975
|
import { readFile as readFile18 } from "node:fs/promises";
|
|
43771
|
-
import { mkdirSync as mkdirSync18, readFileSync as readFileSync36, renameSync as
|
|
43976
|
+
import { mkdirSync as mkdirSync18, readFileSync as readFileSync36, renameSync as renameSync8, unlinkSync as unlinkSync7, writeFileSync as writeFileSync21 } from "node:fs";
|
|
43772
43977
|
import path59 from "node:path";
|
|
43773
43978
|
function validateLocalTimestamp(value2) {
|
|
43774
43979
|
localTimestamp.parse(value2);
|
|
@@ -43879,10 +44084,10 @@ async function withScheduleLock(projectDir, work) {
|
|
|
43879
44084
|
function writeScheduleDocumentSync(projectDir, schedules, original = { version: 1 }) {
|
|
43880
44085
|
const text5 = serializeScheduleDocument(schedules, original), file4 = schedulePath(projectDir);
|
|
43881
44086
|
mkdirSync18(projectDir, { recursive: true, mode: 448 });
|
|
43882
|
-
const temporary = `${file4}.${
|
|
44087
|
+
const temporary = `${file4}.${randomBytes5(8).toString("hex")}.tmp`;
|
|
43883
44088
|
try {
|
|
43884
44089
|
writeFileSync21(temporary, text5, { mode: 384, flag: "wx" });
|
|
43885
|
-
|
|
44090
|
+
renameSync8(temporary, file4);
|
|
43886
44091
|
} finally {
|
|
43887
44092
|
try {
|
|
43888
44093
|
unlinkSync7(temporary);
|
|
@@ -45450,8 +45655,8 @@ async function moveSession(input2, options = {}) {
|
|
|
45450
45655
|
...data.resume ? { continuation: "resume" } : {}
|
|
45451
45656
|
})).move);
|
|
45452
45657
|
if (data.wait !== false && typeof move.id === "string") {
|
|
45453
|
-
const
|
|
45454
|
-
while (!settled4(move) && Date.now() <
|
|
45658
|
+
const until2 = Date.now() + (options.waitMs ?? MOVE_WAIT_MS);
|
|
45659
|
+
while (!settled4(move) && Date.now() < until2) {
|
|
45455
45660
|
await new Promise((resolve17) => setTimeout(resolve17, options.pollMs ?? 3e3));
|
|
45456
45661
|
move = await read(String(move.id)).catch(() => move);
|
|
45457
45662
|
}
|
|
@@ -45462,8 +45667,8 @@ async function moveSession(input2, options = {}) {
|
|
|
45462
45667
|
function claudeAccountRooms(answer2, computer, now = Date.now()) {
|
|
45463
45668
|
const window2 = (room) => {
|
|
45464
45669
|
if (!room) return void 0;
|
|
45465
|
-
const
|
|
45466
|
-
return { ...room, ...
|
|
45670
|
+
const until2 = room.resetsAt ? resetsIn(room.resetsAt, now) : void 0;
|
|
45671
|
+
return { ...room, ...until2 ? { resetsIn: until2 } : {} };
|
|
45467
45672
|
};
|
|
45468
45673
|
return objects(answer2.accounts).filter((row) => row.source === "claude" && Array.isArray(row.windows)).map((row) => {
|
|
45469
45674
|
const usage = row;
|
|
@@ -49222,13 +49427,13 @@ function claudeRooms(inventory, usage, now) {
|
|
|
49222
49427
|
const row = usage.find((item) => item.source === "claude" && (item.account?.id ?? DEFAULT_ACCOUNT) === account2.id);
|
|
49223
49428
|
const windows = row ? accountWindows(row, now) : {};
|
|
49224
49429
|
const out = [windows.fiveHour, windows.week].filter((w) => w?.leftPercent === 0);
|
|
49225
|
-
const
|
|
49430
|
+
const until2 = out.map((w) => w?.resetsAt).filter((value2) => Boolean(value2)).sort().at(-1);
|
|
49226
49431
|
return {
|
|
49227
49432
|
account: account2.id,
|
|
49228
49433
|
...account2.key ? { key: account2.key } : {},
|
|
49229
49434
|
usable: account2.usable,
|
|
49230
49435
|
...windows,
|
|
49231
|
-
...out.length ? { exhausted: true, ...
|
|
49436
|
+
...out.length ? { exhausted: true, ...until2 ? { until: until2 } : {} } : {}
|
|
49232
49437
|
};
|
|
49233
49438
|
});
|
|
49234
49439
|
}
|
|
@@ -49243,9 +49448,9 @@ async function readAccountLimits(now = Date.now()) {
|
|
|
49243
49448
|
}
|
|
49244
49449
|
function noteAccountLimit(entry2, now = Date.now()) {
|
|
49245
49450
|
const run5 = ledgerWrites.then(async () => {
|
|
49246
|
-
const
|
|
49451
|
+
const until2 = entry2.until && Date.parse(entry2.until) > now ? entry2.until : new Date(now + UNKNOWN_RESET_MS).toISOString();
|
|
49247
49452
|
const kept = (await readAccountLimits(now)).filter((item) => item.key !== entry2.key);
|
|
49248
|
-
await atomic(limitsFile(), { limits: [...kept, { key: entry2.key, account: entry2.account, until, at: new Date(now).toISOString() }].slice(-64) });
|
|
49453
|
+
await atomic(limitsFile(), { limits: [...kept, { key: entry2.key, account: entry2.account, until: until2, at: new Date(now).toISOString() }].slice(-64) });
|
|
49249
49454
|
});
|
|
49250
49455
|
ledgerWrites = run5.catch(() => void 0);
|
|
49251
49456
|
return run5;
|
|
@@ -49957,6 +50162,15 @@ async function readClaudeToken(execSecurity = exec10, platform = process.platfor
|
|
|
49957
50162
|
return void 0;
|
|
49958
50163
|
}
|
|
49959
50164
|
}
|
|
50165
|
+
function oneRowPerLogin(rows2) {
|
|
50166
|
+
const at2 = (row) => row.windows.length ? Date.parse(row.updatedAt ?? "") || 0 : -1;
|
|
50167
|
+
const best = /* @__PURE__ */ new Map();
|
|
50168
|
+
for (const row of rows2) {
|
|
50169
|
+
const key4 = row.account?.key;
|
|
50170
|
+
if (key4 && (!best.has(key4) || at2(row) > at2(best.get(key4)))) best.set(key4, row);
|
|
50171
|
+
}
|
|
50172
|
+
return rows2.filter((row) => !row.account?.key || rows2.find((other) => other.account?.key === row.account.key) === row).map((row) => row.account?.key ? { ...best.get(row.account.key), account: row.account } : row);
|
|
50173
|
+
}
|
|
49960
50174
|
async function fetchClaudeUsage(token, fetchImpl = fetch, now = /* @__PURE__ */ new Date()) {
|
|
49961
50175
|
const controller = new AbortController();
|
|
49962
50176
|
const timer = setTimeout(() => controller.abort(), 8e3);
|
|
@@ -50116,13 +50330,13 @@ function capacityRoom(accounts, now) {
|
|
|
50116
50330
|
const left3 = direct.map((window2) => windowLeft(window2, now)).filter((value2) => value2 !== void 0);
|
|
50117
50331
|
if (pool2.left !== void 0) left3.push(pool2.left);
|
|
50118
50332
|
const out = direct.filter((window2) => windowExhausted(window2, now));
|
|
50119
|
-
const
|
|
50333
|
+
const until2 = out.map((window2) => window2.resetsAt).filter((value2) => Boolean(value2)).sort().at(-1);
|
|
50120
50334
|
const exhausted = out.length > 0 || pool2.exhausted;
|
|
50121
50335
|
return {
|
|
50122
50336
|
source: usage.source,
|
|
50123
50337
|
...usage.account?.id ? { account: usage.account.id } : {},
|
|
50124
50338
|
...left3.length ? { leftPercent: Math.min(...left3) } : {},
|
|
50125
|
-
...exhausted ? { exhausted: true, ...
|
|
50339
|
+
...exhausted ? { exhausted: true, ...until2 ? { until: until2 } : {} } : {},
|
|
50126
50340
|
...usage.source === "claude" ? accountWindows(usage, now) : {}
|
|
50127
50341
|
};
|
|
50128
50342
|
});
|
|
@@ -50273,7 +50487,7 @@ var init_usage = __esm({
|
|
|
50273
50487
|
this.limits(allAccounts),
|
|
50274
50488
|
this.spending(sources?.has("copilot") ?? true, sources?.has("elevenlabs") ?? true)
|
|
50275
50489
|
]);
|
|
50276
|
-
return { accounts: [...limits, ...spending] };
|
|
50490
|
+
return { accounts: [...oneRowPerLogin(limits), ...spending] };
|
|
50277
50491
|
}
|
|
50278
50492
|
/** Codex and every Claude home, without the spend readers: what a dispatch capacity probe asks. */
|
|
50279
50493
|
async limits(allAccounts = true) {
|
|
@@ -51544,7 +51758,7 @@ var init_install = __esm({
|
|
|
51544
51758
|
|
|
51545
51759
|
// src/bridge/computers.ts
|
|
51546
51760
|
import { execFile as execFile17 } from "node:child_process";
|
|
51547
|
-
import { chmod as chmod3, lstat as lstat19, mkdir as mkdir18, mkdtemp as
|
|
51761
|
+
import { chmod as chmod3, lstat as lstat19, mkdir as mkdir18, mkdtemp as mkdtemp3, readFile as readFile30, rename as rename5, rm as rm9, writeFile as writeFile5 } from "node:fs/promises";
|
|
51548
51762
|
import { homedir as homedir13 } from "node:os";
|
|
51549
51763
|
import path87 from "node:path";
|
|
51550
51764
|
import { promisify as promisify15 } from "node:util";
|
|
@@ -51582,7 +51796,7 @@ async function enrollComputer(name, root = bridgeRoot()) {
|
|
|
51582
51796
|
try {
|
|
51583
51797
|
const key4 = dispatchKeyPath(root);
|
|
51584
51798
|
if (!await regularFile(key4)) {
|
|
51585
|
-
const temporary = await
|
|
51799
|
+
const temporary = await mkdtemp3(path87.join(root, "enroll-"));
|
|
51586
51800
|
try {
|
|
51587
51801
|
const generated = path87.join(temporary, "key");
|
|
51588
51802
|
await exec12("ssh-keygen", ["-q", "-t", "ed25519", "-N", "", "-C", "phren-computer", "-f", generated], { timeout: 1e4 });
|
|
@@ -52723,8 +52937,8 @@ function roomFor(data, usage) {
|
|
|
52723
52937
|
const account2 = data.account ?? "default";
|
|
52724
52938
|
return usage?.find((item) => item.source === data.harness && (data.harness !== "claude" || (item.account ?? "default") === account2));
|
|
52725
52939
|
}
|
|
52726
|
-
function backIn(
|
|
52727
|
-
const at2 =
|
|
52940
|
+
function backIn(until2, now) {
|
|
52941
|
+
const at2 = until2 ? Date.parse(until2) : NaN;
|
|
52728
52942
|
const minutes = Number.isFinite(at2) ? Math.max(1, Math.round((at2 - now) / 6e4)) : void 0;
|
|
52729
52943
|
return minutes === void 0 ? "" : minutes >= 1440 ? ` for about ${Math.round(minutes / 1440)} more days` : minutes >= 60 ? ` for about ${Math.round(minutes / 60)} more hours` : ` for about ${minutes} more minutes`;
|
|
52730
52944
|
}
|
|
@@ -54855,7 +55069,7 @@ Open or changed files are named in the conversation above and the checked Git st
|
|
|
54855
55069
|
if (launched.linkPending || !launched.target || !("session" in launched.target)) throw new Error("The new conductor conversation is not linked; the hand-over was not confirmed.");
|
|
54856
55070
|
const confirmedTarget = launched.target;
|
|
54857
55071
|
let accepted = false;
|
|
54858
|
-
for (const
|
|
55072
|
+
for (const until2 = this.now + 3e4; this.now < until2; await this.sleep(this.poll)) {
|
|
54859
55073
|
const arrival = (await briefArrival(record4.id))?.accepted?.target;
|
|
54860
55074
|
if (arrival && Object.keys(confirmedTarget).every((key4) => arrival[key4] === confirmedTarget[key4])) {
|
|
54861
55075
|
accepted = true;
|
|
@@ -55223,12 +55437,12 @@ Open or changed files are named in the conversation above and the checked Git st
|
|
|
55223
55437
|
const from = record4.from.target;
|
|
55224
55438
|
const exitMs = this.deps.exitMs ?? 2e4;
|
|
55225
55439
|
const gone = async (ms2) => {
|
|
55226
|
-
const
|
|
55440
|
+
const until2 = this.now + ms2;
|
|
55227
55441
|
for (; ; ) {
|
|
55228
55442
|
const pane2 = findPane(await this.deps.snapshot(from.server), placeOf(from));
|
|
55229
55443
|
if (!pane2) throw new BridgeError(409, "The pane closed while the old agent exited; nothing was started.");
|
|
55230
55444
|
if (pane2.agent !== from.source) return true;
|
|
55231
|
-
if (this.now >=
|
|
55445
|
+
if (this.now >= until2) return false;
|
|
55232
55446
|
await this.sleep(Math.min(this.poll, 500));
|
|
55233
55447
|
}
|
|
55234
55448
|
};
|
|
@@ -55336,7 +55550,7 @@ Open or changed files are named in the conversation above and the checked Git st
|
|
|
55336
55550
|
const place = { server, workspace: String(launched.workspaceId), tab: String(launched.tabId), pane: String(launched.paneId), source };
|
|
55337
55551
|
const newChat = record4.mode === "new-chat";
|
|
55338
55552
|
if (newChat) await this.update(record4, { state: "linking" });
|
|
55339
|
-
for (const
|
|
55553
|
+
for (const until2 = this.now + (newChat ? 18e4 : 3e4); this.now < until2; await this.sleep(this.poll)) {
|
|
55340
55554
|
const pane = findPane(await this.deps.snapshot(server).catch(() => ({})), place);
|
|
55341
55555
|
const session = pane && pane.agent === source ? await this.deps.identity(server, pane).catch(() => void 0) : void 0;
|
|
55342
55556
|
const target2 = targetSchema.safeParse({ ...place, session });
|
|
@@ -55387,7 +55601,7 @@ __export(herdr_exports, {
|
|
|
55387
55601
|
validateTarget: () => validateTarget,
|
|
55388
55602
|
workspaceSnapshot: () => workspaceSnapshot
|
|
55389
55603
|
});
|
|
55390
|
-
import { createHmac as createHmac2, randomBytes as
|
|
55604
|
+
import { createHmac as createHmac2, randomBytes as randomBytes6 } from "node:crypto";
|
|
55391
55605
|
import { execFile as execFile19 } from "node:child_process";
|
|
55392
55606
|
import { connect as connect2 } from "node:net";
|
|
55393
55607
|
import { homedir as homedir14 } from "node:os";
|
|
@@ -55892,10 +56106,10 @@ var init_herdr = __esm({
|
|
|
55892
56106
|
copilotHome2 = () => process.env.COPILOT_HOME || path93.join(homedir14(), ".copilot");
|
|
55893
56107
|
rolloutIds = (files) => files.flatMap((file4) => /rollout-.*-([a-f0-9-]{36})\.jsonl$/i.exec(file4)?.[1] ?? []);
|
|
55894
56108
|
paneCwd = (pane) => pane.foreground_cwd || pane.cwd;
|
|
55895
|
-
startingKey =
|
|
56109
|
+
startingKey = randomBytes6(32);
|
|
55896
56110
|
startingBindings = /* @__PURE__ */ new Map();
|
|
55897
56111
|
startingPaneKey = (server, pane) => JSON.stringify([server, pane.workspace_id, pane.tab_id, pane.pane_id, pane.terminal_id, pane.agent]);
|
|
55898
|
-
startingToken = (process2) => createHmac2("sha256", startingKey).update(process2).update(
|
|
56112
|
+
startingToken = (process2) => createHmac2("sha256", startingKey).update(process2).update(randomBytes6(32)).digest("hex");
|
|
55899
56113
|
sharedIdentities = /* @__PURE__ */ new WeakMap();
|
|
55900
56114
|
}
|
|
55901
56115
|
});
|
|
@@ -56014,7 +56228,7 @@ __export(sudo_exports, {
|
|
|
56014
56228
|
verifyAsker: () => verifyAsker
|
|
56015
56229
|
});
|
|
56016
56230
|
import { execFile as execFile20 } from "node:child_process";
|
|
56017
|
-
import { randomBytes as
|
|
56231
|
+
import { randomBytes as randomBytes7, randomUUID as randomUUID21, timingSafeEqual } from "node:crypto";
|
|
56018
56232
|
import { EventEmitter } from "node:events";
|
|
56019
56233
|
import { existsSync as existsSync36, readlinkSync } from "node:fs";
|
|
56020
56234
|
import { open as open15, readdir as readdir16, readFile as readFile35, readlink as readlink2, unlink as unlink4 } from "node:fs/promises";
|
|
@@ -56175,7 +56389,7 @@ function deliveryFrom(value2) {
|
|
|
56175
56389
|
return typeof item.socket === "string" && DELIVERY_SOCKET.test(item.socket) && typeof item.nonce === "string" && DELIVERY_NONCE.test(item.nonce) ? { socket: item.socket, nonce: item.nonce } : void 0;
|
|
56176
56390
|
}
|
|
56177
56391
|
function newDelivery() {
|
|
56178
|
-
return { socket: `phren-askpass-${
|
|
56392
|
+
return { socket: `phren-askpass-${randomBytes7(16).toString("hex")}`, nonce: randomBytes7(32).toString("hex") };
|
|
56179
56393
|
}
|
|
56180
56394
|
async function listeningInode(name, table2 = () => readFile35("/proc/net/unix", "utf8")) {
|
|
56181
56395
|
const text5 = await table2().catch(() => "");
|
|
@@ -57300,8 +57514,8 @@ async function hostJson(url2, request10) {
|
|
|
57300
57514
|
signal: AbortSignal.timeout(request10.timeoutMs ?? 15e3)
|
|
57301
57515
|
});
|
|
57302
57516
|
} catch (error62) {
|
|
57303
|
-
const
|
|
57304
|
-
throw new HostApiError("unreachable",
|
|
57517
|
+
const timedOut2 = error62 instanceof Error && (error62.name === "TimeoutError" || error62.name === "AbortError");
|
|
57518
|
+
throw new HostApiError("unreachable", timedOut2 ? `${new URL(url2).host} did not answer within ${Math.round((request10.timeoutMs ?? 15e3) / 1e3)} seconds.` : `Could not reach ${new URL(url2).host}.`);
|
|
57305
57519
|
}
|
|
57306
57520
|
if (response.status >= 300 && response.status < 400) throw new HostApiError("failed", `${new URL(url2).host} redirected the API call; set its API address with git config phren.<domain>.api <url>.`, response.status);
|
|
57307
57521
|
const text5 = await response.text();
|
|
@@ -58201,7 +58415,7 @@ var init_git = __esm({
|
|
|
58201
58415
|
import { spawn as spawn10 } from "node:child_process";
|
|
58202
58416
|
function runCombined(command, args, cwd, timeout, extraEnv = {}, killGraceMs = KILL_GRACE_MS2) {
|
|
58203
58417
|
return new Promise((resolve17) => {
|
|
58204
|
-
let output2 = "", truncated = false,
|
|
58418
|
+
let output2 = "", truncated = false, timedOut2 = false, settled4 = false;
|
|
58205
58419
|
let deadline;
|
|
58206
58420
|
const finish = (run5) => {
|
|
58207
58421
|
if (settled4) return;
|
|
@@ -58250,7 +58464,7 @@ function runCombined(command, args, cwd, timeout, extraEnv = {}, killGraceMs = K
|
|
|
58250
58464
|
}
|
|
58251
58465
|
};
|
|
58252
58466
|
const timer = setTimeout(() => {
|
|
58253
|
-
|
|
58467
|
+
timedOut2 = true;
|
|
58254
58468
|
kill("SIGTERM");
|
|
58255
58469
|
setTimeout(escalate, killGraceMs).unref();
|
|
58256
58470
|
deadline = setTimeout(() => {
|
|
@@ -58265,7 +58479,7 @@ function runCombined(command, args, cwd, timeout, extraEnv = {}, killGraceMs = K
|
|
|
58265
58479
|
});
|
|
58266
58480
|
child.on("close", (code) => {
|
|
58267
58481
|
clearTimeout(timer);
|
|
58268
|
-
finish({ code, output: output2.trimEnd(), missing: false, timedOut });
|
|
58482
|
+
finish({ code, output: output2.trimEnd(), missing: false, timedOut: timedOut2 });
|
|
58269
58483
|
});
|
|
58270
58484
|
});
|
|
58271
58485
|
}
|
|
@@ -61365,7 +61579,7 @@ var init_git_sync = __esm({
|
|
|
61365
61579
|
});
|
|
61366
61580
|
|
|
61367
61581
|
// src/bridge/git-review.ts
|
|
61368
|
-
import { mkdtemp as
|
|
61582
|
+
import { mkdtemp as mkdtemp4, rm as rm12, writeFile as writeFile6 } from "node:fs/promises";
|
|
61369
61583
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
61370
61584
|
import path103 from "node:path";
|
|
61371
61585
|
async function repository4(cwd) {
|
|
@@ -61457,7 +61671,7 @@ async function gitApply(cwd, rawPatch, reverse) {
|
|
|
61457
61671
|
const root = await repository4(cwd);
|
|
61458
61672
|
const [file4] = patchFiles(rawPatch);
|
|
61459
61673
|
await repositoryPath(root, file4);
|
|
61460
|
-
const scratch = await
|
|
61674
|
+
const scratch = await mkdtemp4(path103.join(tmpdir5(), "phren-apply-"));
|
|
61461
61675
|
const patchFile = path103.join(scratch, "hunk.patch");
|
|
61462
61676
|
try {
|
|
61463
61677
|
await writeFile6(patchFile, rawPatch.endsWith("\n") ? rawPatch : rawPatch + "\n", { mode: 384 });
|
|
@@ -61772,7 +61986,7 @@ var init_conductor_context = __esm({
|
|
|
61772
61986
|
});
|
|
61773
61987
|
|
|
61774
61988
|
// src/bridge/push.ts
|
|
61775
|
-
import { createCipheriv, createHmac as createHmac4, createPrivateKey, randomBytes as
|
|
61989
|
+
import { createCipheriv, createHmac as createHmac4, createPrivateKey, randomBytes as randomBytes8, sign } from "node:crypto";
|
|
61776
61990
|
import { readFile as readFile43, stat as stat24 } from "node:fs/promises";
|
|
61777
61991
|
import { connect as connect3 } from "node:http2";
|
|
61778
61992
|
import path106 from "node:path";
|
|
@@ -61875,7 +62089,7 @@ function upsertPushDevice(devices, value2) {
|
|
|
61875
62089
|
const device = deviceSchema.parse(value2);
|
|
61876
62090
|
return [...devices.filter((item) => item.deviceID !== device.deviceID), device].slice(-16);
|
|
61877
62091
|
}
|
|
61878
|
-
function relayCiphertext(key4, payload, nonce =
|
|
62092
|
+
function relayCiphertext(key4, payload, nonce = randomBytes8(12)) {
|
|
61879
62093
|
const aps = payload.aps ?? {};
|
|
61880
62094
|
let body2 = aps.alert?.body ?? "";
|
|
61881
62095
|
for (; ; ) {
|
|
@@ -66254,7 +66468,7 @@ var init_file_range = __esm({
|
|
|
66254
66468
|
});
|
|
66255
66469
|
|
|
66256
66470
|
// src/bridge/file-write.ts
|
|
66257
|
-
import { randomBytes as
|
|
66471
|
+
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
66258
66472
|
import { constants as constants4 } from "node:fs";
|
|
66259
66473
|
import { lstat as lstat33, open as open23, realpath as realpath18, rename as rename8, rm as rm13 } from "node:fs/promises";
|
|
66260
66474
|
import path116 from "node:path";
|
|
@@ -66317,7 +66531,7 @@ async function writeRepoFileNow(root, requested, content, expectedVersion) {
|
|
|
66317
66531
|
}
|
|
66318
66532
|
if (!existing) throw new BridgeError(409, "The file is gone. It changed since you opened it.", { code: "file-changed" });
|
|
66319
66533
|
if (fileVersion(existing) !== expectedVersion) throw new BridgeError(409, "The file changed since you opened it.", { code: "file-changed" });
|
|
66320
|
-
const temporary = path116.join(directory, `.${parts[parts.length - 1]}.phren-${
|
|
66534
|
+
const temporary = path116.join(directory, `.${parts[parts.length - 1]}.phren-${randomBytes10(6).toString("hex")}.tmp`);
|
|
66321
66535
|
try {
|
|
66322
66536
|
const handle = await open23(temporary, constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL | constants4.O_NOFOLLOW, existing.mode & 511);
|
|
66323
66537
|
try {
|
|
@@ -67507,7 +67721,7 @@ __export(launcher_exports, {
|
|
|
67507
67721
|
writeManifest: () => writeManifest2
|
|
67508
67722
|
});
|
|
67509
67723
|
import { spawn as spawn12, execFileSync as execFileSync6 } from "node:child_process";
|
|
67510
|
-
import { randomBytes as
|
|
67724
|
+
import { randomBytes as randomBytes11 } from "node:crypto";
|
|
67511
67725
|
import * as fs45 from "node:fs";
|
|
67512
67726
|
import * as path120 from "node:path";
|
|
67513
67727
|
function jobsRoot(store) {
|
|
@@ -67563,7 +67777,7 @@ function createJob(options, env = process.env, nearest = nearestAgent) {
|
|
|
67563
67777
|
if (!options.label.trim() || options.label.length > 200) throw new Error("Choose a label of 1 to 200 characters.");
|
|
67564
67778
|
const worktree = fs45.realpathSync(options.worktree);
|
|
67565
67779
|
if (!fs45.statSync(worktree).isDirectory()) throw new Error("Choose a worktree directory.");
|
|
67566
|
-
const id2 = `${options.provider}-${
|
|
67780
|
+
const id2 = `${options.provider}-${randomBytes11(12).toString("hex")}`;
|
|
67567
67781
|
const root = jobsRoot(options.store), job = path120.join(root, id2);
|
|
67568
67782
|
fs45.mkdirSync(job, { recursive: true, mode: 448 });
|
|
67569
67783
|
fs45.chmodSync(root, 448);
|
|
@@ -67596,7 +67810,7 @@ async function launch(options, reservation = createJob(options)) {
|
|
|
67596
67810
|
const { job, manifest } = reservation, adapter = adapters[options.provider];
|
|
67597
67811
|
console.log(job);
|
|
67598
67812
|
const out = fs45.openSync(path120.join(job, manifest.eventLog), "a"), err = fs45.openSync(path120.join(job, "stderr.log"), "a");
|
|
67599
|
-
const password =
|
|
67813
|
+
const password = randomBytes11(24).toString("hex");
|
|
67600
67814
|
const child = spawn12("nice", ["-n", "15", adapter.command, ...adapter.argv({ ...options, job })], {
|
|
67601
67815
|
cwd: manifest.worktree,
|
|
67602
67816
|
env: {
|
|
@@ -71445,7 +71659,7 @@ var init_resources = __esm({
|
|
|
71445
71659
|
});
|
|
71446
71660
|
|
|
71447
71661
|
// src/bridge/canary.ts
|
|
71448
|
-
import { lstat as lstat35, mkdtemp as
|
|
71662
|
+
import { lstat as lstat35, mkdtemp as mkdtemp5, realpath as realpath20, rm as rm16 } from "node:fs/promises";
|
|
71449
71663
|
import { hostname as hostname11, tmpdir as tmpdir7 } from "node:os";
|
|
71450
71664
|
import path129 from "node:path";
|
|
71451
71665
|
function reason2(error62) {
|
|
@@ -71482,7 +71696,7 @@ async function closeCanaryWorkspaces(server, before, created) {
|
|
|
71482
71696
|
}
|
|
71483
71697
|
async function conductorStep(options, server) {
|
|
71484
71698
|
const before = new Set(objects((await snapshot(server)).workspaces).map((workspace) => String(workspace.workspace_id)));
|
|
71485
|
-
const folder = await realpath20(await
|
|
71699
|
+
const folder = await realpath20(await mkdtemp5(path129.join(tmpdir7(), "phren-canary-")));
|
|
71486
71700
|
let created, failure2, detail;
|
|
71487
71701
|
try {
|
|
71488
71702
|
const launched = await options.launch(server, { role: "conductor", kind: "claude", label: CANARY_LABEL, cwd: folder, timeoutMs: 45e3 });
|
|
@@ -71786,7 +72000,7 @@ var init_launch_worktree = __esm({
|
|
|
71786
72000
|
});
|
|
71787
72001
|
|
|
71788
72002
|
// src/bridge/server-launch.ts
|
|
71789
|
-
import { mkdir as mkdir33, mkdtemp as
|
|
72003
|
+
import { mkdir as mkdir33, mkdtemp as mkdtemp6, readFile as readFile53, realpath as realpath22, rmdir as rmdir2 } from "node:fs/promises";
|
|
71790
72004
|
import path132 from "node:path";
|
|
71791
72005
|
function effortArgs(kind, effort) {
|
|
71792
72006
|
if (kind === "claude") return ["--effort", effort];
|
|
@@ -72097,7 +72311,7 @@ async function startSession(server, data, options) {
|
|
|
72097
72311
|
const agents = path132.join(runtime, "agents");
|
|
72098
72312
|
await mkdir33(agents, { recursive: true, mode: 448 });
|
|
72099
72313
|
if (await realpath22(agents) !== agents) throw new BridgeError(403, "The agents folder must be inside the Phren directory.");
|
|
72100
|
-
scratch = await
|
|
72314
|
+
scratch = await mkdtemp6(path132.join(agents, `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}-${herdrAgentName(label2)}-`));
|
|
72101
72315
|
}
|
|
72102
72316
|
const cwd = scratch ?? worktree?.cwd ?? projectDirectory;
|
|
72103
72317
|
if (scratch || worktree || options.trustFolder) await pretrustFolder(
|
|
@@ -73736,7 +73950,7 @@ var init_file_resolve = __esm({
|
|
|
73736
73950
|
|
|
73737
73951
|
// src/content/citation-freshness.ts
|
|
73738
73952
|
import { execFileSync as execFileSync9 } from "node:child_process";
|
|
73739
|
-
import { readFileSync as readFileSync56, realpathSync as realpathSync7, renameSync as
|
|
73953
|
+
import { readFileSync as readFileSync56, realpathSync as realpathSync7, renameSync as renameSync11, statSync as statSync28, unlinkSync as unlinkSync8, writeFileSync as writeFileSync24 } from "node:fs";
|
|
73740
73954
|
import path141 from "node:path";
|
|
73741
73955
|
import { randomUUID as randomUUID31 } from "node:crypto";
|
|
73742
73956
|
function git8(root, timeoutMs, ...args) {
|
|
@@ -73849,7 +74063,7 @@ function save2(file4, entries2) {
|
|
|
73849
74063
|
const sorted = Object.entries(merged).filter(([, value2]) => Date.now() - Date.parse(value2.checkedAt) <= ("value" in value2 ? RESOLUTION_TTL : RETENTION)).sort((a, b) => Date.parse(b[1].checkedAt) - Date.parse(a[1].checkedAt)).slice(0, 5e3);
|
|
73850
74064
|
const saved = Object.fromEntries(sorted);
|
|
73851
74065
|
writeFileSync24(temp, JSON.stringify(saved), { mode: 384 });
|
|
73852
|
-
|
|
74066
|
+
renameSync11(temp, file4);
|
|
73853
74067
|
rememberCache(file4, saved);
|
|
73854
74068
|
} catch {
|
|
73855
74069
|
} finally {
|
|
@@ -82843,7 +83057,7 @@ async function main() {
|
|
|
82843
83057
|
return askpass2(args[1]);
|
|
82844
83058
|
}
|
|
82845
83059
|
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
|
|
82846
|
-
return runBridge2(args, "0.3.
|
|
83060
|
+
return runBridge2(args, "0.3.66");
|
|
82847
83061
|
}
|
|
82848
83062
|
main().then((code) => {
|
|
82849
83063
|
process.exitCode = code;
|