usebeeline 0.1.27 → 0.1.28
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/usebeeline.mjs +277 -69
- package/package.json +1 -1
package/dist/usebeeline.mjs
CHANGED
|
@@ -14175,7 +14175,7 @@ function configureNetworkFamilyDefaults(network = net) {
|
|
|
14175
14175
|
configureNetworkFamilyDefaults();
|
|
14176
14176
|
|
|
14177
14177
|
// apps/body/dist/cli.js
|
|
14178
|
-
import { dirname as
|
|
14178
|
+
import { dirname as dirname34, resolve as resolve53 } from "node:path";
|
|
14179
14179
|
import { stdin as stdin4, stdout as stdout5 } from "node:process";
|
|
14180
14180
|
|
|
14181
14181
|
// node_modules/@clack/core/dist/index.mjs
|
|
@@ -18253,7 +18253,8 @@ var SERVER_EVENT_KINDS = [
|
|
|
18253
18253
|
"choice-skipped",
|
|
18254
18254
|
"poll-closed",
|
|
18255
18255
|
"workflow-handoff",
|
|
18256
|
-
"subscription-fired"
|
|
18256
|
+
"subscription-fired",
|
|
18257
|
+
"computer-session-activity"
|
|
18257
18258
|
];
|
|
18258
18259
|
var SERVER_EVENT_KIND_DETAIL = {
|
|
18259
18260
|
"joined": "fires when a person or agent joins this Room, or when a Workspace arrival projects into it",
|
|
@@ -18270,7 +18271,8 @@ var SERVER_EVENT_KIND_DETAIL = {
|
|
|
18270
18271
|
"choice-skipped": "fires when a posted choice's window closes unanswered, starting a new turn for the asking agent",
|
|
18271
18272
|
"poll-closed": "fires when a posted poll closes, starting a new turn for the asking agent",
|
|
18272
18273
|
"workflow-handoff": "fires when a workflow run starts or hands off to its next role",
|
|
18273
|
-
"subscription-fired": "wakes the agent that subscribed to one outside event"
|
|
18274
|
+
"subscription-fired": "wakes the agent that subscribed to one outside event",
|
|
18275
|
+
"computer-session-activity": "wakes the sharing agent when a person opens, controls, uses, hands back, or closes its browser view"
|
|
18274
18276
|
};
|
|
18275
18277
|
var PER_ITEM_EVENT_KINDS = [
|
|
18276
18278
|
"grant-decided",
|
|
@@ -18280,7 +18282,8 @@ var PER_ITEM_EVENT_KINDS = [
|
|
|
18280
18282
|
"choice-answered",
|
|
18281
18283
|
"choice-skipped",
|
|
18282
18284
|
"poll-closed",
|
|
18283
|
-
"subscription-fired"
|
|
18285
|
+
"subscription-fired",
|
|
18286
|
+
"computer-session-activity"
|
|
18284
18287
|
];
|
|
18285
18288
|
function isPerItemEventKind(value) {
|
|
18286
18289
|
return PER_ITEM_EVENT_KINDS.includes(value);
|
|
@@ -29655,15 +29658,15 @@ async function retryBeforeReady(work, options) {
|
|
|
29655
29658
|
failures += 1;
|
|
29656
29659
|
const timedRetry = ROOM_RETRY_DELAYS_MS[failures - 1];
|
|
29657
29660
|
console.warn(`[thin-core] server unreachable before READY; ${timedRetry === void 0 ? "waiting for the live socket to open" : `retrying in ${timedRetry}ms or on open`}:`, error);
|
|
29658
|
-
let
|
|
29661
|
+
let opened2 = false;
|
|
29659
29662
|
let wake = () => void 0;
|
|
29660
29663
|
const off = options.onLinkOpen(() => {
|
|
29661
|
-
|
|
29664
|
+
opened2 = true;
|
|
29662
29665
|
wake();
|
|
29663
29666
|
});
|
|
29664
29667
|
try {
|
|
29665
29668
|
const waitStarted = now2();
|
|
29666
|
-
while (!
|
|
29669
|
+
while (!opened2 && !options.signal?.aborted) {
|
|
29667
29670
|
const remaining = [
|
|
29668
29671
|
slice,
|
|
29669
29672
|
options.deadlineAt === void 0 ? Infinity : options.deadlineAt - now2(),
|
|
@@ -29682,7 +29685,7 @@ async function retryBeforeReady(work, options) {
|
|
|
29682
29685
|
}
|
|
29683
29686
|
wake = done;
|
|
29684
29687
|
options.signal?.addEventListener("abort", done, { once: true });
|
|
29685
|
-
if (
|
|
29688
|
+
if (opened2 || options.signal?.aborted)
|
|
29686
29689
|
done();
|
|
29687
29690
|
});
|
|
29688
29691
|
}
|
|
@@ -33330,7 +33333,7 @@ Follow your own owner first, then this Workspace's owner and admins, then member
|
|
|
33330
33333
|
|
|
33331
33334
|
A **tool** is something you can use once a human adds it; a **key** is the credential that tool holds for that human. You spend a key through the mounted connector and never see the credential itself.
|
|
33332
33335
|
|
|
33333
|
-
The tools this build knows, what each is for, and which the owner of this machine already has are one call away: beeline-agent connectors_status. That read is the Connectors page for the machine and owner you actually run on, not the person who asked. Connected apps are listed once per app with a stable ID. Their sign-in and credentials stay with the server. Trusty Squire signs up and signs in to any website hands-off for the person; its vault holds keys when needed. operate_drive drives a whole flow, and flat steps (operate_click, operate_type, operate_select, operate_press, operate_scroll, operate_wait, operate_navigate, operate_read_inbox, operate_extract, and the rest of its flat operate_* actions) handle one action at a time. When you
|
|
33336
|
+
The tools this build knows, what each is for, and which the owner of this machine already has are one call away: beeline-agent connectors_status. That read is the Connectors page for the machine and owner you actually run on, not the person who asked. Connected apps are listed once per app with a stable ID. Their sign-in and credentials stay with the server. Trusty Squire signs up and signs in to any website hands-off for the person; its vault holds keys when needed. operate_drive drives a whole flow, and flat steps (operate_click, operate_type, operate_select, operate_press, operate_scroll, operate_wait, operate_navigate, operate_read_inbox, operate_extract, and the rest of its flat operate_* actions) handle one action at a time. When you want to show an existing browser, call share_browser. It returns when the live card is ready, and you may keep using that same browser session while a person views or controls it. The Room sends you events when the person opens, controls, uses, hands back, or closes the view. End the share explicitly with end_browser_share when it is finished. Tailscale installs its CLI on the selected helper and opens Tailscale's own browser sign-in; once connected, use the CLI for tailnet resources and tailscale file cp or tailscale file get for Taildrop. The wallet is created only from the Connectors page. When you cannot reach a tool, say: I can't reach X on this machine because Y; to fix it, Z. Give one explanation, then take or offer Z.
|
|
33334
33337
|
|
|
33335
33338
|
**Inspect your own host before answering.** When a question is about a system on the machine you run on, inspect its live state with the tools you have: processes, logs, local endpoints or service status. Say what you checked. Memory and Room history are not evidence of current state.
|
|
33336
33339
|
|
|
@@ -36752,7 +36755,7 @@ async function runUpdateFunctionalProbe(input) {
|
|
|
36752
36755
|
const sessionTimeoutMs = input.sessionTimeoutMs ?? UPDATE_PROBE_SESSION_TIMEOUT_MS;
|
|
36753
36756
|
const sessionOpenTimeoutMs = input.sessionOpenTimeoutMs ?? input.sessionTimeoutMs ?? UPDATE_PROBE_SESSION_OPEN_TIMEOUT_MS;
|
|
36754
36757
|
const openSessionAndPrompt = async () => {
|
|
36755
|
-
const
|
|
36758
|
+
const opened2 = await client.sessionNew({
|
|
36756
36759
|
cwd,
|
|
36757
36760
|
mcpServers: [],
|
|
36758
36761
|
systemPrompt: "This is Beeline update validation. Answer only READY.",
|
|
@@ -36760,11 +36763,11 @@ async function runUpdateFunctionalProbe(input) {
|
|
|
36760
36763
|
timeoutMs: sessionOpenTimeoutMs
|
|
36761
36764
|
});
|
|
36762
36765
|
if (input.config.modelSelection) {
|
|
36763
|
-
await applyAgentModelSelection(client,
|
|
36766
|
+
await applyAgentModelSelection(client, opened2.sessionId, parseAdvertisedConfigOptions(opened2.raw, input.config.modelSelection.model, isGrokAgentCommand(selectedAgent)), input.config.modelSelection);
|
|
36764
36767
|
}
|
|
36765
36768
|
return {
|
|
36766
|
-
sessionId:
|
|
36767
|
-
served: await client.sessionPrompt(
|
|
36769
|
+
sessionId: opened2.sessionId,
|
|
36770
|
+
served: await client.sessionPrompt(opened2.sessionId, "Reply READY.", input.turnTimeoutMs ?? UPDATE_PROBE_TURN_TIMEOUT_MS)
|
|
36768
36771
|
};
|
|
36769
36772
|
};
|
|
36770
36773
|
try {
|
|
@@ -39345,11 +39348,11 @@ async function runUpdateProbeCommand(args, options = {}) {
|
|
|
39345
39348
|
// apps/body/dist/machine-helper.js
|
|
39346
39349
|
import { mkdir as mkdir32, rename as rename15, stat as stat12, writeFile as writeFile24 } from "node:fs/promises";
|
|
39347
39350
|
import { homedir as homedir20 } from "node:os";
|
|
39348
|
-
import { dirname as
|
|
39351
|
+
import { dirname as dirname33, resolve as resolve51 } from "node:path";
|
|
39349
39352
|
|
|
39350
39353
|
// apps/body/dist/agent-runtime.js
|
|
39351
39354
|
import { homedir as homedir19 } from "node:os";
|
|
39352
|
-
import { dirname as
|
|
39355
|
+
import { dirname as dirname32, join as join23, resolve as resolve49 } from "node:path";
|
|
39353
39356
|
|
|
39354
39357
|
// apps/body/dist/model-availability.js
|
|
39355
39358
|
var SECRET_VALUE = /(?:token|key|secret|password)=?[^\s,;]*/gi;
|
|
@@ -40250,20 +40253,217 @@ function describe2(error) {
|
|
|
40250
40253
|
return error instanceof Error ? error.message : String(error);
|
|
40251
40254
|
}
|
|
40252
40255
|
|
|
40256
|
+
// apps/body/dist/browser-share-host.js
|
|
40257
|
+
import { createConnection as createConnection4, createServer as createServer3 } from "node:net";
|
|
40258
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync3, rmSync as rmSync4 } from "node:fs";
|
|
40259
|
+
import { dirname as dirname22 } from "node:path";
|
|
40260
|
+
|
|
40261
|
+
// apps/body/dist/browser-share.js
|
|
40262
|
+
var shares = /* @__PURE__ */ new Map();
|
|
40263
|
+
function opened(socket) {
|
|
40264
|
+
return new Promise((resolve54, reject) => {
|
|
40265
|
+
socket.once("open", resolve54);
|
|
40266
|
+
socket.once("error", reject);
|
|
40267
|
+
});
|
|
40268
|
+
}
|
|
40269
|
+
async function shareChromiumPage(input) {
|
|
40270
|
+
if (!input.page.webSocketDebuggerUrl)
|
|
40271
|
+
throw new Error("Chromium page has no debugger socket");
|
|
40272
|
+
const cdp = new import_websocket.default(input.page.webSocketDebuggerUrl);
|
|
40273
|
+
await opened(cdp);
|
|
40274
|
+
const source = new URL(`/s/${input.shareId}/source`, input.serverBaseUrl);
|
|
40275
|
+
source.protocol = source.protocol === "https:" ? "wss:" : "ws:";
|
|
40276
|
+
const relay = new import_websocket.default(source, { headers: { authorization: `Bearer ${input.daemonToken}` } });
|
|
40277
|
+
try {
|
|
40278
|
+
await opened(relay);
|
|
40279
|
+
} catch (error) {
|
|
40280
|
+
cdp.close();
|
|
40281
|
+
throw error;
|
|
40282
|
+
}
|
|
40283
|
+
const share = { cdp, relay, controlled: false };
|
|
40284
|
+
shares.get(input.page.id)?.cdp.close();
|
|
40285
|
+
shares.set(input.page.id, share);
|
|
40286
|
+
let serial = 1;
|
|
40287
|
+
const sendCdp = (method, params = {}) => {
|
|
40288
|
+
if (cdp.readyState !== import_websocket.default.OPEN)
|
|
40289
|
+
return void 0;
|
|
40290
|
+
const id = serial++;
|
|
40291
|
+
cdp.send(JSON.stringify({ id, method, params }));
|
|
40292
|
+
return id;
|
|
40293
|
+
};
|
|
40294
|
+
let lastFrameAt = 0;
|
|
40295
|
+
let firstFrameLogged = false;
|
|
40296
|
+
let inputCount = 0;
|
|
40297
|
+
let screenshotId;
|
|
40298
|
+
let screenshotStartedAt = 0;
|
|
40299
|
+
let fallbackTimer;
|
|
40300
|
+
const capture = () => {
|
|
40301
|
+
if (screenshotId !== void 0 && Date.now() - screenshotStartedAt < 5e3)
|
|
40302
|
+
return;
|
|
40303
|
+
screenshotId = sendCdp("Page.captureScreenshot", { format: "jpeg", quality: 65, captureBeyondViewport: false });
|
|
40304
|
+
screenshotStartedAt = Date.now();
|
|
40305
|
+
};
|
|
40306
|
+
cdp.on("message", (data) => {
|
|
40307
|
+
let message;
|
|
40308
|
+
try {
|
|
40309
|
+
message = JSON.parse(data.toString());
|
|
40310
|
+
} catch {
|
|
40311
|
+
return;
|
|
40312
|
+
}
|
|
40313
|
+
if (message.id === screencastId)
|
|
40314
|
+
console.error(`[computer-share] screencast start ${message.error?.message ? `failed: ${message.error.message}` : "accepted"}`);
|
|
40315
|
+
if (screenshotId !== void 0 && message.id === screenshotId) {
|
|
40316
|
+
screenshotId = void 0;
|
|
40317
|
+
if (message.result?.data && relay.readyState === import_websocket.default.OPEN && relay.bufferedAmount < 4 * 1024 * 1024) {
|
|
40318
|
+
if (!firstFrameLogged) {
|
|
40319
|
+
firstFrameLogged = true;
|
|
40320
|
+
console.error("[computer-share] first JPEG forwarded from screenshot");
|
|
40321
|
+
}
|
|
40322
|
+
relay.send(JSON.stringify({ method: "Page.screencastFrame", params: { data: message.result.data, sessionId: 0 } }));
|
|
40323
|
+
} else if (message.error?.message)
|
|
40324
|
+
console.error(`[computer-share] screenshot failed: ${message.error.message}`);
|
|
40325
|
+
return;
|
|
40326
|
+
}
|
|
40327
|
+
if (message.method === "Page.frameNavigated" && message.params?.frame?.url) {
|
|
40328
|
+
try {
|
|
40329
|
+
const url = new URL(message.params.frame.url);
|
|
40330
|
+
if (url.origin !== "null" && relay.readyState === import_websocket.default.OPEN)
|
|
40331
|
+
relay.send(JSON.stringify({ type: "share-event", name: "navigation", detail: url.origin }));
|
|
40332
|
+
} catch {
|
|
40333
|
+
}
|
|
40334
|
+
return;
|
|
40335
|
+
}
|
|
40336
|
+
if (message.method !== "Page.screencastFrame")
|
|
40337
|
+
return;
|
|
40338
|
+
lastFrameAt = Date.now();
|
|
40339
|
+
if (!firstFrameLogged) {
|
|
40340
|
+
firstFrameLogged = true;
|
|
40341
|
+
console.error("[computer-share] first JPEG forwarded from screencast");
|
|
40342
|
+
}
|
|
40343
|
+
if (relay.readyState === import_websocket.default.OPEN && relay.bufferedAmount < 4 * 1024 * 1024)
|
|
40344
|
+
relay.send(data.toString());
|
|
40345
|
+
if (message.params?.sessionId !== void 0)
|
|
40346
|
+
sendCdp("Page.screencastFrameAck", { sessionId: message.params.sessionId });
|
|
40347
|
+
});
|
|
40348
|
+
relay.on("message", (data) => {
|
|
40349
|
+
let message;
|
|
40350
|
+
try {
|
|
40351
|
+
message = JSON.parse(data.toString());
|
|
40352
|
+
} catch {
|
|
40353
|
+
return;
|
|
40354
|
+
}
|
|
40355
|
+
if (message.type === "takeover") {
|
|
40356
|
+
share.controlled = true;
|
|
40357
|
+
console.error("[computer-share] viewer took control");
|
|
40358
|
+
} else if (message.type === "release") {
|
|
40359
|
+
share.controlled = false;
|
|
40360
|
+
console.error("[computer-share] viewer released control");
|
|
40361
|
+
} else if (share.controlled && message.method?.startsWith("Input.")) {
|
|
40362
|
+
if (inputCount++ < 5)
|
|
40363
|
+
console.error(`[computer-share] forwarded ${message.method}`);
|
|
40364
|
+
sendCdp(message.method, message.params ?? {});
|
|
40365
|
+
}
|
|
40366
|
+
});
|
|
40367
|
+
const finish = () => {
|
|
40368
|
+
if (shares.get(input.page.id) !== share)
|
|
40369
|
+
return;
|
|
40370
|
+
shares.delete(input.page.id);
|
|
40371
|
+
clearTimeout(fallbackTimer);
|
|
40372
|
+
cdp.close();
|
|
40373
|
+
relay.close();
|
|
40374
|
+
void input.onEnded();
|
|
40375
|
+
};
|
|
40376
|
+
cdp.once("close", finish);
|
|
40377
|
+
relay.once("close", finish);
|
|
40378
|
+
sendCdp("Page.enable");
|
|
40379
|
+
const screencastId = sendCdp("Page.startScreencast", { format: "jpeg", quality: 65, maxWidth: 1280, maxHeight: 900, everyNthFrame: 1 });
|
|
40380
|
+
capture();
|
|
40381
|
+
const scheduleFallback = () => {
|
|
40382
|
+
fallbackTimer = setTimeout(() => {
|
|
40383
|
+
if (shares.get(input.page.id) !== share)
|
|
40384
|
+
return;
|
|
40385
|
+
if (Date.now() - lastFrameAt > 1500)
|
|
40386
|
+
capture();
|
|
40387
|
+
scheduleFallback();
|
|
40388
|
+
}, 1e3);
|
|
40389
|
+
fallbackTimer.unref();
|
|
40390
|
+
};
|
|
40391
|
+
scheduleFallback();
|
|
40392
|
+
}
|
|
40393
|
+
|
|
40394
|
+
// apps/body/dist/browser-share-host.js
|
|
40395
|
+
var BrowserShareHost = class {
|
|
40396
|
+
socketPath;
|
|
40397
|
+
server;
|
|
40398
|
+
constructor(socketPath) {
|
|
40399
|
+
this.socketPath = socketPath;
|
|
40400
|
+
}
|
|
40401
|
+
async start() {
|
|
40402
|
+
mkdirSync3(dirname22(this.socketPath), { recursive: true, mode: 448 });
|
|
40403
|
+
rmSync4(this.socketPath, { force: true });
|
|
40404
|
+
this.server = createServer3({ allowHalfOpen: true }, (socket) => {
|
|
40405
|
+
let text2 = "";
|
|
40406
|
+
socket.setEncoding("utf8");
|
|
40407
|
+
socket.on("data", (chunk) => {
|
|
40408
|
+
text2 += chunk;
|
|
40409
|
+
if (text2.length > 65536)
|
|
40410
|
+
socket.destroy();
|
|
40411
|
+
});
|
|
40412
|
+
socket.once("end", () => {
|
|
40413
|
+
void (async () => {
|
|
40414
|
+
const request = JSON.parse(text2);
|
|
40415
|
+
if (!request.page?.webSocketDebuggerUrl || !request.shareId || !request.roomId || !request.serverBaseUrl || !request.daemonToken)
|
|
40416
|
+
throw new Error("Invalid browser share request");
|
|
40417
|
+
await shareChromiumPage({
|
|
40418
|
+
page: request.page,
|
|
40419
|
+
shareId: request.shareId,
|
|
40420
|
+
serverBaseUrl: request.serverBaseUrl,
|
|
40421
|
+
daemonToken: request.daemonToken,
|
|
40422
|
+
onEnded: async () => {
|
|
40423
|
+
await fetch(new URL("/v1/daemon/operations/endComputerSession", request.serverBaseUrl), {
|
|
40424
|
+
method: "POST",
|
|
40425
|
+
headers: { authorization: `Bearer ${request.daemonToken}`, "content-type": "application/json" },
|
|
40426
|
+
body: JSON.stringify({ roomId: request.roomId, sessionId: request.page.id }),
|
|
40427
|
+
signal: AbortSignal.timeout(1e4)
|
|
40428
|
+
}).catch(() => {
|
|
40429
|
+
});
|
|
40430
|
+
}
|
|
40431
|
+
});
|
|
40432
|
+
socket.end(JSON.stringify({ ok: true }));
|
|
40433
|
+
})().catch((error) => socket.end(JSON.stringify({ error: error instanceof Error ? error.message : String(error) })));
|
|
40434
|
+
});
|
|
40435
|
+
});
|
|
40436
|
+
await new Promise((resolve54, reject) => {
|
|
40437
|
+
this.server.once("error", reject);
|
|
40438
|
+
this.server.listen(this.socketPath, () => {
|
|
40439
|
+
this.server.off("error", reject);
|
|
40440
|
+
resolve54();
|
|
40441
|
+
});
|
|
40442
|
+
});
|
|
40443
|
+
chmodSync2(this.socketPath, 384);
|
|
40444
|
+
}
|
|
40445
|
+
async stop() {
|
|
40446
|
+
if (this.server)
|
|
40447
|
+
await new Promise((resolve54) => this.server.close(() => resolve54()));
|
|
40448
|
+
this.server = void 0;
|
|
40449
|
+
rmSync4(this.socketPath, { force: true });
|
|
40450
|
+
}
|
|
40451
|
+
};
|
|
40452
|
+
|
|
40253
40453
|
// apps/body/dist/room-runtime.js
|
|
40254
40454
|
import { execFile as execFile19 } from "node:child_process";
|
|
40255
40455
|
import { createHash as createHash16 } from "node:crypto";
|
|
40256
|
-
import { existsSync as existsSync10, mkdirSync as
|
|
40456
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync4 } from "node:fs";
|
|
40257
40457
|
import { lstat as lstat9, mkdir as mkdir30, readdir as readdir13, realpath as realpath4, rm as rm21 } from "node:fs/promises";
|
|
40258
|
-
import { dirname as
|
|
40458
|
+
import { dirname as dirname30, relative as relative4, resolve as resolve44, sep as sep4 } from "node:path";
|
|
40259
40459
|
import { promisify as promisify13 } from "node:util";
|
|
40260
40460
|
|
|
40261
40461
|
// apps/body/dist/grant-runner.js
|
|
40262
40462
|
import { execFile as execFile11 } from "node:child_process";
|
|
40263
40463
|
import { createHash as createHash13, randomBytes as randomBytes9, randomUUID as randomUUID12 } from "node:crypto";
|
|
40264
40464
|
import { chmod as chmod8, mkdir as mkdir20, readFile as readFile25, readdir as readdir8, rename as rename11, rm as rm15, rmdir, stat as stat9, writeFile as writeFile17 } from "node:fs/promises";
|
|
40265
|
-
import { createServer as
|
|
40266
|
-
import { dirname as
|
|
40465
|
+
import { createServer as createServer4 } from "node:http";
|
|
40466
|
+
import { dirname as dirname23, resolve as resolve32 } from "node:path";
|
|
40267
40467
|
|
|
40268
40468
|
// packages/api-contract/dist/surface-capabilities.js
|
|
40269
40469
|
var SURFACE_CAPABILITY_TABLE = {
|
|
@@ -40300,7 +40500,7 @@ var SANDBOX_STARTED_SCRIPT = ['printf "%s\\n" "$1" >&2', "shift", 'exec "$@"'].j
|
|
|
40300
40500
|
var ROOM_SANDBOX_UNAVAILABLE = "this Room cannot run granted commands: a Room promises a read-only filesystem and that promise is enforced by bubblewrap, which is not usable on this host. Open a corner with open_corner and run it there, where writes belong.";
|
|
40301
40501
|
var ROOM_WRITE_REFUSED_NOTE = "[beeline] the Room filesystem is read-only outside your scratch directory, so this write was refused by the kernel. Open a corner with open_corner to change files.";
|
|
40302
40502
|
function operatorSecretsPath(env = process.env) {
|
|
40303
|
-
return resolve32(
|
|
40503
|
+
return resolve32(dirname23(providerKeyStorePath(env)), "secrets.json");
|
|
40304
40504
|
}
|
|
40305
40505
|
async function readOperatorSecrets(env = process.env) {
|
|
40306
40506
|
const raw = await readFile25(operatorSecretsPath(env), "utf8").catch(() => void 0);
|
|
@@ -40572,7 +40772,7 @@ var GrantRunnerServer = class {
|
|
|
40572
40772
|
if (this.endpoint)
|
|
40573
40773
|
return this.endpoint;
|
|
40574
40774
|
const token = randomBytes9(32).toString("base64url");
|
|
40575
|
-
const server =
|
|
40775
|
+
const server = createServer4((request, response) => {
|
|
40576
40776
|
void this.handle(request, response, token);
|
|
40577
40777
|
});
|
|
40578
40778
|
await new Promise((resolveListen, reject) => {
|
|
@@ -40817,7 +41017,7 @@ import { randomUUID as randomUUID13 } from "node:crypto";
|
|
|
40817
41017
|
import { mkdir as mkdir21, writeFile as writeFile18 } from "node:fs/promises";
|
|
40818
41018
|
import { writeFileSync as writeFileSync4 } from "node:fs";
|
|
40819
41019
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
40820
|
-
import { dirname as
|
|
41020
|
+
import { dirname as dirname24, join as join16 } from "node:path";
|
|
40821
41021
|
var CommandExecutionContext = class {
|
|
40822
41022
|
generationId = randomUUID13();
|
|
40823
41023
|
path;
|
|
@@ -40827,7 +41027,7 @@ var CommandExecutionContext = class {
|
|
|
40827
41027
|
}
|
|
40828
41028
|
async enter(command) {
|
|
40829
41029
|
this.current = command;
|
|
40830
|
-
await mkdir21(
|
|
41030
|
+
await mkdir21(dirname24(this.path), { recursive: true });
|
|
40831
41031
|
await writeFile18(this.path, JSON.stringify({
|
|
40832
41032
|
roomId: command.roomId,
|
|
40833
41033
|
requestId: command.turnRequestId,
|
|
@@ -41115,7 +41315,7 @@ import { createHash as createHash15 } from "node:crypto";
|
|
|
41115
41315
|
import { existsSync as existsSync9 } from "node:fs";
|
|
41116
41316
|
import { mkdir as mkdir29, readFile as readFile33, writeFile as writeFile22 } from "node:fs/promises";
|
|
41117
41317
|
import { homedir as homedir18, hostname as hostname4 } from "node:os";
|
|
41118
|
-
import { dirname as
|
|
41318
|
+
import { dirname as dirname28, join as join21, resolve as resolve42 } from "node:path";
|
|
41119
41319
|
import { promisify as promisify11 } from "node:util";
|
|
41120
41320
|
|
|
41121
41321
|
// apps/body/dist/machine-host.js
|
|
@@ -42427,6 +42627,7 @@ function beelineAgentMcpServer(config, api, context) {
|
|
|
42427
42627
|
{ name: "BEELINE_DAEMON_TOKEN", value: connection.daemonToken },
|
|
42428
42628
|
{ name: "BEELINE_HELPER_VERSION", value: connection.helperVersion },
|
|
42429
42629
|
{ name: "BEELINE_DAEMON_AGENT_ID", value: connection.agentId },
|
|
42630
|
+
...config.browserShareHostSocket ? [{ name: "BEELINE_BROWSER_SHARE_HOST_SOCKET", value: config.browserShareHostSocket }] : [],
|
|
42430
42631
|
{ name: "BEELINE_OPERATOR_HOME", value: config.operatorHome ?? homedir16() },
|
|
42431
42632
|
{ name: "BEELINE_DAEMON_ROOM_ID", value: context.roomId },
|
|
42432
42633
|
{ name: "BEELINE_DAEMON_WORKSPACE_ID", value: context.workspaceId },
|
|
@@ -42599,14 +42800,14 @@ async function awaitInstitutionalContext(fetch2, log2 = console.warn, budgetMs =
|
|
|
42599
42800
|
// apps/body/dist/codegraph.js
|
|
42600
42801
|
import { execFile as execFile16 } from "node:child_process";
|
|
42601
42802
|
import { access as access3, appendFile, mkdir as mkdir24, readFile as readFile31 } from "node:fs/promises";
|
|
42602
|
-
import { dirname as
|
|
42803
|
+
import { dirname as dirname25, isAbsolute as isAbsolute4, resolve as resolve38 } from "node:path";
|
|
42603
42804
|
import { promisify as promisify10 } from "node:util";
|
|
42604
42805
|
var execFileAsync10 = promisify10(execFile16);
|
|
42605
42806
|
var CODEGRAPH_MCP_SERVER_NAME = "codegraph";
|
|
42606
42807
|
var CODEGRAPH_INDEX_PATH = ".codegraph/codegraph.db";
|
|
42607
42808
|
var CODEGRAPH_PREPARE_TIMEOUT_MS = 12e4;
|
|
42608
42809
|
function codegraphIndexDirectory(cwd) {
|
|
42609
|
-
return resolve38(cwd,
|
|
42810
|
+
return resolve38(cwd, dirname25(CODEGRAPH_INDEX_PATH));
|
|
42610
42811
|
}
|
|
42611
42812
|
function codegraphMcpServer(config, cwd, options) {
|
|
42612
42813
|
if (!config.codegraphCommand)
|
|
@@ -42647,7 +42848,7 @@ async function excludeIndexFromGitStatus(cwd) {
|
|
|
42647
42848
|
if (!gitPath)
|
|
42648
42849
|
return;
|
|
42649
42850
|
const path = isAbsolute4(gitPath) ? gitPath : resolve38(cwd, gitPath);
|
|
42650
|
-
await mkdir24(
|
|
42851
|
+
await mkdir24(dirname25(path), { recursive: true });
|
|
42651
42852
|
const existing = await readFile31(path, "utf8").catch(() => "");
|
|
42652
42853
|
if (existing.split("\n").includes(".codegraph/"))
|
|
42653
42854
|
return;
|
|
@@ -42681,7 +42882,7 @@ async function prepareCodegraphIndex(config, cwd) {
|
|
|
42681
42882
|
// apps/body/dist/monolith-room-turn.js
|
|
42682
42883
|
import { mkdir as mkdir26, writeFile as writeFile20 } from "node:fs/promises";
|
|
42683
42884
|
import { homedir as homedir17, hostname as hostname3 } from "node:os";
|
|
42684
|
-
import { dirname as
|
|
42885
|
+
import { dirname as dirname26, join as join19 } from "node:path";
|
|
42685
42886
|
|
|
42686
42887
|
// packages/api-contract/dist/scheduled-prompts.js
|
|
42687
42888
|
var SCHEDULE_SCHEDULER_NAME = "Beeline Scheduler";
|
|
@@ -44321,7 +44522,7 @@ var MonolithRoomTurnLoop = class {
|
|
|
44321
44522
|
}) ? { relay: await this.squireRelay.listen() } : {}
|
|
44322
44523
|
};
|
|
44323
44524
|
const resourceAuthFile = `${this.commandContext.path}.resource-auth.json`;
|
|
44324
|
-
await mkdir26(
|
|
44525
|
+
await mkdir26(dirname26(resourceAuthFile), { recursive: true, mode: 448 });
|
|
44325
44526
|
await writeFile20(resourceAuthFile, JSON.stringify({
|
|
44326
44527
|
...this.options.api.connection(),
|
|
44327
44528
|
turnContextPath: this.commandContext.path
|
|
@@ -44425,6 +44626,7 @@ var MonolithRoomTurnLoop = class {
|
|
|
44425
44626
|
harnessHomeStateDirs: homeStateDirs,
|
|
44426
44627
|
...tmpDir ? { tmpDir } : {},
|
|
44427
44628
|
additionalWritablePaths: [
|
|
44629
|
+
...this.options.config.browserShareHostSocket ? [dirname26(this.options.config.browserShareHostSocket)] : [],
|
|
44428
44630
|
...attachScratchRoot ? [attachScratchRoot] : [],
|
|
44429
44631
|
...codegraphReady ? [codegraphIndexDirectory(this.options.cwd)] : [],
|
|
44430
44632
|
...registryMcpHostBindPaths(configuration.registryMcpRoutes, this.options.config.registryMcpBrokerSocket),
|
|
@@ -44549,25 +44751,25 @@ var MonolithRoomTurnLoop = class {
|
|
|
44549
44751
|
this.sessionSurface = directMessage ? "dm" : "room";
|
|
44550
44752
|
this.turnInstructionPrefix = session.turnPrefix;
|
|
44551
44753
|
this.sessionPromptSectionIds = session.report.map((section) => section.id);
|
|
44552
|
-
const
|
|
44754
|
+
const opened2 = await this.client.sessionNew({
|
|
44553
44755
|
cwd: this.options.cwd,
|
|
44554
44756
|
mcpServers: servers,
|
|
44555
44757
|
mode: "readonly",
|
|
44556
44758
|
systemPrompt: session.systemPrompt
|
|
44557
44759
|
});
|
|
44558
|
-
this.sessionId =
|
|
44760
|
+
this.sessionId = opened2.sessionId;
|
|
44559
44761
|
this.sessionCwd = this.options.cwd;
|
|
44560
44762
|
this.sessionCommit = this.turnCheckout?.commit;
|
|
44561
44763
|
this.sessionFingerprint = fingerprint;
|
|
44562
44764
|
this.sessionCodegraphReady = codegraphReady;
|
|
44563
44765
|
if (selection) {
|
|
44564
|
-
const options = filterAllowedModelConfigOptions(parseAdvertisedConfigOptions(
|
|
44565
|
-
const applied = await applyAgentModelSelection(this.client,
|
|
44766
|
+
const options = filterAllowedModelConfigOptions(parseAdvertisedConfigOptions(opened2.raw, selection.model));
|
|
44767
|
+
const applied = await applyAgentModelSelection(this.client, opened2.sessionId, options, selection);
|
|
44566
44768
|
if (selection.model && applied.appliedSelection.model && applied.appliedSelection.model !== selection.model) {
|
|
44567
44769
|
this.recordModelFallback(applied.appliedSelection, applied.options);
|
|
44568
44770
|
}
|
|
44569
44771
|
}
|
|
44570
|
-
return
|
|
44772
|
+
return opened2.sessionId;
|
|
44571
44773
|
}
|
|
44572
44774
|
/**
|
|
44573
44775
|
* A vanished model id was just substituted for a same-family replacement
|
|
@@ -45615,7 +45817,7 @@ function agentGitIdentityEnv(agent) {
|
|
|
45615
45817
|
import { createHash as createHash14, randomUUID as randomUUID14 } from "node:crypto";
|
|
45616
45818
|
import { constants as fsConstants3 } from "node:fs";
|
|
45617
45819
|
import { chmod as chmod10, copyFile as copyFile2, link, lstat as lstat7, mkdir as mkdir28, readdir as readdir11, readFile as readFile32, readlink as readlink2, rename as rename12, rm as rm19, stat as stat11, symlink as symlink3, utimes } from "node:fs/promises";
|
|
45618
|
-
import { dirname as
|
|
45820
|
+
import { dirname as dirname27, join as join20, resolve as resolve41 } from "node:path";
|
|
45619
45821
|
var STORE_FORMAT = "v1";
|
|
45620
45822
|
var STAGING_PREFIX = ".beeline-warm-";
|
|
45621
45823
|
var STAGING_SWEEP_MS = 24 * 60 * 60 * 1e3;
|
|
@@ -45703,7 +45905,7 @@ async function seedWarmNodeModules(input) {
|
|
|
45703
45905
|
}
|
|
45704
45906
|
for (const tree of plan.trees) {
|
|
45705
45907
|
const target = resolve41(input.worktreePath, tree);
|
|
45706
|
-
await mkdir28(
|
|
45908
|
+
await mkdir28(dirname27(target), { recursive: true });
|
|
45707
45909
|
await rename12(resolve41(staging, tree), target);
|
|
45708
45910
|
placed.push(target);
|
|
45709
45911
|
}
|
|
@@ -46487,7 +46689,7 @@ var MonolithCornerTurnLoop = class {
|
|
|
46487
46689
|
}) ? { relay: await this.squireRelay.listen() } : {}
|
|
46488
46690
|
};
|
|
46489
46691
|
const resourceAuthFile = `${this.commandContext.path}.resource-auth.json`;
|
|
46490
|
-
await mkdir29(
|
|
46692
|
+
await mkdir29(dirname28(resourceAuthFile), { recursive: true, mode: 448 });
|
|
46491
46693
|
await writeFile22(resourceAuthFile, JSON.stringify({
|
|
46492
46694
|
...this.options.api.connection(),
|
|
46493
46695
|
turnContextPath: this.commandContext.path
|
|
@@ -46650,6 +46852,7 @@ var MonolithCornerTurnLoop = class {
|
|
|
46650
46852
|
harnessHomeStateDirs: homeStateDirs,
|
|
46651
46853
|
...tmpDir ? { tmpDir } : {},
|
|
46652
46854
|
additionalWritablePaths: [
|
|
46855
|
+
...this.options.config.browserShareHostSocket ? [dirname28(this.options.config.browserShareHostSocket)] : [],
|
|
46653
46856
|
...attachScratchRoot ? [attachScratchRoot] : [],
|
|
46654
46857
|
...assets ? [] : [npmCacheDir, pnpmStoreDir, turboCacheDir, modelCacheDir],
|
|
46655
46858
|
cargoTargetDir,
|
|
@@ -46802,26 +47005,26 @@ var MonolithCornerTurnLoop = class {
|
|
|
46802
47005
|
});
|
|
46803
47006
|
this.turnSessionPrefix = session.turnPrefix;
|
|
46804
47007
|
this.sessionPromptSectionIds = session.report.map((section) => section.id);
|
|
46805
|
-
const
|
|
47008
|
+
const opened2 = await this.client.sessionNew({
|
|
46806
47009
|
cwd: this.options.worktreePath,
|
|
46807
47010
|
mcpServers: servers,
|
|
46808
47011
|
mode: "edit",
|
|
46809
47012
|
systemPrompt: session.systemPrompt
|
|
46810
47013
|
});
|
|
46811
|
-
this.sessionId =
|
|
47014
|
+
this.sessionId = opened2.sessionId;
|
|
46812
47015
|
this.sessionFingerprint = fingerprint;
|
|
46813
47016
|
this.sessionCodegraphReady = codegraphReady;
|
|
46814
47017
|
let appliedModel;
|
|
46815
47018
|
if (selection) {
|
|
46816
|
-
const options = filterAllowedModelConfigOptions(parseAdvertisedConfigOptions(
|
|
46817
|
-
const applied = await applyAgentModelSelection(this.client,
|
|
47019
|
+
const options = filterAllowedModelConfigOptions(parseAdvertisedConfigOptions(opened2.raw, selection.model));
|
|
47020
|
+
const applied = await applyAgentModelSelection(this.client, opened2.sessionId, options, selection);
|
|
46818
47021
|
appliedModel = applied.appliedSelection.model;
|
|
46819
47022
|
if (selection.model && appliedModel && appliedModel !== selection.model) {
|
|
46820
47023
|
this.recordModelFallback(applied.appliedSelection, applied.options);
|
|
46821
47024
|
}
|
|
46822
47025
|
}
|
|
46823
47026
|
this.sessionModel = appliedModel ?? selection?.model ?? null;
|
|
46824
|
-
return
|
|
47027
|
+
return opened2.sessionId;
|
|
46825
47028
|
}
|
|
46826
47029
|
/**
|
|
46827
47030
|
* A vanished model id was just substituted for a same-family replacement
|
|
@@ -47644,7 +47847,7 @@ ${continuation}` : assembled;
|
|
|
47644
47847
|
// apps/body/dist/corner-disk-recovery.js
|
|
47645
47848
|
import { execFile as execFile18 } from "node:child_process";
|
|
47646
47849
|
import { lstat as lstat8, readdir as readdir12, realpath as realpath3, rm as rm20 } from "node:fs/promises";
|
|
47647
|
-
import { basename as basename10, dirname as
|
|
47850
|
+
import { basename as basename10, dirname as dirname29, join as join22, relative as relative3, resolve as resolve43, sep as sep3 } from "node:path";
|
|
47648
47851
|
import { promisify as promisify12 } from "node:util";
|
|
47649
47852
|
var execFileAsync12 = promisify12(execFile18);
|
|
47650
47853
|
var GENERATED_DIRS = /* @__PURE__ */ new Set([
|
|
@@ -47660,10 +47863,10 @@ var MAX_DIRECTORY_DEPTH = 4;
|
|
|
47660
47863
|
var MAX_VISITED_DIRECTORIES = 5e3;
|
|
47661
47864
|
function cornerRecoveryPointerPath(worktree) {
|
|
47662
47865
|
const checkout = resolve43(worktree.path);
|
|
47663
|
-
if (basename10(checkout) !== worktree.cornerId || basename10(
|
|
47866
|
+
if (basename10(checkout) !== worktree.cornerId || basename10(dirname29(checkout)) !== "corners" || basename10(dirname29(dirname29(checkout))) !== "beeline" || !/^[a-zA-Z0-9-]{1,80}$/.test(worktree.cornerId)) {
|
|
47664
47867
|
throw new Error("refusing recovery pointer outside a Beeline corner checkout");
|
|
47665
47868
|
}
|
|
47666
|
-
return resolve43(
|
|
47869
|
+
return resolve43(dirname29(dirname29(checkout)), "recovery", "corners", `${worktree.cornerId}.json`);
|
|
47667
47870
|
}
|
|
47668
47871
|
async function git(checkout, args) {
|
|
47669
47872
|
const result = await execFileAsync12("git", ["-C", checkout, ...args], {
|
|
@@ -48253,8 +48456,8 @@ async function materializeCornerWorktree(input) {
|
|
|
48253
48456
|
const remote = roomCheckoutRemote(input.remote);
|
|
48254
48457
|
const gitCommonDir = cornerRepositoryCacheDir(input.supervisorRoot, remote);
|
|
48255
48458
|
const path = resolve44(input.supervisorRoot, "beeline", "corners", input.cornerId);
|
|
48256
|
-
await mkdir30(
|
|
48257
|
-
await mkdir30(
|
|
48459
|
+
await mkdir30(dirname30(gitCommonDir), { recursive: true, mode: 448 });
|
|
48460
|
+
await mkdir30(dirname30(path), { recursive: true, mode: 448 });
|
|
48258
48461
|
const authEnv = githubGitEnv(input.token);
|
|
48259
48462
|
if (!existsSync10(resolve44(gitCommonDir, "HEAD"))) {
|
|
48260
48463
|
await execFileAsync13("git", ["clone", "--bare", remote, gitCommonDir], {
|
|
@@ -48358,7 +48561,7 @@ async function mapWithConcurrency(values, limit, visit) {
|
|
|
48358
48561
|
async function discoverCornerWorktree(supervisorRoot2, cornerId) {
|
|
48359
48562
|
const cornersRoot = resolve44(supervisorRoot2, "beeline", "corners");
|
|
48360
48563
|
const path = resolve44(cornersRoot, cornerId);
|
|
48361
|
-
if (
|
|
48564
|
+
if (dirname30(path) !== cornersRoot || !existsSync10(resolve44(path, ".git")))
|
|
48362
48565
|
return void 0;
|
|
48363
48566
|
const [canonicalRoot, canonicalPath] = await Promise.all([
|
|
48364
48567
|
realpath4(cornersRoot),
|
|
@@ -48950,7 +49153,7 @@ var RoomRuntimeCoordinator = class {
|
|
|
48950
49153
|
return this.runtime.rooms.find((room) => room.channelId === roomId);
|
|
48951
49154
|
}
|
|
48952
49155
|
roomRoot(roomId) {
|
|
48953
|
-
return this.roomRecord(roomId)?.root ?? resolve44(
|
|
49156
|
+
return this.roomRecord(roomId)?.root ?? resolve44(dirname30(this.configPath), "rooms", roomId);
|
|
48954
49157
|
}
|
|
48955
49158
|
roomAgentHomeRoot(workspaceRoot, required = false) {
|
|
48956
49159
|
const flag = process.env.BUZZY_BODY_ROOM_HOME;
|
|
@@ -48960,7 +49163,7 @@ var RoomRuntimeCoordinator = class {
|
|
|
48960
49163
|
if (!required && flag !== "1" && !existsSync10(home) && existsSync10(workspaceRoot))
|
|
48961
49164
|
return void 0;
|
|
48962
49165
|
try {
|
|
48963
|
-
|
|
49166
|
+
mkdirSync4(home, { recursive: true, mode: 448 });
|
|
48964
49167
|
return home;
|
|
48965
49168
|
} catch (error) {
|
|
48966
49169
|
console.error(`[thin-core] per-room agent home unavailable at ${home}:`, error);
|
|
@@ -48974,9 +49177,9 @@ var RoomRuntimeCoordinator = class {
|
|
|
48974
49177
|
workspaceRoot,
|
|
48975
49178
|
...process.env.BEELINE_SHARED_ASSETS_ENABLED === "0" ? { agentSharedAssetRoot: void 0 } : { agentSharedAssetRoot: workspaceAssetRoot(this.runtime.supervisorRoot, this.runtime.communityId) },
|
|
48976
49179
|
agentPrivateRoot: resolve44(workspaceRoot, "agent-private"),
|
|
48977
|
-
agentMemoryRoot: resolve44(
|
|
48978
|
-
openRouterRoutingCacheDir: openRouterRoutingCacheDir(
|
|
48979
|
-
turnTraceDir: turnTraceDirectory(
|
|
49180
|
+
agentMemoryRoot: resolve44(dirname30(this.configPath), "memory"),
|
|
49181
|
+
openRouterRoutingCacheDir: openRouterRoutingCacheDir(dirname30(this.configPath)),
|
|
49182
|
+
turnTraceDir: turnTraceDirectory(dirname30(this.configPath)),
|
|
48980
49183
|
...agentHomeRoot ? { agentHomeRoot } : {}
|
|
48981
49184
|
};
|
|
48982
49185
|
}
|
|
@@ -49058,7 +49261,7 @@ var RoomRuntimeCoordinator = class {
|
|
|
49058
49261
|
const targetBranch = repository.targetBranch || "main";
|
|
49059
49262
|
const checkoutId = createHash16("sha256").update(`${roomId}\0${remote}\0${targetBranch}`).digest("hex").slice(0, 24);
|
|
49060
49263
|
const path = resolve44(this.runtime.supervisorRoot, "beeline", "room-checkouts", checkoutId);
|
|
49061
|
-
await mkdir30(
|
|
49264
|
+
await mkdir30(dirname30(path), { recursive: true, mode: 448 });
|
|
49062
49265
|
const token = remote.startsWith("https://github.com/") ? await this.parentRepositoryToken(roomId) : void 0;
|
|
49063
49266
|
const env = token ? githubGitEnv(token.token) : process.env;
|
|
49064
49267
|
if (!existsSync10(resolve44(path, ".git"))) {
|
|
@@ -49632,7 +49835,7 @@ var RoomRuntimeCoordinator = class {
|
|
|
49632
49835
|
async cleanupArchivedCornerLocalState(cornerId, knownArchive) {
|
|
49633
49836
|
if (this.running.has(cornerId) || this.startingCorners.has(cornerId))
|
|
49634
49837
|
return false;
|
|
49635
|
-
const root = resolve44(
|
|
49838
|
+
const root = resolve44(dirname30(this.configPath), "rooms", cornerId);
|
|
49636
49839
|
if (this.roomRoot(cornerId) !== root || !/^[a-zA-Z0-9-]{1,80}$/.test(cornerId))
|
|
49637
49840
|
return false;
|
|
49638
49841
|
const info = await lstat9(root).catch(() => void 0);
|
|
@@ -49663,7 +49866,7 @@ var RoomRuntimeCoordinator = class {
|
|
|
49663
49866
|
* checkout has already gone; a scratch directory identifies legacy chat
|
|
49664
49867
|
* corners. Active scratch gets a 14-day file TTL, never a wholesale reap. */
|
|
49665
49868
|
async sweepCornerLocalState(archived, desired) {
|
|
49666
|
-
const root = resolve44(
|
|
49869
|
+
const root = resolve44(dirname30(this.configPath), "rooms");
|
|
49667
49870
|
const due = this.now() - this.lastCornerScratchSweepAt >= 6 * 60 * 6e4;
|
|
49668
49871
|
if (due)
|
|
49669
49872
|
this.lastCornerScratchSweepAt = this.now();
|
|
@@ -49969,7 +50172,7 @@ var ThinDaemonCore = class {
|
|
|
49969
50172
|
};
|
|
49970
50173
|
|
|
49971
50174
|
// apps/body/dist/force-update-journal.js
|
|
49972
|
-
import { mkdirSync as
|
|
50175
|
+
import { mkdirSync as mkdirSync5, readFileSync as readFileSync11, renameSync as renameSync2, writeFileSync as writeFileSync5 } from "node:fs";
|
|
49973
50176
|
import { resolve as resolve45 } from "node:path";
|
|
49974
50177
|
var NAME = "force-update-interruptions.json";
|
|
49975
50178
|
function pathFor(runtimeDir) {
|
|
@@ -49995,7 +50198,7 @@ function read(runtimeDir) {
|
|
|
49995
50198
|
}
|
|
49996
50199
|
}
|
|
49997
50200
|
function write(runtimeDir, rows) {
|
|
49998
|
-
|
|
50201
|
+
mkdirSync5(runtimeDir, { recursive: true, mode: 448 });
|
|
49999
50202
|
const target = pathFor(runtimeDir);
|
|
50000
50203
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
50001
50204
|
writeFileSync5(temporary, `${JSON.stringify(rows)}
|
|
@@ -50051,7 +50254,7 @@ function staleGeneration(error) {
|
|
|
50051
50254
|
init_launchd();
|
|
50052
50255
|
init_systemd();
|
|
50053
50256
|
import { mkdir as mkdir31, rename as rename13 } from "node:fs/promises";
|
|
50054
|
-
import { dirname as
|
|
50257
|
+
import { dirname as dirname31, resolve as resolve46 } from "node:path";
|
|
50055
50258
|
async function retireRemovedAgent(runtime, options = {}) {
|
|
50056
50259
|
const deletedRoot = resolve46(runtime.supervisorRoot, "beeline", "deleted-runtimes");
|
|
50057
50260
|
const target = resolve46(deletedRoot, `${runtime.agent.publicKey}-${Date.now()}`);
|
|
@@ -50074,7 +50277,7 @@ async function relocateAgentRuntime(runtime, target, options = {}) {
|
|
|
50074
50277
|
...options.run ? { run: options.run } : {}
|
|
50075
50278
|
});
|
|
50076
50279
|
}
|
|
50077
|
-
await mkdir31(
|
|
50280
|
+
await mkdir31(dirname31(destination), { recursive: true, mode: 448 });
|
|
50078
50281
|
await rename13(source, destination);
|
|
50079
50282
|
return destination;
|
|
50080
50283
|
}
|
|
@@ -50200,7 +50403,7 @@ function runScratchSweepLogged(runtimeDir) {
|
|
|
50200
50403
|
void runScratchSweep(runtimeDir).catch((error) => console.error("[body] scratch sweep failed:", error));
|
|
50201
50404
|
}
|
|
50202
50405
|
async function runAgentRuntime(configPath, host, signal) {
|
|
50203
|
-
const runtimeDir =
|
|
50406
|
+
const runtimeDir = dirname32(configPath);
|
|
50204
50407
|
await convergeRuntimeRecordFileModes(configPath);
|
|
50205
50408
|
const accessMigration = await migrateRuntimeRecordAccessPolicy(configPath);
|
|
50206
50409
|
let runtime = accessMigration.runtime;
|
|
@@ -50314,6 +50517,7 @@ async function runAgentRuntime(configPath, host, signal) {
|
|
|
50314
50517
|
let connectorLoop;
|
|
50315
50518
|
let agentSignIn;
|
|
50316
50519
|
let registryMcpBroker;
|
|
50520
|
+
let browserShareHost;
|
|
50317
50521
|
let catalogRefresh;
|
|
50318
50522
|
let leaveHost;
|
|
50319
50523
|
const refreshCatalog = () => {
|
|
@@ -50352,6 +50556,9 @@ async function runAgentRuntime(configPath, host, signal) {
|
|
|
50352
50556
|
);
|
|
50353
50557
|
await registryMcpBroker.start();
|
|
50354
50558
|
config.registryMcpBrokerSocket = registryMcpBroker.socketPath;
|
|
50559
|
+
browserShareHost = new BrowserShareHost(join23(process.env.XDG_STATE_HOME ?? config.operatorHome ?? homedir19(), ".bs", `${process.pid}-${agentId.slice(0, 8)}.sock`));
|
|
50560
|
+
await browserShareHost.start();
|
|
50561
|
+
config.browserShareHostSocket = browserShareHost.socketPath;
|
|
50355
50562
|
let lifecycleRestart;
|
|
50356
50563
|
const core = new ThinDaemonCore(runtime, configPath, config, {
|
|
50357
50564
|
daemonApi,
|
|
@@ -50525,6 +50732,7 @@ async function runAgentRuntime(configPath, host, signal) {
|
|
|
50525
50732
|
connectorLoop?.stop();
|
|
50526
50733
|
agentSignIn?.stop();
|
|
50527
50734
|
await registryMcpBroker?.stop();
|
|
50735
|
+
await browserShareHost?.stop();
|
|
50528
50736
|
daemonApi.closeLive();
|
|
50529
50737
|
await clearDaemonPidRecordIfPid(configPath, process.pid);
|
|
50530
50738
|
}
|
|
@@ -50736,7 +50944,7 @@ async function runMachineHelper(options = {}) {
|
|
|
50736
50944
|
const settle = await settleUpdateAttemptOnStart(layout);
|
|
50737
50945
|
if (settle.kind === "rolled-back") {
|
|
50738
50946
|
for (const path of await hostedRuntimes())
|
|
50739
|
-
await queueUpdateRollbackAlert(
|
|
50947
|
+
await queueUpdateRollbackAlert(dirname33(path), settle.record.releaseId);
|
|
50740
50948
|
console.error(`[helper] self-update ROLLED BACK: bundle ${describeIdentity(settle.record.to)} never confirmed healthy; restored ${settle.record.previousReleaseId ?? "previous release"}`);
|
|
50741
50949
|
return finish(await standDownForRollback());
|
|
50742
50950
|
}
|
|
@@ -50778,7 +50986,7 @@ async function runMachineHelper(options = {}) {
|
|
|
50778
50986
|
since: new Date(slot.since).toISOString()
|
|
50779
50987
|
}]))
|
|
50780
50988
|
};
|
|
50781
|
-
await mkdir32(
|
|
50989
|
+
await mkdir32(dirname33(path), { recursive: true, mode: 448 });
|
|
50782
50990
|
const staged = `${path}.${process.pid}.tmp`;
|
|
50783
50991
|
await writeFile24(staged, `${JSON.stringify(body, null, 2)}
|
|
50784
50992
|
`, { mode: 384 });
|
|
@@ -50942,7 +51150,7 @@ async function runMachineHelper(options = {}) {
|
|
|
50942
51150
|
reason = await runAgent(slot.configPath, host, slot.controller.signal);
|
|
50943
51151
|
} catch (error) {
|
|
50944
51152
|
console.error(`[helper] agent ${slot.agentId} failed:`, error);
|
|
50945
|
-
const failure = await settleDaemonStartFailure(
|
|
51153
|
+
const failure = await settleDaemonStartFailure(dirname33(slot.configPath), error).catch(() => ({ distressed: false }));
|
|
50946
51154
|
if (failure.distressed) {
|
|
50947
51155
|
console.error(`[helper] agent ${slot.agentId} failed to start ${failure.count} times; it stays stopped. operator record: ${failure.path}`);
|
|
50948
51156
|
reason = "distress";
|
|
@@ -50991,7 +51199,7 @@ async function runMachineHelper(options = {}) {
|
|
|
50991
51199
|
const runtime = await readRuntimeRecord(configPath).catch(() => void 0);
|
|
50992
51200
|
const slot = existing ?? {
|
|
50993
51201
|
configPath,
|
|
50994
|
-
agentId: runtime?.agent.publicKey ??
|
|
51202
|
+
agentId: runtime?.agent.publicKey ?? dirname33(configPath).split("/").at(-1),
|
|
50995
51203
|
controller: new AbortController(),
|
|
50996
51204
|
state: "starting",
|
|
50997
51205
|
status: "",
|
|
@@ -51096,7 +51304,7 @@ async function waitForPreviousHolder(configPath, signal) {
|
|
|
51096
51304
|
return;
|
|
51097
51305
|
if (!announced) {
|
|
51098
51306
|
announced = true;
|
|
51099
|
-
console.log(`[helper] waiting for process ${pid} to let go of ${
|
|
51307
|
+
console.log(`[helper] waiting for process ${pid} to let go of ${dirname33(configPath)}`);
|
|
51100
51308
|
}
|
|
51101
51309
|
const waited = Date.now() - startedAt;
|
|
51102
51310
|
if (waited >= PREVIOUS_HOLDER_WAIT_MS && !asked) {
|
|
@@ -51131,7 +51339,7 @@ function sleep3(ms, signal) {
|
|
|
51131
51339
|
import { execFileSync, spawn as spawn15 } from "node:child_process";
|
|
51132
51340
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
51133
51341
|
import { cp as cp2, mkdir as mkdir33, open as open6, readFile as readFile35, rm as rm23, stat as stat13, writeFile as writeFile25 } from "node:fs/promises";
|
|
51134
|
-
import { createServer as
|
|
51342
|
+
import { createServer as createServer5 } from "node:net";
|
|
51135
51343
|
import { existsSync as existsSync11 } from "node:fs";
|
|
51136
51344
|
import { resolve as resolve52 } from "node:path";
|
|
51137
51345
|
var FIRST_PORT = 5554;
|
|
@@ -51157,7 +51365,7 @@ async function processStart(pid) {
|
|
|
51157
51365
|
}
|
|
51158
51366
|
async function portFree(port) {
|
|
51159
51367
|
return new Promise((done) => {
|
|
51160
|
-
const server =
|
|
51368
|
+
const server = createServer5();
|
|
51161
51369
|
server.once("error", () => done(false));
|
|
51162
51370
|
server.listen(port, "127.0.0.1", () => server.close(() => done(true)));
|
|
51163
51371
|
});
|
|
@@ -51461,7 +51669,7 @@ async function main() {
|
|
|
51461
51669
|
if (!agentPubkey)
|
|
51462
51670
|
throw new Error("stop requires --agent <pubkey>");
|
|
51463
51671
|
const configs = await findAgentRuntimeConfigPaths(process.env, process.cwd());
|
|
51464
|
-
const configPath = configs.find((candidate) =>
|
|
51672
|
+
const configPath = configs.find((candidate) => dirname34(candidate).endsWith(agentPubkey));
|
|
51465
51673
|
if (!configPath)
|
|
51466
51674
|
throw new Error(`no stored runtime found for agent ${agentPubkey}`);
|
|
51467
51675
|
const runtime = await readRuntimeRecord(configPath);
|