@axiom-lattice/core 2.1.55 → 2.1.56
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/index.d.mts +13 -39
- package/dist/index.d.ts +13 -39
- package/dist/index.js +1 -240
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -239
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -18173,230 +18173,6 @@ var McpLatticeManager = class _McpLatticeManager extends BaseLatticeManager {
|
|
|
18173
18173
|
};
|
|
18174
18174
|
var mcpManager = McpLatticeManager.getInstance();
|
|
18175
18175
|
|
|
18176
|
-
// src/sandbox_lattice/providers/MicrosandboxProvider.ts
|
|
18177
|
-
import { Sandbox } from "microsandbox";
|
|
18178
|
-
|
|
18179
|
-
// src/sandbox_lattice/MicrosandboxInstance.ts
|
|
18180
|
-
function exec(native, cmd, opts) {
|
|
18181
|
-
return native.execWithConfig({ cmd, args: opts?.args, cwd: opts?.cwd, timeoutMs: opts?.timeoutMs });
|
|
18182
|
-
}
|
|
18183
|
-
var MicrosandboxInstance = class {
|
|
18184
|
-
constructor(name, native) {
|
|
18185
|
-
this.native = native;
|
|
18186
|
-
this.file = {
|
|
18187
|
-
readFile: async (file) => {
|
|
18188
|
-
const fs3 = this.native.fs();
|
|
18189
|
-
const content = await fs3.readString(file);
|
|
18190
|
-
return { content };
|
|
18191
|
-
},
|
|
18192
|
-
writeFile: async (file, content) => {
|
|
18193
|
-
const fs3 = this.native.fs();
|
|
18194
|
-
await fs3.write(file, Buffer.from(content));
|
|
18195
|
-
},
|
|
18196
|
-
listPath: async (path3, options) => {
|
|
18197
|
-
const fs3 = this.native.fs();
|
|
18198
|
-
const entries = await fs3.list(path3);
|
|
18199
|
-
const files = (entries || []).map((e) => ({
|
|
18200
|
-
path: e.path,
|
|
18201
|
-
is_dir: e.kind === "directory",
|
|
18202
|
-
size: e.size,
|
|
18203
|
-
modified_at: e.modified ? String(e.modified) : void 0
|
|
18204
|
-
}));
|
|
18205
|
-
return { files };
|
|
18206
|
-
},
|
|
18207
|
-
findFiles: async (path3, glob) => {
|
|
18208
|
-
const output = await exec(this.native, "sh", {
|
|
18209
|
-
args: ["-c", `find "${path3}" -name "${glob}" -type f`]
|
|
18210
|
-
});
|
|
18211
|
-
const lines = output.stdout().split("\n").filter(Boolean);
|
|
18212
|
-
return { files: lines };
|
|
18213
|
-
},
|
|
18214
|
-
searchInFile: async (file, regex) => {
|
|
18215
|
-
const output = await exec(this.native, "grep", {
|
|
18216
|
-
args: ["-n", "-E", regex, file]
|
|
18217
|
-
});
|
|
18218
|
-
const lines = output.stdout().split("\n").filter(Boolean);
|
|
18219
|
-
const matches = [];
|
|
18220
|
-
const line_numbers = [];
|
|
18221
|
-
for (const line of lines) {
|
|
18222
|
-
const colonIdx = line.indexOf(":");
|
|
18223
|
-
if (colonIdx === -1) continue;
|
|
18224
|
-
const num = parseInt(line.slice(0, colonIdx), 10);
|
|
18225
|
-
const text = line.slice(colonIdx + 1);
|
|
18226
|
-
line_numbers.push(num);
|
|
18227
|
-
matches.push(text);
|
|
18228
|
-
}
|
|
18229
|
-
return { matches, line_numbers };
|
|
18230
|
-
},
|
|
18231
|
-
strReplaceEditor: async (params) => {
|
|
18232
|
-
const { path: path3, old_str, new_str, replace_mode } = params;
|
|
18233
|
-
const delim = "#";
|
|
18234
|
-
const escapedOld = old_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
|
|
18235
|
-
const escapedNew = new_str.replace(new RegExp(`[\\\\${delim}]`, "g"), "\\$&").replace(/\n/g, "\\n");
|
|
18236
|
-
const flag = replace_mode === "ALL" ? "g" : "";
|
|
18237
|
-
await exec(this.native, "sh", {
|
|
18238
|
-
args: ["-c", `sed -i 's${delim}${escapedOld}${delim}${escapedNew}${delim}${flag}' "${path3}"`]
|
|
18239
|
-
});
|
|
18240
|
-
},
|
|
18241
|
-
uploadFile: async (params) => {
|
|
18242
|
-
const fs3 = this.native.fs();
|
|
18243
|
-
await fs3.write(params.file, params.data);
|
|
18244
|
-
},
|
|
18245
|
-
downloadFile: async (params) => {
|
|
18246
|
-
const fs3 = this.native.fs();
|
|
18247
|
-
const data = await fs3.read(params.file);
|
|
18248
|
-
return Buffer.isBuffer(data) ? data : Buffer.from(data);
|
|
18249
|
-
}
|
|
18250
|
-
};
|
|
18251
|
-
this.shell = {
|
|
18252
|
-
execCommand: async (params) => {
|
|
18253
|
-
const output = await exec(this.native, "sh", {
|
|
18254
|
-
args: ["-c", params.command],
|
|
18255
|
-
cwd: params.exec_dir,
|
|
18256
|
-
timeoutMs: params.timeout ? params.timeout * 1e3 : void 0
|
|
18257
|
-
});
|
|
18258
|
-
return {
|
|
18259
|
-
output: output.stdout(),
|
|
18260
|
-
exit_code: output.code ?? 0
|
|
18261
|
-
};
|
|
18262
|
-
}
|
|
18263
|
-
};
|
|
18264
|
-
this.name = name;
|
|
18265
|
-
}
|
|
18266
|
-
async start() {
|
|
18267
|
-
}
|
|
18268
|
-
async stop() {
|
|
18269
|
-
await this.native.stop();
|
|
18270
|
-
}
|
|
18271
|
-
async kill() {
|
|
18272
|
-
await this.native.kill();
|
|
18273
|
-
}
|
|
18274
|
-
async getStatus() {
|
|
18275
|
-
try {
|
|
18276
|
-
await this.native.exec("echo", ["ok"]);
|
|
18277
|
-
return "running";
|
|
18278
|
-
} catch {
|
|
18279
|
-
return "unknown";
|
|
18280
|
-
}
|
|
18281
|
-
}
|
|
18282
|
-
};
|
|
18283
|
-
|
|
18284
|
-
// src/sandbox_lattice/providers/MicrosandboxProvider.ts
|
|
18285
|
-
var defaultMicrosandboxConfig = {
|
|
18286
|
-
image: process.env.MICROSANDBOX_IMAGE ?? "python:3.11-slim",
|
|
18287
|
-
cpus: Number(process.env.MICROSANDBOX_CPUS ?? "1"),
|
|
18288
|
-
memoryMib: Number(process.env.MICROSANDBOX_MEMORY ?? "512"),
|
|
18289
|
-
env: {
|
|
18290
|
-
PYTHONDONTWRITEBYTECODE: "1",
|
|
18291
|
-
PIP_NO_CACHE_DIR: "1",
|
|
18292
|
-
...process.env.MICROSANDBOX_EXTRA_ENV ? Object.fromEntries(
|
|
18293
|
-
process.env.MICROSANDBOX_EXTRA_ENV.split(",").map((pair) => pair.split("="))
|
|
18294
|
-
) : {}
|
|
18295
|
-
}
|
|
18296
|
-
};
|
|
18297
|
-
var MicrosandboxProvider = class {
|
|
18298
|
-
constructor(config = {}) {
|
|
18299
|
-
this.config = config;
|
|
18300
|
-
this.instances = /* @__PURE__ */ new Map();
|
|
18301
|
-
this.creating = /* @__PURE__ */ new Map();
|
|
18302
|
-
}
|
|
18303
|
-
async createSandbox(name, config) {
|
|
18304
|
-
const existing = this.instances.get(name);
|
|
18305
|
-
if (existing) {
|
|
18306
|
-
return existing;
|
|
18307
|
-
}
|
|
18308
|
-
const inFlight = this.creating.get(name);
|
|
18309
|
-
if (inFlight) {
|
|
18310
|
-
return inFlight;
|
|
18311
|
-
}
|
|
18312
|
-
const creation = (async () => {
|
|
18313
|
-
let native;
|
|
18314
|
-
try {
|
|
18315
|
-
const handle = await Sandbox.get(name);
|
|
18316
|
-
if (handle.status === "stopped") {
|
|
18317
|
-
native = await Sandbox.start(name);
|
|
18318
|
-
} else if (handle.status === "running") {
|
|
18319
|
-
native = await handle.connect();
|
|
18320
|
-
} else if (handle.status === "crashed" || handle.status === "draining") {
|
|
18321
|
-
await Sandbox.remove(name);
|
|
18322
|
-
native = void 0;
|
|
18323
|
-
} else {
|
|
18324
|
-
throw new Error(`Unexpected sandbox status: ${handle.status}`);
|
|
18325
|
-
}
|
|
18326
|
-
} catch {
|
|
18327
|
-
native = void 0;
|
|
18328
|
-
}
|
|
18329
|
-
if (!native) {
|
|
18330
|
-
try {
|
|
18331
|
-
native = await Sandbox.createDetached({
|
|
18332
|
-
name,
|
|
18333
|
-
image: this.config.image ?? "python:3.11-slim",
|
|
18334
|
-
cpus: this.config.cpus ?? 1,
|
|
18335
|
-
memoryMib: this.config.memoryMib ?? 512,
|
|
18336
|
-
env: {
|
|
18337
|
-
...this.config.env,
|
|
18338
|
-
...buildSandboxMetadataEnv(config)
|
|
18339
|
-
}
|
|
18340
|
-
});
|
|
18341
|
-
} catch (err) {
|
|
18342
|
-
if (err instanceof Error && err.message.includes("already exists")) {
|
|
18343
|
-
await Sandbox.remove(name);
|
|
18344
|
-
native = await Sandbox.createDetached({
|
|
18345
|
-
name,
|
|
18346
|
-
image: this.config.image ?? "python:3.11-slim",
|
|
18347
|
-
cpus: this.config.cpus ?? 1,
|
|
18348
|
-
memoryMib: this.config.memoryMib ?? 512,
|
|
18349
|
-
env: {
|
|
18350
|
-
...this.config.env,
|
|
18351
|
-
...buildSandboxMetadataEnv(config)
|
|
18352
|
-
}
|
|
18353
|
-
});
|
|
18354
|
-
} else {
|
|
18355
|
-
throw err;
|
|
18356
|
-
}
|
|
18357
|
-
}
|
|
18358
|
-
}
|
|
18359
|
-
const instance = new MicrosandboxInstance(name, native);
|
|
18360
|
-
this.instances.set(name, instance);
|
|
18361
|
-
return instance;
|
|
18362
|
-
})();
|
|
18363
|
-
this.creating.set(name, creation);
|
|
18364
|
-
creation.catch(() => this.creating.delete(name)).then(() => this.creating.delete(name));
|
|
18365
|
-
return creation;
|
|
18366
|
-
}
|
|
18367
|
-
async getSandbox(name) {
|
|
18368
|
-
const instance = this.instances.get(name);
|
|
18369
|
-
if (!instance) {
|
|
18370
|
-
throw new Error(`Sandbox ${name} not found`);
|
|
18371
|
-
}
|
|
18372
|
-
return instance;
|
|
18373
|
-
}
|
|
18374
|
-
async stopSandbox(name) {
|
|
18375
|
-
const instance = this.instances.get(name);
|
|
18376
|
-
if (instance) {
|
|
18377
|
-
try {
|
|
18378
|
-
await instance.stop();
|
|
18379
|
-
} catch {
|
|
18380
|
-
}
|
|
18381
|
-
}
|
|
18382
|
-
}
|
|
18383
|
-
async deleteSandbox(name) {
|
|
18384
|
-
const instance = this.instances.get(name);
|
|
18385
|
-
this.instances.delete(name);
|
|
18386
|
-
if (instance) {
|
|
18387
|
-
try {
|
|
18388
|
-
await instance.kill();
|
|
18389
|
-
await new Promise((r) => setTimeout(r, 200));
|
|
18390
|
-
} catch {
|
|
18391
|
-
}
|
|
18392
|
-
}
|
|
18393
|
-
await Sandbox.remove(name);
|
|
18394
|
-
}
|
|
18395
|
-
async listSandboxes() {
|
|
18396
|
-
return Array.from(this.instances.values());
|
|
18397
|
-
}
|
|
18398
|
-
};
|
|
18399
|
-
|
|
18400
18176
|
// src/sandbox_lattice/MicrosandboxRemoteInstance.ts
|
|
18401
18177
|
var MicrosandboxRemoteInstance = class {
|
|
18402
18178
|
constructor(name, client) {
|
|
@@ -18958,7 +18734,7 @@ var RemoteSandboxProvider = class {
|
|
|
18958
18734
|
};
|
|
18959
18735
|
|
|
18960
18736
|
// src/sandbox_lattice/providers/E2BProvider.ts
|
|
18961
|
-
import { Sandbox
|
|
18737
|
+
import { Sandbox } from "e2b";
|
|
18962
18738
|
|
|
18963
18739
|
// src/sandbox_lattice/E2BInstance.ts
|
|
18964
18740
|
var E2BInstance = class {
|
|
@@ -19079,7 +18855,7 @@ var E2BProvider = class {
|
|
|
19079
18855
|
return inFlight;
|
|
19080
18856
|
}
|
|
19081
18857
|
const creation = (async () => {
|
|
19082
|
-
const native = await
|
|
18858
|
+
const native = await Sandbox.create(
|
|
19083
18859
|
this.config.template ?? "base",
|
|
19084
18860
|
{
|
|
19085
18861
|
apiKey: this.config.apiKey,
|
|
@@ -19431,14 +19207,6 @@ var DaytonaProvider = class {
|
|
|
19431
19207
|
// src/sandbox_lattice/SandboxProviderFactory.ts
|
|
19432
19208
|
function createSandboxProvider(config) {
|
|
19433
19209
|
switch (config.type) {
|
|
19434
|
-
case "microsandbox": {
|
|
19435
|
-
return new MicrosandboxProvider({
|
|
19436
|
-
image: config.microsandboxImage ?? defaultMicrosandboxConfig.image,
|
|
19437
|
-
cpus: config.microsandboxCpus ?? defaultMicrosandboxConfig.cpus,
|
|
19438
|
-
memoryMib: config.microsandboxMemoryMib ?? defaultMicrosandboxConfig.memoryMib,
|
|
19439
|
-
env: defaultMicrosandboxConfig.env
|
|
19440
|
-
});
|
|
19441
|
-
}
|
|
19442
19210
|
case "remote": {
|
|
19443
19211
|
if (!config.remoteBaseURL) {
|
|
19444
19212
|
throw new Error("remoteBaseURL is required when sandbox provider type is 'remote'");
|
|
@@ -19455,8 +19223,7 @@ function createSandboxProvider(config) {
|
|
|
19455
19223
|
baseURL: config.microsandboxServiceBaseURL,
|
|
19456
19224
|
image: config.microsandboxImage,
|
|
19457
19225
|
cpus: config.microsandboxCpus,
|
|
19458
|
-
memoryMib: config.microsandboxMemoryMib
|
|
19459
|
-
env: defaultMicrosandboxConfig.env
|
|
19226
|
+
memoryMib: config.microsandboxMemoryMib
|
|
19460
19227
|
});
|
|
19461
19228
|
}
|
|
19462
19229
|
case "e2b": {
|
|
@@ -19597,8 +19364,6 @@ export {
|
|
|
19597
19364
|
MemoryType,
|
|
19598
19365
|
MessageType,
|
|
19599
19366
|
MetricsServerManager,
|
|
19600
|
-
MicrosandboxInstance,
|
|
19601
|
-
MicrosandboxProvider,
|
|
19602
19367
|
MicrosandboxRemoteInstance,
|
|
19603
19368
|
MicrosandboxRemoteProvider,
|
|
19604
19369
|
MicrosandboxServiceClient,
|
|
@@ -19660,7 +19425,6 @@ export {
|
|
|
19660
19425
|
createUnknownToolHandlerMiddleware,
|
|
19661
19426
|
createWidgetMiddleware,
|
|
19662
19427
|
decrypt,
|
|
19663
|
-
defaultMicrosandboxConfig,
|
|
19664
19428
|
describeCronExpression,
|
|
19665
19429
|
embeddingsLatticeManager,
|
|
19666
19430
|
encrypt,
|