@letta-ai/letta-agent-sdk 0.8.55 → 0.8.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/client-entry.js +5 -5
- package/dist/client-entry.js.map +2 -2
- package/dist/index.js +159 -105
- package/dist/index.js.map +5 -5
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -10412,7 +10412,7 @@ Some skills are part of the environment (e.g. stored in \`.agents\`); others are
|
|
|
10412
10412
|
|
|
10413
10413
|
## Mods
|
|
10414
10414
|
|
|
10415
|
-
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They
|
|
10415
|
+
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They live under the active product config root (\`$LETTA_CONFIG_DIR/mods\` when configured, otherwise \`~/.letta/mods\`) and reload with \`/reload\`.
|
|
10416
10416
|
|
|
10417
10417
|
Treat mods as executable context-shaping affordances, not as hidden memory. Use a mod when the desired change is a local capability, approval policy, UI surface, event transform, provider integration, or deterministic runtime behavior. Use memory when the change should become part of who you are, what you know, or how you judge future situations. Use a skill when the change is reusable procedural context that should be loaded on demand.
|
|
10418
10418
|
|
|
@@ -10591,7 +10591,7 @@ Some skills are part of the environment (e.g. stored in \`.agents\`); others are
|
|
|
10591
10591
|
|
|
10592
10592
|
## Mods
|
|
10593
10593
|
|
|
10594
|
-
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They
|
|
10594
|
+
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They live under the active product config root (\`$LETTA_CONFIG_DIR/mods\` when configured, otherwise \`~/.letta/mods\`) and reload with \`/reload\`.
|
|
10595
10595
|
|
|
10596
10596
|
Treat mods as executable context-shaping affordances, not as hidden memory. Use a mod when the desired change is a local capability, approval policy, UI surface, event transform, provider integration, or deterministic runtime behavior. Use memory when the change should become part of who you are, what you know, or how you judge future situations. Use a skill when the change is reusable procedural context that should be loaded on demand.
|
|
10597
10597
|
|
|
@@ -10737,7 +10737,7 @@ Skills are dynamically loaded capabilities — folders of instructions, scripts,
|
|
|
10737
10737
|
|
|
10738
10738
|
# Mods
|
|
10739
10739
|
|
|
10740
|
-
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They
|
|
10740
|
+
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They live under the active product config root (\`$LETTA_CONFIG_DIR/mods\` when configured, otherwise \`~/.letta/mods\`) and reload with \`/reload\`.
|
|
10741
10741
|
|
|
10742
10742
|
Treat mods as executable context-shaping affordances, not as hidden memory. Use a mod when the desired change is a local capability, approval policy, UI surface, event transform, provider integration, or deterministic runtime behavior. Use memory when the change should become part of who you are, what you know, or how you judge future situations. Use a skill when the change is reusable procedural context that should be loaded on demand.
|
|
10743
10743
|
|
|
@@ -10920,7 +10920,7 @@ Some skills are part of the environment (e.g. stored in \`.agents\`); others are
|
|
|
10920
10920
|
|
|
10921
10921
|
## Mods
|
|
10922
10922
|
|
|
10923
|
-
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They
|
|
10923
|
+
Mods are trusted local code that customize the harness around you. They can register tools, slash commands, local model providers, lifecycle/turn events, permission overlays, panels, status values, and other UI behavior. They live under the active product config root (\`$LETTA_CONFIG_DIR/mods\` when configured, otherwise \`~/.letta/mods\`) and reload with \`/reload\`.
|
|
10924
10924
|
|
|
10925
10925
|
Treat mods as executable context-shaping affordances, not as hidden memory. Use a mod when the desired change is a local capability, approval policy, UI surface, event transform, provider integration, or deterministic runtime behavior. Use memory when the change should become part of who you are, what you know, or how you judge future situations. Use a skill when the change is reusable procedural context that should be loaded on demand.
|
|
10926
10926
|
|
|
@@ -17328,20 +17328,21 @@ class LettaAgentClientBase {
|
|
|
17328
17328
|
// src/local-app-server.ts
|
|
17329
17329
|
import { spawn } from "node:child_process";
|
|
17330
17330
|
import { homedir as homedir4 } from "node:os";
|
|
17331
|
-
import { join as
|
|
17331
|
+
import { join as join8 } from "node:path";
|
|
17332
17332
|
|
|
17333
17333
|
// node_modules/@letta-ai/letta-code/dist/memory-confinement.js
|
|
17334
17334
|
import { homedir as homedir3 } from "node:os";
|
|
17335
|
-
import { basename as basename2, dirname as dirname2, join as
|
|
17335
|
+
import { basename as basename2, dirname as dirname2, join as join4, resolve as resolve3 } from "node:path";
|
|
17336
17336
|
import { existsSync, realpathSync } from "node:fs";
|
|
17337
17337
|
import { homedir as homedir2 } from "node:os";
|
|
17338
|
-
import { basename, dirname, isAbsolute, join as
|
|
17338
|
+
import { basename, dirname, isAbsolute as isAbsolute2, join as join3, resolve as resolve2 } from "node:path";
|
|
17339
17339
|
import { posix, win32 } from "node:path";
|
|
17340
|
+
import { join as join2 } from "node:path";
|
|
17340
17341
|
import { homedir } from "node:os";
|
|
17341
|
-
import { join } from "node:path";
|
|
17342
|
+
import { isAbsolute, join, normalize, resolve } from "node:path";
|
|
17342
17343
|
import { spawnSync } from "node:child_process";
|
|
17343
17344
|
import { existsSync as existsSync2 } from "node:fs";
|
|
17344
|
-
import { delimiter, isAbsolute as
|
|
17345
|
+
import { delimiter, isAbsolute as isAbsolute3, join as join5 } from "node:path";
|
|
17345
17346
|
var SANDBOX_ENV_VAR = "LETTA_SANDBOX";
|
|
17346
17347
|
function buildFsSandboxPolicy(options) {
|
|
17347
17348
|
return {
|
|
@@ -17352,6 +17353,32 @@ function buildFsSandboxPolicy(options) {
|
|
|
17352
17353
|
restrictWrites: options.restrictWrites ?? false
|
|
17353
17354
|
};
|
|
17354
17355
|
}
|
|
17356
|
+
function getOrderedSandboxPathRules(policy) {
|
|
17357
|
+
const rules = [];
|
|
17358
|
+
const append = (kind, roots) => {
|
|
17359
|
+
roots.forEach((root, index) => {
|
|
17360
|
+
rules.push({ kind, root, index });
|
|
17361
|
+
});
|
|
17362
|
+
};
|
|
17363
|
+
append("deny", policy.deniedRoots);
|
|
17364
|
+
append("readonly", policy.readonlyRoots);
|
|
17365
|
+
append("writable", policy.writableRoots);
|
|
17366
|
+
const samePathPriority = {
|
|
17367
|
+
readonly: 0,
|
|
17368
|
+
writable: 1,
|
|
17369
|
+
deny: 2
|
|
17370
|
+
};
|
|
17371
|
+
const depth = (root) => root.split("/").filter(Boolean).length;
|
|
17372
|
+
return rules.sort((a, b) => {
|
|
17373
|
+
const depthDifference = depth(a.root) - depth(b.root);
|
|
17374
|
+
if (depthDifference !== 0)
|
|
17375
|
+
return depthDifference;
|
|
17376
|
+
const pathDifference = a.root.localeCompare(b.root);
|
|
17377
|
+
if (pathDifference !== 0)
|
|
17378
|
+
return pathDifference;
|
|
17379
|
+
return samePathPriority[a.kind] - samePathPriority[b.kind];
|
|
17380
|
+
});
|
|
17381
|
+
}
|
|
17355
17382
|
function normalizeSandboxPath(path2) {
|
|
17356
17383
|
const trimmed = path2.trim();
|
|
17357
17384
|
const absolute = posix.isAbsolute(trimmed) || win32.isAbsolute(trimmed) ? trimmed : posix.resolve("/", trimmed);
|
|
@@ -17367,29 +17394,52 @@ function normalizeRoots(roots) {
|
|
|
17367
17394
|
}
|
|
17368
17395
|
return [...seen];
|
|
17369
17396
|
}
|
|
17397
|
+
function resolveGlobalConfigDir(env = process.env, fallbackHome = homedir()) {
|
|
17398
|
+
const override = env.LETTA_CONFIG_DIR?.trim();
|
|
17399
|
+
if (override) {
|
|
17400
|
+
if (!isAbsolute(override)) {
|
|
17401
|
+
throw new Error("LETTA_CONFIG_DIR must be absolute");
|
|
17402
|
+
}
|
|
17403
|
+
return normalize(override);
|
|
17404
|
+
}
|
|
17405
|
+
return join(env.HOME || fallbackHome, ".letta");
|
|
17406
|
+
}
|
|
17407
|
+
function hasGlobalConfigDirOverride(env = process.env) {
|
|
17408
|
+
return Boolean(env.LETTA_CONFIG_DIR?.trim());
|
|
17409
|
+
}
|
|
17370
17410
|
var LOCAL_BACKEND_DIR_ENV = "LETTA_LOCAL_BACKEND_DIR";
|
|
17371
|
-
function getLocalBackendStorageDir(homeDir
|
|
17372
|
-
|
|
17411
|
+
function getLocalBackendStorageDir(homeDir, env = process.env) {
|
|
17412
|
+
const configDir = homeDir === undefined || hasGlobalConfigDirOverride(env) ? resolveGlobalConfigDir(env, homeDir) : join2(homeDir, ".letta");
|
|
17413
|
+
return env[LOCAL_BACKEND_DIR_ENV] ?? join2(configDir, "lc-local-backend");
|
|
17373
17414
|
}
|
|
17374
17415
|
function getLocalBackendCrossAgentTreeRoot(storageDir = getLocalBackendStorageDir()) {
|
|
17375
|
-
return
|
|
17376
|
-
}
|
|
17377
|
-
function getDefaultAgentsTreeRoot(homeDir = homedir2()) {
|
|
17378
|
-
return canonicalizeRoot(join2(homeDir, ".letta", "agents"));
|
|
17416
|
+
return join2(storageDir, "memfs");
|
|
17379
17417
|
}
|
|
17380
17418
|
function getCrossBackendAgentsTreeRoots(options = {}) {
|
|
17381
|
-
const homeDir = options.homeDir
|
|
17382
|
-
const
|
|
17383
|
-
|
|
17384
|
-
|
|
17385
|
-
|
|
17386
|
-
|
|
17419
|
+
const homeDir = options.homeDir;
|
|
17420
|
+
const env = options.env ?? process.env;
|
|
17421
|
+
const resolvedHome = homeDir ?? env.HOME ?? homedir2();
|
|
17422
|
+
const configRoots = new Set([
|
|
17423
|
+
resolveGlobalConfigDir(env, resolvedHome),
|
|
17424
|
+
join3(resolvedHome, ".letta")
|
|
17425
|
+
]);
|
|
17426
|
+
const localBackendStorageDir = options.localBackendStorageDir ?? getLocalBackendStorageDir(homeDir, env);
|
|
17427
|
+
const roots = new Set;
|
|
17428
|
+
for (const configRoot of configRoots) {
|
|
17429
|
+
roots.add(canonicalizeRoot(join3(configRoot, "agents")));
|
|
17430
|
+
}
|
|
17431
|
+
roots.add(canonicalizeRoot(getLocalBackendCrossAgentTreeRoot(localBackendStorageDir)));
|
|
17432
|
+
for (const configRoot of configRoots) {
|
|
17433
|
+
roots.add(canonicalizeRoot(getLocalBackendCrossAgentTreeRoot(join3(configRoot, "lc-local-backend"))));
|
|
17434
|
+
}
|
|
17435
|
+
return [...roots];
|
|
17387
17436
|
}
|
|
17388
|
-
function getLettaHomeRoot(homeDir =
|
|
17389
|
-
|
|
17437
|
+
function getLettaHomeRoot(homeDir, env = process.env) {
|
|
17438
|
+
const configDir = homeDir === undefined || hasGlobalConfigDirOverride(env) ? resolveGlobalConfigDir(env, homeDir) : join3(homeDir, ".letta");
|
|
17439
|
+
return canonicalizeRoot(configDir);
|
|
17390
17440
|
}
|
|
17391
17441
|
function canonicalizeRoot(input) {
|
|
17392
|
-
const abs =
|
|
17442
|
+
const abs = isAbsolute2(input) ? input : resolve2(input);
|
|
17393
17443
|
let dir = abs;
|
|
17394
17444
|
const tail = [];
|
|
17395
17445
|
while (!existsSync(dir)) {
|
|
@@ -17402,7 +17452,7 @@ function canonicalizeRoot(input) {
|
|
|
17402
17452
|
}
|
|
17403
17453
|
try {
|
|
17404
17454
|
const real = realpathSync(dir);
|
|
17405
|
-
return normalizeSandboxPath(tail.length ?
|
|
17455
|
+
return normalizeSandboxPath(tail.length ? join3(real, ...tail) : real);
|
|
17406
17456
|
} catch {
|
|
17407
17457
|
return normalizeSandboxPath(abs);
|
|
17408
17458
|
}
|
|
@@ -17443,7 +17493,9 @@ function deriveWritableMemoryRootsForTrees(memoryRoots, agentsTreeRoots) {
|
|
|
17443
17493
|
const out = new Set;
|
|
17444
17494
|
for (const root of memoryRoots) {
|
|
17445
17495
|
const canon = canonicalizeRoot(root);
|
|
17446
|
-
|
|
17496
|
+
const isExactDeniedTree = canonicalTrees.includes(canon);
|
|
17497
|
+
const isInsideDeniedTree = canonicalTrees.some((tree) => canon !== tree && isWithinRoot(canon, tree));
|
|
17498
|
+
if (!isExactDeniedTree && (isInsideDeniedTree || !isTreeOrAncestorOfTree(canon, canonicalTrees))) {
|
|
17447
17499
|
out.add(canon);
|
|
17448
17500
|
}
|
|
17449
17501
|
}
|
|
@@ -17475,14 +17527,18 @@ function buildBwrapArgs(policy) {
|
|
|
17475
17527
|
for (const root of policy.baseWritableRoots) {
|
|
17476
17528
|
args.push("--bind-try", root, root);
|
|
17477
17529
|
}
|
|
17478
|
-
for (const
|
|
17479
|
-
|
|
17480
|
-
|
|
17481
|
-
|
|
17482
|
-
|
|
17483
|
-
|
|
17484
|
-
|
|
17485
|
-
|
|
17530
|
+
for (const rule of getOrderedSandboxPathRules(policy)) {
|
|
17531
|
+
switch (rule.kind) {
|
|
17532
|
+
case "deny":
|
|
17533
|
+
args.push("--tmpfs", rule.root);
|
|
17534
|
+
break;
|
|
17535
|
+
case "readonly":
|
|
17536
|
+
args.push("--ro-bind-try", rule.root, rule.root);
|
|
17537
|
+
break;
|
|
17538
|
+
case "writable":
|
|
17539
|
+
args.push("--bind-try", rule.root, rule.root);
|
|
17540
|
+
break;
|
|
17541
|
+
}
|
|
17486
17542
|
}
|
|
17487
17543
|
args.push("--die-with-parent");
|
|
17488
17544
|
return args;
|
|
@@ -17500,22 +17556,20 @@ function buildSeatbeltProfile(policy) {
|
|
|
17500
17556
|
defines.push({ name, value: root });
|
|
17501
17557
|
lines.push(`(allow file-write* (subpath (param "${name}")))`);
|
|
17502
17558
|
});
|
|
17503
|
-
|
|
17504
|
-
const
|
|
17505
|
-
|
|
17506
|
-
|
|
17507
|
-
|
|
17508
|
-
|
|
17509
|
-
|
|
17510
|
-
|
|
17511
|
-
|
|
17512
|
-
|
|
17513
|
-
|
|
17514
|
-
|
|
17515
|
-
|
|
17516
|
-
|
|
17517
|
-
lines.push(`(allow file-read* (subpath (param "${name}")))`);
|
|
17518
|
-
});
|
|
17559
|
+
for (const rule of getOrderedSandboxPathRules(policy)) {
|
|
17560
|
+
const prefix = rule.kind === "deny" ? "DENIED" : rule.kind === "readonly" ? "READONLY" : "WRITABLE";
|
|
17561
|
+
const name = `${prefix}_${rule.index}`;
|
|
17562
|
+
defines.push({ name, value: rule.root });
|
|
17563
|
+
if (rule.kind === "deny") {
|
|
17564
|
+
lines.push(`(deny file-read* file-write* (subpath (param "${name}")))`);
|
|
17565
|
+
lines.push(`(allow file-read-metadata (literal (param "${name}")))`);
|
|
17566
|
+
} else if (rule.kind === "readonly") {
|
|
17567
|
+
lines.push(`(deny file-write* (subpath (param "${name}")))`);
|
|
17568
|
+
lines.push(`(allow file-read* (subpath (param "${name}")))`);
|
|
17569
|
+
} else {
|
|
17570
|
+
lines.push(`(allow file-read* file-write* (subpath (param "${name}")))`);
|
|
17571
|
+
}
|
|
17572
|
+
}
|
|
17519
17573
|
return { profile: `${lines.join(`
|
|
17520
17574
|
`)}
|
|
17521
17575
|
`, defines };
|
|
@@ -17552,8 +17606,8 @@ function wrapLauncher(launcher, policy, options) {
|
|
|
17552
17606
|
}
|
|
17553
17607
|
function normalizeRoot(path2) {
|
|
17554
17608
|
const trimmed = path2.trim();
|
|
17555
|
-
const expanded = trimmed.startsWith("~/") ?
|
|
17556
|
-
return
|
|
17609
|
+
const expanded = trimmed.startsWith("~/") ? join4(homedir3(), trimmed.slice(2)) : trimmed.startsWith("$HOME/") ? join4(homedir3(), trimmed.slice(6)) : trimmed;
|
|
17610
|
+
return resolve3(expanded);
|
|
17557
17611
|
}
|
|
17558
17612
|
function resolveWritableMemoryRoots(env) {
|
|
17559
17613
|
const roots = new Set;
|
|
@@ -17563,7 +17617,7 @@ function resolveWritableMemoryRoots(env) {
|
|
|
17563
17617
|
const root = normalizeRoot(value);
|
|
17564
17618
|
roots.add(root);
|
|
17565
17619
|
if (basename2(root) === "memory") {
|
|
17566
|
-
roots.add(
|
|
17620
|
+
roots.add(join4(dirname2(root), "memory-worktrees"));
|
|
17567
17621
|
}
|
|
17568
17622
|
}
|
|
17569
17623
|
return [...roots];
|
|
@@ -17654,12 +17708,12 @@ function probeBwrap() {
|
|
|
17654
17708
|
return { backend: "bwrap", bwrapPath, reason: "bwrap available" };
|
|
17655
17709
|
}
|
|
17656
17710
|
function resolveExecutableOnPath(executable, envPath = process.env.PATH) {
|
|
17657
|
-
if (
|
|
17711
|
+
if (isAbsolute3(executable) && existsSync2(executable))
|
|
17658
17712
|
return executable;
|
|
17659
17713
|
for (const dir of (envPath ?? "").split(delimiter)) {
|
|
17660
17714
|
if (!dir)
|
|
17661
17715
|
continue;
|
|
17662
|
-
const candidate =
|
|
17716
|
+
const candidate = join5(dir, executable);
|
|
17663
17717
|
if (existsSync2(candidate))
|
|
17664
17718
|
return candidate;
|
|
17665
17719
|
}
|
|
@@ -17672,7 +17726,7 @@ function createMemoryConfinementLauncher(input) {
|
|
|
17672
17726
|
// src/cli-resolver.ts
|
|
17673
17727
|
import { existsSync as existsSync3 } from "node:fs";
|
|
17674
17728
|
import { createRequire as createRequire2 } from "node:module";
|
|
17675
|
-
import { dirname as dirname3, join as
|
|
17729
|
+
import { dirname as dirname3, join as join6 } from "node:path";
|
|
17676
17730
|
import { fileURLToPath } from "node:url";
|
|
17677
17731
|
var require2 = createRequire2(import.meta.url);
|
|
17678
17732
|
var __filename2 = fileURLToPath(import.meta.url);
|
|
@@ -17686,11 +17740,11 @@ function findLettaCli() {
|
|
|
17686
17740
|
return require2.resolve("@letta-ai/letta-code");
|
|
17687
17741
|
} catch {}
|
|
17688
17742
|
const localPaths = [
|
|
17689
|
-
|
|
17690
|
-
|
|
17691
|
-
|
|
17692
|
-
|
|
17693
|
-
|
|
17743
|
+
join6(__dirname2, "..", "node_modules", "@letta-ai", "letta-code", "letta.js"),
|
|
17744
|
+
join6(__dirname2, "../../@letta-ai/letta-code/letta.js"),
|
|
17745
|
+
join6(__dirname2, "../../../letta-code-prod/letta.js"),
|
|
17746
|
+
join6(__dirname2, "../../../letta-code/letta.js"),
|
|
17747
|
+
join6(__dirname2, "..", "..", "letta-code", "letta.js")
|
|
17694
17748
|
];
|
|
17695
17749
|
for (const path2 of localPaths) {
|
|
17696
17750
|
if (existsSync3(path2)) {
|
|
@@ -17733,7 +17787,7 @@ function withDefaultMemoryDirectory(env, options) {
|
|
|
17733
17787
|
if (!options.agentId)
|
|
17734
17788
|
return scopedEnv;
|
|
17735
17789
|
const homeDir = targetHomeDirectory(env);
|
|
17736
|
-
const memoryDir = options.backend === "api" ?
|
|
17790
|
+
const memoryDir = options.backend === "api" ? join8(homeDir, ".letta", "agents", options.agentId, "memory") : join8(env.LETTA_LOCAL_BACKEND_DIR?.trim() || join8(homeDir, ".letta", "lc-local-backend"), "memfs", options.agentId, "memory");
|
|
17737
17791
|
return { ...scopedEnv, MEMORY_DIR: memoryDir };
|
|
17738
17792
|
}
|
|
17739
17793
|
function appendLine(buffer, chunk) {
|
|
@@ -17790,7 +17844,7 @@ function startLocalAppServer(options = {}) {
|
|
|
17790
17844
|
const cliPath = options.cliPath ?? findLettaCli();
|
|
17791
17845
|
const processSpec = buildLocalAppServerProcess(cliPath, options);
|
|
17792
17846
|
const startupTimeoutMs = options.startupTimeoutMs ?? DEFAULT_STARTUP_TIMEOUT_MS;
|
|
17793
|
-
return new Promise((
|
|
17847
|
+
return new Promise((resolve4, reject) => {
|
|
17794
17848
|
const child = spawn(processSpec.command, processSpec.args, {
|
|
17795
17849
|
stdio: ["ignore", "pipe", "pipe"],
|
|
17796
17850
|
env: processSpec.env
|
|
@@ -17817,7 +17871,7 @@ function startLocalAppServer(options = {}) {
|
|
|
17817
17871
|
return;
|
|
17818
17872
|
settled = true;
|
|
17819
17873
|
cleanup();
|
|
17820
|
-
|
|
17874
|
+
resolve4({
|
|
17821
17875
|
url,
|
|
17822
17876
|
isRunning: () => child.exitCode === null && child.signalCode === null,
|
|
17823
17877
|
close: () => terminateProcess(child)
|
|
@@ -17926,7 +17980,7 @@ class SharedLocalAppServer {
|
|
|
17926
17980
|
// src/skill-node.ts
|
|
17927
17981
|
import { readFile, readdir, stat, mkdtemp, rm, mkdir, writeFile } from "node:fs/promises";
|
|
17928
17982
|
import { tmpdir } from "node:os";
|
|
17929
|
-
import { basename as basename3, dirname as dirname5, join as
|
|
17983
|
+
import { basename as basename3, dirname as dirname5, join as join9, relative, sep } from "node:path";
|
|
17930
17984
|
import { execFile } from "node:child_process";
|
|
17931
17985
|
import { promisify } from "node:util";
|
|
17932
17986
|
var run = promisify(execFile);
|
|
@@ -17935,7 +17989,7 @@ async function loadSkillDirectory(dirPath) {
|
|
|
17935
17989
|
if (!dirStat?.isDirectory()) {
|
|
17936
17990
|
throw new Error(`Skill path is not a directory: ${dirPath}`);
|
|
17937
17991
|
}
|
|
17938
|
-
const skillMd = await readFile(
|
|
17992
|
+
const skillMd = await readFile(join9(dirPath, "SKILL.md"), "utf-8").catch(() => null);
|
|
17939
17993
|
if (skillMd === null) {
|
|
17940
17994
|
throw new Error(`Skill directory has no SKILL.md: ${dirPath}`);
|
|
17941
17995
|
}
|
|
@@ -17948,7 +18002,7 @@ async function loadSkillDirectory(dirPath) {
|
|
|
17948
18002
|
const files = {};
|
|
17949
18003
|
const walk = async (current) => {
|
|
17950
18004
|
for (const entry of await readdir(current, { withFileTypes: true })) {
|
|
17951
|
-
const full =
|
|
18005
|
+
const full = join9(current, entry.name);
|
|
17952
18006
|
if (entry.isDirectory()) {
|
|
17953
18007
|
await walk(full);
|
|
17954
18008
|
} else if (entry.isFile()) {
|
|
@@ -17986,11 +18040,11 @@ async function pushSkillSupportFiles(target, skills) {
|
|
|
17986
18040
|
env: gitEnv,
|
|
17987
18041
|
...cwd ? { cwd } : {}
|
|
17988
18042
|
});
|
|
17989
|
-
const work = await mkdtemp(
|
|
18043
|
+
const work = await mkdtemp(join9(tmpdir(), "letta-skill-seed-"));
|
|
17990
18044
|
try {
|
|
17991
18045
|
await git(["clone", "--quiet", "--depth", "1", remote, work]);
|
|
17992
18046
|
for (const entry of entries) {
|
|
17993
|
-
const filePath =
|
|
18047
|
+
const filePath = join9(work, entry.path);
|
|
17994
18048
|
await mkdir(dirname5(filePath), { recursive: true });
|
|
17995
18049
|
await writeFile(filePath, entry.data);
|
|
17996
18050
|
}
|
|
@@ -20274,8 +20328,8 @@ var require_resolve2 = __commonJS2((exports) => {
|
|
|
20274
20328
|
}
|
|
20275
20329
|
return count;
|
|
20276
20330
|
}
|
|
20277
|
-
function getFullPath(resolver, id = "",
|
|
20278
|
-
if (
|
|
20331
|
+
function getFullPath(resolver, id = "", normalize2) {
|
|
20332
|
+
if (normalize2 !== false)
|
|
20279
20333
|
id = normalizeId(id);
|
|
20280
20334
|
const p = resolver.parse(id);
|
|
20281
20335
|
return _getFullPath(resolver, p);
|
|
@@ -21005,7 +21059,7 @@ var require_compile2 = __commonJS2((exports) => {
|
|
|
21005
21059
|
const schOrFunc = root.refs[ref];
|
|
21006
21060
|
if (schOrFunc)
|
|
21007
21061
|
return schOrFunc;
|
|
21008
|
-
let _sch =
|
|
21062
|
+
let _sch = resolve4.call(this, root, ref);
|
|
21009
21063
|
if (_sch === undefined) {
|
|
21010
21064
|
const schema = (_a3 = root.localRefs) === null || _a3 === undefined ? undefined : _a3[ref];
|
|
21011
21065
|
const { schemaId } = this.opts;
|
|
@@ -21032,7 +21086,7 @@ var require_compile2 = __commonJS2((exports) => {
|
|
|
21032
21086
|
function sameSchemaEnv(s1, s2) {
|
|
21033
21087
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
21034
21088
|
}
|
|
21035
|
-
function
|
|
21089
|
+
function resolve4(root, ref) {
|
|
21036
21090
|
let sch;
|
|
21037
21091
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
21038
21092
|
ref = sch;
|
|
@@ -21602,7 +21656,7 @@ var require_schemes2 = __commonJS2((exports, module) => {
|
|
|
21602
21656
|
var require_fast_uri2 = __commonJS2((exports, module) => {
|
|
21603
21657
|
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
|
|
21604
21658
|
var { SCHEMES, getSchemeHandler } = require_schemes2();
|
|
21605
|
-
function
|
|
21659
|
+
function normalize2(uri, options) {
|
|
21606
21660
|
if (typeof uri === "string") {
|
|
21607
21661
|
uri = normalizeString(uri, options);
|
|
21608
21662
|
} else if (typeof uri === "object") {
|
|
@@ -21610,7 +21664,7 @@ var require_fast_uri2 = __commonJS2((exports, module) => {
|
|
|
21610
21664
|
}
|
|
21611
21665
|
return uri;
|
|
21612
21666
|
}
|
|
21613
|
-
function
|
|
21667
|
+
function resolve4(baseURI, relativeURI, options) {
|
|
21614
21668
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
21615
21669
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
21616
21670
|
schemelessOptions.skipEscape = true;
|
|
@@ -21874,8 +21928,8 @@ var require_fast_uri2 = __commonJS2((exports, module) => {
|
|
|
21874
21928
|
}
|
|
21875
21929
|
var fastUri = {
|
|
21876
21930
|
SCHEMES,
|
|
21877
|
-
normalize,
|
|
21878
|
-
resolve:
|
|
21931
|
+
normalize: normalize2,
|
|
21932
|
+
resolve: resolve4,
|
|
21879
21933
|
resolveComponent,
|
|
21880
21934
|
equal,
|
|
21881
21935
|
serialize,
|
|
@@ -24667,12 +24721,12 @@ var require_isexe = __commonJS2((exports, module) => {
|
|
|
24667
24721
|
if (typeof Promise !== "function") {
|
|
24668
24722
|
throw new TypeError("callback not provided");
|
|
24669
24723
|
}
|
|
24670
|
-
return new Promise(function(
|
|
24724
|
+
return new Promise(function(resolve4, reject) {
|
|
24671
24725
|
isexe(path2, options || {}, function(er, is) {
|
|
24672
24726
|
if (er) {
|
|
24673
24727
|
reject(er);
|
|
24674
24728
|
} else {
|
|
24675
|
-
|
|
24729
|
+
resolve4(is);
|
|
24676
24730
|
}
|
|
24677
24731
|
});
|
|
24678
24732
|
});
|
|
@@ -24732,27 +24786,27 @@ var require_which = __commonJS2((exports, module) => {
|
|
|
24732
24786
|
opt = {};
|
|
24733
24787
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
24734
24788
|
const found = [];
|
|
24735
|
-
const step = (i) => new Promise((
|
|
24789
|
+
const step = (i) => new Promise((resolve4, reject) => {
|
|
24736
24790
|
if (i === pathEnv.length)
|
|
24737
|
-
return opt.all && found.length ?
|
|
24791
|
+
return opt.all && found.length ? resolve4(found) : reject(getNotFoundError(cmd));
|
|
24738
24792
|
const ppRaw = pathEnv[i];
|
|
24739
24793
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
24740
24794
|
const pCmd = path2.join(pathPart, cmd);
|
|
24741
24795
|
const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
24742
|
-
|
|
24796
|
+
resolve4(subStep(p, i, 0));
|
|
24743
24797
|
});
|
|
24744
|
-
const subStep = (p, i, ii) => new Promise((
|
|
24798
|
+
const subStep = (p, i, ii) => new Promise((resolve4, reject) => {
|
|
24745
24799
|
if (ii === pathExt.length)
|
|
24746
|
-
return
|
|
24800
|
+
return resolve4(step(i + 1));
|
|
24747
24801
|
const ext = pathExt[ii];
|
|
24748
24802
|
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
24749
24803
|
if (!er && is) {
|
|
24750
24804
|
if (opt.all)
|
|
24751
24805
|
found.push(p + ext);
|
|
24752
24806
|
else
|
|
24753
|
-
return
|
|
24807
|
+
return resolve4(p + ext);
|
|
24754
24808
|
}
|
|
24755
|
-
return
|
|
24809
|
+
return resolve4(subStep(p, i, ii + 1));
|
|
24756
24810
|
});
|
|
24757
24811
|
});
|
|
24758
24812
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -32773,7 +32827,7 @@ class Protocol {
|
|
|
32773
32827
|
return;
|
|
32774
32828
|
}
|
|
32775
32829
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1000;
|
|
32776
|
-
await new Promise((
|
|
32830
|
+
await new Promise((resolve4) => setTimeout(resolve4, pollInterval));
|
|
32777
32831
|
options?.signal?.throwIfAborted();
|
|
32778
32832
|
}
|
|
32779
32833
|
} catch (error2) {
|
|
@@ -32785,7 +32839,7 @@ class Protocol {
|
|
|
32785
32839
|
}
|
|
32786
32840
|
request(request, resultSchema, options) {
|
|
32787
32841
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
32788
|
-
return new Promise((
|
|
32842
|
+
return new Promise((resolve4, reject) => {
|
|
32789
32843
|
const earlyReject = (error2) => {
|
|
32790
32844
|
reject(error2);
|
|
32791
32845
|
};
|
|
@@ -32863,7 +32917,7 @@ class Protocol {
|
|
|
32863
32917
|
if (!parseResult.success) {
|
|
32864
32918
|
reject(parseResult.error);
|
|
32865
32919
|
} else {
|
|
32866
|
-
|
|
32920
|
+
resolve4(parseResult.data);
|
|
32867
32921
|
}
|
|
32868
32922
|
} catch (error2) {
|
|
32869
32923
|
reject(error2);
|
|
@@ -33054,12 +33108,12 @@ class Protocol {
|
|
|
33054
33108
|
interval = task.pollInterval;
|
|
33055
33109
|
}
|
|
33056
33110
|
} catch {}
|
|
33057
|
-
return new Promise((
|
|
33111
|
+
return new Promise((resolve4, reject) => {
|
|
33058
33112
|
if (signal.aborted) {
|
|
33059
33113
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
33060
33114
|
return;
|
|
33061
33115
|
}
|
|
33062
|
-
const timeoutId = setTimeout(
|
|
33116
|
+
const timeoutId = setTimeout(resolve4, interval);
|
|
33063
33117
|
signal.addEventListener("abort", () => {
|
|
33064
33118
|
clearTimeout(timeoutId);
|
|
33065
33119
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -34166,7 +34220,7 @@ class SSEClientTransport {
|
|
|
34166
34220
|
const baseFetch = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
34167
34221
|
const fetchImpl = this._followRedirects ? baseFetch : fetchWithinOrigin(baseFetch);
|
|
34168
34222
|
let redirect;
|
|
34169
|
-
return new Promise((
|
|
34223
|
+
return new Promise((resolve4, reject) => {
|
|
34170
34224
|
this._eventSource = new EventSource(this._url.href, {
|
|
34171
34225
|
...this._eventSourceInit,
|
|
34172
34226
|
fetch: async (url2, init) => {
|
|
@@ -34188,7 +34242,7 @@ class SSEClientTransport {
|
|
|
34188
34242
|
this._abortController = new AbortController;
|
|
34189
34243
|
this._eventSource.onerror = (event) => {
|
|
34190
34244
|
if (event.code === 401 && this._authProvider) {
|
|
34191
|
-
this._authThenStart().then(
|
|
34245
|
+
this._authThenStart().then(resolve4, reject);
|
|
34192
34246
|
return;
|
|
34193
34247
|
}
|
|
34194
34248
|
const error2 = new SseError(event.code, redirect ?? event.message, event);
|
|
@@ -34209,7 +34263,7 @@ class SSEClientTransport {
|
|
|
34209
34263
|
this.close();
|
|
34210
34264
|
return;
|
|
34211
34265
|
}
|
|
34212
|
-
|
|
34266
|
+
resolve4();
|
|
34213
34267
|
});
|
|
34214
34268
|
this._eventSource.onmessage = (event) => {
|
|
34215
34269
|
const messageEvent = event;
|
|
@@ -34375,7 +34429,7 @@ class StdioClientTransport {
|
|
|
34375
34429
|
if (this._process) {
|
|
34376
34430
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
34377
34431
|
}
|
|
34378
|
-
return new Promise((
|
|
34432
|
+
return new Promise((resolve4, reject) => {
|
|
34379
34433
|
this._process = import_cross_spawn.default(this._serverParams.command, this._serverParams.args ?? [], {
|
|
34380
34434
|
env: {
|
|
34381
34435
|
...getDefaultEnvironment(),
|
|
@@ -34391,7 +34445,7 @@ class StdioClientTransport {
|
|
|
34391
34445
|
this.onerror?.(error2);
|
|
34392
34446
|
});
|
|
34393
34447
|
this._process.on("spawn", () => {
|
|
34394
|
-
|
|
34448
|
+
resolve4();
|
|
34395
34449
|
});
|
|
34396
34450
|
this._process.on("close", (_code) => {
|
|
34397
34451
|
this._process = undefined;
|
|
@@ -34443,20 +34497,20 @@ class StdioClientTransport {
|
|
|
34443
34497
|
if (this._process) {
|
|
34444
34498
|
const processToClose = this._process;
|
|
34445
34499
|
this._process = undefined;
|
|
34446
|
-
const closePromise = new Promise((
|
|
34500
|
+
const closePromise = new Promise((resolve4) => {
|
|
34447
34501
|
processToClose.once("close", () => {
|
|
34448
|
-
|
|
34502
|
+
resolve4();
|
|
34449
34503
|
});
|
|
34450
34504
|
});
|
|
34451
34505
|
try {
|
|
34452
34506
|
processToClose.stdin?.end();
|
|
34453
34507
|
} catch {}
|
|
34454
|
-
await Promise.race([closePromise, new Promise((
|
|
34508
|
+
await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2000).unref())]);
|
|
34455
34509
|
if (processToClose.exitCode === null) {
|
|
34456
34510
|
try {
|
|
34457
34511
|
processToClose.kill("SIGTERM");
|
|
34458
34512
|
} catch {}
|
|
34459
|
-
await Promise.race([closePromise, new Promise((
|
|
34513
|
+
await Promise.race([closePromise, new Promise((resolve4) => setTimeout(resolve4, 2000).unref())]);
|
|
34460
34514
|
}
|
|
34461
34515
|
if (processToClose.exitCode === null) {
|
|
34462
34516
|
try {
|
|
@@ -34467,15 +34521,15 @@ class StdioClientTransport {
|
|
|
34467
34521
|
this._readBuffer.clear();
|
|
34468
34522
|
}
|
|
34469
34523
|
send(message) {
|
|
34470
|
-
return new Promise((
|
|
34524
|
+
return new Promise((resolve4) => {
|
|
34471
34525
|
if (!this._process?.stdin) {
|
|
34472
34526
|
throw new Error("Not connected");
|
|
34473
34527
|
}
|
|
34474
34528
|
const json = serializeMessage(message);
|
|
34475
34529
|
if (this._process.stdin.write(json)) {
|
|
34476
|
-
|
|
34530
|
+
resolve4();
|
|
34477
34531
|
} else {
|
|
34478
|
-
this._process.stdin.once("drain",
|
|
34532
|
+
this._process.stdin.once("drain", resolve4);
|
|
34479
34533
|
}
|
|
34480
34534
|
});
|
|
34481
34535
|
}
|
|
@@ -34896,7 +34950,7 @@ class StreamableHTTPClientTransport {
|
|
|
34896
34950
|
}
|
|
34897
34951
|
var DEFAULT_CLIENT_INFO = {
|
|
34898
34952
|
name: "letta-code",
|
|
34899
|
-
version: "0.34.
|
|
34953
|
+
version: "0.34.27"
|
|
34900
34954
|
};
|
|
34901
34955
|
async function connectMcpServer(config2, options = {}) {
|
|
34902
34956
|
let client = new Client(options.clientInfo ?? DEFAULT_CLIENT_INFO);
|
|
@@ -35924,4 +35978,4 @@ export {
|
|
|
35924
35978
|
CloudManagedSandboxExpiredError
|
|
35925
35979
|
};
|
|
35926
35980
|
|
|
35927
|
-
//# debugId=
|
|
35981
|
+
//# debugId=BCDA341E7F884FDC64756E2164756E21
|