@moxt-ai/mobius 0.0.193 → 0.0.195
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/acp/agent-runtime-manager.js +1 -1
- package/dist/acp/agent-runtime-manager.js.map +1 -1
- package/dist/acp/agent-session.js +2 -2
- package/dist/acp/agent-session.js.map +1 -1
- package/dist/acp/native-session.d.ts +1 -0
- package/dist/acp/native-session.d.ts.map +1 -1
- package/dist/agent-catalog/agents/workbuddy-agent.d.ts.map +1 -1
- package/dist/agent-catalog/agents/workbuddy-agent.js +5 -19
- package/dist/agent-catalog/agents/workbuddy-agent.js.map +1 -1
- package/dist/agent-catalog/discover-agent-settings.d.ts.map +1 -1
- package/dist/agent-catalog/discover-agent-settings.js +2 -1
- package/dist/agent-catalog/discover-agent-settings.js.map +1 -1
- package/dist/agent-catalog/resolve-catalog-agent.d.ts +15 -0
- package/dist/agent-catalog/resolve-catalog-agent.d.ts.map +1 -0
- package/dist/agent-catalog/resolve-catalog-agent.js +65 -0
- package/dist/agent-catalog/resolve-catalog-agent.js.map +1 -0
- package/dist/agent-installation/grok-managed-package.d.ts.map +1 -1
- package/dist/agent-installation/grok-managed-package.js +5 -16
- package/dist/agent-installation/grok-managed-package.js.map +1 -1
- package/dist/agent-installation/opencode-managed-release.d.ts.map +1 -1
- package/dist/agent-installation/opencode-managed-release.js +9 -16
- package/dist/agent-installation/opencode-managed-release.js.map +1 -1
- package/dist/cli.js +965 -800
- package/dist/cli.js.map +4 -4
- package/dist/config.d.ts +7 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/daemon-history-commands.d.ts.map +1 -1
- package/dist/daemon-history-commands.js +73 -31
- package/dist/daemon-history-commands.js.map +1 -1
- package/dist/daemon-prompt-executor.d.ts.map +1 -1
- package/dist/daemon-prompt-executor.js +2 -1
- package/dist/daemon-prompt-executor.js.map +1 -1
- package/dist/daemon-session-commands.d.ts +2 -1
- package/dist/daemon-session-commands.d.ts.map +1 -1
- package/dist/daemon-session-commands.js +6 -2
- package/dist/daemon-session-commands.js.map +1 -1
- package/dist/index.js +970 -796
- package/dist/index.js.map +4 -4
- package/dist/native-sessions/service.d.ts.map +1 -1
- package/dist/native-sessions/service.js +5 -2
- package/dist/native-sessions/service.js.map +1 -1
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +12 -5
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/platform/contracts.d.ts +26 -0
- package/dist/platform/contracts.d.ts.map +1 -0
- package/dist/platform/contracts.js +2 -0
- package/dist/platform/contracts.js.map +1 -0
- package/dist/platform/index.d.ts +3 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/index.js +21 -0
- package/dist/platform/index.js.map +1 -0
- package/dist/platform/linux.d.ts +3 -0
- package/dist/platform/linux.d.ts.map +1 -0
- package/dist/platform/linux.js +146 -0
- package/dist/platform/linux.js.map +1 -0
- package/dist/platform/macos.d.ts +3 -0
- package/dist/platform/macos.d.ts.map +1 -0
- package/dist/platform/macos.js +49 -0
- package/dist/platform/macos.js.map +1 -0
- package/dist/platform/posix.d.ts +4 -0
- package/dist/platform/posix.d.ts.map +1 -0
- package/dist/platform/posix.js +47 -0
- package/dist/platform/posix.js.map +1 -0
- package/dist/process/executable.d.ts +2 -4
- package/dist/process/executable.d.ts.map +1 -1
- package/dist/process/executable.js +11 -166
- package/dist/process/executable.js.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +988 -814
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/runtime.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/runtime.ts
|
|
8
|
-
import { mkdir as mkdir7, realpath as
|
|
8
|
+
import { mkdir as mkdir7, realpath as realpath12, stat as stat11 } from "node:fs/promises";
|
|
9
9
|
import { resolve as resolve8 } from "node:path";
|
|
10
10
|
|
|
11
11
|
// ../../node_modules/.pnpm/zod@4.6.5/node_modules/zod/v4/classic/external.js
|
|
@@ -21327,6 +21327,7 @@ var provenanceSchema = external_exports.discriminatedUnion("kind", [
|
|
|
21327
21327
|
]);
|
|
21328
21328
|
var sessionEventFieldsV2 = {
|
|
21329
21329
|
eventId: identifierStringSchema,
|
|
21330
|
+
mobiusMetadata: external_exports.object({ omitted: external_exports.literal(true).optional() }).readonly().optional(),
|
|
21330
21331
|
position: positionSchema,
|
|
21331
21332
|
provenance: provenanceSchema,
|
|
21332
21333
|
recordedAt: external_exports.iso.datetime({ offset: true }),
|
|
@@ -21393,7 +21394,12 @@ var sessionEventLogPageV2Schema = external_exports.object({
|
|
|
21393
21394
|
truncated: external_exports.boolean(),
|
|
21394
21395
|
version: external_exports.literal(2)
|
|
21395
21396
|
}).readonly();
|
|
21396
|
-
var
|
|
21397
|
+
var sessionEventOmissionV2Schema = external_exports.literal("agent-reasoning");
|
|
21398
|
+
var nativeEventPageRequestV2Schema = external_exports.object({
|
|
21399
|
+
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21400
|
+
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21401
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional()
|
|
21402
|
+
}).readonly();
|
|
21397
21403
|
var queuedPromptRequestEventLogV2Schema = external_exports.object({
|
|
21398
21404
|
commandId: identifierStringSchema,
|
|
21399
21405
|
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
|
|
@@ -21440,6 +21446,7 @@ var directoryIdentifier = external_exports.string().regex(/^[a-zA-Z0-9][a-zA-Z0-
|
|
|
21440
21446
|
var pageRequestFields = {
|
|
21441
21447
|
cursor: external_exports.string().min(1).max(512).nullable(),
|
|
21442
21448
|
eventLimit: external_exports.number().int().min(1).max(1e4),
|
|
21449
|
+
omit: external_exports.array(sessionEventOmissionV2Schema).max(1).readonly().optional(),
|
|
21443
21450
|
requestId: identifierStringSchema,
|
|
21444
21451
|
sessionId: identifierStringSchema
|
|
21445
21452
|
};
|
|
@@ -21796,15 +21803,266 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
21796
21803
|
}
|
|
21797
21804
|
|
|
21798
21805
|
// src/process/executable.ts
|
|
21799
|
-
import {
|
|
21806
|
+
import { spawn } from "node:child_process";
|
|
21807
|
+
import { constants as constants2 } from "node:fs";
|
|
21808
|
+
import { access as access2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
21809
|
+
import { join as join3, resolve } from "node:path";
|
|
21810
|
+
|
|
21811
|
+
// src/platform/linux.ts
|
|
21800
21812
|
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
21801
21813
|
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
21802
|
-
import { join
|
|
21814
|
+
import { join } from "node:path";
|
|
21815
|
+
|
|
21816
|
+
// src/platform/posix.ts
|
|
21817
|
+
import { execFile } from "node:child_process";
|
|
21818
|
+
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21819
|
+
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21820
|
+
function parseProcessTable(output2) {
|
|
21821
|
+
const entries = [];
|
|
21822
|
+
for (const line of output2.split("\n")) {
|
|
21823
|
+
const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
|
|
21824
|
+
if (groups === void 0) {
|
|
21825
|
+
continue;
|
|
21826
|
+
}
|
|
21827
|
+
const processId = Number(groups["pid"]);
|
|
21828
|
+
const parentProcessId = Number(groups["ppid"]);
|
|
21829
|
+
const processGroupId = Number(groups["pgid"]);
|
|
21830
|
+
if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21831
|
+
continue;
|
|
21832
|
+
}
|
|
21833
|
+
entries.push({ parentProcessId, processGroupId, processId });
|
|
21834
|
+
}
|
|
21835
|
+
return entries;
|
|
21836
|
+
}
|
|
21837
|
+
function readProcessTableWithPs(executable) {
|
|
21838
|
+
return new Promise((resolveTable) => {
|
|
21839
|
+
execFile(
|
|
21840
|
+
executable,
|
|
21841
|
+
["-axo", "pid=,ppid=,pgid="],
|
|
21842
|
+
{
|
|
21843
|
+
encoding: "utf8",
|
|
21844
|
+
maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
|
|
21845
|
+
signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
|
|
21846
|
+
timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
|
|
21847
|
+
},
|
|
21848
|
+
(error62, stdout) => {
|
|
21849
|
+
resolveTable(error62 === null ? parseProcessTable(stdout) : []);
|
|
21850
|
+
}
|
|
21851
|
+
);
|
|
21852
|
+
});
|
|
21853
|
+
}
|
|
21854
|
+
function processExists(processId) {
|
|
21855
|
+
try {
|
|
21856
|
+
process.kill(processId, 0);
|
|
21857
|
+
return true;
|
|
21858
|
+
} catch {
|
|
21859
|
+
return false;
|
|
21860
|
+
}
|
|
21861
|
+
}
|
|
21862
|
+
|
|
21863
|
+
// src/platform/linux.ts
|
|
21864
|
+
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
21865
|
+
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21866
|
+
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
21867
|
+
return;
|
|
21868
|
+
}
|
|
21869
|
+
const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
|
|
21870
|
+
const parentProcessId = Number(fields[1]);
|
|
21871
|
+
const processGroupId = Number(fields[2]);
|
|
21872
|
+
if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21873
|
+
return;
|
|
21874
|
+
}
|
|
21875
|
+
entries.push({ parentProcessId, processGroupId, processId });
|
|
21876
|
+
}
|
|
21877
|
+
async function readLinuxProcessTable() {
|
|
21878
|
+
const entries = [];
|
|
21879
|
+
try {
|
|
21880
|
+
const directories = await readdir("/proc", { withFileTypes: true });
|
|
21881
|
+
for (const directory of directories) {
|
|
21882
|
+
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21883
|
+
continue;
|
|
21884
|
+
}
|
|
21885
|
+
const processId = Number(directory.name);
|
|
21886
|
+
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21887
|
+
continue;
|
|
21888
|
+
}
|
|
21889
|
+
try {
|
|
21890
|
+
appendLinuxProcessTableEntry(
|
|
21891
|
+
entries,
|
|
21892
|
+
processId,
|
|
21893
|
+
await readFile(join("/proc", directory.name, "stat"), "utf8")
|
|
21894
|
+
);
|
|
21895
|
+
} catch {
|
|
21896
|
+
}
|
|
21897
|
+
}
|
|
21898
|
+
} catch {
|
|
21899
|
+
}
|
|
21900
|
+
return entries;
|
|
21901
|
+
}
|
|
21902
|
+
function readLinuxProcessTableSynchronously() {
|
|
21903
|
+
const entries = [];
|
|
21904
|
+
try {
|
|
21905
|
+
const directories = readdirSync("/proc", { withFileTypes: true });
|
|
21906
|
+
for (const directory of directories) {
|
|
21907
|
+
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21908
|
+
continue;
|
|
21909
|
+
}
|
|
21910
|
+
const processId = Number(directory.name);
|
|
21911
|
+
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21912
|
+
continue;
|
|
21913
|
+
}
|
|
21914
|
+
try {
|
|
21915
|
+
appendLinuxProcessTableEntry(
|
|
21916
|
+
entries,
|
|
21917
|
+
processId,
|
|
21918
|
+
readFileSync(join("/proc", directory.name, "stat"), "utf8")
|
|
21919
|
+
);
|
|
21920
|
+
} catch {
|
|
21921
|
+
}
|
|
21922
|
+
}
|
|
21923
|
+
} catch {
|
|
21924
|
+
}
|
|
21925
|
+
return entries;
|
|
21926
|
+
}
|
|
21927
|
+
async function readLinuxProcessTableWithFallback() {
|
|
21928
|
+
const procfsEntries = await readLinuxProcessTable();
|
|
21929
|
+
if (procfsEntries.length > 0) {
|
|
21930
|
+
return procfsEntries;
|
|
21931
|
+
}
|
|
21932
|
+
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
21933
|
+
try {
|
|
21934
|
+
const resolvedPath = await realpath(candidate);
|
|
21935
|
+
if (!(await stat(resolvedPath)).isFile()) {
|
|
21936
|
+
continue;
|
|
21937
|
+
}
|
|
21938
|
+
await access(resolvedPath, constants.X_OK);
|
|
21939
|
+
} catch {
|
|
21940
|
+
continue;
|
|
21941
|
+
}
|
|
21942
|
+
const entries = await readProcessTableWithPs(candidate);
|
|
21943
|
+
if (entries.length > 0) {
|
|
21944
|
+
return entries;
|
|
21945
|
+
}
|
|
21946
|
+
}
|
|
21947
|
+
return [];
|
|
21948
|
+
}
|
|
21949
|
+
function processExists2(processId) {
|
|
21950
|
+
try {
|
|
21951
|
+
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
21952
|
+
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21953
|
+
if (closingParenthesis >= 0) {
|
|
21954
|
+
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
21955
|
+
if (processState === "Z" || processState === "X") {
|
|
21956
|
+
return false;
|
|
21957
|
+
}
|
|
21958
|
+
}
|
|
21959
|
+
} catch {
|
|
21960
|
+
}
|
|
21961
|
+
return processExists(processId);
|
|
21962
|
+
}
|
|
21963
|
+
var linuxPlatform = {
|
|
21964
|
+
readProcessTable: readLinuxProcessTableWithFallback,
|
|
21965
|
+
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
21966
|
+
processExists: processExists2,
|
|
21967
|
+
workBuddyExecutablePaths: () => [],
|
|
21968
|
+
openCodeArchives: {
|
|
21969
|
+
arm64: {
|
|
21970
|
+
asset: "opencode-linux-arm64.tar.gz",
|
|
21971
|
+
sha256: "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
|
|
21972
|
+
format: "tar.gz"
|
|
21973
|
+
},
|
|
21974
|
+
x64: {
|
|
21975
|
+
asset: "opencode-linux-x64.tar.gz",
|
|
21976
|
+
sha256: "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
|
|
21977
|
+
format: "tar.gz"
|
|
21978
|
+
}
|
|
21979
|
+
},
|
|
21980
|
+
grokDependencies: {
|
|
21981
|
+
arm64: {
|
|
21982
|
+
name: "@xai-official/grok-linux-arm64",
|
|
21983
|
+
integrity: "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
|
|
21984
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
|
|
21985
|
+
},
|
|
21986
|
+
x64: {
|
|
21987
|
+
name: "@xai-official/grok-linux-x64",
|
|
21988
|
+
integrity: "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
|
|
21989
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
|
|
21990
|
+
}
|
|
21991
|
+
}
|
|
21992
|
+
};
|
|
21993
|
+
|
|
21994
|
+
// src/platform/macos.ts
|
|
21995
|
+
import { isAbsolute, join as join2 } from "node:path";
|
|
21996
|
+
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
21997
|
+
"WorkBuddy.app",
|
|
21998
|
+
"Contents",
|
|
21999
|
+
"Resources",
|
|
22000
|
+
"app.asar.unpacked",
|
|
22001
|
+
"cli",
|
|
22002
|
+
"bin",
|
|
22003
|
+
"codebuddy"
|
|
22004
|
+
]);
|
|
22005
|
+
var macosPlatform = {
|
|
22006
|
+
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
22007
|
+
readProcessTableSynchronously: () => [],
|
|
22008
|
+
processExists,
|
|
22009
|
+
workBuddyExecutablePaths: (environment) => {
|
|
22010
|
+
const paths = [join2("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
22011
|
+
const homeDirectory = environment["HOME"];
|
|
22012
|
+
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
22013
|
+
paths.unshift(join2(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
22014
|
+
}
|
|
22015
|
+
return paths;
|
|
22016
|
+
},
|
|
22017
|
+
openCodeArchives: {
|
|
22018
|
+
arm64: {
|
|
22019
|
+
asset: "opencode-darwin-arm64.zip",
|
|
22020
|
+
sha256: "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
|
|
22021
|
+
format: "zip"
|
|
22022
|
+
},
|
|
22023
|
+
x64: {
|
|
22024
|
+
asset: "opencode-darwin-x64.zip",
|
|
22025
|
+
sha256: "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
|
|
22026
|
+
format: "zip"
|
|
22027
|
+
}
|
|
22028
|
+
},
|
|
22029
|
+
grokDependencies: {
|
|
22030
|
+
arm64: {
|
|
22031
|
+
name: "@xai-official/grok-darwin-arm64",
|
|
22032
|
+
integrity: "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
|
|
22033
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
|
|
22034
|
+
},
|
|
22035
|
+
x64: {
|
|
22036
|
+
name: "@xai-official/grok-darwin-x64",
|
|
22037
|
+
integrity: "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
|
|
22038
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
|
|
22039
|
+
}
|
|
22040
|
+
}
|
|
22041
|
+
};
|
|
22042
|
+
|
|
22043
|
+
// src/platform/index.ts
|
|
22044
|
+
var fallbackPlatform = {
|
|
22045
|
+
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
22046
|
+
readProcessTableSynchronously: () => [],
|
|
22047
|
+
processExists,
|
|
22048
|
+
workBuddyExecutablePaths: () => [],
|
|
22049
|
+
openCodeArchives: {},
|
|
22050
|
+
grokDependencies: {}
|
|
22051
|
+
};
|
|
22052
|
+
var platforms = /* @__PURE__ */ new Map([
|
|
22053
|
+
["linux", linuxPlatform],
|
|
22054
|
+
["darwin", macosPlatform],
|
|
22055
|
+
["win32", { ...fallbackPlatform, readProcessTable: () => Promise.resolve([]) }]
|
|
22056
|
+
]);
|
|
22057
|
+
function platformSupportFor(platform) {
|
|
22058
|
+
return platforms.get(platform) ?? fallbackPlatform;
|
|
22059
|
+
}
|
|
22060
|
+
|
|
22061
|
+
// src/process/executable.ts
|
|
22062
|
+
var hostPlatform = platformSupportFor(process.platform);
|
|
21803
22063
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
|
|
21804
22064
|
var PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
21805
22065
|
var PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
|
|
21806
|
-
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21807
|
-
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21808
22066
|
var PROCESS_EXIT_CHECK_ATTEMPTS = 16;
|
|
21809
22067
|
var GRACEFUL_STOP_SIGNAL = 15;
|
|
21810
22068
|
var FORCED_STOP_SIGNAL = 9;
|
|
@@ -21863,13 +22121,13 @@ function executableExtensions(executableName, environment, platform) {
|
|
|
21863
22121
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
21864
22122
|
const absoluteRequestedPath = resolve(requestedPath2);
|
|
21865
22123
|
try {
|
|
21866
|
-
const resolvedPath = await
|
|
21867
|
-
const metadata = await
|
|
22124
|
+
const resolvedPath = await realpath2(absoluteRequestedPath);
|
|
22125
|
+
const metadata = await stat2(resolvedPath);
|
|
21868
22126
|
if (!metadata.isFile()) {
|
|
21869
22127
|
return null;
|
|
21870
22128
|
}
|
|
21871
22129
|
if (platform !== "win32") {
|
|
21872
|
-
await
|
|
22130
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
21873
22131
|
}
|
|
21874
22132
|
return new ResolvedExecutable(
|
|
21875
22133
|
new ExecutableIdentity(
|
|
@@ -21894,7 +22152,7 @@ async function findExecutableOnPath(executableName, environment, platform = proc
|
|
|
21894
22152
|
continue;
|
|
21895
22153
|
}
|
|
21896
22154
|
for (const extension of extensions) {
|
|
21897
|
-
const requestedPath2 = resolve(
|
|
22155
|
+
const requestedPath2 = resolve(join3(entry, `${executableName}${extension}`));
|
|
21898
22156
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
21899
22157
|
if (executable !== null) {
|
|
21900
22158
|
return executable;
|
|
@@ -21915,128 +22173,8 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
21915
22173
|
chunks.push(chunk);
|
|
21916
22174
|
return nextBytes;
|
|
21917
22175
|
}
|
|
21918
|
-
function parseProcessTable(output2) {
|
|
21919
|
-
const entries = [];
|
|
21920
|
-
for (const line of output2.split("\n")) {
|
|
21921
|
-
const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
|
|
21922
|
-
if (groups === void 0) {
|
|
21923
|
-
continue;
|
|
21924
|
-
}
|
|
21925
|
-
const processId = Number(groups["pid"]);
|
|
21926
|
-
const parentProcessId = Number(groups["ppid"]);
|
|
21927
|
-
const processGroupId = Number(groups["pgid"]);
|
|
21928
|
-
if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21929
|
-
continue;
|
|
21930
|
-
}
|
|
21931
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
21932
|
-
}
|
|
21933
|
-
return entries;
|
|
21934
|
-
}
|
|
21935
|
-
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
21936
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21937
|
-
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
21938
|
-
return;
|
|
21939
|
-
}
|
|
21940
|
-
const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
|
|
21941
|
-
const parentProcessId = Number(fields[1]);
|
|
21942
|
-
const processGroupId = Number(fields[2]);
|
|
21943
|
-
if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21944
|
-
return;
|
|
21945
|
-
}
|
|
21946
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
21947
|
-
}
|
|
21948
|
-
async function readLinuxProcessTable() {
|
|
21949
|
-
const entries = [];
|
|
21950
|
-
try {
|
|
21951
|
-
const directories = await readdir("/proc", { withFileTypes: true });
|
|
21952
|
-
for (const directory of directories) {
|
|
21953
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21954
|
-
continue;
|
|
21955
|
-
}
|
|
21956
|
-
const processId = Number(directory.name);
|
|
21957
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21958
|
-
continue;
|
|
21959
|
-
}
|
|
21960
|
-
try {
|
|
21961
|
-
appendLinuxProcessTableEntry(
|
|
21962
|
-
entries,
|
|
21963
|
-
processId,
|
|
21964
|
-
await readFile(join("/proc", directory.name, "stat"), "utf8")
|
|
21965
|
-
);
|
|
21966
|
-
} catch {
|
|
21967
|
-
}
|
|
21968
|
-
}
|
|
21969
|
-
} catch {
|
|
21970
|
-
}
|
|
21971
|
-
return entries;
|
|
21972
|
-
}
|
|
21973
|
-
function readLinuxProcessTableSynchronously() {
|
|
21974
|
-
const entries = [];
|
|
21975
|
-
try {
|
|
21976
|
-
const directories = readdirSync("/proc", { withFileTypes: true });
|
|
21977
|
-
for (const directory of directories) {
|
|
21978
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21979
|
-
continue;
|
|
21980
|
-
}
|
|
21981
|
-
const processId = Number(directory.name);
|
|
21982
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21983
|
-
continue;
|
|
21984
|
-
}
|
|
21985
|
-
try {
|
|
21986
|
-
appendLinuxProcessTableEntry(
|
|
21987
|
-
entries,
|
|
21988
|
-
processId,
|
|
21989
|
-
readFileSync(join("/proc", directory.name, "stat"), "utf8")
|
|
21990
|
-
);
|
|
21991
|
-
} catch {
|
|
21992
|
-
}
|
|
21993
|
-
}
|
|
21994
|
-
} catch {
|
|
21995
|
-
}
|
|
21996
|
-
return entries;
|
|
21997
|
-
}
|
|
21998
|
-
function readProcessTableWithPs(executable) {
|
|
21999
|
-
return new Promise((resolveTable) => {
|
|
22000
|
-
execFile(
|
|
22001
|
-
executable,
|
|
22002
|
-
["-axo", "pid=,ppid=,pgid="],
|
|
22003
|
-
{
|
|
22004
|
-
encoding: "utf8",
|
|
22005
|
-
maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
|
|
22006
|
-
signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
|
|
22007
|
-
timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
|
|
22008
|
-
},
|
|
22009
|
-
(error62, stdout) => {
|
|
22010
|
-
resolveTable(error62 === null ? parseProcessTable(stdout) : []);
|
|
22011
|
-
}
|
|
22012
|
-
);
|
|
22013
|
-
});
|
|
22014
|
-
}
|
|
22015
|
-
async function readLinuxProcessTableWithFallback() {
|
|
22016
|
-
const procfsEntries = await readLinuxProcessTable();
|
|
22017
|
-
if (procfsEntries.length > 0) {
|
|
22018
|
-
return procfsEntries;
|
|
22019
|
-
}
|
|
22020
|
-
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
22021
|
-
const executable = await resolveExecutablePath(candidate);
|
|
22022
|
-
if (executable === null) {
|
|
22023
|
-
continue;
|
|
22024
|
-
}
|
|
22025
|
-
const entries = await readProcessTableWithPs(executable.identity.requestedPath);
|
|
22026
|
-
if (entries.length > 0) {
|
|
22027
|
-
return entries;
|
|
22028
|
-
}
|
|
22029
|
-
}
|
|
22030
|
-
return [];
|
|
22031
|
-
}
|
|
22032
22176
|
function readProcessTable() {
|
|
22033
|
-
|
|
22034
|
-
return Promise.resolve([]);
|
|
22035
|
-
}
|
|
22036
|
-
if (process.platform === "linux") {
|
|
22037
|
-
return readLinuxProcessTableWithFallback();
|
|
22038
|
-
}
|
|
22039
|
-
return readProcessTableWithPs(process.platform === "darwin" ? "/bin/ps" : "/usr/bin/ps");
|
|
22177
|
+
return hostPlatform.readProcessTable();
|
|
22040
22178
|
}
|
|
22041
22179
|
function selectProcessTree(entries, rootProcessId) {
|
|
22042
22180
|
const processIds = /* @__PURE__ */ new Set([rootProcessId]);
|
|
@@ -22073,11 +22211,9 @@ async function captureProcessTree(child2) {
|
|
|
22073
22211
|
if (process.platform === "win32" || child2.pid === void 0) {
|
|
22074
22212
|
return [];
|
|
22075
22213
|
}
|
|
22076
|
-
|
|
22077
|
-
|
|
22078
|
-
|
|
22079
|
-
return selectProcessTree(procfsEntries, child2.pid);
|
|
22080
|
-
}
|
|
22214
|
+
const entries = hostPlatform.readProcessTableSynchronously();
|
|
22215
|
+
if (entries.length > 0) {
|
|
22216
|
+
return selectProcessTree(entries, child2.pid);
|
|
22081
22217
|
}
|
|
22082
22218
|
return selectProcessTree(await readProcessTable(), child2.pid);
|
|
22083
22219
|
}
|
|
@@ -22105,36 +22241,15 @@ function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
|
22105
22241
|
}
|
|
22106
22242
|
}
|
|
22107
22243
|
}
|
|
22108
|
-
function processExists(processId) {
|
|
22109
|
-
if (process.platform === "linux") {
|
|
22110
|
-
try {
|
|
22111
|
-
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
22112
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
22113
|
-
if (closingParenthesis >= 0) {
|
|
22114
|
-
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
22115
|
-
if (processState === "Z" || processState === "X") {
|
|
22116
|
-
return false;
|
|
22117
|
-
}
|
|
22118
|
-
}
|
|
22119
|
-
} catch {
|
|
22120
|
-
}
|
|
22121
|
-
}
|
|
22122
|
-
try {
|
|
22123
|
-
process.kill(processId, 0);
|
|
22124
|
-
return true;
|
|
22125
|
-
} catch {
|
|
22126
|
-
return false;
|
|
22127
|
-
}
|
|
22128
|
-
}
|
|
22129
22244
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
22130
22245
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
22131
22246
|
for (let attempt = 0; attempt < PROCESS_EXIT_CHECK_ATTEMPTS; attempt += 1) {
|
|
22132
|
-
if (processIds.every((processId) => !processExists(processId))) {
|
|
22247
|
+
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
22133
22248
|
return true;
|
|
22134
22249
|
}
|
|
22135
22250
|
await readProcessTable();
|
|
22136
22251
|
}
|
|
22137
|
-
return processIds.every((processId) => !processExists(processId));
|
|
22252
|
+
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
22138
22253
|
}
|
|
22139
22254
|
function terminateProcess(child2) {
|
|
22140
22255
|
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
@@ -22620,8 +22735,8 @@ var LocalAgentInventory = class {
|
|
|
22620
22735
|
};
|
|
22621
22736
|
|
|
22622
22737
|
// src/agent-installation/managed-npm-package.ts
|
|
22623
|
-
import { mkdir, mkdtemp, open as open2, realpath as
|
|
22624
|
-
import { delimiter, dirname, isAbsolute, join as
|
|
22738
|
+
import { mkdir, mkdtemp, open as open2, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
22739
|
+
import { delimiter, dirname, isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
|
|
22625
22740
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
22626
22741
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
22627
22742
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -22672,11 +22787,11 @@ function isRecord3(value) {
|
|
|
22672
22787
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22673
22788
|
}
|
|
22674
22789
|
function packagePath(root, packageName) {
|
|
22675
|
-
return
|
|
22790
|
+
return join4(root, "node_modules", ...packageName.split("/"));
|
|
22676
22791
|
}
|
|
22677
22792
|
function isContainedPath(root, candidate) {
|
|
22678
22793
|
const difference = relative(root, candidate);
|
|
22679
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !
|
|
22794
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute2(difference);
|
|
22680
22795
|
}
|
|
22681
22796
|
async function readJsonRecord(path2, maximumBytes) {
|
|
22682
22797
|
try {
|
|
@@ -22777,14 +22892,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
22777
22892
|
}
|
|
22778
22893
|
}
|
|
22779
22894
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
22780
|
-
const dependencyRoot = await
|
|
22895
|
+
const dependencyRoot = await realpath3(packagePath(rootPath, definition.packageName));
|
|
22781
22896
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
22782
22897
|
throw new ManagedNpmPackageError(
|
|
22783
22898
|
"managed_package_verification_failed",
|
|
22784
22899
|
"The required managed npm dependency escaped its private cache"
|
|
22785
22900
|
);
|
|
22786
22901
|
}
|
|
22787
|
-
const metadata = await readJsonRecord(
|
|
22902
|
+
const metadata = await readJsonRecord(join4(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22788
22903
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22789
22904
|
throw new ManagedNpmPackageError(
|
|
22790
22905
|
"managed_package_verification_failed",
|
|
@@ -22806,15 +22921,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
22806
22921
|
}
|
|
22807
22922
|
}
|
|
22808
22923
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
22809
|
-
const rootPath = await
|
|
22810
|
-
const packageRoot = await
|
|
22924
|
+
const rootPath = await realpath3(root);
|
|
22925
|
+
const packageRoot = await realpath3(packagePath(rootPath, definition.packageName));
|
|
22811
22926
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
22812
22927
|
throw new ManagedNpmPackageError(
|
|
22813
22928
|
"managed_package_verification_failed",
|
|
22814
22929
|
"The managed npm package escaped its private cache"
|
|
22815
22930
|
);
|
|
22816
22931
|
}
|
|
22817
|
-
const metadata = await readJsonRecord(
|
|
22932
|
+
const metadata = await readJsonRecord(join4(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22818
22933
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22819
22934
|
throw new ManagedNpmPackageError(
|
|
22820
22935
|
"managed_package_verification_failed",
|
|
@@ -22822,14 +22937,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
22822
22937
|
);
|
|
22823
22938
|
}
|
|
22824
22939
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
22825
|
-
const lock = await readJsonRecord(
|
|
22940
|
+
const lock = await readJsonRecord(join4(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
22826
22941
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
22827
22942
|
for (const dependency of definition.requiredDependencies) {
|
|
22828
22943
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
22829
22944
|
}
|
|
22830
22945
|
}
|
|
22831
22946
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
22832
|
-
const executable = await resolveExecutablePath(
|
|
22947
|
+
const executable = await resolveExecutablePath(join4(packageRoot, declaredBin));
|
|
22833
22948
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
22834
22949
|
throw new ManagedNpmPackageError(
|
|
22835
22950
|
"managed_package_verification_failed",
|
|
@@ -22842,7 +22957,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22842
22957
|
install = async (root, definition, environment, signal) => {
|
|
22843
22958
|
signal.throwIfAborted();
|
|
22844
22959
|
try {
|
|
22845
|
-
const metadata = await
|
|
22960
|
+
const metadata = await stat3(root);
|
|
22846
22961
|
if (metadata.isDirectory()) {
|
|
22847
22962
|
return await validateManagedNpmPackage(root, definition);
|
|
22848
22963
|
}
|
|
@@ -22853,7 +22968,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22853
22968
|
}
|
|
22854
22969
|
const parent = dirname(root);
|
|
22855
22970
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
22856
|
-
const staging = await mkdtemp(
|
|
22971
|
+
const staging = await mkdtemp(join4(parent, `.${definition.version}.staging-`));
|
|
22857
22972
|
try {
|
|
22858
22973
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
22859
22974
|
if (npm === null) {
|
|
@@ -22879,9 +22994,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22879
22994
|
`${definition.packageName}@${definition.version}`
|
|
22880
22995
|
);
|
|
22881
22996
|
const installEnvironment = {
|
|
22882
|
-
HOME:
|
|
22997
|
+
HOME: join4(staging, "home"),
|
|
22883
22998
|
NPM_CONFIG_AUDIT: "false",
|
|
22884
|
-
NPM_CONFIG_CACHE:
|
|
22999
|
+
NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
|
|
22885
23000
|
NPM_CONFIG_FUND: "false",
|
|
22886
23001
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
22887
23002
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
@@ -22903,8 +23018,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22903
23018
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
22904
23019
|
});
|
|
22905
23020
|
await Promise.all([
|
|
22906
|
-
rm(
|
|
22907
|
-
rm(
|
|
23021
|
+
rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
23022
|
+
rm(join4(staging, "home"), { force: true, recursive: true })
|
|
22908
23023
|
]);
|
|
22909
23024
|
await validateManagedNpmPackage(staging, definition);
|
|
22910
23025
|
try {
|
|
@@ -22940,7 +23055,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22940
23055
|
};
|
|
22941
23056
|
|
|
22942
23057
|
// src/agent-catalog/agent-specification.ts
|
|
22943
|
-
import { join as
|
|
23058
|
+
import { join as join5 } from "node:path";
|
|
22944
23059
|
|
|
22945
23060
|
// src/agent-catalog/version-output.ts
|
|
22946
23061
|
function normalizeVersionOutput(output2) {
|
|
@@ -22963,7 +23078,7 @@ var LocalAgentSpecification = class {
|
|
|
22963
23078
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
22964
23079
|
signal.throwIfAborted();
|
|
22965
23080
|
const executable = await resolveExecutablePath(
|
|
22966
|
-
|
|
23081
|
+
join5(stateDirectory, ...this.managedAgentExecutablePath),
|
|
22967
23082
|
platform
|
|
22968
23083
|
);
|
|
22969
23084
|
signal.throwIfAborted();
|
|
@@ -23167,7 +23282,7 @@ function sessionFailureMeta(failure2) {
|
|
|
23167
23282
|
import { spawn as spawn2 } from "node:child_process";
|
|
23168
23283
|
|
|
23169
23284
|
// src/acp/codex/app-server-protocol.ts
|
|
23170
|
-
import { isAbsolute as
|
|
23285
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
23171
23286
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
23172
23287
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
23173
23288
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -23238,7 +23353,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
23238
23353
|
});
|
|
23239
23354
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
23240
23355
|
imageGenerationItemSchema,
|
|
23241
|
-
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(
|
|
23356
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
|
|
23242
23357
|
external_exports.object({
|
|
23243
23358
|
id: boundedText(256),
|
|
23244
23359
|
text: boundedText(1e6),
|
|
@@ -25104,15 +25219,15 @@ var AgentProbeError = class extends Error {
|
|
|
25104
25219
|
};
|
|
25105
25220
|
|
|
25106
25221
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
25107
|
-
import { isAbsolute as
|
|
25222
|
+
import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
|
|
25108
25223
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
25109
25224
|
context.signal.throwIfAborted();
|
|
25110
25225
|
const platform = context.platform ?? process.platform;
|
|
25111
25226
|
const homeDirectory = context.environment["HOME"];
|
|
25112
|
-
if (platform === "win32" || homeDirectory === void 0 || !
|
|
25227
|
+
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
25113
25228
|
return [];
|
|
25114
25229
|
}
|
|
25115
|
-
const executable = await resolveExecutablePath(
|
|
25230
|
+
const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
|
|
25116
25231
|
context.signal.throwIfAborted();
|
|
25117
25232
|
return executable === null ? [] : [executable];
|
|
25118
25233
|
}
|
|
@@ -25201,8 +25316,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25201
25316
|
};
|
|
25202
25317
|
|
|
25203
25318
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
25204
|
-
import { mkdir as mkdir2, realpath as
|
|
25205
|
-
import { isAbsolute as
|
|
25319
|
+
import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
|
|
25320
|
+
import { isAbsolute as isAbsolute5, join as join8, normalize } from "node:path";
|
|
25206
25321
|
|
|
25207
25322
|
// src/agent-installation/deepseek-managed-package.ts
|
|
25208
25323
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -25220,13 +25335,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
25220
25335
|
|
|
25221
25336
|
// src/storage/state-directory.ts
|
|
25222
25337
|
import { homedir } from "node:os";
|
|
25223
|
-
import { join as
|
|
25338
|
+
import { join as join7, resolve as resolve2 } from "node:path";
|
|
25224
25339
|
function readStateDirectory(environment = process.env) {
|
|
25225
25340
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
25226
25341
|
if (configured !== void 0 && configured.length > 0) {
|
|
25227
25342
|
return resolve2(configured);
|
|
25228
25343
|
}
|
|
25229
|
-
return
|
|
25344
|
+
return join7(homedir(), ".mobius");
|
|
25230
25345
|
}
|
|
25231
25346
|
|
|
25232
25347
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
@@ -25237,20 +25352,20 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
|
|
|
25237
25352
|
model: deepseek-v4-flash-vision-exp
|
|
25238
25353
|
`;
|
|
25239
25354
|
async function prepareAgentHome(path2, imagePrompts) {
|
|
25240
|
-
if (!
|
|
25355
|
+
if (!isAbsolute5(path2) || normalize(path2) !== path2) {
|
|
25241
25356
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
25242
25357
|
}
|
|
25243
25358
|
try {
|
|
25244
25359
|
if (imagePrompts) {
|
|
25245
25360
|
await mkdir2(path2, { mode: 448, recursive: true });
|
|
25246
25361
|
}
|
|
25247
|
-
const resolved = await
|
|
25248
|
-
const metadata = await
|
|
25362
|
+
const resolved = await realpath4(path2);
|
|
25363
|
+
const metadata = await stat4(resolved);
|
|
25249
25364
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
25250
25365
|
throw new Error("Agent home is not a user-owned directory");
|
|
25251
25366
|
}
|
|
25252
25367
|
if (imagePrompts) {
|
|
25253
|
-
await writeFile(
|
|
25368
|
+
await writeFile(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
25254
25369
|
mode: 384
|
|
25255
25370
|
});
|
|
25256
25371
|
}
|
|
@@ -25298,7 +25413,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25298
25413
|
context.signal
|
|
25299
25414
|
);
|
|
25300
25415
|
if (managed.path === agent.path) {
|
|
25301
|
-
selectedHome =
|
|
25416
|
+
selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
25302
25417
|
managedHome = true;
|
|
25303
25418
|
}
|
|
25304
25419
|
} catch {
|
|
@@ -25314,7 +25429,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25314
25429
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
25315
25430
|
signal.throwIfAborted();
|
|
25316
25431
|
const executable = await validateManagedNpmPackage(
|
|
25317
|
-
|
|
25432
|
+
join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
25318
25433
|
DEEPSEEK_HARNESS_PACKAGE
|
|
25319
25434
|
);
|
|
25320
25435
|
signal.throwIfAborted();
|
|
@@ -25368,8 +25483,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25368
25483
|
};
|
|
25369
25484
|
|
|
25370
25485
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25371
|
-
import { realpath as
|
|
25372
|
-
import { isAbsolute as
|
|
25486
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
25487
|
+
import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
|
|
25373
25488
|
import {
|
|
25374
25489
|
RequestError
|
|
25375
25490
|
} from "@agentclientprotocol/sdk";
|
|
@@ -25392,50 +25507,25 @@ var GrokBuildManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
|
25392
25507
|
this.requiredDependencies = Object.freeze([requiredDependency]);
|
|
25393
25508
|
}
|
|
25394
25509
|
};
|
|
25395
|
-
var GROK_DARWIN_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25396
|
-
"@xai-official/grok-darwin-arm64",
|
|
25397
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25398
|
-
"sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
|
|
25399
|
-
"https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
|
|
25400
|
-
);
|
|
25401
|
-
var GROK_DARWIN_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25402
|
-
"@xai-official/grok-darwin-x64",
|
|
25403
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25404
|
-
"sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
|
|
25405
|
-
"https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
|
|
25406
|
-
);
|
|
25407
|
-
var GROK_LINUX_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25408
|
-
"@xai-official/grok-linux-arm64",
|
|
25409
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25410
|
-
"sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
|
|
25411
|
-
"https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
|
|
25412
|
-
);
|
|
25413
|
-
var GROK_LINUX_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25414
|
-
"@xai-official/grok-linux-x64",
|
|
25415
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25416
|
-
"sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
|
|
25417
|
-
"https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
|
|
25418
|
-
);
|
|
25419
25510
|
function grokBuildManagedPackage(platform, architecture) {
|
|
25420
|
-
|
|
25421
|
-
|
|
25422
|
-
|
|
25423
|
-
if (platform === "darwin" && architecture === "x64") {
|
|
25424
|
-
return new GrokBuildManagedPackage(GROK_DARWIN_X64_PACKAGE);
|
|
25425
|
-
}
|
|
25426
|
-
if (platform === "linux" && architecture === "arm64") {
|
|
25427
|
-
return new GrokBuildManagedPackage(GROK_LINUX_ARM64_PACKAGE);
|
|
25511
|
+
const release = platformSupportFor(platform).grokDependencies[architecture];
|
|
25512
|
+
if (release === void 0) {
|
|
25513
|
+
throw new Error("Grok Build does not publish a package for this platform");
|
|
25428
25514
|
}
|
|
25429
|
-
|
|
25430
|
-
|
|
25431
|
-
|
|
25432
|
-
|
|
25515
|
+
return new GrokBuildManagedPackage(
|
|
25516
|
+
new SriManagedNpmDependencyDefinition(
|
|
25517
|
+
release.name,
|
|
25518
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25519
|
+
release.integrity,
|
|
25520
|
+
release.tarballUrl
|
|
25521
|
+
)
|
|
25522
|
+
);
|
|
25433
25523
|
}
|
|
25434
25524
|
|
|
25435
25525
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25436
25526
|
function isContainedPath2(root, candidate) {
|
|
25437
25527
|
const difference = relative2(root, candidate);
|
|
25438
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !
|
|
25528
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
|
|
25439
25529
|
}
|
|
25440
25530
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
25441
25531
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -25464,8 +25554,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25464
25554
|
);
|
|
25465
25555
|
if (managed.path === agent.path) {
|
|
25466
25556
|
return Object.freeze({
|
|
25467
|
-
GROK_HOME: await
|
|
25468
|
-
|
|
25557
|
+
GROK_HOME: await realpath5(
|
|
25558
|
+
join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
25469
25559
|
)
|
|
25470
25560
|
});
|
|
25471
25561
|
}
|
|
@@ -25476,9 +25566,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25476
25566
|
};
|
|
25477
25567
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
25478
25568
|
signal.throwIfAborted();
|
|
25479
|
-
const versionRoot = await
|
|
25480
|
-
await validateManagedNpmPackage(
|
|
25481
|
-
const executable = await resolveExecutablePath(
|
|
25569
|
+
const versionRoot = await realpath5(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
25570
|
+
await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
25571
|
+
const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
|
|
25482
25572
|
signal.throwIfAborted();
|
|
25483
25573
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
25484
25574
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -25578,13 +25668,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25578
25668
|
};
|
|
25579
25669
|
|
|
25580
25670
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
25581
|
-
import { join as
|
|
25671
|
+
import { join as join11 } from "node:path";
|
|
25582
25672
|
|
|
25583
25673
|
// src/agent-installation/managed-agent-archive.ts
|
|
25584
25674
|
import { createHash } from "node:crypto";
|
|
25585
25675
|
import { createReadStream } from "node:fs";
|
|
25586
|
-
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as
|
|
25587
|
-
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as
|
|
25676
|
+
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat5, writeFile as writeFile2 } from "node:fs/promises";
|
|
25677
|
+
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
|
|
25588
25678
|
|
|
25589
25679
|
// src/agent-installation/verified-download.ts
|
|
25590
25680
|
import { fetch } from "undici";
|
|
@@ -25690,7 +25780,7 @@ function isRecord5(value) {
|
|
|
25690
25780
|
}
|
|
25691
25781
|
function isContainedPath3(root, candidate) {
|
|
25692
25782
|
const difference = relative3(root, candidate);
|
|
25693
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !
|
|
25783
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
|
|
25694
25784
|
}
|
|
25695
25785
|
async function hashFile(path2, signal) {
|
|
25696
25786
|
signal.throwIfAborted();
|
|
@@ -25764,16 +25854,16 @@ async function readManifest(path2) {
|
|
|
25764
25854
|
}
|
|
25765
25855
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
25766
25856
|
try {
|
|
25767
|
-
const rootPath = await
|
|
25768
|
-
const rootMetadata = await
|
|
25857
|
+
const rootPath = await realpath6(root);
|
|
25858
|
+
const rootMetadata = await stat5(rootPath);
|
|
25769
25859
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
25770
25860
|
throw new Error("Managed Agent root is not user-owned");
|
|
25771
25861
|
}
|
|
25772
|
-
const manifest = await readManifest(
|
|
25862
|
+
const manifest = await readManifest(join10(rootPath, "archive.json"));
|
|
25773
25863
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
25774
25864
|
throw new Error("Managed Agent archive identity is invalid");
|
|
25775
25865
|
}
|
|
25776
|
-
const executable = await resolveExecutablePath(
|
|
25866
|
+
const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
|
|
25777
25867
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
25778
25868
|
throw new Error("Managed Agent executable is invalid");
|
|
25779
25869
|
}
|
|
@@ -25799,47 +25889,21 @@ function releaseUrl(asset) {
|
|
|
25799
25889
|
return new URL(`https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_MANAGED_VERSION}/${asset}`);
|
|
25800
25890
|
}
|
|
25801
25891
|
function openCodeManagedArchive(platform, architecture) {
|
|
25802
|
-
|
|
25803
|
-
|
|
25804
|
-
|
|
25805
|
-
|
|
25806
|
-
|
|
25807
|
-
|
|
25808
|
-
|
|
25809
|
-
|
|
25810
|
-
|
|
25811
|
-
|
|
25812
|
-
|
|
25813
|
-
|
|
25814
|
-
|
|
25815
|
-
|
|
25816
|
-
|
|
25817
|
-
releaseUrl(asset),
|
|
25818
|
-
"9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
|
|
25819
|
-
"opencode"
|
|
25820
|
-
);
|
|
25821
|
-
}
|
|
25822
|
-
if (platform === "linux" && architecture === "arm64") {
|
|
25823
|
-
const asset = "opencode-linux-arm64.tar.gz";
|
|
25824
|
-
return new TarGzipManagedAgentArchiveDefinition(
|
|
25825
|
-
OPENCODE_MANAGED_VERSION,
|
|
25826
|
-
asset,
|
|
25827
|
-
releaseUrl(asset),
|
|
25828
|
-
"70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
|
|
25829
|
-
"opencode"
|
|
25830
|
-
);
|
|
25831
|
-
}
|
|
25832
|
-
if (platform === "linux" && architecture === "x64") {
|
|
25833
|
-
const asset = "opencode-linux-x64.tar.gz";
|
|
25834
|
-
return new TarGzipManagedAgentArchiveDefinition(
|
|
25835
|
-
OPENCODE_MANAGED_VERSION,
|
|
25836
|
-
asset,
|
|
25837
|
-
releaseUrl(asset),
|
|
25838
|
-
"ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
|
|
25839
|
-
"opencode"
|
|
25840
|
-
);
|
|
25841
|
-
}
|
|
25842
|
-
throw new Error("OpenCode does not publish an approved archive for this platform");
|
|
25892
|
+
const release = platformSupportFor(platform).openCodeArchives[architecture];
|
|
25893
|
+
if (release === void 0) {
|
|
25894
|
+
throw new Error("OpenCode does not publish an approved archive for this platform");
|
|
25895
|
+
}
|
|
25896
|
+
const Definition = {
|
|
25897
|
+
zip: ZipManagedAgentArchiveDefinition,
|
|
25898
|
+
"tar.gz": TarGzipManagedAgentArchiveDefinition
|
|
25899
|
+
}[release.format];
|
|
25900
|
+
return new Definition(
|
|
25901
|
+
OPENCODE_MANAGED_VERSION,
|
|
25902
|
+
release.asset,
|
|
25903
|
+
releaseUrl(release.asset),
|
|
25904
|
+
release.sha256,
|
|
25905
|
+
"opencode"
|
|
25906
|
+
);
|
|
25843
25907
|
}
|
|
25844
25908
|
|
|
25845
25909
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
@@ -25965,7 +26029,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25965
26029
|
return Object.freeze(environment);
|
|
25966
26030
|
};
|
|
25967
26031
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
25968
|
-
|
|
26032
|
+
join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
25969
26033
|
openCodeManagedArchive(platform, process.arch),
|
|
25970
26034
|
signal
|
|
25971
26035
|
);
|
|
@@ -25983,7 +26047,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25983
26047
|
};
|
|
25984
26048
|
|
|
25985
26049
|
// src/agent-catalog/agents/pi-agent.ts
|
|
25986
|
-
import { join as
|
|
26050
|
+
import { join as join12 } from "node:path";
|
|
25987
26051
|
import {
|
|
25988
26052
|
methods as methods4
|
|
25989
26053
|
} from "@agentclientprotocol/sdk";
|
|
@@ -26042,7 +26106,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26042
26106
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26043
26107
|
signal.throwIfAborted();
|
|
26044
26108
|
const executable = await validateManagedNpmPackage(
|
|
26045
|
-
|
|
26109
|
+
join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
26046
26110
|
PI_AGENT_PACKAGE
|
|
26047
26111
|
);
|
|
26048
26112
|
signal.throwIfAborted();
|
|
@@ -26080,7 +26144,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26080
26144
|
};
|
|
26081
26145
|
|
|
26082
26146
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26083
|
-
import {
|
|
26147
|
+
import { join as join13 } from "node:path";
|
|
26084
26148
|
|
|
26085
26149
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
26086
26150
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -26098,15 +26162,6 @@ var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
|
|
|
26098
26162
|
);
|
|
26099
26163
|
|
|
26100
26164
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26101
|
-
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
26102
|
-
"WorkBuddy.app",
|
|
26103
|
-
"Contents",
|
|
26104
|
-
"Resources",
|
|
26105
|
-
"app.asar.unpacked",
|
|
26106
|
-
"cli",
|
|
26107
|
-
"bin",
|
|
26108
|
-
"codebuddy"
|
|
26109
|
-
]);
|
|
26110
26165
|
var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26111
26166
|
adapterVersion = WORKBUDDY_MANAGED_VERSION;
|
|
26112
26167
|
authenticationCommand = () => "codebuddy";
|
|
@@ -26135,7 +26190,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26135
26190
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26136
26191
|
signal.throwIfAborted();
|
|
26137
26192
|
const executable = await validateManagedNpmPackage(
|
|
26138
|
-
|
|
26193
|
+
join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
26139
26194
|
WORKBUDDY_MANAGED_PACKAGE
|
|
26140
26195
|
);
|
|
26141
26196
|
signal.throwIfAborted();
|
|
@@ -26143,17 +26198,11 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26143
26198
|
};
|
|
26144
26199
|
resolveInstalledAgentExecutables = async (context) => {
|
|
26145
26200
|
context.signal.throwIfAborted();
|
|
26146
|
-
|
|
26147
|
-
|
|
26148
|
-
}
|
|
26149
|
-
const requestedPaths = [join11("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
26150
|
-
const homeDirectory = context.environment["HOME"];
|
|
26151
|
-
if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
|
|
26152
|
-
requestedPaths.unshift(join11(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
26153
|
-
}
|
|
26201
|
+
const platform = context.platform ?? process.platform;
|
|
26202
|
+
const requestedPaths = platformSupportFor(platform).workBuddyExecutablePaths(context.environment);
|
|
26154
26203
|
const executables = [];
|
|
26155
26204
|
for (const requestedPath2 of requestedPaths) {
|
|
26156
|
-
const executable = await resolveExecutablePath(requestedPath2,
|
|
26205
|
+
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
26157
26206
|
context.signal.throwIfAborted();
|
|
26158
26207
|
if (executable !== null) {
|
|
26159
26208
|
executables.push(executable);
|
|
@@ -26513,10 +26562,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
26513
26562
|
}
|
|
26514
26563
|
|
|
26515
26564
|
// src/agent-catalog/executable-discovery.ts
|
|
26516
|
-
import { isAbsolute as isAbsolute8, join as
|
|
26565
|
+
import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
|
|
26517
26566
|
|
|
26518
26567
|
// src/agent-installation/managed-adapter-installer.ts
|
|
26519
|
-
import { join as
|
|
26568
|
+
import { join as join14 } from "node:path";
|
|
26520
26569
|
var ManagedAdapterInstallError = class extends Error {
|
|
26521
26570
|
code;
|
|
26522
26571
|
constructor(code, message, options = {}) {
|
|
@@ -26573,7 +26622,7 @@ var ManagedAdapterInstaller = class {
|
|
|
26573
26622
|
this.#stateDirectory = options.stateDirectory;
|
|
26574
26623
|
}
|
|
26575
26624
|
install = async (specification, signal) => {
|
|
26576
|
-
const root =
|
|
26625
|
+
const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
26577
26626
|
try {
|
|
26578
26627
|
return await this.#npmInstaller.install(
|
|
26579
26628
|
root,
|
|
@@ -26607,7 +26656,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
26607
26656
|
let managed;
|
|
26608
26657
|
try {
|
|
26609
26658
|
managed = await validateManagedAdapter(
|
|
26610
|
-
|
|
26659
|
+
join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
26611
26660
|
specification
|
|
26612
26661
|
);
|
|
26613
26662
|
} catch {
|
|
@@ -26920,28 +26969,122 @@ async function discoverLocalAgentInventory(options) {
|
|
|
26920
26969
|
return new LocalAgentInventory(results);
|
|
26921
26970
|
}
|
|
26922
26971
|
|
|
26923
|
-
// src/
|
|
26924
|
-
|
|
26925
|
-
|
|
26926
|
-
|
|
26927
|
-
|
|
26928
|
-
|
|
26929
|
-
|
|
26972
|
+
// src/agent-catalog/publish-agent-catalog.ts
|
|
26973
|
+
import { fetch as fetch2 } from "undici";
|
|
26974
|
+
|
|
26975
|
+
// src/relay-connection/runtime-authentication.ts
|
|
26976
|
+
function runtimeCredential(relayUrl) {
|
|
26977
|
+
return relayUrl.searchParams.get("token") ?? "";
|
|
26978
|
+
}
|
|
26979
|
+
function runtimeAuthorization(relayUrl) {
|
|
26980
|
+
const credential = runtimeCredential(relayUrl);
|
|
26981
|
+
return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
|
|
26982
|
+
}
|
|
26983
|
+
function relayHttpEndpoint(relayUrl) {
|
|
26984
|
+
const endpoint = new URL(relayUrl);
|
|
26985
|
+
endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
|
|
26986
|
+
endpoint.search = "";
|
|
26987
|
+
return endpoint;
|
|
26988
|
+
}
|
|
26989
|
+
|
|
26990
|
+
// src/agent-catalog/publish-agent-catalog.ts
|
|
26991
|
+
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
26992
|
+
var AgentCatalogPublishError = class extends Error {
|
|
26993
|
+
code = "agent_catalog_update_failed";
|
|
26994
|
+
diagnosticDetails;
|
|
26995
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
26996
|
+
super(message, options);
|
|
26997
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
26998
|
+
this.name = "AgentCatalogPublishError";
|
|
26999
|
+
}
|
|
27000
|
+
};
|
|
27001
|
+
function isRecord6(value) {
|
|
27002
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27003
|
+
}
|
|
27004
|
+
function isSafeRelayErrorMessage(value) {
|
|
27005
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
27006
|
+
}
|
|
27007
|
+
async function rejectedCatalogError(response) {
|
|
27008
|
+
let value;
|
|
27009
|
+
try {
|
|
27010
|
+
value = await response.json();
|
|
27011
|
+
} catch {
|
|
27012
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27013
|
+
}
|
|
27014
|
+
if (!isRecord6(value) || !isRecord6(value["error"])) {
|
|
27015
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27016
|
+
}
|
|
27017
|
+
const code = value["error"]["code"];
|
|
27018
|
+
const message = value["error"]["message"];
|
|
27019
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
27020
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27021
|
+
}
|
|
27022
|
+
return new AgentCatalogPublishError(
|
|
27023
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
27024
|
+
{},
|
|
27025
|
+
{
|
|
27026
|
+
relayErrorCode: code
|
|
26930
27027
|
}
|
|
26931
|
-
|
|
26932
|
-
|
|
27028
|
+
);
|
|
27029
|
+
}
|
|
27030
|
+
function catalogEndpoint(config2) {
|
|
27031
|
+
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
27032
|
+
if (endpoint.pathname.endsWith("/daemon")) {
|
|
27033
|
+
endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
|
|
27034
|
+
return endpoint;
|
|
27035
|
+
}
|
|
27036
|
+
const runtimePath = "/v1/runtimes/connect";
|
|
27037
|
+
if (endpoint.pathname.endsWith(runtimePath)) {
|
|
27038
|
+
endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
|
|
27039
|
+
return endpoint;
|
|
27040
|
+
}
|
|
27041
|
+
throw new AgentCatalogPublishError("The Relay URL is invalid");
|
|
27042
|
+
}
|
|
27043
|
+
async function publishAgentCatalog(config2, signal) {
|
|
27044
|
+
signal.throwIfAborted();
|
|
27045
|
+
const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
|
|
27046
|
+
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
27047
|
+
let response;
|
|
27048
|
+
const catalog = config2.catalog.read();
|
|
27049
|
+
try {
|
|
27050
|
+
response = await fetch2(catalogEndpoint(config2), {
|
|
27051
|
+
body: JSON.stringify({
|
|
27052
|
+
agents: catalog.agents.map((agent) => ({
|
|
27053
|
+
agentPath: agent.agentIdentity.requestedPath,
|
|
27054
|
+
agentVersion: agent.agentVersion,
|
|
27055
|
+
agentSettingsDiscovery: true,
|
|
27056
|
+
capabilities: agent.capabilities,
|
|
27057
|
+
id: agent.id,
|
|
27058
|
+
label: agent.label,
|
|
27059
|
+
sessionTurnConfiguration: true
|
|
27060
|
+
})),
|
|
27061
|
+
installableAgents: catalog.installableAgents
|
|
27062
|
+
}),
|
|
27063
|
+
dispatcher: environmentProxyDispatcher,
|
|
27064
|
+
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
27065
|
+
method: "PUT",
|
|
27066
|
+
signal: requestSignal
|
|
27067
|
+
});
|
|
27068
|
+
} catch (error62) {
|
|
27069
|
+
if (signal.aborted) {
|
|
27070
|
+
signal.throwIfAborted();
|
|
27071
|
+
}
|
|
27072
|
+
throw new AgentCatalogPublishError(
|
|
27073
|
+
timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
|
|
27074
|
+
{ cause: error62 }
|
|
26933
27075
|
);
|
|
26934
|
-
}
|
|
26935
|
-
|
|
26936
|
-
|
|
26937
|
-
}
|
|
26938
|
-
|
|
27076
|
+
}
|
|
27077
|
+
if (!response.ok) {
|
|
27078
|
+
throw await rejectedCatalogError(response);
|
|
27079
|
+
}
|
|
27080
|
+
await response.body?.cancel();
|
|
27081
|
+
}
|
|
26939
27082
|
|
|
26940
27083
|
// src/config.ts
|
|
26941
|
-
import { join as
|
|
27084
|
+
import { join as join16, resolve as resolve3 } from "node:path";
|
|
26942
27085
|
function loadDefaultWorkspace(environment = process.env) {
|
|
26943
27086
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
26944
|
-
return configuredWorkspace ??
|
|
27087
|
+
return configuredWorkspace ?? join16(readStateDirectory(environment), "workspace");
|
|
26945
27088
|
}
|
|
26946
27089
|
var DaemonLocalContext = class {
|
|
26947
27090
|
environment;
|
|
@@ -26971,7 +27114,7 @@ var OpaqueDaemonReconnectTarget = class extends DaemonReconnectTarget {
|
|
|
26971
27114
|
this.commandArgument = `--connection ${connectionId2}`;
|
|
26972
27115
|
}
|
|
26973
27116
|
};
|
|
26974
|
-
function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null) {
|
|
27117
|
+
function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
|
|
26975
27118
|
const daemonAgents = agents.map((agent) => withDaemonEnvironment(agent, localContext.environment));
|
|
26976
27119
|
return {
|
|
26977
27120
|
agents: daemonAgents,
|
|
@@ -26982,13 +27125,86 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
26982
27125
|
installableAgents,
|
|
26983
27126
|
localContext,
|
|
26984
27127
|
reconnectTarget,
|
|
26985
|
-
relayUrl: connection.relayUrl
|
|
27128
|
+
relayUrl: connection.relayUrl,
|
|
27129
|
+
...resolveAgent === void 0 ? {} : { resolveAgent }
|
|
26986
27130
|
};
|
|
26987
27131
|
}
|
|
26988
27132
|
|
|
27133
|
+
// src/agent-catalog/resolve-catalog-agent.ts
|
|
27134
|
+
function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
27135
|
+
const swaps = /* @__PURE__ */ new Map();
|
|
27136
|
+
return async (agent, signal) => {
|
|
27137
|
+
const config2 = readConfig();
|
|
27138
|
+
const pending = swaps.get(agent.id);
|
|
27139
|
+
if (pending !== void 0) {
|
|
27140
|
+
await pending;
|
|
27141
|
+
return config2.catalog.find(agent.id);
|
|
27142
|
+
}
|
|
27143
|
+
let release = () => void 0;
|
|
27144
|
+
const gate = new Promise((resolveGate) => {
|
|
27145
|
+
release = resolveGate;
|
|
27146
|
+
});
|
|
27147
|
+
swaps.set(agent.id, gate);
|
|
27148
|
+
try {
|
|
27149
|
+
if (await unchangedIdentity(agent, signal)) {
|
|
27150
|
+
return agent;
|
|
27151
|
+
}
|
|
27152
|
+
signal.throwIfAborted();
|
|
27153
|
+
const inventory = await discover(signal);
|
|
27154
|
+
signal.throwIfAborted();
|
|
27155
|
+
const previous = config2.catalog.read();
|
|
27156
|
+
const previousAgent = previous.agents.find((entry) => entry.id === agent.id);
|
|
27157
|
+
if (previousAgent === void 0) {
|
|
27158
|
+
throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
|
|
27159
|
+
}
|
|
27160
|
+
config2.catalog.transition(
|
|
27161
|
+
[
|
|
27162
|
+
...previous.agents.filter((entry) => entry.id !== agent.id),
|
|
27163
|
+
...inventory.readyAgents().map((ready) => withDaemonEnvironment(ready, config2.localContext.environment))
|
|
27164
|
+
],
|
|
27165
|
+
[...previous.installableAgents.filter((entry) => entry.id !== agent.id), ...inventory.installable]
|
|
27166
|
+
);
|
|
27167
|
+
try {
|
|
27168
|
+
await publish(config2, signal);
|
|
27169
|
+
} catch (error62) {
|
|
27170
|
+
config2.catalog.transition(previous.agents, previous.installableAgents);
|
|
27171
|
+
throw error62;
|
|
27172
|
+
}
|
|
27173
|
+
return config2.catalog.find(agent.id);
|
|
27174
|
+
} finally {
|
|
27175
|
+
swaps.delete(agent.id);
|
|
27176
|
+
release();
|
|
27177
|
+
}
|
|
27178
|
+
};
|
|
27179
|
+
}
|
|
27180
|
+
async function unchangedIdentity(agent, signal) {
|
|
27181
|
+
if (!await revalidateExecutable(agent.agentIdentity)) {
|
|
27182
|
+
return false;
|
|
27183
|
+
}
|
|
27184
|
+
signal.throwIfAborted();
|
|
27185
|
+
return agent.kind !== "acp-adapter-process" || await revalidateExecutable(agent.adapterIdentity);
|
|
27186
|
+
}
|
|
27187
|
+
|
|
27188
|
+
// src/audit/audit-store.ts
|
|
27189
|
+
var MAX_AUDIT_RECORDS = 1024;
|
|
27190
|
+
var AuditStore = class {
|
|
27191
|
+
#records = [];
|
|
27192
|
+
record = (record2) => {
|
|
27193
|
+
if (this.#records.length === MAX_AUDIT_RECORDS) {
|
|
27194
|
+
this.#records.shift();
|
|
27195
|
+
}
|
|
27196
|
+
this.#records.push(
|
|
27197
|
+
record2.details === void 0 ? { ...record2 } : { ...record2, details: { ...record2.details } }
|
|
27198
|
+
);
|
|
27199
|
+
};
|
|
27200
|
+
close = () => {
|
|
27201
|
+
this.#records.length = 0;
|
|
27202
|
+
};
|
|
27203
|
+
};
|
|
27204
|
+
|
|
26989
27205
|
// src/run-daemon.ts
|
|
26990
27206
|
import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
|
|
26991
|
-
import { join as
|
|
27207
|
+
import { join as join20 } from "node:path";
|
|
26992
27208
|
import { styleText } from "node:util";
|
|
26993
27209
|
|
|
26994
27210
|
// src/acp/active-executions.ts
|
|
@@ -27079,7 +27295,7 @@ import {
|
|
|
27079
27295
|
} from "@agentclientprotocol/sdk";
|
|
27080
27296
|
|
|
27081
27297
|
// src/authorization/local-raster.ts
|
|
27082
|
-
import { open as open4, readFile as readFile2, realpath as
|
|
27298
|
+
import { open as open4, readFile as readFile2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
27083
27299
|
import { basename, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
27084
27300
|
import { fileURLToPath } from "node:url";
|
|
27085
27301
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -27150,7 +27366,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
27150
27366
|
return null;
|
|
27151
27367
|
}
|
|
27152
27368
|
try {
|
|
27153
|
-
const target = await
|
|
27369
|
+
const target = await realpath7(requested);
|
|
27154
27370
|
signal.throwIfAborted();
|
|
27155
27371
|
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
27156
27372
|
return null;
|
|
@@ -27198,7 +27414,7 @@ async function readLocalRaster(uri, signal) {
|
|
|
27198
27414
|
if (target === null) {
|
|
27199
27415
|
return null;
|
|
27200
27416
|
}
|
|
27201
|
-
const targetMetadata = await
|
|
27417
|
+
const targetMetadata = await stat6(target);
|
|
27202
27418
|
signal.throwIfAborted();
|
|
27203
27419
|
if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
|
|
27204
27420
|
return null;
|
|
@@ -27377,7 +27593,7 @@ async function replaceImageMarkers(text2, replace) {
|
|
|
27377
27593
|
|
|
27378
27594
|
// src/acp/activity-content.ts
|
|
27379
27595
|
var TRUNCATION_MARKER = "\n\u2026 output truncated by Mobius";
|
|
27380
|
-
function
|
|
27596
|
+
function isRecord7(value) {
|
|
27381
27597
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27382
27598
|
}
|
|
27383
27599
|
function truncate3(value, maximumLength) {
|
|
@@ -27561,16 +27777,16 @@ async function normalizeToolContent(content, prepareContent) {
|
|
|
27561
27777
|
return normalized;
|
|
27562
27778
|
}
|
|
27563
27779
|
function rawMcpToolContent(rawOutput) {
|
|
27564
|
-
if (!
|
|
27780
|
+
if (!isRecord7(rawOutput)) {
|
|
27565
27781
|
return [];
|
|
27566
27782
|
}
|
|
27567
|
-
const result =
|
|
27783
|
+
const result = isRecord7(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
|
|
27568
27784
|
const content = result["content"];
|
|
27569
27785
|
if (!Array.isArray(content)) {
|
|
27570
27786
|
return [];
|
|
27571
27787
|
}
|
|
27572
27788
|
return content.flatMap((item) => {
|
|
27573
|
-
if (!
|
|
27789
|
+
if (!isRecord7(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
|
|
27574
27790
|
return [];
|
|
27575
27791
|
}
|
|
27576
27792
|
const uri = item["uri"];
|
|
@@ -27647,7 +27863,7 @@ function contentPhase(content) {
|
|
|
27647
27863
|
return "";
|
|
27648
27864
|
}
|
|
27649
27865
|
const codex = metadata["codex"];
|
|
27650
|
-
if (!
|
|
27866
|
+
if (!isRecord7(codex)) {
|
|
27651
27867
|
return "";
|
|
27652
27868
|
}
|
|
27653
27869
|
const phase = codex["phase"];
|
|
@@ -28354,7 +28570,7 @@ var SessionConfigProtocolError = class extends Error {
|
|
|
28354
28570
|
this.name = "SessionConfigProtocolError";
|
|
28355
28571
|
}
|
|
28356
28572
|
};
|
|
28357
|
-
function
|
|
28573
|
+
function isRecord8(value) {
|
|
28358
28574
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28359
28575
|
}
|
|
28360
28576
|
function readString3(value, fallback = "") {
|
|
@@ -28385,7 +28601,7 @@ function normalizeConfigValues(value) {
|
|
|
28385
28601
|
}
|
|
28386
28602
|
const normalized = [];
|
|
28387
28603
|
for (const entry of value) {
|
|
28388
|
-
if (!
|
|
28604
|
+
if (!isRecord8(entry)) {
|
|
28389
28605
|
continue;
|
|
28390
28606
|
}
|
|
28391
28607
|
const groupedOptions = entry["options"];
|
|
@@ -28393,7 +28609,7 @@ function normalizeConfigValues(value) {
|
|
|
28393
28609
|
const groupId = readString3(entry["group"]);
|
|
28394
28610
|
const groupName = readString3(entry["name"]);
|
|
28395
28611
|
for (const groupedOption of groupedOptions) {
|
|
28396
|
-
if (
|
|
28612
|
+
if (isRecord8(groupedOption)) {
|
|
28397
28613
|
const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
|
|
28398
28614
|
if (normalizedValue !== void 0) {
|
|
28399
28615
|
normalized.push(normalizedValue);
|
|
@@ -28413,7 +28629,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28413
28629
|
const normalized = [];
|
|
28414
28630
|
if (Array.isArray(value)) {
|
|
28415
28631
|
for (const option of value) {
|
|
28416
|
-
if (!
|
|
28632
|
+
if (!isRecord8(option)) {
|
|
28417
28633
|
continue;
|
|
28418
28634
|
}
|
|
28419
28635
|
const id = truncate4(readString3(option["id"]), 128);
|
|
@@ -28453,12 +28669,12 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28453
28669
|
}
|
|
28454
28670
|
}
|
|
28455
28671
|
}
|
|
28456
|
-
if (
|
|
28672
|
+
if (isRecord8(modes)) {
|
|
28457
28673
|
const values = [];
|
|
28458
28674
|
const availableModes = modes["availableModes"];
|
|
28459
28675
|
if (Array.isArray(availableModes)) {
|
|
28460
28676
|
for (const mode of availableModes) {
|
|
28461
|
-
if (!
|
|
28677
|
+
if (!isRecord8(mode)) {
|
|
28462
28678
|
continue;
|
|
28463
28679
|
}
|
|
28464
28680
|
const id = truncate4(readString3(mode["id"]), 500);
|
|
@@ -28491,7 +28707,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28491
28707
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
28492
28708
|
}
|
|
28493
28709
|
function normalizeStandardLifecycle(response) {
|
|
28494
|
-
const lifecycle =
|
|
28710
|
+
const lifecycle = isRecord8(response) ? response : {};
|
|
28495
28711
|
return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
|
|
28496
28712
|
}
|
|
28497
28713
|
function replaceStandardConfigOptions(current, value) {
|
|
@@ -28533,7 +28749,7 @@ var StandardSessionConfigProtocol = class {
|
|
|
28533
28749
|
"ACP agent exited while changing session configuration",
|
|
28534
28750
|
change.signal
|
|
28535
28751
|
);
|
|
28536
|
-
if (!
|
|
28752
|
+
if (!isRecord8(response) || !Array.isArray(response["configOptions"])) {
|
|
28537
28753
|
throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
|
|
28538
28754
|
}
|
|
28539
28755
|
return replaceStandardConfigOptions(current, response["configOptions"]);
|
|
@@ -29946,7 +30162,7 @@ function sql(strings, ...params) {
|
|
|
29946
30162
|
return new SQL([new StringChunk(str)]);
|
|
29947
30163
|
}
|
|
29948
30164
|
_sql.raw = raw;
|
|
29949
|
-
function
|
|
30165
|
+
function join22(chunks, separator) {
|
|
29950
30166
|
const result = [];
|
|
29951
30167
|
for (const [i, chunk] of chunks.entries()) {
|
|
29952
30168
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -29954,7 +30170,7 @@ function sql(strings, ...params) {
|
|
|
29954
30170
|
}
|
|
29955
30171
|
return new SQL(result);
|
|
29956
30172
|
}
|
|
29957
|
-
_sql.join =
|
|
30173
|
+
_sql.join = join22;
|
|
29958
30174
|
function identifier2(value) {
|
|
29959
30175
|
return new Name(value);
|
|
29960
30176
|
}
|
|
@@ -32099,7 +32315,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
32099
32315
|
const baseTableName = this.tableName;
|
|
32100
32316
|
const tableName = getTableLikeName(table);
|
|
32101
32317
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
32102
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
32318
|
+
if (typeof tableName === "string" && this.config.joins?.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
32103
32319
|
if (!this.isPartialSelect) {
|
|
32104
32320
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
32105
32321
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -32938,7 +33154,7 @@ var SQLiteDialect = class {
|
|
|
32938
33154
|
if (!joins2) return;
|
|
32939
33155
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
32940
33156
|
if (!withEntries.length) return;
|
|
32941
|
-
return sql.join(withEntries.map(([k,
|
|
33157
|
+
return sql.join(withEntries.map(([k, join22]) => {
|
|
32942
33158
|
const relation = tableConfig.relations[k];
|
|
32943
33159
|
const isSingle2 = is(relation, One);
|
|
32944
33160
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -32949,7 +33165,7 @@ var SQLiteDialect = class {
|
|
|
32949
33165
|
table: targetTable,
|
|
32950
33166
|
mode: isSingle2 ? "first" : "many",
|
|
32951
33167
|
schema,
|
|
32952
|
-
queryConfig:
|
|
33168
|
+
queryConfig: join22,
|
|
32953
33169
|
tableConfig: schema[relation.targetTableName],
|
|
32954
33170
|
relationWhere: filter,
|
|
32955
33171
|
isNested: true,
|
|
@@ -32963,7 +33179,7 @@ var SQLiteDialect = class {
|
|
|
32963
33179
|
key: k,
|
|
32964
33180
|
selection: innerQuery.selection,
|
|
32965
33181
|
isArray: !isSingle2,
|
|
32966
|
-
isOptional: (relation.optional ?? false) ||
|
|
33182
|
+
isOptional: (relation.optional ?? false) || join22 !== true && !!join22.where
|
|
32967
33183
|
});
|
|
32968
33184
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
32969
33185
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -33579,7 +33795,7 @@ var SQLiteUpdateBase = class {
|
|
|
33579
33795
|
createJoin(joinType) {
|
|
33580
33796
|
return ((table, on) => {
|
|
33581
33797
|
const tableName = getTableLikeName(table);
|
|
33582
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
33798
|
+
if (typeof tableName === "string" && this.config.joins.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
33583
33799
|
if (typeof on === "function") {
|
|
33584
33800
|
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;
|
|
33585
33801
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -34985,7 +35201,7 @@ var AgentSession = class _AgentSession {
|
|
|
34985
35201
|
);
|
|
34986
35202
|
}
|
|
34987
35203
|
initialize = async (signal, recovery, origin) => {
|
|
34988
|
-
if (origin
|
|
35204
|
+
if (origin !== void 0) {
|
|
34989
35205
|
this.#sessionTitle = origin.title;
|
|
34990
35206
|
}
|
|
34991
35207
|
await this.#initializeAgent(signal);
|
|
@@ -34999,7 +35215,7 @@ var AgentSession = class _AgentSession {
|
|
|
34999
35215
|
this.#cwd,
|
|
35000
35216
|
this.#additionalDirectories,
|
|
35001
35217
|
true,
|
|
35002
|
-
|
|
35218
|
+
origin.title
|
|
35003
35219
|
)
|
|
35004
35220
|
) : this.#store.read(this.#mobiusSessionId)
|
|
35005
35221
|
);
|
|
@@ -36027,7 +36243,7 @@ var toolImageSchema = external_exports.union([
|
|
|
36027
36243
|
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
36028
36244
|
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
36029
36245
|
]);
|
|
36030
|
-
function
|
|
36246
|
+
function isRecord9(value) {
|
|
36031
36247
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36032
36248
|
}
|
|
36033
36249
|
var AcpContentExternalizer = class {
|
|
@@ -36143,13 +36359,13 @@ var AcpContentExternalizer = class {
|
|
|
36143
36359
|
}
|
|
36144
36360
|
return result2;
|
|
36145
36361
|
}
|
|
36146
|
-
if (!
|
|
36362
|
+
if (!isRecord9(value)) {
|
|
36147
36363
|
return value;
|
|
36148
36364
|
}
|
|
36149
36365
|
const image = toolImageSchema.safeParse(value);
|
|
36150
36366
|
if (image.success && image.data.data.length > 0) {
|
|
36151
36367
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
36152
|
-
if (
|
|
36368
|
+
if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
36153
36369
|
images.set(prepared.event["imageKey"], prepared);
|
|
36154
36370
|
} else {
|
|
36155
36371
|
images.set(`unavailable:${images.size}`, prepared);
|
|
@@ -36180,7 +36396,7 @@ var AcpContentExternalizer = class {
|
|
|
36180
36396
|
const prepared = await this.#content(sessionId, content, signal);
|
|
36181
36397
|
agentContent.push({ ...item, content: prepared.agent });
|
|
36182
36398
|
eventContent.push({ ...item, content: prepared.event });
|
|
36183
|
-
if (
|
|
36399
|
+
if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
36184
36400
|
images.delete(prepared.event["imageKey"]);
|
|
36185
36401
|
}
|
|
36186
36402
|
}
|
|
@@ -36238,8 +36454,8 @@ var AcpContentExternalizer = class {
|
|
|
36238
36454
|
|
|
36239
36455
|
// src/external-content/local-external-content-store.ts
|
|
36240
36456
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
36241
|
-
import { lstat, mkdir as mkdir4, readdir as readdir2, realpath as
|
|
36242
|
-
import { dirname as dirname3, join as
|
|
36457
|
+
import { lstat, mkdir as mkdir4, readdir as readdir2, realpath as realpath8, rename as rename3, rm as rm3, stat as stat7, utimes, writeFile as writeFile3 } from "node:fs/promises";
|
|
36458
|
+
import { dirname as dirname3, join as join17 } from "node:path";
|
|
36243
36459
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
36244
36460
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
36245
36461
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -36275,7 +36491,7 @@ var LocalExternalContentStore = class {
|
|
|
36275
36491
|
#expirationTimer;
|
|
36276
36492
|
#cleanup = Promise.resolve();
|
|
36277
36493
|
constructor(stateDirectory) {
|
|
36278
|
-
this.#root =
|
|
36494
|
+
this.#root = join17(stateDirectory, "tmp", "session-content", randomUUID2());
|
|
36279
36495
|
this.#expirationTimer = setInterval(() => {
|
|
36280
36496
|
void this.#expire().catch(() => void 0);
|
|
36281
36497
|
}, 6e4);
|
|
@@ -36290,11 +36506,11 @@ var LocalExternalContentStore = class {
|
|
|
36290
36506
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
36291
36507
|
continue;
|
|
36292
36508
|
}
|
|
36293
|
-
const path2 =
|
|
36509
|
+
const path2 = join17(dirname3(this.#root), directory.name);
|
|
36294
36510
|
if (path2 === this.#root) {
|
|
36295
36511
|
continue;
|
|
36296
36512
|
}
|
|
36297
|
-
const modified = await
|
|
36513
|
+
const modified = await stat7(path2).then(
|
|
36298
36514
|
(entry) => entry.mtimeMs,
|
|
36299
36515
|
() => Date.now()
|
|
36300
36516
|
);
|
|
@@ -36340,10 +36556,10 @@ var LocalExternalContentStore = class {
|
|
|
36340
36556
|
}
|
|
36341
36557
|
await this.#expire();
|
|
36342
36558
|
active.throwIfAborted();
|
|
36343
|
-
const directory =
|
|
36559
|
+
const directory = join17(this.#root, kind);
|
|
36344
36560
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
36345
36561
|
active.throwIfAborted();
|
|
36346
|
-
const path2 =
|
|
36562
|
+
const path2 = join17(directory, key);
|
|
36347
36563
|
const write = atomicWrite(path2, bytes, active);
|
|
36348
36564
|
await write;
|
|
36349
36565
|
active.throwIfAborted();
|
|
@@ -36376,8 +36592,8 @@ var LocalExternalContentStore = class {
|
|
|
36376
36592
|
}
|
|
36377
36593
|
try {
|
|
36378
36594
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
36379
|
-
|
|
36380
|
-
|
|
36595
|
+
realpath8(dirname3(entry.path)),
|
|
36596
|
+
realpath8(entry.path),
|
|
36381
36597
|
lstat(entry.path)
|
|
36382
36598
|
]);
|
|
36383
36599
|
signal.throwIfAborted();
|
|
@@ -36815,7 +37031,7 @@ var AgentRuntimeManager = class {
|
|
|
36815
37031
|
return await this.#startRetainedSessionProcess(
|
|
36816
37032
|
options,
|
|
36817
37033
|
async () => await AgentSession.start(
|
|
36818
|
-
options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId } } : options,
|
|
37034
|
+
options.origin === void 0 && this.#sessionIdentity === "native" && isNativeChatSessionId(options.agent.id, options.sessionId) && this.#store.read(options.sessionId) instanceof MissingAcpStoredSession ? { ...options, origin: { kind: "import", nativeSessionId: options.sessionId, title: "" } } : options,
|
|
36819
37035
|
recovery,
|
|
36820
37036
|
() => this.#observer,
|
|
36821
37037
|
this.#store,
|
|
@@ -37418,117 +37634,6 @@ var AgentRuntimeManager = class {
|
|
|
37418
37634
|
});
|
|
37419
37635
|
};
|
|
37420
37636
|
|
|
37421
|
-
// src/agent-catalog/publish-agent-catalog.ts
|
|
37422
|
-
import { fetch as fetch2 } from "undici";
|
|
37423
|
-
|
|
37424
|
-
// src/relay-connection/runtime-authentication.ts
|
|
37425
|
-
function runtimeCredential(relayUrl) {
|
|
37426
|
-
return relayUrl.searchParams.get("token") ?? "";
|
|
37427
|
-
}
|
|
37428
|
-
function runtimeAuthorization(relayUrl) {
|
|
37429
|
-
const credential = runtimeCredential(relayUrl);
|
|
37430
|
-
return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
|
|
37431
|
-
}
|
|
37432
|
-
function relayHttpEndpoint(relayUrl) {
|
|
37433
|
-
const endpoint = new URL(relayUrl);
|
|
37434
|
-
endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
|
|
37435
|
-
endpoint.search = "";
|
|
37436
|
-
return endpoint;
|
|
37437
|
-
}
|
|
37438
|
-
|
|
37439
|
-
// src/agent-catalog/publish-agent-catalog.ts
|
|
37440
|
-
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
37441
|
-
var AgentCatalogPublishError = class extends Error {
|
|
37442
|
-
code = "agent_catalog_update_failed";
|
|
37443
|
-
diagnosticDetails;
|
|
37444
|
-
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
37445
|
-
super(message, options);
|
|
37446
|
-
this.diagnosticDetails = diagnosticDetails;
|
|
37447
|
-
this.name = "AgentCatalogPublishError";
|
|
37448
|
-
}
|
|
37449
|
-
};
|
|
37450
|
-
function isRecord9(value) {
|
|
37451
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37452
|
-
}
|
|
37453
|
-
function isSafeRelayErrorMessage(value) {
|
|
37454
|
-
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
37455
|
-
}
|
|
37456
|
-
async function rejectedCatalogError(response) {
|
|
37457
|
-
let value;
|
|
37458
|
-
try {
|
|
37459
|
-
value = await response.json();
|
|
37460
|
-
} catch {
|
|
37461
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37462
|
-
}
|
|
37463
|
-
if (!isRecord9(value) || !isRecord9(value["error"])) {
|
|
37464
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37465
|
-
}
|
|
37466
|
-
const code = value["error"]["code"];
|
|
37467
|
-
const message = value["error"]["message"];
|
|
37468
|
-
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
37469
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37470
|
-
}
|
|
37471
|
-
return new AgentCatalogPublishError(
|
|
37472
|
-
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
37473
|
-
{},
|
|
37474
|
-
{
|
|
37475
|
-
relayErrorCode: code
|
|
37476
|
-
}
|
|
37477
|
-
);
|
|
37478
|
-
}
|
|
37479
|
-
function catalogEndpoint(config2) {
|
|
37480
|
-
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
37481
|
-
if (endpoint.pathname.endsWith("/daemon")) {
|
|
37482
|
-
endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
|
|
37483
|
-
return endpoint;
|
|
37484
|
-
}
|
|
37485
|
-
const runtimePath = "/v1/runtimes/connect";
|
|
37486
|
-
if (endpoint.pathname.endsWith(runtimePath)) {
|
|
37487
|
-
endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
|
|
37488
|
-
return endpoint;
|
|
37489
|
-
}
|
|
37490
|
-
throw new AgentCatalogPublishError("The Relay URL is invalid");
|
|
37491
|
-
}
|
|
37492
|
-
async function publishAgentCatalog(config2, signal) {
|
|
37493
|
-
signal.throwIfAborted();
|
|
37494
|
-
const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
|
|
37495
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37496
|
-
let response;
|
|
37497
|
-
const catalog = config2.catalog.read();
|
|
37498
|
-
try {
|
|
37499
|
-
response = await fetch2(catalogEndpoint(config2), {
|
|
37500
|
-
body: JSON.stringify({
|
|
37501
|
-
agents: catalog.agents.map((agent) => ({
|
|
37502
|
-
agentPath: agent.agentIdentity.requestedPath,
|
|
37503
|
-
agentVersion: agent.agentVersion,
|
|
37504
|
-
agentSettingsDiscovery: true,
|
|
37505
|
-
capabilities: agent.capabilities,
|
|
37506
|
-
id: agent.id,
|
|
37507
|
-
label: agent.label,
|
|
37508
|
-
sessionTurnConfiguration: true
|
|
37509
|
-
})),
|
|
37510
|
-
installableAgents: catalog.installableAgents
|
|
37511
|
-
}),
|
|
37512
|
-
dispatcher: environmentProxyDispatcher,
|
|
37513
|
-
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
37514
|
-
method: "PUT",
|
|
37515
|
-
signal: requestSignal
|
|
37516
|
-
});
|
|
37517
|
-
} catch (error62) {
|
|
37518
|
-
if (signal.aborted) {
|
|
37519
|
-
signal.throwIfAborted();
|
|
37520
|
-
}
|
|
37521
|
-
throw new AgentCatalogPublishError(
|
|
37522
|
-
timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
|
|
37523
|
-
{ cause: error62 }
|
|
37524
|
-
);
|
|
37525
|
-
}
|
|
37526
|
-
if (!response.ok) {
|
|
37527
|
-
throw await rejectedCatalogError(response);
|
|
37528
|
-
}
|
|
37529
|
-
await response.body?.cancel();
|
|
37530
|
-
}
|
|
37531
|
-
|
|
37532
37637
|
// src/agent-installation/agent-installation-manager.ts
|
|
37533
37638
|
var INSTALLATION_DEADLINE_MILLISECONDS = 10 * 60 * 1e3;
|
|
37534
37639
|
var AgentInstallation = class {
|
|
@@ -37991,9 +38096,9 @@ var FixedInstallationExecutor = class {
|
|
|
37991
38096
|
};
|
|
37992
38097
|
|
|
37993
38098
|
// src/authorization/workspace-directory.ts
|
|
37994
|
-
import { readdir as readdir3, realpath as
|
|
38099
|
+
import { readdir as readdir3, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
37995
38100
|
import { homedir as homedir2 } from "node:os";
|
|
37996
|
-
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute10, join as
|
|
38101
|
+
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute10, join as join18, normalize as normalize3, relative as relative4 } from "node:path";
|
|
37997
38102
|
|
|
37998
38103
|
// src/authorization/local-authorization-error.ts
|
|
37999
38104
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -38072,9 +38177,9 @@ var WorkspaceDirectoryService = class {
|
|
|
38072
38177
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
38073
38178
|
}
|
|
38074
38179
|
try {
|
|
38075
|
-
const target = await
|
|
38180
|
+
const target = await realpath9(requested);
|
|
38076
38181
|
signal.throwIfAborted();
|
|
38077
|
-
const metadata = await
|
|
38182
|
+
const metadata = await stat8(target);
|
|
38078
38183
|
signal.throwIfAborted();
|
|
38079
38184
|
if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
|
|
38080
38185
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
@@ -38122,7 +38227,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38122
38227
|
continue;
|
|
38123
38228
|
}
|
|
38124
38229
|
try {
|
|
38125
|
-
const path2 = await this.resolvePath(
|
|
38230
|
+
const path2 = await this.resolvePath(join18(target, child2.name), signal);
|
|
38126
38231
|
entries.push({ directoryId: encodePath(path2), name: child2.name });
|
|
38127
38232
|
} catch (cause) {
|
|
38128
38233
|
signal.throwIfAborted();
|
|
@@ -38158,15 +38263,15 @@ var WorkspaceDirectoryService = class {
|
|
|
38158
38263
|
|
|
38159
38264
|
// src/daemon-diagnostic-log.ts
|
|
38160
38265
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
38161
|
-
import { join as
|
|
38266
|
+
import { join as join19 } from "node:path";
|
|
38162
38267
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
38163
38268
|
var DaemonDiagnosticLog = class {
|
|
38164
38269
|
#directory;
|
|
38165
38270
|
#path;
|
|
38166
38271
|
#maximumBytes;
|
|
38167
38272
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
38168
|
-
this.#directory =
|
|
38169
|
-
this.#path =
|
|
38273
|
+
this.#directory = join19(stateDirectory, "logs");
|
|
38274
|
+
this.#path = join19(this.#directory, "daemon.log");
|
|
38170
38275
|
this.#maximumBytes = maximumBytes;
|
|
38171
38276
|
}
|
|
38172
38277
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -40111,9 +40216,10 @@ var NativeSessionService = class {
|
|
|
40111
40216
|
signal
|
|
40112
40217
|
);
|
|
40113
40218
|
signal.throwIfAborted();
|
|
40219
|
+
const cataloged = this.#config.catalog.find(command.agentId);
|
|
40114
40220
|
const options = {
|
|
40115
40221
|
additionalDirectories,
|
|
40116
|
-
agent: this.#config.
|
|
40222
|
+
agent: this.#config.resolveAgent === void 0 ? cataloged : await this.#config.resolveAgent(cataloged, signal),
|
|
40117
40223
|
cwd,
|
|
40118
40224
|
sessionId: command.sessionId,
|
|
40119
40225
|
signal
|
|
@@ -40291,7 +40397,7 @@ var NativeSessionService = class {
|
|
|
40291
40397
|
sessionId: command.targetSessionId,
|
|
40292
40398
|
additionalDirectories: target.additionalDirectories
|
|
40293
40399
|
},
|
|
40294
|
-
action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
|
|
40400
|
+
action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 }
|
|
40295
40401
|
);
|
|
40296
40402
|
signal.throwIfAborted();
|
|
40297
40403
|
const ready = {
|
|
@@ -40665,7 +40771,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
40665
40771
|
// package.json
|
|
40666
40772
|
var package_default = {
|
|
40667
40773
|
name: "@moxt-ai/mobius",
|
|
40668
|
-
version: "0.0.
|
|
40774
|
+
version: "0.0.195",
|
|
40669
40775
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
40670
40776
|
type: "module",
|
|
40671
40777
|
bin: {
|
|
@@ -40968,7 +41074,8 @@ function unsupportedModelIds(unsupportedModels) {
|
|
|
40968
41074
|
return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
|
|
40969
41075
|
}
|
|
40970
41076
|
async function discoverAgentSettings(command, config2, directories, sessions, signal) {
|
|
40971
|
-
const
|
|
41077
|
+
const cataloged = config2.catalog.find(command.agentId);
|
|
41078
|
+
const agent = config2.resolveAgent === void 0 ? cataloged : await config2.resolveAgent(cataloged, signal);
|
|
40972
41079
|
const cwd = await directories.resolve(config2.bindingId, "default", signal);
|
|
40973
41080
|
const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
|
|
40974
41081
|
additionalDirectories: [],
|
|
@@ -41362,7 +41469,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41362
41469
|
|
|
41363
41470
|
// src/artifacts/local-file-streamer.ts
|
|
41364
41471
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
41365
|
-
import { realpath as
|
|
41472
|
+
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
41366
41473
|
import { basename as basename4, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve5 } from "node:path";
|
|
41367
41474
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
41368
41475
|
var CHUNK_BYTES = 192 * 1024;
|
|
@@ -41390,7 +41497,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
41390
41497
|
return null;
|
|
41391
41498
|
}
|
|
41392
41499
|
try {
|
|
41393
|
-
const target = await
|
|
41500
|
+
const target = await realpath10(requested);
|
|
41394
41501
|
signal.throwIfAborted();
|
|
41395
41502
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
41396
41503
|
} catch {
|
|
@@ -41404,7 +41511,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41404
41511
|
if (target === null) {
|
|
41405
41512
|
throw new Error("The local file is unavailable");
|
|
41406
41513
|
}
|
|
41407
|
-
const before = await
|
|
41514
|
+
const before = await stat9(target);
|
|
41408
41515
|
signal.throwIfAborted();
|
|
41409
41516
|
if (!before.isFile() || before.size < 1 || before.size > command.maxBytes) {
|
|
41410
41517
|
throw new Error("The local file is too large to read");
|
|
@@ -41432,7 +41539,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41432
41539
|
});
|
|
41433
41540
|
sequence += 1;
|
|
41434
41541
|
}
|
|
41435
|
-
const after = await
|
|
41542
|
+
const after = await stat9(target);
|
|
41436
41543
|
signal.throwIfAborted();
|
|
41437
41544
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
41438
41545
|
throw new Error("The local file changed during transfer");
|
|
@@ -41476,7 +41583,305 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
41476
41583
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
41477
41584
|
}
|
|
41478
41585
|
|
|
41586
|
+
// src/daemon-session-commands.ts
|
|
41587
|
+
async function resolveCatalogAgent(config2, agentId, signal) {
|
|
41588
|
+
const agent = config2.catalog.find(agentId);
|
|
41589
|
+
return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
|
|
41590
|
+
}
|
|
41591
|
+
async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
|
|
41592
|
+
return await metrics.measure("prepare-total", async () => {
|
|
41593
|
+
const resolved = await metrics.measure(
|
|
41594
|
+
"workspace-resolve",
|
|
41595
|
+
async () => await resolveSessionDirectories(
|
|
41596
|
+
directories,
|
|
41597
|
+
config2.bindingId,
|
|
41598
|
+
command.directoryId,
|
|
41599
|
+
command.additionalDirectoryIds,
|
|
41600
|
+
signal
|
|
41601
|
+
)
|
|
41602
|
+
);
|
|
41603
|
+
const agent = await resolveCatalogAgent(config2, command.agentId, signal);
|
|
41604
|
+
const preparation = {
|
|
41605
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41606
|
+
agent,
|
|
41607
|
+
cwd: resolved.cwd,
|
|
41608
|
+
sessionId: command.sessionId,
|
|
41609
|
+
signal
|
|
41610
|
+
};
|
|
41611
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41612
|
+
const configuration = command.configuration;
|
|
41613
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41614
|
+
"configuration",
|
|
41615
|
+
async () => await sessions.configureSession({
|
|
41616
|
+
...preparation,
|
|
41617
|
+
booleanValue: configuration.booleanValue,
|
|
41618
|
+
configId: configuration.configId,
|
|
41619
|
+
requestId: command.requestId,
|
|
41620
|
+
value: configuration.value,
|
|
41621
|
+
valueType: configuration.valueType
|
|
41622
|
+
})
|
|
41623
|
+
);
|
|
41624
|
+
const listing = await metrics.measure(
|
|
41625
|
+
"workspace-list",
|
|
41626
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41627
|
+
);
|
|
41628
|
+
audit.record({
|
|
41629
|
+
commandId: command.requestId,
|
|
41630
|
+
event: "session_prepared",
|
|
41631
|
+
sessionId: command.sessionId
|
|
41632
|
+
});
|
|
41633
|
+
if (command.configuration !== void 0) {
|
|
41634
|
+
audit.record({
|
|
41635
|
+
commandId: command.requestId,
|
|
41636
|
+
event: "session_configured",
|
|
41637
|
+
sessionId: command.sessionId
|
|
41638
|
+
});
|
|
41639
|
+
}
|
|
41640
|
+
return {
|
|
41641
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41642
|
+
agentId: command.agentId,
|
|
41643
|
+
agentName: prepared.agentName,
|
|
41644
|
+
agentVersion: prepared.agentVersion,
|
|
41645
|
+
capabilities: prepared.capabilities,
|
|
41646
|
+
commands: prepared.commands,
|
|
41647
|
+
configOptions,
|
|
41648
|
+
directoryId: command.directoryId,
|
|
41649
|
+
directoryLabel: listing.directoryLabel,
|
|
41650
|
+
kind: "session.ready",
|
|
41651
|
+
requestId: command.requestId,
|
|
41652
|
+
restored: prepared.restored,
|
|
41653
|
+
sessionId: command.sessionId
|
|
41654
|
+
};
|
|
41655
|
+
});
|
|
41656
|
+
}
|
|
41657
|
+
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
41658
|
+
try {
|
|
41659
|
+
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
41660
|
+
audit.record({
|
|
41661
|
+
commandId: command.requestId,
|
|
41662
|
+
event: "workspace_list_authorized",
|
|
41663
|
+
sessionId: "workspace-browser"
|
|
41664
|
+
});
|
|
41665
|
+
send(socket, {
|
|
41666
|
+
bindingId: command.bindingId,
|
|
41667
|
+
directoryId: listing.directoryId,
|
|
41668
|
+
directoryLabel: listing.directoryLabel,
|
|
41669
|
+
entries: listing.entries,
|
|
41670
|
+
kind: "workspace.entries",
|
|
41671
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
41672
|
+
requestId: command.requestId
|
|
41673
|
+
});
|
|
41674
|
+
} catch (error62) {
|
|
41675
|
+
reportOperationFailure(socket, command.requestId, "", error62);
|
|
41676
|
+
}
|
|
41677
|
+
}
|
|
41678
|
+
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
41679
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41680
|
+
try {
|
|
41681
|
+
const readyEvent = await prepareSession(
|
|
41682
|
+
command,
|
|
41683
|
+
{ kind: "interactive-only" },
|
|
41684
|
+
config2,
|
|
41685
|
+
directories,
|
|
41686
|
+
audit,
|
|
41687
|
+
sessions,
|
|
41688
|
+
metrics,
|
|
41689
|
+
signal
|
|
41690
|
+
);
|
|
41691
|
+
send(socket, {
|
|
41692
|
+
...readyEvent,
|
|
41693
|
+
runtimeTimings: metrics.snapshot()
|
|
41694
|
+
});
|
|
41695
|
+
} catch (error62) {
|
|
41696
|
+
diagnostics.daemonDiagnostic(
|
|
41697
|
+
"session_prepare_failed",
|
|
41698
|
+
command.requestId,
|
|
41699
|
+
{
|
|
41700
|
+
agentId: command.agentId,
|
|
41701
|
+
code: operationErrorCode(error62),
|
|
41702
|
+
sessionId: command.sessionId
|
|
41703
|
+
},
|
|
41704
|
+
error62
|
|
41705
|
+
);
|
|
41706
|
+
audit.record({
|
|
41707
|
+
commandId: command.requestId,
|
|
41708
|
+
details: {
|
|
41709
|
+
agentId: command.agentId,
|
|
41710
|
+
code: operationErrorCode(error62)
|
|
41711
|
+
},
|
|
41712
|
+
event: "session_prepare_failed",
|
|
41713
|
+
sessionId: command.sessionId
|
|
41714
|
+
});
|
|
41715
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41716
|
+
}
|
|
41717
|
+
}
|
|
41718
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
41719
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41720
|
+
try {
|
|
41721
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
41722
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
41723
|
+
if (found === void 0) {
|
|
41724
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
41725
|
+
}
|
|
41726
|
+
return found;
|
|
41727
|
+
});
|
|
41728
|
+
const ready = await prepareSession(
|
|
41729
|
+
{
|
|
41730
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
41731
|
+
agentId: entry.agentId,
|
|
41732
|
+
bindingId: config2.bindingId,
|
|
41733
|
+
directoryId: entry.directoryId,
|
|
41734
|
+
kind: "session.prepare",
|
|
41735
|
+
requestId: command.requestId,
|
|
41736
|
+
sessionId: command.sessionId,
|
|
41737
|
+
sessionState: "provisioned"
|
|
41738
|
+
},
|
|
41739
|
+
{ kind: "history-required" },
|
|
41740
|
+
config2,
|
|
41741
|
+
directories,
|
|
41742
|
+
audit,
|
|
41743
|
+
sessions,
|
|
41744
|
+
metrics,
|
|
41745
|
+
signal
|
|
41746
|
+
);
|
|
41747
|
+
send(socket, {
|
|
41748
|
+
entry,
|
|
41749
|
+
kind: "session.restored",
|
|
41750
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
41751
|
+
requestId: command.requestId
|
|
41752
|
+
});
|
|
41753
|
+
} catch (error62) {
|
|
41754
|
+
diagnostics.daemonDiagnostic(
|
|
41755
|
+
"session_restore_failed",
|
|
41756
|
+
command.requestId,
|
|
41757
|
+
{
|
|
41758
|
+
code: operationErrorCode(error62),
|
|
41759
|
+
sessionId: command.sessionId
|
|
41760
|
+
},
|
|
41761
|
+
error62
|
|
41762
|
+
);
|
|
41763
|
+
audit.record({
|
|
41764
|
+
commandId: command.requestId,
|
|
41765
|
+
details: { code: operationErrorCode(error62) },
|
|
41766
|
+
event: "session_restore_failed",
|
|
41767
|
+
sessionId: command.sessionId
|
|
41768
|
+
});
|
|
41769
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41770
|
+
}
|
|
41771
|
+
}
|
|
41772
|
+
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
41773
|
+
try {
|
|
41774
|
+
const resolved = await resolveSessionDirectories(
|
|
41775
|
+
directories,
|
|
41776
|
+
config2.bindingId,
|
|
41777
|
+
command.directoryId,
|
|
41778
|
+
command.additionalDirectoryIds,
|
|
41779
|
+
signal
|
|
41780
|
+
);
|
|
41781
|
+
const configOptions = await sessions.configureSession({
|
|
41782
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41783
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
41784
|
+
booleanValue: command.booleanValue,
|
|
41785
|
+
configId: command.configId,
|
|
41786
|
+
cwd: resolved.cwd,
|
|
41787
|
+
requestId: command.requestId,
|
|
41788
|
+
sessionId: command.sessionId,
|
|
41789
|
+
signal,
|
|
41790
|
+
value: command.value,
|
|
41791
|
+
valueType: command.valueType
|
|
41792
|
+
});
|
|
41793
|
+
audit.record({
|
|
41794
|
+
commandId: command.requestId,
|
|
41795
|
+
event: "session_configured",
|
|
41796
|
+
sessionId: command.sessionId
|
|
41797
|
+
});
|
|
41798
|
+
send(socket, {
|
|
41799
|
+
configOptions,
|
|
41800
|
+
kind: "session.config.updated",
|
|
41801
|
+
requestId: command.requestId,
|
|
41802
|
+
sessionId: command.sessionId
|
|
41803
|
+
});
|
|
41804
|
+
} catch (error62) {
|
|
41805
|
+
if (signal.aborted) {
|
|
41806
|
+
signal.throwIfAborted();
|
|
41807
|
+
}
|
|
41808
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
41809
|
+
}
|
|
41810
|
+
}
|
|
41811
|
+
|
|
41479
41812
|
// src/daemon-history-commands.ts
|
|
41813
|
+
function isAgentReasoning(event) {
|
|
41814
|
+
return event?.type === "acp" && event.payload.sessionUpdate === "agent_thought_chunk";
|
|
41815
|
+
}
|
|
41816
|
+
function omitAgentReasoning(events) {
|
|
41817
|
+
const retained = [];
|
|
41818
|
+
let previousReasoningMessageId;
|
|
41819
|
+
for (const event of events) {
|
|
41820
|
+
if (event.type !== "acp" || event.payload.sessionUpdate !== "agent_thought_chunk") {
|
|
41821
|
+
previousReasoningMessageId = void 0;
|
|
41822
|
+
retained.push(event);
|
|
41823
|
+
continue;
|
|
41824
|
+
}
|
|
41825
|
+
const messageId = event.payload.messageId ?? null;
|
|
41826
|
+
if (previousReasoningMessageId === void 0 || previousReasoningMessageId !== messageId) {
|
|
41827
|
+
retained.push({
|
|
41828
|
+
...event,
|
|
41829
|
+
mobiusMetadata: { omitted: true },
|
|
41830
|
+
payload: { ...event.payload, content: { text: "", type: "text" } }
|
|
41831
|
+
});
|
|
41832
|
+
}
|
|
41833
|
+
previousReasoningMessageId = messageId;
|
|
41834
|
+
}
|
|
41835
|
+
return retained;
|
|
41836
|
+
}
|
|
41837
|
+
async function loadHistoryPage(sessionId, eventLimit, initialCursor, omitReasoning, queuedPromptRequests, load, eventLogV2) {
|
|
41838
|
+
let cursor = initialCursor;
|
|
41839
|
+
let loaded = [];
|
|
41840
|
+
let sessionGenerationId = null;
|
|
41841
|
+
let sourceNextCursor = null;
|
|
41842
|
+
do {
|
|
41843
|
+
const replay = await load(eventLimit, cursor);
|
|
41844
|
+
if (sessionGenerationId !== null && replay.sessionGenerationId !== sessionGenerationId) {
|
|
41845
|
+
throw new AcpExecutionError("The Session reloaded while history was loading", {}, "session_reloaded");
|
|
41846
|
+
}
|
|
41847
|
+
sessionGenerationId = replay.sessionGenerationId;
|
|
41848
|
+
const events2 = replay.events.map(
|
|
41849
|
+
(event, index2) => eventLogV2.event(
|
|
41850
|
+
sessionId,
|
|
41851
|
+
replay.sessionGenerationId,
|
|
41852
|
+
replay.startPosition + index2,
|
|
41853
|
+
event,
|
|
41854
|
+
"1970-01-01T00:00:00.000Z"
|
|
41855
|
+
)
|
|
41856
|
+
);
|
|
41857
|
+
loaded = [...events2, ...loaded];
|
|
41858
|
+
sourceNextCursor = replay.nextCursor;
|
|
41859
|
+
const visible2 = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
41860
|
+
const reasoningContinuesBeforePage = sourceNextCursor !== null && isAgentReasoning(loaded[0]);
|
|
41861
|
+
if (visible2.length >= eventLimit && !reasoningContinuesBeforePage) {
|
|
41862
|
+
break;
|
|
41863
|
+
}
|
|
41864
|
+
cursor = sourceNextCursor;
|
|
41865
|
+
} while (cursor !== null);
|
|
41866
|
+
if (sessionGenerationId === null) {
|
|
41867
|
+
throw new AcpExecutionError("The Session history is unavailable", {}, "session_history_unavailable");
|
|
41868
|
+
}
|
|
41869
|
+
const visible = omitReasoning ? omitAgentReasoning(loaded) : loaded;
|
|
41870
|
+
const events = visible.slice(-eventLimit);
|
|
41871
|
+
const firstPosition = events[0] === void 0 ? 0 : Number(events[0].position);
|
|
41872
|
+
const nextCursor = firstPosition <= 1 ? null : (firstPosition - 1).toString();
|
|
41873
|
+
return {
|
|
41874
|
+
events: {
|
|
41875
|
+
events,
|
|
41876
|
+
nextCursor,
|
|
41877
|
+
sessionGenerationId,
|
|
41878
|
+
tailCursor: events.at(-1)?.eventId ?? "",
|
|
41879
|
+
truncated: nextCursor !== null,
|
|
41880
|
+
version: 2
|
|
41881
|
+
},
|
|
41882
|
+
queuedPromptRequests
|
|
41883
|
+
};
|
|
41884
|
+
}
|
|
41480
41885
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
|
|
41481
41886
|
let agentId;
|
|
41482
41887
|
try {
|
|
@@ -41494,41 +41899,29 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41494
41899
|
);
|
|
41495
41900
|
const loadOptions = {
|
|
41496
41901
|
additionalDirectories: resolved.additionalDirectories,
|
|
41497
|
-
agent: config2
|
|
41902
|
+
agent: await resolveCatalogAgent(config2, entry.agentId, signal),
|
|
41498
41903
|
cwd: resolved.cwd,
|
|
41499
41904
|
sessionId: command.sessionId,
|
|
41500
41905
|
signal
|
|
41501
41906
|
};
|
|
41502
41907
|
const recovery = eventLogV2.promptRequestRecovery(command.sessionId);
|
|
41503
|
-
const
|
|
41504
|
-
|
|
41505
|
-
|
|
41506
|
-
|
|
41507
|
-
|
|
41508
|
-
|
|
41509
|
-
|
|
41510
|
-
|
|
41511
|
-
"1970-01-01T00:00:00.000Z"
|
|
41512
|
-
)
|
|
41908
|
+
const events = await loadHistoryPage(
|
|
41909
|
+
command.sessionId,
|
|
41910
|
+
command.eventLimit,
|
|
41911
|
+
command.cursor,
|
|
41912
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
41913
|
+
recovery.queuedPromptRequests,
|
|
41914
|
+
async (eventLimit, cursor) => await sessions.loadSessionEventsV2(loadOptions, eventLimit, cursor),
|
|
41915
|
+
eventLogV2
|
|
41513
41916
|
);
|
|
41514
|
-
|
|
41917
|
+
signal.throwIfAborted();
|
|
41515
41918
|
audit.record({
|
|
41516
41919
|
commandId: command.requestId,
|
|
41517
41920
|
event: "session_event_log_v2_loaded",
|
|
41518
41921
|
sessionId: command.sessionId
|
|
41519
41922
|
});
|
|
41520
41923
|
send(socket, {
|
|
41521
|
-
events
|
|
41522
|
-
events: {
|
|
41523
|
-
events,
|
|
41524
|
-
nextCursor: replay.nextCursor,
|
|
41525
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
41526
|
-
tailCursor,
|
|
41527
|
-
truncated: replay.truncated,
|
|
41528
|
-
version: 2
|
|
41529
|
-
},
|
|
41530
|
-
queuedPromptRequests: recovery.queuedPromptRequests
|
|
41531
|
-
},
|
|
41924
|
+
events,
|
|
41532
41925
|
kind: SESSION_LIVE_HISTORY_V2_PAGE_LOADED_KIND,
|
|
41533
41926
|
requestId: command.requestId,
|
|
41534
41927
|
sessionId: command.sessionId
|
|
@@ -41567,46 +41960,30 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
41567
41960
|
command.additionalDirectoryIds,
|
|
41568
41961
|
signal
|
|
41569
41962
|
);
|
|
41570
|
-
const
|
|
41571
|
-
|
|
41572
|
-
|
|
41573
|
-
|
|
41574
|
-
|
|
41575
|
-
|
|
41576
|
-
|
|
41577
|
-
|
|
41963
|
+
const loadOptions = {
|
|
41964
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41965
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
41966
|
+
cwd: resolved.cwd,
|
|
41967
|
+
sessionId: command.sessionId,
|
|
41968
|
+
signal
|
|
41969
|
+
};
|
|
41970
|
+
const events = await loadHistoryPage(
|
|
41578
41971
|
command.sessionId,
|
|
41579
41972
|
command.eventLimit,
|
|
41580
|
-
command.cursor
|
|
41973
|
+
command.cursor,
|
|
41974
|
+
command.omit?.includes("agent-reasoning") === true,
|
|
41975
|
+
[],
|
|
41976
|
+
async (eventLimit, cursor) => await sessions.previewNativeSessionEventsV2(loadOptions, command.sessionId, eventLimit, cursor),
|
|
41977
|
+
eventLogV2
|
|
41581
41978
|
);
|
|
41582
41979
|
signal.throwIfAborted();
|
|
41583
|
-
const events = replay.events.map(
|
|
41584
|
-
(event, index2) => eventLogV2.event(
|
|
41585
|
-
command.sessionId,
|
|
41586
|
-
replay.sessionGenerationId,
|
|
41587
|
-
replay.startPosition + index2,
|
|
41588
|
-
event,
|
|
41589
|
-
"1970-01-01T00:00:00.000Z"
|
|
41590
|
-
)
|
|
41591
|
-
);
|
|
41592
|
-
const tailCursor = events.at(-1)?.eventId ?? "";
|
|
41593
41980
|
audit.record({
|
|
41594
41981
|
commandId: command.requestId,
|
|
41595
41982
|
event: "session_event_log_v2_loaded",
|
|
41596
41983
|
sessionId: command.sessionId
|
|
41597
41984
|
});
|
|
41598
41985
|
send(socket, {
|
|
41599
|
-
events
|
|
41600
|
-
events: {
|
|
41601
|
-
events,
|
|
41602
|
-
nextCursor: replay.nextCursor,
|
|
41603
|
-
sessionGenerationId: replay.sessionGenerationId,
|
|
41604
|
-
tailCursor,
|
|
41605
|
-
truncated: replay.truncated,
|
|
41606
|
-
version: 2
|
|
41607
|
-
},
|
|
41608
|
-
queuedPromptRequests: []
|
|
41609
|
-
},
|
|
41986
|
+
events,
|
|
41610
41987
|
kind: SESSION_PREVIEW_HISTORY_PAGE_LOADED_KIND,
|
|
41611
41988
|
requestId: command.requestId,
|
|
41612
41989
|
sessionId: command.sessionId
|
|
@@ -41862,7 +42239,7 @@ async function executePrompt({
|
|
|
41862
42239
|
command.additionalDirectoryIds,
|
|
41863
42240
|
signal
|
|
41864
42241
|
);
|
|
41865
|
-
const agent = config2
|
|
42242
|
+
const agent = await resolveCatalogAgent(config2, command.agentId, signal);
|
|
41866
42243
|
const availability = await waitForSessionAvailability(signal);
|
|
41867
42244
|
if (availability.kind === "busy") {
|
|
41868
42245
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
@@ -42007,228 +42384,6 @@ async function executePrompt({
|
|
|
42007
42384
|
}
|
|
42008
42385
|
}
|
|
42009
42386
|
|
|
42010
|
-
// src/daemon-session-commands.ts
|
|
42011
|
-
async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
|
|
42012
|
-
return await metrics.measure("prepare-total", async () => {
|
|
42013
|
-
const resolved = await metrics.measure(
|
|
42014
|
-
"workspace-resolve",
|
|
42015
|
-
async () => await resolveSessionDirectories(
|
|
42016
|
-
directories,
|
|
42017
|
-
config2.bindingId,
|
|
42018
|
-
command.directoryId,
|
|
42019
|
-
command.additionalDirectoryIds,
|
|
42020
|
-
signal
|
|
42021
|
-
)
|
|
42022
|
-
);
|
|
42023
|
-
const agent = config2.catalog.find(command.agentId);
|
|
42024
|
-
const preparation = {
|
|
42025
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42026
|
-
agent,
|
|
42027
|
-
cwd: resolved.cwd,
|
|
42028
|
-
sessionId: command.sessionId,
|
|
42029
|
-
signal
|
|
42030
|
-
};
|
|
42031
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
42032
|
-
const configuration = command.configuration;
|
|
42033
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
42034
|
-
"configuration",
|
|
42035
|
-
async () => await sessions.configureSession({
|
|
42036
|
-
...preparation,
|
|
42037
|
-
booleanValue: configuration.booleanValue,
|
|
42038
|
-
configId: configuration.configId,
|
|
42039
|
-
requestId: command.requestId,
|
|
42040
|
-
value: configuration.value,
|
|
42041
|
-
valueType: configuration.valueType
|
|
42042
|
-
})
|
|
42043
|
-
);
|
|
42044
|
-
const listing = await metrics.measure(
|
|
42045
|
-
"workspace-list",
|
|
42046
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
42047
|
-
);
|
|
42048
|
-
audit.record({
|
|
42049
|
-
commandId: command.requestId,
|
|
42050
|
-
event: "session_prepared",
|
|
42051
|
-
sessionId: command.sessionId
|
|
42052
|
-
});
|
|
42053
|
-
if (command.configuration !== void 0) {
|
|
42054
|
-
audit.record({
|
|
42055
|
-
commandId: command.requestId,
|
|
42056
|
-
event: "session_configured",
|
|
42057
|
-
sessionId: command.sessionId
|
|
42058
|
-
});
|
|
42059
|
-
}
|
|
42060
|
-
return {
|
|
42061
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
42062
|
-
agentId: command.agentId,
|
|
42063
|
-
agentName: prepared.agentName,
|
|
42064
|
-
agentVersion: prepared.agentVersion,
|
|
42065
|
-
capabilities: prepared.capabilities,
|
|
42066
|
-
commands: prepared.commands,
|
|
42067
|
-
configOptions,
|
|
42068
|
-
directoryId: command.directoryId,
|
|
42069
|
-
directoryLabel: listing.directoryLabel,
|
|
42070
|
-
kind: "session.ready",
|
|
42071
|
-
requestId: command.requestId,
|
|
42072
|
-
restored: prepared.restored,
|
|
42073
|
-
sessionId: command.sessionId
|
|
42074
|
-
};
|
|
42075
|
-
});
|
|
42076
|
-
}
|
|
42077
|
-
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
42078
|
-
try {
|
|
42079
|
-
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
42080
|
-
audit.record({
|
|
42081
|
-
commandId: command.requestId,
|
|
42082
|
-
event: "workspace_list_authorized",
|
|
42083
|
-
sessionId: "workspace-browser"
|
|
42084
|
-
});
|
|
42085
|
-
send(socket, {
|
|
42086
|
-
bindingId: command.bindingId,
|
|
42087
|
-
directoryId: listing.directoryId,
|
|
42088
|
-
directoryLabel: listing.directoryLabel,
|
|
42089
|
-
entries: listing.entries,
|
|
42090
|
-
kind: "workspace.entries",
|
|
42091
|
-
parentDirectoryId: listing.parentDirectoryId,
|
|
42092
|
-
requestId: command.requestId
|
|
42093
|
-
});
|
|
42094
|
-
} catch (error62) {
|
|
42095
|
-
reportOperationFailure(socket, command.requestId, "", error62);
|
|
42096
|
-
}
|
|
42097
|
-
}
|
|
42098
|
-
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
42099
|
-
const metrics = new AccumulatingOperationMetrics();
|
|
42100
|
-
try {
|
|
42101
|
-
const readyEvent = await prepareSession(
|
|
42102
|
-
command,
|
|
42103
|
-
{ kind: "interactive-only" },
|
|
42104
|
-
config2,
|
|
42105
|
-
directories,
|
|
42106
|
-
audit,
|
|
42107
|
-
sessions,
|
|
42108
|
-
metrics,
|
|
42109
|
-
signal
|
|
42110
|
-
);
|
|
42111
|
-
send(socket, {
|
|
42112
|
-
...readyEvent,
|
|
42113
|
-
runtimeTimings: metrics.snapshot()
|
|
42114
|
-
});
|
|
42115
|
-
} catch (error62) {
|
|
42116
|
-
diagnostics.daemonDiagnostic(
|
|
42117
|
-
"session_prepare_failed",
|
|
42118
|
-
command.requestId,
|
|
42119
|
-
{
|
|
42120
|
-
agentId: command.agentId,
|
|
42121
|
-
code: operationErrorCode(error62),
|
|
42122
|
-
sessionId: command.sessionId
|
|
42123
|
-
},
|
|
42124
|
-
error62
|
|
42125
|
-
);
|
|
42126
|
-
audit.record({
|
|
42127
|
-
commandId: command.requestId,
|
|
42128
|
-
details: {
|
|
42129
|
-
agentId: command.agentId,
|
|
42130
|
-
code: operationErrorCode(error62)
|
|
42131
|
-
},
|
|
42132
|
-
event: "session_prepare_failed",
|
|
42133
|
-
sessionId: command.sessionId
|
|
42134
|
-
});
|
|
42135
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42136
|
-
}
|
|
42137
|
-
}
|
|
42138
|
-
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
42139
|
-
const metrics = new AccumulatingOperationMetrics();
|
|
42140
|
-
try {
|
|
42141
|
-
const entry = await metrics.measure("session-lookup", async () => {
|
|
42142
|
-
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
42143
|
-
if (found === void 0) {
|
|
42144
|
-
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
42145
|
-
}
|
|
42146
|
-
return found;
|
|
42147
|
-
});
|
|
42148
|
-
const ready = await prepareSession(
|
|
42149
|
-
{
|
|
42150
|
-
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
42151
|
-
agentId: entry.agentId,
|
|
42152
|
-
bindingId: config2.bindingId,
|
|
42153
|
-
directoryId: entry.directoryId,
|
|
42154
|
-
kind: "session.prepare",
|
|
42155
|
-
requestId: command.requestId,
|
|
42156
|
-
sessionId: command.sessionId,
|
|
42157
|
-
sessionState: "provisioned"
|
|
42158
|
-
},
|
|
42159
|
-
{ kind: "history-required" },
|
|
42160
|
-
config2,
|
|
42161
|
-
directories,
|
|
42162
|
-
audit,
|
|
42163
|
-
sessions,
|
|
42164
|
-
metrics,
|
|
42165
|
-
signal
|
|
42166
|
-
);
|
|
42167
|
-
send(socket, {
|
|
42168
|
-
entry,
|
|
42169
|
-
kind: "session.restored",
|
|
42170
|
-
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
42171
|
-
requestId: command.requestId
|
|
42172
|
-
});
|
|
42173
|
-
} catch (error62) {
|
|
42174
|
-
diagnostics.daemonDiagnostic(
|
|
42175
|
-
"session_restore_failed",
|
|
42176
|
-
command.requestId,
|
|
42177
|
-
{
|
|
42178
|
-
code: operationErrorCode(error62),
|
|
42179
|
-
sessionId: command.sessionId
|
|
42180
|
-
},
|
|
42181
|
-
error62
|
|
42182
|
-
);
|
|
42183
|
-
audit.record({
|
|
42184
|
-
commandId: command.requestId,
|
|
42185
|
-
details: { code: operationErrorCode(error62) },
|
|
42186
|
-
event: "session_restore_failed",
|
|
42187
|
-
sessionId: command.sessionId
|
|
42188
|
-
});
|
|
42189
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42190
|
-
}
|
|
42191
|
-
}
|
|
42192
|
-
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
42193
|
-
try {
|
|
42194
|
-
const resolved = await resolveSessionDirectories(
|
|
42195
|
-
directories,
|
|
42196
|
-
config2.bindingId,
|
|
42197
|
-
command.directoryId,
|
|
42198
|
-
command.additionalDirectoryIds,
|
|
42199
|
-
signal
|
|
42200
|
-
);
|
|
42201
|
-
const configOptions = await sessions.configureSession({
|
|
42202
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42203
|
-
agent: config2.catalog.find(command.agentId),
|
|
42204
|
-
booleanValue: command.booleanValue,
|
|
42205
|
-
configId: command.configId,
|
|
42206
|
-
cwd: resolved.cwd,
|
|
42207
|
-
requestId: command.requestId,
|
|
42208
|
-
sessionId: command.sessionId,
|
|
42209
|
-
signal,
|
|
42210
|
-
value: command.value,
|
|
42211
|
-
valueType: command.valueType
|
|
42212
|
-
});
|
|
42213
|
-
audit.record({
|
|
42214
|
-
commandId: command.requestId,
|
|
42215
|
-
event: "session_configured",
|
|
42216
|
-
sessionId: command.sessionId
|
|
42217
|
-
});
|
|
42218
|
-
send(socket, {
|
|
42219
|
-
configOptions,
|
|
42220
|
-
kind: "session.config.updated",
|
|
42221
|
-
requestId: command.requestId,
|
|
42222
|
-
sessionId: command.sessionId
|
|
42223
|
-
});
|
|
42224
|
-
} catch (error62) {
|
|
42225
|
-
if (signal.aborted) {
|
|
42226
|
-
signal.throwIfAborted();
|
|
42227
|
-
}
|
|
42228
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
42229
|
-
}
|
|
42230
|
-
}
|
|
42231
|
-
|
|
42232
42387
|
// src/native-sessions/handle-native-requests.ts
|
|
42233
42388
|
import { WebSocket as WebSocket4 } from "undici";
|
|
42234
42389
|
function createNativeSessionRequestHandler(dependencies) {
|
|
@@ -43421,11 +43576,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43421
43576
|
stateDirectory
|
|
43422
43577
|
});
|
|
43423
43578
|
const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
|
|
43424
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
43579
|
+
const sessionDatabase = openAcpSessionDatabase(join20(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
43425
43580
|
let eventsV2;
|
|
43426
43581
|
try {
|
|
43427
43582
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
43428
|
-
openSessionEventCacheV2Database(
|
|
43583
|
+
openSessionEventCacheV2Database(join20(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
43429
43584
|
);
|
|
43430
43585
|
} catch (error62) {
|
|
43431
43586
|
sessionDatabase.close();
|
|
@@ -43628,7 +43783,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43628
43783
|
}
|
|
43629
43784
|
|
|
43630
43785
|
// src/pairing/pair-local-machine.ts
|
|
43631
|
-
import { mkdir as mkdir6, realpath as
|
|
43786
|
+
import { mkdir as mkdir6, realpath as realpath11, stat as stat10 } from "node:fs/promises";
|
|
43632
43787
|
import { hostname as hostname3 } from "node:os";
|
|
43633
43788
|
import { basename as basename6, resolve as resolve7 } from "node:path";
|
|
43634
43789
|
import { fetch as fetch4 } from "undici";
|
|
@@ -43636,7 +43791,7 @@ import { fetch as fetch4 } from "undici";
|
|
|
43636
43791
|
// src/storage/runtime-installation-store.ts
|
|
43637
43792
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
43638
43793
|
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
43639
|
-
import { dirname as dirname6, join as
|
|
43794
|
+
import { dirname as dirname6, join as join21, resolve as resolve6 } from "node:path";
|
|
43640
43795
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
43641
43796
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
43642
43797
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -43879,7 +44034,7 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
43879
44034
|
async function writeJsonAtomically(path2, value, signal) {
|
|
43880
44035
|
signal.throwIfAborted();
|
|
43881
44036
|
const directory = dirname6(path2);
|
|
43882
|
-
const temporaryPath =
|
|
44037
|
+
const temporaryPath = join21(directory, `.${randomUUID9()}.tmp`);
|
|
43883
44038
|
try {
|
|
43884
44039
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
43885
44040
|
signal.throwIfAborted();
|
|
@@ -43905,14 +44060,14 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43905
44060
|
this.applicationId = applicationId;
|
|
43906
44061
|
this.installationId = installationId2;
|
|
43907
44062
|
this.stateDirectory = stateDirectory;
|
|
43908
|
-
this.#channelDirectory =
|
|
43909
|
-
this.#connectionDirectory =
|
|
44063
|
+
this.#channelDirectory = join21(stateDirectory, "channels");
|
|
44064
|
+
this.#connectionDirectory = join21(stateDirectory, "connections");
|
|
43910
44065
|
}
|
|
43911
44066
|
static open = async (options, signal) => {
|
|
43912
44067
|
signal.throwIfAborted();
|
|
43913
44068
|
const applicationId = validateApplicationId(options.applicationId);
|
|
43914
44069
|
const rootDirectory = resolve6(options.stateDirectory);
|
|
43915
|
-
const applicationDirectory =
|
|
44070
|
+
const applicationDirectory = join21(rootDirectory, "installations", applicationId);
|
|
43916
44071
|
try {
|
|
43917
44072
|
await mkdir5(applicationDirectory, { mode: 448, recursive: true });
|
|
43918
44073
|
} catch (cause) {
|
|
@@ -43925,7 +44080,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43925
44080
|
);
|
|
43926
44081
|
}
|
|
43927
44082
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
43928
|
-
const stateDirectory =
|
|
44083
|
+
const stateDirectory = join21(applicationDirectory, storedInstallationId);
|
|
43929
44084
|
try {
|
|
43930
44085
|
await mkdir5(stateDirectory, { mode: 448, recursive: true });
|
|
43931
44086
|
} catch (cause) {
|
|
@@ -43940,8 +44095,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43940
44095
|
signal.throwIfAborted();
|
|
43941
44096
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
43942
44097
|
};
|
|
43943
|
-
connectionPath = (connectionId2) =>
|
|
43944
|
-
channelIndexPath = (channelId) =>
|
|
44098
|
+
connectionPath = (connectionId2) => join21(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
44099
|
+
channelIndexPath = (channelId) => join21(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
43945
44100
|
readConnection = async (connectionId2, signal) => {
|
|
43946
44101
|
const stored = decodeConnection(
|
|
43947
44102
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -44103,7 +44258,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44103
44258
|
};
|
|
44104
44259
|
};
|
|
44105
44260
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
44106
|
-
const pointerPath =
|
|
44261
|
+
const pointerPath = join21(applicationDirectory, "current.json");
|
|
44107
44262
|
try {
|
|
44108
44263
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
44109
44264
|
} catch (cause) {
|
|
@@ -44198,8 +44353,8 @@ async function resolveDefaultWorkspace2(path2) {
|
|
|
44198
44353
|
const requestedWorkspace = resolve7(path2);
|
|
44199
44354
|
try {
|
|
44200
44355
|
await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
|
|
44201
|
-
const defaultWorkspace = await
|
|
44202
|
-
const metadata = await
|
|
44356
|
+
const defaultWorkspace = await realpath11(requestedWorkspace);
|
|
44357
|
+
const metadata = await stat10(defaultWorkspace);
|
|
44203
44358
|
if (!metadata.isDirectory()) {
|
|
44204
44359
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
44205
44360
|
}
|
|
@@ -44298,20 +44453,30 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
|
|
|
44298
44453
|
const relayUrl = mobiusApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
|
|
44299
44454
|
relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
44300
44455
|
relayUrl.searchParams.set("token", connection.runtimeCredential);
|
|
44456
|
+
const config2 = createDaemonConfig(
|
|
44457
|
+
{
|
|
44458
|
+
defaultWorkspace,
|
|
44459
|
+
channelId: connection.channelId,
|
|
44460
|
+
relayUrl
|
|
44461
|
+
},
|
|
44462
|
+
inventory.readyAgents(),
|
|
44463
|
+
inventory.installable,
|
|
44464
|
+
localContext,
|
|
44465
|
+
new OpaqueDaemonReconnectTarget(connection.connectionId),
|
|
44466
|
+
createCatalogAgentResolver(
|
|
44467
|
+
(refreshSignal) => discoverLocalAgentInventory({
|
|
44468
|
+
defaultWorkspace,
|
|
44469
|
+
environment: localContext.environment,
|
|
44470
|
+
signal: refreshSignal
|
|
44471
|
+
}),
|
|
44472
|
+
() => config2,
|
|
44473
|
+
publishAgentCatalog
|
|
44474
|
+
)
|
|
44475
|
+
);
|
|
44301
44476
|
return {
|
|
44302
44477
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
44303
44478
|
connectionId: connection.connectionId,
|
|
44304
|
-
config:
|
|
44305
|
-
{
|
|
44306
|
-
defaultWorkspace,
|
|
44307
|
-
channelId: connection.channelId,
|
|
44308
|
-
relayUrl
|
|
44309
|
-
},
|
|
44310
|
-
inventory.readyAgents(),
|
|
44311
|
-
inventory.installable,
|
|
44312
|
-
localContext,
|
|
44313
|
-
new OpaqueDaemonReconnectTarget(connection.connectionId)
|
|
44314
|
-
),
|
|
44479
|
+
config: config2,
|
|
44315
44480
|
connectionPath: installation.connectionPath(connection.connectionId)
|
|
44316
44481
|
};
|
|
44317
44482
|
}
|
|
@@ -44434,8 +44599,8 @@ async function resolveWorkspace(path2) {
|
|
|
44434
44599
|
const requested = resolve8(path2);
|
|
44435
44600
|
try {
|
|
44436
44601
|
await mkdir7(requested, { recursive: true, mode: 448 });
|
|
44437
|
-
const resolved = await
|
|
44438
|
-
const metadata = await
|
|
44602
|
+
const resolved = await realpath12(requested);
|
|
44603
|
+
const metadata = await stat11(resolved);
|
|
44439
44604
|
if (!metadata.isDirectory()) {
|
|
44440
44605
|
throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
|
|
44441
44606
|
}
|
|
@@ -44452,26 +44617,35 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
44452
44617
|
const localContext = new DaemonLocalContext(readStateDirectory(environment), environment);
|
|
44453
44618
|
const relayUrl = relayUrlFromConnection(connection);
|
|
44454
44619
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
44455
|
-
const
|
|
44620
|
+
const specifications = supportedLocalAgentSpecifications();
|
|
44621
|
+
const discoveryEnvironment = localContext.environment;
|
|
44622
|
+
const discover = async (refreshSignal) => await discoverLocalAgentInventory({
|
|
44456
44623
|
defaultWorkspace,
|
|
44457
|
-
environment:
|
|
44458
|
-
signal
|
|
44624
|
+
environment: discoveryEnvironment,
|
|
44625
|
+
signal: refreshSignal,
|
|
44626
|
+
specifications
|
|
44459
44627
|
});
|
|
44628
|
+
const inventory = await discover(signal);
|
|
44460
44629
|
if (inventory.available.length + inventory.installable.length === 0) {
|
|
44461
44630
|
throw new MobiusRuntimeConfigurationError("No supported Agent is available for the local Runtime");
|
|
44462
44631
|
}
|
|
44463
|
-
|
|
44464
|
-
|
|
44465
|
-
|
|
44466
|
-
|
|
44467
|
-
|
|
44468
|
-
|
|
44469
|
-
|
|
44470
|
-
|
|
44471
|
-
|
|
44472
|
-
|
|
44632
|
+
const config2 = createDaemonConfig(
|
|
44633
|
+
{
|
|
44634
|
+
channelId: connection.channelId,
|
|
44635
|
+
defaultWorkspace,
|
|
44636
|
+
relayUrl
|
|
44637
|
+
},
|
|
44638
|
+
inventory.readyAgents(),
|
|
44639
|
+
inventory.installable,
|
|
44640
|
+
localContext,
|
|
44641
|
+
null,
|
|
44642
|
+
createCatalogAgentResolver(
|
|
44643
|
+
(refreshSignal) => discover(refreshSignal),
|
|
44644
|
+
() => config2,
|
|
44645
|
+
publishAgentCatalog
|
|
44473
44646
|
)
|
|
44474
44647
|
);
|
|
44648
|
+
return new MobiusRuntimeEngine(config2);
|
|
44475
44649
|
}
|
|
44476
44650
|
var MobiusRuntimeEngine = class {
|
|
44477
44651
|
#config;
|