@moxt-ai/mobius 0.0.28 → 0.0.29
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/agent-catalog/acp-readiness-probe.d.ts.map +1 -1
- package/dist/agent-catalog/acp-readiness-probe.js +2 -2
- package/dist/agent-catalog/acp-readiness-probe.js.map +1 -1
- package/dist/agent-catalog/agent-specification.d.ts +3 -0
- package/dist/agent-catalog/agent-specification.d.ts.map +1 -1
- package/dist/agent-catalog/agent-specification.js +3 -0
- package/dist/agent-catalog/agent-specification.js.map +1 -1
- package/dist/agent-catalog/agents/copilot-cli-agent.d.ts +18 -0
- package/dist/agent-catalog/agents/copilot-cli-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/copilot-cli-agent.js +29 -0
- package/dist/agent-catalog/agents/copilot-cli-agent.js.map +1 -0
- package/dist/agent-catalog/agents/gemini-cli-agent.d.ts +14 -0
- package/dist/agent-catalog/agents/gemini-cli-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/gemini-cli-agent.js +30 -0
- package/dist/agent-catalog/agents/gemini-cli-agent.js.map +1 -0
- package/dist/agent-catalog/agents/hermes-agent.d.ts +18 -0
- package/dist/agent-catalog/agents/hermes-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/hermes-agent.js +32 -0
- package/dist/agent-catalog/agents/hermes-agent.js.map +1 -0
- package/dist/agent-catalog/agents/resolve-user-local-executable.d.ts +4 -0
- package/dist/agent-catalog/agents/resolve-user-local-executable.d.ts.map +1 -0
- package/dist/agent-catalog/agents/resolve-user-local-executable.js +14 -0
- package/dist/agent-catalog/agents/resolve-user-local-executable.js.map +1 -0
- package/dist/agent-catalog/agents/supported-agent-specifications.d.ts.map +1 -1
- package/dist/agent-catalog/agents/supported-agent-specifications.js +6 -0
- package/dist/agent-catalog/agents/supported-agent-specifications.js.map +1 -1
- package/dist/agent-catalog/discover-agent.d.ts.map +1 -1
- package/dist/agent-catalog/discover-agent.js +2 -2
- package/dist/agent-catalog/discover-agent.js.map +1 -1
- package/dist/agent-catalog/discover-local-agents.d.ts +3 -0
- package/dist/agent-catalog/discover-local-agents.d.ts.map +1 -1
- package/dist/agent-catalog/discover-local-agents.js +3 -0
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-catalog/executable-discovery.d.ts +1 -2
- package/dist/agent-catalog/executable-discovery.d.ts.map +1 -1
- package/dist/agent-catalog/executable-discovery.js +4 -6
- package/dist/agent-catalog/executable-discovery.js.map +1 -1
- package/dist/agent-catalog/version-output.d.ts +2 -0
- package/dist/agent-catalog/version-output.d.ts.map +1 -0
- package/dist/agent-catalog/version-output.js +4 -0
- package/dist/agent-catalog/version-output.js.map +1 -0
- package/dist/cli.js +372 -233
- package/dist/cli.js.map +4 -4
- package/dist/index.js +361 -224
- package/dist/index.js.map +4 -4
- package/dist/runtime.js +373 -234
- package/dist/runtime.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -18903,6 +18903,28 @@ function date4(params) {
|
|
|
18903
18903
|
|
|
18904
18904
|
// ../protocol/src/prompt-usage.ts
|
|
18905
18905
|
var TOKEN_COUNT = external_exports.number().int().nonnegative();
|
|
18906
|
+
function normalizeQuotaTokenCount(value) {
|
|
18907
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
18908
|
+
return value;
|
|
18909
|
+
}
|
|
18910
|
+
if (Reflect.has(value, "inputTokens") || Reflect.has(value, "outputTokens") || Reflect.has(value, "totalTokens")) {
|
|
18911
|
+
return value;
|
|
18912
|
+
}
|
|
18913
|
+
if (!Reflect.has(value, "input_tokens") && !Reflect.has(value, "output_tokens")) {
|
|
18914
|
+
return value;
|
|
18915
|
+
}
|
|
18916
|
+
const inputTokens = Reflect.get(value, "input_tokens");
|
|
18917
|
+
const outputTokens = Reflect.get(value, "output_tokens");
|
|
18918
|
+
const reportedTotal = Reflect.get(value, "total_tokens");
|
|
18919
|
+
return {
|
|
18920
|
+
cachedInputTokens: Reflect.get(value, "cached_input_tokens"),
|
|
18921
|
+
cachedWriteTokens: Reflect.get(value, "cached_write_tokens"),
|
|
18922
|
+
inputTokens,
|
|
18923
|
+
outputTokens,
|
|
18924
|
+
reasoningOutputTokens: Reflect.get(value, "reasoning_output_tokens"),
|
|
18925
|
+
totalTokens: reportedTotal === void 0 && typeof inputTokens === "number" && typeof outputTokens === "number" ? inputTokens + outputTokens : reportedTotal
|
|
18926
|
+
};
|
|
18927
|
+
}
|
|
18906
18928
|
var promptUsageSchema = external_exports.object({
|
|
18907
18929
|
cachedReadTokens: TOKEN_COUNT.nullish(),
|
|
18908
18930
|
cachedWriteTokens: TOKEN_COUNT.nullish(),
|
|
@@ -18911,14 +18933,17 @@ var promptUsageSchema = external_exports.object({
|
|
|
18911
18933
|
thoughtTokens: TOKEN_COUNT.nullish(),
|
|
18912
18934
|
totalTokens: TOKEN_COUNT
|
|
18913
18935
|
}).readonly();
|
|
18914
|
-
var quotaTokenCountSchema = external_exports.
|
|
18915
|
-
|
|
18916
|
-
|
|
18917
|
-
|
|
18918
|
-
|
|
18919
|
-
|
|
18920
|
-
|
|
18921
|
-
|
|
18936
|
+
var quotaTokenCountSchema = external_exports.preprocess(
|
|
18937
|
+
normalizeQuotaTokenCount,
|
|
18938
|
+
external_exports.object({
|
|
18939
|
+
cachedInputTokens: TOKEN_COUNT.optional(),
|
|
18940
|
+
cachedWriteTokens: TOKEN_COUNT.optional(),
|
|
18941
|
+
inputTokens: TOKEN_COUNT,
|
|
18942
|
+
outputTokens: TOKEN_COUNT,
|
|
18943
|
+
reasoningOutputTokens: TOKEN_COUNT.optional(),
|
|
18944
|
+
totalTokens: TOKEN_COUNT
|
|
18945
|
+
}).readonly()
|
|
18946
|
+
);
|
|
18922
18947
|
var promptMetadataSchema = external_exports.object({
|
|
18923
18948
|
quota: external_exports.object({
|
|
18924
18949
|
model_usage: external_exports.array(
|
|
@@ -25759,7 +25784,7 @@ var BotOutboundIpcServer = class {
|
|
|
25759
25784
|
import { randomUUID as randomUUID3 } from "node:crypto";
|
|
25760
25785
|
import { mkdir as mkdir4, open as open4, realpath as realpath7, rename as rename3, stat as stat7, writeFile as writeFile2 } from "node:fs/promises";
|
|
25761
25786
|
import { hostname as hostname3 } from "node:os";
|
|
25762
|
-
import { basename as basename2, join as
|
|
25787
|
+
import { basename as basename2, join as join15, resolve as resolve3 } from "node:path";
|
|
25763
25788
|
import { fetch as fetch3 } from "undici";
|
|
25764
25789
|
|
|
25765
25790
|
// src/agent-catalog/agent-discovery.ts
|
|
@@ -26189,6 +26214,13 @@ var ManagedNpmPackageInstaller = class {
|
|
|
26189
26214
|
|
|
26190
26215
|
// src/agent-catalog/agent-specification.ts
|
|
26191
26216
|
import { join as join5 } from "node:path";
|
|
26217
|
+
|
|
26218
|
+
// src/agent-catalog/version-output.ts
|
|
26219
|
+
function normalizeVersionOutput(output2) {
|
|
26220
|
+
return output2.trim().split(/\r?\n/, 1)[0]?.trim().slice(0, 128) ?? "";
|
|
26221
|
+
}
|
|
26222
|
+
|
|
26223
|
+
// src/agent-catalog/agent-specification.ts
|
|
26192
26224
|
var VERSION_PROBE_TIMEOUT_MILLISECONDS = 3e3;
|
|
26193
26225
|
var ACP_PROBE_TIMEOUT_MILLISECONDS = 5e3;
|
|
26194
26226
|
var DEFAULT_PROMPT_TIMEOUT_MILLISECONDS = 30 * 60 * 1e3;
|
|
@@ -26197,6 +26229,8 @@ var LocalAgentSpecification = class {
|
|
|
26197
26229
|
authenticationCommand = () => "";
|
|
26198
26230
|
adapterVersionArguments = ["--version"];
|
|
26199
26231
|
agentVersionArguments = ["--version"];
|
|
26232
|
+
normalizeAdapterVersion = normalizeVersionOutput;
|
|
26233
|
+
normalizeAgentVersion = normalizeVersionOutput;
|
|
26200
26234
|
promptTimeoutMilliseconds = DEFAULT_PROMPT_TIMEOUT_MILLISECONDS;
|
|
26201
26235
|
versionProbeTimeoutMilliseconds = VERSION_PROBE_TIMEOUT_MILLISECONDS;
|
|
26202
26236
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
@@ -26308,6 +26342,20 @@ var AgentProbeError = class extends Error {
|
|
|
26308
26342
|
}
|
|
26309
26343
|
};
|
|
26310
26344
|
|
|
26345
|
+
// src/agent-catalog/agents/resolve-user-local-executable.ts
|
|
26346
|
+
import { isAbsolute as isAbsolute4, join as join6 } from "node:path";
|
|
26347
|
+
async function resolveUserLocalExecutable(executableName, context) {
|
|
26348
|
+
context.signal.throwIfAborted();
|
|
26349
|
+
const platform = context.platform ?? process.platform;
|
|
26350
|
+
const homeDirectory = context.environment["HOME"];
|
|
26351
|
+
if (platform === "win32" || homeDirectory === void 0 || !isAbsolute4(homeDirectory)) {
|
|
26352
|
+
return [];
|
|
26353
|
+
}
|
|
26354
|
+
const executable = await resolveExecutablePath(join6(homeDirectory, ".local", "bin", executableName), platform);
|
|
26355
|
+
context.signal.throwIfAborted();
|
|
26356
|
+
return executable === null ? [] : [executable];
|
|
26357
|
+
}
|
|
26358
|
+
|
|
26311
26359
|
// src/agent-catalog/agents/verify-session-creation.ts
|
|
26312
26360
|
import { methods as methods4 } from "@agentclientprotocol/sdk";
|
|
26313
26361
|
async function verifySessionCreation(connection, capabilities, defaultWorkspace, signal, label) {
|
|
@@ -26332,6 +26380,37 @@ async function verifySessionCreation(connection, capabilities, defaultWorkspace,
|
|
|
26332
26380
|
}
|
|
26333
26381
|
}
|
|
26334
26382
|
|
|
26383
|
+
// src/agent-catalog/agents/copilot-cli-agent.ts
|
|
26384
|
+
var COPILOT_CLI_TESTED_VERSION = "1.0.83";
|
|
26385
|
+
var CopilotCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26386
|
+
acpProbeTimeoutMilliseconds = 2e4;
|
|
26387
|
+
adapterVersion = COPILOT_CLI_TESTED_VERSION;
|
|
26388
|
+
authenticationCommand = () => "copilot login";
|
|
26389
|
+
agentExecutable = "copilot";
|
|
26390
|
+
id = "github-copilot-cli";
|
|
26391
|
+
label = "GitHub Copilot CLI";
|
|
26392
|
+
versionProbeTimeoutMilliseconds = 1e4;
|
|
26393
|
+
constructor() {
|
|
26394
|
+
super(
|
|
26395
|
+
"MOBIUS_COPILOT_PATH",
|
|
26396
|
+
["--no-auto-update", "--acp", "--stdio"],
|
|
26397
|
+
["agents", "github-copilot-cli", COPILOT_CLI_TESTED_VERSION, "bin", "copilot"]
|
|
26398
|
+
);
|
|
26399
|
+
}
|
|
26400
|
+
createLaunchEnvironment = async (_agent, _context) => Object.freeze({ COPILOT_AUTO_UPDATE: "false" });
|
|
26401
|
+
resolveInstalledAgentExecutables = async (context) => await resolveUserLocalExecutable(this.agentExecutable, context);
|
|
26402
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
26403
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
26404
|
+
if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null || (initialized.authMethods ?? []).length === 0) {
|
|
26405
|
+
throw new AgentProbeError(
|
|
26406
|
+
"acp_incompatible",
|
|
26407
|
+
"GitHub Copilot CLI reported an unsupported ACP capability set"
|
|
26408
|
+
);
|
|
26409
|
+
}
|
|
26410
|
+
await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
|
|
26411
|
+
};
|
|
26412
|
+
};
|
|
26413
|
+
|
|
26335
26414
|
// src/agent-catalog/agents/cursor-cli-agent.ts
|
|
26336
26415
|
var CURSOR_CLI_TESTED_VERSION = "2026.09.02-c22c1a3";
|
|
26337
26416
|
var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
@@ -26358,7 +26437,7 @@ var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26358
26437
|
|
|
26359
26438
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
26360
26439
|
import { realpath as realpath4, stat as stat5 } from "node:fs/promises";
|
|
26361
|
-
import { isAbsolute as
|
|
26440
|
+
import { isAbsolute as isAbsolute5, join as join7, normalize as normalize2 } from "node:path";
|
|
26362
26441
|
|
|
26363
26442
|
// src/agent-installation/deepseek-managed-package.ts
|
|
26364
26443
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -26376,7 +26455,7 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
26376
26455
|
|
|
26377
26456
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
26378
26457
|
async function validateAgentHome(path2) {
|
|
26379
|
-
if (!
|
|
26458
|
+
if (!isAbsolute5(path2) || normalize2(path2) !== path2) {
|
|
26380
26459
|
throw new AgentProbeError("agent_environment_invalid", "The configured Agent home is invalid");
|
|
26381
26460
|
}
|
|
26382
26461
|
try {
|
|
@@ -26426,7 +26505,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26426
26505
|
context.signal
|
|
26427
26506
|
);
|
|
26428
26507
|
if (managed.path === agent.path) {
|
|
26429
|
-
selectedHome =
|
|
26508
|
+
selectedHome = join7(readStateDirectory(context.environment), "agents", this.id, "home");
|
|
26430
26509
|
}
|
|
26431
26510
|
} catch {
|
|
26432
26511
|
context.signal.throwIfAborted();
|
|
@@ -26442,7 +26521,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26442
26521
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26443
26522
|
signal.throwIfAborted();
|
|
26444
26523
|
const executable = await validateManagedNpmPackage(
|
|
26445
|
-
|
|
26524
|
+
join7(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
26446
26525
|
DEEPSEEK_HARNESS_PACKAGE
|
|
26447
26526
|
);
|
|
26448
26527
|
signal.throwIfAborted();
|
|
@@ -26462,9 +26541,41 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26462
26541
|
};
|
|
26463
26542
|
};
|
|
26464
26543
|
|
|
26544
|
+
// src/agent-catalog/agents/gemini-cli-agent.ts
|
|
26545
|
+
var GEMINI_CLI_TESTED_VERSION = "0.59.0";
|
|
26546
|
+
var GeminiCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26547
|
+
acpProbeTimeoutMilliseconds = 2e4;
|
|
26548
|
+
adapterVersion = GEMINI_CLI_TESTED_VERSION;
|
|
26549
|
+
authenticationCommand = () => "gemini";
|
|
26550
|
+
agentExecutable = "gemini";
|
|
26551
|
+
id = "gemini-cli";
|
|
26552
|
+
label = "Gemini CLI";
|
|
26553
|
+
versionProbeTimeoutMilliseconds = 1e4;
|
|
26554
|
+
constructor() {
|
|
26555
|
+
super(
|
|
26556
|
+
"MOBIUS_GEMINI_PATH",
|
|
26557
|
+
["--acp"],
|
|
26558
|
+
[
|
|
26559
|
+
"agents",
|
|
26560
|
+
"gemini-cli",
|
|
26561
|
+
GEMINI_CLI_TESTED_VERSION,
|
|
26562
|
+
"bin",
|
|
26563
|
+
process.platform === "win32" ? "gemini.cmd" : "gemini"
|
|
26564
|
+
]
|
|
26565
|
+
);
|
|
26566
|
+
}
|
|
26567
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
26568
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
26569
|
+
if (capabilities.loadSession !== true || (initialized.authMethods ?? []).length === 0) {
|
|
26570
|
+
throw new AgentProbeError("acp_incompatible", "Gemini CLI reported an unsupported ACP capability set");
|
|
26571
|
+
}
|
|
26572
|
+
await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
|
|
26573
|
+
};
|
|
26574
|
+
};
|
|
26575
|
+
|
|
26465
26576
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
26466
26577
|
import { realpath as realpath5 } from "node:fs/promises";
|
|
26467
|
-
import { isAbsolute as
|
|
26578
|
+
import { isAbsolute as isAbsolute6, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
26468
26579
|
|
|
26469
26580
|
// src/agent-installation/grok-managed-package.ts
|
|
26470
26581
|
var GROK_BUILD_MANAGED_VERSION = "1.0.21";
|
|
@@ -26527,7 +26638,7 @@ function grokBuildManagedPackage(platform, architecture) {
|
|
|
26527
26638
|
// src/agent-catalog/agents/grok-build-agent.ts
|
|
26528
26639
|
function isContainedPath2(root, candidate) {
|
|
26529
26640
|
const difference = relative3(root, candidate);
|
|
26530
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !
|
|
26641
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute6(difference);
|
|
26531
26642
|
}
|
|
26532
26643
|
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26533
26644
|
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
@@ -26555,7 +26666,7 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26555
26666
|
if (managed.path === agent.path) {
|
|
26556
26667
|
return Object.freeze({
|
|
26557
26668
|
GROK_HOME: await realpath5(
|
|
26558
|
-
|
|
26669
|
+
join8(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION, "home")
|
|
26559
26670
|
)
|
|
26560
26671
|
});
|
|
26561
26672
|
}
|
|
@@ -26566,9 +26677,9 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26566
26677
|
};
|
|
26567
26678
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
26568
26679
|
signal.throwIfAborted();
|
|
26569
|
-
const versionRoot = await realpath5(
|
|
26570
|
-
await validateManagedNpmPackage(
|
|
26571
|
-
const executable = await resolveExecutablePath(
|
|
26680
|
+
const versionRoot = await realpath5(join8(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION));
|
|
26681
|
+
await validateManagedNpmPackage(join8(versionRoot, "package"), grokBuildManagedPackage(platform, process.arch));
|
|
26682
|
+
const executable = await resolveExecutablePath(join8(versionRoot, "home", "bin", "grok"), platform);
|
|
26572
26683
|
signal.throwIfAborted();
|
|
26573
26684
|
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
26574
26685
|
throw new AgentProbeError("managed_agent_invalid", "The managed Grok Build executable is invalid");
|
|
@@ -26585,14 +26696,39 @@ var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26585
26696
|
};
|
|
26586
26697
|
};
|
|
26587
26698
|
|
|
26699
|
+
// src/agent-catalog/agents/hermes-agent.ts
|
|
26700
|
+
var HERMES_TESTED_VERSION = "0.21.1";
|
|
26701
|
+
var HermesAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
26702
|
+
acpProbeTimeoutMilliseconds = 2e4;
|
|
26703
|
+
adapterVersion = HERMES_TESTED_VERSION;
|
|
26704
|
+
adapterVersionArguments = ["acp", "--version"];
|
|
26705
|
+
authenticationCommand = () => "hermes acp --setup";
|
|
26706
|
+
agentExecutable = "hermes";
|
|
26707
|
+
agentVersionArguments = ["acp", "--version"];
|
|
26708
|
+
id = "hermes";
|
|
26709
|
+
label = "Hermes Agent";
|
|
26710
|
+
constructor() {
|
|
26711
|
+
super("MOBIUS_HERMES_PATH", ["acp"], ["agents", "hermes", HERMES_TESTED_VERSION, "bin", "hermes"]);
|
|
26712
|
+
}
|
|
26713
|
+
resolveInstalledAgentExecutables = async (context) => await resolveUserLocalExecutable(this.agentExecutable, context);
|
|
26714
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
26715
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
26716
|
+
const session = capabilities.sessionCapabilities;
|
|
26717
|
+
if (capabilities.loadSession !== true || session?.fork == null || session.list == null || session.resume == null || (initialized.authMethods ?? []).length === 0) {
|
|
26718
|
+
throw new AgentProbeError("acp_incompatible", "Hermes Agent reported an unsupported ACP capability set");
|
|
26719
|
+
}
|
|
26720
|
+
await verifySessionCreation(connection, capabilities, defaultWorkspace, signal, this.label);
|
|
26721
|
+
};
|
|
26722
|
+
};
|
|
26723
|
+
|
|
26588
26724
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
26589
|
-
import { join as
|
|
26725
|
+
import { join as join10 } from "node:path";
|
|
26590
26726
|
|
|
26591
26727
|
// src/agent-installation/managed-agent-archive.ts
|
|
26592
26728
|
import { createHash as createHash2 } from "node:crypto";
|
|
26593
26729
|
import { createReadStream } from "node:fs";
|
|
26594
26730
|
import { chmod as chmod2, copyFile, mkdir as mkdir3, mkdtemp as mkdtemp2, open as open3, realpath as realpath6, rename as rename2, rm as rm2, stat as stat6, writeFile } from "node:fs/promises";
|
|
26595
|
-
import { dirname as dirname5, isAbsolute as
|
|
26731
|
+
import { dirname as dirname5, isAbsolute as isAbsolute7, join as join9, relative as relative4, sep as sep4 } from "node:path";
|
|
26596
26732
|
|
|
26597
26733
|
// src/agent-installation/verified-download.ts
|
|
26598
26734
|
import { fetch as fetch2 } from "undici";
|
|
@@ -26698,7 +26834,7 @@ function isRecord10(value) {
|
|
|
26698
26834
|
}
|
|
26699
26835
|
function isContainedPath3(root, candidate) {
|
|
26700
26836
|
const difference = relative4(root, candidate);
|
|
26701
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep4}`) && !
|
|
26837
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep4}`) && !isAbsolute7(difference);
|
|
26702
26838
|
}
|
|
26703
26839
|
async function hashFile(path2, signal) {
|
|
26704
26840
|
signal.throwIfAborted();
|
|
@@ -26777,11 +26913,11 @@ async function validateManagedAgentArchive(root, definition, signal) {
|
|
|
26777
26913
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
26778
26914
|
throw new Error("Managed Agent root is not user-owned");
|
|
26779
26915
|
}
|
|
26780
|
-
const manifest = await readManifest(
|
|
26916
|
+
const manifest = await readManifest(join9(rootPath, "archive.json"));
|
|
26781
26917
|
if (manifest["archiveSha256"] !== definition.archiveSha256 || manifest["archiveUrl"] !== definition.archiveUrl.toString() || manifest["version"] !== definition.version || typeof manifest["executableSha256"] !== "string") {
|
|
26782
26918
|
throw new Error("Managed Agent archive identity is invalid");
|
|
26783
26919
|
}
|
|
26784
|
-
const executable = await resolveExecutablePath(
|
|
26920
|
+
const executable = await resolveExecutablePath(join9(rootPath, "bin", definition.executableName));
|
|
26785
26921
|
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
26786
26922
|
throw new Error("Managed Agent executable is invalid");
|
|
26787
26923
|
}
|
|
@@ -26873,7 +27009,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26873
27009
|
}
|
|
26874
27010
|
createLaunchEnvironment = async (_agent, _context) => Object.freeze({ OPENCODE_DISABLE_AUTOUPDATE: "1" });
|
|
26875
27011
|
resolveManagedAgent = async (stateDirectory, platform, signal) => await validateManagedAgentArchive(
|
|
26876
|
-
|
|
27012
|
+
join10(stateDirectory, "agents", this.id, OPENCODE_MANAGED_VERSION),
|
|
26877
27013
|
openCodeManagedArchive(platform, process.arch),
|
|
26878
27014
|
signal
|
|
26879
27015
|
);
|
|
@@ -26891,7 +27027,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
26891
27027
|
};
|
|
26892
27028
|
|
|
26893
27029
|
// src/agent-catalog/agents/pi-agent.ts
|
|
26894
|
-
import { join as
|
|
27030
|
+
import { join as join11 } from "node:path";
|
|
26895
27031
|
import {
|
|
26896
27032
|
methods as methods5
|
|
26897
27033
|
} from "@agentclientprotocol/sdk";
|
|
@@ -26950,7 +27086,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26950
27086
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
26951
27087
|
signal.throwIfAborted();
|
|
26952
27088
|
const executable = await validateManagedNpmPackage(
|
|
26953
|
-
|
|
27089
|
+
join11(stateDirectory, "agents", this.id, PI_AGENT_PACKAGE.version),
|
|
26954
27090
|
PI_AGENT_PACKAGE
|
|
26955
27091
|
);
|
|
26956
27092
|
signal.throwIfAborted();
|
|
@@ -26988,7 +27124,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
26988
27124
|
};
|
|
26989
27125
|
|
|
26990
27126
|
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
26991
|
-
import { isAbsolute as
|
|
27127
|
+
import { isAbsolute as isAbsolute8, join as join12 } from "node:path";
|
|
26992
27128
|
|
|
26993
27129
|
// src/agent-installation/workbuddy-managed-package.ts
|
|
26994
27130
|
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
@@ -27041,7 +27177,7 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
27041
27177
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
27042
27178
|
signal.throwIfAborted();
|
|
27043
27179
|
const executable = await validateManagedNpmPackage(
|
|
27044
|
-
|
|
27180
|
+
join12(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
27045
27181
|
WORKBUDDY_MANAGED_PACKAGE
|
|
27046
27182
|
);
|
|
27047
27183
|
signal.throwIfAborted();
|
|
@@ -27052,10 +27188,10 @@ var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
27052
27188
|
if ((context.platform ?? process.platform) !== "darwin") {
|
|
27053
27189
|
return [];
|
|
27054
27190
|
}
|
|
27055
|
-
const requestedPaths = [
|
|
27191
|
+
const requestedPaths = [join12("/Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH)];
|
|
27056
27192
|
const homeDirectory = context.environment["HOME"];
|
|
27057
|
-
if (homeDirectory !== void 0 &&
|
|
27058
|
-
requestedPaths.unshift(
|
|
27193
|
+
if (homeDirectory !== void 0 && isAbsolute8(homeDirectory)) {
|
|
27194
|
+
requestedPaths.unshift(join12(homeDirectory, "Applications", ...WORKBUDDY_MACOS_EXECUTABLE_PATH));
|
|
27059
27195
|
}
|
|
27060
27196
|
const executables = [];
|
|
27061
27197
|
for (const requestedPath of requestedPaths) {
|
|
@@ -27081,12 +27217,15 @@ function supportedLocalAgentSpecifications() {
|
|
|
27081
27217
|
return Object.freeze([
|
|
27082
27218
|
new CodexAgentSpecification(),
|
|
27083
27219
|
new ClaudeCodeAgentSpecification(),
|
|
27220
|
+
new CopilotCliAgentSpecification(),
|
|
27084
27221
|
new PiAgentSpecification(),
|
|
27085
27222
|
new DeepSeekHarnessAgentSpecification(),
|
|
27223
|
+
new HermesAgentSpecification(),
|
|
27086
27224
|
new OpenCodeAgentSpecification(),
|
|
27087
27225
|
new CursorCliAgentSpecification(),
|
|
27088
27226
|
new GrokBuildAgentSpecification(),
|
|
27089
|
-
new WorkBuddyAgentSpecification()
|
|
27227
|
+
new WorkBuddyAgentSpecification(),
|
|
27228
|
+
new GeminiCliAgentSpecification()
|
|
27090
27229
|
]);
|
|
27091
27230
|
}
|
|
27092
27231
|
|
|
@@ -27098,12 +27237,172 @@ import {
|
|
|
27098
27237
|
PROTOCOL_VERSION as PROTOCOL_VERSION2,
|
|
27099
27238
|
RequestError as RequestError2
|
|
27100
27239
|
} from "@agentclientprotocol/sdk";
|
|
27240
|
+
var ACP_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
27241
|
+
var VerifiedAcpReadiness = class {
|
|
27242
|
+
adapterVersion;
|
|
27243
|
+
capabilities;
|
|
27244
|
+
constructor(adapterVersion, capabilities) {
|
|
27245
|
+
this.adapterVersion = adapterVersion;
|
|
27246
|
+
this.capabilities = capabilities;
|
|
27247
|
+
}
|
|
27248
|
+
};
|
|
27249
|
+
var DiscoveryAcpHandler = class {
|
|
27250
|
+
onElicitation = (_request, _signal) => Promise.reject(new Error("ACP probe does not accept elicitations"));
|
|
27251
|
+
onElicitationComplete = (_notification) => Promise.resolve();
|
|
27252
|
+
onPermission = (_request, _signal) => Promise.reject(new Error("ACP probe does not grant permissions"));
|
|
27253
|
+
onUpdate = (_notification) => Promise.resolve();
|
|
27254
|
+
};
|
|
27255
|
+
function readableAcpStream(input2) {
|
|
27256
|
+
let byteLength = 0;
|
|
27257
|
+
let open5 = true;
|
|
27258
|
+
return new ReadableStream({
|
|
27259
|
+
start(controller) {
|
|
27260
|
+
input2.on("data", (chunk) => {
|
|
27261
|
+
if (!open5) {
|
|
27262
|
+
return;
|
|
27263
|
+
}
|
|
27264
|
+
if (!(chunk instanceof Uint8Array)) {
|
|
27265
|
+
open5 = false;
|
|
27266
|
+
controller.error(new Error("ACP adapter produced invalid output"));
|
|
27267
|
+
return;
|
|
27268
|
+
}
|
|
27269
|
+
byteLength += chunk.byteLength;
|
|
27270
|
+
if (byteLength > ACP_OUTPUT_LIMIT_BYTES) {
|
|
27271
|
+
open5 = false;
|
|
27272
|
+
controller.error(new Error("ACP adapter output limit exceeded"));
|
|
27273
|
+
return;
|
|
27274
|
+
}
|
|
27275
|
+
controller.enqueue(new Uint8Array(chunk));
|
|
27276
|
+
});
|
|
27277
|
+
input2.once("end", () => {
|
|
27278
|
+
if (open5) {
|
|
27279
|
+
open5 = false;
|
|
27280
|
+
controller.close();
|
|
27281
|
+
}
|
|
27282
|
+
});
|
|
27283
|
+
input2.once("error", (error61) => {
|
|
27284
|
+
if (open5) {
|
|
27285
|
+
open5 = false;
|
|
27286
|
+
controller.error(error61);
|
|
27287
|
+
}
|
|
27288
|
+
});
|
|
27289
|
+
},
|
|
27290
|
+
cancel() {
|
|
27291
|
+
open5 = false;
|
|
27292
|
+
}
|
|
27293
|
+
});
|
|
27294
|
+
}
|
|
27295
|
+
function writableAcpStream(output2) {
|
|
27296
|
+
return new WritableStream({
|
|
27297
|
+
write(chunk) {
|
|
27298
|
+
return new Promise((resolveWrite, rejectWrite) => {
|
|
27299
|
+
output2.write(chunk, (error61) => {
|
|
27300
|
+
if (error61) {
|
|
27301
|
+
rejectWrite(error61);
|
|
27302
|
+
return;
|
|
27303
|
+
}
|
|
27304
|
+
resolveWrite();
|
|
27305
|
+
});
|
|
27306
|
+
});
|
|
27307
|
+
}
|
|
27308
|
+
});
|
|
27309
|
+
}
|
|
27310
|
+
async function probeAcpReadiness(specification, agent, environment, defaultWorkspace, signal) {
|
|
27311
|
+
signal.throwIfAborted();
|
|
27312
|
+
const controller = new AbortController();
|
|
27313
|
+
let timedOut = false;
|
|
27314
|
+
const timeout = setTimeout(() => {
|
|
27315
|
+
timedOut = true;
|
|
27316
|
+
controller.abort(new Error("ACP probe timed out"));
|
|
27317
|
+
}, specification.acpProbeTimeoutMilliseconds);
|
|
27318
|
+
const abort = () => controller.abort(signal.reason);
|
|
27319
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
27320
|
+
if (signal.aborted) {
|
|
27321
|
+
abort();
|
|
27322
|
+
}
|
|
27323
|
+
const child = spawn3(agent.adapterPath, [...agent.arguments], {
|
|
27324
|
+
cwd: defaultWorkspace,
|
|
27325
|
+
detached: process.platform !== "win32",
|
|
27326
|
+
env: { ...environment, ...agent.environment },
|
|
27327
|
+
shell: false,
|
|
27328
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
27329
|
+
});
|
|
27330
|
+
const processExit = new Promise((_resolve, reject) => {
|
|
27331
|
+
const rejectExit = () => reject(new Error("ACP adapter exited during initialization"));
|
|
27332
|
+
child.once("error", reject);
|
|
27333
|
+
child.once("exit", rejectExit);
|
|
27334
|
+
if (child.exitCode !== null || child.signalCode !== null) {
|
|
27335
|
+
rejectExit();
|
|
27336
|
+
}
|
|
27337
|
+
});
|
|
27338
|
+
const stdin = child.stdin;
|
|
27339
|
+
const stdout = child.stdout;
|
|
27340
|
+
const stderr = child.stderr;
|
|
27341
|
+
if (stdin === null || stdout === null || stderr === null) {
|
|
27342
|
+
await stopProcessTree(child);
|
|
27343
|
+
throw new AgentProbeError("acp_incompatible", "ACP adapter streams are unavailable");
|
|
27344
|
+
}
|
|
27345
|
+
let stderrBytes = 0;
|
|
27346
|
+
const consumeStderr = (chunk) => {
|
|
27347
|
+
stderrBytes += chunk.byteLength;
|
|
27348
|
+
if (stderrBytes > ACP_OUTPUT_LIMIT_BYTES) {
|
|
27349
|
+
controller.abort(new Error("ACP adapter output limit exceeded"));
|
|
27350
|
+
}
|
|
27351
|
+
};
|
|
27352
|
+
stderr.on("data", consumeStderr);
|
|
27353
|
+
const connection = createAcpClient(new DiscoveryAcpHandler()).connect(
|
|
27354
|
+
ndJsonStream2(writableAcpStream(stdin), readableAcpStream(stdout))
|
|
27355
|
+
);
|
|
27356
|
+
try {
|
|
27357
|
+
const initialized = await Promise.race([
|
|
27358
|
+
connection.agent.request(
|
|
27359
|
+
methods6.agent.initialize,
|
|
27360
|
+
{
|
|
27361
|
+
clientCapabilities: {},
|
|
27362
|
+
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
27363
|
+
protocolVersion: PROTOCOL_VERSION2
|
|
27364
|
+
},
|
|
27365
|
+
{ cancellationSignal: controller.signal }
|
|
27366
|
+
),
|
|
27367
|
+
processExit
|
|
27368
|
+
]);
|
|
27369
|
+
if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
|
|
27370
|
+
throw new AgentProbeError("acp_incompatible", "ACP adapter selected an unsupported protocol version");
|
|
27371
|
+
}
|
|
27372
|
+
await specification.verifyAcp(connection, initialized, defaultWorkspace, controller.signal);
|
|
27373
|
+
return new VerifiedAcpReadiness(
|
|
27374
|
+
normalizeVersionOutput(initialized.agentInfo?.version ?? ""),
|
|
27375
|
+
normalizeAcpCapabilities(initialized)
|
|
27376
|
+
);
|
|
27377
|
+
} catch (error61) {
|
|
27378
|
+
if (signal.aborted) {
|
|
27379
|
+
signal.throwIfAborted();
|
|
27380
|
+
}
|
|
27381
|
+
if (timedOut) {
|
|
27382
|
+
throw new AgentProbeError("adapter_probe_timeout", "ACP adapter probe timed out", { cause: error61 });
|
|
27383
|
+
}
|
|
27384
|
+
if (error61 instanceof AgentProbeError) {
|
|
27385
|
+
throw error61;
|
|
27386
|
+
}
|
|
27387
|
+
if (error61 instanceof RequestError2 && error61.code === -32e3 && specification.authenticationCommand().length > 0) {
|
|
27388
|
+
throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error61 });
|
|
27389
|
+
}
|
|
27390
|
+
throw new AgentProbeError("acp_incompatible", "ACP adapter initialization failed", { cause: error61 });
|
|
27391
|
+
} finally {
|
|
27392
|
+
clearTimeout(timeout);
|
|
27393
|
+
signal.removeEventListener("abort", abort);
|
|
27394
|
+
connection.close();
|
|
27395
|
+
stdin.end();
|
|
27396
|
+
stderr.removeListener("data", consumeStderr);
|
|
27397
|
+
await stopProcessTree(child);
|
|
27398
|
+
}
|
|
27399
|
+
}
|
|
27101
27400
|
|
|
27102
27401
|
// src/agent-catalog/executable-discovery.ts
|
|
27103
|
-
import { isAbsolute as
|
|
27402
|
+
import { isAbsolute as isAbsolute9, join as join14 } from "node:path";
|
|
27104
27403
|
|
|
27105
27404
|
// src/agent-installation/managed-adapter-installer.ts
|
|
27106
|
-
import { join as
|
|
27405
|
+
import { join as join13 } from "node:path";
|
|
27107
27406
|
var ManagedAdapterInstallError = class extends Error {
|
|
27108
27407
|
code;
|
|
27109
27408
|
constructor(code, message, options = {}) {
|
|
@@ -27160,7 +27459,7 @@ var ManagedAdapterInstaller = class {
|
|
|
27160
27459
|
this.#stateDirectory = options.stateDirectory;
|
|
27161
27460
|
}
|
|
27162
27461
|
install = async (specification, signal) => {
|
|
27163
|
-
const root =
|
|
27462
|
+
const root = join13(this.#stateDirectory, "adapters", specification.id, specification.adapterVersion);
|
|
27164
27463
|
try {
|
|
27165
27464
|
return await this.#npmInstaller.install(
|
|
27166
27465
|
root,
|
|
@@ -27194,7 +27493,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
27194
27493
|
let managed;
|
|
27195
27494
|
try {
|
|
27196
27495
|
managed = await validateManagedAdapter(
|
|
27197
|
-
|
|
27496
|
+
join14(readStateDirectory(context.environment), "adapters", specification.id, specification.adapterVersion),
|
|
27198
27497
|
specification
|
|
27199
27498
|
);
|
|
27200
27499
|
} catch {
|
|
@@ -27205,7 +27504,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
27205
27504
|
async function resolveSpecificationExecutables(executableName, overrideVariable, resolveInstalled, resolveManaged, context) {
|
|
27206
27505
|
const override = context.environment[overrideVariable];
|
|
27207
27506
|
if (override !== void 0) {
|
|
27208
|
-
if (override.length === 0 || !
|
|
27507
|
+
if (override.length === 0 || !isAbsolute9(override)) {
|
|
27209
27508
|
return [];
|
|
27210
27509
|
}
|
|
27211
27510
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -27259,10 +27558,7 @@ async function resolveAdapterExecutable(specification, context) {
|
|
|
27259
27558
|
const executables = await resolveAdapterExecutables(specification, context);
|
|
27260
27559
|
return executables[0] ?? null;
|
|
27261
27560
|
}
|
|
27262
|
-
function
|
|
27263
|
-
return output2.trim().split(/\r?\n/, 1)[0]?.trim().slice(0, 128) ?? "";
|
|
27264
|
-
}
|
|
27265
|
-
async function probeVersion(executable, arguments_, environment, defaultWorkspace, signal, timeoutMilliseconds) {
|
|
27561
|
+
async function probeVersion(executable, arguments_, environment, defaultWorkspace, signal, timeoutMilliseconds, normalize4 = normalizeVersionOutput) {
|
|
27266
27562
|
const result = await runBoundedProcess({
|
|
27267
27563
|
arguments: arguments_,
|
|
27268
27564
|
command: executable.path,
|
|
@@ -27271,7 +27567,7 @@ async function probeVersion(executable, arguments_, environment, defaultWorkspac
|
|
|
27271
27567
|
signal,
|
|
27272
27568
|
timeoutMilliseconds
|
|
27273
27569
|
});
|
|
27274
|
-
const version2 =
|
|
27570
|
+
const version2 = normalize4(result.stdout || result.stderr);
|
|
27275
27571
|
if (version2.length === 0) {
|
|
27276
27572
|
throw new ProcessExecutionError("process_exit_failed", "The executable did not report a version");
|
|
27277
27573
|
}
|
|
@@ -27295,7 +27591,8 @@ async function findVerifiedAgentExecutable(specification, context) {
|
|
|
27295
27591
|
context.environment,
|
|
27296
27592
|
context.defaultWorkspace,
|
|
27297
27593
|
context.signal,
|
|
27298
|
-
specification.versionProbeTimeoutMilliseconds
|
|
27594
|
+
specification.versionProbeTimeoutMilliseconds,
|
|
27595
|
+
specification.normalizeAgentVersion
|
|
27299
27596
|
);
|
|
27300
27597
|
return new VerifiedAgentExecutable(executable, version2);
|
|
27301
27598
|
} catch {
|
|
@@ -27307,168 +27604,6 @@ async function findVerifiedAgentExecutable(specification, context) {
|
|
|
27307
27604
|
return null;
|
|
27308
27605
|
}
|
|
27309
27606
|
|
|
27310
|
-
// src/agent-catalog/acp-readiness-probe.ts
|
|
27311
|
-
var ACP_OUTPUT_LIMIT_BYTES = 1024 * 1024;
|
|
27312
|
-
var VerifiedAcpReadiness = class {
|
|
27313
|
-
adapterVersion;
|
|
27314
|
-
capabilities;
|
|
27315
|
-
constructor(adapterVersion, capabilities) {
|
|
27316
|
-
this.adapterVersion = adapterVersion;
|
|
27317
|
-
this.capabilities = capabilities;
|
|
27318
|
-
}
|
|
27319
|
-
};
|
|
27320
|
-
var DiscoveryAcpHandler = class {
|
|
27321
|
-
onElicitation = (_request, _signal) => Promise.reject(new Error("ACP probe does not accept elicitations"));
|
|
27322
|
-
onElicitationComplete = (_notification) => Promise.resolve();
|
|
27323
|
-
onPermission = (_request, _signal) => Promise.reject(new Error("ACP probe does not grant permissions"));
|
|
27324
|
-
onUpdate = (_notification) => Promise.resolve();
|
|
27325
|
-
};
|
|
27326
|
-
function readableAcpStream(input2) {
|
|
27327
|
-
let byteLength = 0;
|
|
27328
|
-
let open5 = true;
|
|
27329
|
-
return new ReadableStream({
|
|
27330
|
-
start(controller) {
|
|
27331
|
-
input2.on("data", (chunk) => {
|
|
27332
|
-
if (!open5) {
|
|
27333
|
-
return;
|
|
27334
|
-
}
|
|
27335
|
-
if (!(chunk instanceof Uint8Array)) {
|
|
27336
|
-
open5 = false;
|
|
27337
|
-
controller.error(new Error("ACP adapter produced invalid output"));
|
|
27338
|
-
return;
|
|
27339
|
-
}
|
|
27340
|
-
byteLength += chunk.byteLength;
|
|
27341
|
-
if (byteLength > ACP_OUTPUT_LIMIT_BYTES) {
|
|
27342
|
-
open5 = false;
|
|
27343
|
-
controller.error(new Error("ACP adapter output limit exceeded"));
|
|
27344
|
-
return;
|
|
27345
|
-
}
|
|
27346
|
-
controller.enqueue(new Uint8Array(chunk));
|
|
27347
|
-
});
|
|
27348
|
-
input2.once("end", () => {
|
|
27349
|
-
if (open5) {
|
|
27350
|
-
open5 = false;
|
|
27351
|
-
controller.close();
|
|
27352
|
-
}
|
|
27353
|
-
});
|
|
27354
|
-
input2.once("error", (error61) => {
|
|
27355
|
-
if (open5) {
|
|
27356
|
-
open5 = false;
|
|
27357
|
-
controller.error(error61);
|
|
27358
|
-
}
|
|
27359
|
-
});
|
|
27360
|
-
},
|
|
27361
|
-
cancel() {
|
|
27362
|
-
open5 = false;
|
|
27363
|
-
}
|
|
27364
|
-
});
|
|
27365
|
-
}
|
|
27366
|
-
function writableAcpStream(output2) {
|
|
27367
|
-
return new WritableStream({
|
|
27368
|
-
write(chunk) {
|
|
27369
|
-
return new Promise((resolveWrite, rejectWrite) => {
|
|
27370
|
-
output2.write(chunk, (error61) => {
|
|
27371
|
-
if (error61) {
|
|
27372
|
-
rejectWrite(error61);
|
|
27373
|
-
return;
|
|
27374
|
-
}
|
|
27375
|
-
resolveWrite();
|
|
27376
|
-
});
|
|
27377
|
-
});
|
|
27378
|
-
}
|
|
27379
|
-
});
|
|
27380
|
-
}
|
|
27381
|
-
async function probeAcpReadiness(specification, agent, environment, defaultWorkspace, signal) {
|
|
27382
|
-
signal.throwIfAborted();
|
|
27383
|
-
const controller = new AbortController();
|
|
27384
|
-
let timedOut = false;
|
|
27385
|
-
const timeout = setTimeout(() => {
|
|
27386
|
-
timedOut = true;
|
|
27387
|
-
controller.abort(new Error("ACP probe timed out"));
|
|
27388
|
-
}, specification.acpProbeTimeoutMilliseconds);
|
|
27389
|
-
const abort = () => controller.abort(signal.reason);
|
|
27390
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
27391
|
-
if (signal.aborted) {
|
|
27392
|
-
abort();
|
|
27393
|
-
}
|
|
27394
|
-
const child = spawn3(agent.adapterPath, [...agent.arguments], {
|
|
27395
|
-
cwd: defaultWorkspace,
|
|
27396
|
-
detached: process.platform !== "win32",
|
|
27397
|
-
env: { ...environment, ...agent.environment },
|
|
27398
|
-
shell: false,
|
|
27399
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
27400
|
-
});
|
|
27401
|
-
const processExit = new Promise((_resolve, reject) => {
|
|
27402
|
-
const rejectExit = () => reject(new Error("ACP adapter exited during initialization"));
|
|
27403
|
-
child.once("error", reject);
|
|
27404
|
-
child.once("exit", rejectExit);
|
|
27405
|
-
if (child.exitCode !== null || child.signalCode !== null) {
|
|
27406
|
-
rejectExit();
|
|
27407
|
-
}
|
|
27408
|
-
});
|
|
27409
|
-
const stdin = child.stdin;
|
|
27410
|
-
const stdout = child.stdout;
|
|
27411
|
-
const stderr = child.stderr;
|
|
27412
|
-
if (stdin === null || stdout === null || stderr === null) {
|
|
27413
|
-
await stopProcessTree(child);
|
|
27414
|
-
throw new AgentProbeError("acp_incompatible", "ACP adapter streams are unavailable");
|
|
27415
|
-
}
|
|
27416
|
-
let stderrBytes = 0;
|
|
27417
|
-
const consumeStderr = (chunk) => {
|
|
27418
|
-
stderrBytes += chunk.byteLength;
|
|
27419
|
-
if (stderrBytes > ACP_OUTPUT_LIMIT_BYTES) {
|
|
27420
|
-
controller.abort(new Error("ACP adapter output limit exceeded"));
|
|
27421
|
-
}
|
|
27422
|
-
};
|
|
27423
|
-
stderr.on("data", consumeStderr);
|
|
27424
|
-
const connection = createAcpClient(new DiscoveryAcpHandler()).connect(
|
|
27425
|
-
ndJsonStream2(writableAcpStream(stdin), readableAcpStream(stdout))
|
|
27426
|
-
);
|
|
27427
|
-
try {
|
|
27428
|
-
const initialized = await Promise.race([
|
|
27429
|
-
connection.agent.request(
|
|
27430
|
-
methods6.agent.initialize,
|
|
27431
|
-
{
|
|
27432
|
-
clientCapabilities: {},
|
|
27433
|
-
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
27434
|
-
protocolVersion: PROTOCOL_VERSION2
|
|
27435
|
-
},
|
|
27436
|
-
{ cancellationSignal: controller.signal }
|
|
27437
|
-
),
|
|
27438
|
-
processExit
|
|
27439
|
-
]);
|
|
27440
|
-
if (initialized.protocolVersion !== PROTOCOL_VERSION2) {
|
|
27441
|
-
throw new AgentProbeError("acp_incompatible", "ACP adapter selected an unsupported protocol version");
|
|
27442
|
-
}
|
|
27443
|
-
await specification.verifyAcp(connection, initialized, defaultWorkspace, controller.signal);
|
|
27444
|
-
return new VerifiedAcpReadiness(
|
|
27445
|
-
normalizedVersion(initialized.agentInfo?.version ?? ""),
|
|
27446
|
-
normalizeAcpCapabilities(initialized)
|
|
27447
|
-
);
|
|
27448
|
-
} catch (error61) {
|
|
27449
|
-
if (signal.aborted) {
|
|
27450
|
-
signal.throwIfAborted();
|
|
27451
|
-
}
|
|
27452
|
-
if (timedOut) {
|
|
27453
|
-
throw new AgentProbeError("adapter_probe_timeout", "ACP adapter probe timed out", { cause: error61 });
|
|
27454
|
-
}
|
|
27455
|
-
if (error61 instanceof AgentProbeError) {
|
|
27456
|
-
throw error61;
|
|
27457
|
-
}
|
|
27458
|
-
if (error61 instanceof RequestError2 && error61.code === -32e3 && specification.authenticationCommand().length > 0) {
|
|
27459
|
-
throw new AgentProbeError("authentication_required", "Agent authentication is required", { cause: error61 });
|
|
27460
|
-
}
|
|
27461
|
-
throw new AgentProbeError("acp_incompatible", "ACP adapter initialization failed", { cause: error61 });
|
|
27462
|
-
} finally {
|
|
27463
|
-
clearTimeout(timeout);
|
|
27464
|
-
signal.removeEventListener("abort", abort);
|
|
27465
|
-
connection.close();
|
|
27466
|
-
stdin.end();
|
|
27467
|
-
stderr.removeListener("data", consumeStderr);
|
|
27468
|
-
await stopProcessTree(child);
|
|
27469
|
-
}
|
|
27470
|
-
}
|
|
27471
|
-
|
|
27472
27607
|
// src/agent-catalog/discover-agent.ts
|
|
27473
27608
|
function agentProbeFailure(specification, error61) {
|
|
27474
27609
|
if (error61 instanceof AgentProbeError) {
|
|
@@ -27512,7 +27647,8 @@ async function discoverAgent(specification, context) {
|
|
|
27512
27647
|
context.environment,
|
|
27513
27648
|
context.defaultWorkspace,
|
|
27514
27649
|
context.signal,
|
|
27515
|
-
specification.versionProbeTimeoutMilliseconds
|
|
27650
|
+
specification.versionProbeTimeoutMilliseconds,
|
|
27651
|
+
specification.normalizeAgentVersion
|
|
27516
27652
|
);
|
|
27517
27653
|
} catch (error61) {
|
|
27518
27654
|
if (context.signal.aborted) {
|
|
@@ -27548,7 +27684,8 @@ async function discoverAgent(specification, context) {
|
|
|
27548
27684
|
},
|
|
27549
27685
|
context.defaultWorkspace,
|
|
27550
27686
|
context.signal,
|
|
27551
|
-
specification.versionProbeTimeoutMilliseconds
|
|
27687
|
+
specification.versionProbeTimeoutMilliseconds,
|
|
27688
|
+
specification.normalizeAdapterVersion
|
|
27552
27689
|
);
|
|
27553
27690
|
}
|
|
27554
27691
|
} catch (error61) {
|
|
@@ -27821,10 +27958,10 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
27821
27958
|
return options.pairingId.length > 0 ? decodePairingResponse(value, "runtimeCredential", REDEEM_RESPONSE_KEYS) : decodePairingResponse(value, "daemonToken", CLAIM_RESPONSE_KEYS);
|
|
27822
27959
|
}
|
|
27823
27960
|
async function persistConnection(channelId, relayOrigin, runtimeCredential2, defaultWorkspace, environment) {
|
|
27824
|
-
const connectionsDirectory =
|
|
27961
|
+
const connectionsDirectory = join15(readStateDirectory(environment), "connections");
|
|
27825
27962
|
await mkdir4(connectionsDirectory, { mode: 448, recursive: true });
|
|
27826
|
-
const connectionPath =
|
|
27827
|
-
const temporaryPath =
|
|
27963
|
+
const connectionPath = join15(connectionsDirectory, `${channelId}.json`);
|
|
27964
|
+
const temporaryPath = join15(connectionsDirectory, `.${channelId}.${randomUUID3()}.tmp`);
|
|
27828
27965
|
await writeFile2(
|
|
27829
27966
|
temporaryPath,
|
|
27830
27967
|
`${JSON.stringify(
|
|
@@ -27862,7 +27999,7 @@ function decodeSavedConnection(value, expectedChannelId) {
|
|
|
27862
27999
|
};
|
|
27863
28000
|
}
|
|
27864
28001
|
async function readSavedConnection(channelId, environment) {
|
|
27865
|
-
const connectionPath =
|
|
28002
|
+
const connectionPath = join15(readStateDirectory(environment), "connections", `${channelId}.json`);
|
|
27866
28003
|
let encoded = "";
|
|
27867
28004
|
const handle = await open4(connectionPath, "r");
|
|
27868
28005
|
try {
|
|
@@ -27898,7 +28035,7 @@ function buildPairedDaemon(connection, connectionPath, inventory, environment) {
|
|
|
27898
28035
|
const relayUrl = mobiusApiUrl(connection.relayOrigin, "/v1/runtimes/connect");
|
|
27899
28036
|
relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
27900
28037
|
relayUrl.searchParams.set("token", connection.runtimeCredential);
|
|
27901
|
-
const auditDatabasePath =
|
|
28038
|
+
const auditDatabasePath = join15(readStateDirectory(environment), "audit", `${connection.channelId}.sqlite`);
|
|
27902
28039
|
return {
|
|
27903
28040
|
channelUrl: new URL(`/channels/${encodeURIComponent(connection.channelId)}`, connection.relayOrigin).toString(),
|
|
27904
28041
|
config: createDaemonConfig(
|
|
@@ -27960,7 +28097,7 @@ async function pairLocalMachine(arguments_, signal = new AbortController().signa
|
|
|
27960
28097
|
}
|
|
27961
28098
|
async function resumeMobiusRuntime(channelId, signal, environment = process.env) {
|
|
27962
28099
|
const normalizedChannelId = validatePairingId(channelId);
|
|
27963
|
-
const connectionPath =
|
|
28100
|
+
const connectionPath = join15(readStateDirectory(environment), "connections", `${normalizedChannelId}.json`);
|
|
27964
28101
|
const connection = await readSavedConnection(normalizedChannelId, environment);
|
|
27965
28102
|
const inventory = await discoverLocalAgentInventory({
|
|
27966
28103
|
defaultWorkspace: connection.defaultWorkspace,
|
|
@@ -27975,7 +28112,7 @@ async function resumeLocalMachine(arguments_, signal = new AbortController().sig
|
|
|
27975
28112
|
|
|
27976
28113
|
// src/run-daemon.ts
|
|
27977
28114
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
27978
|
-
import { basename as basename5, join as
|
|
28115
|
+
import { basename as basename5, join as join17 } from "node:path";
|
|
27979
28116
|
import { styleText } from "node:util";
|
|
27980
28117
|
import { fetch as fetch7, WebSocket as WebSocket2 } from "undici";
|
|
27981
28118
|
|
|
@@ -28919,7 +29056,7 @@ async function uploadRuntimeArtifact(config2, sessionId, image, signal) {
|
|
|
28919
29056
|
// src/authorization/workspace-directory.ts
|
|
28920
29057
|
import { readdir, realpath as realpath8, stat as stat8 } from "node:fs/promises";
|
|
28921
29058
|
import { homedir as homedir2 } from "node:os";
|
|
28922
|
-
import { basename as basename3, dirname as dirname6, isAbsolute as
|
|
29059
|
+
import { basename as basename3, dirname as dirname6, isAbsolute as isAbsolute10, join as join16, normalize as normalize3, relative as relative5 } from "node:path";
|
|
28923
29060
|
var WorkspaceDirectoryListing = class {
|
|
28924
29061
|
directoryId;
|
|
28925
29062
|
directoryLabel;
|
|
@@ -28971,7 +29108,7 @@ var WorkspaceDirectoryService = class {
|
|
|
28971
29108
|
}
|
|
28972
29109
|
if (id.startsWith("path-")) {
|
|
28973
29110
|
const path2 = decodePath(id, "path-");
|
|
28974
|
-
if (
|
|
29111
|
+
if (isAbsolute10(path2)) {
|
|
28975
29112
|
return path2;
|
|
28976
29113
|
}
|
|
28977
29114
|
}
|
|
@@ -28979,7 +29116,7 @@ var WorkspaceDirectoryService = class {
|
|
|
28979
29116
|
};
|
|
28980
29117
|
resolvePath = async (requested, signal) => {
|
|
28981
29118
|
signal.throwIfAborted();
|
|
28982
|
-
if (!
|
|
29119
|
+
if (!isAbsolute10(requested) || requested.includes("\0") || normalize3(requested) !== requested) {
|
|
28983
29120
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
28984
29121
|
}
|
|
28985
29122
|
try {
|
|
@@ -28987,7 +29124,7 @@ var WorkspaceDirectoryService = class {
|
|
|
28987
29124
|
signal.throwIfAborted();
|
|
28988
29125
|
const metadata = await stat8(target);
|
|
28989
29126
|
signal.throwIfAborted();
|
|
28990
|
-
if (!
|
|
29127
|
+
if (!isAbsolute10(target) || normalize3(target) !== target || !metadata.isDirectory()) {
|
|
28991
29128
|
throw new LocalAuthorizationError("The selected location is not a directory");
|
|
28992
29129
|
}
|
|
28993
29130
|
return target;
|
|
@@ -29003,7 +29140,7 @@ var WorkspaceDirectoryService = class {
|
|
|
29003
29140
|
};
|
|
29004
29141
|
label = (path2) => {
|
|
29005
29142
|
const suffix = relative5(homedir2(), path2);
|
|
29006
|
-
return suffix === "" ? "~" : !
|
|
29143
|
+
return suffix === "" ? "~" : !isAbsolute10(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
29007
29144
|
};
|
|
29008
29145
|
identify = async (bindingId, requestedPath, signal) => {
|
|
29009
29146
|
this.authorizeMachine(bindingId);
|
|
@@ -29033,7 +29170,7 @@ var WorkspaceDirectoryService = class {
|
|
|
29033
29170
|
continue;
|
|
29034
29171
|
}
|
|
29035
29172
|
try {
|
|
29036
|
-
const path2 = await this.resolvePath(
|
|
29173
|
+
const path2 = await this.resolvePath(join16(target, child.name), signal);
|
|
29037
29174
|
entries.push({ directoryId: encodePath(path2), name: child.name });
|
|
29038
29175
|
} catch (cause) {
|
|
29039
29176
|
signal.throwIfAborted();
|
|
@@ -30905,7 +31042,7 @@ function botIpcSocketPath() {
|
|
|
30905
31042
|
if (process.platform === "win32") {
|
|
30906
31043
|
return `\\\\.\\pipe\\mobius-bot-${randomUUID6()}`;
|
|
30907
31044
|
}
|
|
30908
|
-
return
|
|
31045
|
+
return join17("/tmp", `mobius-bot-${randomUUID6()}.sock`);
|
|
30909
31046
|
}
|
|
30910
31047
|
var DaemonAcpObserver = class {
|
|
30911
31048
|
#config;
|
|
@@ -32851,7 +32988,7 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
32851
32988
|
|
|
32852
32989
|
// src/runtime.ts
|
|
32853
32990
|
import { mkdir as mkdir5, realpath as realpath9, stat as stat9 } from "node:fs/promises";
|
|
32854
|
-
import { dirname as dirname8, join as
|
|
32991
|
+
import { dirname as dirname8, join as join18, resolve as resolve5 } from "node:path";
|
|
32855
32992
|
var APP_CREDENTIAL_PATTERN = /^mapp_[a-zA-Z0-9_-]{22}_[a-zA-Z0-9_-]{43}$/;
|
|
32856
32993
|
var CONVERSATION_CREDENTIAL_PATTERN = /^mconv_[a-zA-Z0-9_-]{22}_[a-zA-Z0-9_-]{43}$/;
|
|
32857
32994
|
var IDENTIFIER_PATTERN9 = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
@@ -32916,7 +33053,7 @@ function loadMobiusRuntimeConnection(environment = process.env) {
|
|
|
32916
33053
|
throw new MobiusRuntimeConfigurationError("MOBIUS_CHANNEL_ID is invalid");
|
|
32917
33054
|
}
|
|
32918
33055
|
return Object.freeze({
|
|
32919
|
-
auditDatabasePath: environment["MOBIUS_AUDIT_DATABASE"]?.trim() ||
|
|
33056
|
+
auditDatabasePath: environment["MOBIUS_AUDIT_DATABASE"]?.trim() || join18(readStateDirectory(environment), "audit", `${channelId}.sqlite`),
|
|
32920
33057
|
channelId,
|
|
32921
33058
|
defaultWorkspace: loadDefaultWorkspace(environment),
|
|
32922
33059
|
relayUrl: requiredEnvironmentValue(environment, "MOBIUS_RELAY_URL"),
|