@moxt-ai/mobius 0.0.14 → 0.0.15
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/create-client.d.ts.map +1 -1
- package/dist/acp/create-client.js +16 -1
- package/dist/acp/create-client.js.map +1 -1
- package/dist/agent-catalog/agent-discovery.d.ts +1 -1
- package/dist/agent-catalog/agent-discovery.d.ts.map +1 -1
- package/dist/agent-catalog/agent-discovery.js +2 -2
- package/dist/agent-catalog/agent-discovery.js.map +1 -1
- package/dist/agent-catalog/agents/cursor-cli-agent.d.ts +13 -0
- package/dist/agent-catalog/agents/cursor-cli-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/cursor-cli-agent.js +25 -0
- package/dist/agent-catalog/agents/cursor-cli-agent.js.map +1 -0
- package/dist/agent-catalog/agents/grok-build-agent.d.ts +18 -0
- package/dist/agent-catalog/agents/grok-build-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/grok-build-agent.js +75 -0
- package/dist/agent-catalog/agents/grok-build-agent.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/agents/verify-session-creation.d.ts +3 -0
- package/dist/agent-catalog/agents/verify-session-creation.d.ts.map +1 -0
- package/dist/agent-catalog/agents/verify-session-creation.js +16 -0
- package/dist/agent-catalog/agents/verify-session-creation.js.map +1 -0
- package/dist/agent-catalog/agents/workbuddy-agent.d.ts +15 -0
- package/dist/agent-catalog/agents/workbuddy-agent.d.ts.map +1 -0
- package/dist/agent-catalog/agents/workbuddy-agent.js +41 -0
- package/dist/agent-catalog/agents/workbuddy-agent.js.map +1 -0
- 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 +4 -10
- package/dist/agent-catalog/discover-local-agents.js.map +1 -1
- package/dist/agent-catalog/local-agent.d.ts +1 -2
- package/dist/agent-catalog/local-agent.d.ts.map +1 -1
- package/dist/agent-catalog/local-agent.js +1 -3
- package/dist/agent-catalog/local-agent.js.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.d.ts.map +1 -1
- package/dist/agent-catalog/publish-agent-catalog.js +0 -1
- package/dist/agent-catalog/publish-agent-catalog.js.map +1 -1
- package/dist/agent-installation/agent-installation-manager.d.ts +1 -8
- package/dist/agent-installation/agent-installation-manager.d.ts.map +1 -1
- package/dist/agent-installation/agent-installation-manager.js +7 -24
- package/dist/agent-installation/agent-installation-manager.js.map +1 -1
- package/dist/agent-installation/fixed-agent-install-recipe.d.ts +20 -0
- package/dist/agent-installation/fixed-agent-install-recipe.d.ts.map +1 -0
- package/dist/agent-installation/fixed-agent-install-recipe.js +18 -0
- package/dist/agent-installation/fixed-agent-install-recipe.js.map +1 -0
- package/dist/agent-installation/fixed-agent-install-recipes.d.ts +5 -18
- package/dist/agent-installation/fixed-agent-install-recipes.d.ts.map +1 -1
- package/dist/agent-installation/fixed-agent-install-recipes.js +9 -16
- package/dist/agent-installation/fixed-agent-install-recipes.js.map +1 -1
- package/dist/agent-installation/grok-build-install-recipe.d.ts +12 -0
- package/dist/agent-installation/grok-build-install-recipe.d.ts.map +1 -0
- package/dist/agent-installation/grok-build-install-recipe.js +102 -0
- package/dist/agent-installation/grok-build-install-recipe.js.map +1 -0
- package/dist/agent-installation/grok-managed-package.d.ts +4 -0
- package/dist/agent-installation/grok-managed-package.d.ts.map +1 -0
- package/dist/agent-installation/grok-managed-package.js +34 -0
- package/dist/agent-installation/grok-managed-package.js.map +1 -0
- package/dist/agent-installation/managed-npm-package.d.ts +8 -0
- package/dist/agent-installation/managed-npm-package.d.ts.map +1 -1
- package/dist/agent-installation/managed-npm-package.js +32 -3
- package/dist/agent-installation/managed-npm-package.js.map +1 -1
- package/dist/agent-installation/workbuddy-install-recipe.d.ts +12 -0
- package/dist/agent-installation/workbuddy-install-recipe.d.ts.map +1 -0
- package/dist/agent-installation/workbuddy-install-recipe.js +51 -0
- package/dist/agent-installation/workbuddy-install-recipe.js.map +1 -0
- package/dist/agent-installation/workbuddy-managed-package.d.ts +10 -0
- package/dist/agent-installation/workbuddy-managed-package.d.ts.map +1 -0
- package/dist/agent-installation/workbuddy-managed-package.js +11 -0
- package/dist/agent-installation/workbuddy-managed-package.js.map +1 -0
- package/dist/cli.js +784 -355
- package/dist/cli.js.map +4 -4
- package/dist/index.js +729 -300
- package/dist/index.js.map +4 -4
- package/dist/pairing/pair-local-machine.d.ts.map +1 -1
- package/dist/pairing/pair-local-machine.js +0 -1
- package/dist/pairing/pair-local-machine.js.map +1 -1
- package/dist/run-daemon.d.ts.map +1 -1
- package/dist/run-daemon.js +3 -12
- package/dist/run-daemon.js.map +1 -1
- package/package.json +2 -2
- package/dist/agent-installation/installation-grants.d.ts +0 -2
- package/dist/agent-installation/installation-grants.d.ts.map +0 -1
- package/dist/agent-installation/installation-grants.js +0 -51
- package/dist/agent-installation/installation-grants.js.map +0 -1
- package/dist/agent-installation/local-installation-authorizer.d.ts +0 -7
- package/dist/agent-installation/local-installation-authorizer.d.ts.map +0 -1
- package/dist/agent-installation/local-installation-authorizer.js +0 -32
- package/dist/agent-installation/local-installation-authorizer.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
client,
|
|
10
10
|
methods
|
|
11
11
|
} from "@agentclientprotocol/sdk";
|
|
12
|
+
function discardExtensionParams(_params) {
|
|
13
|
+
return Object.freeze({});
|
|
14
|
+
}
|
|
12
15
|
var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
13
16
|
methods.client.session.requestPermission,
|
|
14
17
|
async (context) => await handler.onPermission(context.params, context.signal)
|
|
@@ -19,7 +22,26 @@ var createAcpClient = (handler) => client({ name: "mobius" }).onRequest(
|
|
|
19
22
|
await handler.onUpdate(context.params);
|
|
20
23
|
}).onNotification(methods.client.elicitation.complete, async (context) => {
|
|
21
24
|
await handler.onElicitationComplete(context.params);
|
|
22
|
-
})
|
|
25
|
+
}).onRequest("cursor/ask_question", discardExtensionParams, async () => ({
|
|
26
|
+
outcome: {
|
|
27
|
+
outcome: "skipped",
|
|
28
|
+
reason: "Mobius does not expose Cursor question extensions"
|
|
29
|
+
}
|
|
30
|
+
})).onRequest("cursor/create_plan", discardExtensionParams, async () => ({
|
|
31
|
+
outcome: { outcome: "cancelled" }
|
|
32
|
+
})).onNotification(
|
|
33
|
+
"cursor/update_todos",
|
|
34
|
+
discardExtensionParams,
|
|
35
|
+
async () => Promise.resolve()
|
|
36
|
+
).onNotification(
|
|
37
|
+
"cursor/task",
|
|
38
|
+
discardExtensionParams,
|
|
39
|
+
async () => Promise.resolve()
|
|
40
|
+
).onNotification(
|
|
41
|
+
"cursor/generate_image",
|
|
42
|
+
discardExtensionParams,
|
|
43
|
+
async () => Promise.resolve()
|
|
44
|
+
);
|
|
23
45
|
|
|
24
46
|
// src/config.ts
|
|
25
47
|
import { join as join3 } from "node:path";
|
|
@@ -1985,8 +2007,8 @@ function emoji() {
|
|
|
1985
2007
|
}
|
|
1986
2008
|
var ipv4 = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
1987
2009
|
var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
|
|
1988
|
-
var mac = (
|
|
1989
|
-
const escapedDelim = escapeRegex(
|
|
2010
|
+
var mac = (delimiter3) => {
|
|
2011
|
+
const escapedDelim = escapeRegex(delimiter3 ?? ":");
|
|
1990
2012
|
return new RegExp(`^(?:[0-9A-F]{2}${escapedDelim}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${escapedDelim}){5}[0-9a-f]{2}$`);
|
|
1991
2013
|
};
|
|
1992
2014
|
var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
@@ -18961,7 +18983,6 @@ var SESSION_OPERATION_FAILED_KIND = "session.operation.failed";
|
|
|
18961
18983
|
var AGENT_CONTENT_KIND = "agent.content";
|
|
18962
18984
|
var AGENT_INSTALL_REQUEST_KIND = "agent.install.request";
|
|
18963
18985
|
var AGENT_INSTALL_CANCEL_KIND = "agent.install.cancel";
|
|
18964
|
-
var AGENT_INSTALL_AWAITING_APPROVAL_KIND = "agent.install.awaiting_approval";
|
|
18965
18986
|
var AGENT_INSTALL_STARTED_KIND = "agent.install.started";
|
|
18966
18987
|
var AGENT_INSTALL_PROGRESS_KIND = "agent.install.progress";
|
|
18967
18988
|
var AGENT_INSTALL_COMPLETED_KIND = "agent.install.completed";
|
|
@@ -19267,10 +19288,6 @@ var agentInstallCancelCommandSchema = external_exports.strictObject({
|
|
|
19267
19288
|
kind: external_exports.literal(AGENT_INSTALL_CANCEL_KIND),
|
|
19268
19289
|
requestId: IDENTIFIER
|
|
19269
19290
|
}).readonly();
|
|
19270
|
-
var agentInstallAwaitingApprovalEventSchema = external_exports.strictObject({
|
|
19271
|
-
...agentInstallIdentityFields,
|
|
19272
|
-
kind: external_exports.literal(AGENT_INSTALL_AWAITING_APPROVAL_KIND)
|
|
19273
|
-
}).readonly();
|
|
19274
19291
|
var agentInstallStartedEventSchema = external_exports.strictObject({
|
|
19275
19292
|
...agentInstallIdentityFields,
|
|
19276
19293
|
kind: external_exports.literal(AGENT_INSTALL_STARTED_KIND)
|
|
@@ -19353,7 +19370,6 @@ var encodeSessionOperationFailedEvent = (message) => encode3(message, sessionOpe
|
|
|
19353
19370
|
var encodeAgentContentEvent = (message) => encode3(message, agentContentEventSchema);
|
|
19354
19371
|
var decodeAgentInstallRequestCommand = (encoded) => decode3(encoded, agentInstallRequestCommandSchema);
|
|
19355
19372
|
var decodeAgentInstallCancelCommand = (encoded) => decode3(encoded, agentInstallCancelCommandSchema);
|
|
19356
|
-
var encodeAgentInstallAwaitingApprovalEvent = (message) => encode3(message, agentInstallAwaitingApprovalEventSchema);
|
|
19357
19373
|
var encodeAgentInstallStartedEvent = (message) => encode3(message, agentInstallStartedEventSchema);
|
|
19358
19374
|
var encodeAgentInstallProgressEvent = (message) => encode3(message, agentInstallProgressEventSchema);
|
|
19359
19375
|
var encodeAgentInstallCompletedEvent = (message) => encode3(message, agentInstallCompletedEventSchema);
|
|
@@ -21004,11 +21020,9 @@ var LocalAgentDefinition = class {
|
|
|
21004
21020
|
var InstallableAgentDefinition = class {
|
|
21005
21021
|
id;
|
|
21006
21022
|
label;
|
|
21007
|
-
|
|
21008
|
-
constructor(id, label, requiresLocalApproval = true) {
|
|
21023
|
+
constructor(id, label) {
|
|
21009
21024
|
this.id = id;
|
|
21010
21025
|
this.label = label;
|
|
21011
|
-
this.requiresLocalApproval = requiresLocalApproval;
|
|
21012
21026
|
}
|
|
21013
21027
|
};
|
|
21014
21028
|
var LocalAgentCatalogSnapshot = class {
|
|
@@ -24170,58 +24184,16 @@ var LocalAuthorizationError = class extends Error {
|
|
|
24170
24184
|
import { randomUUID } from "node:crypto";
|
|
24171
24185
|
import {
|
|
24172
24186
|
mkdir as mkdir3,
|
|
24173
|
-
open as
|
|
24174
|
-
realpath as
|
|
24187
|
+
open as open5,
|
|
24188
|
+
realpath as realpath6,
|
|
24175
24189
|
rename as rename3,
|
|
24176
24190
|
stat as stat5,
|
|
24177
24191
|
writeFile as writeFile2
|
|
24178
24192
|
} from "node:fs/promises";
|
|
24179
24193
|
import { hostname as hostname3 } from "node:os";
|
|
24180
|
-
import { basename, join as
|
|
24194
|
+
import { basename, join as join14, resolve as resolve3 } from "node:path";
|
|
24181
24195
|
import { fetch as fetch2 } from "undici";
|
|
24182
24196
|
|
|
24183
|
-
// src/agent-installation/installation-grants.ts
|
|
24184
|
-
import { open as open2 } from "node:fs/promises";
|
|
24185
|
-
import { join as join4 } from "node:path";
|
|
24186
|
-
var MAX_GRANT_FILE_LENGTH = 16 * 1024;
|
|
24187
|
-
var AGENT_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
|
|
24188
|
-
function isRecord4(value) {
|
|
24189
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24190
|
-
}
|
|
24191
|
-
async function readGrantedAgents(stateDirectory) {
|
|
24192
|
-
const path2 = join4(stateDirectory, "installation-grants.json");
|
|
24193
|
-
let handle;
|
|
24194
|
-
try {
|
|
24195
|
-
handle = await open2(path2, "r");
|
|
24196
|
-
} catch (error61) {
|
|
24197
|
-
if (error61 instanceof Error && "code" in error61 && error61.code === "ENOENT") {
|
|
24198
|
-
return /* @__PURE__ */ new Set();
|
|
24199
|
-
}
|
|
24200
|
-
throw error61;
|
|
24201
|
-
}
|
|
24202
|
-
try {
|
|
24203
|
-
const metadata = await handle.stat();
|
|
24204
|
-
if (!metadata.isFile() || metadata.size > MAX_GRANT_FILE_LENGTH || typeof process.getuid === "function" && metadata.uid !== process.getuid() || process.platform !== "win32" && (metadata.mode & 63) !== 0) {
|
|
24205
|
-
throw new Error("The local installation grant file is not private");
|
|
24206
|
-
}
|
|
24207
|
-
const encoded = await handle.readFile({ encoding: "utf8" });
|
|
24208
|
-
const value = JSON.parse(encoded);
|
|
24209
|
-
if (!isRecord4(value) || Object.keys(value).length !== 1 || !Array.isArray(value["agents"])) {
|
|
24210
|
-
throw new Error("The local installation grant file is invalid");
|
|
24211
|
-
}
|
|
24212
|
-
const agents = /* @__PURE__ */ new Set();
|
|
24213
|
-
for (const candidate of value["agents"]) {
|
|
24214
|
-
if (typeof candidate !== "string" || !AGENT_ID_PATTERN.test(candidate) || agents.has(candidate)) {
|
|
24215
|
-
throw new Error("The local installation grant file is invalid");
|
|
24216
|
-
}
|
|
24217
|
-
agents.add(candidate);
|
|
24218
|
-
}
|
|
24219
|
-
return agents;
|
|
24220
|
-
} finally {
|
|
24221
|
-
await handle.close();
|
|
24222
|
-
}
|
|
24223
|
-
}
|
|
24224
|
-
|
|
24225
24197
|
// src/agent-catalog/agent-discovery.ts
|
|
24226
24198
|
var AgentDiscovery = class {
|
|
24227
24199
|
specification;
|
|
@@ -24286,7 +24258,7 @@ var LocalAgentInventory = class {
|
|
|
24286
24258
|
discoveries;
|
|
24287
24259
|
installable;
|
|
24288
24260
|
unavailable;
|
|
24289
|
-
constructor(discoveries,
|
|
24261
|
+
constructor(discoveries, platform = process.platform, architecture = process.arch) {
|
|
24290
24262
|
const available = [];
|
|
24291
24263
|
const unavailable = [];
|
|
24292
24264
|
for (const discovery of discoveries) {
|
|
@@ -24309,8 +24281,7 @@ var LocalAgentInventory = class {
|
|
|
24309
24281
|
).map(
|
|
24310
24282
|
(discovery) => new InstallableAgentDefinition(
|
|
24311
24283
|
discovery.specification.id,
|
|
24312
|
-
discovery.specification.label
|
|
24313
|
-
!grantedAgents.has(discovery.specification.id)
|
|
24284
|
+
discovery.specification.label
|
|
24314
24285
|
)
|
|
24315
24286
|
)
|
|
24316
24287
|
);
|
|
@@ -24323,13 +24294,13 @@ var LocalAgentInventory = class {
|
|
|
24323
24294
|
import {
|
|
24324
24295
|
mkdir,
|
|
24325
24296
|
mkdtemp,
|
|
24326
|
-
open as
|
|
24297
|
+
open as open2,
|
|
24327
24298
|
realpath as realpath2,
|
|
24328
24299
|
rename,
|
|
24329
24300
|
rm,
|
|
24330
24301
|
stat as stat2
|
|
24331
24302
|
} from "node:fs/promises";
|
|
24332
|
-
import { delimiter, dirname as dirname3, isAbsolute, join as
|
|
24303
|
+
import { delimiter, dirname as dirname3, isAbsolute, join as join4, relative, sep } from "node:path";
|
|
24333
24304
|
var INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
24334
24305
|
var PACKAGE_METADATA_LIMIT_BYTES = 64 * 1024;
|
|
24335
24306
|
var PACKAGE_LOCK_LIMIT_BYTES = 8 * 1024 * 1024;
|
|
@@ -24348,6 +24319,7 @@ var ManagedNpmPackageDefinition = class {
|
|
|
24348
24319
|
};
|
|
24349
24320
|
var SriManagedNpmPackageDefinition = class extends ManagedNpmPackageDefinition {
|
|
24350
24321
|
integrity;
|
|
24322
|
+
requiredDependencies = Object.freeze([]);
|
|
24351
24323
|
tarballUrl;
|
|
24352
24324
|
constructor(packageName, version2, executableName, integrity, tarballUrl) {
|
|
24353
24325
|
super(packageName, version2, executableName);
|
|
@@ -24355,6 +24327,18 @@ var SriManagedNpmPackageDefinition = class extends ManagedNpmPackageDefinition {
|
|
|
24355
24327
|
this.tarballUrl = tarballUrl;
|
|
24356
24328
|
}
|
|
24357
24329
|
};
|
|
24330
|
+
var SriManagedNpmDependencyDefinition = class {
|
|
24331
|
+
integrity;
|
|
24332
|
+
packageName;
|
|
24333
|
+
tarballUrl;
|
|
24334
|
+
version;
|
|
24335
|
+
constructor(packageName, version2, integrity, tarballUrl) {
|
|
24336
|
+
this.integrity = integrity;
|
|
24337
|
+
this.packageName = packageName;
|
|
24338
|
+
this.tarballUrl = tarballUrl;
|
|
24339
|
+
this.version = version2;
|
|
24340
|
+
}
|
|
24341
|
+
};
|
|
24358
24342
|
var ManagedNpmPackageError = class extends Error {
|
|
24359
24343
|
code;
|
|
24360
24344
|
constructor(code, message, options = {}) {
|
|
@@ -24363,11 +24347,11 @@ var ManagedNpmPackageError = class extends Error {
|
|
|
24363
24347
|
this.name = "ManagedNpmPackageError";
|
|
24364
24348
|
}
|
|
24365
24349
|
};
|
|
24366
|
-
function
|
|
24350
|
+
function isRecord4(value) {
|
|
24367
24351
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24368
24352
|
}
|
|
24369
24353
|
function packagePath(root, packageName) {
|
|
24370
|
-
return
|
|
24354
|
+
return join4(root, "node_modules", ...packageName.split("/"));
|
|
24371
24355
|
}
|
|
24372
24356
|
function isContainedPath(root, candidate) {
|
|
24373
24357
|
const difference = relative(root, candidate);
|
|
@@ -24375,7 +24359,7 @@ function isContainedPath(root, candidate) {
|
|
|
24375
24359
|
}
|
|
24376
24360
|
async function readJsonRecord(path2, maximumBytes) {
|
|
24377
24361
|
try {
|
|
24378
|
-
const handle = await
|
|
24362
|
+
const handle = await open2(path2, "r");
|
|
24379
24363
|
try {
|
|
24380
24364
|
const metadata = await handle.stat();
|
|
24381
24365
|
if (!metadata.isFile() || metadata.size > maximumBytes) {
|
|
@@ -24387,7 +24371,7 @@ async function readJsonRecord(path2, maximumBytes) {
|
|
|
24387
24371
|
const value = JSON.parse(
|
|
24388
24372
|
await handle.readFile({ encoding: "utf8" })
|
|
24389
24373
|
);
|
|
24390
|
-
if (!
|
|
24374
|
+
if (!isRecord4(value)) {
|
|
24391
24375
|
throw new ManagedNpmPackageError(
|
|
24392
24376
|
"managed_package_verification_failed",
|
|
24393
24377
|
"The managed npm package metadata is invalid"
|
|
@@ -24413,7 +24397,7 @@ function readBinPath(packageMetadata, executableName) {
|
|
|
24413
24397
|
if (typeof bin === "string") {
|
|
24414
24398
|
return bin;
|
|
24415
24399
|
}
|
|
24416
|
-
if (
|
|
24400
|
+
if (isRecord4(bin) && typeof bin[executableName] === "string") {
|
|
24417
24401
|
return bin[executableName];
|
|
24418
24402
|
}
|
|
24419
24403
|
throw new ManagedNpmPackageError(
|
|
@@ -24421,7 +24405,7 @@ function readBinPath(packageMetadata, executableName) {
|
|
|
24421
24405
|
"The managed npm package executable declaration is invalid"
|
|
24422
24406
|
);
|
|
24423
24407
|
}
|
|
24424
|
-
function
|
|
24408
|
+
function verifyPackageLockEntry(lock, definition, verifyDependencyClosure) {
|
|
24425
24409
|
if (lock["lockfileVersion"] !== 3) {
|
|
24426
24410
|
throw new ManagedNpmPackageError(
|
|
24427
24411
|
"managed_package_verification_failed",
|
|
@@ -24429,7 +24413,7 @@ function verifyPackageLock(lock, definition) {
|
|
|
24429
24413
|
);
|
|
24430
24414
|
}
|
|
24431
24415
|
const packages = lock["packages"];
|
|
24432
|
-
if (!
|
|
24416
|
+
if (!isRecord4(packages)) {
|
|
24433
24417
|
throw new ManagedNpmPackageError(
|
|
24434
24418
|
"managed_package_verification_failed",
|
|
24435
24419
|
"The managed npm package lockfile is invalid"
|
|
@@ -24440,10 +24424,10 @@ function verifyPackageLock(lock, definition) {
|
|
|
24440
24424
|
let matches = 0;
|
|
24441
24425
|
for (const [key, candidate] of Object.entries(packages)) {
|
|
24442
24426
|
const normalizedKey = key.replaceAll("\\", "/");
|
|
24443
|
-
if (
|
|
24427
|
+
if (verifyDependencyClosure && normalizedKey.length > 0) {
|
|
24444
24428
|
let resolved;
|
|
24445
24429
|
try {
|
|
24446
|
-
if (!normalizedKey.split("/").includes("node_modules") || !
|
|
24430
|
+
if (!normalizedKey.split("/").includes("node_modules") || !isRecord4(candidate) || typeof candidate["version"] !== "string" || candidate["version"].length === 0 || typeof candidate["integrity"] !== "string" || !/^sha512-[A-Za-z0-9+/]{86}==$/.test(candidate["integrity"]) || typeof candidate["resolved"] !== "string") {
|
|
24447
24431
|
throw new Error("Invalid locked dependency");
|
|
24448
24432
|
}
|
|
24449
24433
|
resolved = new URL(candidate["resolved"]);
|
|
@@ -24466,13 +24450,35 @@ function verifyPackageLock(lock, definition) {
|
|
|
24466
24450
|
matches += 1;
|
|
24467
24451
|
}
|
|
24468
24452
|
}
|
|
24469
|
-
if (matches !== 1 || !
|
|
24453
|
+
if (matches !== 1 || !isRecord4(entry) || entry["integrity"] !== definition.integrity || entry["resolved"] !== definition.tarballUrl || entry["version"] !== definition.version) {
|
|
24470
24454
|
throw new ManagedNpmPackageError(
|
|
24471
24455
|
"managed_package_verification_failed",
|
|
24472
24456
|
"The managed npm package lockfile does not match the pinned artifact"
|
|
24473
24457
|
);
|
|
24474
24458
|
}
|
|
24475
24459
|
}
|
|
24460
|
+
async function verifyRequiredDependency(rootPath, lock, definition) {
|
|
24461
|
+
const dependencyRoot = await realpath2(
|
|
24462
|
+
packagePath(rootPath, definition.packageName)
|
|
24463
|
+
);
|
|
24464
|
+
if (!isContainedPath(rootPath, dependencyRoot)) {
|
|
24465
|
+
throw new ManagedNpmPackageError(
|
|
24466
|
+
"managed_package_verification_failed",
|
|
24467
|
+
"The required managed npm dependency escaped its private cache"
|
|
24468
|
+
);
|
|
24469
|
+
}
|
|
24470
|
+
const metadata = await readJsonRecord(
|
|
24471
|
+
join4(dependencyRoot, "package.json"),
|
|
24472
|
+
PACKAGE_METADATA_LIMIT_BYTES
|
|
24473
|
+
);
|
|
24474
|
+
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
24475
|
+
throw new ManagedNpmPackageError(
|
|
24476
|
+
"managed_package_verification_failed",
|
|
24477
|
+
"The required managed npm dependency identity is invalid"
|
|
24478
|
+
);
|
|
24479
|
+
}
|
|
24480
|
+
verifyPackageLockEntry(lock, definition, false);
|
|
24481
|
+
}
|
|
24476
24482
|
async function validateManagedNpmPackage(root, definition) {
|
|
24477
24483
|
try {
|
|
24478
24484
|
return await validateManagedNpmPackageContents(root, definition);
|
|
@@ -24499,7 +24505,7 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
24499
24505
|
);
|
|
24500
24506
|
}
|
|
24501
24507
|
const metadata = await readJsonRecord(
|
|
24502
|
-
|
|
24508
|
+
join4(packageRoot, "package.json"),
|
|
24503
24509
|
PACKAGE_METADATA_LIMIT_BYTES
|
|
24504
24510
|
);
|
|
24505
24511
|
if (metadata["name"] !== definition.packageName || metadata["version"] !== definition.version) {
|
|
@@ -24509,17 +24515,22 @@ async function validateManagedNpmPackageContents(root, definition) {
|
|
|
24509
24515
|
);
|
|
24510
24516
|
}
|
|
24511
24517
|
if (definition instanceof SriManagedNpmPackageDefinition) {
|
|
24512
|
-
|
|
24513
|
-
|
|
24514
|
-
|
|
24515
|
-
|
|
24516
|
-
|
|
24517
|
-
|
|
24518
|
+
const lock = await readJsonRecord(
|
|
24519
|
+
join4(rootPath, "package-lock.json"),
|
|
24520
|
+
PACKAGE_LOCK_LIMIT_BYTES
|
|
24521
|
+
);
|
|
24522
|
+
verifyPackageLockEntry(
|
|
24523
|
+
lock,
|
|
24524
|
+
definition,
|
|
24525
|
+
definition.verifyDependencyClosure
|
|
24518
24526
|
);
|
|
24527
|
+
for (const dependency of definition.requiredDependencies) {
|
|
24528
|
+
await verifyRequiredDependency(rootPath, lock, dependency);
|
|
24529
|
+
}
|
|
24519
24530
|
}
|
|
24520
24531
|
const declaredBin = readBinPath(metadata, definition.executableName);
|
|
24521
24532
|
const executable = await resolveExecutablePath(
|
|
24522
|
-
|
|
24533
|
+
join4(packageRoot, declaredBin)
|
|
24523
24534
|
);
|
|
24524
24535
|
if (executable === null || !isContainedPath(rootPath, executable.path)) {
|
|
24525
24536
|
throw new ManagedNpmPackageError(
|
|
@@ -24545,7 +24556,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
24545
24556
|
const parent = dirname3(root);
|
|
24546
24557
|
await mkdir(parent, { mode: 448, recursive: true });
|
|
24547
24558
|
const staging = await mkdtemp(
|
|
24548
|
-
|
|
24559
|
+
join4(parent, `.${definition.version}.staging-`)
|
|
24549
24560
|
);
|
|
24550
24561
|
try {
|
|
24551
24562
|
const npm = await findExecutableOnPath(
|
|
@@ -24575,9 +24586,9 @@ var ManagedNpmPackageInstaller = class {
|
|
|
24575
24586
|
`${definition.packageName}@${definition.version}`
|
|
24576
24587
|
);
|
|
24577
24588
|
const installEnvironment = {
|
|
24578
|
-
HOME:
|
|
24589
|
+
HOME: join4(staging, "home"),
|
|
24579
24590
|
NPM_CONFIG_AUDIT: "false",
|
|
24580
|
-
NPM_CONFIG_CACHE:
|
|
24591
|
+
NPM_CONFIG_CACHE: join4(staging, ".npm-cache"),
|
|
24581
24592
|
NPM_CONFIG_FUND: "false",
|
|
24582
24593
|
NPM_CONFIG_IGNORE_SCRIPTS: "true",
|
|
24583
24594
|
NPM_CONFIG_PACKAGE_LOCK: "true",
|
|
@@ -24599,8 +24610,8 @@ var ManagedNpmPackageInstaller = class {
|
|
|
24599
24610
|
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS
|
|
24600
24611
|
});
|
|
24601
24612
|
await Promise.all([
|
|
24602
|
-
rm(
|
|
24603
|
-
rm(
|
|
24613
|
+
rm(join4(staging, ".npm-cache"), { force: true, recursive: true }),
|
|
24614
|
+
rm(join4(staging, "home"), { force: true, recursive: true })
|
|
24604
24615
|
]);
|
|
24605
24616
|
await validateManagedNpmPackage(staging, definition);
|
|
24606
24617
|
try {
|
|
@@ -24636,7 +24647,7 @@ var ManagedNpmPackageInstaller = class {
|
|
|
24636
24647
|
};
|
|
24637
24648
|
|
|
24638
24649
|
// src/agent-catalog/agent-specification.ts
|
|
24639
|
-
import { join as
|
|
24650
|
+
import { join as join5 } from "node:path";
|
|
24640
24651
|
var VERSION_PROBE_TIMEOUT_MILLISECONDS = 3e3;
|
|
24641
24652
|
var ACP_PROBE_TIMEOUT_MILLISECONDS = 5e3;
|
|
24642
24653
|
var DEFAULT_PROMPT_TIMEOUT_MILLISECONDS = 30 * 60 * 1e3;
|
|
@@ -24650,7 +24661,7 @@ var LocalAgentSpecification = class {
|
|
|
24650
24661
|
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
24651
24662
|
signal.throwIfAborted();
|
|
24652
24663
|
const executable = await resolveExecutablePath(
|
|
24653
|
-
|
|
24664
|
+
join5(stateDirectory, ...this.managedAgentExecutablePath),
|
|
24654
24665
|
platform
|
|
24655
24666
|
);
|
|
24656
24667
|
signal.throwIfAborted();
|
|
@@ -24755,9 +24766,84 @@ var CodexAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
24755
24766
|
managedAgentExecutablePath = ["agents", "codex", "bin", "codex"];
|
|
24756
24767
|
};
|
|
24757
24768
|
|
|
24769
|
+
// src/agent-catalog/agent-probe-error.ts
|
|
24770
|
+
var AgentProbeError = class extends Error {
|
|
24771
|
+
code;
|
|
24772
|
+
constructor(code, message, options = {}) {
|
|
24773
|
+
super(message, options);
|
|
24774
|
+
this.code = code;
|
|
24775
|
+
this.name = "AgentProbeError";
|
|
24776
|
+
}
|
|
24777
|
+
};
|
|
24778
|
+
|
|
24779
|
+
// src/agent-catalog/agents/verify-session-creation.ts
|
|
24780
|
+
import {
|
|
24781
|
+
methods as methods3
|
|
24782
|
+
} from "@agentclientprotocol/sdk";
|
|
24783
|
+
async function verifySessionCreation(connection, capabilities, defaultWorkspace, signal, label) {
|
|
24784
|
+
const session = await connection.agent.request(
|
|
24785
|
+
methods3.agent.session.new,
|
|
24786
|
+
{
|
|
24787
|
+
additionalDirectories: [],
|
|
24788
|
+
cwd: defaultWorkspace,
|
|
24789
|
+
mcpServers: []
|
|
24790
|
+
},
|
|
24791
|
+
{ cancellationSignal: signal }
|
|
24792
|
+
);
|
|
24793
|
+
if (session.sessionId.length === 0) {
|
|
24794
|
+
throw new AgentProbeError(
|
|
24795
|
+
"acp_incompatible",
|
|
24796
|
+
`${label} returned an invalid ACP session`
|
|
24797
|
+
);
|
|
24798
|
+
}
|
|
24799
|
+
if (capabilities.sessionCapabilities?.close != null) {
|
|
24800
|
+
await connection.agent.request(
|
|
24801
|
+
methods3.agent.session.close,
|
|
24802
|
+
{ sessionId: session.sessionId },
|
|
24803
|
+
{ cancellationSignal: signal }
|
|
24804
|
+
);
|
|
24805
|
+
}
|
|
24806
|
+
}
|
|
24807
|
+
|
|
24808
|
+
// src/agent-catalog/agents/cursor-cli-agent.ts
|
|
24809
|
+
var CURSOR_CLI_TESTED_VERSION = "2026.09.02-c22c1a3";
|
|
24810
|
+
var CursorCliAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
24811
|
+
adapterVersion = CURSOR_CLI_TESTED_VERSION;
|
|
24812
|
+
authenticationCommand = () => "cursor-agent login";
|
|
24813
|
+
agentExecutable = "cursor-agent";
|
|
24814
|
+
id = "cursor";
|
|
24815
|
+
label = "Cursor CLI";
|
|
24816
|
+
constructor() {
|
|
24817
|
+
super(
|
|
24818
|
+
"MOBIUS_CURSOR_PATH",
|
|
24819
|
+
["--disable-auto-update", "acp"],
|
|
24820
|
+
["agents", "cursor", CURSOR_CLI_TESTED_VERSION, "bin", "cursor-agent"]
|
|
24821
|
+
);
|
|
24822
|
+
}
|
|
24823
|
+
supportsInstallation = (_platform, _architecture) => false;
|
|
24824
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
24825
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
24826
|
+
if (capabilities.loadSession !== true || capabilities.sessionCapabilities?.list == null || !(initialized.authMethods ?? []).some(
|
|
24827
|
+
(method) => method.id === "cursor_login"
|
|
24828
|
+
)) {
|
|
24829
|
+
throw new AgentProbeError(
|
|
24830
|
+
"acp_incompatible",
|
|
24831
|
+
"Cursor CLI reported an unsupported ACP capability set"
|
|
24832
|
+
);
|
|
24833
|
+
}
|
|
24834
|
+
await verifySessionCreation(
|
|
24835
|
+
connection,
|
|
24836
|
+
capabilities,
|
|
24837
|
+
defaultWorkspace,
|
|
24838
|
+
signal,
|
|
24839
|
+
this.label
|
|
24840
|
+
);
|
|
24841
|
+
};
|
|
24842
|
+
};
|
|
24843
|
+
|
|
24758
24844
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
24759
24845
|
import { realpath as realpath3, stat as stat3 } from "node:fs/promises";
|
|
24760
|
-
import { isAbsolute as isAbsolute2, join as
|
|
24846
|
+
import { isAbsolute as isAbsolute2, join as join6, normalize } from "node:path";
|
|
24761
24847
|
|
|
24762
24848
|
// src/agent-installation/deepseek-managed-package.ts
|
|
24763
24849
|
var DeepSeekHarnessManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
@@ -24775,16 +24861,6 @@ var DEEPSEEK_HARNESS_PACKAGE = new DeepSeekHarnessManagedPackage(
|
|
|
24775
24861
|
"https://registry.npmjs.org/@deepseek-ai/dsh/-/dsh-0.1.2-rc.1.tgz"
|
|
24776
24862
|
);
|
|
24777
24863
|
|
|
24778
|
-
// src/agent-catalog/agent-probe-error.ts
|
|
24779
|
-
var AgentProbeError = class extends Error {
|
|
24780
|
-
code;
|
|
24781
|
-
constructor(code, message, options = {}) {
|
|
24782
|
-
super(message, options);
|
|
24783
|
-
this.code = code;
|
|
24784
|
-
this.name = "AgentProbeError";
|
|
24785
|
-
}
|
|
24786
|
-
};
|
|
24787
|
-
|
|
24788
24864
|
// src/agent-catalog/agents/deepseek-harness-agent.ts
|
|
24789
24865
|
async function validateAgentHome(path2) {
|
|
24790
24866
|
if (!isAbsolute2(path2) || normalize(path2) !== path2) {
|
|
@@ -24842,7 +24918,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
24842
24918
|
context.signal
|
|
24843
24919
|
);
|
|
24844
24920
|
if (managed.path === agent.path) {
|
|
24845
|
-
selectedHome =
|
|
24921
|
+
selectedHome = join6(
|
|
24846
24922
|
readStateDirectory(context.environment),
|
|
24847
24923
|
"agents",
|
|
24848
24924
|
this.id,
|
|
@@ -24863,7 +24939,7 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
24863
24939
|
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
24864
24940
|
signal.throwIfAborted();
|
|
24865
24941
|
const executable = await validateManagedNpmPackage(
|
|
24866
|
-
|
|
24942
|
+
join6(stateDirectory, "agents", this.id, DEEPSEEK_HARNESS_PACKAGE.version),
|
|
24867
24943
|
DEEPSEEK_HARNESS_PACKAGE
|
|
24868
24944
|
);
|
|
24869
24945
|
signal.throwIfAborted();
|
|
@@ -24883,6 +24959,166 @@ var DeepSeekHarnessAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
24883
24959
|
};
|
|
24884
24960
|
};
|
|
24885
24961
|
|
|
24962
|
+
// src/agent-catalog/agents/grok-build-agent.ts
|
|
24963
|
+
import { realpath as realpath4 } from "node:fs/promises";
|
|
24964
|
+
import { isAbsolute as isAbsolute3, join as join7, relative as relative2, sep as sep2 } from "node:path";
|
|
24965
|
+
|
|
24966
|
+
// src/agent-installation/grok-managed-package.ts
|
|
24967
|
+
var GROK_BUILD_MANAGED_VERSION = "1.0.21";
|
|
24968
|
+
var GrokBuildManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
24969
|
+
dependencyResolutionArguments = Object.freeze([
|
|
24970
|
+
"--before=2026-09-04T19:51:47.325Z"
|
|
24971
|
+
]);
|
|
24972
|
+
includeOptionalDependencies = true;
|
|
24973
|
+
requiredDependencies;
|
|
24974
|
+
verifyDependencyClosure = true;
|
|
24975
|
+
constructor(requiredDependency) {
|
|
24976
|
+
super(
|
|
24977
|
+
"@xai-official/grok",
|
|
24978
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
24979
|
+
"grok",
|
|
24980
|
+
"sha512-6yQqC+h1o+ObaqCxImK23dhkrOX1DEBMOKaH6fCK+B4gX0/8XIKZp0n7iKyBdK8KZa5vhMn7pS45kjX49Tps5g==",
|
|
24981
|
+
"https://registry.npmjs.org/@xai-official/grok/-/grok-1.0.21.tgz"
|
|
24982
|
+
);
|
|
24983
|
+
this.requiredDependencies = Object.freeze([requiredDependency]);
|
|
24984
|
+
}
|
|
24985
|
+
};
|
|
24986
|
+
var GROK_DARWIN_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
24987
|
+
"@xai-official/grok-darwin-arm64",
|
|
24988
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
24989
|
+
"sha512-I4pKZGnR6Mv4MJOJsB9B/i2o0ODF4eZtp4jHN5feoTqKIeAUVg38OzBtE8aN/wZa7Xg+qhnf6Jd1tcAFvMoFtQ==",
|
|
24990
|
+
"https://registry.npmjs.org/@xai-official/grok-darwin-arm64/-/grok-darwin-arm64-1.0.21.tgz"
|
|
24991
|
+
);
|
|
24992
|
+
var GROK_DARWIN_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
24993
|
+
"@xai-official/grok-darwin-x64",
|
|
24994
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
24995
|
+
"sha512-h0nFj3NZ9Kz8w6fQ6UDxxeSIhC1WjwwoRE92iNbG//tZy6YGkppR3s7oRVtt4Xl0CJANKUt0EusyIYnnAvKLzw==",
|
|
24996
|
+
"https://registry.npmjs.org/@xai-official/grok-darwin-x64/-/grok-darwin-x64-1.0.21.tgz"
|
|
24997
|
+
);
|
|
24998
|
+
var GROK_LINUX_ARM64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
24999
|
+
"@xai-official/grok-linux-arm64",
|
|
25000
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25001
|
+
"sha512-Jlwz9XtZPNKz/V/ydifC8OVu3hIZz7pmoStt8c4KCqkSWjWiZ/PBIC0iJiq8rvByhx5Z0EdSyq8ZXVwtocceGA==",
|
|
25002
|
+
"https://registry.npmjs.org/@xai-official/grok-linux-arm64/-/grok-linux-arm64-1.0.21.tgz"
|
|
25003
|
+
);
|
|
25004
|
+
var GROK_LINUX_X64_PACKAGE = new SriManagedNpmDependencyDefinition(
|
|
25005
|
+
"@xai-official/grok-linux-x64",
|
|
25006
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25007
|
+
"sha512-AjDV5ifEz5LFG2Jt5IlhAeEkJati/wOvCchVbR4eIj2ogjvmXoXlzBrYRXuAJpXBy5q0se/Yuez5FxDU9Ju81w==",
|
|
25008
|
+
"https://registry.npmjs.org/@xai-official/grok-linux-x64/-/grok-linux-x64-1.0.21.tgz"
|
|
25009
|
+
);
|
|
25010
|
+
function grokBuildManagedPackage(platform, architecture) {
|
|
25011
|
+
if (platform === "darwin" && architecture === "arm64") {
|
|
25012
|
+
return new GrokBuildManagedPackage(GROK_DARWIN_ARM64_PACKAGE);
|
|
25013
|
+
}
|
|
25014
|
+
if (platform === "darwin" && architecture === "x64") {
|
|
25015
|
+
return new GrokBuildManagedPackage(GROK_DARWIN_X64_PACKAGE);
|
|
25016
|
+
}
|
|
25017
|
+
if (platform === "linux" && architecture === "arm64") {
|
|
25018
|
+
return new GrokBuildManagedPackage(GROK_LINUX_ARM64_PACKAGE);
|
|
25019
|
+
}
|
|
25020
|
+
if (platform === "linux" && architecture === "x64") {
|
|
25021
|
+
return new GrokBuildManagedPackage(GROK_LINUX_X64_PACKAGE);
|
|
25022
|
+
}
|
|
25023
|
+
throw new Error("Grok Build does not publish a package for this platform");
|
|
25024
|
+
}
|
|
25025
|
+
|
|
25026
|
+
// src/agent-catalog/agents/grok-build-agent.ts
|
|
25027
|
+
function isContainedPath2(root, candidate) {
|
|
25028
|
+
const difference = relative2(root, candidate);
|
|
25029
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep2}`) && !isAbsolute3(difference);
|
|
25030
|
+
}
|
|
25031
|
+
var GrokBuildAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
25032
|
+
adapterVersion = GROK_BUILD_MANAGED_VERSION;
|
|
25033
|
+
authenticationCommand = () => "grok login";
|
|
25034
|
+
agentExecutable = "grok";
|
|
25035
|
+
agentVersionArguments = ["version"];
|
|
25036
|
+
adapterVersionArguments = ["version"];
|
|
25037
|
+
id = "grok-build";
|
|
25038
|
+
label = "Grok Build";
|
|
25039
|
+
constructor() {
|
|
25040
|
+
super(
|
|
25041
|
+
"MOBIUS_GROK_BUILD_PATH",
|
|
25042
|
+
["--no-auto-update", "agent", "stdio"],
|
|
25043
|
+
[
|
|
25044
|
+
"agents",
|
|
25045
|
+
"grok-build",
|
|
25046
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25047
|
+
"home",
|
|
25048
|
+
"bin",
|
|
25049
|
+
"grok"
|
|
25050
|
+
]
|
|
25051
|
+
);
|
|
25052
|
+
}
|
|
25053
|
+
createLaunchEnvironment = async (agent, context) => {
|
|
25054
|
+
const stateDirectory = readStateDirectory(context.environment);
|
|
25055
|
+
try {
|
|
25056
|
+
const managed = await this.resolveManagedAgent(
|
|
25057
|
+
stateDirectory,
|
|
25058
|
+
context.platform ?? process.platform,
|
|
25059
|
+
context.signal
|
|
25060
|
+
);
|
|
25061
|
+
if (managed.path === agent.path) {
|
|
25062
|
+
return Object.freeze({
|
|
25063
|
+
GROK_HOME: await realpath4(
|
|
25064
|
+
join7(
|
|
25065
|
+
stateDirectory,
|
|
25066
|
+
"agents",
|
|
25067
|
+
this.id,
|
|
25068
|
+
GROK_BUILD_MANAGED_VERSION,
|
|
25069
|
+
"home"
|
|
25070
|
+
)
|
|
25071
|
+
)
|
|
25072
|
+
});
|
|
25073
|
+
}
|
|
25074
|
+
} catch {
|
|
25075
|
+
context.signal.throwIfAborted();
|
|
25076
|
+
}
|
|
25077
|
+
return Object.freeze({});
|
|
25078
|
+
};
|
|
25079
|
+
resolveManagedAgent = async (stateDirectory, platform, signal) => {
|
|
25080
|
+
signal.throwIfAborted();
|
|
25081
|
+
const versionRoot = await realpath4(
|
|
25082
|
+
join7(stateDirectory, "agents", this.id, GROK_BUILD_MANAGED_VERSION)
|
|
25083
|
+
);
|
|
25084
|
+
await validateManagedNpmPackage(
|
|
25085
|
+
join7(versionRoot, "package"),
|
|
25086
|
+
grokBuildManagedPackage(platform, process.arch)
|
|
25087
|
+
);
|
|
25088
|
+
const executable = await resolveExecutablePath(
|
|
25089
|
+
join7(versionRoot, "home", "bin", "grok"),
|
|
25090
|
+
platform
|
|
25091
|
+
);
|
|
25092
|
+
signal.throwIfAborted();
|
|
25093
|
+
if (executable === null || !isContainedPath2(versionRoot, executable.path)) {
|
|
25094
|
+
throw new AgentProbeError(
|
|
25095
|
+
"managed_agent_invalid",
|
|
25096
|
+
"The managed Grok Build executable is invalid"
|
|
25097
|
+
);
|
|
25098
|
+
}
|
|
25099
|
+
return executable;
|
|
25100
|
+
};
|
|
25101
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
25102
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
25103
|
+
const session = capabilities.sessionCapabilities;
|
|
25104
|
+
if (capabilities.loadSession !== true || session?.close == null || session.list == null || session.resume == null || !(initialized.authMethods ?? []).some(
|
|
25105
|
+
(method) => method.id === "xai.api_key" || method.id === "grok.com"
|
|
25106
|
+
)) {
|
|
25107
|
+
throw new AgentProbeError(
|
|
25108
|
+
"acp_incompatible",
|
|
25109
|
+
"Grok Build reported an unsupported ACP capability set"
|
|
25110
|
+
);
|
|
25111
|
+
}
|
|
25112
|
+
await verifySessionCreation(
|
|
25113
|
+
connection,
|
|
25114
|
+
capabilities,
|
|
25115
|
+
defaultWorkspace,
|
|
25116
|
+
signal,
|
|
25117
|
+
this.label
|
|
25118
|
+
);
|
|
25119
|
+
};
|
|
25120
|
+
};
|
|
25121
|
+
|
|
24886
25122
|
// src/agent-catalog/agents/opencode-agent.ts
|
|
24887
25123
|
import { join as join9 } from "node:path";
|
|
24888
25124
|
|
|
@@ -24894,18 +25130,18 @@ import {
|
|
|
24894
25130
|
copyFile,
|
|
24895
25131
|
mkdir as mkdir2,
|
|
24896
25132
|
mkdtemp as mkdtemp2,
|
|
24897
|
-
open as
|
|
24898
|
-
realpath as
|
|
25133
|
+
open as open4,
|
|
25134
|
+
realpath as realpath5,
|
|
24899
25135
|
rename as rename2,
|
|
24900
25136
|
rm as rm2,
|
|
24901
25137
|
stat as stat4,
|
|
24902
25138
|
writeFile
|
|
24903
25139
|
} from "node:fs/promises";
|
|
24904
|
-
import { dirname as dirname4, isAbsolute as
|
|
25140
|
+
import { dirname as dirname4, isAbsolute as isAbsolute4, join as join8, relative as relative3, sep as sep3 } from "node:path";
|
|
24905
25141
|
|
|
24906
25142
|
// src/agent-installation/verified-download.ts
|
|
24907
25143
|
import { createHash } from "node:crypto";
|
|
24908
|
-
import { open as
|
|
25144
|
+
import { open as open3, unlink } from "node:fs/promises";
|
|
24909
25145
|
import { fetch } from "undici";
|
|
24910
25146
|
|
|
24911
25147
|
// src/network/environment-proxy.ts
|
|
@@ -25037,7 +25273,7 @@ async function downloadVerifiedFile(options, transport = new UndiciInstallerDown
|
|
|
25037
25273
|
);
|
|
25038
25274
|
}
|
|
25039
25275
|
}
|
|
25040
|
-
handle = await
|
|
25276
|
+
handle = await open3(options.destination, "wx", 384);
|
|
25041
25277
|
const digest = createHash("sha256");
|
|
25042
25278
|
const reader = fetched.response.body.getReader();
|
|
25043
25279
|
let bytes = 0;
|
|
@@ -25147,12 +25383,12 @@ var ManagedAgentArchiveError = class extends Error {
|
|
|
25147
25383
|
var ManagedAgentArchiveDownloader = class {
|
|
25148
25384
|
download = async (options) => await downloadVerifiedFile(options);
|
|
25149
25385
|
};
|
|
25150
|
-
function
|
|
25386
|
+
function isRecord5(value) {
|
|
25151
25387
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
25152
25388
|
}
|
|
25153
|
-
function
|
|
25154
|
-
const difference =
|
|
25155
|
-
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${
|
|
25389
|
+
function isContainedPath3(root, candidate) {
|
|
25390
|
+
const difference = relative3(root, candidate);
|
|
25391
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep3}`) && !isAbsolute4(difference);
|
|
25156
25392
|
}
|
|
25157
25393
|
async function hashFile(path2, signal) {
|
|
25158
25394
|
signal.throwIfAborted();
|
|
@@ -25187,7 +25423,7 @@ async function hashFile(path2, signal) {
|
|
|
25187
25423
|
async function readManifest(path2) {
|
|
25188
25424
|
let handle;
|
|
25189
25425
|
try {
|
|
25190
|
-
handle = await
|
|
25426
|
+
handle = await open4(path2, "r");
|
|
25191
25427
|
} catch (error61) {
|
|
25192
25428
|
throw new ManagedAgentArchiveError(
|
|
25193
25429
|
"managed_archive_verification_failed",
|
|
@@ -25206,7 +25442,7 @@ async function readManifest(path2) {
|
|
|
25206
25442
|
const parsed = JSON.parse(
|
|
25207
25443
|
await handle.readFile({ encoding: "utf8" })
|
|
25208
25444
|
);
|
|
25209
|
-
if (!
|
|
25445
|
+
if (!isRecord5(parsed)) {
|
|
25210
25446
|
throw new ManagedAgentArchiveError(
|
|
25211
25447
|
"managed_archive_verification_failed",
|
|
25212
25448
|
"The managed Agent archive manifest is invalid"
|
|
@@ -25228,7 +25464,7 @@ async function readManifest(path2) {
|
|
|
25228
25464
|
}
|
|
25229
25465
|
async function validateManagedAgentArchive(root, definition, signal) {
|
|
25230
25466
|
try {
|
|
25231
|
-
const rootPath = await
|
|
25467
|
+
const rootPath = await realpath5(root);
|
|
25232
25468
|
const rootMetadata = await stat4(rootPath);
|
|
25233
25469
|
if (!rootMetadata.isDirectory() || typeof process.getuid === "function" && rootMetadata.uid !== process.getuid()) {
|
|
25234
25470
|
throw new Error("Managed Agent root is not user-owned");
|
|
@@ -25240,7 +25476,7 @@ async function validateManagedAgentArchive(root, definition, signal) {
|
|
|
25240
25476
|
const executable = await resolveExecutablePath(
|
|
25241
25477
|
join8(rootPath, "bin", definition.executableName)
|
|
25242
25478
|
);
|
|
25243
|
-
if (executable === null || !
|
|
25479
|
+
if (executable === null || !isContainedPath3(rootPath, executable.path) || await hashFile(executable.path, signal) !== manifest["executableSha256"]) {
|
|
25244
25480
|
throw new Error("Managed Agent executable is invalid");
|
|
25245
25481
|
}
|
|
25246
25482
|
return executable;
|
|
@@ -25296,7 +25532,7 @@ var ManagedAgentArchiveInstaller = class {
|
|
|
25296
25532
|
const archivePath = join8(working, definition.archiveName);
|
|
25297
25533
|
const extractionRoot = join8(working, "extracted");
|
|
25298
25534
|
await mkdir2(extractionRoot, { mode: 448 });
|
|
25299
|
-
const canonicalExtractionRoot = await
|
|
25535
|
+
const canonicalExtractionRoot = await realpath5(extractionRoot);
|
|
25300
25536
|
const download = await this.#downloader.download({
|
|
25301
25537
|
allowedHosts: /* @__PURE__ */ new Set([
|
|
25302
25538
|
"github.com",
|
|
@@ -25334,11 +25570,11 @@ var ManagedAgentArchiveInstaller = class {
|
|
|
25334
25570
|
signal,
|
|
25335
25571
|
timeoutMilliseconds: ARCHIVE_EXTRACTION_TIMEOUT_MILLISECONDS
|
|
25336
25572
|
});
|
|
25337
|
-
const extracted = await
|
|
25573
|
+
const extracted = await realpath5(
|
|
25338
25574
|
join8(canonicalExtractionRoot, definition.executableName)
|
|
25339
25575
|
);
|
|
25340
25576
|
const extractedMetadata = await stat4(extracted);
|
|
25341
|
-
if (!
|
|
25577
|
+
if (!isContainedPath3(canonicalExtractionRoot, extracted) || !extractedMetadata.isFile()) {
|
|
25342
25578
|
throw new ManagedAgentArchiveError(
|
|
25343
25579
|
"managed_archive_verification_failed",
|
|
25344
25580
|
"The managed Agent archive executable is invalid"
|
|
@@ -25493,7 +25729,7 @@ var OpenCodeAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
|
25493
25729
|
// src/agent-catalog/agents/pi-agent.ts
|
|
25494
25730
|
import { join as join10 } from "node:path";
|
|
25495
25731
|
import {
|
|
25496
|
-
methods as
|
|
25732
|
+
methods as methods4
|
|
25497
25733
|
} from "@agentclientprotocol/sdk";
|
|
25498
25734
|
|
|
25499
25735
|
// src/agent-installation/pi-managed-packages.ts
|
|
@@ -25565,7 +25801,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
25565
25801
|
);
|
|
25566
25802
|
}
|
|
25567
25803
|
const session = await connection.agent.request(
|
|
25568
|
-
|
|
25804
|
+
methods4.agent.session.new,
|
|
25569
25805
|
{
|
|
25570
25806
|
additionalDirectories: [],
|
|
25571
25807
|
cwd: defaultWorkspace,
|
|
@@ -25580,7 +25816,7 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
25580
25816
|
);
|
|
25581
25817
|
}
|
|
25582
25818
|
const prompt = await connection.agent.request(
|
|
25583
|
-
|
|
25819
|
+
methods4.agent.session.prompt,
|
|
25584
25820
|
{
|
|
25585
25821
|
prompt: [{ text: "/session", type: "text" }],
|
|
25586
25822
|
sessionId: session.sessionId
|
|
@@ -25596,6 +25832,77 @@ var PiAgentSpecification = class extends BridgedAcpAgentDefinition {
|
|
|
25596
25832
|
};
|
|
25597
25833
|
};
|
|
25598
25834
|
|
|
25835
|
+
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
25836
|
+
import { join as join11 } from "node:path";
|
|
25837
|
+
|
|
25838
|
+
// src/agent-installation/workbuddy-managed-package.ts
|
|
25839
|
+
var WORKBUDDY_MANAGED_VERSION = "2.146.0";
|
|
25840
|
+
var WorkBuddyManagedPackage = class extends SriManagedNpmPackageDefinition {
|
|
25841
|
+
dependencyResolutionArguments = Object.freeze([
|
|
25842
|
+
"--before=2026-09-05T12:39:25.295Z"
|
|
25843
|
+
]);
|
|
25844
|
+
includeOptionalDependencies = true;
|
|
25845
|
+
verifyDependencyClosure = true;
|
|
25846
|
+
};
|
|
25847
|
+
var WORKBUDDY_MANAGED_PACKAGE = new WorkBuddyManagedPackage(
|
|
25848
|
+
"@tencent-ai/codebuddy-code",
|
|
25849
|
+
WORKBUDDY_MANAGED_VERSION,
|
|
25850
|
+
"codebuddy",
|
|
25851
|
+
"sha512-81V+8rzYJY8PezHZMs4VZN2nvoijrsRWIuCERTr6hELotcxaZaAcqbQQSbHJcN8eTlFE5TRPlzMI4oEkLCat4A==",
|
|
25852
|
+
"https://registry.npmjs.org/@tencent-ai/codebuddy-code/-/codebuddy-code-2.146.0.tgz"
|
|
25853
|
+
);
|
|
25854
|
+
|
|
25855
|
+
// src/agent-catalog/agents/workbuddy-agent.ts
|
|
25856
|
+
var WorkBuddyAgentSpecification = class extends DirectAcpAgentDefinition {
|
|
25857
|
+
adapterVersion = WORKBUDDY_MANAGED_VERSION;
|
|
25858
|
+
authenticationCommand = () => "codebuddy";
|
|
25859
|
+
agentExecutable = "codebuddy";
|
|
25860
|
+
id = "workbuddy";
|
|
25861
|
+
label = "WorkBuddy";
|
|
25862
|
+
constructor() {
|
|
25863
|
+
super(
|
|
25864
|
+
"MOBIUS_WORKBUDDY_PATH",
|
|
25865
|
+
["--acp"],
|
|
25866
|
+
[
|
|
25867
|
+
"agents",
|
|
25868
|
+
"workbuddy",
|
|
25869
|
+
WORKBUDDY_MANAGED_VERSION,
|
|
25870
|
+
"node_modules",
|
|
25871
|
+
"@tencent-ai",
|
|
25872
|
+
"codebuddy-code",
|
|
25873
|
+
"bin",
|
|
25874
|
+
"codebuddy"
|
|
25875
|
+
]
|
|
25876
|
+
);
|
|
25877
|
+
}
|
|
25878
|
+
createLaunchEnvironment = () => Promise.resolve(Object.freeze({ DISABLE_AUTOUPDATER: "1" }));
|
|
25879
|
+
resolveManagedAgent = async (stateDirectory, _platform, signal) => {
|
|
25880
|
+
signal.throwIfAborted();
|
|
25881
|
+
const executable = await validateManagedNpmPackage(
|
|
25882
|
+
join11(stateDirectory, "agents", this.id, WORKBUDDY_MANAGED_VERSION),
|
|
25883
|
+
WORKBUDDY_MANAGED_PACKAGE
|
|
25884
|
+
);
|
|
25885
|
+
signal.throwIfAborted();
|
|
25886
|
+
return executable;
|
|
25887
|
+
};
|
|
25888
|
+
verifyAcp = async (connection, initialized, defaultWorkspace, signal) => {
|
|
25889
|
+
const capabilities = initialized.agentCapabilities ?? {};
|
|
25890
|
+
if (capabilities.loadSession !== true || (initialized.authMethods ?? []).length === 0) {
|
|
25891
|
+
throw new AgentProbeError(
|
|
25892
|
+
"acp_incompatible",
|
|
25893
|
+
"WorkBuddy reported an unsupported ACP capability set"
|
|
25894
|
+
);
|
|
25895
|
+
}
|
|
25896
|
+
await verifySessionCreation(
|
|
25897
|
+
connection,
|
|
25898
|
+
capabilities,
|
|
25899
|
+
defaultWorkspace,
|
|
25900
|
+
signal,
|
|
25901
|
+
this.label
|
|
25902
|
+
);
|
|
25903
|
+
};
|
|
25904
|
+
};
|
|
25905
|
+
|
|
25599
25906
|
// src/agent-catalog/agents/supported-agent-specifications.ts
|
|
25600
25907
|
function supportedLocalAgentSpecifications() {
|
|
25601
25908
|
return Object.freeze([
|
|
@@ -25603,24 +25910,27 @@ function supportedLocalAgentSpecifications() {
|
|
|
25603
25910
|
new ClaudeCodeAgentSpecification(),
|
|
25604
25911
|
new PiAgentSpecification(),
|
|
25605
25912
|
new DeepSeekHarnessAgentSpecification(),
|
|
25606
|
-
new OpenCodeAgentSpecification()
|
|
25913
|
+
new OpenCodeAgentSpecification(),
|
|
25914
|
+
new CursorCliAgentSpecification(),
|
|
25915
|
+
new GrokBuildAgentSpecification(),
|
|
25916
|
+
new WorkBuddyAgentSpecification()
|
|
25607
25917
|
]);
|
|
25608
25918
|
}
|
|
25609
25919
|
|
|
25610
25920
|
// src/agent-catalog/acp-readiness-probe.ts
|
|
25611
25921
|
import { spawn as spawn3 } from "node:child_process";
|
|
25612
25922
|
import {
|
|
25613
|
-
methods as
|
|
25923
|
+
methods as methods5,
|
|
25614
25924
|
ndJsonStream as ndJsonStream2,
|
|
25615
25925
|
PROTOCOL_VERSION as PROTOCOL_VERSION2,
|
|
25616
25926
|
RequestError as RequestError2
|
|
25617
25927
|
} from "@agentclientprotocol/sdk";
|
|
25618
25928
|
|
|
25619
25929
|
// src/agent-catalog/executable-discovery.ts
|
|
25620
|
-
import { isAbsolute as
|
|
25930
|
+
import { isAbsolute as isAbsolute5, join as join13 } from "node:path";
|
|
25621
25931
|
|
|
25622
25932
|
// src/agent-installation/managed-adapter-installer.ts
|
|
25623
|
-
import { join as
|
|
25933
|
+
import { join as join12 } from "node:path";
|
|
25624
25934
|
var ManagedAdapterInstallError = class extends Error {
|
|
25625
25935
|
code;
|
|
25626
25936
|
constructor(code, message, options = {}) {
|
|
@@ -25682,7 +25992,7 @@ var ManagedAdapterInstaller = class {
|
|
|
25682
25992
|
this.#stateDirectory = options.stateDirectory;
|
|
25683
25993
|
}
|
|
25684
25994
|
install = async (specification, signal) => {
|
|
25685
|
-
const root =
|
|
25995
|
+
const root = join12(
|
|
25686
25996
|
this.#stateDirectory,
|
|
25687
25997
|
"adapters",
|
|
25688
25998
|
specification.id,
|
|
@@ -25721,7 +26031,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
25721
26031
|
let managed;
|
|
25722
26032
|
try {
|
|
25723
26033
|
managed = await validateManagedAdapter(
|
|
25724
|
-
|
|
26034
|
+
join13(
|
|
25725
26035
|
readStateDirectory(context.environment),
|
|
25726
26036
|
"adapters",
|
|
25727
26037
|
specification.id,
|
|
@@ -25737,7 +26047,7 @@ async function resolveManagedAdapterExecutable(specification, context) {
|
|
|
25737
26047
|
async function resolveSpecificationExecutables(executableName, overrideVariable, resolveManaged, context) {
|
|
25738
26048
|
const override = context.environment[overrideVariable];
|
|
25739
26049
|
if (override !== void 0) {
|
|
25740
|
-
if (override.length === 0 || !
|
|
26050
|
+
if (override.length === 0 || !isAbsolute5(override)) {
|
|
25741
26051
|
return [];
|
|
25742
26052
|
}
|
|
25743
26053
|
const executable = await resolveExecutablePath(override, context.platform);
|
|
@@ -25848,41 +26158,41 @@ var DiscoveryAcpHandler = class {
|
|
|
25848
26158
|
};
|
|
25849
26159
|
function readableAcpStream(input2) {
|
|
25850
26160
|
let byteLength = 0;
|
|
25851
|
-
let
|
|
26161
|
+
let open6 = true;
|
|
25852
26162
|
return new ReadableStream({
|
|
25853
26163
|
start(controller) {
|
|
25854
26164
|
input2.on("data", (chunk) => {
|
|
25855
|
-
if (!
|
|
26165
|
+
if (!open6) {
|
|
25856
26166
|
return;
|
|
25857
26167
|
}
|
|
25858
26168
|
if (!(chunk instanceof Uint8Array)) {
|
|
25859
|
-
|
|
26169
|
+
open6 = false;
|
|
25860
26170
|
controller.error(new Error("ACP adapter produced invalid output"));
|
|
25861
26171
|
return;
|
|
25862
26172
|
}
|
|
25863
26173
|
byteLength += chunk.byteLength;
|
|
25864
26174
|
if (byteLength > ACP_OUTPUT_LIMIT_BYTES) {
|
|
25865
|
-
|
|
26175
|
+
open6 = false;
|
|
25866
26176
|
controller.error(new Error("ACP adapter output limit exceeded"));
|
|
25867
26177
|
return;
|
|
25868
26178
|
}
|
|
25869
26179
|
controller.enqueue(new Uint8Array(chunk));
|
|
25870
26180
|
});
|
|
25871
26181
|
input2.once("end", () => {
|
|
25872
|
-
if (
|
|
25873
|
-
|
|
26182
|
+
if (open6) {
|
|
26183
|
+
open6 = false;
|
|
25874
26184
|
controller.close();
|
|
25875
26185
|
}
|
|
25876
26186
|
});
|
|
25877
26187
|
input2.once("error", (error61) => {
|
|
25878
|
-
if (
|
|
25879
|
-
|
|
26188
|
+
if (open6) {
|
|
26189
|
+
open6 = false;
|
|
25880
26190
|
controller.error(error61);
|
|
25881
26191
|
}
|
|
25882
26192
|
});
|
|
25883
26193
|
},
|
|
25884
26194
|
cancel() {
|
|
25885
|
-
|
|
26195
|
+
open6 = false;
|
|
25886
26196
|
}
|
|
25887
26197
|
});
|
|
25888
26198
|
}
|
|
@@ -25951,7 +26261,7 @@ async function probeAcpReadiness(specification, agent, environment, defaultWorks
|
|
|
25951
26261
|
try {
|
|
25952
26262
|
const initialized = await Promise.race([
|
|
25953
26263
|
connection.agent.request(
|
|
25954
|
-
|
|
26264
|
+
methods5.agent.initialize,
|
|
25955
26265
|
{
|
|
25956
26266
|
clientCapabilities: {},
|
|
25957
26267
|
clientInfo: { name: "mobius", version: "0.0.3" },
|
|
@@ -26162,16 +26472,8 @@ async function discoverLocalAgentInventory(options) {
|
|
|
26162
26472
|
async (specification) => await discoverAgent(specification, options)
|
|
26163
26473
|
)
|
|
26164
26474
|
);
|
|
26165
|
-
let grantedAgents = /* @__PURE__ */ new Set();
|
|
26166
|
-
try {
|
|
26167
|
-
grantedAgents = await readGrantedAgents(
|
|
26168
|
-
readStateDirectory(options.environment)
|
|
26169
|
-
);
|
|
26170
|
-
} catch {
|
|
26171
|
-
}
|
|
26172
26475
|
return new LocalAgentInventory(
|
|
26173
26476
|
discoveries,
|
|
26174
|
-
grantedAgents,
|
|
26175
26477
|
options.platform,
|
|
26176
26478
|
options.architecture
|
|
26177
26479
|
);
|
|
@@ -26202,7 +26504,7 @@ var PairingClientError = class extends Error {
|
|
|
26202
26504
|
this.name = "PairingClientError";
|
|
26203
26505
|
}
|
|
26204
26506
|
};
|
|
26205
|
-
function
|
|
26507
|
+
function isRecord6(value) {
|
|
26206
26508
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
26207
26509
|
}
|
|
26208
26510
|
function hasExactKeys(value, expectedKeys) {
|
|
@@ -26316,7 +26618,7 @@ async function resolveDefaultWorkspace(path2) {
|
|
|
26316
26618
|
const requestedWorkspace = resolve3(path2);
|
|
26317
26619
|
try {
|
|
26318
26620
|
await mkdir3(requestedWorkspace, { recursive: true, mode: 448 });
|
|
26319
|
-
const defaultWorkspace = await
|
|
26621
|
+
const defaultWorkspace = await realpath6(requestedWorkspace);
|
|
26320
26622
|
const metadata = await stat5(defaultWorkspace);
|
|
26321
26623
|
if (!metadata.isDirectory()) {
|
|
26322
26624
|
throw new PairingClientError(
|
|
@@ -26355,9 +26657,9 @@ async function readJsonResponse(response) {
|
|
|
26355
26657
|
}
|
|
26356
26658
|
}
|
|
26357
26659
|
function readRelayError(value) {
|
|
26358
|
-
if (
|
|
26660
|
+
if (isRecord6(value)) {
|
|
26359
26661
|
const error61 = value["error"];
|
|
26360
|
-
if (
|
|
26662
|
+
if (isRecord6(error61)) {
|
|
26361
26663
|
const code = error61["code"];
|
|
26362
26664
|
const message = error61["message"];
|
|
26363
26665
|
if (typeof code === "string" && typeof message === "string") {
|
|
@@ -26371,7 +26673,7 @@ function readRelayError(value) {
|
|
|
26371
26673
|
);
|
|
26372
26674
|
}
|
|
26373
26675
|
function decodeClaimResponse(value) {
|
|
26374
|
-
if (!
|
|
26676
|
+
if (!isRecord6(value) || !hasExactKeys(value, CLAIM_RESPONSE_KEYS)) {
|
|
26375
26677
|
throw new PairingClientError(
|
|
26376
26678
|
"invalid_relay_response",
|
|
26377
26679
|
"The relay returned an invalid pairing response"
|
|
@@ -26401,8 +26703,7 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
26401
26703
|
agents,
|
|
26402
26704
|
installableAgents: installableAgents.map((agent) => ({
|
|
26403
26705
|
id: agent.id,
|
|
26404
|
-
label: agent.label
|
|
26405
|
-
requiresLocalApproval: agent.requiresLocalApproval
|
|
26706
|
+
label: agent.label
|
|
26406
26707
|
})),
|
|
26407
26708
|
machineName: hostname3(),
|
|
26408
26709
|
pairingCode: options.code,
|
|
@@ -26430,10 +26731,10 @@ async function claimPairing(options, defaultWorkspace, localAgents, installableA
|
|
|
26430
26731
|
return decodeClaimResponse(value);
|
|
26431
26732
|
}
|
|
26432
26733
|
async function persistConnection(channelId, relayOrigin, daemonToken, defaultWorkspace) {
|
|
26433
|
-
const connectionsDirectory =
|
|
26734
|
+
const connectionsDirectory = join14(readStateDirectory(), "connections");
|
|
26434
26735
|
await mkdir3(connectionsDirectory, { mode: 448, recursive: true });
|
|
26435
|
-
const connectionPath =
|
|
26436
|
-
const temporaryPath =
|
|
26736
|
+
const connectionPath = join14(connectionsDirectory, `${channelId}.json`);
|
|
26737
|
+
const temporaryPath = join14(
|
|
26437
26738
|
connectionsDirectory,
|
|
26438
26739
|
`.${channelId}.${randomUUID()}.tmp`
|
|
26439
26740
|
);
|
|
@@ -26456,7 +26757,7 @@ async function persistConnection(channelId, relayOrigin, daemonToken, defaultWor
|
|
|
26456
26757
|
return connectionPath;
|
|
26457
26758
|
}
|
|
26458
26759
|
function decodeSavedConnection(value, expectedChannelId) {
|
|
26459
|
-
if (!
|
|
26760
|
+
if (!isRecord6(value) || !hasExactKeys(value, SAVED_CONNECTION_KEYS)) {
|
|
26460
26761
|
throw new PairingClientError(
|
|
26461
26762
|
"invalid_connection",
|
|
26462
26763
|
"The saved connection is invalid"
|
|
@@ -26480,13 +26781,13 @@ function decodeSavedConnection(value, expectedChannelId) {
|
|
|
26480
26781
|
};
|
|
26481
26782
|
}
|
|
26482
26783
|
async function readSavedConnection(channelId) {
|
|
26483
|
-
const connectionPath =
|
|
26784
|
+
const connectionPath = join14(
|
|
26484
26785
|
readStateDirectory(),
|
|
26485
26786
|
"connections",
|
|
26486
26787
|
`${channelId}.json`
|
|
26487
26788
|
);
|
|
26488
26789
|
let encoded = "";
|
|
26489
|
-
const handle = await
|
|
26790
|
+
const handle = await open5(connectionPath, "r");
|
|
26490
26791
|
try {
|
|
26491
26792
|
const metadata = await handle.stat();
|
|
26492
26793
|
if (!metadata.isFile() || metadata.size > MAX_CONNECTION_FILE_LENGTH) {
|
|
@@ -26535,7 +26836,7 @@ function buildPairedDaemon(connection, connectionPath, inventory) {
|
|
|
26535
26836
|
);
|
|
26536
26837
|
relayUrl.protocol = relayUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
26537
26838
|
relayUrl.searchParams.set("token", connection.daemonToken);
|
|
26538
|
-
const auditDatabasePath =
|
|
26839
|
+
const auditDatabasePath = join14(
|
|
26539
26840
|
readStateDirectory(),
|
|
26540
26841
|
"audit",
|
|
26541
26842
|
`${connection.channelId}.sqlite`
|
|
@@ -26594,7 +26895,7 @@ async function pairLocalMachine(arguments_, signal = new AbortController().signa
|
|
|
26594
26895
|
}
|
|
26595
26896
|
async function resumeLocalMachine(arguments_, signal = new AbortController().signal) {
|
|
26596
26897
|
const channelId = parseChannelArgument(arguments_);
|
|
26597
|
-
const connectionPath =
|
|
26898
|
+
const connectionPath = join14(
|
|
26598
26899
|
readStateDirectory(),
|
|
26599
26900
|
"connections",
|
|
26600
26901
|
`${channelId}.json`
|
|
@@ -26649,8 +26950,7 @@ async function publishAgentCatalog(config2, signal) {
|
|
|
26649
26950
|
})),
|
|
26650
26951
|
installableAgents: catalog.installableAgents.map((agent) => ({
|
|
26651
26952
|
id: agent.id,
|
|
26652
|
-
label: agent.label
|
|
26653
|
-
requiresLocalApproval: agent.requiresLocalApproval
|
|
26953
|
+
label: agent.label
|
|
26654
26954
|
}))
|
|
26655
26955
|
}),
|
|
26656
26956
|
dispatcher: environmentProxyDispatcher,
|
|
@@ -26691,12 +26991,6 @@ var RequestedInstallation = class extends AgentInstallation {
|
|
|
26691
26991
|
super(requestId, agentId);
|
|
26692
26992
|
}
|
|
26693
26993
|
};
|
|
26694
|
-
var AwaitingLocalApproval = class extends AgentInstallation {
|
|
26695
|
-
status = "awaiting_local_approval";
|
|
26696
|
-
constructor(requestId, agentId) {
|
|
26697
|
-
super(requestId, agentId);
|
|
26698
|
-
}
|
|
26699
|
-
};
|
|
26700
26994
|
var RunningInstallation = class extends AgentInstallation {
|
|
26701
26995
|
stage;
|
|
26702
26996
|
status = "running";
|
|
@@ -26751,9 +27045,9 @@ var InstallationJob = class {
|
|
|
26751
27045
|
this.state = new RequestedInstallation(requestId, agentId);
|
|
26752
27046
|
}
|
|
26753
27047
|
};
|
|
26754
|
-
function
|
|
27048
|
+
function authorizedSpecificationFor(specifications, agentId) {
|
|
26755
27049
|
for (const specification of specifications) {
|
|
26756
|
-
if (specification.id === agentId) {
|
|
27050
|
+
if (specification.id === agentId && specification.supportsInstallation(process.platform, process.arch)) {
|
|
26757
27051
|
return specification;
|
|
26758
27052
|
}
|
|
26759
27053
|
}
|
|
@@ -26772,14 +27066,12 @@ function executionFailure(error61) {
|
|
|
26772
27066
|
var AgentInstallationManager = class {
|
|
26773
27067
|
#activeAgents = /* @__PURE__ */ new Map();
|
|
26774
27068
|
#audit;
|
|
26775
|
-
#authorizer;
|
|
26776
27069
|
#executor;
|
|
26777
27070
|
#jobs = /* @__PURE__ */ new Map();
|
|
26778
27071
|
#observer;
|
|
26779
27072
|
#specifications;
|
|
26780
|
-
constructor(specifications,
|
|
27073
|
+
constructor(specifications, executor, observer, audit = new NullInstallationAudit()) {
|
|
26781
27074
|
this.#audit = audit;
|
|
26782
|
-
this.#authorizer = authorizer;
|
|
26783
27075
|
this.#executor = executor;
|
|
26784
27076
|
this.#observer = observer;
|
|
26785
27077
|
this.#specifications = Object.freeze([...specifications]);
|
|
@@ -26810,7 +27102,7 @@ var AgentInstallationManager = class {
|
|
|
26810
27102
|
command.requestId,
|
|
26811
27103
|
command.agentId
|
|
26812
27104
|
);
|
|
26813
|
-
const specification =
|
|
27105
|
+
const specification = authorizedSpecificationFor(
|
|
26814
27106
|
this.#specifications,
|
|
26815
27107
|
command.agentId
|
|
26816
27108
|
);
|
|
@@ -26913,45 +27205,14 @@ var AgentInstallationManager = class {
|
|
|
26913
27205
|
}, INSTALLATION_DEADLINE_MILLISECONDS);
|
|
26914
27206
|
const signal = job.controller.signal;
|
|
26915
27207
|
try {
|
|
26916
|
-
await this.#transition(
|
|
26917
|
-
job,
|
|
26918
|
-
new AwaitingLocalApproval(job.requestId, job.agentId)
|
|
26919
|
-
);
|
|
26920
|
-
this.#audit.record(
|
|
26921
|
-
"agent_installation_awaiting_approval",
|
|
26922
|
-
job.requestId,
|
|
26923
|
-
job.agentId
|
|
26924
|
-
);
|
|
26925
|
-
const approved = await this.#authorizer.authorize(
|
|
26926
|
-
specification.id,
|
|
26927
|
-
specification.label,
|
|
26928
|
-
job.requestId,
|
|
26929
|
-
signal
|
|
26930
|
-
);
|
|
26931
27208
|
signal.throwIfAborted();
|
|
26932
|
-
if (!approved) {
|
|
26933
|
-
const denied = new FailedInstallation(
|
|
26934
|
-
job.requestId,
|
|
26935
|
-
job.agentId,
|
|
26936
|
-
"installation_not_authorized",
|
|
26937
|
-
"Installation was not approved on the local machine"
|
|
26938
|
-
);
|
|
26939
|
-
await this.#transition(job, denied);
|
|
26940
|
-
this.#audit.record(
|
|
26941
|
-
"agent_installation_denied",
|
|
26942
|
-
job.requestId,
|
|
26943
|
-
job.agentId
|
|
26944
|
-
);
|
|
26945
|
-
job.completion.resolve(denied);
|
|
26946
|
-
return;
|
|
26947
|
-
}
|
|
26948
27209
|
this.#audit.record(
|
|
26949
27210
|
"agent_installation_authorized",
|
|
26950
27211
|
job.requestId,
|
|
26951
|
-
|
|
27212
|
+
specification.id
|
|
26952
27213
|
);
|
|
26953
27214
|
await this.#executor.execute(
|
|
26954
|
-
|
|
27215
|
+
specification.id,
|
|
26955
27216
|
job.requestId,
|
|
26956
27217
|
async (stage) => {
|
|
26957
27218
|
signal.throwIfAborted();
|
|
@@ -27221,12 +27482,10 @@ import { realpathSync as realpathSync2, statSync as statSync2 } from "node:fs";
|
|
|
27221
27482
|
import { resolve as resolve4 } from "node:path";
|
|
27222
27483
|
|
|
27223
27484
|
// src/agent-installation/fixed-agent-install-recipes.ts
|
|
27224
|
-
import { mkdir as
|
|
27225
|
-
import { join as
|
|
27226
|
-
|
|
27227
|
-
|
|
27228
|
-
var AGENT_INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
27229
|
-
var MINIMAL_PATH2 = "/usr/bin:/bin";
|
|
27485
|
+
import { mkdir as mkdir5, mkdtemp as mkdtemp3, rm as rm3 } from "node:fs/promises";
|
|
27486
|
+
import { join as join17 } from "node:path";
|
|
27487
|
+
|
|
27488
|
+
// src/agent-installation/fixed-agent-install-recipe.ts
|
|
27230
27489
|
var FixedAgentInstallRecipe = class {
|
|
27231
27490
|
assertSupportedPlatform = () => {
|
|
27232
27491
|
if (process.platform !== "darwin" && process.platform !== "linux" || process.arch !== "arm64" && process.arch !== "x64") {
|
|
@@ -27247,28 +27506,243 @@ var FixedAgentInstallRecipe = class {
|
|
|
27247
27506
|
return executable;
|
|
27248
27507
|
};
|
|
27249
27508
|
};
|
|
27509
|
+
|
|
27510
|
+
// src/agent-installation/grok-build-install-recipe.ts
|
|
27511
|
+
import { mkdir as mkdir4, realpath as realpath7, stat as stat6 } from "node:fs/promises";
|
|
27512
|
+
import { delimiter as delimiter2, dirname as dirname5, isAbsolute as isAbsolute6, join as join15, relative as relative4, sep as sep4 } from "node:path";
|
|
27513
|
+
var INSTALL_TIMEOUT_MILLISECONDS2 = 5 * 60 * 1e3;
|
|
27514
|
+
function isContainedPath4(root, candidate) {
|
|
27515
|
+
const difference = relative4(root, candidate);
|
|
27516
|
+
return difference.length > 0 && difference !== ".." && !difference.startsWith(`..${sep4}`) && !isAbsolute6(difference);
|
|
27517
|
+
}
|
|
27518
|
+
async function resolveLifecycleScript(packageRoot) {
|
|
27519
|
+
try {
|
|
27520
|
+
const canonicalPackageRoot = await realpath7(packageRoot);
|
|
27521
|
+
const script = await realpath7(
|
|
27522
|
+
join15(canonicalPackageRoot, "bin", "postinstall.js")
|
|
27523
|
+
);
|
|
27524
|
+
const metadata = await stat6(script);
|
|
27525
|
+
if (!metadata.isFile() || !isContainedPath4(canonicalPackageRoot, script)) {
|
|
27526
|
+
throw new Error("Invalid Grok Build lifecycle script");
|
|
27527
|
+
}
|
|
27528
|
+
return script;
|
|
27529
|
+
} catch (error61) {
|
|
27530
|
+
throw new InstallationManagerError(
|
|
27531
|
+
"agent_verification_failed",
|
|
27532
|
+
"The managed Grok Build lifecycle script is invalid",
|
|
27533
|
+
{ cause: error61 }
|
|
27534
|
+
);
|
|
27535
|
+
}
|
|
27536
|
+
}
|
|
27537
|
+
var GrokBuildInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
27538
|
+
#npmInstaller;
|
|
27539
|
+
id = "grok-build";
|
|
27540
|
+
label = "Grok Build";
|
|
27541
|
+
releaseChannel = GROK_BUILD_MANAGED_VERSION;
|
|
27542
|
+
constructor(npmInstaller = new ManagedNpmPackageInstaller()) {
|
|
27543
|
+
super();
|
|
27544
|
+
this.#npmInstaller = npmInstaller;
|
|
27545
|
+
}
|
|
27546
|
+
install = async (options) => {
|
|
27547
|
+
this.assertSupportedPlatform();
|
|
27548
|
+
const definition = grokBuildManagedPackage(process.platform, process.arch);
|
|
27549
|
+
const versionRoot = join15(
|
|
27550
|
+
options.stateDirectory,
|
|
27551
|
+
"agents",
|
|
27552
|
+
this.id,
|
|
27553
|
+
GROK_BUILD_MANAGED_VERSION
|
|
27554
|
+
);
|
|
27555
|
+
const packageRoot = join15(versionRoot, "package");
|
|
27556
|
+
const managedHome = join15(versionRoot, "home");
|
|
27557
|
+
try {
|
|
27558
|
+
await mkdir4(managedHome, { mode: 448, recursive: true });
|
|
27559
|
+
const canonicalHome = await realpath7(managedHome);
|
|
27560
|
+
await options.report("downloading");
|
|
27561
|
+
await options.report("verifying");
|
|
27562
|
+
await options.report("installing_agent");
|
|
27563
|
+
await this.#npmInstaller.install(
|
|
27564
|
+
packageRoot,
|
|
27565
|
+
definition,
|
|
27566
|
+
options.environment,
|
|
27567
|
+
options.signal
|
|
27568
|
+
);
|
|
27569
|
+
options.audit.record(
|
|
27570
|
+
"agent_npm_package_verified",
|
|
27571
|
+
options.requestId,
|
|
27572
|
+
this.id,
|
|
27573
|
+
{
|
|
27574
|
+
integrity: definition.integrity,
|
|
27575
|
+
package: definition.packageName,
|
|
27576
|
+
version: definition.version
|
|
27577
|
+
}
|
|
27578
|
+
);
|
|
27579
|
+
const script = await resolveLifecycleScript(
|
|
27580
|
+
join15(packageRoot, "node_modules", "@xai-official", "grok")
|
|
27581
|
+
);
|
|
27582
|
+
await runBoundedProcess({
|
|
27583
|
+
arguments: [script],
|
|
27584
|
+
command: process.execPath,
|
|
27585
|
+
cwd: dirname5(script),
|
|
27586
|
+
environment: {
|
|
27587
|
+
GROK_HOME: canonicalHome,
|
|
27588
|
+
GROK_INSTALL_COMPLETIONS: "0",
|
|
27589
|
+
GROK_NPM_REGISTRY: "https://registry.npmjs.org/",
|
|
27590
|
+
HOME: canonicalHome,
|
|
27591
|
+
PATH: `${dirname5(process.execPath)}${delimiter2}/usr/bin${delimiter2}/bin`
|
|
27592
|
+
},
|
|
27593
|
+
outputLimitBytes: 64 * 1024,
|
|
27594
|
+
signal: options.signal,
|
|
27595
|
+
timeoutMilliseconds: INSTALL_TIMEOUT_MILLISECONDS2
|
|
27596
|
+
});
|
|
27597
|
+
options.audit.record(
|
|
27598
|
+
"agent_lifecycle_step_completed",
|
|
27599
|
+
options.requestId,
|
|
27600
|
+
this.id,
|
|
27601
|
+
{
|
|
27602
|
+
lifecycle: "postinstall",
|
|
27603
|
+
package: definition.packageName,
|
|
27604
|
+
version: definition.version
|
|
27605
|
+
}
|
|
27606
|
+
);
|
|
27607
|
+
return await this.requireInstalledExecutable(
|
|
27608
|
+
join15(canonicalHome, "bin", "grok")
|
|
27609
|
+
);
|
|
27610
|
+
} catch (error61) {
|
|
27611
|
+
if (options.signal.aborted) {
|
|
27612
|
+
options.signal.throwIfAborted();
|
|
27613
|
+
}
|
|
27614
|
+
if (error61 instanceof ManagedNpmPackageError) {
|
|
27615
|
+
if (error61.code === "managed_package_verification_failed") {
|
|
27616
|
+
throw new InstallationManagerError(
|
|
27617
|
+
"agent_verification_failed",
|
|
27618
|
+
"The managed Grok Build packages did not match their pinned artifacts",
|
|
27619
|
+
{ cause: error61 }
|
|
27620
|
+
);
|
|
27621
|
+
}
|
|
27622
|
+
if (error61.code === "managed_package_publish_failed") {
|
|
27623
|
+
throw new InstallationManagerError(
|
|
27624
|
+
"agent_publish_failed",
|
|
27625
|
+
"The managed Grok Build package could not be published",
|
|
27626
|
+
{ cause: error61 }
|
|
27627
|
+
);
|
|
27628
|
+
}
|
|
27629
|
+
throw new InstallationManagerError(error61.code, error61.message, {
|
|
27630
|
+
cause: error61
|
|
27631
|
+
});
|
|
27632
|
+
}
|
|
27633
|
+
if (error61 instanceof InstallationManagerError) {
|
|
27634
|
+
throw error61;
|
|
27635
|
+
}
|
|
27636
|
+
throw new InstallationManagerError(
|
|
27637
|
+
"agent_install_failed",
|
|
27638
|
+
"The fixed Grok Build installation recipe failed",
|
|
27639
|
+
{ cause: error61 }
|
|
27640
|
+
);
|
|
27641
|
+
}
|
|
27642
|
+
};
|
|
27643
|
+
};
|
|
27644
|
+
|
|
27645
|
+
// src/agent-installation/workbuddy-install-recipe.ts
|
|
27646
|
+
import { join as join16 } from "node:path";
|
|
27647
|
+
var WorkBuddyInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
27648
|
+
#npmInstaller;
|
|
27649
|
+
id = "workbuddy";
|
|
27650
|
+
label = "WorkBuddy";
|
|
27651
|
+
releaseChannel = WORKBUDDY_MANAGED_VERSION;
|
|
27652
|
+
constructor(npmInstaller = new ManagedNpmPackageInstaller()) {
|
|
27653
|
+
super();
|
|
27654
|
+
this.#npmInstaller = npmInstaller;
|
|
27655
|
+
}
|
|
27656
|
+
install = async (options) => {
|
|
27657
|
+
this.assertSupportedPlatform();
|
|
27658
|
+
try {
|
|
27659
|
+
await options.report("downloading");
|
|
27660
|
+
await options.report("verifying");
|
|
27661
|
+
await options.report("installing_agent");
|
|
27662
|
+
const executable = await this.#npmInstaller.install(
|
|
27663
|
+
join16(
|
|
27664
|
+
options.stateDirectory,
|
|
27665
|
+
"agents",
|
|
27666
|
+
this.id,
|
|
27667
|
+
WORKBUDDY_MANAGED_VERSION
|
|
27668
|
+
),
|
|
27669
|
+
WORKBUDDY_MANAGED_PACKAGE,
|
|
27670
|
+
options.environment,
|
|
27671
|
+
options.signal
|
|
27672
|
+
);
|
|
27673
|
+
options.audit.record(
|
|
27674
|
+
"agent_npm_package_verified",
|
|
27675
|
+
options.requestId,
|
|
27676
|
+
this.id,
|
|
27677
|
+
{
|
|
27678
|
+
integrity: WORKBUDDY_MANAGED_PACKAGE.integrity,
|
|
27679
|
+
package: WORKBUDDY_MANAGED_PACKAGE.packageName,
|
|
27680
|
+
version: WORKBUDDY_MANAGED_PACKAGE.version
|
|
27681
|
+
}
|
|
27682
|
+
);
|
|
27683
|
+
return executable;
|
|
27684
|
+
} catch (error61) {
|
|
27685
|
+
if (options.signal.aborted) {
|
|
27686
|
+
options.signal.throwIfAborted();
|
|
27687
|
+
}
|
|
27688
|
+
if (error61 instanceof ManagedNpmPackageError) {
|
|
27689
|
+
if (error61.code === "managed_package_verification_failed") {
|
|
27690
|
+
throw new InstallationManagerError(
|
|
27691
|
+
"agent_verification_failed",
|
|
27692
|
+
"The managed WorkBuddy package did not match its pinned artifact",
|
|
27693
|
+
{ cause: error61 }
|
|
27694
|
+
);
|
|
27695
|
+
}
|
|
27696
|
+
if (error61.code === "managed_package_publish_failed") {
|
|
27697
|
+
throw new InstallationManagerError(
|
|
27698
|
+
"agent_publish_failed",
|
|
27699
|
+
"The managed WorkBuddy package could not be published",
|
|
27700
|
+
{ cause: error61 }
|
|
27701
|
+
);
|
|
27702
|
+
}
|
|
27703
|
+
throw new InstallationManagerError(error61.code, error61.message, {
|
|
27704
|
+
cause: error61
|
|
27705
|
+
});
|
|
27706
|
+
}
|
|
27707
|
+
if (error61 instanceof InstallationManagerError) {
|
|
27708
|
+
throw error61;
|
|
27709
|
+
}
|
|
27710
|
+
throw new InstallationManagerError(
|
|
27711
|
+
"agent_install_failed",
|
|
27712
|
+
"The fixed WorkBuddy installation recipe failed",
|
|
27713
|
+
{ cause: error61 }
|
|
27714
|
+
);
|
|
27715
|
+
}
|
|
27716
|
+
};
|
|
27717
|
+
};
|
|
27718
|
+
|
|
27719
|
+
// src/agent-installation/fixed-agent-install-recipes.ts
|
|
27720
|
+
var INSTALLER_DOWNLOAD_LIMIT_BYTES = 1024 * 1024;
|
|
27721
|
+
var INSTALLER_DOWNLOAD_TIMEOUT_MILLISECONDS = 6e4;
|
|
27722
|
+
var AGENT_INSTALL_TIMEOUT_MILLISECONDS = 5 * 60 * 1e3;
|
|
27723
|
+
var MINIMAL_PATH2 = "/usr/bin:/bin";
|
|
27250
27724
|
var CodexInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
27251
27725
|
id = "codex";
|
|
27252
27726
|
label = "Codex";
|
|
27253
27727
|
releaseChannel = "latest";
|
|
27254
27728
|
install = async (options) => {
|
|
27255
27729
|
this.assertSupportedPlatform();
|
|
27256
|
-
const root =
|
|
27257
|
-
const temporaryRoot =
|
|
27730
|
+
const root = join17(options.stateDirectory, "agents", this.id);
|
|
27731
|
+
const temporaryRoot = join17(options.stateDirectory, "temporary");
|
|
27258
27732
|
await Promise.all([
|
|
27259
|
-
|
|
27260
|
-
|
|
27733
|
+
mkdir5(root, { mode: 448, recursive: true }),
|
|
27734
|
+
mkdir5(temporaryRoot, { mode: 448, recursive: true })
|
|
27261
27735
|
]);
|
|
27262
27736
|
const temporaryDirectory = await mkdtemp3(
|
|
27263
|
-
|
|
27737
|
+
join17(temporaryRoot, ".codex-install-")
|
|
27264
27738
|
);
|
|
27265
|
-
const installerPath =
|
|
27266
|
-
const installDirectory =
|
|
27267
|
-
const codexHome =
|
|
27739
|
+
const installerPath = join17(temporaryDirectory, "install.sh");
|
|
27740
|
+
const installDirectory = join17(root, "bin");
|
|
27741
|
+
const codexHome = join17(root, "home");
|
|
27268
27742
|
try {
|
|
27269
27743
|
await Promise.all([
|
|
27270
|
-
|
|
27271
|
-
|
|
27744
|
+
mkdir5(installDirectory, { mode: 448, recursive: true }),
|
|
27745
|
+
mkdir5(codexHome, { mode: 448, recursive: true })
|
|
27272
27746
|
]);
|
|
27273
27747
|
await options.report("downloading");
|
|
27274
27748
|
const download = await downloadVerifiedFile({
|
|
@@ -27308,7 +27782,7 @@ var CodexInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27308
27782
|
timeoutMilliseconds: AGENT_INSTALL_TIMEOUT_MILLISECONDS
|
|
27309
27783
|
});
|
|
27310
27784
|
return await this.requireInstalledExecutable(
|
|
27311
|
-
|
|
27785
|
+
join17(installDirectory, "codex")
|
|
27312
27786
|
);
|
|
27313
27787
|
} catch (error61) {
|
|
27314
27788
|
if (options.signal.aborted) {
|
|
@@ -27332,17 +27806,17 @@ var ClaudeCodeInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27332
27806
|
releaseChannel = "stable";
|
|
27333
27807
|
install = async (options) => {
|
|
27334
27808
|
this.assertSupportedPlatform();
|
|
27335
|
-
const root =
|
|
27336
|
-
const managedHome =
|
|
27337
|
-
const temporaryRoot =
|
|
27809
|
+
const root = join17(options.stateDirectory, "agents", this.id);
|
|
27810
|
+
const managedHome = join17(root, "home");
|
|
27811
|
+
const temporaryRoot = join17(options.stateDirectory, "temporary");
|
|
27338
27812
|
await Promise.all([
|
|
27339
|
-
|
|
27340
|
-
|
|
27813
|
+
mkdir5(managedHome, { mode: 448, recursive: true }),
|
|
27814
|
+
mkdir5(temporaryRoot, { mode: 448, recursive: true })
|
|
27341
27815
|
]);
|
|
27342
27816
|
const temporaryDirectory = await mkdtemp3(
|
|
27343
|
-
|
|
27817
|
+
join17(temporaryRoot, ".claude-install-")
|
|
27344
27818
|
);
|
|
27345
|
-
const installerPath =
|
|
27819
|
+
const installerPath = join17(temporaryDirectory, "install.sh");
|
|
27346
27820
|
try {
|
|
27347
27821
|
await options.report("downloading");
|
|
27348
27822
|
const download = await downloadVerifiedFile({
|
|
@@ -27379,7 +27853,7 @@ var ClaudeCodeInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27379
27853
|
timeoutMilliseconds: AGENT_INSTALL_TIMEOUT_MILLISECONDS
|
|
27380
27854
|
});
|
|
27381
27855
|
return await this.requireInstalledExecutable(
|
|
27382
|
-
|
|
27856
|
+
join17(managedHome, ".local", "bin", "claude")
|
|
27383
27857
|
);
|
|
27384
27858
|
} catch (error61) {
|
|
27385
27859
|
if (options.signal.aborted) {
|
|
@@ -27413,7 +27887,7 @@ var PiInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27413
27887
|
await options.report("verifying");
|
|
27414
27888
|
await options.report("installing_agent");
|
|
27415
27889
|
const executable = await this.#npmInstaller.install(
|
|
27416
|
-
|
|
27890
|
+
join17(
|
|
27417
27891
|
options.stateDirectory,
|
|
27418
27892
|
"agents",
|
|
27419
27893
|
this.id,
|
|
@@ -27480,18 +27954,18 @@ var DeepSeekHarnessInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27480
27954
|
install = async (options) => {
|
|
27481
27955
|
this.assertSupportedPlatform();
|
|
27482
27956
|
try {
|
|
27483
|
-
const managedHome =
|
|
27957
|
+
const managedHome = join17(
|
|
27484
27958
|
options.stateDirectory,
|
|
27485
27959
|
"agents",
|
|
27486
27960
|
this.id,
|
|
27487
27961
|
"home"
|
|
27488
27962
|
);
|
|
27489
|
-
await
|
|
27963
|
+
await mkdir5(managedHome, { mode: 448, recursive: true });
|
|
27490
27964
|
await options.report("downloading");
|
|
27491
27965
|
await options.report("verifying");
|
|
27492
27966
|
await options.report("installing_agent");
|
|
27493
27967
|
const executable = await this.#npmInstaller.install(
|
|
27494
|
-
|
|
27968
|
+
join17(
|
|
27495
27969
|
options.stateDirectory,
|
|
27496
27970
|
"agents",
|
|
27497
27971
|
this.id,
|
|
@@ -27563,7 +28037,7 @@ var OpenCodeInstallRecipe = class extends FixedAgentInstallRecipe {
|
|
|
27563
28037
|
await options.report("verifying");
|
|
27564
28038
|
await options.report("installing_agent");
|
|
27565
28039
|
const executable = await this.#archiveInstaller.install(
|
|
27566
|
-
|
|
28040
|
+
join17(
|
|
27567
28041
|
options.stateDirectory,
|
|
27568
28042
|
"agents",
|
|
27569
28043
|
this.id,
|
|
@@ -27622,7 +28096,9 @@ function fixedAgentInstallRecipes() {
|
|
|
27622
28096
|
new ClaudeCodeInstallRecipe(),
|
|
27623
28097
|
new PiInstallRecipe(),
|
|
27624
28098
|
new DeepSeekHarnessInstallRecipe(),
|
|
27625
|
-
new OpenCodeInstallRecipe()
|
|
28099
|
+
new OpenCodeInstallRecipe(),
|
|
28100
|
+
new GrokBuildInstallRecipe(),
|
|
28101
|
+
new WorkBuddyInstallRecipe()
|
|
27626
28102
|
]);
|
|
27627
28103
|
}
|
|
27628
28104
|
|
|
@@ -27863,51 +28339,16 @@ var FixedInstallationExecutor = class {
|
|
|
27863
28339
|
};
|
|
27864
28340
|
};
|
|
27865
28341
|
|
|
27866
|
-
// src/agent-installation/local-installation-authorizer.ts
|
|
27867
|
-
import { createInterface } from "node:readline/promises";
|
|
27868
|
-
var ConsoleInstallationAuthorizer = class {
|
|
27869
|
-
#stateDirectory;
|
|
27870
|
-
constructor(stateDirectory) {
|
|
27871
|
-
this.#stateDirectory = stateDirectory;
|
|
27872
|
-
}
|
|
27873
|
-
authorize = async (agentId, label, requestId, signal) => {
|
|
27874
|
-
signal.throwIfAborted();
|
|
27875
|
-
const grants = await readGrantedAgents(this.#stateDirectory);
|
|
27876
|
-
signal.throwIfAborted();
|
|
27877
|
-
if (grants.has(agentId)) {
|
|
27878
|
-
return true;
|
|
27879
|
-
}
|
|
27880
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
27881
|
-
return false;
|
|
27882
|
-
}
|
|
27883
|
-
const prompt = createInterface({
|
|
27884
|
-
input: process.stdin,
|
|
27885
|
-
output: process.stdout
|
|
27886
|
-
});
|
|
27887
|
-
try {
|
|
27888
|
-
const answer = await prompt.question(
|
|
27889
|
-
`
|
|
27890
|
-
Mobius Web requested installation of ${label} (${requestId}). Allow this fixed user-level recipe? [y/N] `,
|
|
27891
|
-
{ signal }
|
|
27892
|
-
);
|
|
27893
|
-
const normalized = answer.trim().toLowerCase();
|
|
27894
|
-
return normalized === "y" || normalized === "yes";
|
|
27895
|
-
} finally {
|
|
27896
|
-
prompt.close();
|
|
27897
|
-
}
|
|
27898
|
-
};
|
|
27899
|
-
};
|
|
27900
|
-
|
|
27901
28342
|
// src/authorization/workspace-directory.ts
|
|
27902
|
-
import { readdir, realpath as
|
|
28343
|
+
import { readdir, realpath as realpath8, stat as stat7 } from "node:fs/promises";
|
|
27903
28344
|
import { homedir as homedir2 } from "node:os";
|
|
27904
28345
|
import {
|
|
27905
28346
|
basename as basename2,
|
|
27906
|
-
dirname as
|
|
27907
|
-
isAbsolute as
|
|
27908
|
-
join as
|
|
28347
|
+
dirname as dirname6,
|
|
28348
|
+
isAbsolute as isAbsolute7,
|
|
28349
|
+
join as join18,
|
|
27909
28350
|
normalize as normalize2,
|
|
27910
|
-
relative as
|
|
28351
|
+
relative as relative5
|
|
27911
28352
|
} from "node:path";
|
|
27912
28353
|
var WorkspaceDirectoryListing = class {
|
|
27913
28354
|
directoryId;
|
|
@@ -27957,20 +28398,20 @@ var WorkspaceDirectoryService = class {
|
|
|
27957
28398
|
if (id === "home") return homedir2();
|
|
27958
28399
|
if (id.startsWith("path-")) {
|
|
27959
28400
|
const path2 = decodePath(id, "path-");
|
|
27960
|
-
if (
|
|
28401
|
+
if (isAbsolute7(path2)) return path2;
|
|
27961
28402
|
}
|
|
27962
28403
|
throw new LocalAuthorizationError("The directory identifier is invalid");
|
|
27963
28404
|
};
|
|
27964
28405
|
resolvePath = async (requested, signal) => {
|
|
27965
28406
|
signal.throwIfAborted();
|
|
27966
|
-
if (!
|
|
28407
|
+
if (!isAbsolute7(requested) || requested.includes("\0") || normalize2(requested) !== requested)
|
|
27967
28408
|
throw new LocalAuthorizationError("The local directory path is invalid");
|
|
27968
28409
|
try {
|
|
27969
|
-
const target = await
|
|
28410
|
+
const target = await realpath8(requested);
|
|
27970
28411
|
signal.throwIfAborted();
|
|
27971
|
-
const metadata = await
|
|
28412
|
+
const metadata = await stat7(target);
|
|
27972
28413
|
signal.throwIfAborted();
|
|
27973
|
-
if (!
|
|
28414
|
+
if (!isAbsolute7(target) || normalize2(target) !== target || !metadata.isDirectory())
|
|
27974
28415
|
throw new LocalAuthorizationError(
|
|
27975
28416
|
"The selected location is not a directory"
|
|
27976
28417
|
);
|
|
@@ -27985,8 +28426,8 @@ var WorkspaceDirectoryService = class {
|
|
|
27985
28426
|
}
|
|
27986
28427
|
};
|
|
27987
28428
|
label = (path2) => {
|
|
27988
|
-
const suffix =
|
|
27989
|
-
return suffix === "" ? "~" : !
|
|
28429
|
+
const suffix = relative5(homedir2(), path2);
|
|
28430
|
+
return suffix === "" ? "~" : !isAbsolute7(suffix) && suffix !== ".." && !suffix.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`) ? `~/${suffix.replaceAll("\\", "/")}` : path2;
|
|
27990
28431
|
};
|
|
27991
28432
|
identify = async (bindingId, requestedPath, signal) => {
|
|
27992
28433
|
this.authorizeMachine(bindingId);
|
|
@@ -28014,7 +28455,7 @@ var WorkspaceDirectoryService = class {
|
|
|
28014
28455
|
continue;
|
|
28015
28456
|
}
|
|
28016
28457
|
try {
|
|
28017
|
-
const path2 = await this.resolvePath(
|
|
28458
|
+
const path2 = await this.resolvePath(join18(target, child.name), signal);
|
|
28018
28459
|
entries.push({ directoryId: encodePath(path2), name: child.name });
|
|
28019
28460
|
} catch (cause) {
|
|
28020
28461
|
signal.throwIfAborted();
|
|
@@ -28022,7 +28463,7 @@ var WorkspaceDirectoryService = class {
|
|
|
28022
28463
|
}
|
|
28023
28464
|
}
|
|
28024
28465
|
entries.sort((a, b) => a.name.localeCompare(b.name));
|
|
28025
|
-
const parent =
|
|
28466
|
+
const parent = dirname6(target);
|
|
28026
28467
|
return new WorkspaceDirectoryListing(
|
|
28027
28468
|
id,
|
|
28028
28469
|
this.label(target),
|
|
@@ -28815,7 +29256,7 @@ var RelayConnectionLiveness = class {
|
|
|
28815
29256
|
|
|
28816
29257
|
// src/relay-connection/session-event-outbox.ts
|
|
28817
29258
|
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
28818
|
-
import { dirname as
|
|
29259
|
+
import { dirname as dirname7 } from "node:path";
|
|
28819
29260
|
import { DatabaseSync as DatabaseSync3 } from "node:sqlite";
|
|
28820
29261
|
function readPendingEnvelope(row) {
|
|
28821
29262
|
if (typeof row !== "object" || row === null || Array.isArray(row)) {
|
|
@@ -28830,7 +29271,7 @@ function readPendingEnvelope(row) {
|
|
|
28830
29271
|
var SessionEventOutbox = class {
|
|
28831
29272
|
#database;
|
|
28832
29273
|
constructor(path2) {
|
|
28833
|
-
mkdirSync3(
|
|
29274
|
+
mkdirSync3(dirname7(path2), { recursive: true });
|
|
28834
29275
|
this.#database = new DatabaseSync3(path2);
|
|
28835
29276
|
this.#database.exec(`
|
|
28836
29277
|
CREATE TABLE IF NOT EXISTS relay_session_event_outbox (
|
|
@@ -29122,17 +29563,6 @@ var DaemonInstallationObserver = class {
|
|
|
29122
29563
|
if (state instanceof RequestedInstallation) {
|
|
29123
29564
|
return Promise.resolve();
|
|
29124
29565
|
}
|
|
29125
|
-
if (state instanceof AwaitingLocalApproval) {
|
|
29126
|
-
this.#send(
|
|
29127
|
-
socket,
|
|
29128
|
-
encodeAgentInstallAwaitingApprovalEvent({
|
|
29129
|
-
agentId: state.agentId,
|
|
29130
|
-
kind: AGENT_INSTALL_AWAITING_APPROVAL_KIND,
|
|
29131
|
-
requestId: state.requestId
|
|
29132
|
-
})
|
|
29133
|
-
);
|
|
29134
|
-
return Promise.resolve();
|
|
29135
|
-
}
|
|
29136
29566
|
if (state instanceof RunningInstallation) {
|
|
29137
29567
|
if (!this.#started.has(state.requestId)) {
|
|
29138
29568
|
this.#started.add(state.requestId);
|
|
@@ -30029,7 +30459,6 @@ async function runDaemon(config2, audit, signal, timer = systemDaemonTimer) {
|
|
|
30029
30459
|
);
|
|
30030
30460
|
const installations = new AgentInstallationManager(
|
|
30031
30461
|
specifications,
|
|
30032
|
-
new ConsoleInstallationAuthorizer(stateDirectory),
|
|
30033
30462
|
installationExecutor,
|
|
30034
30463
|
installationObserver,
|
|
30035
30464
|
installationAudit
|