@moxt-ai/mobius 0.0.192 → 0.0.194
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.d.ts +1 -1
- package/dist/acp/agent-runtime-manager.d.ts.map +1 -1
- package/dist/acp/agent-runtime-manager.js +5 -2
- package/dist/acp/agent-runtime-manager.js.map +1 -1
- package/dist/acp/agent-session.d.ts +13 -0
- package/dist/acp/agent-session.d.ts.map +1 -1
- package/dist/acp/agent-session.js +11 -2
- package/dist/acp/agent-session.js.map +1 -1
- package/dist/acp/codex/agent.d.ts +13 -0
- package/dist/acp/codex/agent.d.ts.map +1 -1
- package/dist/acp/codex/agent.js +1 -0
- package/dist/acp/codex/agent.js.map +1 -1
- package/dist/acp/codex/settings.d.ts +2 -0
- package/dist/acp/codex/settings.d.ts.map +1 -1
- package/dist/acp/codex/settings.js +23 -9
- package/dist/acp/codex/settings.js.map +1 -1
- package/dist/acp/in-process/acp-endpoint.d.ts +3 -0
- package/dist/acp/in-process/acp-endpoint.d.ts.map +1 -1
- package/dist/acp/in-process/acp-endpoint.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/acp/session-contracts.d.ts +11 -2
- package/dist/acp/session-contracts.d.ts.map +1 -1
- package/dist/acp/session-contracts.js +3 -1
- package/dist/acp/session-contracts.js.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 +10 -3
- 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 +5660 -5488
- 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 +3 -2
- 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 +3 -2
- 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 +945 -762
- 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 +963 -780
- package/dist/runtime.js.map +4 -4
- package/dist/session-event-log-v2.d.ts +3 -1
- package/dist/session-event-log-v2.d.ts.map +1 -1
- package/dist/session-event-log-v2.js +17 -3
- package/dist/session-event-log-v2.js.map +1 -1
- 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
|
|
@@ -21284,8 +21284,10 @@ var lifecycleMetadataV2Schema = external_exports.discriminatedUnion("kind", [
|
|
|
21284
21284
|
external_exports.object({
|
|
21285
21285
|
...lifecycleBase,
|
|
21286
21286
|
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
|
|
21287
|
+
disposition: shortString.optional(),
|
|
21287
21288
|
kind: external_exports.literal("prompt.requested"),
|
|
21288
|
-
context: promptExecutionContextV2Schema.optional()
|
|
21289
|
+
context: promptExecutionContextV2Schema.optional(),
|
|
21290
|
+
targetCommandId: identifierStringSchema.optional()
|
|
21289
21291
|
}).readonly(),
|
|
21290
21292
|
external_exports.object({ ...lifecycleBase, attemptId: identifierStringSchema, epoch: identifierStringSchema, kind: external_exports.literal("prompt.started") }).readonly(),
|
|
21291
21293
|
external_exports.object({ ...lifecycleBase, kind: external_exports.literal("prompt.completed"), stopReason: shortString }).readonly(),
|
|
@@ -21394,7 +21396,9 @@ var sessionEventLogPageV2Schema = external_exports.object({
|
|
|
21394
21396
|
var nativeEventPageRequestV2Schema = external_exports.object({ cursor: external_exports.string().min(1).max(512).nullable(), eventLimit: external_exports.number().int().min(1).max(1e4) }).readonly();
|
|
21395
21397
|
var queuedPromptRequestEventLogV2Schema = external_exports.object({
|
|
21396
21398
|
commandId: identifierStringSchema,
|
|
21397
|
-
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly()
|
|
21399
|
+
content: external_exports.array(contentBlockV2Schema).min(1).max(100).readonly(),
|
|
21400
|
+
disposition: shortString.optional(),
|
|
21401
|
+
targetCommandId: identifierStringSchema.optional()
|
|
21398
21402
|
}).readonly();
|
|
21399
21403
|
var nativeSessionEventsV2Schema = external_exports.object({
|
|
21400
21404
|
events: sessionEventLogPageV2Schema,
|
|
@@ -21792,15 +21796,266 @@ function normalizeAcpCapabilities(initialized) {
|
|
|
21792
21796
|
}
|
|
21793
21797
|
|
|
21794
21798
|
// src/process/executable.ts
|
|
21795
|
-
import {
|
|
21799
|
+
import { spawn } from "node:child_process";
|
|
21800
|
+
import { constants as constants2 } from "node:fs";
|
|
21801
|
+
import { access as access2, realpath as realpath2, stat as stat2 } from "node:fs/promises";
|
|
21802
|
+
import { join as join3, resolve } from "node:path";
|
|
21803
|
+
|
|
21804
|
+
// src/platform/linux.ts
|
|
21796
21805
|
import { constants, readdirSync, readFileSync } from "node:fs";
|
|
21797
21806
|
import { access, readdir, readFile, realpath, stat } from "node:fs/promises";
|
|
21798
|
-
import { join
|
|
21807
|
+
import { join } from "node:path";
|
|
21808
|
+
|
|
21809
|
+
// src/platform/posix.ts
|
|
21810
|
+
import { execFile } from "node:child_process";
|
|
21811
|
+
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21812
|
+
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21813
|
+
function parseProcessTable(output2) {
|
|
21814
|
+
const entries = [];
|
|
21815
|
+
for (const line of output2.split("\n")) {
|
|
21816
|
+
const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
|
|
21817
|
+
if (groups === void 0) {
|
|
21818
|
+
continue;
|
|
21819
|
+
}
|
|
21820
|
+
const processId = Number(groups["pid"]);
|
|
21821
|
+
const parentProcessId = Number(groups["ppid"]);
|
|
21822
|
+
const processGroupId = Number(groups["pgid"]);
|
|
21823
|
+
if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21824
|
+
continue;
|
|
21825
|
+
}
|
|
21826
|
+
entries.push({ parentProcessId, processGroupId, processId });
|
|
21827
|
+
}
|
|
21828
|
+
return entries;
|
|
21829
|
+
}
|
|
21830
|
+
function readProcessTableWithPs(executable) {
|
|
21831
|
+
return new Promise((resolveTable) => {
|
|
21832
|
+
execFile(
|
|
21833
|
+
executable,
|
|
21834
|
+
["-axo", "pid=,ppid=,pgid="],
|
|
21835
|
+
{
|
|
21836
|
+
encoding: "utf8",
|
|
21837
|
+
maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
|
|
21838
|
+
signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
|
|
21839
|
+
timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
|
|
21840
|
+
},
|
|
21841
|
+
(error62, stdout) => {
|
|
21842
|
+
resolveTable(error62 === null ? parseProcessTable(stdout) : []);
|
|
21843
|
+
}
|
|
21844
|
+
);
|
|
21845
|
+
});
|
|
21846
|
+
}
|
|
21847
|
+
function processExists(processId) {
|
|
21848
|
+
try {
|
|
21849
|
+
process.kill(processId, 0);
|
|
21850
|
+
return true;
|
|
21851
|
+
} catch {
|
|
21852
|
+
return false;
|
|
21853
|
+
}
|
|
21854
|
+
}
|
|
21855
|
+
|
|
21856
|
+
// src/platform/linux.ts
|
|
21857
|
+
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
21858
|
+
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21859
|
+
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
21860
|
+
return;
|
|
21861
|
+
}
|
|
21862
|
+
const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
|
|
21863
|
+
const parentProcessId = Number(fields[1]);
|
|
21864
|
+
const processGroupId = Number(fields[2]);
|
|
21865
|
+
if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21866
|
+
return;
|
|
21867
|
+
}
|
|
21868
|
+
entries.push({ parentProcessId, processGroupId, processId });
|
|
21869
|
+
}
|
|
21870
|
+
async function readLinuxProcessTable() {
|
|
21871
|
+
const entries = [];
|
|
21872
|
+
try {
|
|
21873
|
+
const directories = await readdir("/proc", { withFileTypes: true });
|
|
21874
|
+
for (const directory of directories) {
|
|
21875
|
+
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21876
|
+
continue;
|
|
21877
|
+
}
|
|
21878
|
+
const processId = Number(directory.name);
|
|
21879
|
+
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21880
|
+
continue;
|
|
21881
|
+
}
|
|
21882
|
+
try {
|
|
21883
|
+
appendLinuxProcessTableEntry(
|
|
21884
|
+
entries,
|
|
21885
|
+
processId,
|
|
21886
|
+
await readFile(join("/proc", directory.name, "stat"), "utf8")
|
|
21887
|
+
);
|
|
21888
|
+
} catch {
|
|
21889
|
+
}
|
|
21890
|
+
}
|
|
21891
|
+
} catch {
|
|
21892
|
+
}
|
|
21893
|
+
return entries;
|
|
21894
|
+
}
|
|
21895
|
+
function readLinuxProcessTableSynchronously() {
|
|
21896
|
+
const entries = [];
|
|
21897
|
+
try {
|
|
21898
|
+
const directories = readdirSync("/proc", { withFileTypes: true });
|
|
21899
|
+
for (const directory of directories) {
|
|
21900
|
+
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21901
|
+
continue;
|
|
21902
|
+
}
|
|
21903
|
+
const processId = Number(directory.name);
|
|
21904
|
+
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21905
|
+
continue;
|
|
21906
|
+
}
|
|
21907
|
+
try {
|
|
21908
|
+
appendLinuxProcessTableEntry(
|
|
21909
|
+
entries,
|
|
21910
|
+
processId,
|
|
21911
|
+
readFileSync(join("/proc", directory.name, "stat"), "utf8")
|
|
21912
|
+
);
|
|
21913
|
+
} catch {
|
|
21914
|
+
}
|
|
21915
|
+
}
|
|
21916
|
+
} catch {
|
|
21917
|
+
}
|
|
21918
|
+
return entries;
|
|
21919
|
+
}
|
|
21920
|
+
async function readLinuxProcessTableWithFallback() {
|
|
21921
|
+
const procfsEntries = await readLinuxProcessTable();
|
|
21922
|
+
if (procfsEntries.length > 0) {
|
|
21923
|
+
return procfsEntries;
|
|
21924
|
+
}
|
|
21925
|
+
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
21926
|
+
try {
|
|
21927
|
+
const resolvedPath = await realpath(candidate);
|
|
21928
|
+
if (!(await stat(resolvedPath)).isFile()) {
|
|
21929
|
+
continue;
|
|
21930
|
+
}
|
|
21931
|
+
await access(resolvedPath, constants.X_OK);
|
|
21932
|
+
} catch {
|
|
21933
|
+
continue;
|
|
21934
|
+
}
|
|
21935
|
+
const entries = await readProcessTableWithPs(candidate);
|
|
21936
|
+
if (entries.length > 0) {
|
|
21937
|
+
return entries;
|
|
21938
|
+
}
|
|
21939
|
+
}
|
|
21940
|
+
return [];
|
|
21941
|
+
}
|
|
21942
|
+
function processExists2(processId) {
|
|
21943
|
+
try {
|
|
21944
|
+
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
21945
|
+
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21946
|
+
if (closingParenthesis >= 0) {
|
|
21947
|
+
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
21948
|
+
if (processState === "Z" || processState === "X") {
|
|
21949
|
+
return false;
|
|
21950
|
+
}
|
|
21951
|
+
}
|
|
21952
|
+
} catch {
|
|
21953
|
+
}
|
|
21954
|
+
return processExists(processId);
|
|
21955
|
+
}
|
|
21956
|
+
var linuxPlatform = {
|
|
21957
|
+
readProcessTable: readLinuxProcessTableWithFallback,
|
|
21958
|
+
readProcessTableSynchronously: readLinuxProcessTableSynchronously,
|
|
21959
|
+
processExists: processExists2,
|
|
21960
|
+
workBuddyExecutablePaths: () => [],
|
|
21961
|
+
openCodeArchives: {
|
|
21962
|
+
arm64: {
|
|
21963
|
+
asset: "opencode-linux-arm64.tar.gz",
|
|
21964
|
+
sha256: "70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
|
|
21965
|
+
format: "tar.gz"
|
|
21966
|
+
},
|
|
21967
|
+
x64: {
|
|
21968
|
+
asset: "opencode-linux-x64.tar.gz",
|
|
21969
|
+
sha256: "ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
|
|
21970
|
+
format: "tar.gz"
|
|
21971
|
+
}
|
|
21972
|
+
},
|
|
21973
|
+
grokDependencies: {
|
|
21974
|
+
arm64: {
|
|
21975
|
+
name: "@xai-official/grok-linux-arm64",
|
|
21976
|
+
integrity: "sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
|
|
21977
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
|
|
21978
|
+
},
|
|
21979
|
+
x64: {
|
|
21980
|
+
name: "@xai-official/grok-linux-x64",
|
|
21981
|
+
integrity: "sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
|
|
21982
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
|
|
21983
|
+
}
|
|
21984
|
+
}
|
|
21985
|
+
};
|
|
21986
|
+
|
|
21987
|
+
// src/platform/macos.ts
|
|
21988
|
+
import { isAbsolute, join as join2 } from "node:path";
|
|
21989
|
+
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
21990
|
+
"WorkBuddy.app",
|
|
21991
|
+
"Contents",
|
|
21992
|
+
"Resources",
|
|
21993
|
+
"app.asar.unpacked",
|
|
21994
|
+
"cli",
|
|
21995
|
+
"bin",
|
|
21996
|
+
"codebuddy"
|
|
21997
|
+
]);
|
|
21998
|
+
var macosPlatform = {
|
|
21999
|
+
readProcessTable: () => readProcessTableWithPs("/bin/ps"),
|
|
22000
|
+
readProcessTableSynchronously: () => [],
|
|
22001
|
+
processExists,
|
|
22002
|
+
workBuddyExecutablePaths: (environment) => {
|
|
22003
|
+
const paths = [join2("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
22004
|
+
const homeDirectory = environment["HOME"];
|
|
22005
|
+
if (homeDirectory !== void 0 && isAbsolute(homeDirectory)) {
|
|
22006
|
+
paths.unshift(join2(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
22007
|
+
}
|
|
22008
|
+
return paths;
|
|
22009
|
+
},
|
|
22010
|
+
openCodeArchives: {
|
|
22011
|
+
arm64: {
|
|
22012
|
+
asset: "opencode-darwin-arm64.zip",
|
|
22013
|
+
sha256: "fe764f7f360c584a83e18dd5f23fb1a6b2725f5ee8854b0252fe558f7798e946",
|
|
22014
|
+
format: "zip"
|
|
22015
|
+
},
|
|
22016
|
+
x64: {
|
|
22017
|
+
asset: "opencode-darwin-x64.zip",
|
|
22018
|
+
sha256: "9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
|
|
22019
|
+
format: "zip"
|
|
22020
|
+
}
|
|
22021
|
+
},
|
|
22022
|
+
grokDependencies: {
|
|
22023
|
+
arm64: {
|
|
22024
|
+
name: "@xai-official/grok-darwin-arm64",
|
|
22025
|
+
integrity: "sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
|
|
22026
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
|
|
22027
|
+
},
|
|
22028
|
+
x64: {
|
|
22029
|
+
name: "@xai-official/grok-darwin-x64",
|
|
22030
|
+
integrity: "sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
|
|
22031
|
+
tarballUrl: "https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
|
|
22032
|
+
}
|
|
22033
|
+
}
|
|
22034
|
+
};
|
|
22035
|
+
|
|
22036
|
+
// src/platform/index.ts
|
|
22037
|
+
var fallbackPlatform = {
|
|
22038
|
+
readProcessTable: () => readProcessTableWithPs("/usr/bin/ps"),
|
|
22039
|
+
readProcessTableSynchronously: () => [],
|
|
22040
|
+
processExists,
|
|
22041
|
+
workBuddyExecutablePaths: () => [],
|
|
22042
|
+
openCodeArchives: {},
|
|
22043
|
+
grokDependencies: {}
|
|
22044
|
+
};
|
|
22045
|
+
var platforms = /* @__PURE__ */ new Map([
|
|
22046
|
+
["linux", linuxPlatform],
|
|
22047
|
+
["darwin", macosPlatform],
|
|
22048
|
+
["win32", { ...fallbackPlatform, readProcessTable: () => Promise.resolve([]) }]
|
|
22049
|
+
]);
|
|
22050
|
+
function platformSupportFor(platform) {
|
|
22051
|
+
return platforms.get(platform) ?? fallbackPlatform;
|
|
22052
|
+
}
|
|
22053
|
+
|
|
22054
|
+
// src/process/executable.ts
|
|
22055
|
+
var hostPlatform = platformSupportFor(process.platform);
|
|
21799
22056
|
var DEFAULT_OUTPUT_LIMIT_BYTES = 16 * 1024;
|
|
21800
22057
|
var PROCESS_GRACEFUL_STOP_TIMEOUT_MILLISECONDS = 1e3;
|
|
21801
22058
|
var PROCESS_FORCED_STOP_TIMEOUT_MILLISECONDS = 5e3;
|
|
21802
|
-
var PROCESS_TABLE_TIMEOUT_MILLISECONDS = 1e3;
|
|
21803
|
-
var PROCESS_TABLE_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
21804
22059
|
var PROCESS_EXIT_CHECK_ATTEMPTS = 16;
|
|
21805
22060
|
var GRACEFUL_STOP_SIGNAL = 15;
|
|
21806
22061
|
var FORCED_STOP_SIGNAL = 9;
|
|
@@ -21859,13 +22114,13 @@ function executableExtensions(executableName, environment, platform) {
|
|
|
21859
22114
|
async function resolveExecutablePath(requestedPath2, platform = process.platform) {
|
|
21860
22115
|
const absoluteRequestedPath = resolve(requestedPath2);
|
|
21861
22116
|
try {
|
|
21862
|
-
const resolvedPath = await
|
|
21863
|
-
const metadata = await
|
|
22117
|
+
const resolvedPath = await realpath2(absoluteRequestedPath);
|
|
22118
|
+
const metadata = await stat2(resolvedPath);
|
|
21864
22119
|
if (!metadata.isFile()) {
|
|
21865
22120
|
return null;
|
|
21866
22121
|
}
|
|
21867
22122
|
if (platform !== "win32") {
|
|
21868
|
-
await
|
|
22123
|
+
await access2(resolvedPath, constants2.X_OK);
|
|
21869
22124
|
}
|
|
21870
22125
|
return new ResolvedExecutable(
|
|
21871
22126
|
new ExecutableIdentity(
|
|
@@ -21890,7 +22145,7 @@ async function findExecutableOnPath(executableName, environment, platform = proc
|
|
|
21890
22145
|
continue;
|
|
21891
22146
|
}
|
|
21892
22147
|
for (const extension of extensions) {
|
|
21893
|
-
const requestedPath2 = resolve(
|
|
22148
|
+
const requestedPath2 = resolve(join3(entry, `${executableName}${extension}`));
|
|
21894
22149
|
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
21895
22150
|
if (executable !== null) {
|
|
21896
22151
|
return executable;
|
|
@@ -21911,128 +22166,8 @@ function appendBounded(chunks, chunk, currentBytes, limitBytes) {
|
|
|
21911
22166
|
chunks.push(chunk);
|
|
21912
22167
|
return nextBytes;
|
|
21913
22168
|
}
|
|
21914
|
-
function parseProcessTable(output2) {
|
|
21915
|
-
const entries = [];
|
|
21916
|
-
for (const line of output2.split("\n")) {
|
|
21917
|
-
const groups = /^\s*(?<pid>\d+)\s+(?<ppid>\d+)\s+(?<pgid>\d+)\s*$/.exec(line)?.groups;
|
|
21918
|
-
if (groups === void 0) {
|
|
21919
|
-
continue;
|
|
21920
|
-
}
|
|
21921
|
-
const processId = Number(groups["pid"]);
|
|
21922
|
-
const parentProcessId = Number(groups["ppid"]);
|
|
21923
|
-
const processGroupId = Number(groups["pgid"]);
|
|
21924
|
-
if (!Number.isSafeInteger(processId) || processId <= 0 || !Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21925
|
-
continue;
|
|
21926
|
-
}
|
|
21927
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
21928
|
-
}
|
|
21929
|
-
return entries;
|
|
21930
|
-
}
|
|
21931
|
-
function appendLinuxProcessTableEntry(entries, processId, encoded) {
|
|
21932
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
21933
|
-
if (!encoded.startsWith(`${processId.toString()} (`) || closingParenthesis < 0) {
|
|
21934
|
-
return;
|
|
21935
|
-
}
|
|
21936
|
-
const fields = encoded.slice(closingParenthesis + 1).trim().split(/\s+/);
|
|
21937
|
-
const parentProcessId = Number(fields[1]);
|
|
21938
|
-
const processGroupId = Number(fields[2]);
|
|
21939
|
-
if (!Number.isSafeInteger(parentProcessId) || parentProcessId < 0 || !Number.isSafeInteger(processGroupId) || processGroupId <= 0) {
|
|
21940
|
-
return;
|
|
21941
|
-
}
|
|
21942
|
-
entries.push({ parentProcessId, processGroupId, processId });
|
|
21943
|
-
}
|
|
21944
|
-
async function readLinuxProcessTable() {
|
|
21945
|
-
const entries = [];
|
|
21946
|
-
try {
|
|
21947
|
-
const directories = await readdir("/proc", { withFileTypes: true });
|
|
21948
|
-
for (const directory of directories) {
|
|
21949
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21950
|
-
continue;
|
|
21951
|
-
}
|
|
21952
|
-
const processId = Number(directory.name);
|
|
21953
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21954
|
-
continue;
|
|
21955
|
-
}
|
|
21956
|
-
try {
|
|
21957
|
-
appendLinuxProcessTableEntry(
|
|
21958
|
-
entries,
|
|
21959
|
-
processId,
|
|
21960
|
-
await readFile(join("/proc", directory.name, "stat"), "utf8")
|
|
21961
|
-
);
|
|
21962
|
-
} catch {
|
|
21963
|
-
}
|
|
21964
|
-
}
|
|
21965
|
-
} catch {
|
|
21966
|
-
}
|
|
21967
|
-
return entries;
|
|
21968
|
-
}
|
|
21969
|
-
function readLinuxProcessTableSynchronously() {
|
|
21970
|
-
const entries = [];
|
|
21971
|
-
try {
|
|
21972
|
-
const directories = readdirSync("/proc", { withFileTypes: true });
|
|
21973
|
-
for (const directory of directories) {
|
|
21974
|
-
if (!directory.isDirectory() || !/^\d+$/.test(directory.name)) {
|
|
21975
|
-
continue;
|
|
21976
|
-
}
|
|
21977
|
-
const processId = Number(directory.name);
|
|
21978
|
-
if (!Number.isSafeInteger(processId) || processId <= 0) {
|
|
21979
|
-
continue;
|
|
21980
|
-
}
|
|
21981
|
-
try {
|
|
21982
|
-
appendLinuxProcessTableEntry(
|
|
21983
|
-
entries,
|
|
21984
|
-
processId,
|
|
21985
|
-
readFileSync(join("/proc", directory.name, "stat"), "utf8")
|
|
21986
|
-
);
|
|
21987
|
-
} catch {
|
|
21988
|
-
}
|
|
21989
|
-
}
|
|
21990
|
-
} catch {
|
|
21991
|
-
}
|
|
21992
|
-
return entries;
|
|
21993
|
-
}
|
|
21994
|
-
function readProcessTableWithPs(executable) {
|
|
21995
|
-
return new Promise((resolveTable) => {
|
|
21996
|
-
execFile(
|
|
21997
|
-
executable,
|
|
21998
|
-
["-axo", "pid=,ppid=,pgid="],
|
|
21999
|
-
{
|
|
22000
|
-
encoding: "utf8",
|
|
22001
|
-
maxBuffer: PROCESS_TABLE_OUTPUT_LIMIT_BYTES,
|
|
22002
|
-
signal: AbortSignal.timeout(PROCESS_TABLE_TIMEOUT_MILLISECONDS),
|
|
22003
|
-
timeout: PROCESS_TABLE_TIMEOUT_MILLISECONDS
|
|
22004
|
-
},
|
|
22005
|
-
(error62, stdout) => {
|
|
22006
|
-
resolveTable(error62 === null ? parseProcessTable(stdout) : []);
|
|
22007
|
-
}
|
|
22008
|
-
);
|
|
22009
|
-
});
|
|
22010
|
-
}
|
|
22011
|
-
async function readLinuxProcessTableWithFallback() {
|
|
22012
|
-
const procfsEntries = await readLinuxProcessTable();
|
|
22013
|
-
if (procfsEntries.length > 0) {
|
|
22014
|
-
return procfsEntries;
|
|
22015
|
-
}
|
|
22016
|
-
for (const candidate of ["/usr/bin/ps", "/bin/ps", "/run/current-system/sw/bin/ps"]) {
|
|
22017
|
-
const executable = await resolveExecutablePath(candidate);
|
|
22018
|
-
if (executable === null) {
|
|
22019
|
-
continue;
|
|
22020
|
-
}
|
|
22021
|
-
const entries = await readProcessTableWithPs(executable.identity.requestedPath);
|
|
22022
|
-
if (entries.length > 0) {
|
|
22023
|
-
return entries;
|
|
22024
|
-
}
|
|
22025
|
-
}
|
|
22026
|
-
return [];
|
|
22027
|
-
}
|
|
22028
22169
|
function readProcessTable() {
|
|
22029
|
-
|
|
22030
|
-
return Promise.resolve([]);
|
|
22031
|
-
}
|
|
22032
|
-
if (process.platform === "linux") {
|
|
22033
|
-
return readLinuxProcessTableWithFallback();
|
|
22034
|
-
}
|
|
22035
|
-
return readProcessTableWithPs(process.platform === "darwin" ? "/bin/ps" : "/usr/bin/ps");
|
|
22170
|
+
return hostPlatform.readProcessTable();
|
|
22036
22171
|
}
|
|
22037
22172
|
function selectProcessTree(entries, rootProcessId) {
|
|
22038
22173
|
const processIds = /* @__PURE__ */ new Set([rootProcessId]);
|
|
@@ -22069,11 +22204,9 @@ async function captureProcessTree(child2) {
|
|
|
22069
22204
|
if (process.platform === "win32" || child2.pid === void 0) {
|
|
22070
22205
|
return [];
|
|
22071
22206
|
}
|
|
22072
|
-
|
|
22073
|
-
|
|
22074
|
-
|
|
22075
|
-
return selectProcessTree(procfsEntries, child2.pid);
|
|
22076
|
-
}
|
|
22207
|
+
const entries = hostPlatform.readProcessTableSynchronously();
|
|
22208
|
+
if (entries.length > 0) {
|
|
22209
|
+
return selectProcessTree(entries, child2.pid);
|
|
22077
22210
|
}
|
|
22078
22211
|
return selectProcessTree(await readProcessTable(), child2.pid);
|
|
22079
22212
|
}
|
|
@@ -22101,36 +22234,15 @@ function signalCapturedProcessGroups(processes, rootProcessId, signal) {
|
|
|
22101
22234
|
}
|
|
22102
22235
|
}
|
|
22103
22236
|
}
|
|
22104
|
-
function processExists(processId) {
|
|
22105
|
-
if (process.platform === "linux") {
|
|
22106
|
-
try {
|
|
22107
|
-
const encoded = readFileSync(join("/proc", processId.toString(), "stat"), "utf8");
|
|
22108
|
-
const closingParenthesis = encoded.lastIndexOf(")");
|
|
22109
|
-
if (closingParenthesis >= 0) {
|
|
22110
|
-
const processState = encoded.slice(closingParenthesis + 1).trimStart().charAt(0);
|
|
22111
|
-
if (processState === "Z" || processState === "X") {
|
|
22112
|
-
return false;
|
|
22113
|
-
}
|
|
22114
|
-
}
|
|
22115
|
-
} catch {
|
|
22116
|
-
}
|
|
22117
|
-
}
|
|
22118
|
-
try {
|
|
22119
|
-
process.kill(processId, 0);
|
|
22120
|
-
return true;
|
|
22121
|
-
} catch {
|
|
22122
|
-
return false;
|
|
22123
|
-
}
|
|
22124
|
-
}
|
|
22125
22237
|
async function waitForCapturedProcessesExit(processes, rootProcessId) {
|
|
22126
22238
|
const processIds = processes.map((identity2) => identity2.processId).filter((processId) => processId !== rootProcessId);
|
|
22127
22239
|
for (let attempt = 0; attempt < PROCESS_EXIT_CHECK_ATTEMPTS; attempt += 1) {
|
|
22128
|
-
if (processIds.every((processId) => !processExists(processId))) {
|
|
22240
|
+
if (processIds.every((processId) => !hostPlatform.processExists(processId))) {
|
|
22129
22241
|
return true;
|
|
22130
22242
|
}
|
|
22131
22243
|
await readProcessTable();
|
|
22132
22244
|
}
|
|
22133
|
-
return processIds.every((processId) => !processExists(processId));
|
|
22245
|
+
return processIds.every((processId) => !hostPlatform.processExists(processId));
|
|
22134
22246
|
}
|
|
22135
22247
|
function terminateProcess(child2) {
|
|
22136
22248
|
if (child2.exitCode !== null || child2.signalCode !== null || child2.pid === void 0) {
|
|
@@ -22616,8 +22728,8 @@ var LocalAgentInventory = class {
|
|
|
22616
22728
|
};
|
|
22617
22729
|
|
|
22618
22730
|
// src/agent-installation/managed-npm-package.ts
|
|
22619
|
-
import { mkdir, mkdtemp, open as open2, realpath as
|
|
22620
|
-
import { delimiter, dirname, isAbsolute, join as
|
|
22731
|
+
import { mkdir, mkdtemp, open as open2, realpath as realpath3, rename, rm, stat as stat3 } from "node:fs/promises";
|
|
22732
|
+
import { delimiter, dirname, isAbsolute as isAbsolute2, join as join4, relative, sep } from "node:path";
|
|
22621
22733
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
22622
22734
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
22623
22735
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -22668,11 +22780,11 @@ function isRecord3(value) {
|
|
|
22668
22780
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22669
22781
|
}
|
|
22670
22782
|
function packagePath(root, packageName) {
|
|
22671
|
-
return
|
|
22783
|
+
return join4(root, "node_modules", ...packageName.split("/"));
|
|
22672
22784
|
}
|
|
22673
22785
|
function isContainedPath(root, candidate) {
|
|
22674
22786
|
const difference = relative(root, candidate);
|
|
22675
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !
|
|
22787
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep}`) && !isAbsolute2(difference);
|
|
22676
22788
|
}
|
|
22677
22789
|
async function readJsonRecord(path2, maximumBytes) {
|
|
22678
22790
|
try {
|
|
@@ -22773,14 +22885,14 @@ function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
|
22773
22885
|
}
|
|
22774
22886
|
}
|
|
22775
22887
|
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
22776
|
-
const dependencyRoot = await
|
|
22888
|
+
const dependencyRoot = await realpath3(packagePath(rootPath, definition.packageName));
|
|
22777
22889
|
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
22778
22890
|
throw new ManagedNpmPackageError(
|
|
22779
22891
|
"managed_package_verification_failed",
|
|
22780
22892
|
"The required managed npm dependency escaped its private cache"
|
|
22781
22893
|
);
|
|
22782
22894
|
}
|
|
22783
|
-
const metadata = await readJsonRecord(
|
|
22895
|
+
const metadata = await readJsonRecord(join4(dependencyRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22784
22896
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22785
22897
|
throw new ManagedNpmPackageError(
|
|
22786
22898
|
"managed_package_verification_failed",
|
|
@@ -22802,15 +22914,15 @@ async function validateManagedNpmPackage(root, definition) {
|
|
|
22802
22914
|
}
|
|
22803
22915
|
}
|
|
22804
22916
|
async function validateManagedNpmPackageContents(root, definition) {
|
|
22805
|
-
const rootPath = await
|
|
22806
|
-
const packageRoot = await
|
|
22917
|
+
const rootPath = await realpath3(root);
|
|
22918
|
+
const packageRoot = await realpath3(packagePath(rootPath, definition.packageName));
|
|
22807
22919
|
if (!isContainedPath(rootPath, packageRoot)) {
|
|
22808
22920
|
throw new ManagedNpmPackageError(
|
|
22809
22921
|
"managed_package_verification_failed",
|
|
22810
22922
|
"The managed npm package escaped its private cache"
|
|
22811
22923
|
);
|
|
22812
22924
|
}
|
|
22813
|
-
const metadata = await readJsonRecord(
|
|
22925
|
+
const metadata = await readJsonRecord(join4(packageRoot, "package.json"), PACKAGE_METADATA_LIMIT_BYTES);
|
|
22814
22926
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
22815
22927
|
throw new ManagedNpmPackageError(
|
|
22816
22928
|
"managed_package_verification_failed",
|
|
@@ -22818,14 +22930,14 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
22818
22930
|
);
|
|
22819
22931
|
}
|
|
22820
22932
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
22821
|
-
const lock = await readJsonRecord(
|
|
22933
|
+
const lock = await readJsonRecord(join4(rootPath, "package-lock.json"), PACKAGE_LOCK_LIMIT_BYTES);
|
|
22822
22934
|
verifyPackageLockEntry(lock, definition, definition.verifyDependencyClosure);
|
|
22823
22935
|
for (const dependency of definition.requiredDependencies) {
|
|
22824
22936
|
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
22825
22937
|
}
|
|
22826
22938
|
}
|
|
22827
22939
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
22828
|
-
const executable = await resolveExecutablePath(
|
|
22940
|
+
const executable = await resolveExecutablePath(join4(packageRoot, declaredBin));
|
|
22829
22941
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
22830
22942
|
throw new ManagedNpmPackageError(
|
|
22831
22943
|
"managed_package_verification_failed",
|
|
@@ -22838,7 +22950,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22838
22950
|
install = async (root, definition, environment, signal) => {
|
|
22839
22951
|
signal.throwIfAborted();
|
|
22840
22952
|
try {
|
|
22841
|
-
const metadata = await
|
|
22953
|
+
const metadata = await stat3(root);
|
|
22842
22954
|
if (metadata.isDirectory()) {
|
|
22843
22955
|
return await validateManagedNpmPackage(root, definition);
|
|
22844
22956
|
}
|
|
@@ -22849,7 +22961,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22849
22961
|
}
|
|
22850
22962
|
const parent = dirname(root);
|
|
22851
22963
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
22852
|
-
const staging = await mkdtemp(
|
|
22964
|
+
const staging = await mkdtemp(join4(parent, `.${definition.version}.staging-`));
|
|
22853
22965
|
try {
|
|
22854
22966
|
const npm = await findExecutableOnPath(process.platform === "win32" ? "npm.cmd" : "npm", environment);
|
|
22855
22967
|
if (npm === null) {
|
|
@@ -22875,9 +22987,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22875
22987
|
`${definition.packageName}@${definition.version}`
|
|
22876
22988
|
);
|
|
22877
22989
|
const installEnvironment = {
|
|
22878
|
-
HOME:
|
|
22990
|
+
HOME: join4(staging, "home"),
|
|
22879
22991
|
NPM_CONFIG_AUDIT: "false",
|
|
22880
|
-
NPM_CONFIG_CACHE:
|
|
22992
|
+
NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
|
|
22881
22993
|
NPM_CONFIG_FUND: "false",
|
|
22882
22994
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
22883
22995
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
@@ -22899,8 +23011,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22899
23011
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
22900
23012
|
});
|
|
22901
23013
|
await Promise.all([
|
|
22902
|
-
rm(
|
|
22903
|
-
rm(
|
|
23014
|
+
rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
23015
|
+
rm(join4(staging, "home"), { force: true, recursive: true })
|
|
22904
23016
|
]);
|
|
22905
23017
|
await validateManagedNpmPackage(staging, definition);
|
|
22906
23018
|
try {
|
|
@@ -22936,7 +23048,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
22936
23048
|
};
|
|
22937
23049
|
|
|
22938
23050
|
// src/agent-catalog/agent-specification.ts
|
|
22939
|
-
import { join as
|
|
23051
|
+
import { join as join5 } from "node:path";
|
|
22940
23052
|
|
|
22941
23053
|
// src/agent-catalog/version-output.ts
|
|
22942
23054
|
function normalizeVersionOutput(output2) {
|
|
@@ -22959,7 +23071,7 @@ var LocalAgentSpecification = class {
|
|
|
22959
23071
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
22960
23072
|
signal.throwIfAborted();
|
|
22961
23073
|
const executable = await resolveExecutablePath(
|
|
22962
|
-
|
|
23074
|
+
join5(stateDirectory, ...this.managedAgentExecutablePath),
|
|
22963
23075
|
platform
|
|
22964
23076
|
);
|
|
22965
23077
|
signal.throwIfAborted();
|
|
@@ -23163,7 +23275,7 @@ function sessionFailureMeta(failure2) {
|
|
|
23163
23275
|
import { spawn as spawn2 } from "node:child_process";
|
|
23164
23276
|
|
|
23165
23277
|
// src/acp/codex/app-server-protocol.ts
|
|
23166
|
-
import { isAbsolute as
|
|
23278
|
+
import { isAbsolute as isAbsolute3 } from "node:path";
|
|
23167
23279
|
var boundedText = (maximum) => external_exports.string().max(maximum);
|
|
23168
23280
|
var jsonValue = external_exports.lazy(() => external_exports.unknown());
|
|
23169
23281
|
var requestIdSchema = external_exports.union([external_exports.number(), external_exports.string()]).refine((value) => typeof value === "number" || value.length <= 256);
|
|
@@ -23234,7 +23346,7 @@ var imageGenerationItemSchema = external_exports.object({
|
|
|
23234
23346
|
});
|
|
23235
23347
|
var threadItemSchema = external_exports.discriminatedUnion("type", [
|
|
23236
23348
|
imageGenerationItemSchema,
|
|
23237
|
-
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(
|
|
23349
|
+
external_exports.object({ type: external_exports.literal("imageView"), id: boundedText(256), path: boundedText(32768).refine(isAbsolute3) }),
|
|
23238
23350
|
external_exports.object({
|
|
23239
23351
|
id: boundedText(256),
|
|
23240
23352
|
text: boundedText(1e6),
|
|
@@ -23917,7 +24029,7 @@ function effortValues(model) {
|
|
|
23917
24029
|
}));
|
|
23918
24030
|
}
|
|
23919
24031
|
function supportedSelection(models, reportedModel, reportedEffort) {
|
|
23920
|
-
const model = models.find((candidate) => candidate.id === reportedModel)
|
|
24032
|
+
const model = models.find((candidate) => candidate.id === reportedModel);
|
|
23921
24033
|
if (model === void 0) {
|
|
23922
24034
|
return { model: reportedModel, effort: reportedEffort };
|
|
23923
24035
|
}
|
|
@@ -23928,7 +24040,11 @@ function supportedSelection(models, reportedModel, reportedEffort) {
|
|
|
23928
24040
|
};
|
|
23929
24041
|
}
|
|
23930
24042
|
function modelSetting(models, currentValue) {
|
|
23931
|
-
const
|
|
24043
|
+
const catalogValues = modelValues(models);
|
|
24044
|
+
const values = currentValue.length > 0 && !catalogValues.some((value) => value.value === currentValue) ? [
|
|
24045
|
+
{ description: "Current model configured in Codex", name: currentValue, value: currentValue },
|
|
24046
|
+
...catalogValues
|
|
24047
|
+
] : catalogValues;
|
|
23932
24048
|
const current = values.some((value) => value.value === currentValue) ? currentValue : models.find((model) => model.isDefault === true)?.id ?? values[0]?.value ?? "";
|
|
23933
24049
|
if (current.length === 0) {
|
|
23934
24050
|
return null;
|
|
@@ -24046,7 +24162,8 @@ var CodexSettings = class {
|
|
|
24046
24162
|
turnParameters = () => {
|
|
24047
24163
|
const selection = this.#selection;
|
|
24048
24164
|
const mode = AGENT_MODES.find((candidate) => candidate.id === selection.mode) ?? DEFAULT_MODE;
|
|
24049
|
-
const
|
|
24165
|
+
const model = this.#model(selection.model);
|
|
24166
|
+
const supportsFast = model?.additionalSpeedTiers?.includes(FAST_TIER) === true;
|
|
24050
24167
|
return {
|
|
24051
24168
|
approvalPolicy: mode.approvalPolicy,
|
|
24052
24169
|
approvalsReviewer: mode.approvalsReviewer,
|
|
@@ -24064,8 +24181,8 @@ var CodexSettings = class {
|
|
|
24064
24181
|
}
|
|
24065
24182
|
}
|
|
24066
24183
|
} : {},
|
|
24067
|
-
...selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
24068
|
-
...
|
|
24184
|
+
...model === void 0 || selection.effort.length === 0 ? {} : { effort: selection.effort },
|
|
24185
|
+
...model === void 0 ? {} : { model: model.id },
|
|
24069
24186
|
...selection.fastMode && supportsFast ? { serviceTier: SERVICE_TIER_FAST } : {}
|
|
24070
24187
|
};
|
|
24071
24188
|
};
|
|
@@ -24134,6 +24251,18 @@ var CodexSettings = class {
|
|
|
24134
24251
|
options.push(modeSetting(this.#selection.mode));
|
|
24135
24252
|
return options;
|
|
24136
24253
|
};
|
|
24254
|
+
agentModelEffort = () => ({
|
|
24255
|
+
effortSettingId: REASONING_EFFORT_SETTING_ID,
|
|
24256
|
+
modelSettingId: MODEL_SETTING_ID,
|
|
24257
|
+
resolution: AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE,
|
|
24258
|
+
unsupportedModelIds: [],
|
|
24259
|
+
valuesByModel: Object.fromEntries(
|
|
24260
|
+
this.#models.map((model) => [
|
|
24261
|
+
model.id,
|
|
24262
|
+
effortValues(model).map((value) => ({ ...value, groupId: "", groupName: "" }))
|
|
24263
|
+
])
|
|
24264
|
+
)
|
|
24265
|
+
});
|
|
24137
24266
|
selectRestoredThread = (thread) => {
|
|
24138
24267
|
const supported = supportedSelection(
|
|
24139
24268
|
this.#models,
|
|
@@ -24519,6 +24648,7 @@ var CodexAcpAgent = class {
|
|
|
24519
24648
|
await this.#interruptTurn();
|
|
24520
24649
|
});
|
|
24521
24650
|
}
|
|
24651
|
+
agentSettingsModelEffort = () => this.#settings.agentModelEffort();
|
|
24522
24652
|
/** The ACP agent app Mobius connects its own ACP client to, in-process. */
|
|
24523
24653
|
app = () => this.#app;
|
|
24524
24654
|
nativeTurnId = () => this.#nativeTurnId;
|
|
@@ -25082,15 +25212,15 @@ var AgentProbeError = class extends Error {
|
|
|
25082
25212
|
};
|
|
25083
25213
|
|
|
25084
25214
|
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
25085
|
-
import { isAbsolute as
|
|
25215
|
+
import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
|
|
25086
25216
|
async function resolveUserLocalExecutable(executableName, context) {
|
|
25087
25217
|
context.signal.throwIfAborted();
|
|
25088
25218
|
const platform = context.platform ?? process.platform;
|
|
25089
25219
|
const homeDirectory = context.environment["HOME"];
|
|
25090
|
-
if (platform === "win32" || homeDirectory === void 0 || !
|
|
25220
|
+
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
25091
25221
|
return [];
|
|
25092
25222
|
}
|
|
25093
|
-
const executable = await resolveExecutablePath(
|
|
25223
|
+
const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
|
|
25094
25224
|
context.signal.throwIfAborted();
|
|
25095
25225
|
return executable === null ? [] : [executable];
|
|
25096
25226
|
}
|
|
@@ -25179,8 +25309,8 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25179
25309
|
};
|
|
25180
25310
|
|
|
25181
25311
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
25182
|
-
import { mkdir as mkdir2, realpath as
|
|
25183
|
-
import { isAbsolute as
|
|
25312
|
+
import { mkdir as mkdir2, realpath as realpath4, stat as stat4, writeFile } from "node:fs/promises";
|
|
25313
|
+
import { isAbsolute as isAbsolute5, join as join8, normalize } from "node:path";
|
|
25184
25314
|
|
|
25185
25315
|
// src/agent-installation/deepseek-managed-package.ts
|
|
25186
25316
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -25198,13 +25328,13 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
25198
25328
|
|
|
25199
25329
|
// src/storage/state-directory.ts
|
|
25200
25330
|
import { homedir } from "node:os";
|
|
25201
|
-
import { join as
|
|
25331
|
+
import { join as join7, resolve as resolve2 } from "node:path";
|
|
25202
25332
|
function readStateDirectory(environment = process.env) {
|
|
25203
25333
|
const configured = environment["MOBIUS_STATE_DIRECTORY"]?.trim();
|
|
25204
25334
|
if (configured !== void 0 && configured.length > 0) {
|
|
25205
25335
|
return resolve2(configured);
|
|
25206
25336
|
}
|
|
25207
|
-
return
|
|
25337
|
+
return join7(homedir(), ".mobius");
|
|
25208
25338
|
}
|
|
25209
25339
|
|
|
25210
25340
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
@@ -25215,20 +25345,20 @@ var DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH = `# Managed by Mobius: pin the ACP brid
|
|
|
25215
25345
|
model: deepseek-v4-flash-vision-exp
|
|
25216
25346
|
`;
|
|
25217
25347
|
async function prepareAgentHome(path2, imagePrompts) {
|
|
25218
|
-
if (!
|
|
25348
|
+
if (!isAbsolute5(path2) || normalize(path2) !== path2) {
|
|
25219
25349
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
25220
25350
|
}
|
|
25221
25351
|
try {
|
|
25222
25352
|
if (imagePrompts) {
|
|
25223
25353
|
await mkdir2(path2, { mode: 448, recursive: true });
|
|
25224
25354
|
}
|
|
25225
|
-
const resolved = await
|
|
25226
|
-
const metadata = await
|
|
25355
|
+
const resolved = await realpath4(path2);
|
|
25356
|
+
const metadata = await stat4(resolved);
|
|
25227
25357
|
if (!metadata.isDirectory() || typeof process.getuid === "function" && metadata.uid !== process.getuid()) {
|
|
25228
25358
|
throw new Error("Agent home is not a user-owned directory");
|
|
25229
25359
|
}
|
|
25230
25360
|
if (imagePrompts) {
|
|
25231
|
-
await writeFile(
|
|
25361
|
+
await writeFile(join8(resolved, "cordis.patch.yml"), DEEPSEEK_HARNESS_IMAGE_PROMPT_PATCH, {
|
|
25232
25362
|
mode: 384
|
|
25233
25363
|
});
|
|
25234
25364
|
}
|
|
@@ -25276,7 +25406,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25276
25406
|
context.signal
|
|
25277
25407
|
);
|
|
25278
25408
|
if (managed.path === agent.path) {
|
|
25279
|
-
selectedHome =
|
|
25409
|
+
selectedHome = join8(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
25280
25410
|
managedHome = true;
|
|
25281
25411
|
}
|
|
25282
25412
|
} catch {
|
|
@@ -25292,7 +25422,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25292
25422
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
25293
25423
|
signal.throwIfAborted();
|
|
25294
25424
|
const executable = await validateManagedNpmPackage(
|
|
25295
|
-
|
|
25425
|
+
join8(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
25296
25426
|
DEEPSEEK_HARNESS_PACKAGE
|
|
25297
25427
|
);
|
|
25298
25428
|
signal.throwIfAborted();
|
|
@@ -25346,8 +25476,8 @@ var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25346
25476
|
};
|
|
25347
25477
|
|
|
25348
25478
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25349
|
-
import { realpath as
|
|
25350
|
-
import { isAbsolute as
|
|
25479
|
+
import { realpath as realpath5 } from "node:fs/promises";
|
|
25480
|
+
import { isAbsolute as isAbsolute6, join as join9, relative as relative2, sep as sep2 } from "node:path";
|
|
25351
25481
|
import {
|
|
25352
25482
|
RequestError
|
|
25353
25483
|
} from "@agentclientprotocol/sdk";
|
|
@@ -25370,50 +25500,25 @@ var GrokBuildManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
|
25370
25500
|
this.requiredDependencies = Object.freeze([requiredDependency]);
|
|
25371
25501
|
}
|
|
25372
25502
|
};
|
|
25373
|
-
var GROK_DARWIN_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25374
|
-
"@xai-official/grok-darwin-arm64",
|
|
25375
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25376
|
-
"sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
|
|
25377
|
-
"https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
|
|
25378
|
-
);
|
|
25379
|
-
var GROK_DARWIN_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25380
|
-
"@xai-official/grok-darwin-x64",
|
|
25381
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25382
|
-
"sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
|
|
25383
|
-
"https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
|
|
25384
|
-
);
|
|
25385
|
-
var GROK_LINUX_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25386
|
-
"@xai-official/grok-linux-arm64",
|
|
25387
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25388
|
-
"sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
|
|
25389
|
-
"https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
|
|
25390
|
-
);
|
|
25391
|
-
var GROK_LINUX_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25392
|
-
"@xai-official/grok-linux-x64",
|
|
25393
|
-
GROK_BUILD_MANAGED_VERSION,
|
|
25394
|
-
"sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
|
|
25395
|
-
"https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
|
|
25396
|
-
);
|
|
25397
25503
|
function grokBuildManagedPackage(platform, architecture) {
|
|
25398
|
-
|
|
25399
|
-
|
|
25400
|
-
|
|
25401
|
-
if (platform === "darwin" && architecture === "x64") {
|
|
25402
|
-
return new GrokBuildManagedPackage(GROK_DARWIN_X64_PACKAGE);
|
|
25403
|
-
}
|
|
25404
|
-
if (platform === "linux" && architecture === "arm64") {
|
|
25405
|
-
return new GrokBuildManagedPackage(GROK_LINUX_ARM64_PACKAGE);
|
|
25406
|
-
}
|
|
25407
|
-
if (platform === "linux" && architecture === "x64") {
|
|
25408
|
-
return new GrokBuildManagedPackage(GROK_LINUX_X64_PACKAGE);
|
|
25504
|
+
const release = platformSupportFor(platform).grokDependencies[architecture];
|
|
25505
|
+
if (release === void 0) {
|
|
25506
|
+
throw new Error("Grok Build does not publish a package for this platform");
|
|
25409
25507
|
}
|
|
25410
|
-
|
|
25508
|
+
return new GrokBuildManagedPackage(
|
|
25509
|
+
new SriManagedNpmDependencyDefinition(
|
|
25510
|
+
release.name,
|
|
25511
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25512
|
+
release.integrity,
|
|
25513
|
+
release.tarballUrl
|
|
25514
|
+
)
|
|
25515
|
+
);
|
|
25411
25516
|
}
|
|
25412
25517
|
|
|
25413
25518
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25414
25519
|
function isContainedPath2(root, candidate) {
|
|
25415
25520
|
const difference = relative2(root, candidate);
|
|
25416
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !
|
|
25521
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute6(difference);
|
|
25417
25522
|
}
|
|
25418
25523
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
25419
25524
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -25442,8 +25547,8 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25442
25547
|
);
|
|
25443
25548
|
if (managed.path === agent.path) {
|
|
25444
25549
|
return Object.freeze({
|
|
25445
|
-
GROK_HOME: await
|
|
25446
|
-
|
|
25550
|
+
GROK_HOME: await realpath5(
|
|
25551
|
+
join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
25447
25552
|
)
|
|
25448
25553
|
});
|
|
25449
25554
|
}
|
|
@@ -25454,9 +25559,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25454
25559
|
};
|
|
25455
25560
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
25456
25561
|
signal.throwIfAborted();
|
|
25457
|
-
const versionRoot = await
|
|
25458
|
-
await validateManagedNpmPackage(
|
|
25459
|
-
const executable = await resolveExecutablePath(
|
|
25562
|
+
const versionRoot = await realpath5(join9(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
25563
|
+
await validateManagedNpmPackage(join9(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
25564
|
+
const executable = await resolveExecutablePath(join9(versionRoot, "home", "bin", "grok"), platform);
|
|
25460
25565
|
signal.throwIfAborted();
|
|
25461
25566
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
25462
25567
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -25556,13 +25661,13 @@ var OhMyPiAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25556
25661
|
};
|
|
25557
25662
|
|
|
25558
25663
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
25559
|
-
import { join as
|
|
25664
|
+
import { join as join11 } from "node:path";
|
|
25560
25665
|
|
|
25561
25666
|
// src/agent-installation/managed-agent-archive.ts
|
|
25562
25667
|
import { createHash } from "node:crypto";
|
|
25563
25668
|
import { createReadStream } from "node:fs";
|
|
25564
|
-
import { chmod, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as
|
|
25565
|
-
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as
|
|
25669
|
+
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";
|
|
25670
|
+
import { delimiter as delimiter2, dirname as dirname2, isAbsolute as isAbsolute7, join as join10, relative as relative3, sep as sep3 } from "node:path";
|
|
25566
25671
|
|
|
25567
25672
|
// src/agent-installation/verified-download.ts
|
|
25568
25673
|
import { fetch } from "undici";
|
|
@@ -25668,7 +25773,7 @@ function isRecord5(value) {
|
|
|
25668
25773
|
}
|
|
25669
25774
|
function isContainedPath3(root, candidate) {
|
|
25670
25775
|
const difference = relative3(root, candidate);
|
|
25671
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !
|
|
25776
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute7(difference);
|
|
25672
25777
|
}
|
|
25673
25778
|
async function hashFile(path2, signal) {
|
|
25674
25779
|
signal.throwIfAborted();
|
|
@@ -25742,16 +25847,16 @@ async function readManifest(path2) {
|
|
|
25742
25847
|
}
|
|
25743
25848
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
25744
25849
|
try {
|
|
25745
|
-
const rootPath = await
|
|
25746
|
-
const rootMetadata = await
|
|
25850
|
+
const rootPath = await realpath6(root);
|
|
25851
|
+
const rootMetadata = await stat5(rootPath);
|
|
25747
25852
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
25748
25853
|
throw new Error("Managed Agent root is not user-owned");
|
|
25749
25854
|
}
|
|
25750
|
-
const manifest = await readManifest(
|
|
25855
|
+
const manifest = await readManifest(join10(rootPath, "archive.json"));
|
|
25751
25856
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
25752
25857
|
throw new Error("Managed Agent archive identity is invalid");
|
|
25753
25858
|
}
|
|
25754
|
-
const executable = await resolveExecutablePath(
|
|
25859
|
+
const executable = await resolveExecutablePath(join10(rootPath, "bin", definition.executableName));
|
|
25755
25860
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
25756
25861
|
throw new Error("Managed Agent executable is invalid");
|
|
25757
25862
|
}
|
|
@@ -25777,47 +25882,21 @@ function releaseUrl(asset) {
|
|
|
25777
25882
|
return new URL(`https://github.com/anomalyco/opencode/releases/download/v${OPENCODE_MANAGED_VERSION}/${asset}`);
|
|
25778
25883
|
}
|
|
25779
25884
|
function openCodeManagedArchive(platform, architecture) {
|
|
25780
|
-
|
|
25781
|
-
|
|
25782
|
-
|
|
25783
|
-
|
|
25784
|
-
|
|
25785
|
-
|
|
25786
|
-
|
|
25787
|
-
|
|
25788
|
-
|
|
25789
|
-
|
|
25790
|
-
|
|
25791
|
-
|
|
25792
|
-
|
|
25793
|
-
|
|
25794
|
-
|
|
25795
|
-
releaseUrl(asset),
|
|
25796
|
-
"9858853e7bacdbbd22c2d70c377e009dc4b354dd04f5588705411e7afb89fd2d",
|
|
25797
|
-
"opencode"
|
|
25798
|
-
);
|
|
25799
|
-
}
|
|
25800
|
-
if (platform === "linux" && architecture === "arm64") {
|
|
25801
|
-
const asset = "opencode-linux-arm64.tar.gz";
|
|
25802
|
-
return new TarGzipManagedAgentArchiveDefinition(
|
|
25803
|
-
OPENCODE_MANAGED_VERSION,
|
|
25804
|
-
asset,
|
|
25805
|
-
releaseUrl(asset),
|
|
25806
|
-
"70baf769395ca4e7a68924026530c390eace194f3b7e4919d4efcb2aa2eed3c0",
|
|
25807
|
-
"opencode"
|
|
25808
|
-
);
|
|
25809
|
-
}
|
|
25810
|
-
if (platform === "linux" && architecture === "x64") {
|
|
25811
|
-
const asset = "opencode-linux-x64.tar.gz";
|
|
25812
|
-
return new TarGzipManagedAgentArchiveDefinition(
|
|
25813
|
-
OPENCODE_MANAGED_VERSION,
|
|
25814
|
-
asset,
|
|
25815
|
-
releaseUrl(asset),
|
|
25816
|
-
"ea800b7ff56226b70952126c9fc1e2517ca4c4b5682fd9d3f9e87449697a1194",
|
|
25817
|
-
"opencode"
|
|
25818
|
-
);
|
|
25819
|
-
}
|
|
25820
|
-
throw new Error("OpenCode does not publish an approved archive for this platform");
|
|
25885
|
+
const release = platformSupportFor(platform).openCodeArchives[architecture];
|
|
25886
|
+
if (release === void 0) {
|
|
25887
|
+
throw new Error("OpenCode does not publish an approved archive for this platform");
|
|
25888
|
+
}
|
|
25889
|
+
const Definition = {
|
|
25890
|
+
zip: ZipManagedAgentArchiveDefinition,
|
|
25891
|
+
"tar.gz": TarGzipManagedAgentArchiveDefinition
|
|
25892
|
+
}[release.format];
|
|
25893
|
+
return new Definition(
|
|
25894
|
+
OPENCODE_MANAGED_VERSION,
|
|
25895
|
+
release.asset,
|
|
25896
|
+
releaseUrl(release.asset),
|
|
25897
|
+
release.sha256,
|
|
25898
|
+
"opencode"
|
|
25899
|
+
);
|
|
25821
25900
|
}
|
|
25822
25901
|
|
|
25823
25902
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
@@ -25943,7 +26022,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25943
26022
|
return Object.freeze(environment);
|
|
25944
26023
|
};
|
|
25945
26024
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
25946
|
-
|
|
26025
|
+
join11(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
25947
26026
|
openCodeManagedArchive(platform, process.arch),
|
|
25948
26027
|
signal
|
|
25949
26028
|
);
|
|
@@ -25961,7 +26040,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25961
26040
|
};
|
|
25962
26041
|
|
|
25963
26042
|
// src/agent-catalog/agents/pi-agent.ts
|
|
25964
|
-
import { join as
|
|
26043
|
+
import { join as join12 } from "node:path";
|
|
25965
26044
|
import {
|
|
25966
26045
|
methods as methods4
|
|
25967
26046
|
} from "@agentclientprotocol/sdk";
|
|
@@ -26020,7 +26099,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26020
26099
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26021
26100
|
signal.throwIfAborted();
|
|
26022
26101
|
const executable = await validateManagedNpmPackage(
|
|
26023
|
-
|
|
26102
|
+
join12(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
26024
26103
|
PI_AGENT_PACKAGE
|
|
26025
26104
|
);
|
|
26026
26105
|
signal.throwIfAborted();
|
|
@@ -26058,7 +26137,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26058
26137
|
};
|
|
26059
26138
|
|
|
26060
26139
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26061
|
-
import {
|
|
26140
|
+
import { join as join13 } from "node:path";
|
|
26062
26141
|
|
|
26063
26142
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
26064
26143
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -26076,15 +26155,6 @@ var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
|
|
|
26076
26155
|
);
|
|
26077
26156
|
|
|
26078
26157
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26079
|
-
var WORKBUDDY_MACOS_EXECUTABLE_PATH = Object.freeze([
|
|
26080
|
-
"WorkBuddy.app",
|
|
26081
|
-
"Contents",
|
|
26082
|
-
"Resources",
|
|
26083
|
-
"app.asar.unpacked",
|
|
26084
|
-
"cli",
|
|
26085
|
-
"bin",
|
|
26086
|
-
"codebuddy"
|
|
26087
|
-
]);
|
|
26088
26158
|
var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26089
26159
|
adapterVersion = WORKBUDDY_MANAGED_VERSION;
|
|
26090
26160
|
authenticationCommand = () => "codebuddy";
|
|
@@ -26113,7 +26183,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26113
26183
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26114
26184
|
signal.throwIfAborted();
|
|
26115
26185
|
const executable = await validateManagedNpmPackage(
|
|
26116
|
-
|
|
26186
|
+
join13(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
26117
26187
|
WORKBUDDY_MANAGED_PACKAGE
|
|
26118
26188
|
);
|
|
26119
26189
|
signal.throwIfAborted();
|
|
@@ -26121,17 +26191,11 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26121
26191
|
};
|
|
26122
26192
|
resolveInstalledAgentExecutables = async (context) => {
|
|
26123
26193
|
context.signal.throwIfAborted();
|
|
26124
|
-
|
|
26125
|
-
|
|
26126
|
-
}
|
|
26127
|
-
const requestedPaths = [join11("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
26128
|
-
const homeDirectory = context.environment["HOME"];
|
|
26129
|
-
if (homeDirectory !== void 0 && isAbsolute7(homeDirectory)) {
|
|
26130
|
-
requestedPaths.unshift(join11(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
26131
|
-
}
|
|
26194
|
+
const platform = context.platform ?? process.platform;
|
|
26195
|
+
const requestedPaths = platformSupportFor(platform).workBuddyExecutablePaths(context.environment);
|
|
26132
26196
|
const executables = [];
|
|
26133
26197
|
for (const requestedPath2 of requestedPaths) {
|
|
26134
|
-
const executable = await resolveExecutablePath(requestedPath2,
|
|
26198
|
+
const executable = await resolveExecutablePath(requestedPath2, platform);
|
|
26135
26199
|
context.signal.throwIfAborted();
|
|
26136
26200
|
if (executable !== null) {
|
|
26137
26201
|
executables.push(executable);
|
|
@@ -26491,10 +26555,10 @@ function isAgentVersionSupported(reportedVersion, minimumSupportedVersion) {
|
|
|
26491
26555
|
}
|
|
26492
26556
|
|
|
26493
26557
|
// src/agent-catalog/executable-discovery.ts
|
|
26494
|
-
import { isAbsolute as isAbsolute8, join as
|
|
26558
|
+
import { isAbsolute as isAbsolute8, join as join15 } from "node:path";
|
|
26495
26559
|
|
|
26496
26560
|
// src/agent-installation/managed-adapter-installer.ts
|
|
26497
|
-
import { join as
|
|
26561
|
+
import { join as join14 } from "node:path";
|
|
26498
26562
|
var ManagedAdapterInstallError = class extends Error {
|
|
26499
26563
|
code;
|
|
26500
26564
|
constructor(code, message, options = {}) {
|
|
@@ -26551,7 +26615,7 @@ var ManagedAdapterInstaller = class {
|
|
|
26551
26615
|
this.#stateDirectory = options.stateDirectory;
|
|
26552
26616
|
}
|
|
26553
26617
|
install = async (specification, signal) => {
|
|
26554
|
-
const root =
|
|
26618
|
+
const root = join14(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
26555
26619
|
try {
|
|
26556
26620
|
return await this.#npmInstaller.install(
|
|
26557
26621
|
root,
|
|
@@ -26585,7 +26649,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
26585
26649
|
let managed;
|
|
26586
26650
|
try {
|
|
26587
26651
|
managed = await validateManagedAdapter(
|
|
26588
|
-
|
|
26652
|
+
join15(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
26589
26653
|
specification
|
|
26590
26654
|
);
|
|
26591
26655
|
} catch {
|
|
@@ -26898,28 +26962,122 @@ async function discoverLocalAgentInventory(options) {
|
|
|
26898
26962
|
return new LocalAgentInventory(results);
|
|
26899
26963
|
}
|
|
26900
26964
|
|
|
26901
|
-
// src/
|
|
26902
|
-
|
|
26903
|
-
|
|
26904
|
-
|
|
26905
|
-
|
|
26906
|
-
|
|
26907
|
-
|
|
26965
|
+
// src/agent-catalog/publish-agent-catalog.ts
|
|
26966
|
+
import { fetch as fetch2 } from "undici";
|
|
26967
|
+
|
|
26968
|
+
// src/relay-connection/runtime-authentication.ts
|
|
26969
|
+
function runtimeCredential(relayUrl) {
|
|
26970
|
+
return relayUrl.searchParams.get("token") ?? "";
|
|
26971
|
+
}
|
|
26972
|
+
function runtimeAuthorization(relayUrl) {
|
|
26973
|
+
const credential = runtimeCredential(relayUrl);
|
|
26974
|
+
return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
|
|
26975
|
+
}
|
|
26976
|
+
function relayHttpEndpoint(relayUrl) {
|
|
26977
|
+
const endpoint = new URL(relayUrl);
|
|
26978
|
+
endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
|
|
26979
|
+
endpoint.search = "";
|
|
26980
|
+
return endpoint;
|
|
26981
|
+
}
|
|
26982
|
+
|
|
26983
|
+
// src/agent-catalog/publish-agent-catalog.ts
|
|
26984
|
+
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
26985
|
+
var AgentCatalogPublishError = class extends Error {
|
|
26986
|
+
code = "agent_catalog_update_failed";
|
|
26987
|
+
diagnosticDetails;
|
|
26988
|
+
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
26989
|
+
super(message, options);
|
|
26990
|
+
this.diagnosticDetails = diagnosticDetails;
|
|
26991
|
+
this.name = "AgentCatalogPublishError";
|
|
26992
|
+
}
|
|
26993
|
+
};
|
|
26994
|
+
function isRecord6(value) {
|
|
26995
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26996
|
+
}
|
|
26997
|
+
function isSafeRelayErrorMessage(value) {
|
|
26998
|
+
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
26999
|
+
}
|
|
27000
|
+
async function rejectedCatalogError(response) {
|
|
27001
|
+
let value;
|
|
27002
|
+
try {
|
|
27003
|
+
value = await response.json();
|
|
27004
|
+
} catch {
|
|
27005
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27006
|
+
}
|
|
27007
|
+
if (!isRecord6(value) || !isRecord6(value["error"])) {
|
|
27008
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27009
|
+
}
|
|
27010
|
+
const code = value["error"]["code"];
|
|
27011
|
+
const message = value["error"]["message"];
|
|
27012
|
+
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
27013
|
+
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
27014
|
+
}
|
|
27015
|
+
return new AgentCatalogPublishError(
|
|
27016
|
+
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
27017
|
+
{},
|
|
27018
|
+
{
|
|
27019
|
+
relayErrorCode: code
|
|
26908
27020
|
}
|
|
26909
|
-
|
|
26910
|
-
|
|
27021
|
+
);
|
|
27022
|
+
}
|
|
27023
|
+
function catalogEndpoint(config2) {
|
|
27024
|
+
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
27025
|
+
if (endpoint.pathname.endsWith("/daemon")) {
|
|
27026
|
+
endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
|
|
27027
|
+
return endpoint;
|
|
27028
|
+
}
|
|
27029
|
+
const runtimePath = "/v1/runtimes/connect";
|
|
27030
|
+
if (endpoint.pathname.endsWith(runtimePath)) {
|
|
27031
|
+
endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
|
|
27032
|
+
return endpoint;
|
|
27033
|
+
}
|
|
27034
|
+
throw new AgentCatalogPublishError("The Relay URL is invalid");
|
|
27035
|
+
}
|
|
27036
|
+
async function publishAgentCatalog(config2, signal) {
|
|
27037
|
+
signal.throwIfAborted();
|
|
27038
|
+
const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
|
|
27039
|
+
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
27040
|
+
let response;
|
|
27041
|
+
const catalog = config2.catalog.read();
|
|
27042
|
+
try {
|
|
27043
|
+
response = await fetch2(catalogEndpoint(config2), {
|
|
27044
|
+
body: JSON.stringify({
|
|
27045
|
+
agents: catalog.agents.map((agent) => ({
|
|
27046
|
+
agentPath: agent.agentIdentity.requestedPath,
|
|
27047
|
+
agentVersion: agent.agentVersion,
|
|
27048
|
+
agentSettingsDiscovery: true,
|
|
27049
|
+
capabilities: agent.capabilities,
|
|
27050
|
+
id: agent.id,
|
|
27051
|
+
label: agent.label,
|
|
27052
|
+
sessionTurnConfiguration: true
|
|
27053
|
+
})),
|
|
27054
|
+
installableAgents: catalog.installableAgents
|
|
27055
|
+
}),
|
|
27056
|
+
dispatcher: environmentProxyDispatcher,
|
|
27057
|
+
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
27058
|
+
method: "PUT",
|
|
27059
|
+
signal: requestSignal
|
|
27060
|
+
});
|
|
27061
|
+
} catch (error62) {
|
|
27062
|
+
if (signal.aborted) {
|
|
27063
|
+
signal.throwIfAborted();
|
|
27064
|
+
}
|
|
27065
|
+
throw new AgentCatalogPublishError(
|
|
27066
|
+
timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
|
|
27067
|
+
{ cause: error62 }
|
|
26911
27068
|
);
|
|
26912
|
-
}
|
|
26913
|
-
|
|
26914
|
-
|
|
26915
|
-
}
|
|
26916
|
-
|
|
27069
|
+
}
|
|
27070
|
+
if (!response.ok) {
|
|
27071
|
+
throw await rejectedCatalogError(response);
|
|
27072
|
+
}
|
|
27073
|
+
await response.body?.cancel();
|
|
27074
|
+
}
|
|
26917
27075
|
|
|
26918
27076
|
// src/config.ts
|
|
26919
|
-
import { join as
|
|
27077
|
+
import { join as join16, resolve as resolve3 } from "node:path";
|
|
26920
27078
|
function loadDefaultWorkspace(environment = process.env) {
|
|
26921
27079
|
const { MOBIUS_DEFAULT_WORKSPACE: configuredWorkspace } = environment;
|
|
26922
|
-
return configuredWorkspace ??
|
|
27080
|
+
return configuredWorkspace ?? join16(readStateDirectory(environment), "workspace");
|
|
26923
27081
|
}
|
|
26924
27082
|
var DaemonLocalContext = class {
|
|
26925
27083
|
environment;
|
|
@@ -26949,7 +27107,7 @@ var OpaqueDaemonReconnectTarget = class extends DaemonReconnectTarget {
|
|
|
26949
27107
|
this.commandArgument = `--connection ${connectionId2}`;
|
|
26950
27108
|
}
|
|
26951
27109
|
};
|
|
26952
|
-
function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null) {
|
|
27110
|
+
function createDaemonConfig(connection, agents = [], installableAgents = [], localContext = new DaemonLocalContext(readStateDirectory(), process.env), reconnectTarget = null, resolveAgent) {
|
|
26953
27111
|
const daemonAgents = agents.map((agent) => withDaemonEnvironment(agent, localContext.environment));
|
|
26954
27112
|
return {
|
|
26955
27113
|
agents: daemonAgents,
|
|
@@ -26960,13 +27118,86 @@ function createDaemonConfig(connection, agents = [], installableAgents = [], loc
|
|
|
26960
27118
|
installableAgents,
|
|
26961
27119
|
localContext,
|
|
26962
27120
|
reconnectTarget,
|
|
26963
|
-
relayUrl: connection.relayUrl
|
|
27121
|
+
relayUrl: connection.relayUrl,
|
|
27122
|
+
...resolveAgent === void 0 ? {} : { resolveAgent }
|
|
26964
27123
|
};
|
|
26965
27124
|
}
|
|
26966
27125
|
|
|
27126
|
+
// src/agent-catalog/resolve-catalog-agent.ts
|
|
27127
|
+
function createCatalogAgentResolver(discover, readConfig, publish) {
|
|
27128
|
+
const swaps = /* @__PURE__ */ new Map();
|
|
27129
|
+
return async (agent, signal) => {
|
|
27130
|
+
const config2 = readConfig();
|
|
27131
|
+
const pending = swaps.get(agent.id);
|
|
27132
|
+
if (pending !== void 0) {
|
|
27133
|
+
await pending;
|
|
27134
|
+
return config2.catalog.find(agent.id);
|
|
27135
|
+
}
|
|
27136
|
+
let release = () => void 0;
|
|
27137
|
+
const gate = new Promise((resolveGate) => {
|
|
27138
|
+
release = resolveGate;
|
|
27139
|
+
});
|
|
27140
|
+
swaps.set(agent.id, gate);
|
|
27141
|
+
try {
|
|
27142
|
+
if (await unchangedIdentity(agent, signal)) {
|
|
27143
|
+
return agent;
|
|
27144
|
+
}
|
|
27145
|
+
signal.throwIfAborted();
|
|
27146
|
+
const inventory = await discover(signal);
|
|
27147
|
+
signal.throwIfAborted();
|
|
27148
|
+
const previous = config2.catalog.read();
|
|
27149
|
+
const previousAgent = previous.agents.find((entry) => entry.id === agent.id);
|
|
27150
|
+
if (previousAgent === void 0) {
|
|
27151
|
+
throw new Error(`The local Agent ${agent.id} left the catalog before its refresh completed`);
|
|
27152
|
+
}
|
|
27153
|
+
config2.catalog.transition(
|
|
27154
|
+
[
|
|
27155
|
+
...previous.agents.filter((entry) => entry.id !== agent.id),
|
|
27156
|
+
...inventory.readyAgents().map((ready) => withDaemonEnvironment(ready, config2.localContext.environment))
|
|
27157
|
+
],
|
|
27158
|
+
[...previous.installableAgents.filter((entry) => entry.id !== agent.id), ...inventory.installable]
|
|
27159
|
+
);
|
|
27160
|
+
try {
|
|
27161
|
+
await publish(config2, signal);
|
|
27162
|
+
} catch (error62) {
|
|
27163
|
+
config2.catalog.transition(previous.agents, previous.installableAgents);
|
|
27164
|
+
throw error62;
|
|
27165
|
+
}
|
|
27166
|
+
return config2.catalog.find(agent.id);
|
|
27167
|
+
} finally {
|
|
27168
|
+
swaps.delete(agent.id);
|
|
27169
|
+
release();
|
|
27170
|
+
}
|
|
27171
|
+
};
|
|
27172
|
+
}
|
|
27173
|
+
async function unchangedIdentity(agent, signal) {
|
|
27174
|
+
if (!await revalidateExecutable(agent.agentIdentity)) {
|
|
27175
|
+
return false;
|
|
27176
|
+
}
|
|
27177
|
+
signal.throwIfAborted();
|
|
27178
|
+
return agent.kind !== "acp-adapter-process" || await revalidateExecutable(agent.adapterIdentity);
|
|
27179
|
+
}
|
|
27180
|
+
|
|
27181
|
+
// src/audit/audit-store.ts
|
|
27182
|
+
var MAX_AUDIT_RECORDS = 1024;
|
|
27183
|
+
var AuditStore = class {
|
|
27184
|
+
#records = [];
|
|
27185
|
+
record = (record2) => {
|
|
27186
|
+
if (this.#records.length === MAX_AUDIT_RECORDS) {
|
|
27187
|
+
this.#records.shift();
|
|
27188
|
+
}
|
|
27189
|
+
this.#records.push(
|
|
27190
|
+
record2.details === void 0 ? { ...record2 } : { ...record2, details: { ...record2.details } }
|
|
27191
|
+
);
|
|
27192
|
+
};
|
|
27193
|
+
close = () => {
|
|
27194
|
+
this.#records.length = 0;
|
|
27195
|
+
};
|
|
27196
|
+
};
|
|
27197
|
+
|
|
26967
27198
|
// src/run-daemon.ts
|
|
26968
27199
|
import { createHash as createHash7, randomUUID as randomUUID8 } from "node:crypto";
|
|
26969
|
-
import { join as
|
|
27200
|
+
import { join as join20 } from "node:path";
|
|
26970
27201
|
import { styleText } from "node:util";
|
|
26971
27202
|
|
|
26972
27203
|
// src/acp/active-executions.ts
|
|
@@ -27057,7 +27288,7 @@ import {
|
|
|
27057
27288
|
} from "@agentclientprotocol/sdk";
|
|
27058
27289
|
|
|
27059
27290
|
// src/authorization/local-raster.ts
|
|
27060
|
-
import { open as open4, readFile as readFile2, realpath as
|
|
27291
|
+
import { open as open4, readFile as readFile2, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
27061
27292
|
import { basename, isAbsolute as isAbsolute9, normalize as normalize2 } from "node:path";
|
|
27062
27293
|
import { fileURLToPath } from "node:url";
|
|
27063
27294
|
var MAX_LOCAL_RASTER_BYTES = 128 * 1024 * 1024;
|
|
@@ -27128,7 +27359,7 @@ async function resolveCanonicalPath(requested, signal) {
|
|
|
27128
27359
|
return null;
|
|
27129
27360
|
}
|
|
27130
27361
|
try {
|
|
27131
|
-
const target = await
|
|
27362
|
+
const target = await realpath7(requested);
|
|
27132
27363
|
signal.throwIfAborted();
|
|
27133
27364
|
if (!isAbsolute9(target) || normalize2(target) !== target) {
|
|
27134
27365
|
return null;
|
|
@@ -27176,7 +27407,7 @@ async function readLocalRaster(uri, signal) {
|
|
|
27176
27407
|
if (target === null) {
|
|
27177
27408
|
return null;
|
|
27178
27409
|
}
|
|
27179
|
-
const targetMetadata = await
|
|
27410
|
+
const targetMetadata = await stat6(target);
|
|
27180
27411
|
signal.throwIfAborted();
|
|
27181
27412
|
if (!targetMetadata.isFile() || targetMetadata.size < 1 || targetMetadata.size > MAX_LOCAL_RASTER_BYTES) {
|
|
27182
27413
|
return null;
|
|
@@ -27355,7 +27586,7 @@ async function replaceImageMarkers(text2, replace) {
|
|
|
27355
27586
|
|
|
27356
27587
|
// src/acp/activity-content.ts
|
|
27357
27588
|
var TRUNCATION_MARKER = "\n\u2026 output truncated by Mobius";
|
|
27358
|
-
function
|
|
27589
|
+
function isRecord7(value) {
|
|
27359
27590
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
27360
27591
|
}
|
|
27361
27592
|
function truncate3(value, maximumLength) {
|
|
@@ -27539,16 +27770,16 @@ async function normalizeToolContent(content, prepareContent) {
|
|
|
27539
27770
|
return normalized;
|
|
27540
27771
|
}
|
|
27541
27772
|
function rawMcpToolContent(rawOutput) {
|
|
27542
|
-
if (!
|
|
27773
|
+
if (!isRecord7(rawOutput)) {
|
|
27543
27774
|
return [];
|
|
27544
27775
|
}
|
|
27545
|
-
const result =
|
|
27776
|
+
const result = isRecord7(rawOutput["result"]) ? rawOutput["result"] : rawOutput;
|
|
27546
27777
|
const content = result["content"];
|
|
27547
27778
|
if (!Array.isArray(content)) {
|
|
27548
27779
|
return [];
|
|
27549
27780
|
}
|
|
27550
27781
|
return content.flatMap((item) => {
|
|
27551
|
-
if (!
|
|
27782
|
+
if (!isRecord7(item) || item["type"] !== "image" || typeof item["data"] !== "string" || typeof item["mimeType"] !== "string") {
|
|
27552
27783
|
return [];
|
|
27553
27784
|
}
|
|
27554
27785
|
const uri = item["uri"];
|
|
@@ -27625,7 +27856,7 @@ function contentPhase(content) {
|
|
|
27625
27856
|
return "";
|
|
27626
27857
|
}
|
|
27627
27858
|
const codex = metadata["codex"];
|
|
27628
|
-
if (!
|
|
27859
|
+
if (!isRecord7(codex)) {
|
|
27629
27860
|
return "";
|
|
27630
27861
|
}
|
|
27631
27862
|
const phase = codex["phase"];
|
|
@@ -28332,7 +28563,7 @@ var SessionConfigProtocolError = class extends Error {
|
|
|
28332
28563
|
this.name = "SessionConfigProtocolError";
|
|
28333
28564
|
}
|
|
28334
28565
|
};
|
|
28335
|
-
function
|
|
28566
|
+
function isRecord8(value) {
|
|
28336
28567
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
28337
28568
|
}
|
|
28338
28569
|
function readString3(value, fallback = "") {
|
|
@@ -28363,7 +28594,7 @@ function normalizeConfigValues(value) {
|
|
|
28363
28594
|
}
|
|
28364
28595
|
const normalized = [];
|
|
28365
28596
|
for (const entry of value) {
|
|
28366
|
-
if (!
|
|
28597
|
+
if (!isRecord8(entry)) {
|
|
28367
28598
|
continue;
|
|
28368
28599
|
}
|
|
28369
28600
|
const groupedOptions = entry["options"];
|
|
@@ -28371,7 +28602,7 @@ function normalizeConfigValues(value) {
|
|
|
28371
28602
|
const groupId = readString3(entry["group"]);
|
|
28372
28603
|
const groupName = readString3(entry["name"]);
|
|
28373
28604
|
for (const groupedOption of groupedOptions) {
|
|
28374
|
-
if (
|
|
28605
|
+
if (isRecord8(groupedOption)) {
|
|
28375
28606
|
const normalizedValue = normalizeConfigValue(groupedOption, groupId, groupName);
|
|
28376
28607
|
if (normalizedValue !== void 0) {
|
|
28377
28608
|
normalized.push(normalizedValue);
|
|
@@ -28391,7 +28622,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28391
28622
|
const normalized = [];
|
|
28392
28623
|
if (Array.isArray(value)) {
|
|
28393
28624
|
for (const option of value) {
|
|
28394
|
-
if (!
|
|
28625
|
+
if (!isRecord8(option)) {
|
|
28395
28626
|
continue;
|
|
28396
28627
|
}
|
|
28397
28628
|
const id = truncate4(readString3(option["id"]), 128);
|
|
@@ -28431,12 +28662,12 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28431
28662
|
}
|
|
28432
28663
|
}
|
|
28433
28664
|
}
|
|
28434
|
-
if (
|
|
28665
|
+
if (isRecord8(modes)) {
|
|
28435
28666
|
const values = [];
|
|
28436
28667
|
const availableModes = modes["availableModes"];
|
|
28437
28668
|
if (Array.isArray(availableModes)) {
|
|
28438
28669
|
for (const mode of availableModes) {
|
|
28439
|
-
if (!
|
|
28670
|
+
if (!isRecord8(mode)) {
|
|
28440
28671
|
continue;
|
|
28441
28672
|
}
|
|
28442
28673
|
const id = truncate4(readString3(mode["id"]), 500);
|
|
@@ -28469,7 +28700,7 @@ function normalizeConfigOptions(value, modes) {
|
|
|
28469
28700
|
return normalized.slice(0, MAXIMUM_CONFIG_OPTIONS);
|
|
28470
28701
|
}
|
|
28471
28702
|
function normalizeStandardLifecycle(response) {
|
|
28472
|
-
const lifecycle =
|
|
28703
|
+
const lifecycle = isRecord8(response) ? response : {};
|
|
28473
28704
|
return normalizeConfigOptions(lifecycle["configOptions"], lifecycle["modes"]);
|
|
28474
28705
|
}
|
|
28475
28706
|
function replaceStandardConfigOptions(current, value) {
|
|
@@ -28511,7 +28742,7 @@ var StandardSessionConfigProtocol = class {
|
|
|
28511
28742
|
"ACP agent exited while changing session configuration",
|
|
28512
28743
|
change.signal
|
|
28513
28744
|
);
|
|
28514
|
-
if (!
|
|
28745
|
+
if (!isRecord8(response) || !Array.isArray(response["configOptions"])) {
|
|
28515
28746
|
throw new SessionConfigProtocolError("The Agent returned an invalid session configuration response");
|
|
28516
28747
|
}
|
|
28517
28748
|
return replaceStandardConfigOptions(current, response["configOptions"]);
|
|
@@ -28612,10 +28843,12 @@ var AcpAgentSettingsSnapshot = class {
|
|
|
28612
28843
|
agentName;
|
|
28613
28844
|
agentVersion;
|
|
28614
28845
|
configOptions;
|
|
28615
|
-
|
|
28846
|
+
modelEffort;
|
|
28847
|
+
constructor(agentName, agentVersion, configOptions, modelEffort) {
|
|
28616
28848
|
this.agentName = agentName;
|
|
28617
28849
|
this.agentVersion = agentVersion;
|
|
28618
28850
|
this.configOptions = configOptions;
|
|
28851
|
+
this.modelEffort = modelEffort;
|
|
28619
28852
|
}
|
|
28620
28853
|
};
|
|
28621
28854
|
|
|
@@ -29922,7 +30155,7 @@ function sql(strings, ...params) {
|
|
|
29922
30155
|
return new SQL([new StringChunk(str)]);
|
|
29923
30156
|
}
|
|
29924
30157
|
_sql.raw = raw;
|
|
29925
|
-
function
|
|
30158
|
+
function join22(chunks, separator) {
|
|
29926
30159
|
const result = [];
|
|
29927
30160
|
for (const [i, chunk] of chunks.entries()) {
|
|
29928
30161
|
if (i > 0 && separator !== void 0) result.push(separator);
|
|
@@ -29930,7 +30163,7 @@ function sql(strings, ...params) {
|
|
|
29930
30163
|
}
|
|
29931
30164
|
return new SQL(result);
|
|
29932
30165
|
}
|
|
29933
|
-
_sql.join =
|
|
30166
|
+
_sql.join = join22;
|
|
29934
30167
|
function identifier2(value) {
|
|
29935
30168
|
return new Name(value);
|
|
29936
30169
|
}
|
|
@@ -32075,7 +32308,7 @@ var SQLiteSelectBase = class extends TypedQueryBuilder {
|
|
|
32075
32308
|
const baseTableName = this.tableName;
|
|
32076
32309
|
const tableName = getTableLikeName(table);
|
|
32077
32310
|
for (const item of extractUsedTable(table)) this.usedTables.add(item);
|
|
32078
|
-
if (typeof tableName === "string" && this.config.joins?.some((
|
|
32311
|
+
if (typeof tableName === "string" && this.config.joins?.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
32079
32312
|
if (!this.isPartialSelect) {
|
|
32080
32313
|
if (Object.keys(this.joinsNotNullableMap).length === 1 && typeof baseTableName === "string") this.config.fields = { [baseTableName]: this.config.fields };
|
|
32081
32314
|
if (typeof tableName === "string" && !is(table, SQL)) {
|
|
@@ -32914,7 +33147,7 @@ var SQLiteDialect = class {
|
|
|
32914
33147
|
if (!joins2) return;
|
|
32915
33148
|
const withEntries = Object.entries(joins2).filter(([_, v]) => v);
|
|
32916
33149
|
if (!withEntries.length) return;
|
|
32917
|
-
return sql.join(withEntries.map(([k,
|
|
33150
|
+
return sql.join(withEntries.map(([k, join22]) => {
|
|
32918
33151
|
const relation = tableConfig.relations[k];
|
|
32919
33152
|
const isSingle2 = is(relation, One);
|
|
32920
33153
|
const targetTable = aliasedTable(relation.targetTable, `d${currentDepth + 1}`);
|
|
@@ -32925,7 +33158,7 @@ var SQLiteDialect = class {
|
|
|
32925
33158
|
table: targetTable,
|
|
32926
33159
|
mode: isSingle2 ? "first" : "many",
|
|
32927
33160
|
schema,
|
|
32928
|
-
queryConfig:
|
|
33161
|
+
queryConfig: join22,
|
|
32929
33162
|
tableConfig: schema[relation.targetTableName],
|
|
32930
33163
|
relationWhere: filter,
|
|
32931
33164
|
isNested: true,
|
|
@@ -32939,7 +33172,7 @@ var SQLiteDialect = class {
|
|
|
32939
33172
|
key: k,
|
|
32940
33173
|
selection: innerQuery.selection,
|
|
32941
33174
|
isArray: !isSingle2,
|
|
32942
|
-
isOptional: (relation.optional ?? false) ||
|
|
33175
|
+
isOptional: (relation.optional ?? false) || join22 !== true && !!join22.where
|
|
32943
33176
|
});
|
|
32944
33177
|
const jsonColumns = sql.join(innerQuery.selection.map((s) => {
|
|
32945
33178
|
return sql`${sql.raw(this.escapeString(s.key))}, ${s.selection ? sql`${jsonb}(${sql.identifier(s.key)})` : sql.identifier(s.key)}`;
|
|
@@ -33555,7 +33788,7 @@ var SQLiteUpdateBase = class {
|
|
|
33555
33788
|
createJoin(joinType) {
|
|
33556
33789
|
return ((table, on) => {
|
|
33557
33790
|
const tableName = getTableLikeName(table);
|
|
33558
|
-
if (typeof tableName === "string" && this.config.joins.some((
|
|
33791
|
+
if (typeof tableName === "string" && this.config.joins.some((join22) => join22.alias === tableName)) throw new Error(`Alias "${tableName}" is already used in this query`);
|
|
33559
33792
|
if (typeof on === "function") {
|
|
33560
33793
|
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;
|
|
33561
33794
|
on = on(new Proxy(this.config.table[Table.Symbol.Columns], new SelectionProxyHandler({
|
|
@@ -34961,7 +35194,7 @@ var AgentSession = class _AgentSession {
|
|
|
34961
35194
|
);
|
|
34962
35195
|
}
|
|
34963
35196
|
initialize = async (signal, recovery, origin) => {
|
|
34964
|
-
if (origin
|
|
35197
|
+
if (origin !== void 0) {
|
|
34965
35198
|
this.#sessionTitle = origin.title;
|
|
34966
35199
|
}
|
|
34967
35200
|
await this.#initializeAgent(signal);
|
|
@@ -34975,7 +35208,7 @@ var AgentSession = class _AgentSession {
|
|
|
34975
35208
|
this.#cwd,
|
|
34976
35209
|
this.#additionalDirectories,
|
|
34977
35210
|
true,
|
|
34978
|
-
|
|
35211
|
+
origin.title
|
|
34979
35212
|
)
|
|
34980
35213
|
) : this.#store.read(this.#mobiusSessionId)
|
|
34981
35214
|
);
|
|
@@ -35325,8 +35558,10 @@ var AgentSession = class _AgentSession {
|
|
|
35325
35558
|
payload: {
|
|
35326
35559
|
commandId: options.commandId,
|
|
35327
35560
|
content: lifecycleV2.content,
|
|
35561
|
+
...lifecycleV2.disposition === void 0 ? {} : { disposition: lifecycleV2.disposition },
|
|
35328
35562
|
kind: "prompt.requested",
|
|
35329
|
-
...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context }
|
|
35563
|
+
...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context },
|
|
35564
|
+
...lifecycleV2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycleV2.targetCommandId }
|
|
35330
35565
|
},
|
|
35331
35566
|
type: "lifecycle-metadata"
|
|
35332
35567
|
});
|
|
@@ -35433,8 +35668,10 @@ var AgentSession = class _AgentSession {
|
|
|
35433
35668
|
payload: {
|
|
35434
35669
|
commandId: options.commandId,
|
|
35435
35670
|
content: lifecycleV2.content,
|
|
35671
|
+
...lifecycleV2.disposition === void 0 ? {} : { disposition: lifecycleV2.disposition },
|
|
35436
35672
|
kind: "prompt.requested",
|
|
35437
|
-
...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context }
|
|
35673
|
+
...lifecycleV2.context === void 0 ? {} : { context: lifecycleV2.context },
|
|
35674
|
+
...lifecycleV2.targetCommandId === void 0 ? {} : { targetCommandId: lifecycleV2.targetCommandId }
|
|
35438
35675
|
},
|
|
35439
35676
|
type: "lifecycle-metadata"
|
|
35440
35677
|
});
|
|
@@ -35704,6 +35941,7 @@ var AgentSession = class _AgentSession {
|
|
|
35704
35941
|
}
|
|
35705
35942
|
};
|
|
35706
35943
|
closeProcess = () => this.#connection.closeProcess();
|
|
35944
|
+
agentSettingsModelEffort = () => this.#connection.inProcessAgent?.agentSettingsModelEffort?.() ?? null;
|
|
35707
35945
|
race = (operation, exitMessage, signal) => this.#connection.race(operation, exitMessage, signal);
|
|
35708
35946
|
assertNativeSession = (sessionId) => {
|
|
35709
35947
|
if (sessionId !== this.#updates.sessionId()) {
|
|
@@ -35998,7 +36236,7 @@ var toolImageSchema = external_exports.union([
|
|
|
35998
36236
|
file: external_exports.object({ base64: external_exports.string(), type: external_exports.string() })
|
|
35999
36237
|
}).transform(({ file: file2 }) => ({ type: "image", data: file2.base64, mimeType: file2.type }))
|
|
36000
36238
|
]);
|
|
36001
|
-
function
|
|
36239
|
+
function isRecord9(value) {
|
|
36002
36240
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36003
36241
|
}
|
|
36004
36242
|
var AcpContentExternalizer = class {
|
|
@@ -36114,13 +36352,13 @@ var AcpContentExternalizer = class {
|
|
|
36114
36352
|
}
|
|
36115
36353
|
return result2;
|
|
36116
36354
|
}
|
|
36117
|
-
if (!
|
|
36355
|
+
if (!isRecord9(value)) {
|
|
36118
36356
|
return value;
|
|
36119
36357
|
}
|
|
36120
36358
|
const image = toolImageSchema.safeParse(value);
|
|
36121
36359
|
if (image.success && image.data.data.length > 0) {
|
|
36122
36360
|
const prepared = await this.#content(sessionId, image.data, signal);
|
|
36123
|
-
if (
|
|
36361
|
+
if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
36124
36362
|
images.set(prepared.event["imageKey"], prepared);
|
|
36125
36363
|
} else {
|
|
36126
36364
|
images.set(`unavailable:${images.size}`, prepared);
|
|
@@ -36151,7 +36389,7 @@ var AcpContentExternalizer = class {
|
|
|
36151
36389
|
const prepared = await this.#content(sessionId, content, signal);
|
|
36152
36390
|
agentContent.push({ ...item, content: prepared.agent });
|
|
36153
36391
|
eventContent.push({ ...item, content: prepared.event });
|
|
36154
|
-
if (
|
|
36392
|
+
if (isRecord9(prepared.event) && typeof prepared.event["imageKey"] === "string") {
|
|
36155
36393
|
images.delete(prepared.event["imageKey"]);
|
|
36156
36394
|
}
|
|
36157
36395
|
}
|
|
@@ -36209,8 +36447,8 @@ var AcpContentExternalizer = class {
|
|
|
36209
36447
|
|
|
36210
36448
|
// src/external-content/local-external-content-store.ts
|
|
36211
36449
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
36212
|
-
import { lstat, mkdir as mkdir4, readdir as readdir2, realpath as
|
|
36213
|
-
import { dirname as dirname3, join as
|
|
36450
|
+
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";
|
|
36451
|
+
import { dirname as dirname3, join as join17 } from "node:path";
|
|
36214
36452
|
var contentRequest = /^mobius-content:(image|audio|resource):([a-f0-9]{64})$/u;
|
|
36215
36453
|
var CONTENT_LIFETIME_MILLISECONDS = 24 * 60 * 60 * 1e3;
|
|
36216
36454
|
var metadataSchema2 = external_exports.strictObject({
|
|
@@ -36246,7 +36484,7 @@ var LocalExternalContentStore = class {
|
|
|
36246
36484
|
#expirationTimer;
|
|
36247
36485
|
#cleanup = Promise.resolve();
|
|
36248
36486
|
constructor(stateDirectory) {
|
|
36249
|
-
this.#root =
|
|
36487
|
+
this.#root = join17(stateDirectory, "tmp", "session-content", randomUUID2());
|
|
36250
36488
|
this.#expirationTimer = setInterval(() => {
|
|
36251
36489
|
void this.#expire().catch(() => void 0);
|
|
36252
36490
|
}, 6e4);
|
|
@@ -36261,11 +36499,11 @@ var LocalExternalContentStore = class {
|
|
|
36261
36499
|
if (!directory.isDirectory() || !/^[a-f0-9-]{36}$/u.test(directory.name)) {
|
|
36262
36500
|
continue;
|
|
36263
36501
|
}
|
|
36264
|
-
const path2 =
|
|
36502
|
+
const path2 = join17(dirname3(this.#root), directory.name);
|
|
36265
36503
|
if (path2 === this.#root) {
|
|
36266
36504
|
continue;
|
|
36267
36505
|
}
|
|
36268
|
-
const modified = await
|
|
36506
|
+
const modified = await stat7(path2).then(
|
|
36269
36507
|
(entry) => entry.mtimeMs,
|
|
36270
36508
|
() => Date.now()
|
|
36271
36509
|
);
|
|
@@ -36311,10 +36549,10 @@ var LocalExternalContentStore = class {
|
|
|
36311
36549
|
}
|
|
36312
36550
|
await this.#expire();
|
|
36313
36551
|
active.throwIfAborted();
|
|
36314
|
-
const directory =
|
|
36552
|
+
const directory = join17(this.#root, kind);
|
|
36315
36553
|
await mkdir4(directory, { mode: 448, recursive: true });
|
|
36316
36554
|
active.throwIfAborted();
|
|
36317
|
-
const path2 =
|
|
36555
|
+
const path2 = join17(directory, key);
|
|
36318
36556
|
const write = atomicWrite(path2, bytes, active);
|
|
36319
36557
|
await write;
|
|
36320
36558
|
active.throwIfAborted();
|
|
@@ -36347,8 +36585,8 @@ var LocalExternalContentStore = class {
|
|
|
36347
36585
|
}
|
|
36348
36586
|
try {
|
|
36349
36587
|
const [resolvedDirectory, resolvedPath, file2] = await Promise.all([
|
|
36350
|
-
|
|
36351
|
-
|
|
36588
|
+
realpath8(dirname3(entry.path)),
|
|
36589
|
+
realpath8(entry.path),
|
|
36352
36590
|
lstat(entry.path)
|
|
36353
36591
|
]);
|
|
36354
36592
|
signal.throwIfAborted();
|
|
@@ -36786,7 +37024,7 @@ var AgentRuntimeManager = class {
|
|
|
36786
37024
|
return await this.#startRetainedSessionProcess(
|
|
36787
37025
|
options,
|
|
36788
37026
|
async () => await AgentSession.start(
|
|
36789
|
-
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,
|
|
37027
|
+
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,
|
|
36790
37028
|
recovery,
|
|
36791
37029
|
() => this.#observer,
|
|
36792
37030
|
this.#store,
|
|
@@ -36942,6 +37180,7 @@ var AgentRuntimeManager = class {
|
|
|
36942
37180
|
),
|
|
36943
37181
|
async (runtime) => {
|
|
36944
37182
|
const prepared = runtime.prepared();
|
|
37183
|
+
const discoveredModelEffort = runtime.agentSettingsModelEffort();
|
|
36945
37184
|
const model = options2.model;
|
|
36946
37185
|
const configOptions = model === void 0 ? prepared.configOptions : await runtime.configure({
|
|
36947
37186
|
...options2,
|
|
@@ -36954,7 +37193,12 @@ var AgentRuntimeManager = class {
|
|
|
36954
37193
|
value: model,
|
|
36955
37194
|
valueType: "select"
|
|
36956
37195
|
});
|
|
36957
|
-
return new AcpAgentSettingsSnapshot(
|
|
37196
|
+
return new AcpAgentSettingsSnapshot(
|
|
37197
|
+
prepared.agentName,
|
|
37198
|
+
prepared.agentVersion,
|
|
37199
|
+
configOptions,
|
|
37200
|
+
discoveredModelEffort === null ? { kind: "unavailable" } : { kind: "complete", value: discoveredModelEffort }
|
|
37201
|
+
);
|
|
36958
37202
|
},
|
|
36959
37203
|
async (runtime) => await runtime.close()
|
|
36960
37204
|
);
|
|
@@ -37383,117 +37627,6 @@ var AgentRuntimeManager = class {
|
|
|
37383
37627
|
});
|
|
37384
37628
|
};
|
|
37385
37629
|
|
|
37386
|
-
// src/agent-catalog/publish-agent-catalog.ts
|
|
37387
|
-
import { fetch as fetch2 } from "undici";
|
|
37388
|
-
|
|
37389
|
-
// src/relay-connection/runtime-authentication.ts
|
|
37390
|
-
function runtimeCredential(relayUrl) {
|
|
37391
|
-
return relayUrl.searchParams.get("token") ?? "";
|
|
37392
|
-
}
|
|
37393
|
-
function runtimeAuthorization(relayUrl) {
|
|
37394
|
-
const credential = runtimeCredential(relayUrl);
|
|
37395
|
-
return credential.length === 0 ? {} : { authorization: `Bearer ${credential}` };
|
|
37396
|
-
}
|
|
37397
|
-
function relayHttpEndpoint(relayUrl) {
|
|
37398
|
-
const endpoint = new URL(relayUrl);
|
|
37399
|
-
endpoint.protocol = endpoint.protocol === "wss:" ? "https:" : "http:";
|
|
37400
|
-
endpoint.search = "";
|
|
37401
|
-
return endpoint;
|
|
37402
|
-
}
|
|
37403
|
-
|
|
37404
|
-
// src/agent-catalog/publish-agent-catalog.ts
|
|
37405
|
-
var CATALOG_UPDATE_TIMEOUT_MILLISECONDS = 2e4;
|
|
37406
|
-
var AgentCatalogPublishError = class extends Error {
|
|
37407
|
-
code = "agent_catalog_update_failed";
|
|
37408
|
-
diagnosticDetails;
|
|
37409
|
-
constructor(message, options = {}, diagnosticDetails = {}) {
|
|
37410
|
-
super(message, options);
|
|
37411
|
-
this.diagnosticDetails = diagnosticDetails;
|
|
37412
|
-
this.name = "AgentCatalogPublishError";
|
|
37413
|
-
}
|
|
37414
|
-
};
|
|
37415
|
-
function isRecord9(value) {
|
|
37416
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
37417
|
-
}
|
|
37418
|
-
function isSafeRelayErrorMessage(value) {
|
|
37419
|
-
return value.length > 0 && value.length <= 512 && Array.from(value).every((character) => character.charCodeAt(0) >= 32 && character.charCodeAt(0) !== 127);
|
|
37420
|
-
}
|
|
37421
|
-
async function rejectedCatalogError(response) {
|
|
37422
|
-
let value;
|
|
37423
|
-
try {
|
|
37424
|
-
value = await response.json();
|
|
37425
|
-
} catch {
|
|
37426
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37427
|
-
}
|
|
37428
|
-
if (!isRecord9(value) || !isRecord9(value["error"])) {
|
|
37429
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37430
|
-
}
|
|
37431
|
-
const code = value["error"]["code"];
|
|
37432
|
-
const message = value["error"]["message"];
|
|
37433
|
-
if (typeof code !== "string" || !/^[a-z][a-z0-9_]{0,63}$/.test(code) || typeof message !== "string" || !isSafeRelayErrorMessage(message)) {
|
|
37434
|
-
return new AgentCatalogPublishError("The Relay rejected the Agent catalog update");
|
|
37435
|
-
}
|
|
37436
|
-
return new AgentCatalogPublishError(
|
|
37437
|
-
`The Relay rejected the Agent catalog update (${code}): ${message}`,
|
|
37438
|
-
{},
|
|
37439
|
-
{
|
|
37440
|
-
relayErrorCode: code
|
|
37441
|
-
}
|
|
37442
|
-
);
|
|
37443
|
-
}
|
|
37444
|
-
function catalogEndpoint(config2) {
|
|
37445
|
-
const endpoint = relayHttpEndpoint(config2.relayUrl);
|
|
37446
|
-
if (endpoint.pathname.endsWith("/daemon")) {
|
|
37447
|
-
endpoint.pathname = `${endpoint.pathname.slice(0, -"/daemon".length)}/catalog`;
|
|
37448
|
-
return endpoint;
|
|
37449
|
-
}
|
|
37450
|
-
const runtimePath = "/v1/runtimes/connect";
|
|
37451
|
-
if (endpoint.pathname.endsWith(runtimePath)) {
|
|
37452
|
-
endpoint.pathname = `${endpoint.pathname.slice(0, -runtimePath.length)}/channels/${encodeURIComponent(config2.channelId)}/catalog`;
|
|
37453
|
-
return endpoint;
|
|
37454
|
-
}
|
|
37455
|
-
throw new AgentCatalogPublishError("The Relay URL is invalid");
|
|
37456
|
-
}
|
|
37457
|
-
async function publishAgentCatalog(config2, signal) {
|
|
37458
|
-
signal.throwIfAborted();
|
|
37459
|
-
const timeoutSignal = AbortSignal.timeout(CATALOG_UPDATE_TIMEOUT_MILLISECONDS);
|
|
37460
|
-
const requestSignal = AbortSignal.any([signal, timeoutSignal]);
|
|
37461
|
-
let response;
|
|
37462
|
-
const catalog = config2.catalog.read();
|
|
37463
|
-
try {
|
|
37464
|
-
response = await fetch2(catalogEndpoint(config2), {
|
|
37465
|
-
body: JSON.stringify({
|
|
37466
|
-
agents: catalog.agents.map((agent) => ({
|
|
37467
|
-
agentPath: agent.agentIdentity.requestedPath,
|
|
37468
|
-
agentVersion: agent.agentVersion,
|
|
37469
|
-
agentSettingsDiscovery: true,
|
|
37470
|
-
capabilities: agent.capabilities,
|
|
37471
|
-
id: agent.id,
|
|
37472
|
-
label: agent.label,
|
|
37473
|
-
sessionTurnConfiguration: true
|
|
37474
|
-
})),
|
|
37475
|
-
installableAgents: catalog.installableAgents
|
|
37476
|
-
}),
|
|
37477
|
-
dispatcher: environmentProxyDispatcher,
|
|
37478
|
-
headers: { ...runtimeAuthorization(config2.relayUrl), "content-type": "application/json" },
|
|
37479
|
-
method: "PUT",
|
|
37480
|
-
signal: requestSignal
|
|
37481
|
-
});
|
|
37482
|
-
} catch (error62) {
|
|
37483
|
-
if (signal.aborted) {
|
|
37484
|
-
signal.throwIfAborted();
|
|
37485
|
-
}
|
|
37486
|
-
throw new AgentCatalogPublishError(
|
|
37487
|
-
timeoutSignal.aborted ? "The Agent catalog update timed out" : "The Agent catalog could not be updated",
|
|
37488
|
-
{ cause: error62 }
|
|
37489
|
-
);
|
|
37490
|
-
}
|
|
37491
|
-
if (!response.ok) {
|
|
37492
|
-
throw await rejectedCatalogError(response);
|
|
37493
|
-
}
|
|
37494
|
-
await response.body?.cancel();
|
|
37495
|
-
}
|
|
37496
|
-
|
|
37497
37630
|
// src/agent-installation/agent-installation-manager.ts
|
|
37498
37631
|
var INSTALLATION_DEADLINE_MILLISECONDS = 10 * 60 * 1e3;
|
|
37499
37632
|
var AgentInstallation = class {
|
|
@@ -37956,9 +38089,9 @@ var FixedInstallationExecutor = class {
|
|
|
37956
38089
|
};
|
|
37957
38090
|
|
|
37958
38091
|
// src/authorization/workspace-directory.ts
|
|
37959
|
-
import { readdir as readdir3, realpath as
|
|
38092
|
+
import { readdir as readdir3, realpath as realpath9, stat as stat8 } from "node:fs/promises";
|
|
37960
38093
|
import { homedir as homedir2 } from "node:os";
|
|
37961
|
-
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute10, join as
|
|
38094
|
+
import { basename as basename3, dirname as dirname4, isAbsolute as isAbsolute10, join as join18, normalize as normalize3, relative as relative4 } from "node:path";
|
|
37962
38095
|
|
|
37963
38096
|
// src/authorization/local-authorization-error.ts
|
|
37964
38097
|
var LocalAuthorizationError = class extends Error {
|
|
@@ -38037,9 +38170,9 @@ var WorkspaceDirectoryService = class {
|
|
|
38037
38170
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
38038
38171
|
}
|
|
38039
38172
|
try {
|
|
38040
|
-
const target = await
|
|
38173
|
+
const target = await realpath9(requested);
|
|
38041
38174
|
signal.throwIfAborted();
|
|
38042
|
-
const metadata = await
|
|
38175
|
+
const metadata = await stat8(target);
|
|
38043
38176
|
signal.throwIfAborted();
|
|
38044
38177
|
if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
|
|
38045
38178
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
@@ -38087,7 +38220,7 @@ var WorkspaceDirectoryService = class {
|
|
|
38087
38220
|
continue;
|
|
38088
38221
|
}
|
|
38089
38222
|
try {
|
|
38090
|
-
const path2 = await this.resolvePath(
|
|
38223
|
+
const path2 = await this.resolvePath(join18(target, child2.name), signal);
|
|
38091
38224
|
entries.push({ directoryId: encodePath(path2), name: child2.name });
|
|
38092
38225
|
} catch (cause) {
|
|
38093
38226
|
signal.throwIfAborted();
|
|
@@ -38123,15 +38256,15 @@ var WorkspaceDirectoryService = class {
|
|
|
38123
38256
|
|
|
38124
38257
|
// src/daemon-diagnostic-log.ts
|
|
38125
38258
|
import { appendFileSync, mkdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, writeFileSync } from "node:fs";
|
|
38126
|
-
import { join as
|
|
38259
|
+
import { join as join19 } from "node:path";
|
|
38127
38260
|
var MAXIMUM_DAEMON_LOG_BYTES = 1 * 1024 * 1024;
|
|
38128
38261
|
var DaemonDiagnosticLog = class {
|
|
38129
38262
|
#directory;
|
|
38130
38263
|
#path;
|
|
38131
38264
|
#maximumBytes;
|
|
38132
38265
|
constructor(stateDirectory, maximumBytes = MAXIMUM_DAEMON_LOG_BYTES) {
|
|
38133
|
-
this.#directory =
|
|
38134
|
-
this.#path =
|
|
38266
|
+
this.#directory = join19(stateDirectory, "logs");
|
|
38267
|
+
this.#path = join19(this.#directory, "daemon.log");
|
|
38135
38268
|
this.#maximumBytes = maximumBytes;
|
|
38136
38269
|
}
|
|
38137
38270
|
// Export only correlation and failure metadata. Local messages and paths stay local.
|
|
@@ -40076,9 +40209,10 @@ var NativeSessionService = class {
|
|
|
40076
40209
|
signal
|
|
40077
40210
|
);
|
|
40078
40211
|
signal.throwIfAborted();
|
|
40212
|
+
const cataloged = this.#config.catalog.find(command.agentId);
|
|
40079
40213
|
const options = {
|
|
40080
40214
|
additionalDirectories,
|
|
40081
|
-
agent: this.#config.
|
|
40215
|
+
agent: this.#config.resolveAgent === void 0 ? cataloged : await this.#config.resolveAgent(cataloged, signal),
|
|
40082
40216
|
cwd,
|
|
40083
40217
|
sessionId: command.sessionId,
|
|
40084
40218
|
signal
|
|
@@ -40256,7 +40390,7 @@ var NativeSessionService = class {
|
|
|
40256
40390
|
sessionId: command.targetSessionId,
|
|
40257
40391
|
additionalDirectories: target.additionalDirectories
|
|
40258
40392
|
},
|
|
40259
|
-
action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId }
|
|
40393
|
+
action === "fork" ? { kind: "fork", nativeSessionId: target.info.sessionId, title: title2 } : { kind: "import", nativeSessionId: target.info.sessionId, title: title2 }
|
|
40260
40394
|
);
|
|
40261
40395
|
signal.throwIfAborted();
|
|
40262
40396
|
const ready = {
|
|
@@ -40630,7 +40764,7 @@ import { WebSocket as WebSocket5 } from "undici";
|
|
|
40630
40764
|
// package.json
|
|
40631
40765
|
var package_default = {
|
|
40632
40766
|
name: "@moxt-ai/mobius",
|
|
40633
|
-
version: "0.0.
|
|
40767
|
+
version: "0.0.194",
|
|
40634
40768
|
description: "Mobius CLI for pairing and running local AI agent services.",
|
|
40635
40769
|
type: "module",
|
|
40636
40770
|
bin: {
|
|
@@ -40933,7 +41067,8 @@ function unsupportedModelIds(unsupportedModels) {
|
|
|
40933
41067
|
return [...new Set(unsupportedModels.map((item) => item.requestedValue))];
|
|
40934
41068
|
}
|
|
40935
41069
|
async function discoverAgentSettings(command, config2, directories, sessions, signal) {
|
|
40936
|
-
const
|
|
41070
|
+
const cataloged = config2.catalog.find(command.agentId);
|
|
41071
|
+
const agent = config2.resolveAgent === void 0 ? cataloged : await config2.resolveAgent(cataloged, signal);
|
|
40937
41072
|
const cwd = await directories.resolve(config2.bindingId, "default", signal);
|
|
40938
41073
|
const inspectedBaseSnapshot = await sessions.inspectAgentSettings({
|
|
40939
41074
|
additionalDirectories: [],
|
|
@@ -40944,7 +41079,8 @@ async function discoverAgentSettings(command, config2, directories, sessions, si
|
|
|
40944
41079
|
const baseSnapshot = {
|
|
40945
41080
|
agentName: inspectedBaseSnapshot.agentName,
|
|
40946
41081
|
agentVersion: inspectedBaseSnapshot.agentVersion,
|
|
40947
|
-
configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal)
|
|
41082
|
+
configOptions: await discoverOpenCodeModelOptions(agent, cwd, inspectedBaseSnapshot.configOptions, signal),
|
|
41083
|
+
modelEffort: inspectedBaseSnapshot.modelEffort
|
|
40948
41084
|
};
|
|
40949
41085
|
const baseModel = modelOption(baseSnapshot.configOptions);
|
|
40950
41086
|
const unsupportedModels = [];
|
|
@@ -40984,6 +41120,7 @@ async function discoverAgentSettings(command, config2, directories, sessions, si
|
|
|
40984
41120
|
baseSnapshot.configOptions,
|
|
40985
41121
|
selectedSnapshot.configOptions,
|
|
40986
41122
|
unsupportedModels,
|
|
41123
|
+
baseSnapshot.modelEffort,
|
|
40987
41124
|
cwd,
|
|
40988
41125
|
sessions,
|
|
40989
41126
|
signal
|
|
@@ -41076,7 +41213,7 @@ function unavailableModelEffort() {
|
|
|
41076
41213
|
valuesByModel: {}
|
|
41077
41214
|
};
|
|
41078
41215
|
}
|
|
41079
|
-
async function discoverModelEffort(command, agent, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, cwd, sessions, signal) {
|
|
41216
|
+
async function discoverModelEffort(command, agent, resolution, initialOptions, selectedOptions, initiallyUnsupportedModels, discoveredModelEffort, cwd, sessions, signal) {
|
|
41080
41217
|
const model = modelOption(initialOptions);
|
|
41081
41218
|
const unsupportedModels = initiallyUnsupportedModels;
|
|
41082
41219
|
if (resolution !== AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && resolution !== AGENT_MODEL_EFFORT_RESOLUTION_ON_MODEL_SELECTION) {
|
|
@@ -41085,6 +41222,9 @@ async function discoverModelEffort(command, agent, resolution, initialOptions, s
|
|
|
41085
41222
|
if (model === void 0 || model.type !== "select" || model.values.length === 0) {
|
|
41086
41223
|
return { ...unavailableModelEffort(), unsupportedModelIds: unsupportedModelIds(unsupportedModels) };
|
|
41087
41224
|
}
|
|
41225
|
+
if (resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE && discoveredModelEffort.kind === "complete" && discoveredModelEffort.value.resolution === AGENT_MODEL_EFFORT_RESOLUTION_COMPLETE) {
|
|
41226
|
+
return discoveredModelEffort.value;
|
|
41227
|
+
}
|
|
41088
41228
|
const inspectModel = async (modelValue) => (await sessions.inspectAgentSettings({
|
|
41089
41229
|
additionalDirectories: [],
|
|
41090
41230
|
agent,
|
|
@@ -41322,7 +41462,7 @@ function createAgentSettingsDiscoveryHandler(dependencies) {
|
|
|
41322
41462
|
|
|
41323
41463
|
// src/artifacts/local-file-streamer.ts
|
|
41324
41464
|
import { createReadStream as createReadStream2 } from "node:fs";
|
|
41325
|
-
import { realpath as
|
|
41465
|
+
import { realpath as realpath10, stat as stat9 } from "node:fs/promises";
|
|
41326
41466
|
import { basename as basename4, extname, isAbsolute as isAbsolute11, normalize as normalize4, resolve as resolve5 } from "node:path";
|
|
41327
41467
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
41328
41468
|
var CHUNK_BYTES = 192 * 1024;
|
|
@@ -41350,7 +41490,7 @@ async function resolveFile(value, workingDirectory, signal) {
|
|
|
41350
41490
|
return null;
|
|
41351
41491
|
}
|
|
41352
41492
|
try {
|
|
41353
|
-
const target = await
|
|
41493
|
+
const target = await realpath10(requested);
|
|
41354
41494
|
signal.throwIfAborted();
|
|
41355
41495
|
return isAbsolute11(target) && normalize4(target) === target ? target : null;
|
|
41356
41496
|
} catch {
|
|
@@ -41364,7 +41504,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41364
41504
|
if (target === null) {
|
|
41365
41505
|
throw new Error("The local file is unavailable");
|
|
41366
41506
|
}
|
|
41367
|
-
const before = await
|
|
41507
|
+
const before = await stat9(target);
|
|
41368
41508
|
signal.throwIfAborted();
|
|
41369
41509
|
if (!before.isFile() || before.size < 1 || before.size > command.maxBytes) {
|
|
41370
41510
|
throw new Error("The local file is too large to read");
|
|
@@ -41392,7 +41532,7 @@ async function streamLocalFile(command, send2, signal, workingDirectory, externa
|
|
|
41392
41532
|
});
|
|
41393
41533
|
sequence += 1;
|
|
41394
41534
|
}
|
|
41395
|
-
const after = await
|
|
41535
|
+
const after = await stat9(target);
|
|
41396
41536
|
signal.throwIfAborted();
|
|
41397
41537
|
if (after.size !== before.size || after.mtimeMs !== before.mtimeMs) {
|
|
41398
41538
|
throw new Error("The local file changed during transfer");
|
|
@@ -41436,6 +41576,232 @@ async function resolveSessionDirectories(directories, bindingId, directoryId2, a
|
|
|
41436
41576
|
return new ResolvedSessionDirectories(cwd, additionalDirectories, additionalDirectoryEntries);
|
|
41437
41577
|
}
|
|
41438
41578
|
|
|
41579
|
+
// src/daemon-session-commands.ts
|
|
41580
|
+
async function resolveCatalogAgent(config2, agentId, signal) {
|
|
41581
|
+
const agent = config2.catalog.find(agentId);
|
|
41582
|
+
return config2.resolveAgent === void 0 ? agent : await config2.resolveAgent(agent, signal);
|
|
41583
|
+
}
|
|
41584
|
+
async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
|
|
41585
|
+
return await metrics.measure("prepare-total", async () => {
|
|
41586
|
+
const resolved = await metrics.measure(
|
|
41587
|
+
"workspace-resolve",
|
|
41588
|
+
async () => await resolveSessionDirectories(
|
|
41589
|
+
directories,
|
|
41590
|
+
config2.bindingId,
|
|
41591
|
+
command.directoryId,
|
|
41592
|
+
command.additionalDirectoryIds,
|
|
41593
|
+
signal
|
|
41594
|
+
)
|
|
41595
|
+
);
|
|
41596
|
+
const agent = await resolveCatalogAgent(config2, command.agentId, signal);
|
|
41597
|
+
const preparation = {
|
|
41598
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41599
|
+
agent,
|
|
41600
|
+
cwd: resolved.cwd,
|
|
41601
|
+
sessionId: command.sessionId,
|
|
41602
|
+
signal
|
|
41603
|
+
};
|
|
41604
|
+
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41605
|
+
const configuration = command.configuration;
|
|
41606
|
+
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41607
|
+
"configuration",
|
|
41608
|
+
async () => await sessions.configureSession({
|
|
41609
|
+
...preparation,
|
|
41610
|
+
booleanValue: configuration.booleanValue,
|
|
41611
|
+
configId: configuration.configId,
|
|
41612
|
+
requestId: command.requestId,
|
|
41613
|
+
value: configuration.value,
|
|
41614
|
+
valueType: configuration.valueType
|
|
41615
|
+
})
|
|
41616
|
+
);
|
|
41617
|
+
const listing = await metrics.measure(
|
|
41618
|
+
"workspace-list",
|
|
41619
|
+
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
41620
|
+
);
|
|
41621
|
+
audit.record({
|
|
41622
|
+
commandId: command.requestId,
|
|
41623
|
+
event: "session_prepared",
|
|
41624
|
+
sessionId: command.sessionId
|
|
41625
|
+
});
|
|
41626
|
+
if (command.configuration !== void 0) {
|
|
41627
|
+
audit.record({
|
|
41628
|
+
commandId: command.requestId,
|
|
41629
|
+
event: "session_configured",
|
|
41630
|
+
sessionId: command.sessionId
|
|
41631
|
+
});
|
|
41632
|
+
}
|
|
41633
|
+
return {
|
|
41634
|
+
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
41635
|
+
agentId: command.agentId,
|
|
41636
|
+
agentName: prepared.agentName,
|
|
41637
|
+
agentVersion: prepared.agentVersion,
|
|
41638
|
+
capabilities: prepared.capabilities,
|
|
41639
|
+
commands: prepared.commands,
|
|
41640
|
+
configOptions,
|
|
41641
|
+
directoryId: command.directoryId,
|
|
41642
|
+
directoryLabel: listing.directoryLabel,
|
|
41643
|
+
kind: "session.ready",
|
|
41644
|
+
requestId: command.requestId,
|
|
41645
|
+
restored: prepared.restored,
|
|
41646
|
+
sessionId: command.sessionId
|
|
41647
|
+
};
|
|
41648
|
+
});
|
|
41649
|
+
}
|
|
41650
|
+
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
41651
|
+
try {
|
|
41652
|
+
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
41653
|
+
audit.record({
|
|
41654
|
+
commandId: command.requestId,
|
|
41655
|
+
event: "workspace_list_authorized",
|
|
41656
|
+
sessionId: "workspace-browser"
|
|
41657
|
+
});
|
|
41658
|
+
send(socket, {
|
|
41659
|
+
bindingId: command.bindingId,
|
|
41660
|
+
directoryId: listing.directoryId,
|
|
41661
|
+
directoryLabel: listing.directoryLabel,
|
|
41662
|
+
entries: listing.entries,
|
|
41663
|
+
kind: "workspace.entries",
|
|
41664
|
+
parentDirectoryId: listing.parentDirectoryId,
|
|
41665
|
+
requestId: command.requestId
|
|
41666
|
+
});
|
|
41667
|
+
} catch (error62) {
|
|
41668
|
+
reportOperationFailure(socket, command.requestId, "", error62);
|
|
41669
|
+
}
|
|
41670
|
+
}
|
|
41671
|
+
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
41672
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41673
|
+
try {
|
|
41674
|
+
const readyEvent = await prepareSession(
|
|
41675
|
+
command,
|
|
41676
|
+
{ kind: "interactive-only" },
|
|
41677
|
+
config2,
|
|
41678
|
+
directories,
|
|
41679
|
+
audit,
|
|
41680
|
+
sessions,
|
|
41681
|
+
metrics,
|
|
41682
|
+
signal
|
|
41683
|
+
);
|
|
41684
|
+
send(socket, {
|
|
41685
|
+
...readyEvent,
|
|
41686
|
+
runtimeTimings: metrics.snapshot()
|
|
41687
|
+
});
|
|
41688
|
+
} catch (error62) {
|
|
41689
|
+
diagnostics.daemonDiagnostic(
|
|
41690
|
+
"session_prepare_failed",
|
|
41691
|
+
command.requestId,
|
|
41692
|
+
{
|
|
41693
|
+
agentId: command.agentId,
|
|
41694
|
+
code: operationErrorCode(error62),
|
|
41695
|
+
sessionId: command.sessionId
|
|
41696
|
+
},
|
|
41697
|
+
error62
|
|
41698
|
+
);
|
|
41699
|
+
audit.record({
|
|
41700
|
+
commandId: command.requestId,
|
|
41701
|
+
details: {
|
|
41702
|
+
agentId: command.agentId,
|
|
41703
|
+
code: operationErrorCode(error62)
|
|
41704
|
+
},
|
|
41705
|
+
event: "session_prepare_failed",
|
|
41706
|
+
sessionId: command.sessionId
|
|
41707
|
+
});
|
|
41708
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41709
|
+
}
|
|
41710
|
+
}
|
|
41711
|
+
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
41712
|
+
const metrics = new AccumulatingOperationMetrics();
|
|
41713
|
+
try {
|
|
41714
|
+
const entry = await metrics.measure("session-lookup", async () => {
|
|
41715
|
+
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
41716
|
+
if (found === void 0) {
|
|
41717
|
+
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
41718
|
+
}
|
|
41719
|
+
return found;
|
|
41720
|
+
});
|
|
41721
|
+
const ready = await prepareSession(
|
|
41722
|
+
{
|
|
41723
|
+
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
41724
|
+
agentId: entry.agentId,
|
|
41725
|
+
bindingId: config2.bindingId,
|
|
41726
|
+
directoryId: entry.directoryId,
|
|
41727
|
+
kind: "session.prepare",
|
|
41728
|
+
requestId: command.requestId,
|
|
41729
|
+
sessionId: command.sessionId,
|
|
41730
|
+
sessionState: "provisioned"
|
|
41731
|
+
},
|
|
41732
|
+
{ kind: "history-required" },
|
|
41733
|
+
config2,
|
|
41734
|
+
directories,
|
|
41735
|
+
audit,
|
|
41736
|
+
sessions,
|
|
41737
|
+
metrics,
|
|
41738
|
+
signal
|
|
41739
|
+
);
|
|
41740
|
+
send(socket, {
|
|
41741
|
+
entry,
|
|
41742
|
+
kind: "session.restored",
|
|
41743
|
+
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
41744
|
+
requestId: command.requestId
|
|
41745
|
+
});
|
|
41746
|
+
} catch (error62) {
|
|
41747
|
+
diagnostics.daemonDiagnostic(
|
|
41748
|
+
"session_restore_failed",
|
|
41749
|
+
command.requestId,
|
|
41750
|
+
{
|
|
41751
|
+
code: operationErrorCode(error62),
|
|
41752
|
+
sessionId: command.sessionId
|
|
41753
|
+
},
|
|
41754
|
+
error62
|
|
41755
|
+
);
|
|
41756
|
+
audit.record({
|
|
41757
|
+
commandId: command.requestId,
|
|
41758
|
+
details: { code: operationErrorCode(error62) },
|
|
41759
|
+
event: "session_restore_failed",
|
|
41760
|
+
sessionId: command.sessionId
|
|
41761
|
+
});
|
|
41762
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
41763
|
+
}
|
|
41764
|
+
}
|
|
41765
|
+
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
41766
|
+
try {
|
|
41767
|
+
const resolved = await resolveSessionDirectories(
|
|
41768
|
+
directories,
|
|
41769
|
+
config2.bindingId,
|
|
41770
|
+
command.directoryId,
|
|
41771
|
+
command.additionalDirectoryIds,
|
|
41772
|
+
signal
|
|
41773
|
+
);
|
|
41774
|
+
const configOptions = await sessions.configureSession({
|
|
41775
|
+
additionalDirectories: resolved.additionalDirectories,
|
|
41776
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
41777
|
+
booleanValue: command.booleanValue,
|
|
41778
|
+
configId: command.configId,
|
|
41779
|
+
cwd: resolved.cwd,
|
|
41780
|
+
requestId: command.requestId,
|
|
41781
|
+
sessionId: command.sessionId,
|
|
41782
|
+
signal,
|
|
41783
|
+
value: command.value,
|
|
41784
|
+
valueType: command.valueType
|
|
41785
|
+
});
|
|
41786
|
+
audit.record({
|
|
41787
|
+
commandId: command.requestId,
|
|
41788
|
+
event: "session_configured",
|
|
41789
|
+
sessionId: command.sessionId
|
|
41790
|
+
});
|
|
41791
|
+
send(socket, {
|
|
41792
|
+
configOptions,
|
|
41793
|
+
kind: "session.config.updated",
|
|
41794
|
+
requestId: command.requestId,
|
|
41795
|
+
sessionId: command.sessionId
|
|
41796
|
+
});
|
|
41797
|
+
} catch (error62) {
|
|
41798
|
+
if (signal.aborted) {
|
|
41799
|
+
signal.throwIfAborted();
|
|
41800
|
+
}
|
|
41801
|
+
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
41802
|
+
}
|
|
41803
|
+
}
|
|
41804
|
+
|
|
41439
41805
|
// src/daemon-history-commands.ts
|
|
41440
41806
|
async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, directories, audit, diagnostics, sessions, nativeSessions, eventLogV2, signal) {
|
|
41441
41807
|
let agentId;
|
|
@@ -41454,7 +41820,7 @@ async function executeSessionLiveHistoryV2PageLoad(socket, command, config2, dir
|
|
|
41454
41820
|
);
|
|
41455
41821
|
const loadOptions = {
|
|
41456
41822
|
additionalDirectories: resolved.additionalDirectories,
|
|
41457
|
-
agent: config2
|
|
41823
|
+
agent: await resolveCatalogAgent(config2, entry.agentId, signal),
|
|
41458
41824
|
cwd: resolved.cwd,
|
|
41459
41825
|
sessionId: command.sessionId,
|
|
41460
41826
|
signal
|
|
@@ -41530,7 +41896,7 @@ async function executeSessionPreviewHistoryPageLoad(socket, command, config2, di
|
|
|
41530
41896
|
const replay = await sessions.previewNativeSessionEventsV2(
|
|
41531
41897
|
{
|
|
41532
41898
|
additionalDirectories: resolved.additionalDirectories,
|
|
41533
|
-
agent: config2
|
|
41899
|
+
agent: await resolveCatalogAgent(config2, command.agentId, signal),
|
|
41534
41900
|
cwd: resolved.cwd,
|
|
41535
41901
|
sessionId: command.sessionId,
|
|
41536
41902
|
signal
|
|
@@ -41822,7 +42188,7 @@ async function executePrompt({
|
|
|
41822
42188
|
command.additionalDirectoryIds,
|
|
41823
42189
|
signal
|
|
41824
42190
|
);
|
|
41825
|
-
const agent = config2
|
|
42191
|
+
const agent = await resolveCatalogAgent(config2, command.agentId, signal);
|
|
41826
42192
|
const availability = await waitForSessionAvailability(signal);
|
|
41827
42193
|
if (availability.kind === "busy") {
|
|
41828
42194
|
throw new AcpExecutionError("Another prompt is already running in this conversation", {}, "session_busy");
|
|
@@ -41880,7 +42246,13 @@ async function executePrompt({
|
|
|
41880
42246
|
}
|
|
41881
42247
|
}
|
|
41882
42248
|
const stream = activateAttempt();
|
|
41883
|
-
const lifecycleV2 = eventLogV2.started(
|
|
42249
|
+
const lifecycleV2 = eventLogV2.started(
|
|
42250
|
+
command.sessionId,
|
|
42251
|
+
command.commandId,
|
|
42252
|
+
attemptId,
|
|
42253
|
+
stream.epoch,
|
|
42254
|
+
availability.disposition
|
|
42255
|
+
);
|
|
41884
42256
|
const attachments = await resolvePromptArtifacts(config2, command, signal);
|
|
41885
42257
|
let stopReason;
|
|
41886
42258
|
if (availability.disposition === SessionPromptDisposition.Steer) {
|
|
@@ -41961,228 +42333,6 @@ async function executePrompt({
|
|
|
41961
42333
|
}
|
|
41962
42334
|
}
|
|
41963
42335
|
|
|
41964
|
-
// src/daemon-session-commands.ts
|
|
41965
|
-
async function prepareSession(command, recovery, config2, directories, audit, sessions, metrics, signal) {
|
|
41966
|
-
return await metrics.measure("prepare-total", async () => {
|
|
41967
|
-
const resolved = await metrics.measure(
|
|
41968
|
-
"workspace-resolve",
|
|
41969
|
-
async () => await resolveSessionDirectories(
|
|
41970
|
-
directories,
|
|
41971
|
-
config2.bindingId,
|
|
41972
|
-
command.directoryId,
|
|
41973
|
-
command.additionalDirectoryIds,
|
|
41974
|
-
signal
|
|
41975
|
-
)
|
|
41976
|
-
);
|
|
41977
|
-
const agent = config2.catalog.find(command.agentId);
|
|
41978
|
-
const preparation = {
|
|
41979
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
41980
|
-
agent,
|
|
41981
|
-
cwd: resolved.cwd,
|
|
41982
|
-
sessionId: command.sessionId,
|
|
41983
|
-
signal
|
|
41984
|
-
};
|
|
41985
|
-
const prepared = command.transient === true ? await sessions.inspectSession(preparation, metrics) : recovery.kind === "history-required" ? await sessions.restoreSession(preparation, metrics) : await sessions.prepareSession(preparation, metrics);
|
|
41986
|
-
const configuration = command.configuration;
|
|
41987
|
-
const configOptions = configuration === void 0 ? prepared.configOptions : await metrics.measure(
|
|
41988
|
-
"configuration",
|
|
41989
|
-
async () => await sessions.configureSession({
|
|
41990
|
-
...preparation,
|
|
41991
|
-
booleanValue: configuration.booleanValue,
|
|
41992
|
-
configId: configuration.configId,
|
|
41993
|
-
requestId: command.requestId,
|
|
41994
|
-
value: configuration.value,
|
|
41995
|
-
valueType: configuration.valueType
|
|
41996
|
-
})
|
|
41997
|
-
);
|
|
41998
|
-
const listing = await metrics.measure(
|
|
41999
|
-
"workspace-list",
|
|
42000
|
-
async () => await directories.list(config2.bindingId, command.directoryId, signal)
|
|
42001
|
-
);
|
|
42002
|
-
audit.record({
|
|
42003
|
-
commandId: command.requestId,
|
|
42004
|
-
event: "session_prepared",
|
|
42005
|
-
sessionId: command.sessionId
|
|
42006
|
-
});
|
|
42007
|
-
if (command.configuration !== void 0) {
|
|
42008
|
-
audit.record({
|
|
42009
|
-
commandId: command.requestId,
|
|
42010
|
-
event: "session_configured",
|
|
42011
|
-
sessionId: command.sessionId
|
|
42012
|
-
});
|
|
42013
|
-
}
|
|
42014
|
-
return {
|
|
42015
|
-
additionalDirectories: resolved.additionalDirectoryEntries,
|
|
42016
|
-
agentId: command.agentId,
|
|
42017
|
-
agentName: prepared.agentName,
|
|
42018
|
-
agentVersion: prepared.agentVersion,
|
|
42019
|
-
capabilities: prepared.capabilities,
|
|
42020
|
-
commands: prepared.commands,
|
|
42021
|
-
configOptions,
|
|
42022
|
-
directoryId: command.directoryId,
|
|
42023
|
-
directoryLabel: listing.directoryLabel,
|
|
42024
|
-
kind: "session.ready",
|
|
42025
|
-
requestId: command.requestId,
|
|
42026
|
-
restored: prepared.restored,
|
|
42027
|
-
sessionId: command.sessionId
|
|
42028
|
-
};
|
|
42029
|
-
});
|
|
42030
|
-
}
|
|
42031
|
-
async function executeWorkspaceList(socket, command, directories, audit, signal) {
|
|
42032
|
-
try {
|
|
42033
|
-
const listing = await directories.list(command.bindingId, command.directoryId, signal);
|
|
42034
|
-
audit.record({
|
|
42035
|
-
commandId: command.requestId,
|
|
42036
|
-
event: "workspace_list_authorized",
|
|
42037
|
-
sessionId: "workspace-browser"
|
|
42038
|
-
});
|
|
42039
|
-
send(socket, {
|
|
42040
|
-
bindingId: command.bindingId,
|
|
42041
|
-
directoryId: listing.directoryId,
|
|
42042
|
-
directoryLabel: listing.directoryLabel,
|
|
42043
|
-
entries: listing.entries,
|
|
42044
|
-
kind: "workspace.entries",
|
|
42045
|
-
parentDirectoryId: listing.parentDirectoryId,
|
|
42046
|
-
requestId: command.requestId
|
|
42047
|
-
});
|
|
42048
|
-
} catch (error62) {
|
|
42049
|
-
reportOperationFailure(socket, command.requestId, "", error62);
|
|
42050
|
-
}
|
|
42051
|
-
}
|
|
42052
|
-
async function executeSessionPrepare(socket, command, config2, directories, audit, sessions, diagnostics, signal) {
|
|
42053
|
-
const metrics = new AccumulatingOperationMetrics();
|
|
42054
|
-
try {
|
|
42055
|
-
const readyEvent = await prepareSession(
|
|
42056
|
-
command,
|
|
42057
|
-
{ kind: "interactive-only" },
|
|
42058
|
-
config2,
|
|
42059
|
-
directories,
|
|
42060
|
-
audit,
|
|
42061
|
-
sessions,
|
|
42062
|
-
metrics,
|
|
42063
|
-
signal
|
|
42064
|
-
);
|
|
42065
|
-
send(socket, {
|
|
42066
|
-
...readyEvent,
|
|
42067
|
-
runtimeTimings: metrics.snapshot()
|
|
42068
|
-
});
|
|
42069
|
-
} catch (error62) {
|
|
42070
|
-
diagnostics.daemonDiagnostic(
|
|
42071
|
-
"session_prepare_failed",
|
|
42072
|
-
command.requestId,
|
|
42073
|
-
{
|
|
42074
|
-
agentId: command.agentId,
|
|
42075
|
-
code: operationErrorCode(error62),
|
|
42076
|
-
sessionId: command.sessionId
|
|
42077
|
-
},
|
|
42078
|
-
error62
|
|
42079
|
-
);
|
|
42080
|
-
audit.record({
|
|
42081
|
-
commandId: command.requestId,
|
|
42082
|
-
details: {
|
|
42083
|
-
agentId: command.agentId,
|
|
42084
|
-
code: operationErrorCode(error62)
|
|
42085
|
-
},
|
|
42086
|
-
event: "session_prepare_failed",
|
|
42087
|
-
sessionId: command.sessionId
|
|
42088
|
-
});
|
|
42089
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42090
|
-
}
|
|
42091
|
-
}
|
|
42092
|
-
async function executeSessionRestore(socket, command, config2, directories, audit, sessions, nativeSessions, diagnostics, signal) {
|
|
42093
|
-
const metrics = new AccumulatingOperationMetrics();
|
|
42094
|
-
try {
|
|
42095
|
-
const entry = await metrics.measure("session-lookup", async () => {
|
|
42096
|
-
const [found] = await nativeSessions.querySessions([command.sessionId], signal);
|
|
42097
|
-
if (found === void 0) {
|
|
42098
|
-
throw new AcpExecutionError("The Session was not found", {}, "session_not_found");
|
|
42099
|
-
}
|
|
42100
|
-
return found;
|
|
42101
|
-
});
|
|
42102
|
-
const ready = await prepareSession(
|
|
42103
|
-
{
|
|
42104
|
-
additionalDirectoryIds: entry.additionalDirectories.map((directory) => directory.directoryId),
|
|
42105
|
-
agentId: entry.agentId,
|
|
42106
|
-
bindingId: config2.bindingId,
|
|
42107
|
-
directoryId: entry.directoryId,
|
|
42108
|
-
kind: "session.prepare",
|
|
42109
|
-
requestId: command.requestId,
|
|
42110
|
-
sessionId: command.sessionId,
|
|
42111
|
-
sessionState: "provisioned"
|
|
42112
|
-
},
|
|
42113
|
-
{ kind: "history-required" },
|
|
42114
|
-
config2,
|
|
42115
|
-
directories,
|
|
42116
|
-
audit,
|
|
42117
|
-
sessions,
|
|
42118
|
-
metrics,
|
|
42119
|
-
signal
|
|
42120
|
-
);
|
|
42121
|
-
send(socket, {
|
|
42122
|
-
entry,
|
|
42123
|
-
kind: "session.restored",
|
|
42124
|
-
ready: { ...ready, runtimeTimings: metrics.snapshot() },
|
|
42125
|
-
requestId: command.requestId
|
|
42126
|
-
});
|
|
42127
|
-
} catch (error62) {
|
|
42128
|
-
diagnostics.daemonDiagnostic(
|
|
42129
|
-
"session_restore_failed",
|
|
42130
|
-
command.requestId,
|
|
42131
|
-
{
|
|
42132
|
-
code: operationErrorCode(error62),
|
|
42133
|
-
sessionId: command.sessionId
|
|
42134
|
-
},
|
|
42135
|
-
error62
|
|
42136
|
-
);
|
|
42137
|
-
audit.record({
|
|
42138
|
-
commandId: command.requestId,
|
|
42139
|
-
details: { code: operationErrorCode(error62) },
|
|
42140
|
-
event: "session_restore_failed",
|
|
42141
|
-
sessionId: command.sessionId
|
|
42142
|
-
});
|
|
42143
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62, metrics.snapshot());
|
|
42144
|
-
}
|
|
42145
|
-
}
|
|
42146
|
-
async function executeSessionConfigure(socket, command, config2, directories, audit, sessions, signal) {
|
|
42147
|
-
try {
|
|
42148
|
-
const resolved = await resolveSessionDirectories(
|
|
42149
|
-
directories,
|
|
42150
|
-
config2.bindingId,
|
|
42151
|
-
command.directoryId,
|
|
42152
|
-
command.additionalDirectoryIds,
|
|
42153
|
-
signal
|
|
42154
|
-
);
|
|
42155
|
-
const configOptions = await sessions.configureSession({
|
|
42156
|
-
additionalDirectories: resolved.additionalDirectories,
|
|
42157
|
-
agent: config2.catalog.find(command.agentId),
|
|
42158
|
-
booleanValue: command.booleanValue,
|
|
42159
|
-
configId: command.configId,
|
|
42160
|
-
cwd: resolved.cwd,
|
|
42161
|
-
requestId: command.requestId,
|
|
42162
|
-
sessionId: command.sessionId,
|
|
42163
|
-
signal,
|
|
42164
|
-
value: command.value,
|
|
42165
|
-
valueType: command.valueType
|
|
42166
|
-
});
|
|
42167
|
-
audit.record({
|
|
42168
|
-
commandId: command.requestId,
|
|
42169
|
-
event: "session_configured",
|
|
42170
|
-
sessionId: command.sessionId
|
|
42171
|
-
});
|
|
42172
|
-
send(socket, {
|
|
42173
|
-
configOptions,
|
|
42174
|
-
kind: "session.config.updated",
|
|
42175
|
-
requestId: command.requestId,
|
|
42176
|
-
sessionId: command.sessionId
|
|
42177
|
-
});
|
|
42178
|
-
} catch (error62) {
|
|
42179
|
-
if (signal.aborted) {
|
|
42180
|
-
signal.throwIfAborted();
|
|
42181
|
-
}
|
|
42182
|
-
reportOperationFailure(socket, command.requestId, command.sessionId, error62);
|
|
42183
|
-
}
|
|
42184
|
-
}
|
|
42185
|
-
|
|
42186
42336
|
// src/native-sessions/handle-native-requests.ts
|
|
42187
42337
|
import { WebSocket as WebSocket4 } from "undici";
|
|
42188
42338
|
function createNativeSessionRequestHandler(dependencies) {
|
|
@@ -43190,20 +43340,29 @@ var DaemonSessionEventLogV2 = class {
|
|
|
43190
43340
|
this.#queued.set(command.commandId, {
|
|
43191
43341
|
commandId: command.commandId,
|
|
43192
43342
|
content: promptContent(command),
|
|
43343
|
+
...command.disposition === void 0 ? {} : { disposition: command.disposition },
|
|
43193
43344
|
context: {
|
|
43194
43345
|
agentId: command.agentId,
|
|
43195
43346
|
directoryId: command.directoryId,
|
|
43196
43347
|
additionalDirectoryIds: command.additionalDirectoryIds
|
|
43197
43348
|
},
|
|
43198
43349
|
phase: "queued",
|
|
43199
|
-
sessionId: command.sessionId
|
|
43350
|
+
sessionId: command.sessionId,
|
|
43351
|
+
...command.targetCommandId.length === 0 ? {} : { targetCommandId: command.targetCommandId }
|
|
43200
43352
|
});
|
|
43201
43353
|
};
|
|
43202
|
-
started = (sessionId, commandId, attemptId, epoch) => {
|
|
43354
|
+
started = (sessionId, commandId, attemptId, epoch, disposition) => {
|
|
43203
43355
|
const request = this.#queued.get(commandId);
|
|
43204
43356
|
if (request?.sessionId === sessionId) {
|
|
43205
43357
|
this.#queued.set(commandId, { ...request, phase: "running" });
|
|
43206
|
-
return {
|
|
43358
|
+
return {
|
|
43359
|
+
attemptId,
|
|
43360
|
+
content: request.content,
|
|
43361
|
+
disposition,
|
|
43362
|
+
epoch,
|
|
43363
|
+
context: request.context,
|
|
43364
|
+
...request.targetCommandId === void 0 ? {} : { targetCommandId: request.targetCommandId }
|
|
43365
|
+
};
|
|
43207
43366
|
}
|
|
43208
43367
|
throw new Error("The executing prompt was not registered in the V2 queue");
|
|
43209
43368
|
};
|
|
@@ -43290,7 +43449,12 @@ var DaemonSessionEventLogV2 = class {
|
|
|
43290
43449
|
}
|
|
43291
43450
|
};
|
|
43292
43451
|
promptRequestRecovery = (sessionId) => ({
|
|
43293
|
-
queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && request.phase === "queued").map(({ commandId, content }) => ({
|
|
43452
|
+
queuedPromptRequests: [...this.#queued.values()].filter((request) => request.sessionId === sessionId && request.phase === "queued").map(({ commandId, content, disposition, targetCommandId }) => ({
|
|
43453
|
+
commandId,
|
|
43454
|
+
content,
|
|
43455
|
+
...disposition === void 0 ? {} : { disposition },
|
|
43456
|
+
...targetCommandId === void 0 ? {} : { targetCommandId }
|
|
43457
|
+
}))
|
|
43294
43458
|
});
|
|
43295
43459
|
};
|
|
43296
43460
|
|
|
@@ -43361,11 +43525,11 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43361
43525
|
stateDirectory
|
|
43362
43526
|
});
|
|
43363
43527
|
const channelHash = createHash7("sha256").update(config2.channelId).digest("hex");
|
|
43364
|
-
const sessionDatabase = openAcpSessionDatabase(
|
|
43528
|
+
const sessionDatabase = openAcpSessionDatabase(join20(stateDirectory, "sessions", `${channelHash}.sqlite`));
|
|
43365
43529
|
let eventsV2;
|
|
43366
43530
|
try {
|
|
43367
43531
|
eventsV2 = new CachedAcpSessionEventStoreV2(
|
|
43368
|
-
openSessionEventCacheV2Database(
|
|
43532
|
+
openSessionEventCacheV2Database(join20(stateDirectory, "sessions", `${channelHash}.events.sqlite`))
|
|
43369
43533
|
);
|
|
43370
43534
|
} catch (error62) {
|
|
43371
43535
|
sessionDatabase.close();
|
|
@@ -43568,7 +43732,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer, opti
|
|
|
43568
43732
|
}
|
|
43569
43733
|
|
|
43570
43734
|
// src/pairing/pair-local-machine.ts
|
|
43571
|
-
import { mkdir as mkdir6, realpath as
|
|
43735
|
+
import { mkdir as mkdir6, realpath as realpath11, stat as stat10 } from "node:fs/promises";
|
|
43572
43736
|
import { hostname as hostname3 } from "node:os";
|
|
43573
43737
|
import { basename as basename6, resolve as resolve7 } from "node:path";
|
|
43574
43738
|
import { fetch as fetch4 } from "undici";
|
|
@@ -43576,7 +43740,7 @@ import { fetch as fetch4 } from "undici";
|
|
|
43576
43740
|
// src/storage/runtime-installation-store.ts
|
|
43577
43741
|
import { createHash as createHash8, randomUUID as randomUUID9 } from "node:crypto";
|
|
43578
43742
|
import { mkdir as mkdir5, open as open5, readdir as readdir4, rename as rename4, unlink, writeFile as writeFile4 } from "node:fs/promises";
|
|
43579
|
-
import { dirname as dirname6, join as
|
|
43743
|
+
import { dirname as dirname6, join as join21, resolve as resolve6 } from "node:path";
|
|
43580
43744
|
var APPLICATION_ID_PATTERN = /^[a-z][a-z0-9]*(?:[.-][a-z0-9]+){1,31}$/;
|
|
43581
43745
|
var CONNECTION_ID_PATTERN = /^mcn_[a-f0-9]{32}$/;
|
|
43582
43746
|
var INSTALLATION_ID_PATTERN = /^min_[a-f0-9]{32}$/;
|
|
@@ -43819,7 +43983,7 @@ async function readJsonFile(path2, signal, missingCode) {
|
|
|
43819
43983
|
async function writeJsonAtomically(path2, value, signal) {
|
|
43820
43984
|
signal.throwIfAborted();
|
|
43821
43985
|
const directory = dirname6(path2);
|
|
43822
|
-
const temporaryPath =
|
|
43986
|
+
const temporaryPath = join21(directory, `.${randomUUID9()}.tmp`);
|
|
43823
43987
|
try {
|
|
43824
43988
|
await mkdir5(directory, { mode: 448, recursive: true });
|
|
43825
43989
|
signal.throwIfAborted();
|
|
@@ -43845,14 +44009,14 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43845
44009
|
this.applicationId = applicationId;
|
|
43846
44010
|
this.installationId = installationId2;
|
|
43847
44011
|
this.stateDirectory = stateDirectory;
|
|
43848
|
-
this.#channelDirectory =
|
|
43849
|
-
this.#connectionDirectory =
|
|
44012
|
+
this.#channelDirectory = join21(stateDirectory, "channels");
|
|
44013
|
+
this.#connectionDirectory = join21(stateDirectory, "connections");
|
|
43850
44014
|
}
|
|
43851
44015
|
static open = async (options, signal) => {
|
|
43852
44016
|
signal.throwIfAborted();
|
|
43853
44017
|
const applicationId = validateApplicationId(options.applicationId);
|
|
43854
44018
|
const rootDirectory = resolve6(options.stateDirectory);
|
|
43855
|
-
const applicationDirectory =
|
|
44019
|
+
const applicationDirectory = join21(rootDirectory, "installations", applicationId);
|
|
43856
44020
|
try {
|
|
43857
44021
|
await mkdir5(applicationDirectory, { mode: 448, recursive: true });
|
|
43858
44022
|
} catch (cause) {
|
|
@@ -43865,7 +44029,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43865
44029
|
);
|
|
43866
44030
|
}
|
|
43867
44031
|
const storedInstallationId = await readOrCreateInstallationId(applicationDirectory, signal);
|
|
43868
|
-
const stateDirectory =
|
|
44032
|
+
const stateDirectory = join21(applicationDirectory, storedInstallationId);
|
|
43869
44033
|
try {
|
|
43870
44034
|
await mkdir5(stateDirectory, { mode: 448, recursive: true });
|
|
43871
44035
|
} catch (cause) {
|
|
@@ -43880,8 +44044,8 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
43880
44044
|
signal.throwIfAborted();
|
|
43881
44045
|
return new _RuntimeInstallationStore(applicationId, storedInstallationId, stateDirectory);
|
|
43882
44046
|
};
|
|
43883
|
-
connectionPath = (connectionId2) =>
|
|
43884
|
-
channelIndexPath = (channelId) =>
|
|
44047
|
+
connectionPath = (connectionId2) => join21(this.#connectionDirectory, `${validateConnectionId(connectionId2)}.json`);
|
|
44048
|
+
channelIndexPath = (channelId) => join21(this.#channelDirectory, channelIndexFileName(validateIdentifier(channelId, "invalid_channel_id")));
|
|
43885
44049
|
readConnection = async (connectionId2, signal) => {
|
|
43886
44050
|
const stored = decodeConnection(
|
|
43887
44051
|
await readJsonFile(this.connectionPath(connectionId2), signal, "connection_not_found")
|
|
@@ -44043,7 +44207,7 @@ var RuntimeInstallationStore = class _RuntimeInstallationStore {
|
|
|
44043
44207
|
};
|
|
44044
44208
|
};
|
|
44045
44209
|
async function readOrCreateInstallationId(applicationDirectory, signal) {
|
|
44046
|
-
const pointerPath =
|
|
44210
|
+
const pointerPath = join21(applicationDirectory, "current.json");
|
|
44047
44211
|
try {
|
|
44048
44212
|
return decodeInstallationPointer(await readJsonFile(pointerPath, signal, "installation_not_found")).installationId;
|
|
44049
44213
|
} catch (cause) {
|
|
@@ -44138,8 +44302,8 @@ async function resolveDefaultWorkspace2(path2) {
|
|
|
44138
44302
|
const requestedWorkspace = resolve7(path2);
|
|
44139
44303
|
try {
|
|
44140
44304
|
await mkdir6(requestedWorkspace, { recursive: true, mode: 448 });
|
|
44141
|
-
const defaultWorkspace = await
|
|
44142
|
-
const metadata = await
|
|
44305
|
+
const defaultWorkspace = await realpath11(requestedWorkspace);
|
|
44306
|
+
const metadata = await stat10(defaultWorkspace);
|
|
44143
44307
|
if (!metadata.isDirectory()) {
|
|
44144
44308
|
throw new PairingClientError("invalid_workspace", "The default workspace is not a directory");
|
|
44145
44309
|
}
|
|
@@ -44238,20 +44402,30 @@ function buildPairedDaemon(installation, connection, defaultWorkspace, inventory
|
|
|
44238
44402
|
const relayUrl = mobiusApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
|
|
44239
44403
|
relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
44240
44404
|
relayUrl.searchParams.set("token", connection.runtimeCredential);
|
|
44405
|
+
const config2 = createDaemonConfig(
|
|
44406
|
+
{
|
|
44407
|
+
defaultWorkspace,
|
|
44408
|
+
channelId: connection.channelId,
|
|
44409
|
+
relayUrl
|
|
44410
|
+
},
|
|
44411
|
+
inventory.readyAgents(),
|
|
44412
|
+
inventory.installable,
|
|
44413
|
+
localContext,
|
|
44414
|
+
new OpaqueDaemonReconnectTarget(connection.connectionId),
|
|
44415
|
+
createCatalogAgentResolver(
|
|
44416
|
+
(refreshSignal) => discoverLocalAgentInventory({
|
|
44417
|
+
defaultWorkspace,
|
|
44418
|
+
environment: localContext.environment,
|
|
44419
|
+
signal: refreshSignal
|
|
44420
|
+
}),
|
|
44421
|
+
() => config2,
|
|
44422
|
+
publishAgentCatalog
|
|
44423
|
+
)
|
|
44424
|
+
);
|
|
44241
44425
|
return {
|
|
44242
44426
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
44243
44427
|
connectionId: connection.connectionId,
|
|
44244
|
-
config:
|
|
44245
|
-
{
|
|
44246
|
-
defaultWorkspace,
|
|
44247
|
-
channelId: connection.channelId,
|
|
44248
|
-
relayUrl
|
|
44249
|
-
},
|
|
44250
|
-
inventory.readyAgents(),
|
|
44251
|
-
inventory.installable,
|
|
44252
|
-
localContext,
|
|
44253
|
-
new OpaqueDaemonReconnectTarget(connection.connectionId)
|
|
44254
|
-
),
|
|
44428
|
+
config: config2,
|
|
44255
44429
|
connectionPath: installation.connectionPath(connection.connectionId)
|
|
44256
44430
|
};
|
|
44257
44431
|
}
|
|
@@ -44374,8 +44548,8 @@ async function resolveWorkspace(path2) {
|
|
|
44374
44548
|
const requested = resolve8(path2);
|
|
44375
44549
|
try {
|
|
44376
44550
|
await mkdir7(requested, { recursive: true, mode: 448 });
|
|
44377
|
-
const resolved = await
|
|
44378
|
-
const metadata = await
|
|
44551
|
+
const resolved = await realpath12(requested);
|
|
44552
|
+
const metadata = await stat11(resolved);
|
|
44379
44553
|
if (!metadata.isDirectory()) {
|
|
44380
44554
|
throw new MobiusRuntimeConfigurationError("The Runtime workspace is not a directory");
|
|
44381
44555
|
}
|
|
@@ -44392,26 +44566,35 @@ async function createMobiusRuntimeEngine(connection, signal, environment = proce
|
|
|
44392
44566
|
const localContext = new DaemonLocalContext(readStateDirectory(environment), environment);
|
|
44393
44567
|
const relayUrl = relayUrlFromConnection(connection);
|
|
44394
44568
|
const defaultWorkspace = await resolveWorkspace(connection.defaultWorkspace);
|
|
44395
|
-
const
|
|
44569
|
+
const specifications = supportedLocalAgentSpecifications();
|
|
44570
|
+
const discoveryEnvironment = localContext.environment;
|
|
44571
|
+
const discover = async (refreshSignal) => await discoverLocalAgentInventory({
|
|
44396
44572
|
defaultWorkspace,
|
|
44397
|
-
environment:
|
|
44398
|
-
signal
|
|
44573
|
+
environment: discoveryEnvironment,
|
|
44574
|
+
signal: refreshSignal,
|
|
44575
|
+
specifications
|
|
44399
44576
|
});
|
|
44577
|
+
const inventory = await discover(signal);
|
|
44400
44578
|
if (inventory.available.length + inventory.installable.length === 0) {
|
|
44401
44579
|
throw new MobiusRuntimeConfigurationError("No supported Agent is available for the local Runtime");
|
|
44402
44580
|
}
|
|
44403
|
-
|
|
44404
|
-
|
|
44405
|
-
|
|
44406
|
-
|
|
44407
|
-
|
|
44408
|
-
|
|
44409
|
-
|
|
44410
|
-
|
|
44411
|
-
|
|
44412
|
-
|
|
44581
|
+
const config2 = createDaemonConfig(
|
|
44582
|
+
{
|
|
44583
|
+
channelId: connection.channelId,
|
|
44584
|
+
defaultWorkspace,
|
|
44585
|
+
relayUrl
|
|
44586
|
+
},
|
|
44587
|
+
inventory.readyAgents(),
|
|
44588
|
+
inventory.installable,
|
|
44589
|
+
localContext,
|
|
44590
|
+
null,
|
|
44591
|
+
createCatalogAgentResolver(
|
|
44592
|
+
(refreshSignal) => discover(refreshSignal),
|
|
44593
|
+
() => config2,
|
|
44594
|
+
publishAgentCatalog
|
|
44413
44595
|
)
|
|
44414
44596
|
);
|
|
44597
|
+
return new MobiusRuntimeEngine(config2);
|
|
44415
44598
|
}
|
|
44416
44599
|
var MobiusRuntimeEngine = class {
|
|
44417
44600
|
#config;
|