@phren/cli 0.3.46 → 0.3.47
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/codex-auth-refresh.d.ts +7 -0
- package/dist/bridge/codex-auth-refresh.js +15 -0
- package/dist/bridge/git-write-policy.d.ts +13 -0
- package/dist/bridge/git-write-policy.js +39 -0
- package/dist/bridge/schedule-format.d.ts +4 -1
- package/dist/bridge/schedule-format.js +40 -3
- package/dist/bridge/schedule-update.d.ts +6 -0
- package/dist/bridge/schedule-update.js +63 -0
- package/dist/bridge/schedules.js +16 -4
- package/dist/bridge/server-pane-routes.d.ts +4 -2
- package/dist/bridge/server-pane-routes.js +8 -2
- package/dist/bridge/server-routes.js +14 -4
- package/dist/bridge-hook.mjs +307 -109
- package/dist/cli/actions.js +4 -0
- package/dist/mcp/profile.js +23 -4
- package/dist/modules/registry.js +2 -2
- package/dist/task/lifecycle.js +3 -2
- package/package.json +1 -1
package/dist/bridge-hook.mjs
CHANGED
|
@@ -386,10 +386,10 @@ function mergeDefs(...defs) {
|
|
|
386
386
|
function cloneDef(schema) {
|
|
387
387
|
return mergeDefs(schema._zod.def);
|
|
388
388
|
}
|
|
389
|
-
function getElementAtPath(obj3,
|
|
390
|
-
if (!
|
|
389
|
+
function getElementAtPath(obj3, path146) {
|
|
390
|
+
if (!path146)
|
|
391
391
|
return obj3;
|
|
392
|
-
return
|
|
392
|
+
return path146.reduce((acc, key4) => acc?.[key4], obj3);
|
|
393
393
|
}
|
|
394
394
|
function promiseAllObject(promisesObj) {
|
|
395
395
|
const keys2 = Object.keys(promisesObj);
|
|
@@ -648,11 +648,11 @@ function explicitlyAborted(x2, startIndex = 0) {
|
|
|
648
648
|
}
|
|
649
649
|
return false;
|
|
650
650
|
}
|
|
651
|
-
function prefixIssues(
|
|
651
|
+
function prefixIssues(path146, issues) {
|
|
652
652
|
return issues.map((iss) => {
|
|
653
653
|
var _a3;
|
|
654
654
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
655
|
-
iss.path.unshift(
|
|
655
|
+
iss.path.unshift(path146);
|
|
656
656
|
return iss;
|
|
657
657
|
});
|
|
658
658
|
}
|
|
@@ -1173,16 +1173,16 @@ function flattenError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
1175
1175
|
const fieldErrors = { _errors: [] };
|
|
1176
|
-
const processError = (error63,
|
|
1176
|
+
const processError = (error63, path146 = []) => {
|
|
1177
1177
|
for (const issue2 of error63.issues) {
|
|
1178
1178
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1179
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1179
|
+
issue2.errors.map((issues) => processError({ issues }, [...path146, ...issue2.path]));
|
|
1180
1180
|
} else if (issue2.code === "invalid_key") {
|
|
1181
|
-
processError({ issues: issue2.issues }, [...
|
|
1181
|
+
processError({ issues: issue2.issues }, [...path146, ...issue2.path]);
|
|
1182
1182
|
} else if (issue2.code === "invalid_element") {
|
|
1183
|
-
processError({ issues: issue2.issues }, [...
|
|
1183
|
+
processError({ issues: issue2.issues }, [...path146, ...issue2.path]);
|
|
1184
1184
|
} else {
|
|
1185
|
-
const fullpath = [...
|
|
1185
|
+
const fullpath = [...path146, ...issue2.path];
|
|
1186
1186
|
if (fullpath.length === 0) {
|
|
1187
1187
|
fieldErrors._errors.push(mapper(issue2));
|
|
1188
1188
|
} else {
|
|
@@ -1221,17 +1221,17 @@ function formatError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
1223
1223
|
const result = { errors: [] };
|
|
1224
|
-
const processError = (error63,
|
|
1224
|
+
const processError = (error63, path146 = []) => {
|
|
1225
1225
|
var _a3;
|
|
1226
1226
|
for (const issue2 of error63.issues) {
|
|
1227
1227
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
1228
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
1228
|
+
issue2.errors.map((issues) => processError({ issues }, [...path146, ...issue2.path]));
|
|
1229
1229
|
} else if (issue2.code === "invalid_key") {
|
|
1230
|
-
processError({ issues: issue2.issues }, [...
|
|
1230
|
+
processError({ issues: issue2.issues }, [...path146, ...issue2.path]);
|
|
1231
1231
|
} else if (issue2.code === "invalid_element") {
|
|
1232
|
-
processError({ issues: issue2.issues }, [...
|
|
1232
|
+
processError({ issues: issue2.issues }, [...path146, ...issue2.path]);
|
|
1233
1233
|
} else {
|
|
1234
|
-
const fullpath = [...
|
|
1234
|
+
const fullpath = [...path146, ...issue2.path];
|
|
1235
1235
|
if (fullpath.length === 0) {
|
|
1236
1236
|
result.errors.push(mapper(issue2));
|
|
1237
1237
|
continue;
|
|
@@ -1270,8 +1270,8 @@ function treeifyError(error62, mapper = (issue2) => issue2.message) {
|
|
|
1270
1270
|
}
|
|
1271
1271
|
function toDotPath(_path) {
|
|
1272
1272
|
const segs = [];
|
|
1273
|
-
const
|
|
1274
|
-
for (const seg of
|
|
1273
|
+
const path146 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
1274
|
+
for (const seg of path146) {
|
|
1275
1275
|
if (typeof seg === "number")
|
|
1276
1276
|
segs.push(`[${seg}]`);
|
|
1277
1277
|
else if (typeof seg === "symbol")
|
|
@@ -16755,8 +16755,8 @@ var init_json_schema_processors = __esm({
|
|
|
16755
16755
|
let minItems = def.items.length;
|
|
16756
16756
|
while (minItems > 0) {
|
|
16757
16757
|
const item = def.items[minItems - 1];
|
|
16758
|
-
const
|
|
16759
|
-
if (!
|
|
16758
|
+
const optional3 = ctx.io === "input" ? inputOptin(item) !== void 0 : item._zod.optout === "optional";
|
|
16759
|
+
if (!optional3)
|
|
16760
16760
|
break;
|
|
16761
16761
|
minItems--;
|
|
16762
16762
|
}
|
|
@@ -19267,13 +19267,13 @@ function resolveRef(ref, ctx) {
|
|
|
19267
19267
|
if (!ref.startsWith("#")) {
|
|
19268
19268
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
19269
19269
|
}
|
|
19270
|
-
const
|
|
19271
|
-
if (
|
|
19270
|
+
const path146 = ref.slice(1).split("/").filter(Boolean);
|
|
19271
|
+
if (path146.length === 0) {
|
|
19272
19272
|
return ctx.rootSchema;
|
|
19273
19273
|
}
|
|
19274
19274
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
19275
|
-
if (
|
|
19276
|
-
const key4 =
|
|
19275
|
+
if (path146[0] === defsKey) {
|
|
19276
|
+
const key4 = path146[1] === void 0 ? void 0 : decodeJSONPointerSegment(path146[1]);
|
|
19277
19277
|
if (!key4 || !ctx.defs[key4]) {
|
|
19278
19278
|
throw new Error(`Reference not found: ${ref}`);
|
|
19279
19279
|
}
|
|
@@ -32292,7 +32292,7 @@ var require_websocket = __commonJS({
|
|
|
32292
32292
|
var http = __require("http");
|
|
32293
32293
|
var net2 = __require("net");
|
|
32294
32294
|
var tls = __require("tls");
|
|
32295
|
-
var { randomBytes:
|
|
32295
|
+
var { randomBytes: randomBytes11, createHash: createHash32 } = __require("crypto");
|
|
32296
32296
|
var { Duplex: Duplex2, Readable: Readable2 } = __require("stream");
|
|
32297
32297
|
var { URL: URL2 } = __require("url");
|
|
32298
32298
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -32843,7 +32843,7 @@ var require_websocket = __commonJS({
|
|
|
32843
32843
|
}
|
|
32844
32844
|
}
|
|
32845
32845
|
const defaultPort = isSecure ? 443 : 80;
|
|
32846
|
-
const key4 =
|
|
32846
|
+
const key4 = randomBytes11(16).toString("base64");
|
|
32847
32847
|
const request9 = isSecure ? https.request : http.request;
|
|
32848
32848
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
32849
32849
|
let perMessageDeflate;
|
|
@@ -38000,7 +38000,7 @@ var init_package_metadata = __esm({
|
|
|
38000
38000
|
__dirname = path37.dirname(fileURLToPath2(import.meta.url));
|
|
38001
38001
|
ROOT = path37.join(__dirname, "..");
|
|
38002
38002
|
PACKAGE_JSON_PATH = path37.join(ROOT, "package.json");
|
|
38003
|
-
BUNDLED_VERSION = true ? "0.3.
|
|
38003
|
+
BUNDLED_VERSION = true ? "0.3.47" : "0.0.0";
|
|
38004
38004
|
PACKAGE_JSON = readPackageJson();
|
|
38005
38005
|
PACKAGE_NAME = PACKAGE_JSON.name || "phren";
|
|
38006
38006
|
VERSION = PACKAGE_JSON.version || BUNDLED_VERSION;
|
|
@@ -38975,7 +38975,7 @@ var init_registry = __esm({
|
|
|
38975
38975
|
init_package_metadata();
|
|
38976
38976
|
core = (names) => names.map((name) => ({ name, profiles: ["core", "full"] }));
|
|
38977
38977
|
full = (names) => names.map((name) => ({ name, profiles: ["full"] }));
|
|
38978
|
-
routes = (method, paths) => paths.map((
|
|
38978
|
+
routes = (method, paths) => paths.map((path146) => ({ method, path: path146 }));
|
|
38979
38979
|
BUILTIN_MODULES = [
|
|
38980
38980
|
{
|
|
38981
38981
|
schemaVersion: 1,
|
|
@@ -39369,8 +39369,8 @@ var init_registry = __esm({
|
|
|
39369
39369
|
tools: [],
|
|
39370
39370
|
cliCommands: ["schedule"],
|
|
39371
39371
|
agentHooks: [],
|
|
39372
|
-
hookRoutes: routes("POST", ["/v1/schedules", "/v1/schedules/run", "/v1/schedules/history"]),
|
|
39373
|
-
capabilities: ["schedules", "scheduleProjects"],
|
|
39372
|
+
hookRoutes: routes("POST", ["/v1/schedules", "/v1/schedules/run", "/v1/schedules/history", "/v1/schedules/update"]),
|
|
39373
|
+
capabilities: ["schedules", "scheduleProjects", "scheduleUpdate"],
|
|
39374
39374
|
storeFiles: ["<project>/schedules.yaml", ".runtime/agent-fanouts/<run-id>/**"],
|
|
39375
39375
|
localFiles: ["<bridge>/schedule-runs.jsonl"],
|
|
39376
39376
|
phoneScreens: [{ screen: "SchedulesView", capability: "schedules" }],
|
|
@@ -42481,7 +42481,9 @@ var init_computer_names = __esm({
|
|
|
42481
42481
|
});
|
|
42482
42482
|
|
|
42483
42483
|
// src/bridge/schedule-format.ts
|
|
42484
|
+
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
42484
42485
|
import { readFile as readFile27 } from "node:fs/promises";
|
|
42486
|
+
import { mkdirSync as mkdirSync11, readFileSync as readFileSync25, renameSync as renameSync7, unlinkSync as unlinkSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
42485
42487
|
import path56 from "node:path";
|
|
42486
42488
|
function validateLocalTimestamp(value2) {
|
|
42487
42489
|
localTimestamp.parse(value2);
|
|
@@ -42543,6 +42545,19 @@ async function readScheduleDocument(projectDir) {
|
|
|
42543
42545
|
if (error62.code === "ENOENT") return { document: { version: 1 }, schedules: [] };
|
|
42544
42546
|
throw error62;
|
|
42545
42547
|
}
|
|
42548
|
+
return parseScheduleDocument(text5);
|
|
42549
|
+
}
|
|
42550
|
+
function readScheduleDocumentSync(projectDir) {
|
|
42551
|
+
let text5;
|
|
42552
|
+
try {
|
|
42553
|
+
text5 = readFileSync25(schedulePath(projectDir), "utf8");
|
|
42554
|
+
} catch (error62) {
|
|
42555
|
+
if (error62.code === "ENOENT") return { document: { version: 1 }, schedules: [] };
|
|
42556
|
+
throw error62;
|
|
42557
|
+
}
|
|
42558
|
+
return parseScheduleDocument(text5);
|
|
42559
|
+
}
|
|
42560
|
+
function parseScheduleDocument(text5) {
|
|
42546
42561
|
const document = object2(load(text5, { schema: CORE_SCHEMA }));
|
|
42547
42562
|
if (document.version !== 1) throw new Error("schedules.yaml must have version: 1.");
|
|
42548
42563
|
if (!Array.isArray(document.schedules)) throw new Error("schedules.yaml must contain a schedules list.");
|
|
@@ -42551,11 +42566,49 @@ async function readScheduleDocument(projectDir) {
|
|
|
42551
42566
|
if (new Set(schedules.map((item) => item.id)).size !== schedules.length) throw new Error("Schedule IDs must be unique within a project.");
|
|
42552
42567
|
return { document, schedules };
|
|
42553
42568
|
}
|
|
42554
|
-
async function
|
|
42569
|
+
async function withScheduleLock(projectDir, work) {
|
|
42570
|
+
const file4 = path56.resolve(schedulePath(projectDir));
|
|
42571
|
+
const previous = scheduleQueues.get(file4) ?? Promise.resolve();
|
|
42572
|
+
const next = previous.catch(() => void 0).then(async () => {
|
|
42573
|
+
const deadline = Date.now() + SCHEDULE_LOCK_WAIT_MS;
|
|
42574
|
+
let release = tryFileLock(file4);
|
|
42575
|
+
while (!release) {
|
|
42576
|
+
if (Date.now() >= deadline) throw new Error("schedules.yaml is being changed elsewhere. Try again.");
|
|
42577
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
42578
|
+
release = tryFileLock(file4);
|
|
42579
|
+
}
|
|
42580
|
+
try {
|
|
42581
|
+
const result = work();
|
|
42582
|
+
return result instanceof Promise ? await result : result;
|
|
42583
|
+
} finally {
|
|
42584
|
+
release();
|
|
42585
|
+
}
|
|
42586
|
+
});
|
|
42587
|
+
scheduleQueues.set(file4, next);
|
|
42588
|
+
try {
|
|
42589
|
+
return await next;
|
|
42590
|
+
} finally {
|
|
42591
|
+
if (scheduleQueues.get(file4) === next) scheduleQueues.delete(file4);
|
|
42592
|
+
}
|
|
42593
|
+
}
|
|
42594
|
+
function writeScheduleDocumentSync(projectDir, schedules, original = { version: 1 }) {
|
|
42595
|
+
const text5 = serializeScheduleDocument(schedules, original), file4 = schedulePath(projectDir);
|
|
42596
|
+
mkdirSync11(projectDir, { recursive: true, mode: 448 });
|
|
42597
|
+
const temporary = `${file4}.${randomBytes4(8).toString("hex")}.tmp`;
|
|
42598
|
+
try {
|
|
42599
|
+
writeFileSync11(temporary, text5, { mode: 384, flag: "wx" });
|
|
42600
|
+
renameSync7(temporary, file4);
|
|
42601
|
+
} finally {
|
|
42602
|
+
try {
|
|
42603
|
+
unlinkSync4(temporary);
|
|
42604
|
+
} catch {
|
|
42605
|
+
}
|
|
42606
|
+
}
|
|
42607
|
+
}
|
|
42608
|
+
function serializeScheduleDocument(schedules, original) {
|
|
42555
42609
|
if (schedules.length > MAX_SCHEDULES) throw new Error(`A project can have at most ${MAX_SCHEDULES} schedules.`);
|
|
42556
42610
|
schedules.forEach(parseSchedule);
|
|
42557
|
-
|
|
42558
|
-
await atomicInPrivateDir(schedulePath(projectDir), text5);
|
|
42611
|
+
return dump({ ...original, version: 1, schedules }, { lineWidth: 1e3, noRefs: true, sortKeys: false });
|
|
42559
42612
|
}
|
|
42560
42613
|
function canonicalComputer(value2) {
|
|
42561
42614
|
const normalized = value2.trim().toLowerCase();
|
|
@@ -42712,7 +42765,7 @@ async function writeScheduleRuns(file4, runs) {
|
|
|
42712
42765
|
function scheduleRunsFile() {
|
|
42713
42766
|
return path56.join(bridgeRoot(), "schedule-runs.jsonl");
|
|
42714
42767
|
}
|
|
42715
|
-
var SCHEDULE_EVERY, SCHEDULE_HARNESSES, SCHEDULE_NOTIFY, WEEKDAYS, SCHEDULE_SESSIONS, SCHEDULE_RUN_STATUSES, scheduleId, plain, singleLine, scheduleName, timestamp2, localTimestamp, clockTime, schedulePath, runningStatuses, MAX_SCHEDULES, MAX_RUNS, REUSE_PANES;
|
|
42768
|
+
var SCHEDULE_EVERY, SCHEDULE_HARNESSES, SCHEDULE_NOTIFY, WEEKDAYS, SCHEDULE_SESSIONS, SCHEDULE_RUN_STATUSES, scheduleId, plain, singleLine, scheduleName, timestamp2, localTimestamp, clockTime, schedulePath, runningStatuses, MAX_SCHEDULES, MAX_RUNS, scheduleQueues, SCHEDULE_LOCK_WAIT_MS, REUSE_PANES;
|
|
42716
42769
|
var init_schedule_format = __esm({
|
|
42717
42770
|
"src/bridge/schedule-format.ts"() {
|
|
42718
42771
|
"use strict";
|
|
@@ -42739,6 +42792,8 @@ var init_schedule_format = __esm({
|
|
|
42739
42792
|
runningStatuses = /* @__PURE__ */ new Set(["launched", "running", "blocked"]);
|
|
42740
42793
|
MAX_SCHEDULES = 64;
|
|
42741
42794
|
MAX_RUNS = 2e3;
|
|
42795
|
+
scheduleQueues = /* @__PURE__ */ new Map();
|
|
42796
|
+
SCHEDULE_LOCK_WAIT_MS = 5e3;
|
|
42742
42797
|
REUSE_PANES = 8;
|
|
42743
42798
|
}
|
|
42744
42799
|
});
|
|
@@ -43239,10 +43294,10 @@ function projectAgents(values, parent, receipt, fallbackComputer, fallbackTarget
|
|
|
43239
43294
|
for (const value2 of values.slice(0, 128)) {
|
|
43240
43295
|
if (state.count >= 128) break;
|
|
43241
43296
|
const raw = object2(value2), id2 = childID.safeParse(raw.id), source = provider.safeParse(raw.provider);
|
|
43242
|
-
const
|
|
43297
|
+
const path146 = publicLabel(raw.path);
|
|
43243
43298
|
const callId = typeof raw.callId === "string" && raw.callId.length > 0 && raw.callId.length <= 200 ? raw.callId : void 0;
|
|
43244
43299
|
const routed = destination(raw, fallbackComputer, fallbackTarget);
|
|
43245
|
-
if (!id2.success || !source.success || !
|
|
43300
|
+
if (!id2.success || !source.success || !path146 || !callId || !routed) continue;
|
|
43246
43301
|
const descendant = lineage ? `${lineage}/${id2.data}` : id2.data;
|
|
43247
43302
|
const nestedSession = sessionId.safeParse(raw.session);
|
|
43248
43303
|
const cycleIdentity = nestedSession.success ? nestedSession.data : routed.remote.child ?? routed.remote.target.session;
|
|
@@ -43255,7 +43310,7 @@ function projectAgents(values, parent, receipt, fallbackComputer, fallbackTarget
|
|
|
43255
43310
|
projected.push({
|
|
43256
43311
|
id: publicID(parent, routed.computer.id, receipt.id, descendant),
|
|
43257
43312
|
provider: source.data,
|
|
43258
|
-
path:
|
|
43313
|
+
path: path146,
|
|
43259
43314
|
callId,
|
|
43260
43315
|
state: raw.failed === true ? "failed" : childState,
|
|
43261
43316
|
...typeof raw.finishedAt === "string" && Number.isFinite(Date.parse(raw.finishedAt)) ? { finishedAt: raw.finishedAt } : {},
|
|
@@ -44027,7 +44082,7 @@ var init_conductor_group = __esm({
|
|
|
44027
44082
|
});
|
|
44028
44083
|
|
|
44029
44084
|
// src/bridge/conductor-role.ts
|
|
44030
|
-
import { lstatSync as lstatSync2, readFileSync as
|
|
44085
|
+
import { lstatSync as lstatSync2, readFileSync as readFileSync26 } from "node:fs";
|
|
44031
44086
|
import path60 from "node:path";
|
|
44032
44087
|
async function readRoleState() {
|
|
44033
44088
|
const file4 = roleFile();
|
|
@@ -44035,7 +44090,7 @@ async function readRoleState() {
|
|
|
44035
44090
|
let text5;
|
|
44036
44091
|
try {
|
|
44037
44092
|
const info = lstatSync2(file4);
|
|
44038
|
-
text5 = info.isFile() && info.size <= 65536 ?
|
|
44093
|
+
text5 = info.isFile() && info.size <= 65536 ? readFileSync26(file4, "utf8") : "";
|
|
44039
44094
|
} catch {
|
|
44040
44095
|
text5 = void 0;
|
|
44041
44096
|
}
|
|
@@ -47552,7 +47607,7 @@ var init_schedules = __esm({
|
|
|
47552
47607
|
const projectDir = this.projectDirectory(projectName2), project = path68.basename(projectDir);
|
|
47553
47608
|
const file4 = await readScheduleDocument(projectDir), schedule = file4.schedules.find((item) => item.id === id2);
|
|
47554
47609
|
if (!schedule) throw new BridgeError(404, `Schedule "${id2}" was not found in ${project}.`);
|
|
47555
|
-
if (expectedUpdatedAt !== void 0 &&
|
|
47610
|
+
if (expectedUpdatedAt !== void 0 && expectedUpdatedAt !== schedule.updatedAt) {
|
|
47556
47611
|
throw new BridgeError(409, "This computer has a different schedule revision. Wait for store sync to finish, refresh the schedule, and try Run now again.");
|
|
47557
47612
|
}
|
|
47558
47613
|
if (!this.owns(schedule)) throw new BridgeError(409, `${schedule.computer} owns this schedule; run it from that computer.`);
|
|
@@ -47592,9 +47647,21 @@ var init_schedules = __esm({
|
|
|
47592
47647
|
await writeScheduleRuns(this.runsFile, [...runs, ...children.map((child) => child.run)]);
|
|
47593
47648
|
for (const child of children) this.own.add(child.run.id);
|
|
47594
47649
|
if (schedule.every === "once" && schedule.enabled) {
|
|
47595
|
-
const schedules = file4.schedules.map((item) => item.id === id2 ? { ...item, enabled: false, updatedAt: startedAt2 } : item);
|
|
47596
47650
|
try {
|
|
47597
|
-
await
|
|
47651
|
+
await withScheduleLock(projectDir, () => {
|
|
47652
|
+
const current2 = readScheduleDocumentSync(projectDir);
|
|
47653
|
+
const schedules = current2.document.schedules ?? [];
|
|
47654
|
+
const index2 = schedules.findIndex((item) => item.id === id2);
|
|
47655
|
+
if (index2 < 0) return;
|
|
47656
|
+
const occurrence = schedules[index2];
|
|
47657
|
+
if (occurrence.every !== "once" || occurrence.once !== schedule.once || occurrence.updatedAt !== schedule.updatedAt) return;
|
|
47658
|
+
schedules[index2] = {
|
|
47659
|
+
...schedules[index2],
|
|
47660
|
+
enabled: false,
|
|
47661
|
+
updatedAt: new Date(Math.max(this.now().getTime(), Date.parse(schedules[index2].updatedAt) + 1)).toISOString()
|
|
47662
|
+
};
|
|
47663
|
+
writeScheduleDocumentSync(projectDir, schedules, current2.document);
|
|
47664
|
+
});
|
|
47598
47665
|
} catch (error62) {
|
|
47599
47666
|
this.log(`[schedule] Could not disable consumed once schedule ${project}/${id2}: ${String(error62)}`);
|
|
47600
47667
|
}
|
|
@@ -49442,7 +49509,7 @@ var init_task_format = __esm({
|
|
|
49442
49509
|
// src/bridge/memory-store.ts
|
|
49443
49510
|
import { execFile as execFile16, spawn as spawn8 } from "node:child_process";
|
|
49444
49511
|
import { createHash as createHash21 } from "node:crypto";
|
|
49445
|
-
import { mkdirSync as
|
|
49512
|
+
import { mkdirSync as mkdirSync17, readFileSync as readFileSync33, renameSync as renameSync10, unlinkSync as unlinkSync7, writeFileSync as writeFileSync15 } from "node:fs";
|
|
49446
49513
|
import { lstat as lstat21, mkdir as mkdir21, realpath as realpath11 } from "node:fs/promises";
|
|
49447
49514
|
import path75 from "node:path";
|
|
49448
49515
|
import { promisify as promisify14 } from "node:util";
|
|
@@ -49630,7 +49697,7 @@ function lockedStoreFile(file4, rel, work) {
|
|
|
49630
49697
|
}
|
|
49631
49698
|
function currentShaSync(file4) {
|
|
49632
49699
|
try {
|
|
49633
|
-
return blobSha(
|
|
49700
|
+
return blobSha(readFileSync33(file4));
|
|
49634
49701
|
} catch (error62) {
|
|
49635
49702
|
if (error62.code === "ENOENT") return null;
|
|
49636
49703
|
throw error62;
|
|
@@ -49644,10 +49711,10 @@ function putStoreFile(store, data) {
|
|
|
49644
49711
|
const file4 = await storeFile(store, input2.path);
|
|
49645
49712
|
lockedStoreFile(file4, input2.path, () => {
|
|
49646
49713
|
if (currentShaSync(file4) !== (input2.sha ?? null)) throw new BridgeError(409, `${input2.path} changed on this computer.`);
|
|
49647
|
-
|
|
49714
|
+
mkdirSync17(path75.dirname(file4), { recursive: true });
|
|
49648
49715
|
const temporary = `${file4}.phren-${process.pid}-${Date.now()}`;
|
|
49649
|
-
|
|
49650
|
-
|
|
49716
|
+
writeFileSync15(temporary, content, { flag: "wx" });
|
|
49717
|
+
renameSync10(temporary, file4);
|
|
49651
49718
|
});
|
|
49652
49719
|
return { content: { sha: blobSha(content), path: input2.path }, commit: { sha: blobSha(content) } };
|
|
49653
49720
|
});
|
|
@@ -49658,7 +49725,7 @@ function deleteStoreFile(store, data) {
|
|
|
49658
49725
|
const file4 = await storeFile(store, input2.path);
|
|
49659
49726
|
lockedStoreFile(file4, input2.path, () => {
|
|
49660
49727
|
if (currentShaSync(file4) !== input2.sha) throw new BridgeError(409, `${input2.path} changed on this computer.`);
|
|
49661
|
-
|
|
49728
|
+
unlinkSync7(file4);
|
|
49662
49729
|
});
|
|
49663
49730
|
return { ok: true };
|
|
49664
49731
|
});
|
|
@@ -49889,7 +49956,7 @@ var init_task_receipts = __esm({
|
|
|
49889
49956
|
// src/data/tasks.ts
|
|
49890
49957
|
import * as fs32 from "fs";
|
|
49891
49958
|
import * as path79 from "path";
|
|
49892
|
-
import { createHash as createHash22, randomBytes as
|
|
49959
|
+
import { createHash as createHash22, randomBytes as randomBytes5, randomUUID as randomUUID18 } from "crypto";
|
|
49893
49960
|
function formatClaim(claim2) {
|
|
49894
49961
|
return `Claimed: ${claim2.computer} ${claim2.at}${claim2.session ? ` session:${claim2.session}` : ""}`;
|
|
49895
49962
|
}
|
|
@@ -50002,7 +50069,7 @@ function parseContinuation(lines, idx) {
|
|
|
50002
50069
|
};
|
|
50003
50070
|
}
|
|
50004
50071
|
function newBid() {
|
|
50005
|
-
return
|
|
50072
|
+
return randomBytes5(4).toString("hex");
|
|
50006
50073
|
}
|
|
50007
50074
|
function stripBid(text5) {
|
|
50008
50075
|
const m = text5.match(METADATA_PATTERN);
|
|
@@ -54160,6 +54227,48 @@ var init_hand_off_queue = __esm({
|
|
|
54160
54227
|
}
|
|
54161
54228
|
});
|
|
54162
54229
|
|
|
54230
|
+
// src/bridge/git-write-policy.ts
|
|
54231
|
+
function clientIdentity(headers) {
|
|
54232
|
+
const clean5 = (value2) => (Array.isArray(value2) ? value2.join(", ") : value2 ?? "").replace(/[\x00-\x1f\x7f]/g, " ").trim().slice(0, 200);
|
|
54233
|
+
const client = clean5(headers["x-phren-client"]);
|
|
54234
|
+
const version2 = clean5(headers["x-phren-app-version"] || headers["x-phren-client-version"]);
|
|
54235
|
+
const agent = clean5(headers["user-agent"]);
|
|
54236
|
+
return [client, version2, agent].filter(Boolean).join(" / ") || "unknown client";
|
|
54237
|
+
}
|
|
54238
|
+
var EXPECTED_REPOSITORY_REQUIRED, WRITE_ROUTES, isGitWriteRoute, GitWriteDiagnostics;
|
|
54239
|
+
var init_git_write_policy = __esm({
|
|
54240
|
+
"src/bridge/git-write-policy.ts"() {
|
|
54241
|
+
"use strict";
|
|
54242
|
+
EXPECTED_REPOSITORY_REQUIRED = false;
|
|
54243
|
+
WRITE_ROUTES = new Set(["stage", "unstage", "discard", "commit", "push", "pr", "pr/merge", "host-token", "checkout", "fetch", "pull", "apply"].map((action) => `/v1/git/${action}`));
|
|
54244
|
+
isGitWriteRoute = (route2) => WRITE_ROUTES.has(route2);
|
|
54245
|
+
GitWriteDiagnostics = class {
|
|
54246
|
+
clients = /* @__PURE__ */ new Map();
|
|
54247
|
+
record(route2, headers) {
|
|
54248
|
+
let client = clientIdentity(headers);
|
|
54249
|
+
if (!this.clients.has(client) && this.clients.size >= 128) client = "other clients";
|
|
54250
|
+
let entry2 = this.clients.get(client);
|
|
54251
|
+
if (!entry2) {
|
|
54252
|
+
entry2 = { count: 0, routes: /* @__PURE__ */ new Set() };
|
|
54253
|
+
this.clients.set(client, entry2);
|
|
54254
|
+
}
|
|
54255
|
+
entry2.count++;
|
|
54256
|
+
if (!entry2.routes.has(route2)) {
|
|
54257
|
+
entry2.routes.add(route2);
|
|
54258
|
+
console.warn(`[phren-hook] ${route2}: git write without expectedRepository from ${client}; update the app before the compatibility window ends.`);
|
|
54259
|
+
}
|
|
54260
|
+
}
|
|
54261
|
+
snapshot() {
|
|
54262
|
+
return [...this.clients].map(([client, entry2]) => ({
|
|
54263
|
+
client,
|
|
54264
|
+
count: entry2.count,
|
|
54265
|
+
warning: `${entry2.count} git writes without expectedRepository from ${client}`
|
|
54266
|
+
}));
|
|
54267
|
+
}
|
|
54268
|
+
};
|
|
54269
|
+
}
|
|
54270
|
+
});
|
|
54271
|
+
|
|
54163
54272
|
// src/bridge/git-host-auth.ts
|
|
54164
54273
|
import { createHash as createHash25 } from "node:crypto";
|
|
54165
54274
|
import { execFile as execFile20 } from "node:child_process";
|
|
@@ -54631,19 +54740,19 @@ function obj(value2) {
|
|
|
54631
54740
|
}
|
|
54632
54741
|
function projectPath(host) {
|
|
54633
54742
|
if (!host.webUrl || !host.domain) return null;
|
|
54634
|
-
const
|
|
54635
|
-
return
|
|
54743
|
+
const path146 = host.webUrl.replace(/^https?:\/\/[^/]+\//, "");
|
|
54744
|
+
return path146 || null;
|
|
54636
54745
|
}
|
|
54637
54746
|
async function context(root, host) {
|
|
54638
|
-
const
|
|
54639
|
-
if (!host.domain || !
|
|
54747
|
+
const path146 = projectPath(host);
|
|
54748
|
+
if (!host.domain || !path146) return { available: false, reason: "unknown-host", message: "This repository has no GitLab remote.", pulls: [], current: null };
|
|
54640
54749
|
const token = await resolveHostToken("gitlab", host.domain);
|
|
54641
54750
|
if (!token) return { available: false, reason: "auth", message: SIGN_IN(host.domain), pulls: [], current: null };
|
|
54642
54751
|
const base = await apiRoot(root, host.domain, `https://${host.domain}/api/v4`);
|
|
54643
|
-
return { base, token: token.token, project: encodeURIComponent(
|
|
54752
|
+
return { base, token: token.token, project: encodeURIComponent(path146), domain: host.domain, account: { source: token.source, ...token.user ? { user: token.user } : {} } };
|
|
54644
54753
|
}
|
|
54645
|
-
function call(ctx,
|
|
54646
|
-
return hostJson(`${ctx.base}/projects/${ctx.project}${
|
|
54754
|
+
function call(ctx, path146, init = {}) {
|
|
54755
|
+
return hostJson(`${ctx.base}/projects/${ctx.project}${path146}`, { token: ctx.token, scheme: "private-token", ...init });
|
|
54647
54756
|
}
|
|
54648
54757
|
function listed(mr) {
|
|
54649
54758
|
const author = obj(mr.author);
|
|
@@ -54845,8 +54954,8 @@ async function context2(root, host) {
|
|
|
54845
54954
|
const api = await apiRoot(root, host.domain, `https://${host.domain}/api/v1`);
|
|
54846
54955
|
return { api, web: api.replace(/\/api\/v1$/, ""), repo, token: token.token, domain: host.domain, account: { source: token.source, ...token.user ? { user: token.user } : {} } };
|
|
54847
54956
|
}
|
|
54848
|
-
function call2(ctx,
|
|
54849
|
-
return hostJson(`${ctx.api}/repos/${ctx.repo}${
|
|
54957
|
+
function call2(ctx, path146, init = {}) {
|
|
54958
|
+
return hostJson(`${ctx.api}/repos/${ctx.repo}${path146}`, { token: ctx.token, scheme: "bearer", ...init });
|
|
54850
54959
|
}
|
|
54851
54960
|
function sameRepository(ctx, pull) {
|
|
54852
54961
|
const head = obj2(pull.head_repository);
|
|
@@ -55082,8 +55191,8 @@ function parseRemoteUrl(url2) {
|
|
|
55082
55191
|
return null;
|
|
55083
55192
|
}
|
|
55084
55193
|
}
|
|
55085
|
-
function clean4(
|
|
55086
|
-
return
|
|
55194
|
+
function clean4(path146) {
|
|
55195
|
+
return path146.replace(/^\/+/, "").replace(/\/+$/, "").replace(/\.git$/i, "");
|
|
55087
55196
|
}
|
|
55088
55197
|
function kindFromDomain(domain2) {
|
|
55089
55198
|
if (domain2 === "github.com" || domain2.endsWith(".github.com") || domain2.endsWith(".ghe.com")) return "github";
|
|
@@ -55291,7 +55400,7 @@ var init_git_hosts = __esm({
|
|
|
55291
55400
|
|
|
55292
55401
|
// src/bridge/git.ts
|
|
55293
55402
|
import { createHash as createHash26 } from "node:crypto";
|
|
55294
|
-
import { readFileSync as
|
|
55403
|
+
import { readFileSync as readFileSync43, realpathSync as realpathSync3 } from "node:fs";
|
|
55295
55404
|
import { lstat as lstat25, open as open17, readdir as readdir15, realpath as realpath12 } from "node:fs/promises";
|
|
55296
55405
|
import path95 from "node:path";
|
|
55297
55406
|
function statusLetter(code) {
|
|
@@ -55532,13 +55641,13 @@ function repositoryId(root) {
|
|
|
55532
55641
|
const dotGit = path95.join(root, ".git");
|
|
55533
55642
|
let gitDir2 = dotGit;
|
|
55534
55643
|
try {
|
|
55535
|
-
const link = /^gitdir:\s*(.+)$/m.exec(
|
|
55644
|
+
const link = /^gitdir:\s*(.+)$/m.exec(readFileSync43(dotGit, "utf8"));
|
|
55536
55645
|
if (link) gitDir2 = path95.resolve(root, link[1].trim());
|
|
55537
55646
|
} catch {
|
|
55538
55647
|
}
|
|
55539
55648
|
let common = gitDir2;
|
|
55540
55649
|
try {
|
|
55541
|
-
common = path95.resolve(gitDir2,
|
|
55650
|
+
common = path95.resolve(gitDir2, readFileSync43(path95.join(gitDir2, "commondir"), "utf8").trim());
|
|
55542
55651
|
} catch {
|
|
55543
55652
|
}
|
|
55544
55653
|
return realpathSync3(common);
|
|
@@ -56573,7 +56682,7 @@ var init_conductor_context = __esm({
|
|
|
56573
56682
|
});
|
|
56574
56683
|
|
|
56575
56684
|
// src/bridge/push.ts
|
|
56576
|
-
import { createCipheriv, createHmac as createHmac3, createPrivateKey, randomBytes as
|
|
56685
|
+
import { createCipheriv, createHmac as createHmac3, createPrivateKey, randomBytes as randomBytes7, sign } from "node:crypto";
|
|
56577
56686
|
import { readFile as readFile42, stat as stat21 } from "node:fs/promises";
|
|
56578
56687
|
import { connect as connect3 } from "node:http2";
|
|
56579
56688
|
import path100 from "node:path";
|
|
@@ -56676,7 +56785,7 @@ function upsertPushDevice(devices, value2) {
|
|
|
56676
56785
|
const device = deviceSchema.parse(value2);
|
|
56677
56786
|
return [...devices.filter((item) => item.deviceID !== device.deviceID), device].slice(-16);
|
|
56678
56787
|
}
|
|
56679
|
-
function relayCiphertext(key4, payload, nonce =
|
|
56788
|
+
function relayCiphertext(key4, payload, nonce = randomBytes7(12)) {
|
|
56680
56789
|
const aps = payload.aps ?? {};
|
|
56681
56790
|
let body2 = aps.alert?.body ?? "";
|
|
56682
56791
|
for (; ; ) {
|
|
@@ -57321,7 +57430,7 @@ var init_opencode_permissions = __esm({
|
|
|
57321
57430
|
|
|
57322
57431
|
// src/bridge/prompt-deliveries.ts
|
|
57323
57432
|
import { createHash as createHash29 } from "node:crypto";
|
|
57324
|
-
import { readFileSync as
|
|
57433
|
+
import { readFileSync as readFileSync44 } from "node:fs";
|
|
57325
57434
|
import { open as open18 } from "node:fs/promises";
|
|
57326
57435
|
function promptKey(text5) {
|
|
57327
57436
|
return unwrapPastedContent(text5).split("\n").filter((line) => !PICTURE_PATH_LINE.test(line)).join("\n").replace(/\[Image #\d+\]/g, " ").replace(/\s+/g, " ").trim();
|
|
@@ -57405,7 +57514,7 @@ var init_prompt_deliveries = __esm({
|
|
|
57405
57514
|
this.landed = landed;
|
|
57406
57515
|
if (!file4) return;
|
|
57407
57516
|
try {
|
|
57408
|
-
for (const row of objects(object2(JSON.parse(
|
|
57517
|
+
for (const row of objects(object2(JSON.parse(readFileSync44(file4, "utf8"))).records)) {
|
|
57409
57518
|
const parsed = recordSchema2.safeParse(row);
|
|
57410
57519
|
if (parsed.success) this.records.push({ ...parsed.data, state: parsed.data.state === "typed" ? "queued" : parsed.data.state });
|
|
57411
57520
|
}
|
|
@@ -61428,7 +61537,7 @@ var init_file_range = __esm({
|
|
|
61428
61537
|
});
|
|
61429
61538
|
|
|
61430
61539
|
// src/bridge/file-write.ts
|
|
61431
|
-
import { randomBytes as
|
|
61540
|
+
import { randomBytes as randomBytes9 } from "node:crypto";
|
|
61432
61541
|
import { constants as constants4 } from "node:fs";
|
|
61433
61542
|
import { lstat as lstat31, open as open23, realpath as realpath17, rename as rename7, rm as rm12 } from "node:fs/promises";
|
|
61434
61543
|
import path110 from "node:path";
|
|
@@ -61491,7 +61600,7 @@ async function writeRepoFileNow(root, requested, content, expectedVersion) {
|
|
|
61491
61600
|
}
|
|
61492
61601
|
if (!existing) throw new BridgeError(409, "The file is gone. It changed since you opened it.", { code: "file-changed" });
|
|
61493
61602
|
if (fileVersion(existing) !== expectedVersion) throw new BridgeError(409, "The file changed since you opened it.", { code: "file-changed" });
|
|
61494
|
-
const temporary = path110.join(directory, `.${parts[parts.length - 1]}.phren-${
|
|
61603
|
+
const temporary = path110.join(directory, `.${parts[parts.length - 1]}.phren-${randomBytes9(6).toString("hex")}.tmp`);
|
|
61495
61604
|
try {
|
|
61496
61605
|
const handle = await open23(temporary, constants4.O_WRONLY | constants4.O_CREAT | constants4.O_EXCL | constants4.O_NOFOLLOW, existing.mode & 511);
|
|
61497
61606
|
try {
|
|
@@ -61810,7 +61919,11 @@ function deliveryReply(agentHooks, id2, target, text5) {
|
|
|
61810
61919
|
...status.reason ? { reason: status.reason } : {}
|
|
61811
61920
|
};
|
|
61812
61921
|
}
|
|
61813
|
-
async function paneRoute(ctx, url2, data, response) {
|
|
61922
|
+
async function paneRoute(ctx, url2, data, response, headers = {}) {
|
|
61923
|
+
if (isGitWriteRoute(url2.pathname) && data.expectedRepository === void 0) {
|
|
61924
|
+
ctx.gitWrites?.record(url2.pathname, headers);
|
|
61925
|
+
if (EXPECTED_REPOSITORY_REQUIRED) throw new BridgeError(400, "This app is too old to change Git safely. Update it.", { code: "expected-repository-required" });
|
|
61926
|
+
}
|
|
61814
61927
|
if (["/v1/diff", "/v1/git/status", "/v1/git/worktrees"].includes(url2.pathname)) {
|
|
61815
61928
|
return withGitReadDeadline(() => paneRouteOnce(ctx, url2, data, response, () => {
|
|
61816
61929
|
}));
|
|
@@ -62093,7 +62206,7 @@ async function paneRouteOnce(ctx, url2, data, response, typing) {
|
|
|
62093
62206
|
}));
|
|
62094
62207
|
} else if (url2.pathname.startsWith("/v1/git/")) {
|
|
62095
62208
|
let cwd = await gitRepository(pane, target, data.child, data.worktree);
|
|
62096
|
-
if (
|
|
62209
|
+
if (isGitWriteRoute(url2.pathname) && data.expectedRepository !== void 0) {
|
|
62097
62210
|
const expected = external_exports.string().min(1).max(4096).refine((value2) => path111.isAbsolute(value2) && !value2.includes("\0"), "Expected an absolute repository path.").parse(data.expectedRepository);
|
|
62098
62211
|
const root = await gitRoot(cwd);
|
|
62099
62212
|
if (root !== expected) throw new BridgeError(409, "This pane's checkout changed. Refresh Changes before writing.", { code: "git-checkout-changed" });
|
|
@@ -62146,6 +62259,7 @@ var ANSWER_KEYS, HERDR_KEYS, questionText, claudeQuestionBody, secretText, promp
|
|
|
62146
62259
|
var init_server_pane_routes = __esm({
|
|
62147
62260
|
"src/bridge/server-pane-routes.ts"() {
|
|
62148
62261
|
"use strict";
|
|
62262
|
+
init_git_write_policy();
|
|
62149
62263
|
init_zod();
|
|
62150
62264
|
init_git();
|
|
62151
62265
|
init_fanouts();
|
|
@@ -62488,7 +62602,7 @@ __export(launcher_exports, {
|
|
|
62488
62602
|
writeManifest: () => writeManifest2
|
|
62489
62603
|
});
|
|
62490
62604
|
import { spawn as spawn12, execFileSync as execFileSync6 } from "node:child_process";
|
|
62491
|
-
import { randomBytes as
|
|
62605
|
+
import { randomBytes as randomBytes10 } from "node:crypto";
|
|
62492
62606
|
import * as fs44 from "node:fs";
|
|
62493
62607
|
import * as path114 from "node:path";
|
|
62494
62608
|
function jobsRoot(store) {
|
|
@@ -62544,7 +62658,7 @@ function createJob(options, env = process.env, nearest = nearestAgent) {
|
|
|
62544
62658
|
if (!options.label.trim() || options.label.length > 200) throw new Error("Choose a label of 1 to 200 characters.");
|
|
62545
62659
|
const worktree = fs44.realpathSync(options.worktree);
|
|
62546
62660
|
if (!fs44.statSync(worktree).isDirectory()) throw new Error("Choose a worktree directory.");
|
|
62547
|
-
const id2 = `${options.provider}-${
|
|
62661
|
+
const id2 = `${options.provider}-${randomBytes10(12).toString("hex")}`;
|
|
62548
62662
|
const root = jobsRoot(options.store), job = path114.join(root, id2);
|
|
62549
62663
|
fs44.mkdirSync(job, { recursive: true, mode: 448 });
|
|
62550
62664
|
fs44.chmodSync(root, 448);
|
|
@@ -62577,7 +62691,7 @@ async function launch(options, reservation = createJob(options)) {
|
|
|
62577
62691
|
const { job, manifest } = reservation, adapter = adapters[options.provider];
|
|
62578
62692
|
console.log(job);
|
|
62579
62693
|
const out = fs44.openSync(path114.join(job, manifest.eventLog), "a"), err = fs44.openSync(path114.join(job, "stderr.log"), "a");
|
|
62580
|
-
const password =
|
|
62694
|
+
const password = randomBytes10(24).toString("hex");
|
|
62581
62695
|
const child = spawn12("nice", ["-n", "15", adapter.command, ...adapter.argv({ ...options, job })], {
|
|
62582
62696
|
cwd: manifest.worktree,
|
|
62583
62697
|
env: {
|
|
@@ -63357,8 +63471,8 @@ function relayLiveSpeech(client, query, options = {}) {
|
|
|
63357
63471
|
params.set("auto_mode", "true");
|
|
63358
63472
|
params.set("inactivity_timeout", "180");
|
|
63359
63473
|
}
|
|
63360
|
-
const
|
|
63361
|
-
const socket = connect5(`${origin}${
|
|
63474
|
+
const path146 = endpoint === "dialogue" ? "/v1/text-to-dialogue/stream-input" : `/v1/text-to-speech/${encodeURIComponent(voice)}/stream-input`;
|
|
63475
|
+
const socket = connect5(`${origin}${path146}?${params}`, key4);
|
|
63362
63476
|
upstream = socket;
|
|
63363
63477
|
const current2 = () => upstream === socket && !closed;
|
|
63364
63478
|
let voiced = false, firstAudio;
|
|
@@ -64154,7 +64268,7 @@ var init_code_routes = __esm({
|
|
|
64154
64268
|
const project = projectSchema.parse(projectValue ?? "");
|
|
64155
64269
|
const { codeDatabasePath } = await requireCodePackage(this.store);
|
|
64156
64270
|
const file4 = codeDatabasePath(this.store, project);
|
|
64157
|
-
await Promise.all([file4, `${file4}-journal`, `${file4}-wal`, `${file4}-shm`].map((
|
|
64271
|
+
await Promise.all([file4, `${file4}-journal`, `${file4}-wal`, `${file4}-shm`].map((path146) => rm14(path146, { force: true })));
|
|
64158
64272
|
return { project, disabled: true };
|
|
64159
64273
|
}
|
|
64160
64274
|
async reindex(projectValue) {
|
|
@@ -65036,7 +65150,7 @@ var init_settings_switch = __esm({
|
|
|
65036
65150
|
});
|
|
65037
65151
|
|
|
65038
65152
|
// src/bridge/job-registry.ts
|
|
65039
|
-
import { readFileSync as
|
|
65153
|
+
import { readFileSync as readFileSync50 } from "node:fs";
|
|
65040
65154
|
import path120 from "node:path";
|
|
65041
65155
|
function jobKey(job) {
|
|
65042
65156
|
if (job.pane) return `pane:${paneKey3(job.pane)}`;
|
|
@@ -65177,7 +65291,7 @@ var init_job_registry = __esm({
|
|
|
65177
65291
|
now;
|
|
65178
65292
|
async list() {
|
|
65179
65293
|
try {
|
|
65180
|
-
const parsed = stateSchema2.safeParse(JSON.parse(
|
|
65294
|
+
const parsed = stateSchema2.safeParse(JSON.parse(readFileSync50(this.file, "utf8")));
|
|
65181
65295
|
return parsed.success ? parsed.data.jobs : [];
|
|
65182
65296
|
} catch {
|
|
65183
65297
|
return [];
|
|
@@ -73296,9 +73410,80 @@ var init_steps = __esm({
|
|
|
73296
73410
|
}
|
|
73297
73411
|
});
|
|
73298
73412
|
|
|
73413
|
+
// src/bridge/schedule-update.ts
|
|
73414
|
+
import path139 from "node:path";
|
|
73415
|
+
async function updateScheduleRoute(store, body2) {
|
|
73416
|
+
let input2;
|
|
73417
|
+
try {
|
|
73418
|
+
input2 = updateSchema.parse(body2);
|
|
73419
|
+
} catch (error62) {
|
|
73420
|
+
throw new BridgeError(400, error62 instanceof Error ? error62.message : "Invalid schedule update.");
|
|
73421
|
+
}
|
|
73422
|
+
const directory = getProjectDirs(store).find((dir) => path139.basename(dir).toLowerCase() === input2.project.toLowerCase());
|
|
73423
|
+
if (!directory) throw new BridgeError(404, `Unknown project "${input2.project}".`);
|
|
73424
|
+
return withScheduleLock(directory, () => {
|
|
73425
|
+
const file4 = readScheduleDocumentSync(directory);
|
|
73426
|
+
const schedules = file4.document.schedules ?? [];
|
|
73427
|
+
const index2 = schedules.findIndex((schedule) => schedule.id === input2.id);
|
|
73428
|
+
if (index2 < 0) throw new BridgeError(404, `Schedule "${input2.id}" was not found in ${input2.project}.`);
|
|
73429
|
+
const current2 = schedules[index2];
|
|
73430
|
+
if (current2.updatedAt !== input2.expectedUpdatedAt) {
|
|
73431
|
+
throw new BridgeError(409, "This schedule changed. Refresh it and try again.", { schedule: current2 });
|
|
73432
|
+
}
|
|
73433
|
+
const updated = { ...current2 };
|
|
73434
|
+
for (const [key4, value2] of Object.entries(input2.changes)) {
|
|
73435
|
+
if (value2 === null) delete updated[key4];
|
|
73436
|
+
else updated[key4] = value2;
|
|
73437
|
+
}
|
|
73438
|
+
try {
|
|
73439
|
+
parseSchedule(updated);
|
|
73440
|
+
} catch (error62) {
|
|
73441
|
+
throw new BridgeError(400, error62 instanceof Error ? error62.message : "Invalid schedule.");
|
|
73442
|
+
}
|
|
73443
|
+
updated.updatedAt = new Date(Math.max(Date.now(), Date.parse(current2.updatedAt) + 1)).toISOString();
|
|
73444
|
+
schedules[index2] = updated;
|
|
73445
|
+
writeScheduleDocumentSync(directory, schedules, file4.document);
|
|
73446
|
+
return { ok: true, schedule: updated };
|
|
73447
|
+
});
|
|
73448
|
+
}
|
|
73449
|
+
var optional2, updateSchema;
|
|
73450
|
+
var init_schedule_update = __esm({
|
|
73451
|
+
"src/bridge/schedule-update.ts"() {
|
|
73452
|
+
"use strict";
|
|
73453
|
+
init_zod();
|
|
73454
|
+
init_shared();
|
|
73455
|
+
init_protocol();
|
|
73456
|
+
init_schedule_format();
|
|
73457
|
+
optional2 = (schema) => schema.nullable().optional();
|
|
73458
|
+
updateSchema = external_exports.object({
|
|
73459
|
+
project: external_exports.string().min(1).max(200),
|
|
73460
|
+
id: external_exports.string().regex(/^[a-f0-9]{8}$/),
|
|
73461
|
+
expectedUpdatedAt: external_exports.string().datetime({ offset: true }),
|
|
73462
|
+
changes: external_exports.object({
|
|
73463
|
+
name: external_exports.string().optional(),
|
|
73464
|
+
prompt: external_exports.string().optional(),
|
|
73465
|
+
enabled: external_exports.boolean().optional(),
|
|
73466
|
+
computer: external_exports.string().optional(),
|
|
73467
|
+
harness: external_exports.enum(SCHEDULE_HARNESSES).optional(),
|
|
73468
|
+
every: external_exports.enum(SCHEDULE_EVERY).optional(),
|
|
73469
|
+
model: optional2(external_exports.string()),
|
|
73470
|
+
account: optional2(external_exports.string()),
|
|
73471
|
+
notify: optional2(external_exports.array(external_exports.enum(SCHEDULE_NOTIFY))),
|
|
73472
|
+
projects: optional2(external_exports.array(external_exports.string())),
|
|
73473
|
+
session: optional2(external_exports.enum(SCHEDULE_SESSIONS)),
|
|
73474
|
+
at: optional2(external_exports.string()),
|
|
73475
|
+
days: optional2(external_exports.array(external_exports.enum(WEEKDAYS))),
|
|
73476
|
+
interval: optional2(external_exports.string()),
|
|
73477
|
+
once: optional2(external_exports.string()),
|
|
73478
|
+
cron: optional2(external_exports.string())
|
|
73479
|
+
}).strict()
|
|
73480
|
+
}).strict();
|
|
73481
|
+
}
|
|
73482
|
+
});
|
|
73483
|
+
|
|
73299
73484
|
// src/bridge/session-rename.ts
|
|
73300
73485
|
import { open as open28 } from "node:fs/promises";
|
|
73301
|
-
import
|
|
73486
|
+
import path140 from "node:path";
|
|
73302
73487
|
function lastCustomTitle(text5) {
|
|
73303
73488
|
for (const line of text5.split("\n").reverse()) {
|
|
73304
73489
|
if (!line.includes('"custom-title"')) continue;
|
|
@@ -73448,7 +73633,7 @@ var init_session_rename = __esm({
|
|
|
73448
73633
|
return text5 === void 0 ? void 0 : lastCustomTitle(text5);
|
|
73449
73634
|
},
|
|
73450
73635
|
async codexIndexTitle(thread) {
|
|
73451
|
-
const text5 = await tail(
|
|
73636
|
+
const text5 = await tail(path140.join(codexHome(), "session_index.jsonl"));
|
|
73452
73637
|
return text5 === void 0 ? void 0 : lastIndexedName(text5, thread);
|
|
73453
73638
|
},
|
|
73454
73639
|
sleep: (ms2) => new Promise((resolve17) => setTimeout(resolve17, ms2)),
|
|
@@ -73461,7 +73646,7 @@ var init_session_rename = __esm({
|
|
|
73461
73646
|
import { execFile as execFile31 } from "node:child_process";
|
|
73462
73647
|
import { readFile as readFile54 } from "node:fs/promises";
|
|
73463
73648
|
import { homedir as homedir21, hostname as hostname12, userInfo as userInfo5 } from "node:os";
|
|
73464
|
-
import
|
|
73649
|
+
import path141 from "node:path";
|
|
73465
73650
|
import { promisify as promisify29 } from "node:util";
|
|
73466
73651
|
function sshConfigHosts(text5) {
|
|
73467
73652
|
const hosts = [];
|
|
@@ -73504,11 +73689,11 @@ async function probe2(host) {
|
|
|
73504
73689
|
return computerId ? { host, computerId, user: field("user") ?? "", client: field("client") } : void 0;
|
|
73505
73690
|
}
|
|
73506
73691
|
async function discoverComputers(options = {}) {
|
|
73507
|
-
const config4 = options.sshConfig ?? await readFile54(
|
|
73692
|
+
const config4 = options.sshConfig ?? await readFile54(path141.join(homedir21(), ".ssh", "config"), "utf8").catch(() => "");
|
|
73508
73693
|
const store = options.store !== void 0 ? options.store : findPhrenPath();
|
|
73509
73694
|
const machines = store ? listMachines(store) : void 0;
|
|
73510
73695
|
const { peers } = await optionalHookPeers();
|
|
73511
|
-
const own2 = (await readFile54(
|
|
73696
|
+
const own2 = (await readFile54(path141.join(bridgeRoot(), "computer-id"), "utf8").catch(() => "")).trim();
|
|
73512
73697
|
const known2 = new Set([...localNames(), ...peers.flatMap((peer) => [peer.name, peer.address])].map(computerLabel));
|
|
73513
73698
|
const candidates = [.../* @__PURE__ */ new Set([...sshConfigHosts(config4), ...machines?.ok ? Object.keys(machines.data) : []])].filter((host) => !known2.has(computerLabel(host))).slice(0, 32);
|
|
73514
73699
|
const [found, peerIds] = await Promise.all([
|
|
@@ -73530,7 +73715,7 @@ function slugName(value2) {
|
|
|
73530
73715
|
async function linkComputer(host, options = {}) {
|
|
73531
73716
|
const remote = await probe2(host);
|
|
73532
73717
|
if (!remote) throw new BridgeError(409, `${host} answers over ssh but Phren Hook is not installed there. Run phren bridge install on it first.`);
|
|
73533
|
-
const own2 = (await readFile54(
|
|
73718
|
+
const own2 = (await readFile54(path141.join(bridgeRoot(), "computer-id"), "utf8").catch(() => "")).trim();
|
|
73534
73719
|
if (remote.computerId === own2) throw new BridgeError(409, `${host} is this computer.`);
|
|
73535
73720
|
const name = computerName.parse(options.name ?? slugName(host));
|
|
73536
73721
|
const as2 = computerName.parse(options.as ?? slugName(hostname12()));
|
|
@@ -73711,7 +73896,7 @@ var init_mux_wire = __esm({
|
|
|
73711
73896
|
});
|
|
73712
73897
|
|
|
73713
73898
|
// src/bridge/server-routes.ts
|
|
73714
|
-
import
|
|
73899
|
+
import path142 from "node:path";
|
|
73715
73900
|
async function childActivity(source, session) {
|
|
73716
73901
|
const key4 = `${source}\0${session}`, now = Date.now(), cached3 = childActivityCache.get(key4);
|
|
73717
73902
|
if (cached3 && (cached3.pending || now - cached3.at < CHILD_ACTIVITY_CACHE_MS)) return cached3.result;
|
|
@@ -73733,7 +73918,10 @@ function capabilitiesForModules(snapshot2) {
|
|
|
73733
73918
|
const result = Object.fromEntries(Object.entries(capabilities).filter(([name]) => allowed.has(name)));
|
|
73734
73919
|
for (const name of ["memory", "tasks", "hook", "git", "schedules"]) if (snapshot2.has(name)) result[name] = true;
|
|
73735
73920
|
if (snapshot2.has("hook")) result.approvalRules = { version: 2, effects: ["always-ask", "deny"], harnesses: ["claude"], events: ["PermissionRequest"], tools: ["Bash"], inputField: "command", conductorTools: false, mcpTools: false, preExecution: false };
|
|
73736
|
-
if (snapshot2.has("schedules"))
|
|
73921
|
+
if (snapshot2.has("schedules")) {
|
|
73922
|
+
result.scheduleProjects = true;
|
|
73923
|
+
result.scheduleUpdate = true;
|
|
73924
|
+
}
|
|
73737
73925
|
if (snapshot2.has("tasks")) {
|
|
73738
73926
|
result.taskDependencies = true;
|
|
73739
73927
|
result.taskWriterSafety = true;
|
|
@@ -73923,6 +74111,8 @@ function createRouteHandler(ctx) {
|
|
|
73923
74111
|
} = ctx;
|
|
73924
74112
|
const { conversationReader, childConversationReader, emptyPage } = ctx.streams;
|
|
73925
74113
|
const readWorkspaces = workspacesReader(ctx);
|
|
74114
|
+
const gitWrites = new GitWriteDiagnostics();
|
|
74115
|
+
const paneContext = { ...ctx, gitWrites };
|
|
73926
74116
|
return async (request9, response) => {
|
|
73927
74117
|
response.setHeader("X-Phren-Protocol", String(PROTOCOL));
|
|
73928
74118
|
response.setHeader("Cache-Control", "no-store");
|
|
@@ -73964,13 +74154,16 @@ function createRouteHandler(ctx) {
|
|
|
73964
74154
|
result = hookMetrics.snapshot();
|
|
73965
74155
|
break;
|
|
73966
74156
|
case "/v1/health/details":
|
|
73967
|
-
result =
|
|
73968
|
-
|
|
73969
|
-
|
|
73970
|
-
|
|
73971
|
-
|
|
73972
|
-
|
|
73973
|
-
|
|
74157
|
+
result = {
|
|
74158
|
+
...await healthDetails({
|
|
74159
|
+
hookVersion: version2,
|
|
74160
|
+
computerId: computerID2,
|
|
74161
|
+
store: scheduleStore,
|
|
74162
|
+
scheduler: scheduler ? { running: true, lastTickAt: scheduler.lastTickAt } : void 0,
|
|
74163
|
+
push: agentHooks.push.status
|
|
74164
|
+
}),
|
|
74165
|
+
gitWrites: gitWrites.snapshot()
|
|
74166
|
+
};
|
|
73974
74167
|
break;
|
|
73975
74168
|
case "/v1/health/peers": {
|
|
73976
74169
|
const caller = external_exports.object({ name: external_exports.string().max(253).optional(), hostKey: external_exports.string().max(512).optional() }).parse({ name: url2.searchParams.get("name") ?? void 0, hostKey: url2.searchParams.get("hostKey") ?? void 0 });
|
|
@@ -74110,7 +74303,7 @@ function createRouteHandler(ctx) {
|
|
|
74110
74303
|
case "/v1/files/range": {
|
|
74111
74304
|
let root;
|
|
74112
74305
|
if (url2.searchParams.get("scope") === "uploads") {
|
|
74113
|
-
root =
|
|
74306
|
+
root = path142.join(bridgeRoot(), "uploads");
|
|
74114
74307
|
} else if (url2.searchParams.has("session")) {
|
|
74115
74308
|
const target = targetFromURL(url2), pane = await validateTarget(target);
|
|
74116
74309
|
const cwd = await gitRepository(pane, target, url2.searchParams.get("child") ?? void 0, url2.searchParams.get("worktree") ?? void 0);
|
|
@@ -74368,6 +74561,8 @@ function createRouteHandler(ctx) {
|
|
|
74368
74561
|
}).parse(data);
|
|
74369
74562
|
const runs = await scheduler.launchNow(input2.project, input2.id, false, input2.expectedUpdatedAt);
|
|
74370
74563
|
result = { ok: runs.every((run4) => run4.status !== "failed"), run: runs[0], runs };
|
|
74564
|
+
} else if (url2.pathname === "/v1/schedules/update") {
|
|
74565
|
+
result = await updateScheduleRoute(scheduleStore, data);
|
|
74371
74566
|
} else if (url2.pathname === "/v1/schedules/history") {
|
|
74372
74567
|
const input2 = external_exports.object({
|
|
74373
74568
|
project: external_exports.string().min(1).max(200).optional(),
|
|
@@ -74476,7 +74671,7 @@ function createRouteHandler(ctx) {
|
|
|
74476
74671
|
{ ...data, cwd: await launchDirectory(data.cwd ?? homeDir(), await journal.recent(), locatedDirectories) }
|
|
74477
74672
|
)) : await workspaceAction(selectedServer(url2), operation, data);
|
|
74478
74673
|
} else {
|
|
74479
|
-
result = await paneRoute(
|
|
74674
|
+
result = await paneRoute(paneContext, url2, data, response, request9.headers);
|
|
74480
74675
|
}
|
|
74481
74676
|
}
|
|
74482
74677
|
} else if (request9.method === "DELETE") {
|
|
@@ -74548,6 +74743,7 @@ var init_server_routes = __esm({
|
|
|
74548
74743
|
init_uploads();
|
|
74549
74744
|
init_steps();
|
|
74550
74745
|
init_usage();
|
|
74746
|
+
init_schedule_update();
|
|
74551
74747
|
init_schedule_watch();
|
|
74552
74748
|
init_health();
|
|
74553
74749
|
init_shared();
|
|
@@ -74558,6 +74754,7 @@ var init_server_routes = __esm({
|
|
|
74558
74754
|
init_conductor_sets();
|
|
74559
74755
|
init_conductor_role();
|
|
74560
74756
|
init_metrics();
|
|
74757
|
+
init_git_write_policy();
|
|
74561
74758
|
init_speech();
|
|
74562
74759
|
init_speech_key();
|
|
74563
74760
|
init_speech_voice();
|
|
@@ -75418,8 +75615,8 @@ var init_server_overview = __esm({
|
|
|
75418
75615
|
|
|
75419
75616
|
// src/bridge/codex-auth-refresh.ts
|
|
75420
75617
|
import { readFile as readFile55 } from "node:fs/promises";
|
|
75421
|
-
import
|
|
75422
|
-
async function lastCodexRefresh(file4 =
|
|
75618
|
+
import path143 from "node:path";
|
|
75619
|
+
async function lastCodexRefresh(file4 = path143.join(codexHome(), "auth.json")) {
|
|
75423
75620
|
try {
|
|
75424
75621
|
const auth = object2(JSON.parse(await readFile55(file4, "utf8")));
|
|
75425
75622
|
if (!object2(auth.tokens).refresh_token) return void 0;
|
|
@@ -75432,7 +75629,7 @@ async function lastCodexRefresh(file4 = path142.join(codexHome(), "auth.json"))
|
|
|
75432
75629
|
function codexAuthRefreshEnabled(env = process.env) {
|
|
75433
75630
|
return !/^(?:0|off|false|no)$/i.test(env.PHREN_CODEX_AUTH_REFRESH ?? "");
|
|
75434
75631
|
}
|
|
75435
|
-
var REFRESH_AFTER_MS, CodexAuthKeeper;
|
|
75632
|
+
var REFRESH_AFTER_MS, CODEX_SIGNIN_STALE_MS, CodexAuthKeeper;
|
|
75436
75633
|
var init_codex_auth_refresh = __esm({
|
|
75437
75634
|
"src/bridge/codex-auth-refresh.ts"() {
|
|
75438
75635
|
"use strict";
|
|
@@ -75441,6 +75638,7 @@ var init_codex_auth_refresh = __esm({
|
|
|
75441
75638
|
init_codex_app_server();
|
|
75442
75639
|
init_protocol();
|
|
75443
75640
|
REFRESH_AFTER_MS = 6 * 864e5;
|
|
75641
|
+
CODEX_SIGNIN_STALE_MS = 9 * 864e5;
|
|
75444
75642
|
CodexAuthKeeper = class {
|
|
75445
75643
|
constructor(refresher, file4, now = () => Date.now()) {
|
|
75446
75644
|
this.refresher = refresher;
|
|
@@ -75483,10 +75681,10 @@ var init_codex_auth_refresh = __esm({
|
|
|
75483
75681
|
// src/bridge/server.ts
|
|
75484
75682
|
import { randomUUID as randomUUID30 } from "node:crypto";
|
|
75485
75683
|
import { chmod as chmod6, lstat as lstat36, mkdir as mkdir35, readFile as readFile56, rm as rm17, unlink as unlink10, writeFile as writeFile12 } from "node:fs/promises";
|
|
75486
|
-
import { readFileSync as
|
|
75684
|
+
import { readFileSync as readFileSync58 } from "node:fs";
|
|
75487
75685
|
import { createServer as createServer4 } from "node:http";
|
|
75488
75686
|
import { cpus as cpus2, hostname as hostname13, loadavg as loadavg2 } from "node:os";
|
|
75489
|
-
import
|
|
75687
|
+
import path144 from "node:path";
|
|
75490
75688
|
async function serve(version2, options = {}) {
|
|
75491
75689
|
process.umask(63);
|
|
75492
75690
|
const modules = activateModules(defaultPhrenPath(), void 0, true);
|
|
@@ -75496,7 +75694,7 @@ async function serve(version2, options = {}) {
|
|
|
75496
75694
|
await mkdir35(root, { recursive: true, mode: 448 });
|
|
75497
75695
|
await chmod6(root, 448);
|
|
75498
75696
|
let computerID2;
|
|
75499
|
-
const identityFile =
|
|
75697
|
+
const identityFile = path144.join(root, "computer-id");
|
|
75500
75698
|
try {
|
|
75501
75699
|
computerID2 = (await readFile56(identityFile, "utf8")).trim();
|
|
75502
75700
|
} catch {
|
|
@@ -75515,7 +75713,7 @@ async function serve(version2, options = {}) {
|
|
|
75515
75713
|
}) : void 0;
|
|
75516
75714
|
const locatedDirectories = /* @__PURE__ */ new Set();
|
|
75517
75715
|
const journal = new ActivityJournal();
|
|
75518
|
-
const agentHooks = new AgentHooks(void 0, modules,
|
|
75716
|
+
const agentHooks = new AgentHooks(void 0, modules, path144.join(bridgeRoot(), "deliveries.json"));
|
|
75519
75717
|
const returns = dispatches ? new DispatchReturns({
|
|
75520
75718
|
// Continue on another signed-in account when a Claude worker stops at its usage limit: opt-in, `phren config account-failover on`.
|
|
75521
75719
|
failover: new AccountFailover({ rooms: () => dispatches.claudeRooms(), dispatch: (input2, origin, continues) => dispatches.dispatch(input2, origin, continues) }),
|
|
@@ -75623,7 +75821,7 @@ async function serve(version2, options = {}) {
|
|
|
75623
75821
|
if (codeReindexer) agentHooks.changes.onRecord = (files) => codeReindexer.record(files);
|
|
75624
75822
|
function gatewayTiming() {
|
|
75625
75823
|
try {
|
|
75626
|
-
const parsed = JSON.parse(
|
|
75824
|
+
const parsed = JSON.parse(readFileSync58(path144.join(root, "gateway.json"), "utf8"));
|
|
75627
75825
|
if (typeof parsed.ms === "number" && Number.isFinite(parsed.ms) && parsed.ms >= 0) return Math.round(parsed.ms);
|
|
75628
75826
|
} catch {
|
|
75629
75827
|
}
|
|
@@ -75669,7 +75867,7 @@ async function serve(version2, options = {}) {
|
|
|
75669
75867
|
}
|
|
75670
75868
|
const stopRetention = modules.has("git") ? await startChangeRetention() : () => {
|
|
75671
75869
|
};
|
|
75672
|
-
if (modules.has("git")) await rm17(
|
|
75870
|
+
if (modules.has("git")) await rm17(path144.join(root, "changes-scratch"), { recursive: true, force: true });
|
|
75673
75871
|
const streams = transcriptStreams({ modules, agentHooks, codexQuestions, sideQuestions, settingsSwitcher, info, activeCapabilities });
|
|
75674
75872
|
const { stream } = streams;
|
|
75675
75873
|
const overview = overviewStream({
|
|
@@ -75937,14 +76135,14 @@ __export(device_enroll_exports, {
|
|
|
75937
76135
|
});
|
|
75938
76136
|
import { readFile as readFile57 } from "node:fs/promises";
|
|
75939
76137
|
import { homedir as homedir22, userInfo as userInfo6 } from "node:os";
|
|
75940
|
-
import
|
|
76138
|
+
import path145 from "node:path";
|
|
75941
76139
|
async function enrollDevice(input2, options) {
|
|
75942
76140
|
try {
|
|
75943
76141
|
const publicKey = publicComputerKey(input2);
|
|
75944
76142
|
const comment = options.device === "android" ? "phren-android" : "phren-iphone";
|
|
75945
76143
|
const line = `restrict,pty,${forcedCommand} ${publicKey} ${comment}`;
|
|
75946
76144
|
const encoded = publicKey.split(" ")[1];
|
|
75947
|
-
const file4 =
|
|
76145
|
+
const file4 = path145.join(options.sshDirectory ?? path145.join(homedir22(), ".ssh"), "authorized_keys");
|
|
75948
76146
|
const before = await readFile57(file4, "utf8").catch(() => "");
|
|
75949
76147
|
await appendAuthorizedKey(
|
|
75950
76148
|
line,
|
|
@@ -75952,7 +76150,7 @@ async function enrollDevice(input2, options) {
|
|
|
75952
76150
|
"This phone key is already authorized with different options.",
|
|
75953
76151
|
options.sshDirectory
|
|
75954
76152
|
);
|
|
75955
|
-
const id2 = await readFile57(
|
|
76153
|
+
const id2 = await readFile57(path145.join(options.root ?? bridgeRoot(), "computer-id"), "utf8").then((value2) => value2.trim() || null).catch(() => null);
|
|
75956
76154
|
return {
|
|
75957
76155
|
v: 1,
|
|
75958
76156
|
ok: true,
|
|
@@ -76341,7 +76539,7 @@ async function main() {
|
|
|
76341
76539
|
return askpass2(args[1]);
|
|
76342
76540
|
}
|
|
76343
76541
|
const { runBridge: runBridge2 } = await Promise.resolve().then(() => (init_command(), command_exports));
|
|
76344
|
-
return runBridge2(args, "0.3.
|
|
76542
|
+
return runBridge2(args, "0.3.47");
|
|
76345
76543
|
}
|
|
76346
76544
|
main().then((code) => {
|
|
76347
76545
|
process.exitCode = code;
|