@moxt-ai/mobius 0.0.313 → 0.0.315
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/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +7 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli.js +423 -327
- package/dist/cli.js.map +4 -4
- package/dist/daemon/lifecycle/worker.d.ts.map +1 -1
- package/dist/daemon/lifecycle/worker.js +22 -2
- package/dist/daemon/lifecycle/worker.js.map +1 -1
- package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts +1 -1
- package/dist/runtime/catalog/handle-agent-catalog-discovery.d.ts.map +1 -1
- package/dist/runtime/catalog/handle-agent-catalog-discovery.js +2 -5
- package/dist/runtime/catalog/handle-agent-catalog-discovery.js.map +1 -1
- package/dist/runtime/catalog/refresh-agent-catalog.d.ts +9 -0
- package/dist/runtime/catalog/refresh-agent-catalog.d.ts.map +1 -0
- package/dist/runtime/catalog/refresh-agent-catalog.js +13 -0
- package/dist/runtime/catalog/refresh-agent-catalog.js.map +1 -0
- package/dist/runtime.js +13 -8
- package/dist/runtime.js.map +4 -4
- package/dist/storage/state-root.d.ts +12 -0
- package/dist/storage/state-root.d.ts.map +1 -0
- package/dist/storage/state-root.js +59 -0
- package/dist/storage/state-root.js.map +1 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2086,7 +2086,7 @@ var init_package = __esm({
|
|
|
2086
2086
|
"package.json"() {
|
|
2087
2087
|
package_default = {
|
|
2088
2088
|
name: "@moxt-ai/mobius",
|
|
2089
|
-
version: "0.0.
|
|
2089
|
+
version: "0.0.315",
|
|
2090
2090
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
2091
2091
|
type: "module",
|
|
2092
2092
|
bin: {
|
|
@@ -5605,6 +5605,161 @@ var init_commander = __esm({
|
|
|
5605
5605
|
}
|
|
5606
5606
|
});
|
|
5607
5607
|
|
|
5608
|
+
// src/util/node-error.ts
|
|
5609
|
+
function isNodeError(error62, code) {
|
|
5610
|
+
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
|
|
5611
|
+
}
|
|
5612
|
+
var init_node_error = __esm({
|
|
5613
|
+
"src/util/node-error.ts"() {
|
|
5614
|
+
"use strict";
|
|
5615
|
+
}
|
|
5616
|
+
});
|
|
5617
|
+
|
|
5618
|
+
// src/storage/installation/installation-files.ts
|
|
5619
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
5620
|
+
import { mkdir, open, readdir, rename, unlink, writeFile } from "node:fs/promises";
|
|
5621
|
+
import { dirname, join } from "node:path";
|
|
5622
|
+
function applicationDirectory(root, applicationId) {
|
|
5623
|
+
return join(root, "installations", applicationId);
|
|
5624
|
+
}
|
|
5625
|
+
function installationPointerPath(applicationDirectory2) {
|
|
5626
|
+
return join(applicationDirectory2, "current.json");
|
|
5627
|
+
}
|
|
5628
|
+
function installationDirectory(applicationDirectory2, installationId2) {
|
|
5629
|
+
return join(applicationDirectory2, installationId2);
|
|
5630
|
+
}
|
|
5631
|
+
function connectionDirectory(installationDirectory2) {
|
|
5632
|
+
return join(installationDirectory2, "connections");
|
|
5633
|
+
}
|
|
5634
|
+
function connectionFilePath(connectionDirectory2, connectionId2) {
|
|
5635
|
+
return join(connectionDirectory2, `${connectionId2}.json`);
|
|
5636
|
+
}
|
|
5637
|
+
function channelIndexFilePath(installationDirectory2, channelId) {
|
|
5638
|
+
return join(installationDirectory2, "channels", `mci_${createHash("sha256").update(channelId).digest("hex")}.json`);
|
|
5639
|
+
}
|
|
5640
|
+
async function readInstallationFile(path8) {
|
|
5641
|
+
let handle;
|
|
5642
|
+
try {
|
|
5643
|
+
handle = await open(path8, "r");
|
|
5644
|
+
} catch (cause) {
|
|
5645
|
+
return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
|
|
5646
|
+
}
|
|
5647
|
+
try {
|
|
5648
|
+
const metadata = await handle.stat();
|
|
5649
|
+
if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
|
|
5650
|
+
return { kind: "not-a-small-file" };
|
|
5651
|
+
}
|
|
5652
|
+
return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
|
|
5653
|
+
} finally {
|
|
5654
|
+
await handle.close();
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
async function writeInstallationFile(path8, text2, signal) {
|
|
5658
|
+
signal.throwIfAborted();
|
|
5659
|
+
const directory = dirname(path8);
|
|
5660
|
+
const temporaryPath = join(directory, `.${randomUUID()}.tmp`);
|
|
5661
|
+
try {
|
|
5662
|
+
await mkdir(directory, { mode: 448, recursive: true });
|
|
5663
|
+
signal.throwIfAborted();
|
|
5664
|
+
await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
|
|
5665
|
+
signal.throwIfAborted();
|
|
5666
|
+
await rename(temporaryPath, path8);
|
|
5667
|
+
} catch (cause) {
|
|
5668
|
+
await unlink(temporaryPath).catch(() => void 0);
|
|
5669
|
+
throw cause;
|
|
5670
|
+
}
|
|
5671
|
+
}
|
|
5672
|
+
async function createInstallationFile(path8, text2) {
|
|
5673
|
+
await writeFile(path8, text2, { flag: "wx", mode: 384 });
|
|
5674
|
+
}
|
|
5675
|
+
async function listInstallationFiles(directory) {
|
|
5676
|
+
return await readdir(directory);
|
|
5677
|
+
}
|
|
5678
|
+
async function removeInstallationFile(path8) {
|
|
5679
|
+
await unlink(path8);
|
|
5680
|
+
}
|
|
5681
|
+
var MAXIMUM_FILE_BYTES;
|
|
5682
|
+
var init_installation_files = __esm({
|
|
5683
|
+
"src/storage/installation/installation-files.ts"() {
|
|
5684
|
+
"use strict";
|
|
5685
|
+
init_node_error();
|
|
5686
|
+
MAXIMUM_FILE_BYTES = 16 * 1024;
|
|
5687
|
+
}
|
|
5688
|
+
});
|
|
5689
|
+
|
|
5690
|
+
// src/storage/state-directory.ts
|
|
5691
|
+
import { homedir } from "node:os";
|
|
5692
|
+
import { join as join2, resolve } from "node:path";
|
|
5693
|
+
function readStateDirectory(environment = process.env) {
|
|
5694
|
+
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
5695
|
+
if (configured !== void 0 && configured.length > 0) {
|
|
5696
|
+
return resolve(configured);
|
|
5697
|
+
}
|
|
5698
|
+
return join2(homedir(), ".mobius");
|
|
5699
|
+
}
|
|
5700
|
+
var init_state_directory = __esm({
|
|
5701
|
+
"src/storage/state-directory.ts"() {
|
|
5702
|
+
"use strict";
|
|
5703
|
+
}
|
|
5704
|
+
});
|
|
5705
|
+
|
|
5706
|
+
// src/storage/state-root.ts
|
|
5707
|
+
import { readFile, stat } from "node:fs/promises";
|
|
5708
|
+
import { basename, dirname as dirname2, join as join3 } from "node:path";
|
|
5709
|
+
async function exists(path8) {
|
|
5710
|
+
return await stat(path8).then(
|
|
5711
|
+
() => true,
|
|
5712
|
+
() => false
|
|
5713
|
+
);
|
|
5714
|
+
}
|
|
5715
|
+
async function owningRoot(directory) {
|
|
5716
|
+
const application = dirname2(directory);
|
|
5717
|
+
const installations = dirname2(application);
|
|
5718
|
+
if (basename(installations) !== "installations") {
|
|
5719
|
+
return null;
|
|
5720
|
+
}
|
|
5721
|
+
let pointer;
|
|
5722
|
+
try {
|
|
5723
|
+
pointer = JSON.parse(await readFile(installationPointerPath(application), "utf8"));
|
|
5724
|
+
} catch {
|
|
5725
|
+
return null;
|
|
5726
|
+
}
|
|
5727
|
+
if (typeof pointer !== "object" || pointer === null || !("installationId" in pointer) || pointer.installationId !== basename(directory)) {
|
|
5728
|
+
return null;
|
|
5729
|
+
}
|
|
5730
|
+
const container = dirname2(installations);
|
|
5731
|
+
return basename(dirname2(container)) === "versions" ? dirname2(dirname2(container)) : container;
|
|
5732
|
+
}
|
|
5733
|
+
async function validateStateRoot(environment) {
|
|
5734
|
+
const directory = readStateDirectory(environment);
|
|
5735
|
+
if (await exists(join3(directory, "current-data.txt")) || await exists(join3(directory, "versions"))) {
|
|
5736
|
+
return;
|
|
5737
|
+
}
|
|
5738
|
+
const root = await owningRoot(directory);
|
|
5739
|
+
if (root !== null) {
|
|
5740
|
+
throw new StateRootError(directory, root);
|
|
5741
|
+
}
|
|
5742
|
+
}
|
|
5743
|
+
var StateRootError;
|
|
5744
|
+
var init_state_root = __esm({
|
|
5745
|
+
"src/storage/state-root.ts"() {
|
|
5746
|
+
"use strict";
|
|
5747
|
+
init_installation_files();
|
|
5748
|
+
init_state_directory();
|
|
5749
|
+
StateRootError = class extends Error {
|
|
5750
|
+
code = "state_root_is_installation_data";
|
|
5751
|
+
owningRoot;
|
|
5752
|
+
constructor(stateDirectory, owningRoot2) {
|
|
5753
|
+
super(
|
|
5754
|
+
`MOBIUS_STATE_DIRECTORY (${stateDirectory}) is Mobius installation data, not a state root. Use the state root that owns it: MOBIUS_STATE_DIRECTORY=${owningRoot2}`
|
|
5755
|
+
);
|
|
5756
|
+
this.name = "StateRootError";
|
|
5757
|
+
this.owningRoot = owningRoot2;
|
|
5758
|
+
}
|
|
5759
|
+
};
|
|
5760
|
+
}
|
|
5761
|
+
});
|
|
5762
|
+
|
|
5608
5763
|
// src/acp/harness/claude/parent-lifeline.ts
|
|
5609
5764
|
import { spawn } from "node:child_process";
|
|
5610
5765
|
import { Duplex } from "node:stream";
|
|
@@ -41746,7 +41901,7 @@ var init_background_task_notifications = __esm({
|
|
|
41746
41901
|
});
|
|
41747
41902
|
|
|
41748
41903
|
// src/acp/harness/claude/upstream/dist/elicitation.js
|
|
41749
|
-
import { randomUUID as
|
|
41904
|
+
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
41750
41905
|
import { CreateElicitationResponse } from "@agentclientprotocol/sdk";
|
|
41751
41906
|
function mcpElicitationToCreateRequest(request, sessionId) {
|
|
41752
41907
|
if (request.mode === "url") {
|
|
@@ -41761,7 +41916,7 @@ function mcpElicitationToCreateRequest(request, sessionId) {
|
|
|
41761
41916
|
// URL elicitations need a stable id so the client can correlate the
|
|
41762
41917
|
// later `session/complete_elicitation` notification. MCP servers usually
|
|
41763
41918
|
// provide one; fall back to a generated id if not.
|
|
41764
|
-
elicitationId: request.elicitationId ??
|
|
41919
|
+
elicitationId: request.elicitationId ?? randomUUID3()
|
|
41765
41920
|
};
|
|
41766
41921
|
}
|
|
41767
41922
|
return {
|
|
@@ -47644,7 +47799,7 @@ function isBackEdge(ctx, value) {
|
|
|
47644
47799
|
const backEdges = ctx[STATE]?.backEdges;
|
|
47645
47800
|
return backEdges !== void 0 && isRef(value) && backEdges.has(value);
|
|
47646
47801
|
}
|
|
47647
|
-
var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff,
|
|
47802
|
+
var $ZodCyclicError, STATE, NO_ISSUES, recursive, NONE, ASSUMED, PROVEN, handoff, open4, memo;
|
|
47648
47803
|
var init_memoizer = __esm({
|
|
47649
47804
|
"../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/core/memoizer.js"() {
|
|
47650
47805
|
init_util();
|
|
@@ -47660,7 +47815,7 @@ var init_memoizer = __esm({
|
|
|
47660
47815
|
NONE = 0;
|
|
47661
47816
|
ASSUMED = 1;
|
|
47662
47817
|
PROVEN = 2;
|
|
47663
|
-
|
|
47818
|
+
open4 = [];
|
|
47664
47819
|
memo = {
|
|
47665
47820
|
alloc(_inst, payload, empty) {
|
|
47666
47821
|
const bucket = handoff;
|
|
@@ -47669,7 +47824,7 @@ var init_memoizer = __esm({
|
|
|
47669
47824
|
handoff = void 0;
|
|
47670
47825
|
const entry = { value: empty, issues: null };
|
|
47671
47826
|
bucket.set(payload.value, entry);
|
|
47672
|
-
|
|
47827
|
+
open4.push(entry);
|
|
47673
47828
|
return empty;
|
|
47674
47829
|
},
|
|
47675
47830
|
guard(inst) {
|
|
@@ -47740,10 +47895,10 @@ var init_memoizer = __esm({
|
|
|
47740
47895
|
return payload;
|
|
47741
47896
|
}
|
|
47742
47897
|
handoff = bucket;
|
|
47743
|
-
const depth =
|
|
47898
|
+
const depth = open4.length;
|
|
47744
47899
|
const result = base(payload, ctx);
|
|
47745
47900
|
handoff = void 0;
|
|
47746
|
-
const entry =
|
|
47901
|
+
const entry = open4.length > depth ? open4.pop() : void 0;
|
|
47747
47902
|
if (result instanceof Promise) {
|
|
47748
47903
|
return result.then((r) => {
|
|
47749
47904
|
if (entry)
|
|
@@ -65163,7 +65318,7 @@ var init_session_mode = __esm({
|
|
|
65163
65318
|
|
|
65164
65319
|
// src/acp/harness/claude/upstream/dist/acp-agent.js
|
|
65165
65320
|
import { execFile } from "node:child_process";
|
|
65166
|
-
import { randomUUID as
|
|
65321
|
+
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
65167
65322
|
import { existsSync as existsSync3 } from "node:fs";
|
|
65168
65323
|
import * as fs4 from "node:fs/promises";
|
|
65169
65324
|
import * as os3 from "node:os";
|
|
@@ -65439,7 +65594,7 @@ async function authenticateMcpServer(host, sessionId, query, serverName) {
|
|
|
65439
65594
|
if (!login.authUrl) {
|
|
65440
65595
|
throw new Error("Claude Code requested user action without returning an authorization URL");
|
|
65441
65596
|
}
|
|
65442
|
-
const elicitationId = `mcp-oauth-${
|
|
65597
|
+
const elicitationId = `mcp-oauth-${randomUUID4()}`;
|
|
65443
65598
|
const flowAbort = new AbortController();
|
|
65444
65599
|
const abortFlow = () => flowAbort.abort(session.abortController.signal.reason);
|
|
65445
65600
|
session.abortController.signal.addEventListener("abort", abortFlow, { once: true });
|
|
@@ -67294,7 +67449,7 @@ var init_acp_agent = __esm({
|
|
|
67294
67449
|
await this.publishTaskPlan(params.sessionId, session.taskState);
|
|
67295
67450
|
}
|
|
67296
67451
|
const userMessage = promptToClaude(params);
|
|
67297
|
-
const promptUuid =
|
|
67452
|
+
const promptUuid = randomUUID4();
|
|
67298
67453
|
userMessage.uuid = promptUuid;
|
|
67299
67454
|
const firstText = params.prompt[0]?.type === "text" ? params.prompt[0].text : "";
|
|
67300
67455
|
const isLocalOnlyCommand = firstText.startsWith("/") && LOCAL_ONLY_COMMANDS.has(firstText.split(" ", 1)[0]);
|
|
@@ -67446,7 +67601,7 @@ var init_acp_agent = __esm({
|
|
|
67446
67601
|
prompt: params.prompt
|
|
67447
67602
|
};
|
|
67448
67603
|
const userMessage = promptToClaude(promptRequest);
|
|
67449
|
-
const steeredUuid =
|
|
67604
|
+
const steeredUuid = randomUUID4();
|
|
67450
67605
|
userMessage.uuid = steeredUuid;
|
|
67451
67606
|
userMessage.priority = (session.pendingUserInputCount ?? 0) > 0 ? STEER_PRIORITY_LATER : STEER_PRIORITY_NOW;
|
|
67452
67607
|
turnInFlight.steeredEchoes ??= /* @__PURE__ */ new Set();
|
|
@@ -67839,7 +67994,7 @@ var init_acp_agent = __esm({
|
|
|
67839
67994
|
case "status": {
|
|
67840
67995
|
if (message.status === "compacting") {
|
|
67841
67996
|
if (compaction === null) {
|
|
67842
|
-
compaction = { id:
|
|
67997
|
+
compaction = { id: randomUUID4() };
|
|
67843
67998
|
await sendUpdate({
|
|
67844
67999
|
sessionId: message.session_id,
|
|
67845
68000
|
update: {
|
|
@@ -69465,7 +69620,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69465
69620
|
} else if (creationOpts.resume) {
|
|
69466
69621
|
sessionId = creationOpts.resume;
|
|
69467
69622
|
} else {
|
|
69468
|
-
sessionId =
|
|
69623
|
+
sessionId = randomUUID4();
|
|
69469
69624
|
}
|
|
69470
69625
|
const input2 = new Pushable();
|
|
69471
69626
|
const settingsManager = new SettingsManager(params.cwd, {
|
|
@@ -69663,7 +69818,7 @@ ${message.api_refusal_explanation}` : "";
|
|
|
69663
69818
|
...acpAdditionalDirectories
|
|
69664
69819
|
];
|
|
69665
69820
|
if (creationOpts?.resume === void 0) {
|
|
69666
|
-
options.sessionId = creationOpts.publicSessionId ?
|
|
69821
|
+
options.sessionId = creationOpts.publicSessionId ? randomUUID4() : sessionId;
|
|
69667
69822
|
}
|
|
69668
69823
|
if (abortController?.signal.aborted) {
|
|
69669
69824
|
throw new Error("Cancelled");
|
|
@@ -69923,9 +70078,9 @@ var init_path_error = __esm({
|
|
|
69923
70078
|
// src/util/platform/posix.ts
|
|
69924
70079
|
import { execFile as execFile2 } from "node:child_process";
|
|
69925
70080
|
import { constants as constants3 } from "node:fs";
|
|
69926
|
-
import { access as access2, chmod, lstat as lstat2, realpath as realpath3, unlink as
|
|
70081
|
+
import { access as access2, chmod, lstat as lstat2, realpath as realpath3, unlink as unlink3 } from "node:fs/promises";
|
|
69927
70082
|
import { tmpdir } from "node:os";
|
|
69928
|
-
import { join as
|
|
70083
|
+
import { join as join10 } from "node:path";
|
|
69929
70084
|
function parseProcessTable(output2) {
|
|
69930
70085
|
const entries = [];
|
|
69931
70086
|
for (const line of output2.split("\n")) {
|
|
@@ -70005,7 +70160,7 @@ function terminateProcess(child, signal) {
|
|
|
70005
70160
|
}
|
|
70006
70161
|
async function removeControlSocket(path8) {
|
|
70007
70162
|
try {
|
|
70008
|
-
await
|
|
70163
|
+
await unlink3(path8);
|
|
70009
70164
|
} catch (cause) {
|
|
70010
70165
|
if (!(cause instanceof Error) || !("code" in cause) || cause.code !== "ENOENT") {
|
|
70011
70166
|
throw cause;
|
|
@@ -70020,7 +70175,7 @@ var init_posix = __esm({
|
|
|
70020
70175
|
PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
70021
70176
|
PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
70022
70177
|
posixOperations = {
|
|
70023
|
-
controlSocketPath: (installationHash) =>
|
|
70178
|
+
controlSocketPath: (installationHash) => join10(tmpdir(), `mobius-${installationHash}.sock`),
|
|
70024
70179
|
prepareControlSocket: removeControlSocket,
|
|
70025
70180
|
secureControlSocket: async (path8) => {
|
|
70026
70181
|
await chmod(path8, 384);
|
|
@@ -70055,8 +70210,8 @@ var init_posix = __esm({
|
|
|
70055
70210
|
|
|
70056
70211
|
// src/util/platform/linux.ts
|
|
70057
70212
|
import { constants as constants4, readdirSync as readdirSync2, readFileSync as readFileSync2 } from "node:fs";
|
|
70058
|
-
import { access as access3, readdir as
|
|
70059
|
-
import { isAbsolute as isAbsolute5, join as
|
|
70213
|
+
import { access as access3, readdir as readdir4, readFile as readFile4, realpath as realpath4, stat as stat4 } from "node:fs/promises";
|
|
70214
|
+
import { isAbsolute as isAbsolute5, join as join11 } from "node:path";
|
|
70060
70215
|
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
70061
70216
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
70062
70217
|
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
@@ -70073,7 +70228,7 @@ function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
|
70073
70228
|
async function readLinuxProcessTable() {
|
|
70074
70229
|
const entries = [];
|
|
70075
70230
|
try {
|
|
70076
|
-
const directories = await
|
|
70231
|
+
const directories = await readdir4("/proc", { withFileTypes: true });
|
|
70077
70232
|
for (const directory of directories) {
|
|
70078
70233
|
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
70079
70234
|
continue;
|
|
@@ -70086,7 +70241,7 @@ async function readLinuxProcessTable() {
|
|
|
70086
70241
|
appendLinuxProcessTableEntry(
|
|
70087
70242
|
entries,
|
|
70088
70243
|
processId,
|
|
70089
|
-
await
|
|
70244
|
+
await readFile4(join11("/proc", directory.name, "stat"), "utf8")
|
|
70090
70245
|
);
|
|
70091
70246
|
} catch {
|
|
70092
70247
|
}
|
|
@@ -70111,7 +70266,7 @@ function readLinuxProcessTableSynchronously() {
|
|
|
70111
70266
|
appendLinuxProcessTableEntry(
|
|
70112
70267
|
entries,
|
|
70113
70268
|
processId,
|
|
70114
|
-
readFileSync2(
|
|
70269
|
+
readFileSync2(join11("/proc", directory.name, "stat"), "utf8")
|
|
70115
70270
|
);
|
|
70116
70271
|
} catch {
|
|
70117
70272
|
}
|
|
@@ -70128,7 +70283,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
70128
70283
|
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
70129
70284
|
try {
|
|
70130
70285
|
const resolvedPath = await realpath4(candidate);
|
|
70131
|
-
if (!(await
|
|
70286
|
+
if (!(await stat4(resolvedPath)).isFile()) {
|
|
70132
70287
|
continue;
|
|
70133
70288
|
}
|
|
70134
70289
|
await access3(resolvedPath, constants4.X_OK);
|
|
@@ -70144,7 +70299,7 @@ async function readLinuxProcessTableWithFallback() {
|
|
|
70144
70299
|
}
|
|
70145
70300
|
function processExists2(processId) {
|
|
70146
70301
|
try {
|
|
70147
|
-
const encoded = readFileSync2(
|
|
70302
|
+
const encoded = readFileSync2(join11("/proc", processId.toString(), "stat"), "utf8");
|
|
70148
70303
|
const closingParenthesis = encoded.lastIndexOf(")");
|
|
70149
70304
|
if (closingParenthesis >= 0) {
|
|
70150
70305
|
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
@@ -70168,7 +70323,7 @@ var init_linux = __esm({
|
|
|
70168
70323
|
processExists: processExists2,
|
|
70169
70324
|
claudeCodeExecutablePaths: (environment) => {
|
|
70170
70325
|
const homeDirectory = environment["HOME"];
|
|
70171
|
-
return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [
|
|
70326
|
+
return homeDirectory !== void 0 && isAbsolute5(homeDirectory) ? [join11(homeDirectory, ".local", "bin", "claude")] : [];
|
|
70172
70327
|
}
|
|
70173
70328
|
};
|
|
70174
70329
|
}
|
|
@@ -70176,7 +70331,7 @@ var init_linux = __esm({
|
|
|
70176
70331
|
|
|
70177
70332
|
// src/util/platform/claude-desktop.ts
|
|
70178
70333
|
import { readdirSync as readdirSync3 } from "node:fs";
|
|
70179
|
-
import { join as
|
|
70334
|
+
import { join as join12 } from "node:path";
|
|
70180
70335
|
function installedDirectories(directory) {
|
|
70181
70336
|
try {
|
|
70182
70337
|
return readdirSync3(directory, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
@@ -70192,14 +70347,14 @@ function claudeDesktopExecutablePaths(roots, executablePaths) {
|
|
|
70192
70347
|
for (const root of roots) {
|
|
70193
70348
|
const versions = installedDirectories(root).filter((version2) => /^\d+\.\d+\.\d+$/.test(version2)).toSorted((left, right) => right.localeCompare(left, "en", { numeric: true }));
|
|
70194
70349
|
for (const version2 of versions) {
|
|
70195
|
-
const directory =
|
|
70350
|
+
const directory = join12(root, version2);
|
|
70196
70351
|
const installations = [
|
|
70197
70352
|
directory,
|
|
70198
|
-
...installedDirectories(directory).map((build) =>
|
|
70353
|
+
...installedDirectories(directory).map((build) => join12(directory, build))
|
|
70199
70354
|
];
|
|
70200
70355
|
for (const installation of installations) {
|
|
70201
70356
|
for (const executablePath of executablePaths) {
|
|
70202
|
-
paths.push(
|
|
70357
|
+
paths.push(join12(installation, ...executablePath));
|
|
70203
70358
|
}
|
|
70204
70359
|
}
|
|
70205
70360
|
}
|
|
@@ -70213,7 +70368,7 @@ var init_claude_desktop = __esm({
|
|
|
70213
70368
|
});
|
|
70214
70369
|
|
|
70215
70370
|
// src/util/platform/macos.ts
|
|
70216
|
-
import { isAbsolute as isAbsolute6, join as
|
|
70371
|
+
import { isAbsolute as isAbsolute6, join as join13 } from "node:path";
|
|
70217
70372
|
var macosPlatform;
|
|
70218
70373
|
var init_macos = __esm({
|
|
70219
70374
|
"src/util/platform/macos.ts"() {
|
|
@@ -70229,10 +70384,10 @@ var init_macos = __esm({
|
|
|
70229
70384
|
const paths = ["/opt/homebrew/bin/claude", "/usr/local/bin/claude"];
|
|
70230
70385
|
const homeDirectory = environment["HOME"];
|
|
70231
70386
|
if (homeDirectory !== void 0 && isAbsolute6(homeDirectory)) {
|
|
70232
|
-
paths.unshift(
|
|
70387
|
+
paths.unshift(join13(homeDirectory, ".local", "bin", "claude"));
|
|
70233
70388
|
paths.push(
|
|
70234
70389
|
...claudeDesktopExecutablePaths(
|
|
70235
|
-
[
|
|
70390
|
+
[join13(homeDirectory, "Library", "Application Support", "Claude", "claude-code")],
|
|
70236
70391
|
[["claude.app", "Contents", "MacOS", "claude"], ["claude"]]
|
|
70237
70392
|
)
|
|
70238
70393
|
);
|
|
@@ -70261,8 +70416,8 @@ var init_process_error = __esm({
|
|
|
70261
70416
|
|
|
70262
70417
|
// src/util/platform/windows.ts
|
|
70263
70418
|
import { execFile as execFile3 } from "node:child_process";
|
|
70264
|
-
import { readFile as
|
|
70265
|
-
import { dirname as
|
|
70419
|
+
import { readFile as readFile5, realpath as realpath5 } from "node:fs/promises";
|
|
70420
|
+
import { dirname as dirname7, extname, isAbsolute as isAbsolute7, join as join14, resolve as resolve8 } from "node:path";
|
|
70266
70421
|
import { promisify as promisify2 } from "node:util";
|
|
70267
70422
|
function environmentValue(environment, name2) {
|
|
70268
70423
|
return Object.entries(environment).find(([key]) => key.toUpperCase() === name2.toUpperCase())?.[1];
|
|
@@ -70271,16 +70426,16 @@ function desktopClaudeExecutablePaths(environment) {
|
|
|
70271
70426
|
const roots = [];
|
|
70272
70427
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70273
70428
|
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70274
|
-
const dataDirectory =
|
|
70429
|
+
const dataDirectory = join14(localAppData, "Claude-Data");
|
|
70275
70430
|
for (const installation of installedDirectories(dataDirectory)) {
|
|
70276
70431
|
if (installation.startsWith("claude_")) {
|
|
70277
|
-
roots.push(
|
|
70432
|
+
roots.push(join14(dataDirectory, installation, "claude-code"));
|
|
70278
70433
|
}
|
|
70279
70434
|
}
|
|
70280
70435
|
}
|
|
70281
70436
|
const appData = environmentValue(environment, "APPDATA");
|
|
70282
70437
|
if (appData !== void 0 && isAbsolute7(appData)) {
|
|
70283
|
-
roots.push(
|
|
70438
|
+
roots.push(join14(appData, "Claude", "claude-code"));
|
|
70284
70439
|
}
|
|
70285
70440
|
return claudeDesktopExecutablePaths(roots, [["claude.exe"]]);
|
|
70286
70441
|
}
|
|
@@ -70303,13 +70458,13 @@ async function resolveExecutableTarget(path8) {
|
|
|
70303
70458
|
resolvedPath = await realpath5(path8);
|
|
70304
70459
|
}
|
|
70305
70460
|
if (extname(resolvedPath).toLowerCase() === ".cmd") {
|
|
70306
|
-
const shim = await
|
|
70461
|
+
const shim = await readFile5(resolvedPath, "utf8");
|
|
70307
70462
|
if (shim.includes('SET "NPM_CLI_JS=%~dp0\\node_modules\\npm\\bin\\npm-cli.js"') && shim.includes('"%NODE_EXE%" "%NPM_CLI_JS%" %*')) {
|
|
70308
|
-
return await realpath5(
|
|
70463
|
+
return await realpath5(resolve8(dirname7(resolvedPath), "node_modules/npm/bin/npm-cli.js"));
|
|
70309
70464
|
}
|
|
70310
70465
|
const script = /"%_prog%"\s+"%dp0%[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*/iu.exec(shim)?.[1];
|
|
70311
70466
|
if (script !== void 0 && shim.includes("SET dp0=%~dp0")) {
|
|
70312
|
-
resolvedPath = await realpath5(
|
|
70467
|
+
resolvedPath = await realpath5(resolve8(dirname7(resolvedPath), script));
|
|
70313
70468
|
} else {
|
|
70314
70469
|
const pnpmScript = /^\s*node\s+"%~dp0[\\/]([^"\r\n]+\.(?:js|mjs|cjs))"\s+%\*\s*$/imu.exec(shim)?.[1];
|
|
70315
70470
|
if (pnpmScript === void 0 || !shim.includes("@SETLOCAL")) {
|
|
@@ -70318,7 +70473,7 @@ async function resolveExecutableTarget(path8) {
|
|
|
70318
70473
|
"Use a native executable or a verified Node entrypoint"
|
|
70319
70474
|
);
|
|
70320
70475
|
}
|
|
70321
|
-
resolvedPath = await realpath5(
|
|
70476
|
+
resolvedPath = await realpath5(resolve8(dirname7(resolvedPath), pnpmScript));
|
|
70322
70477
|
}
|
|
70323
70478
|
}
|
|
70324
70479
|
return resolvedPath;
|
|
@@ -70342,7 +70497,7 @@ function readProcessTable() {
|
|
|
70342
70497
|
}
|
|
70343
70498
|
return new Promise((resolveTable) => {
|
|
70344
70499
|
execFile3(
|
|
70345
|
-
|
|
70500
|
+
join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
70346
70501
|
[
|
|
70347
70502
|
"-NoLogo",
|
|
70348
70503
|
"-NoProfile",
|
|
@@ -70383,7 +70538,7 @@ async function validatePathPermissions(path8, _directory, privateAccess, signal)
|
|
|
70383
70538
|
}
|
|
70384
70539
|
try {
|
|
70385
70540
|
await execute(
|
|
70386
|
-
|
|
70541
|
+
join14(systemRoot, "System32", "WindowsPowerShell", "v1.0", "powershell.exe"),
|
|
70387
70542
|
[
|
|
70388
70543
|
"-NoLogo",
|
|
70389
70544
|
"-NoProfile",
|
|
@@ -70466,11 +70621,11 @@ if ($env:MOBIUS_PERMISSION_PRIVATE -eq '1') {
|
|
|
70466
70621
|
const paths = [];
|
|
70467
70622
|
const userProfile = environmentValue(environment, "USERPROFILE");
|
|
70468
70623
|
if (userProfile !== void 0 && isAbsolute7(userProfile)) {
|
|
70469
|
-
paths.push(
|
|
70624
|
+
paths.push(join14(userProfile, ".local", "bin", "claude.exe"));
|
|
70470
70625
|
}
|
|
70471
70626
|
const localAppData = environmentValue(environment, "LOCALAPPDATA");
|
|
70472
70627
|
if (localAppData !== void 0 && isAbsolute7(localAppData)) {
|
|
70473
|
-
paths.push(
|
|
70628
|
+
paths.push(join14(localAppData, "Microsoft", "WinGet", "Links", "claude.exe"));
|
|
70474
70629
|
}
|
|
70475
70630
|
paths.push(...desktopClaudeExecutablePaths(environment));
|
|
70476
70631
|
return paths;
|
|
@@ -70508,13 +70663,13 @@ var init_platform = __esm({
|
|
|
70508
70663
|
|
|
70509
70664
|
// src/util/process/executable.ts
|
|
70510
70665
|
import { spawn as spawn3 } from "node:child_process";
|
|
70511
|
-
import { stat as
|
|
70512
|
-
import { join as
|
|
70666
|
+
import { stat as stat5 } from "node:fs/promises";
|
|
70667
|
+
import { join as join15, resolve as resolve9 } from "node:path";
|
|
70513
70668
|
async function resolveExecutablePath(requestedPath2, platform2 = process.platform) {
|
|
70514
|
-
const absoluteRequestedPath =
|
|
70669
|
+
const absoluteRequestedPath = resolve9(requestedPath2);
|
|
70515
70670
|
try {
|
|
70516
70671
|
const resolvedPath = await platformSupportFor(platform2).resolveExecutableTarget(absoluteRequestedPath);
|
|
70517
|
-
const metadata = await
|
|
70672
|
+
const metadata = await stat5(resolvedPath);
|
|
70518
70673
|
if (!metadata.isFile()) {
|
|
70519
70674
|
return null;
|
|
70520
70675
|
}
|
|
@@ -70542,7 +70697,7 @@ async function findExecutableOnPath(executableName, environment, platform2 = pro
|
|
|
70542
70697
|
continue;
|
|
70543
70698
|
}
|
|
70544
70699
|
for (const extension of extensions) {
|
|
70545
|
-
const requestedPath2 =
|
|
70700
|
+
const requestedPath2 = resolve9(join15(entry, `${executableName}${extension}`));
|
|
70546
70701
|
const executable = await resolveExecutablePath(requestedPath2, platform2);
|
|
70547
70702
|
if (executable !== null) {
|
|
70548
70703
|
return executable;
|
|
@@ -71791,7 +71946,7 @@ var init_items = __esm({
|
|
|
71791
71946
|
});
|
|
71792
71947
|
|
|
71793
71948
|
// src/acp/harness/codex/borrowed-agent.ts
|
|
71794
|
-
import { randomUUID as
|
|
71949
|
+
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
71795
71950
|
import { setTimeout as setTimeout2 } from "node:timers/promises";
|
|
71796
71951
|
var REQUEST_TIMEOUT, POLL_INTERVAL, queueResponseSchema, queuePageSchema, CodexBorrowedAcpAgent;
|
|
71797
71952
|
var init_borrowed_agent = __esm({
|
|
@@ -71959,7 +72114,7 @@ var init_borrowed_agent = __esm({
|
|
|
71959
72114
|
if (this.#pending !== null) {
|
|
71960
72115
|
throw new AcpExecutionError("Another prompt is already running", {}, "session_busy");
|
|
71961
72116
|
}
|
|
71962
|
-
const pending = { clientId:
|
|
72117
|
+
const pending = { clientId: randomUUID5(), completion: Promise.withResolvers() };
|
|
71963
72118
|
this.#pending = pending;
|
|
71964
72119
|
void pending.completion.promise.catch(() => {
|
|
71965
72120
|
});
|
|
@@ -72071,7 +72226,7 @@ var init_borrowed_agent = __esm({
|
|
|
72071
72226
|
|
|
72072
72227
|
// src/storage/files/local-files.ts
|
|
72073
72228
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
72074
|
-
import { mkdir as
|
|
72229
|
+
import { mkdir as mkdir4, open as open5, readdir as readdir5, readFile as readFile6, realpath as realpath6, stat as stat6 } from "node:fs/promises";
|
|
72075
72230
|
function entryKind(entry) {
|
|
72076
72231
|
if (entry.isDirectory()) {
|
|
72077
72232
|
return "directory";
|
|
@@ -72094,7 +72249,7 @@ async function canonicalPath(path8) {
|
|
|
72094
72249
|
return await realpath6(path8);
|
|
72095
72250
|
}
|
|
72096
72251
|
async function readPathMetadata(path8) {
|
|
72097
|
-
const metadata = await
|
|
72252
|
+
const metadata = await stat6(path8);
|
|
72098
72253
|
return {
|
|
72099
72254
|
kind: metadata.isDirectory() ? "directory" : metadata.isFile() ? "file" : "other",
|
|
72100
72255
|
modifiedAt: metadata.mtime,
|
|
@@ -72103,20 +72258,20 @@ async function readPathMetadata(path8) {
|
|
|
72103
72258
|
};
|
|
72104
72259
|
}
|
|
72105
72260
|
async function listDirectory(path8) {
|
|
72106
|
-
const entries = await
|
|
72261
|
+
const entries = await readdir5(path8, { withFileTypes: true });
|
|
72107
72262
|
return entries.map((entry) => ({ kind: entryKind(entry), name: entry.name }));
|
|
72108
72263
|
}
|
|
72109
72264
|
async function ensurePrivateDirectory(path8) {
|
|
72110
|
-
await
|
|
72265
|
+
await mkdir4(path8, { mode: 448, recursive: true });
|
|
72111
72266
|
}
|
|
72112
72267
|
async function ensureCanonicalDirectory(path8) {
|
|
72113
72268
|
await ensurePrivateDirectory(path8);
|
|
72114
72269
|
const resolved = await realpath6(path8);
|
|
72115
|
-
return (await
|
|
72270
|
+
return (await stat6(resolved)).isDirectory() ? resolved : null;
|
|
72116
72271
|
}
|
|
72117
72272
|
async function readFileStart(path8, byteLength) {
|
|
72118
72273
|
const bytes = new Uint8Array(byteLength);
|
|
72119
|
-
const handle = await
|
|
72274
|
+
const handle = await open5(path8, "r");
|
|
72120
72275
|
try {
|
|
72121
72276
|
await handle.read(bytes, 0, byteLength, 0);
|
|
72122
72277
|
} finally {
|
|
@@ -72125,7 +72280,7 @@ async function readFileStart(path8, byteLength) {
|
|
|
72125
72280
|
return bytes;
|
|
72126
72281
|
}
|
|
72127
72282
|
async function readFileBytes(path8) {
|
|
72128
|
-
return await
|
|
72283
|
+
return await readFile6(path8);
|
|
72129
72284
|
}
|
|
72130
72285
|
function readFileChunks(path8, chunkBytes, signal) {
|
|
72131
72286
|
return createReadStream2(path8, { highWaterMark: chunkBytes, signal });
|
|
@@ -72137,7 +72292,7 @@ var init_local_files = __esm({
|
|
|
72137
72292
|
});
|
|
72138
72293
|
|
|
72139
72294
|
// src/acp/content/raster.ts
|
|
72140
|
-
import { basename as
|
|
72295
|
+
import { basename as basename5, isAbsolute as isAbsolute9, normalize } from "node:path";
|
|
72141
72296
|
import { fileURLToPath } from "node:url";
|
|
72142
72297
|
function startsWith(bytes, signature, offset = 0) {
|
|
72143
72298
|
if (bytes.byteLength < offset + signature.byteLength) {
|
|
@@ -72225,7 +72380,7 @@ async function readLocalRaster(uri, signal) {
|
|
|
72225
72380
|
if (mimeType === null) {
|
|
72226
72381
|
return null;
|
|
72227
72382
|
}
|
|
72228
|
-
return new LocalRasterImage(
|
|
72383
|
+
return new LocalRasterImage(basename5(target) || "Image", mimeType, target);
|
|
72229
72384
|
}
|
|
72230
72385
|
var MAX_LOCAL_RASTER_BYTES, PNG_SIGNATURE, JPEG_SIGNATURE, GIF87_SIGNATURE, GIF89_SIGNATURE, RIFF_SIGNATURE, WEBP_SIGNATURE, LocalRasterImage;
|
|
72231
72386
|
var init_raster = __esm({
|
|
@@ -72355,7 +72510,7 @@ var init_history_images = __esm({
|
|
|
72355
72510
|
});
|
|
72356
72511
|
|
|
72357
72512
|
// src/acp/harness/codex/owned-agent.ts
|
|
72358
|
-
import { randomUUID as
|
|
72513
|
+
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
72359
72514
|
import { setTimeout as delay } from "node:timers/promises";
|
|
72360
72515
|
import { methods as methods2 } from "@agentclientprotocol/sdk";
|
|
72361
72516
|
function permissionDecision(optionId) {
|
|
@@ -72585,7 +72740,7 @@ var init_owned_agent = __esm({
|
|
|
72585
72740
|
signal.throwIfAborted();
|
|
72586
72741
|
const open7 = this.#settleCompaction("failed", cause instanceof Error ? cause.message : String(cause));
|
|
72587
72742
|
if (open7 === null && !this.#turnSettledCompaction) {
|
|
72588
|
-
const compactionId =
|
|
72743
|
+
const compactionId = randomUUID6();
|
|
72589
72744
|
await this.#enqueue(async () => {
|
|
72590
72745
|
await this.#context.emit({
|
|
72591
72746
|
compactionId,
|
|
@@ -73051,7 +73206,7 @@ var init_owned_agent = __esm({
|
|
|
73051
73206
|
});
|
|
73052
73207
|
|
|
73053
73208
|
// src/acp/harness/codex/history.ts
|
|
73054
|
-
import { createHash } from "node:crypto";
|
|
73209
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
73055
73210
|
async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
73056
73211
|
const deadline = AbortSignal.any([signal, AbortSignal.timeout(6e4)]);
|
|
73057
73212
|
const seenCursors = /* @__PURE__ */ new Set();
|
|
@@ -73136,7 +73291,7 @@ async function replayCodexHistory(client2, threadId, emit, signal) {
|
|
|
73136
73291
|
}
|
|
73137
73292
|
}
|
|
73138
73293
|
if (turn.error != null) {
|
|
73139
|
-
const identity2 =
|
|
73294
|
+
const identity2 = createHash2("sha256").update(threadId).update("\0").update(turn.id ?? turnIndex.toString()).digest("hex");
|
|
73140
73295
|
await emit({
|
|
73141
73296
|
sessionUpdate: "tool_call",
|
|
73142
73297
|
toolCallId: `agent-error-${identity2}`,
|
|
@@ -76721,8 +76876,8 @@ var init_process = __esm({
|
|
|
76721
76876
|
const sessionFile = typeof state?.sessionFile === "string" ? state.sessionFile : null;
|
|
76722
76877
|
if (sessionFile) {
|
|
76723
76878
|
const { mkdirSync: mkdirSync5 } = await import("node:fs");
|
|
76724
|
-
const { dirname:
|
|
76725
|
-
mkdirSync5(
|
|
76879
|
+
const { dirname: dirname13 } = await import("node:path");
|
|
76880
|
+
mkdirSync5(dirname13(sessionFile), { recursive: true });
|
|
76726
76881
|
}
|
|
76727
76882
|
} catch {
|
|
76728
76883
|
}
|
|
@@ -77028,9 +77183,9 @@ var init_auth_required = __esm({
|
|
|
77028
77183
|
});
|
|
77029
77184
|
|
|
77030
77185
|
// src/acp/harness/pi/upstream/dist/acp/environment.js
|
|
77031
|
-
import { homedir as
|
|
77186
|
+
import { homedir as homedir3 } from "node:os";
|
|
77032
77187
|
function environmentHome(environment) {
|
|
77033
|
-
return environment["HOME"] ?? environment["USERPROFILE"] ??
|
|
77188
|
+
return environment["HOME"] ?? environment["USERPROFILE"] ?? homedir3();
|
|
77034
77189
|
}
|
|
77035
77190
|
var init_environment = __esm({
|
|
77036
77191
|
"src/acp/harness/pi/upstream/dist/acp/environment.js"() {
|
|
@@ -77039,12 +77194,12 @@ var init_environment = __esm({
|
|
|
77039
77194
|
});
|
|
77040
77195
|
|
|
77041
77196
|
// src/acp/harness/pi/upstream/dist/acp/paths.js
|
|
77042
|
-
import { join as
|
|
77197
|
+
import { join as join16 } from "node:path";
|
|
77043
77198
|
function getPiAcpDir(environment = process.env) {
|
|
77044
|
-
return
|
|
77199
|
+
return join16(environmentHome(environment), ".pi", "pi-acp");
|
|
77045
77200
|
}
|
|
77046
77201
|
function getPiAcpSessionMapPath(environment = process.env) {
|
|
77047
|
-
return
|
|
77202
|
+
return join16(getPiAcpDir(environment), "session-map.json");
|
|
77048
77203
|
}
|
|
77049
77204
|
var init_paths = __esm({
|
|
77050
77205
|
"src/acp/harness/pi/upstream/dist/acp/paths.js"() {
|
|
@@ -77100,13 +77255,13 @@ var init_pi_commands = __esm({
|
|
|
77100
77255
|
|
|
77101
77256
|
// src/acp/harness/pi/upstream/dist/acp/pi-sessions.js
|
|
77102
77257
|
import { closeSync as closeSync2, existsSync as existsSync4, openSync as openSync2, readdirSync as readdirSync4, readFileSync as readFileSync3, readSync as readSync2, statSync as statSync2 } from "node:fs";
|
|
77103
|
-
import { isAbsolute as isAbsolute10, join as
|
|
77258
|
+
import { isAbsolute as isAbsolute10, join as join17, resolve as resolve10 } from "node:path";
|
|
77104
77259
|
function getPiAgentDir(environment) {
|
|
77105
77260
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
77106
|
-
return configured ?
|
|
77261
|
+
return configured ? resolve10(configured) : join17(environmentHome(environment), ".pi", "agent");
|
|
77107
77262
|
}
|
|
77108
77263
|
function readSessionDirFromSettings(agentDir) {
|
|
77109
|
-
const settingsPath =
|
|
77264
|
+
const settingsPath = join17(agentDir, "settings.json");
|
|
77110
77265
|
try {
|
|
77111
77266
|
if (!existsSync4(settingsPath)) {
|
|
77112
77267
|
return null;
|
|
@@ -77120,25 +77275,25 @@ function readSessionDirFromSettings(agentDir) {
|
|
|
77120
77275
|
if (typeof sessionDir !== "string" || !sessionDir.trim()) {
|
|
77121
77276
|
return null;
|
|
77122
77277
|
}
|
|
77123
|
-
return isAbsolute10(sessionDir) ? sessionDir :
|
|
77278
|
+
return isAbsolute10(sessionDir) ? sessionDir : resolve10(agentDir, sessionDir);
|
|
77124
77279
|
} catch {
|
|
77125
77280
|
return null;
|
|
77126
77281
|
}
|
|
77127
77282
|
}
|
|
77128
77283
|
function getPiSessionsDir(environment = process.env) {
|
|
77129
77284
|
const agentDir = getPiAgentDir(environment);
|
|
77130
|
-
return readSessionDirFromSettings(agentDir) ??
|
|
77285
|
+
return readSessionDirFromSettings(agentDir) ?? join17(agentDir, "sessions");
|
|
77131
77286
|
}
|
|
77132
77287
|
function getPiSessionDiscoveryDirs(environment) {
|
|
77133
77288
|
const discoveryDirectories = [getPiSessionsDir(environment)];
|
|
77134
77289
|
const mobiusSessionDirectory = environment["MOBIUS_PI_SESSION_DIR"];
|
|
77135
77290
|
if (mobiusSessionDirectory !== void 0 && mobiusSessionDirectory.trim().length > 0) {
|
|
77136
|
-
const mobiusSessionsRoot =
|
|
77291
|
+
const mobiusSessionsRoot = resolve10(mobiusSessionDirectory, "..");
|
|
77137
77292
|
for (const entry of readdirSync4(mobiusSessionsRoot, { withFileTypes: true, encoding: "utf-8" })) {
|
|
77138
77293
|
if (!entry.isDirectory()) {
|
|
77139
77294
|
continue;
|
|
77140
77295
|
}
|
|
77141
|
-
const directory =
|
|
77296
|
+
const directory = join17(mobiusSessionsRoot, entry.name);
|
|
77142
77297
|
if (!discoveryDirectories.includes(directory)) {
|
|
77143
77298
|
discoveryDirectories.push(directory);
|
|
77144
77299
|
}
|
|
@@ -77155,7 +77310,7 @@ function walkJsonlFiles(dir, out2) {
|
|
|
77155
77310
|
}
|
|
77156
77311
|
for (const e of entries) {
|
|
77157
77312
|
const name2 = typeof e.name === "string" ? e.name : String(e.name);
|
|
77158
|
-
const p =
|
|
77313
|
+
const p = join17(dir, name2);
|
|
77159
77314
|
if (e.isDirectory()) {
|
|
77160
77315
|
walkJsonlFiles(p, out2);
|
|
77161
77316
|
} else if (e.isFile() && name2.endsWith(".jsonl")) {
|
|
@@ -77433,7 +77588,7 @@ var init_pi_sessions = __esm({
|
|
|
77433
77588
|
|
|
77434
77589
|
// src/acp/harness/pi/upstream/dist/acp/pi-settings.js
|
|
77435
77590
|
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
|
|
77436
|
-
import { join as
|
|
77591
|
+
import { join as join18, resolve as resolve11 } from "node:path";
|
|
77437
77592
|
function isObject2(x) {
|
|
77438
77593
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
77439
77594
|
}
|
|
@@ -77462,15 +77617,15 @@ function readJsonFile(path8) {
|
|
|
77462
77617
|
}
|
|
77463
77618
|
}
|
|
77464
77619
|
function getMergedSettings(cwd, environment) {
|
|
77465
|
-
const globalSettingsPath =
|
|
77466
|
-
const projectSettingsPath =
|
|
77620
|
+
const globalSettingsPath = join18(getAgentDir(environment), "settings.json");
|
|
77621
|
+
const projectSettingsPath = resolve11(cwd, ".pi", "settings.json");
|
|
77467
77622
|
const global2 = readJsonFile(globalSettingsPath);
|
|
77468
77623
|
const project = readJsonFile(projectSettingsPath);
|
|
77469
77624
|
return deepMerge(global2, project);
|
|
77470
77625
|
}
|
|
77471
77626
|
function getAgentDir(environment = process.env) {
|
|
77472
77627
|
const configured = environment["PI_CODING_AGENT_DIR"];
|
|
77473
|
-
return configured ?
|
|
77628
|
+
return configured ? resolve11(configured) : join18(environmentHome(environment), ".pi", "agent");
|
|
77474
77629
|
}
|
|
77475
77630
|
function getEnableSkillCommands(cwd, environment = process.env) {
|
|
77476
77631
|
const merged = getMergedSettings(cwd, environment);
|
|
@@ -77681,9 +77836,9 @@ var init_extension_questions = __esm({
|
|
|
77681
77836
|
|
|
77682
77837
|
// src/acp/harness/pi/upstream/dist/acp/session-store.js
|
|
77683
77838
|
import { mkdirSync as mkdirSync2, readFileSync as readFileSync5, writeFileSync } from "node:fs";
|
|
77684
|
-
import { dirname as
|
|
77839
|
+
import { dirname as dirname8 } from "node:path";
|
|
77685
77840
|
function ensureParentDir(path8) {
|
|
77686
|
-
mkdirSync2(
|
|
77841
|
+
mkdirSync2(dirname8(path8), { recursive: true });
|
|
77687
77842
|
}
|
|
77688
77843
|
function loadFile(path8) {
|
|
77689
77844
|
try {
|
|
@@ -77740,7 +77895,7 @@ var init_session_store = __esm({
|
|
|
77740
77895
|
|
|
77741
77896
|
// src/acp/harness/pi/upstream/dist/acp/slash-commands.js
|
|
77742
77897
|
import { existsSync as existsSync6, readdirSync as readdirSync5, readFileSync as readFileSync6 } from "node:fs";
|
|
77743
|
-
import { join as
|
|
77898
|
+
import { join as join19, resolve as resolve12 } from "node:path";
|
|
77744
77899
|
function parseFrontmatter(content) {
|
|
77745
77900
|
const frontmatter = {};
|
|
77746
77901
|
if (!content.startsWith("---")) {
|
|
@@ -77768,7 +77923,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
77768
77923
|
try {
|
|
77769
77924
|
const entries = readdirSync5(dir, { withFileTypes: true });
|
|
77770
77925
|
for (const entry of entries) {
|
|
77771
|
-
const fullPath =
|
|
77926
|
+
const fullPath = join19(dir, entry.name);
|
|
77772
77927
|
if (entry.isDirectory()) {
|
|
77773
77928
|
const newSubdir = subdir ? `${subdir}:${entry.name}` : entry.name;
|
|
77774
77929
|
commands.push(...loadCommandsFromDir(fullPath, source, newSubdir));
|
|
@@ -77808,8 +77963,8 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
77808
77963
|
}
|
|
77809
77964
|
function loadSlashCommands(cwd, environment = process.env) {
|
|
77810
77965
|
const commands = [];
|
|
77811
|
-
const userDir =
|
|
77812
|
-
const projectDir =
|
|
77966
|
+
const userDir = join19(environmentHome(environment), ".pi", "agent", "prompts");
|
|
77967
|
+
const projectDir = resolve12(cwd, ".pi", "prompts");
|
|
77813
77968
|
commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
77814
77969
|
commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
77815
77970
|
return commands;
|
|
@@ -77969,7 +78124,7 @@ var init_pi_tools = __esm({
|
|
|
77969
78124
|
});
|
|
77970
78125
|
|
|
77971
78126
|
// src/acp/harness/pi/upstream/dist/acp/session.js
|
|
77972
|
-
import { randomUUID as
|
|
78127
|
+
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
77973
78128
|
import { readFileSync as readFileSync7 } from "node:fs";
|
|
77974
78129
|
import { isAbsolute as isAbsolute11, resolve as resolvePath } from "node:path";
|
|
77975
78130
|
import { RequestError as RequestError6 } from "@agentclientprotocol/sdk";
|
|
@@ -78248,13 +78403,13 @@ var init_session = __esm({
|
|
|
78248
78403
|
return settled;
|
|
78249
78404
|
}
|
|
78250
78405
|
if (this.activeCompactionId === null) {
|
|
78251
|
-
this.activeCompactionId =
|
|
78406
|
+
this.activeCompactionId = randomUUID7();
|
|
78252
78407
|
}
|
|
78253
78408
|
return this.activeCompactionId;
|
|
78254
78409
|
}
|
|
78255
78410
|
/** Opening half of compactionId: always returns an id. */
|
|
78256
78411
|
openCompactionId() {
|
|
78257
|
-
return this.compactionId(true) ??
|
|
78412
|
+
return this.compactionId(true) ?? randomUUID7();
|
|
78258
78413
|
}
|
|
78259
78414
|
constructor(opts) {
|
|
78260
78415
|
this.sessionId = opts.sessionId;
|
|
@@ -78895,9 +79050,9 @@ var init_prompt = __esm({
|
|
|
78895
79050
|
|
|
78896
79051
|
// src/acp/harness/pi/upstream/dist/acp/agent.js
|
|
78897
79052
|
import { spawnSync } from "node:child_process";
|
|
78898
|
-
import { randomUUID as
|
|
79053
|
+
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
78899
79054
|
import { existsSync as existsSync7, readdirSync as readdirSync6, readFileSync as readFileSync8, realpathSync as realpathSync3, statSync as statSync3, unlinkSync as unlinkSync2 } from "node:fs";
|
|
78900
|
-
import { basename as
|
|
79055
|
+
import { basename as basename6, dirname as dirname9, isAbsolute as isAbsolute12, join as join20 } from "node:path";
|
|
78901
79056
|
import { RequestError as RequestError7 } from "@agentclientprotocol/sdk";
|
|
78902
79057
|
function thinkingLevelName(id) {
|
|
78903
79058
|
return id.split(/[_-]/u).map((part) => part.length === 0 ? part : `${part[0]?.toUpperCase() ?? ""}${part.slice(1)}`).join(" ");
|
|
@@ -79172,7 +79327,7 @@ function buildStartupInfo(opts) {
|
|
|
79172
79327
|
md.push("");
|
|
79173
79328
|
};
|
|
79174
79329
|
const contextItems = [];
|
|
79175
|
-
const contextPath =
|
|
79330
|
+
const contextPath = join20(opts.cwd, "AGENTS.md");
|
|
79176
79331
|
if (existsSync7(contextPath)) {
|
|
79177
79332
|
contextItems.push(contextPath);
|
|
79178
79333
|
}
|
|
@@ -79181,7 +79336,7 @@ function buildStartupInfo(opts) {
|
|
|
79181
79336
|
const pushSkillFromRoot = (root) => {
|
|
79182
79337
|
try {
|
|
79183
79338
|
for (const e of readdirSync6(root)) {
|
|
79184
|
-
const p =
|
|
79339
|
+
const p = join20(root, e);
|
|
79185
79340
|
try {
|
|
79186
79341
|
const st2 = statSync3(p);
|
|
79187
79342
|
if (st2.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -79206,7 +79361,7 @@ function buildStartupInfo(opts) {
|
|
|
79206
79361
|
if (name2 === "node_modules" || name2 === ".git") {
|
|
79207
79362
|
continue;
|
|
79208
79363
|
}
|
|
79209
|
-
const p =
|
|
79364
|
+
const p = join20(dir, name2);
|
|
79210
79365
|
let st2;
|
|
79211
79366
|
try {
|
|
79212
79367
|
st2 = statSync3(p);
|
|
@@ -79223,36 +79378,36 @@ function buildStartupInfo(opts) {
|
|
|
79223
79378
|
} catch {
|
|
79224
79379
|
}
|
|
79225
79380
|
};
|
|
79226
|
-
const globalSkillsDir =
|
|
79381
|
+
const globalSkillsDir = join20(getAgentDir(opts.environment), "skills");
|
|
79227
79382
|
pushSkillFromRoot(globalSkillsDir);
|
|
79228
79383
|
const home = opts.environment["HOME"] ?? opts.environment["USERPROFILE"] ?? "";
|
|
79229
|
-
const legacyAgentsSkillsDir =
|
|
79384
|
+
const legacyAgentsSkillsDir = join20(home, ".agents", "skills");
|
|
79230
79385
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
79231
|
-
const projectSkillsDir =
|
|
79386
|
+
const projectSkillsDir = join20(opts.cwd, ".pi", "skills");
|
|
79232
79387
|
pushSkillFromRoot(projectSkillsDir);
|
|
79233
79388
|
addSection("Skills", skillsItems);
|
|
79234
79389
|
const promptsItems = [];
|
|
79235
|
-
const promptsDir =
|
|
79390
|
+
const promptsDir = join20(home, ".pi", "agent", "prompts");
|
|
79236
79391
|
try {
|
|
79237
79392
|
const prompts = readdirSync6(promptsDir).filter((f) => f.endsWith(".md"));
|
|
79238
79393
|
for (const f of prompts) {
|
|
79239
|
-
promptsItems.push(`/${
|
|
79394
|
+
promptsItems.push(`/${basename6(f, ".md")}`);
|
|
79240
79395
|
}
|
|
79241
79396
|
} catch {
|
|
79242
79397
|
}
|
|
79243
79398
|
addSection("Prompts", promptsItems);
|
|
79244
79399
|
const extItems = [];
|
|
79245
|
-
const extDir =
|
|
79400
|
+
const extDir = join20(home, ".pi", "agent", "extensions");
|
|
79246
79401
|
try {
|
|
79247
79402
|
const exts = readdirSync6(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
79248
79403
|
for (const f of exts) {
|
|
79249
|
-
extItems.push(
|
|
79404
|
+
extItems.push(join20(extDir, f));
|
|
79250
79405
|
}
|
|
79251
79406
|
} catch {
|
|
79252
79407
|
}
|
|
79253
79408
|
const settingsPaths = [
|
|
79254
|
-
|
|
79255
|
-
|
|
79409
|
+
join20(getAgentDir(opts.environment), "settings.json"),
|
|
79410
|
+
join20(opts.cwd, ".pi", "settings.json")
|
|
79256
79411
|
];
|
|
79257
79412
|
for (const settingsPath of settingsPaths) {
|
|
79258
79413
|
try {
|
|
@@ -79589,7 +79744,7 @@ var init_agent2 = __esm({
|
|
|
79589
79744
|
const args = parseCommandArgs(argsString);
|
|
79590
79745
|
if (cmd === "compact") {
|
|
79591
79746
|
const customInstructions = args.join(" ").trim() || void 0;
|
|
79592
|
-
const compactionId =
|
|
79747
|
+
const compactionId = randomUUID8();
|
|
79593
79748
|
await this.conn.sessionUpdate({
|
|
79594
79749
|
sessionId: session.sessionId,
|
|
79595
79750
|
update: {
|
|
@@ -79814,8 +79969,8 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
79814
79969
|
const piPath = String(which.stdout ?? "").split(/\r?\n/)[0]?.trim();
|
|
79815
79970
|
if (piPath) {
|
|
79816
79971
|
const resolved = realpathSync3(piPath);
|
|
79817
|
-
const pkgRoot =
|
|
79818
|
-
const p =
|
|
79972
|
+
const pkgRoot = dirname9(dirname9(resolved));
|
|
79973
|
+
const p = join20(pkgRoot, "CHANGELOG.md");
|
|
79819
79974
|
if (existsSync7(p)) {
|
|
79820
79975
|
return p;
|
|
79821
79976
|
}
|
|
@@ -79826,7 +79981,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
79826
79981
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
79827
79982
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
79828
79983
|
if (root) {
|
|
79829
|
-
const p =
|
|
79984
|
+
const p = join20(root, "@earendil-works", "pi-coding-agent", "CHANGELOG.md");
|
|
79830
79985
|
if (existsSync7(p)) {
|
|
79831
79986
|
return p;
|
|
79832
79987
|
}
|
|
@@ -79920,7 +80075,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
79920
80075
|
return { stopReason: "end_turn" };
|
|
79921
80076
|
}
|
|
79922
80077
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
79923
|
-
const outputPath =
|
|
80078
|
+
const outputPath = join20(session.cwd, `pi-session-${safeSessionId}.html`);
|
|
79924
80079
|
let resultPath = "";
|
|
79925
80080
|
try {
|
|
79926
80081
|
const result2 = await session.proc.exportHtml(outputPath);
|
|
@@ -80525,22 +80680,6 @@ var init_endpoint2 = __esm({
|
|
|
80525
80680
|
}
|
|
80526
80681
|
});
|
|
80527
80682
|
|
|
80528
|
-
// src/storage/state-directory.ts
|
|
80529
|
-
import { homedir as homedir3 } from "node:os";
|
|
80530
|
-
import { join as join18, resolve as resolve12 } from "node:path";
|
|
80531
|
-
function readStateDirectory(environment = process.env) {
|
|
80532
|
-
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
80533
|
-
if (configured !== void 0 && configured.length > 0) {
|
|
80534
|
-
return resolve12(configured);
|
|
80535
|
-
}
|
|
80536
|
-
return join18(homedir3(), ".mobius");
|
|
80537
|
-
}
|
|
80538
|
-
var init_state_directory = __esm({
|
|
80539
|
-
"src/storage/state-directory.ts"() {
|
|
80540
|
-
"use strict";
|
|
80541
|
-
}
|
|
80542
|
-
});
|
|
80543
|
-
|
|
80544
80683
|
// src/agent/discovery/agent-probe-error.ts
|
|
80545
80684
|
var AgentProbeError;
|
|
80546
80685
|
var init_agent_probe_error = __esm({
|
|
@@ -80558,8 +80697,8 @@ var init_agent_probe_error = __esm({
|
|
|
80558
80697
|
});
|
|
80559
80698
|
|
|
80560
80699
|
// src/agent/specification/vendors/pi-agent.ts
|
|
80561
|
-
import { createHash as
|
|
80562
|
-
import { join as
|
|
80700
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
80701
|
+
import { join as join21 } from "node:path";
|
|
80563
80702
|
import {
|
|
80564
80703
|
methods as methods6
|
|
80565
80704
|
} from "@agentclientprotocol/sdk";
|
|
@@ -80579,8 +80718,8 @@ var init_pi_agent = __esm({
|
|
|
80579
80718
|
// The Pi ACP fork inlines embedded prompt resources into the turn message, so Mobius
|
|
80580
80719
|
// keeps the adapter's opt-in capability flag enabled for every launch it owns.
|
|
80581
80720
|
createLaunchEnvironment = async (_agent, context) => {
|
|
80582
|
-
const workspaceHash =
|
|
80583
|
-
const sessionDirectory =
|
|
80721
|
+
const workspaceHash = createHash3("sha256").update(context.defaultWorkspace).digest("hex").slice(0, 24);
|
|
80722
|
+
const sessionDirectory = join21(
|
|
80584
80723
|
readStateDirectory(context.environment),
|
|
80585
80724
|
"agents",
|
|
80586
80725
|
"pi",
|
|
@@ -80786,7 +80925,7 @@ var init_agent_discovery = __esm({
|
|
|
80786
80925
|
|
|
80787
80926
|
// src/util/process/local-executable.ts
|
|
80788
80927
|
import { realpathSync as realpathSync4, statSync as statSync4 } from "node:fs";
|
|
80789
|
-
import { realpath as realpath7, stat as
|
|
80928
|
+
import { realpath as realpath7, stat as stat7 } from "node:fs/promises";
|
|
80790
80929
|
function readExecutableIdentity(path8) {
|
|
80791
80930
|
const resolvedPath = realpathSync4(path8);
|
|
80792
80931
|
const metadata = statSync4(resolvedPath);
|
|
@@ -80802,7 +80941,7 @@ function readExecutableIdentity(path8) {
|
|
|
80802
80941
|
async function resolveLaunchFiles(entry, executable) {
|
|
80803
80942
|
const resolvedEntry = await realpath7(entry);
|
|
80804
80943
|
const resolvedExecutable = await realpath7(executable);
|
|
80805
|
-
if (!(await
|
|
80944
|
+
if (!(await stat7(resolvedEntry)).isFile() || !(await stat7(resolvedExecutable)).isFile()) {
|
|
80806
80945
|
return null;
|
|
80807
80946
|
}
|
|
80808
80947
|
return { entry: resolvedEntry, executable: resolvedExecutable };
|
|
@@ -83012,7 +83151,7 @@ var init_session_event_id_allocator = __esm({
|
|
|
83012
83151
|
});
|
|
83013
83152
|
|
|
83014
83153
|
// src/session/history/session-event-store.ts
|
|
83015
|
-
import { randomUUID as
|
|
83154
|
+
import { randomUUID as randomUUID9 } from "node:crypto";
|
|
83016
83155
|
function liveEvent(sessionId, sessionGenerationId, eventId, position, event, recordedAt = (/* @__PURE__ */ new Date()).toISOString()) {
|
|
83017
83156
|
return {
|
|
83018
83157
|
eventId,
|
|
@@ -83169,7 +83308,7 @@ var init_session_event_store = __esm({
|
|
|
83169
83308
|
this.#eventIds = eventIds;
|
|
83170
83309
|
}
|
|
83171
83310
|
#session = (sessionId) => {
|
|
83172
|
-
const sessionGenerationId =
|
|
83311
|
+
const sessionGenerationId = randomUUID9();
|
|
83173
83312
|
const session = this.#events.get(sessionId) ?? new SessionEvents(sessionGenerationId);
|
|
83174
83313
|
this.#events.set(sessionId, session);
|
|
83175
83314
|
return session;
|
|
@@ -83234,7 +83373,7 @@ var init_session_event_store = __esm({
|
|
|
83234
83373
|
this.#events.delete(sessionId);
|
|
83235
83374
|
};
|
|
83236
83375
|
reset = (sessionId) => {
|
|
83237
|
-
const sessionGenerationId =
|
|
83376
|
+
const sessionGenerationId = randomUUID9();
|
|
83238
83377
|
this.#events.set(sessionId, new SessionEvents(sessionGenerationId));
|
|
83239
83378
|
};
|
|
83240
83379
|
};
|
|
@@ -83250,7 +83389,7 @@ var init_session_event_store = __esm({
|
|
|
83250
83389
|
this.#cacheTable = cacheTable;
|
|
83251
83390
|
}
|
|
83252
83391
|
#session = (sessionId) => {
|
|
83253
|
-
const sessionGenerationId =
|
|
83392
|
+
const sessionGenerationId = randomUUID9();
|
|
83254
83393
|
const session = this.#sessions.get(sessionId) ?? new SessionEvents(sessionGenerationId);
|
|
83255
83394
|
this.#sessions.set(sessionId, session);
|
|
83256
83395
|
return session;
|
|
@@ -83376,7 +83515,7 @@ var init_session_event_store = __esm({
|
|
|
83376
83515
|
reset = (sessionId) => {
|
|
83377
83516
|
const previous = this.#sessions.get(sessionId);
|
|
83378
83517
|
this.#deletePersisted(sessionId, previous?.sessionGenerationId);
|
|
83379
|
-
const sessionGenerationId =
|
|
83518
|
+
const sessionGenerationId = randomUUID9();
|
|
83380
83519
|
this.#sessions.set(sessionId, new SessionEvents(sessionGenerationId));
|
|
83381
83520
|
};
|
|
83382
83521
|
materializedEventCount = (sessionId) => this.#sessions.get(sessionId)?.materializedCount ?? 0;
|
|
@@ -84557,7 +84696,7 @@ var init_sql = __esm({
|
|
|
84557
84696
|
return new SQL([new StringChunk(str)]);
|
|
84558
84697
|
}
|
|
84559
84698
|
_sql.raw = raw;
|
|
84560
|
-
function
|
|
84699
|
+
function join39(chunks, separator) {
|
|
84561
84700
|
const result = [];
|
|
84562
84701
|
for (const [i, chunk] of chunks.entries()) {
|
|
84563
84702
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -84565,7 +84704,7 @@ var init_sql = __esm({
|
|
|
84565
84704
|
}
|
|
84566
84705
|
return new SQL(result);
|
|
84567
84706
|
}
|
|
84568
|
-
_sql.join =
|
|
84707
|
+
_sql.join = join39;
|
|
84569
84708
|
function identifier2(value) {
|
|
84570
84709
|
return new Name(value);
|
|
84571
84710
|
}
|
|
@@ -86523,7 +86662,7 @@ var init_select = __esm({
|
|
|
86523
86662
|
const baseTableName = this.tableName;
|
|
86524
86663
|
const tableName = getTableLikeName(table);
|
|
86525
86664
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
86526
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
86665
|
+
if (typeof tableName === "string" && this.config.joins?.some((join39) => join39.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
86527
86666
|
if (!this.isPartialSelect) {
|
|
86528
86667
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
86529
86668
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -87063,7 +87202,7 @@ function isNull(value) {
|
|
|
87063
87202
|
function isNotNull(value) {
|
|
87064
87203
|
return sql`(${value} is not null)`;
|
|
87065
87204
|
}
|
|
87066
|
-
function
|
|
87205
|
+
function exists2(subquery) {
|
|
87067
87206
|
return sql`exists ${subquery}`;
|
|
87068
87207
|
}
|
|
87069
87208
|
function notExists(subquery) {
|
|
@@ -87498,7 +87637,7 @@ function relationsFilterToSQL(table, filter, tableRelations = {}, tablesRelation
|
|
|
87498
87637
|
const { filter: relationFilter, joinCondition } = relationToSQL(relation, table, targetTable, throughTable);
|
|
87499
87638
|
const filter2 = and(relationFilter, typeof value === "boolean" ? void 0 : relationsFilterToSQL(targetTable, value, targetConfig.relations, tablesRelations, depth + 1));
|
|
87500
87639
|
const subquery = throughTable ? sql`(select * from ${getTableAsAliasSQL(targetTable)} inner join ${getTableAsAliasSQL(throughTable)} on ${joinCondition}${sql` where ${filter2}`.if(filter2)} limit 1)` : sql`(select * from ${getTableAsAliasSQL(targetTable)}${sql` where ${filter2}`.if(filter2)} limit 1)`;
|
|
87501
|
-
if (filter2) parts.push((value ?
|
|
87640
|
+
if (filter2) parts.push((value ? exists2 : notExists)(subquery));
|
|
87502
87641
|
}
|
|
87503
87642
|
}
|
|
87504
87643
|
}
|
|
@@ -87666,7 +87805,7 @@ var init_relations = __esm({
|
|
|
87666
87805
|
and,
|
|
87667
87806
|
between,
|
|
87668
87807
|
eq: eq2,
|
|
87669
|
-
exists,
|
|
87808
|
+
exists: exists2,
|
|
87670
87809
|
gt: gt2,
|
|
87671
87810
|
gte: gte2,
|
|
87672
87811
|
ilike,
|
|
@@ -88120,7 +88259,7 @@ var init_dialect = __esm({
|
|
|
88120
88259
|
if (!joins2) return;
|
|
88121
88260
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
88122
88261
|
if (!withEntries.length) return;
|
|
88123
|
-
return sql.join(withEntries.map(([k2,
|
|
88262
|
+
return sql.join(withEntries.map(([k2, join39]) => {
|
|
88124
88263
|
const relation = tableConfig.relations[k2];
|
|
88125
88264
|
const isSingle2 = is(relation, One2);
|
|
88126
88265
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -88131,7 +88270,7 @@ var init_dialect = __esm({
|
|
|
88131
88270
|
table: targetTable,
|
|
88132
88271
|
mode: isSingle2 ? "first" : "many",
|
|
88133
88272
|
schema,
|
|
88134
|
-
queryConfig:
|
|
88273
|
+
queryConfig: join39,
|
|
88135
88274
|
tableConfig: schema[relation.targetTableName],
|
|
88136
88275
|
relationWhere: filter,
|
|
88137
88276
|
isNested: true,
|
|
@@ -88145,7 +88284,7 @@ var init_dialect = __esm({
|
|
|
88145
88284
|
key: k2,
|
|
88146
88285
|
selection: innerQuery.selection,
|
|
88147
88286
|
isArray: !isSingle2,
|
|
88148
|
-
isOptional: (relation.optional ?? false) ||
|
|
88287
|
+
isOptional: (relation.optional ?? false) || join39 !== true && !!join39.where
|
|
88149
88288
|
});
|
|
88150
88289
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
88151
88290
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -88567,7 +88706,7 @@ var init_update = __esm({
|
|
|
88567
88706
|
createJoin(joinType) {
|
|
88568
88707
|
return ((table, on2) => {
|
|
88569
88708
|
const tableName = getTableLikeName(table);
|
|
88570
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
88709
|
+
if (typeof tableName === "string" && this.config.joins.some((join39) => join39.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
88571
88710
|
if (typeof on2 === "function") {
|
|
88572
88711
|
const from = this.config.from ? is(table, SQLiteTable) ? table[Table.Symbol.Columns] : is(table, Subquery) ? table._.selectedFields : is(table, SQLiteViewBase) ? table[ViewBaseConfig].selectedFields : void 0 : void 0;
|
|
88573
88712
|
on2 = on2(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -89386,7 +89525,7 @@ var init_node_sqlite = __esm({
|
|
|
89386
89525
|
|
|
89387
89526
|
// src/storage/sqlite/local-sqlite-database.ts
|
|
89388
89527
|
import { chmodSync, mkdirSync as mkdirSync3 } from "node:fs";
|
|
89389
|
-
import { dirname as
|
|
89528
|
+
import { dirname as dirname10 } from "node:path";
|
|
89390
89529
|
import { DatabaseSync as DatabaseSync2 } from "node:sqlite";
|
|
89391
89530
|
var LocalSqliteDatabase;
|
|
89392
89531
|
var init_local_sqlite_database = __esm({
|
|
@@ -89398,7 +89537,7 @@ var init_local_sqlite_database = __esm({
|
|
|
89398
89537
|
orm;
|
|
89399
89538
|
#sqlite;
|
|
89400
89539
|
constructor(path8, label, migrations, pragmas = []) {
|
|
89401
|
-
mkdirSync3(
|
|
89540
|
+
mkdirSync3(dirname10(path8), { mode: 448, recursive: true });
|
|
89402
89541
|
this.#sqlite = new DatabaseSync2(path8);
|
|
89403
89542
|
chmodSync(path8, 384);
|
|
89404
89543
|
try {
|
|
@@ -89452,13 +89591,13 @@ var init_local_sqlite_database = __esm({
|
|
|
89452
89591
|
});
|
|
89453
89592
|
|
|
89454
89593
|
// src/storage/sqlite/local-databases.ts
|
|
89455
|
-
import { createHash as
|
|
89456
|
-
import { join as
|
|
89594
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
89595
|
+
import { join as join22 } from "node:path";
|
|
89457
89596
|
function channelSessionDatabasePaths(stateDirectory, channelId) {
|
|
89458
|
-
const channelHash =
|
|
89597
|
+
const channelHash = createHash4("sha256").update(channelId).digest("hex");
|
|
89459
89598
|
return {
|
|
89460
|
-
events:
|
|
89461
|
-
sessions:
|
|
89599
|
+
events: join22(stateDirectory, "sessions", `${channelHash}.events.sqlite`),
|
|
89600
|
+
sessions: join22(stateDirectory, "sessions", `${channelHash}.sqlite`)
|
|
89462
89601
|
};
|
|
89463
89602
|
}
|
|
89464
89603
|
var openAcpSessionDatabase, openSessionEventCacheDatabase;
|
|
@@ -89691,13 +89830,13 @@ var init_session_event_cache_table = __esm({
|
|
|
89691
89830
|
// src/storage/session/temporary-session-event-cache.ts
|
|
89692
89831
|
import { mkdtempSync, rmSync as rmSync2 } from "node:fs";
|
|
89693
89832
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
89694
|
-
import { join as
|
|
89833
|
+
import { join as join23 } from "node:path";
|
|
89695
89834
|
function openTemporarySessionEventCache() {
|
|
89696
|
-
const directory = mkdtempSync(
|
|
89835
|
+
const directory = mkdtempSync(join23(tmpdir2(), "mobius-preview-events-"));
|
|
89697
89836
|
const removeFiles = () => rmSync2(directory, { recursive: true, force: true });
|
|
89698
89837
|
try {
|
|
89699
89838
|
return {
|
|
89700
|
-
table: new SessionEventCacheTable(openSessionEventCacheDatabase(
|
|
89839
|
+
table: new SessionEventCacheTable(openSessionEventCacheDatabase(join23(directory, "events.sqlite"))),
|
|
89701
89840
|
removeFiles
|
|
89702
89841
|
};
|
|
89703
89842
|
} catch (error62) {
|
|
@@ -89822,7 +89961,7 @@ var init_tool_event = __esm({
|
|
|
89822
89961
|
});
|
|
89823
89962
|
|
|
89824
89963
|
// src/acp/adapter/codex/adapter.ts
|
|
89825
|
-
import { createHash as
|
|
89964
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
89826
89965
|
var CodexAdapter;
|
|
89827
89966
|
var init_adapter2 = __esm({
|
|
89828
89967
|
"src/acp/adapter/codex/adapter.ts"() {
|
|
@@ -89943,7 +90082,7 @@ var init_adapter2 = __esm({
|
|
|
89943
90082
|
},
|
|
89944
90083
|
async (runtime) => await runtime.closeProcess()
|
|
89945
90084
|
);
|
|
89946
|
-
const generationId =
|
|
90085
|
+
const generationId = createHash5("sha256").update(request.nativeSessionId).update("\0").update(JSON.stringify(events)).digest("hex");
|
|
89947
90086
|
this.#previewCache.events.materialize(sessionId, generationId, events);
|
|
89948
90087
|
return this.#previewCache.events.page(sessionId, request.eventLimit, request.cursor);
|
|
89949
90088
|
};
|
|
@@ -90546,10 +90685,10 @@ var init_catalog2 = __esm({
|
|
|
90546
90685
|
});
|
|
90547
90686
|
|
|
90548
90687
|
// src/runtime/config.ts
|
|
90549
|
-
import { join as
|
|
90688
|
+
import { join as join24, resolve as resolve14 } from "node:path";
|
|
90550
90689
|
function loadDefaultWorkspace(environment = process.env) {
|
|
90551
90690
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
90552
|
-
return configuredWorkspace ??
|
|
90691
|
+
return configuredWorkspace ?? join24(readStateDirectory(environment), "workspace");
|
|
90553
90692
|
}
|
|
90554
90693
|
function withRuntimeEnvironment(agent, environment) {
|
|
90555
90694
|
const launchEnvironment = {};
|
|
@@ -90665,88 +90804,6 @@ var init_resolve_catalog_agent = __esm({
|
|
|
90665
90804
|
}
|
|
90666
90805
|
});
|
|
90667
90806
|
|
|
90668
|
-
// src/util/node-error.ts
|
|
90669
|
-
function isNodeError(error62, code) {
|
|
90670
|
-
return typeof error62 === "object" && error62 !== null && "code" in error62 && error62.code === code;
|
|
90671
|
-
}
|
|
90672
|
-
var init_node_error = __esm({
|
|
90673
|
-
"src/util/node-error.ts"() {
|
|
90674
|
-
"use strict";
|
|
90675
|
-
}
|
|
90676
|
-
});
|
|
90677
|
-
|
|
90678
|
-
// src/storage/installation/installation-files.ts
|
|
90679
|
-
import { createHash as createHash5, randomUUID as randomUUID9 } from "node:crypto";
|
|
90680
|
-
import { mkdir as mkdir4, open as open5, readdir as readdir5, rename as rename3, unlink as unlink3, writeFile } from "node:fs/promises";
|
|
90681
|
-
import { dirname as dirname9, join as join23 } from "node:path";
|
|
90682
|
-
function applicationDirectory(root, applicationId) {
|
|
90683
|
-
return join23(root, "installations", applicationId);
|
|
90684
|
-
}
|
|
90685
|
-
function installationPointerPath(applicationDirectory2) {
|
|
90686
|
-
return join23(applicationDirectory2, "current.json");
|
|
90687
|
-
}
|
|
90688
|
-
function installationDirectory(applicationDirectory2, installationId2) {
|
|
90689
|
-
return join23(applicationDirectory2, installationId2);
|
|
90690
|
-
}
|
|
90691
|
-
function connectionDirectory(installationDirectory2) {
|
|
90692
|
-
return join23(installationDirectory2, "connections");
|
|
90693
|
-
}
|
|
90694
|
-
function connectionFilePath(connectionDirectory2, connectionId2) {
|
|
90695
|
-
return join23(connectionDirectory2, `${connectionId2}.json`);
|
|
90696
|
-
}
|
|
90697
|
-
function channelIndexFilePath(installationDirectory2, channelId) {
|
|
90698
|
-
return join23(installationDirectory2, "channels", `mci_${createHash5("sha256").update(channelId).digest("hex")}.json`);
|
|
90699
|
-
}
|
|
90700
|
-
async function readInstallationFile(path8) {
|
|
90701
|
-
let handle;
|
|
90702
|
-
try {
|
|
90703
|
-
handle = await open5(path8, "r");
|
|
90704
|
-
} catch (cause) {
|
|
90705
|
-
return isNodeError(cause, "ENOENT") ? { kind: "missing", cause } : { kind: "unopenable", cause };
|
|
90706
|
-
}
|
|
90707
|
-
try {
|
|
90708
|
-
const metadata = await handle.stat();
|
|
90709
|
-
if (!metadata.isFile() || metadata.size > MAXIMUM_FILE_BYTES) {
|
|
90710
|
-
return { kind: "not-a-small-file" };
|
|
90711
|
-
}
|
|
90712
|
-
return { kind: "read", text: await handle.readFile({ encoding: "utf8" }) };
|
|
90713
|
-
} finally {
|
|
90714
|
-
await handle.close();
|
|
90715
|
-
}
|
|
90716
|
-
}
|
|
90717
|
-
async function writeInstallationFile(path8, text2, signal) {
|
|
90718
|
-
signal.throwIfAborted();
|
|
90719
|
-
const directory = dirname9(path8);
|
|
90720
|
-
const temporaryPath = join23(directory, `.${randomUUID9()}.tmp`);
|
|
90721
|
-
try {
|
|
90722
|
-
await mkdir4(directory, { mode: 448, recursive: true });
|
|
90723
|
-
signal.throwIfAborted();
|
|
90724
|
-
await writeFile(temporaryPath, text2, { flag: "wx", mode: 384 });
|
|
90725
|
-
signal.throwIfAborted();
|
|
90726
|
-
await rename3(temporaryPath, path8);
|
|
90727
|
-
} catch (cause) {
|
|
90728
|
-
await unlink3(temporaryPath).catch(() => void 0);
|
|
90729
|
-
throw cause;
|
|
90730
|
-
}
|
|
90731
|
-
}
|
|
90732
|
-
async function createInstallationFile(path8, text2) {
|
|
90733
|
-
await writeFile(path8, text2, { flag: "wx", mode: 384 });
|
|
90734
|
-
}
|
|
90735
|
-
async function listInstallationFiles(directory) {
|
|
90736
|
-
return await readdir5(directory);
|
|
90737
|
-
}
|
|
90738
|
-
async function removeInstallationFile(path8) {
|
|
90739
|
-
await unlink3(path8);
|
|
90740
|
-
}
|
|
90741
|
-
var MAXIMUM_FILE_BYTES;
|
|
90742
|
-
var init_installation_files = __esm({
|
|
90743
|
-
"src/storage/installation/installation-files.ts"() {
|
|
90744
|
-
"use strict";
|
|
90745
|
-
init_node_error();
|
|
90746
|
-
MAXIMUM_FILE_BYTES = 16 * 1024;
|
|
90747
|
-
}
|
|
90748
|
-
});
|
|
90749
|
-
|
|
90750
90807
|
// src/util/filesystem/private-path.ts
|
|
90751
90808
|
import { lstat as lstat3 } from "node:fs/promises";
|
|
90752
90809
|
async function validateLocalPath(path8, directory, privateAccess, signal) {
|
|
@@ -91264,13 +91321,13 @@ var init_runtime_installation_store = __esm({
|
|
|
91264
91321
|
|
|
91265
91322
|
// src/storage/daemon/version-data.ts
|
|
91266
91323
|
import { randomUUID as randomUUID11 } from "node:crypto";
|
|
91267
|
-
import { cp as cp2, lstat as lstat4, mkdtemp, readFile as
|
|
91268
|
-
import { join as
|
|
91324
|
+
import { cp as cp2, lstat as lstat4, mkdtemp, readFile as readFile7, rename as rename4, rm as rm3, writeFile as writeFile2 } from "node:fs/promises";
|
|
91325
|
+
import { join as join25 } from "node:path";
|
|
91269
91326
|
async function readCurrentDataVersion(root, signal) {
|
|
91270
|
-
const pointer =
|
|
91327
|
+
const pointer = join25(root, "current-data.txt");
|
|
91271
91328
|
try {
|
|
91272
91329
|
await validateLocalPath(pointer, false, true, signal);
|
|
91273
|
-
const value = (await
|
|
91330
|
+
const value = (await readFile7(pointer, { encoding: "utf8", signal })).trim();
|
|
91274
91331
|
if (!value.startsWith("versions/")) {
|
|
91275
91332
|
throw new DataInheritanceError("The current data pointer must name a version directory");
|
|
91276
91333
|
}
|
|
@@ -91284,7 +91341,7 @@ async function readCurrentDataVersion(root, signal) {
|
|
|
91284
91341
|
}
|
|
91285
91342
|
async function versionDataExists(root, version2, signal) {
|
|
91286
91343
|
try {
|
|
91287
|
-
await validateLocalPath(
|
|
91344
|
+
await validateLocalPath(join25(root, "versions", version2), true, true, signal);
|
|
91288
91345
|
return true;
|
|
91289
91346
|
} catch (cause) {
|
|
91290
91347
|
if (!isNodeError(cause, "ENOENT")) {
|
|
@@ -91294,13 +91351,13 @@ async function versionDataExists(root, version2, signal) {
|
|
|
91294
91351
|
}
|
|
91295
91352
|
}
|
|
91296
91353
|
async function copyVersionData(root, sourceVersion, targetVersion, signal) {
|
|
91297
|
-
const versions =
|
|
91298
|
-
const source =
|
|
91299
|
-
const target =
|
|
91354
|
+
const versions = join25(root, "versions");
|
|
91355
|
+
const source = join25(versions, sourceVersion);
|
|
91356
|
+
const target = join25(versions, targetVersion);
|
|
91300
91357
|
await validateLocalPath(root, true, true, signal);
|
|
91301
91358
|
await validateLocalPath(versions, true, true, signal);
|
|
91302
91359
|
await validateLocalPath(source, true, true, signal);
|
|
91303
|
-
const staging = await mkdtemp(
|
|
91360
|
+
const staging = await mkdtemp(join25(versions, `.${targetVersion}-`));
|
|
91304
91361
|
try {
|
|
91305
91362
|
await cp2(source, staging, {
|
|
91306
91363
|
recursive: true,
|
|
@@ -91327,13 +91384,13 @@ async function copyVersionData(root, sourceVersion, targetVersion, signal) {
|
|
|
91327
91384
|
}
|
|
91328
91385
|
async function writeCurrentDataVersion(root, version2, signal) {
|
|
91329
91386
|
await validateLocalPath(root, true, true, signal);
|
|
91330
|
-
await validateLocalPath(
|
|
91331
|
-
const temporary =
|
|
91387
|
+
await validateLocalPath(join25(root, "versions", version2), true, true, signal);
|
|
91388
|
+
const temporary = join25(root, `.current-data-${randomUUID11()}.txt`);
|
|
91332
91389
|
try {
|
|
91333
91390
|
await writeFile2(temporary, `versions/${version2}
|
|
91334
91391
|
`, { mode: 384, flag: "wx", signal });
|
|
91335
91392
|
signal.throwIfAborted();
|
|
91336
|
-
await rename4(temporary,
|
|
91393
|
+
await rename4(temporary, join25(root, "current-data.txt"));
|
|
91337
91394
|
} finally {
|
|
91338
91395
|
await rm3(temporary, { force: true });
|
|
91339
91396
|
}
|
|
@@ -91353,15 +91410,15 @@ var init_version_data = __esm({
|
|
|
91353
91410
|
|
|
91354
91411
|
// src/storage/daemon/control-token.ts
|
|
91355
91412
|
import { randomBytes } from "node:crypto";
|
|
91356
|
-
import { readFile as
|
|
91357
|
-
import { join as
|
|
91413
|
+
import { readFile as readFile8, writeFile as writeFile3 } from "node:fs/promises";
|
|
91414
|
+
import { join as join26 } from "node:path";
|
|
91358
91415
|
function controlTokenPath(stateDirectory) {
|
|
91359
|
-
return
|
|
91416
|
+
return join26(stateDirectory, "manager.token");
|
|
91360
91417
|
}
|
|
91361
91418
|
async function readOrCreateControlToken(stateDirectory) {
|
|
91362
91419
|
const path8 = controlTokenPath(stateDirectory);
|
|
91363
91420
|
try {
|
|
91364
|
-
return (await
|
|
91421
|
+
return (await readFile8(path8, "utf8")).trim();
|
|
91365
91422
|
} catch (cause) {
|
|
91366
91423
|
if (!isNodeError(cause, "ENOENT")) {
|
|
91367
91424
|
throw cause;
|
|
@@ -91376,7 +91433,7 @@ async function readOrCreateControlToken(stateDirectory) {
|
|
|
91376
91433
|
if (!isNodeError(cause, "EEXIST")) {
|
|
91377
91434
|
throw cause;
|
|
91378
91435
|
}
|
|
91379
|
-
return (await
|
|
91436
|
+
return (await readFile8(path8, "utf8")).trim();
|
|
91380
91437
|
}
|
|
91381
91438
|
}
|
|
91382
91439
|
var init_control_token = __esm({
|
|
@@ -91578,7 +91635,7 @@ var init_data = __esm({
|
|
|
91578
91635
|
|
|
91579
91636
|
// src/daemon/pairing/pair-local-machine.ts
|
|
91580
91637
|
import { hostname as hostname3 } from "node:os";
|
|
91581
|
-
import { basename as
|
|
91638
|
+
import { basename as basename7, join as join27, resolve as resolve16 } from "node:path";
|
|
91582
91639
|
import { fetch as fetch3 } from "undici";
|
|
91583
91640
|
function hasExactKeys2(value, expectedKeys) {
|
|
91584
91641
|
const keys = Object.keys(value);
|
|
@@ -91729,7 +91786,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, signal) {
|
|
|
91729
91786
|
agents,
|
|
91730
91787
|
machineName: hostname3(),
|
|
91731
91788
|
pairingCode: options.code,
|
|
91732
|
-
workspaceName:
|
|
91789
|
+
workspaceName: basename7(defaultWorkspace) || "Local workspace"
|
|
91733
91790
|
}),
|
|
91734
91791
|
dispatcher: environmentProxyDispatcher,
|
|
91735
91792
|
headers: { "content-type": "application/json" },
|
|
@@ -91831,7 +91888,7 @@ async function openMobiusCliInstallation(signal, environment) {
|
|
|
91831
91888
|
return await openRuntimeInstallationStore(
|
|
91832
91889
|
{
|
|
91833
91890
|
applicationId: MOBIUS_CLI_APPLICATION_ID,
|
|
91834
|
-
stateDirectory:
|
|
91891
|
+
stateDirectory: join27(readStateDirectory(environment), "versions", package_default.version)
|
|
91835
91892
|
},
|
|
91836
91893
|
signal
|
|
91837
91894
|
);
|
|
@@ -92102,10 +92159,10 @@ var init_agents = __esm({
|
|
|
92102
92159
|
});
|
|
92103
92160
|
|
|
92104
92161
|
// src/storage/daemon/manager-lock.ts
|
|
92105
|
-
import { readFile as
|
|
92106
|
-
import { join as
|
|
92162
|
+
import { readFile as readFile9, unlink as unlink4, writeFile as writeFile4 } from "node:fs/promises";
|
|
92163
|
+
import { join as join28 } from "node:path";
|
|
92107
92164
|
async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
|
|
92108
|
-
const path8 =
|
|
92165
|
+
const path8 = join28(stateDirectory, name2);
|
|
92109
92166
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
92110
92167
|
try {
|
|
92111
92168
|
await writeFile4(path8, `${process.pid.toString()}
|
|
@@ -92115,7 +92172,7 @@ async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
|
|
|
92115
92172
|
if (!isNodeError(cause, "EEXIST")) {
|
|
92116
92173
|
throw cause;
|
|
92117
92174
|
}
|
|
92118
|
-
const encoded = await
|
|
92175
|
+
const encoded = await readFile9(path8, "utf8").catch(() => "");
|
|
92119
92176
|
const pid = Number(encoded.trim());
|
|
92120
92177
|
if (Number.isSafeInteger(pid) && pid > 1) {
|
|
92121
92178
|
try {
|
|
@@ -92134,7 +92191,7 @@ async function acquireManagerLock(stateDirectory, name2 = "manager.lock") {
|
|
|
92134
92191
|
}
|
|
92135
92192
|
async function managerLockExists(stateDirectory) {
|
|
92136
92193
|
try {
|
|
92137
|
-
await
|
|
92194
|
+
await readFile9(join28(stateDirectory, "manager.lock"), "utf8");
|
|
92138
92195
|
return true;
|
|
92139
92196
|
} catch (cause) {
|
|
92140
92197
|
if (isNodeError(cause, "ENOENT")) {
|
|
@@ -92222,7 +92279,7 @@ var init_local_server = __esm({
|
|
|
92222
92279
|
|
|
92223
92280
|
// src/storage/logs/bounded-log.ts
|
|
92224
92281
|
import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync4, readFileSync as readFileSync9, renameSync as renameSync2, statSync as statSync5, writeFileSync as writeFileSync2 } from "node:fs";
|
|
92225
|
-
import { join as
|
|
92282
|
+
import { join as join29 } from "node:path";
|
|
92226
92283
|
var BoundedLineLog;
|
|
92227
92284
|
var init_bounded_log = __esm({
|
|
92228
92285
|
"src/storage/logs/bounded-log.ts"() {
|
|
@@ -92235,7 +92292,7 @@ var init_bounded_log = __esm({
|
|
|
92235
92292
|
#onWriteFailure;
|
|
92236
92293
|
constructor(directory, filename, maximumBytes, onWriteFailure = () => void 0) {
|
|
92237
92294
|
this.#directory = directory;
|
|
92238
|
-
this.#path =
|
|
92295
|
+
this.#path = join29(directory, filename);
|
|
92239
92296
|
this.#maximumBytes = maximumBytes;
|
|
92240
92297
|
this.#onWriteFailure = onWriteFailure;
|
|
92241
92298
|
}
|
|
@@ -92288,20 +92345,20 @@ var init_bounded_log = __esm({
|
|
|
92288
92345
|
|
|
92289
92346
|
// src/storage/logs/log-files.ts
|
|
92290
92347
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
92291
|
-
import { lstat as lstat5, readdir as readdir6, readFile as
|
|
92292
|
-
import { join as
|
|
92348
|
+
import { lstat as lstat5, readdir as readdir6, readFile as readFile10 } from "node:fs/promises";
|
|
92349
|
+
import { join as join30, relative as relative2 } from "node:path";
|
|
92293
92350
|
function unhandledRejectionLogFilename(role) {
|
|
92294
92351
|
return `unhandled-rejections-${role}.log`;
|
|
92295
92352
|
}
|
|
92296
92353
|
function logDirectory(stateDirectory) {
|
|
92297
|
-
return
|
|
92354
|
+
return join30(stateDirectory, "logs");
|
|
92298
92355
|
}
|
|
92299
92356
|
function processLogPaths(stateDirectory) {
|
|
92300
92357
|
return [
|
|
92301
92358
|
WORKER_LIFECYCLE_LOG_FILENAME,
|
|
92302
92359
|
unhandledRejectionLogFilename("manager"),
|
|
92303
92360
|
unhandledRejectionLogFilename("worker")
|
|
92304
|
-
].map((filename) =>
|
|
92361
|
+
].map((filename) => join30(logDirectory(stateDirectory), filename));
|
|
92305
92362
|
}
|
|
92306
92363
|
function readLogText(path8) {
|
|
92307
92364
|
try {
|
|
@@ -92314,17 +92371,17 @@ function isAbsent(cause) {
|
|
|
92314
92371
|
return typeof cause === "object" && cause !== null && Reflect.get(cause, "code") === "ENOENT";
|
|
92315
92372
|
}
|
|
92316
92373
|
async function findLogDirectories(root, unreadable, signal) {
|
|
92317
|
-
const versions =
|
|
92318
|
-
const installationsRoots = [
|
|
92374
|
+
const versions = join30(root, VERSIONS_DIRECTORY);
|
|
92375
|
+
const installationsRoots = [join30(root, INSTALLATIONS_DIRECTORY)];
|
|
92319
92376
|
for (const version2 of await listDirectories(versions, root, unreadable, signal)) {
|
|
92320
|
-
installationsRoots.push(
|
|
92377
|
+
installationsRoots.push(join30(versions, version2, INSTALLATIONS_DIRECTORY));
|
|
92321
92378
|
}
|
|
92322
92379
|
const found = [];
|
|
92323
92380
|
for (const installations of installationsRoots) {
|
|
92324
92381
|
for (const applicationId of await listDirectories(installations, root, unreadable, signal)) {
|
|
92325
|
-
const application =
|
|
92382
|
+
const application = join30(installations, applicationId);
|
|
92326
92383
|
for (const installationId2 of await listDirectories(application, root, unreadable, signal)) {
|
|
92327
|
-
const logs =
|
|
92384
|
+
const logs = join30(application, installationId2, "logs");
|
|
92328
92385
|
const status = await directoryStatus(logs);
|
|
92329
92386
|
if (status === "listed") {
|
|
92330
92387
|
found.push(logs);
|
|
@@ -92382,7 +92439,7 @@ async function readOwnedLogFile(path8, signal) {
|
|
|
92382
92439
|
return { kind: "skipped" };
|
|
92383
92440
|
}
|
|
92384
92441
|
try {
|
|
92385
|
-
return { kind: "read", content: await
|
|
92442
|
+
return { kind: "read", content: await readFile10(path8, { encoding: "utf8", signal }) };
|
|
92386
92443
|
} catch (cause) {
|
|
92387
92444
|
if (signal.aborted) {
|
|
92388
92445
|
throw cause;
|
|
@@ -92934,14 +92991,14 @@ var init_manager2 = __esm({
|
|
|
92934
92991
|
});
|
|
92935
92992
|
|
|
92936
92993
|
// src/storage/daemon/release-files.ts
|
|
92937
|
-
import { readFile as
|
|
92938
|
-
import { join as
|
|
92994
|
+
import { readFile as readFile11, realpath as realpath8 } from "node:fs/promises";
|
|
92995
|
+
import { join as join31 } from "node:path";
|
|
92939
92996
|
function releasePrefix(version2) {
|
|
92940
|
-
return
|
|
92997
|
+
return join31(readStateDirectory(), "npm", version2);
|
|
92941
92998
|
}
|
|
92942
92999
|
async function readInstalledRelease(prefix) {
|
|
92943
|
-
const packageRoot = await realpath8(
|
|
92944
|
-
return { manifest: await
|
|
93000
|
+
const packageRoot = await realpath8(join31(prefix, "node_modules", "@moxt-ai", "mobius"));
|
|
93001
|
+
return { manifest: await readFile11(join31(packageRoot, "package.json"), "utf8"), packageRoot };
|
|
92945
93002
|
}
|
|
92946
93003
|
var init_release_files = __esm({
|
|
92947
93004
|
"src/storage/daemon/release-files.ts"() {
|
|
@@ -92951,7 +93008,7 @@ var init_release_files = __esm({
|
|
|
92951
93008
|
});
|
|
92952
93009
|
|
|
92953
93010
|
// src/daemon/upgrades/package.ts
|
|
92954
|
-
import { isAbsolute as isAbsolute16, join as
|
|
93011
|
+
import { isAbsolute as isAbsolute16, join as join32, relative as relative3 } from "node:path";
|
|
92955
93012
|
async function prepareDaemonReleaseVersion(version2, signal) {
|
|
92956
93013
|
runtimeUpgradeVersionSchema.parse(version2);
|
|
92957
93014
|
signal.throwIfAborted();
|
|
@@ -93032,7 +93089,7 @@ async function verifyInstalledDaemonRelease(installed, prefix, version2, signal)
|
|
|
93032
93089
|
bin: external_exports.object({ mobius: external_exports.literal("dist/cli.js") }),
|
|
93033
93090
|
engines: external_exports.object({ node: external_exports.string().refine((value) => (0, import_semver.validRange)(value) !== null) })
|
|
93034
93091
|
}).parse(JSON.parse(installed.manifest));
|
|
93035
|
-
const entry = await canonicalPath(
|
|
93092
|
+
const entry = await canonicalPath(join32(installed.packageRoot, metadata.bin.mobius));
|
|
93036
93093
|
const resolved = relative3(await canonicalPath(prefix), entry);
|
|
93037
93094
|
if (resolved.startsWith("..") || isAbsolute16(resolved)) {
|
|
93038
93095
|
throw new Error("Installed entry escaped npm prefix");
|
|
@@ -93265,6 +93322,24 @@ var init_quit = __esm({
|
|
|
93265
93322
|
}
|
|
93266
93323
|
});
|
|
93267
93324
|
|
|
93325
|
+
// src/runtime/catalog/refresh-agent-catalog.ts
|
|
93326
|
+
async function refreshAgentCatalog(config2, discover, signal) {
|
|
93327
|
+
const readyAgents = await discover(signal);
|
|
93328
|
+
signal.throwIfAborted();
|
|
93329
|
+
return await config2.catalog.replaceAndPublish(
|
|
93330
|
+
() => readyAgents.map((agent) => withRuntimeEnvironment(agent, config2.localContext.environment)),
|
|
93331
|
+
(publishSignal) => publishAgentCatalog(config2, publishSignal),
|
|
93332
|
+
signal
|
|
93333
|
+
);
|
|
93334
|
+
}
|
|
93335
|
+
var init_refresh_agent_catalog = __esm({
|
|
93336
|
+
"src/runtime/catalog/refresh-agent-catalog.ts"() {
|
|
93337
|
+
"use strict";
|
|
93338
|
+
init_config();
|
|
93339
|
+
init_publish_agent_catalog();
|
|
93340
|
+
}
|
|
93341
|
+
});
|
|
93342
|
+
|
|
93268
93343
|
// src/schema/acp-session-store/acp-session.ts
|
|
93269
93344
|
var acpSession;
|
|
93270
93345
|
var init_acp_session = __esm({
|
|
@@ -97351,7 +97426,7 @@ var init_session_turns = __esm({
|
|
|
97351
97426
|
|
|
97352
97427
|
// src/session/workspace/workspace-directory.ts
|
|
97353
97428
|
import { homedir as homedir4 } from "node:os";
|
|
97354
|
-
import { basename as
|
|
97429
|
+
import { basename as basename8, dirname as dirname11, isAbsolute as isAbsolute17, join as join33, normalize as normalize2, relative as relative4 } from "node:path";
|
|
97355
97430
|
function encodePath(path8) {
|
|
97356
97431
|
const encoded = Buffer.from(path8, "utf8").toString("base64url");
|
|
97357
97432
|
if (path8.length === 0 || path8.length > MAX_WORKSPACE_PATH_LENGTH || encoded.length + "path-".length > MAX_DIRECTORY_IDENTIFIER_LENGTH) {
|
|
@@ -97454,7 +97529,7 @@ var init_workspace_directory = __esm({
|
|
|
97454
97529
|
return {
|
|
97455
97530
|
path: path8,
|
|
97456
97531
|
directoryId: encodePath(path8),
|
|
97457
|
-
name:
|
|
97532
|
+
name: basename8(path8) || path8,
|
|
97458
97533
|
label: this.label(path8)
|
|
97459
97534
|
};
|
|
97460
97535
|
};
|
|
@@ -97480,7 +97555,7 @@ var init_workspace_directory = __esm({
|
|
|
97480
97555
|
continue;
|
|
97481
97556
|
}
|
|
97482
97557
|
try {
|
|
97483
|
-
const path8 = await this.resolvePath(
|
|
97558
|
+
const path8 = await this.resolvePath(join33(target, child.name), signal);
|
|
97484
97559
|
entries.push({ directoryId: encodePath(path8), name: child.name });
|
|
97485
97560
|
} catch (cause) {
|
|
97486
97561
|
signal.throwIfAborted();
|
|
@@ -97490,7 +97565,7 @@ var init_workspace_directory = __esm({
|
|
|
97490
97565
|
}
|
|
97491
97566
|
}
|
|
97492
97567
|
entries.sort((a, b2) => a.name.localeCompare(b2.name));
|
|
97493
|
-
const parent =
|
|
97568
|
+
const parent = dirname11(target);
|
|
97494
97569
|
return new WorkspaceDirectoryListing(
|
|
97495
97570
|
id,
|
|
97496
97571
|
this.label(target),
|
|
@@ -97651,8 +97726,8 @@ var init_session_layer = __esm({
|
|
|
97651
97726
|
|
|
97652
97727
|
// src/storage/files/scratch-directory.ts
|
|
97653
97728
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
97654
|
-
import { lstat as lstat6, mkdir as mkdir5, readdir as readdir7, realpath as realpath9, rename as rename5, rm as rm4, stat as
|
|
97655
|
-
import { dirname as
|
|
97729
|
+
import { lstat as lstat6, mkdir as mkdir5, readdir as readdir7, realpath as realpath9, rename as rename5, rm as rm4, stat as stat8, utimes, writeFile as writeFile5 } from "node:fs/promises";
|
|
97730
|
+
import { dirname as dirname12, join as join34 } from "node:path";
|
|
97656
97731
|
async function atomicWrite(path8, bytes, signal) {
|
|
97657
97732
|
const temporary = `${path8}.${randomUUID15()}.tmp`;
|
|
97658
97733
|
try {
|
|
@@ -97670,22 +97745,22 @@ var init_scratch_directory = __esm({
|
|
|
97670
97745
|
ScratchDirectory = class {
|
|
97671
97746
|
#root;
|
|
97672
97747
|
constructor(parent) {
|
|
97673
|
-
this.#root =
|
|
97748
|
+
this.#root = join34(parent, randomUUID15());
|
|
97674
97749
|
}
|
|
97675
97750
|
/** Refreshes this directory's lease and removes sibling directories whose lease is older than `leaseMilliseconds`. */
|
|
97676
97751
|
refreshLease = async (leaseMilliseconds) => {
|
|
97677
97752
|
await mkdir5(this.#root, { mode: 448, recursive: true });
|
|
97678
97753
|
const now = /* @__PURE__ */ new Date();
|
|
97679
97754
|
await utimes(this.#root, now, now);
|
|
97680
|
-
for (const directory of await readdir7(
|
|
97755
|
+
for (const directory of await readdir7(dirname12(this.#root), { withFileTypes: true })) {
|
|
97681
97756
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
97682
97757
|
continue;
|
|
97683
97758
|
}
|
|
97684
|
-
const path8 =
|
|
97759
|
+
const path8 = join34(dirname12(this.#root), directory.name);
|
|
97685
97760
|
if (path8 === this.#root) {
|
|
97686
97761
|
continue;
|
|
97687
97762
|
}
|
|
97688
|
-
const modified = await
|
|
97763
|
+
const modified = await stat8(path8).then(
|
|
97689
97764
|
(entry) => entry.mtimeMs,
|
|
97690
97765
|
() => Date.now()
|
|
97691
97766
|
);
|
|
@@ -97696,10 +97771,10 @@ var init_scratch_directory = __esm({
|
|
|
97696
97771
|
};
|
|
97697
97772
|
/** Writes `bytes` atomically to `<group>/<name>` with owner-only permissions and returns the path. */
|
|
97698
97773
|
write = async (group, name2, bytes, signal) => {
|
|
97699
|
-
const directory =
|
|
97774
|
+
const directory = join34(this.#root, group);
|
|
97700
97775
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
97701
97776
|
signal.throwIfAborted();
|
|
97702
|
-
const path8 =
|
|
97777
|
+
const path8 = join34(directory, name2);
|
|
97703
97778
|
await atomicWrite(path8, bytes, signal);
|
|
97704
97779
|
return path8;
|
|
97705
97780
|
};
|
|
@@ -97710,11 +97785,11 @@ var init_scratch_directory = __esm({
|
|
|
97710
97785
|
resolveFile = async (path8) => {
|
|
97711
97786
|
try {
|
|
97712
97787
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
97713
|
-
realpath9(
|
|
97788
|
+
realpath9(dirname12(path8)),
|
|
97714
97789
|
realpath9(path8),
|
|
97715
97790
|
lstat6(path8)
|
|
97716
97791
|
]);
|
|
97717
|
-
return file2.isFile() && !file2.isSymbolicLink() &&
|
|
97792
|
+
return file2.isFile() && !file2.isSymbolicLink() && dirname12(resolvedPath) === resolvedDirectory ? resolvedPath : null;
|
|
97718
97793
|
} catch {
|
|
97719
97794
|
return null;
|
|
97720
97795
|
}
|
|
@@ -97728,7 +97803,7 @@ var init_scratch_directory = __esm({
|
|
|
97728
97803
|
|
|
97729
97804
|
// src/session/content/external-content-store.ts
|
|
97730
97805
|
import { createHash as createHash8 } from "node:crypto";
|
|
97731
|
-
import { join as
|
|
97806
|
+
import { join as join35 } from "node:path";
|
|
97732
97807
|
var contentRequest, CONTENT_LIFETIME_MILLISECONDS, metadataSchema, LocalExternalContentStore;
|
|
97733
97808
|
var init_external_content_store = __esm({
|
|
97734
97809
|
"src/session/content/external-content-store.ts"() {
|
|
@@ -97750,7 +97825,7 @@ var init_external_content_store = __esm({
|
|
|
97750
97825
|
#expirationTimer;
|
|
97751
97826
|
#cleanup = Promise.resolve();
|
|
97752
97827
|
constructor(stateDirectory) {
|
|
97753
|
-
this.#scratch = new ScratchDirectory(
|
|
97828
|
+
this.#scratch = new ScratchDirectory(join35(stateDirectory, "tmp", "session-content"));
|
|
97754
97829
|
this.#expirationTimer = setInterval(() => {
|
|
97755
97830
|
void this.#expire().catch(() => void 0);
|
|
97756
97831
|
}, 6e4);
|
|
@@ -98150,7 +98225,7 @@ var init_agent_process_pool = __esm({
|
|
|
98150
98225
|
});
|
|
98151
98226
|
|
|
98152
98227
|
// src/runtime/observability/diagnostic-log.ts
|
|
98153
|
-
import { join as
|
|
98228
|
+
import { join as join36 } from "node:path";
|
|
98154
98229
|
function exportedFields(value) {
|
|
98155
98230
|
const entry = {};
|
|
98156
98231
|
for (const field of REMOTE_DIAGNOSTIC_FIELDS) {
|
|
@@ -98219,7 +98294,7 @@ var init_diagnostic_log = __esm({
|
|
|
98219
98294
|
this.#maximumBytes = maximumBytes;
|
|
98220
98295
|
const processLogsDirectory = options.processLogsDirectory;
|
|
98221
98296
|
this.#sources = [
|
|
98222
|
-
{ maximumBytes, path:
|
|
98297
|
+
{ maximumBytes, path: join36(directory, DAEMON_LOG_FILENAME) },
|
|
98223
98298
|
// The process logs a Runtime does not own, but must read to explain its own deaths.
|
|
98224
98299
|
...processLogsDirectory === void 0 ? [] : processLogPaths(processLogsDirectory).map((path8) => ({ maximumBytes: null, path: path8 }))
|
|
98225
98300
|
];
|
|
@@ -98498,13 +98573,7 @@ function createAgentCatalogDiscoveryHandler(dependencies) {
|
|
|
98498
98573
|
);
|
|
98499
98574
|
completion = (async () => {
|
|
98500
98575
|
try {
|
|
98501
|
-
const
|
|
98502
|
-
operationSignal.throwIfAborted();
|
|
98503
|
-
const published = await config2.catalog.replaceAndPublish(
|
|
98504
|
-
() => readyAgents.map((agent) => withRuntimeEnvironment(agent, config2.localContext.environment)),
|
|
98505
|
-
(publishSignal) => publishAgentCatalog(config2, publishSignal),
|
|
98506
|
-
operationSignal
|
|
98507
|
-
);
|
|
98576
|
+
const published = await refreshAgentCatalog(config2, discover, operationSignal);
|
|
98508
98577
|
operationSignal.throwIfAborted();
|
|
98509
98578
|
if (socket.readyState === WebSocket3.OPEN) {
|
|
98510
98579
|
send(
|
|
@@ -98554,8 +98623,7 @@ var init_handle_agent_catalog_discovery = __esm({
|
|
|
98554
98623
|
init_protocol();
|
|
98555
98624
|
init_operation_error();
|
|
98556
98625
|
init_transport();
|
|
98557
|
-
|
|
98558
|
-
init_publish_agent_catalog();
|
|
98626
|
+
init_refresh_agent_catalog();
|
|
98559
98627
|
CATALOG_DISCOVERY_TIMEOUT_MILLISECONDS = 9e4;
|
|
98560
98628
|
}
|
|
98561
98629
|
});
|
|
@@ -99132,7 +99200,7 @@ var init_agent_settings = __esm({
|
|
|
99132
99200
|
});
|
|
99133
99201
|
|
|
99134
99202
|
// src/session/content/session-files.ts
|
|
99135
|
-
import { basename as
|
|
99203
|
+
import { basename as basename9, extname as extname2, isAbsolute as isAbsolute18, join as join37, normalize as normalize3, resolve as resolve18 } from "node:path";
|
|
99136
99204
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
99137
99205
|
function requestedPath(value) {
|
|
99138
99206
|
if (value.includes("\0")) {
|
|
@@ -99156,7 +99224,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
99156
99224
|
if (isAbsolute18(requested.path) && normalize3(requested.path) !== requested.path) {
|
|
99157
99225
|
return null;
|
|
99158
99226
|
}
|
|
99159
|
-
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [
|
|
99227
|
+
const candidates = requested.explicitUrl || workingDirectory === null ? [requested.path] : isAbsolute18(requested.path) ? [join37(workingDirectory, requested.path), requested.path] : [resolve18(workingDirectory, requested.path)];
|
|
99160
99228
|
for (const candidate of candidates) {
|
|
99161
99229
|
if (!isAbsolute18(candidate) || normalize3(candidate) !== candidate) {
|
|
99162
99230
|
continue;
|
|
@@ -99190,7 +99258,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
99190
99258
|
kind: FILE_BEGIN_KIND,
|
|
99191
99259
|
mediaType: external?.mediaType ?? raster?.mimeType ?? (extname2(target).toLowerCase() === ".svg" ? "image/svg+xml" : "application/octet-stream"),
|
|
99192
99260
|
modifiedAt: before.modifiedAt.toISOString(),
|
|
99193
|
-
name: external?.name ?? (
|
|
99261
|
+
name: external?.name ?? (basename9(target) || "file"),
|
|
99194
99262
|
requestId: command.requestId,
|
|
99195
99263
|
sessionId: command.sessionId
|
|
99196
99264
|
});
|
|
@@ -99266,7 +99334,7 @@ var init_file_read = __esm({
|
|
|
99266
99334
|
});
|
|
99267
99335
|
|
|
99268
99336
|
// src/session/workspace/resolve-session-directories.ts
|
|
99269
|
-
import { basename as
|
|
99337
|
+
import { basename as basename10 } from "node:path";
|
|
99270
99338
|
async function resolveSessionDirectories(directories, bindingId, directoryId, additionalDirectoryIds, signal) {
|
|
99271
99339
|
const selection = await directories.describe(bindingId, directoryId, signal);
|
|
99272
99340
|
const cwd = selection.path;
|
|
@@ -99282,7 +99350,7 @@ async function resolveSessionDirectories(directories, bindingId, directoryId, ad
|
|
|
99282
99350
|
additionalDirectories.push(directory);
|
|
99283
99351
|
additionalDirectoryEntries.push({
|
|
99284
99352
|
directoryId: additionalDirectoryId,
|
|
99285
|
-
name:
|
|
99353
|
+
name: basename10(directory)
|
|
99286
99354
|
});
|
|
99287
99355
|
}
|
|
99288
99356
|
return new ResolvedSessionDirectories(cwd, selection.label, additionalDirectories, additionalDirectoryEntries);
|
|
@@ -102127,7 +102195,7 @@ async function runWorkerRuntime(version2, combined, shutdown, rejectionGuard) {
|
|
|
102127
102195
|
}
|
|
102128
102196
|
}
|
|
102129
102197
|
).finally(() => active.delete(connection.connectionId));
|
|
102130
|
-
active.set(connection.connectionId, { controller, completion });
|
|
102198
|
+
active.set(connection.connectionId, { config: paired.config, controller, completion });
|
|
102131
102199
|
} catch (cause) {
|
|
102132
102200
|
combined.throwIfAborted();
|
|
102133
102201
|
fail(connection.connectionId, cause);
|
|
@@ -102135,6 +102203,26 @@ async function runWorkerRuntime(version2, combined, shutdown, rejectionGuard) {
|
|
|
102135
102203
|
}
|
|
102136
102204
|
}
|
|
102137
102205
|
};
|
|
102206
|
+
const refreshRunningCatalogs = async (connectionIds) => {
|
|
102207
|
+
await Promise.all(
|
|
102208
|
+
[...connectionIds].map(async (connectionId2) => {
|
|
102209
|
+
const config2 = active.get(connectionId2)?.config;
|
|
102210
|
+
if (config2?.rediscoverAgents === void 0) {
|
|
102211
|
+
return;
|
|
102212
|
+
}
|
|
102213
|
+
try {
|
|
102214
|
+
await refreshAgentCatalog(
|
|
102215
|
+
config2,
|
|
102216
|
+
config2.rediscoverAgents,
|
|
102217
|
+
AbortSignal.any([combined, AbortSignal.timeout(9e4)])
|
|
102218
|
+
);
|
|
102219
|
+
} catch (cause) {
|
|
102220
|
+
combined.throwIfAborted();
|
|
102221
|
+
console.error(`Runtime ${connectionId2} could not refresh its Agent catalog`, cause);
|
|
102222
|
+
}
|
|
102223
|
+
})
|
|
102224
|
+
);
|
|
102225
|
+
};
|
|
102138
102226
|
let reload = Promise.resolve();
|
|
102139
102227
|
let upgrades = Promise.resolve();
|
|
102140
102228
|
try {
|
|
@@ -102147,7 +102235,8 @@ async function runWorkerRuntime(version2, combined, shutdown, rejectionGuard) {
|
|
|
102147
102235
|
if (typeof request !== "object" || request === null || !("kind" in request) || request.kind !== "reload") {
|
|
102148
102236
|
return { kind: "error", code: "invalid_reload", message: "Expected a configuration reload" };
|
|
102149
102237
|
}
|
|
102150
|
-
const
|
|
102238
|
+
const running = new Set(active.keys());
|
|
102239
|
+
const pending = reload.then(reconcile).then(async () => await refreshRunningCatalogs(running));
|
|
102151
102240
|
reload = pending.catch(() => void 0);
|
|
102152
102241
|
await pending;
|
|
102153
102242
|
return { kind: "reloaded" };
|
|
@@ -102176,6 +102265,7 @@ var WorkerRuntimeError;
|
|
|
102176
102265
|
var init_worker = __esm({
|
|
102177
102266
|
"src/daemon/lifecycle/worker.ts"() {
|
|
102178
102267
|
"use strict";
|
|
102268
|
+
init_refresh_agent_catalog();
|
|
102179
102269
|
init_engine();
|
|
102180
102270
|
init_runtime_turn_activity();
|
|
102181
102271
|
init_manager_lock();
|
|
@@ -102295,7 +102385,7 @@ var init_daemon = __esm({
|
|
|
102295
102385
|
});
|
|
102296
102386
|
|
|
102297
102387
|
// src/cli/handler/logs/logic/collect-local-logs.ts
|
|
102298
|
-
import { join as
|
|
102388
|
+
import { join as join38, relative as relative5, resolve as resolve19 } from "node:path";
|
|
102299
102389
|
async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
|
|
102300
102390
|
signal.throwIfAborted();
|
|
102301
102391
|
const root = resolve19(stateDirectory);
|
|
@@ -102305,7 +102395,7 @@ async function collectLocalDaemonLogs(stateDirectory, tailLines, signal) {
|
|
|
102305
102395
|
for (const directory of directories) {
|
|
102306
102396
|
const names = await listLogFiles(directory, root, unreadable);
|
|
102307
102397
|
for (const name2 of names) {
|
|
102308
|
-
const path8 =
|
|
102398
|
+
const path8 = join38(directory, name2);
|
|
102309
102399
|
const reported = relative5(root, path8);
|
|
102310
102400
|
const read = await readOwnedLogFile(path8, signal);
|
|
102311
102401
|
if (read.kind === "unreadable") {
|
|
@@ -102668,10 +102758,15 @@ async function runCLI() {
|
|
|
102668
102758
|
version: package_default.version
|
|
102669
102759
|
};
|
|
102670
102760
|
try {
|
|
102761
|
+
await validateStateRoot(process.env);
|
|
102671
102762
|
await createProgram(context).parseAsync(process.argv);
|
|
102672
102763
|
} catch (error62) {
|
|
102673
102764
|
if (error62 instanceof CommanderError) {
|
|
102674
102765
|
process.exitCode = error62.exitCode;
|
|
102766
|
+
} else if (error62 instanceof StateRootError) {
|
|
102767
|
+
process.stderr.write(`${error62.message}
|
|
102768
|
+
`);
|
|
102769
|
+
process.exitCode = 78;
|
|
102675
102770
|
} else if (!shutdown.signal.aborted) {
|
|
102676
102771
|
const message = error62 instanceof Error ? error62.message : "Unknown failure";
|
|
102677
102772
|
process.stderr.write(`Mobius daemon failed: ${message}
|
|
@@ -102688,6 +102783,7 @@ var init_cli = __esm({
|
|
|
102688
102783
|
"use strict";
|
|
102689
102784
|
init_commander();
|
|
102690
102785
|
init_package();
|
|
102786
|
+
init_state_root();
|
|
102691
102787
|
init_agents();
|
|
102692
102788
|
init_daemon();
|
|
102693
102789
|
init_logs();
|