@letta-ai/letta-code 0.14.13 → 0.14.14
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/letta.js +82 -50
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -3122,7 +3122,7 @@ var package_default;
|
|
|
3122
3122
|
var init_package = __esm(() => {
|
|
3123
3123
|
package_default = {
|
|
3124
3124
|
name: "@letta-ai/letta-code",
|
|
3125
|
-
version: "0.14.
|
|
3125
|
+
version: "0.14.14",
|
|
3126
3126
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
3127
3127
|
type: "module",
|
|
3128
3128
|
bin: {
|
|
@@ -3355,20 +3355,46 @@ async function mkdir(path2, options) {
|
|
|
3355
3355
|
var init_fs = () => {};
|
|
3356
3356
|
|
|
3357
3357
|
// src/utils/secrets.ts
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3358
|
+
function getErrorMessage(error) {
|
|
3359
|
+
return error instanceof Error ? error.message : String(error);
|
|
3360
|
+
}
|
|
3361
|
+
function isDuplicateKeychainItemError(error) {
|
|
3362
|
+
const message = getErrorMessage(error);
|
|
3363
|
+
return message.includes("already exists in the keychain") || message.includes("code: -25299");
|
|
3364
|
+
}
|
|
3365
|
+
async function setSecretValue(name, value) {
|
|
3366
|
+
if (!secretsAvailable) {
|
|
3367
|
+
throw new Error("Secrets API unavailable");
|
|
3368
|
+
}
|
|
3369
|
+
try {
|
|
3370
|
+
await secrets.set({
|
|
3371
|
+
service: SERVICE_NAME,
|
|
3372
|
+
name,
|
|
3373
|
+
value
|
|
3374
|
+
});
|
|
3375
|
+
return;
|
|
3376
|
+
} catch (error) {
|
|
3377
|
+
if (!isDuplicateKeychainItemError(error)) {
|
|
3378
|
+
throw error;
|
|
3369
3379
|
}
|
|
3370
3380
|
}
|
|
3371
|
-
|
|
3381
|
+
try {
|
|
3382
|
+
await secrets.delete({
|
|
3383
|
+
service: SERVICE_NAME,
|
|
3384
|
+
name
|
|
3385
|
+
});
|
|
3386
|
+
} catch {}
|
|
3387
|
+
await secrets.set({
|
|
3388
|
+
service: SERVICE_NAME,
|
|
3389
|
+
name,
|
|
3390
|
+
value
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
async function setApiKey(apiKey) {
|
|
3394
|
+
if (!secretsAvailable) {
|
|
3395
|
+
throw new Error("Secrets API unavailable");
|
|
3396
|
+
}
|
|
3397
|
+
await setSecretValue(API_KEY_NAME, apiKey);
|
|
3372
3398
|
}
|
|
3373
3399
|
async function getApiKey() {
|
|
3374
3400
|
if (secretsAvailable) {
|
|
@@ -3384,19 +3410,10 @@ async function getApiKey() {
|
|
|
3384
3410
|
return null;
|
|
3385
3411
|
}
|
|
3386
3412
|
async function setRefreshToken(refreshToken) {
|
|
3387
|
-
if (secretsAvailable) {
|
|
3388
|
-
|
|
3389
|
-
await secrets.set({
|
|
3390
|
-
service: SERVICE_NAME,
|
|
3391
|
-
name: REFRESH_TOKEN_NAME,
|
|
3392
|
-
value: refreshToken
|
|
3393
|
-
});
|
|
3394
|
-
return;
|
|
3395
|
-
} catch (error) {
|
|
3396
|
-
console.warn(`Failed to store refresh token in secrets, using fallback: ${error}`);
|
|
3397
|
-
}
|
|
3413
|
+
if (!secretsAvailable) {
|
|
3414
|
+
throw new Error("Secrets API unavailable");
|
|
3398
3415
|
}
|
|
3399
|
-
|
|
3416
|
+
await setSecretValue(REFRESH_TOKEN_NAME, refreshToken);
|
|
3400
3417
|
}
|
|
3401
3418
|
async function getRefreshToken() {
|
|
3402
3419
|
if (secretsAvailable) {
|
|
@@ -3497,6 +3514,9 @@ __export(exports_settings_manager, {
|
|
|
3497
3514
|
});
|
|
3498
3515
|
import { homedir } from "node:os";
|
|
3499
3516
|
import { join } from "node:path";
|
|
3517
|
+
function isSubagentProcess() {
|
|
3518
|
+
return process.env.LETTA_CODE_AGENT_ROLE === "subagent";
|
|
3519
|
+
}
|
|
3500
3520
|
function normalizeBaseUrl(baseUrl) {
|
|
3501
3521
|
let normalized = baseUrl.replace(/^https?:\/\//, "");
|
|
3502
3522
|
normalized = normalized.replace(/\/$/, "");
|
|
@@ -3529,14 +3549,18 @@ class SettingsManager {
|
|
|
3529
3549
|
}
|
|
3530
3550
|
this.initialized = true;
|
|
3531
3551
|
await this.checkSecretsSupport();
|
|
3532
|
-
|
|
3552
|
+
if (!isSubagentProcess()) {
|
|
3553
|
+
await this.migrateTokensToSecrets();
|
|
3554
|
+
}
|
|
3533
3555
|
this.migrateToAgentsArray();
|
|
3534
3556
|
} catch (error) {
|
|
3535
3557
|
console.error("Error loading settings, using defaults:", error);
|
|
3536
3558
|
this.settings = { ...DEFAULT_SETTINGS };
|
|
3537
3559
|
this.initialized = true;
|
|
3538
3560
|
await this.checkSecretsSupport();
|
|
3539
|
-
|
|
3561
|
+
if (!isSubagentProcess()) {
|
|
3562
|
+
await this.migrateTokensToSecrets();
|
|
3563
|
+
}
|
|
3540
3564
|
this.migrateToAgentsArray();
|
|
3541
3565
|
}
|
|
3542
3566
|
}
|
|
@@ -5704,7 +5728,7 @@ Some blocks are read-only in the API (e.g., certain system-managed blocks). For
|
|
|
5704
5728
|
var init_system_prompt_memfs = () => {};
|
|
5705
5729
|
|
|
5706
5730
|
// src/utils/error.ts
|
|
5707
|
-
function
|
|
5731
|
+
function getErrorMessage2(error) {
|
|
5708
5732
|
return error instanceof Error ? error.message : String(error);
|
|
5709
5733
|
}
|
|
5710
5734
|
|
|
@@ -6919,7 +6943,7 @@ function getBuiltinSubagents() {
|
|
|
6919
6943
|
const config = parseSubagentContent(source);
|
|
6920
6944
|
builtins[config.name] = config;
|
|
6921
6945
|
} catch (error) {
|
|
6922
|
-
console.warn(`[subagent] Failed to parse built-in subagent: ${
|
|
6946
|
+
console.warn(`[subagent] Failed to parse built-in subagent: ${getErrorMessage2(error)}`);
|
|
6923
6947
|
}
|
|
6924
6948
|
}
|
|
6925
6949
|
cache.builtins = builtins;
|
|
@@ -6954,14 +6978,14 @@ async function discoverSubagentsFromDir(agentsDir, seenNames, subagents, errors)
|
|
|
6954
6978
|
} catch (error) {
|
|
6955
6979
|
errors.push({
|
|
6956
6980
|
path: filePath,
|
|
6957
|
-
message:
|
|
6981
|
+
message: getErrorMessage2(error)
|
|
6958
6982
|
});
|
|
6959
6983
|
}
|
|
6960
6984
|
}
|
|
6961
6985
|
} catch (error) {
|
|
6962
6986
|
errors.push({
|
|
6963
6987
|
path: agentsDir,
|
|
6964
|
-
message: `Failed to read agents directory: ${
|
|
6988
|
+
message: `Failed to read agents directory: ${getErrorMessage2(error)}`
|
|
6965
6989
|
});
|
|
6966
6990
|
}
|
|
6967
6991
|
}
|
|
@@ -54693,7 +54717,7 @@ function parseResultFromStdout(stdout, agentId) {
|
|
|
54693
54717
|
agentId: agentId || "",
|
|
54694
54718
|
report: "",
|
|
54695
54719
|
success: false,
|
|
54696
|
-
error: `Failed to parse subagent output: ${
|
|
54720
|
+
error: `Failed to parse subagent output: ${getErrorMessage2(parseError)}`
|
|
54697
54721
|
};
|
|
54698
54722
|
}
|
|
54699
54723
|
}
|
|
@@ -54867,7 +54891,7 @@ async function executeSubagent(type, config, model, userPrompt, baseURL, subagen
|
|
|
54867
54891
|
agentId: "",
|
|
54868
54892
|
report: "",
|
|
54869
54893
|
success: false,
|
|
54870
|
-
error:
|
|
54894
|
+
error: getErrorMessage2(error)
|
|
54871
54895
|
};
|
|
54872
54896
|
}
|
|
54873
54897
|
}
|
|
@@ -60957,7 +60981,7 @@ function getBuiltinSubagents2() {
|
|
|
60957
60981
|
const config = parseSubagentContent2(source);
|
|
60958
60982
|
builtins[config.name] = config;
|
|
60959
60983
|
} catch (error) {
|
|
60960
|
-
console.warn(`[subagent] Failed to parse built-in subagent: ${
|
|
60984
|
+
console.warn(`[subagent] Failed to parse built-in subagent: ${getErrorMessage2(error)}`);
|
|
60961
60985
|
}
|
|
60962
60986
|
}
|
|
60963
60987
|
cache5.builtins = builtins;
|
|
@@ -60992,14 +61016,14 @@ async function discoverSubagentsFromDir2(agentsDir, seenNames, subagents, errors
|
|
|
60992
61016
|
} catch (error) {
|
|
60993
61017
|
errors.push({
|
|
60994
61018
|
path: filePath,
|
|
60995
|
-
message:
|
|
61019
|
+
message: getErrorMessage2(error)
|
|
60996
61020
|
});
|
|
60997
61021
|
}
|
|
60998
61022
|
}
|
|
60999
61023
|
} catch (error) {
|
|
61000
61024
|
errors.push({
|
|
61001
61025
|
path: agentsDir,
|
|
61002
|
-
message: `Failed to read agents directory: ${
|
|
61026
|
+
message: `Failed to read agents directory: ${getErrorMessage2(error)}`
|
|
61003
61027
|
});
|
|
61004
61028
|
}
|
|
61005
61029
|
}
|
|
@@ -91148,7 +91172,7 @@ Your ChatGPT Plus/Pro subscription is now linked.`, true, "finished");
|
|
|
91148
91172
|
}
|
|
91149
91173
|
} catch (error) {
|
|
91150
91174
|
settingsManager.clearOAuthState();
|
|
91151
|
-
const errorMessage =
|
|
91175
|
+
const errorMessage = getErrorMessage2(error);
|
|
91152
91176
|
let displayMessage;
|
|
91153
91177
|
if (errorMessage === "PLAN_UPGRADE_REQUIRED") {
|
|
91154
91178
|
displayMessage = `✗ ChatGPT OAuth requires a Pro or Enterprise plan
|
|
@@ -91184,7 +91208,7 @@ Use /connect minimax <api_key> to connect.`, false);
|
|
|
91184
91208
|
|
|
91185
91209
|
` + `Provider '${MINIMAX_PROVIDER_NAME}' removed from Letta.`, true, "finished");
|
|
91186
91210
|
} catch (error) {
|
|
91187
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from MiniMax: ${
|
|
91211
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from MiniMax: ${getErrorMessage2(error)}`, false, "finished");
|
|
91188
91212
|
} finally {
|
|
91189
91213
|
ctx.setCommandRunning(false);
|
|
91190
91214
|
}
|
|
@@ -91205,7 +91229,7 @@ Use /connect and select "AWS Bedrock" to connect.`, false);
|
|
|
91205
91229
|
|
|
91206
91230
|
` + `Provider '${BEDROCK_PROVIDER_NAME}' removed from Letta.`, true, "finished");
|
|
91207
91231
|
} catch (error) {
|
|
91208
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Bedrock: ${
|
|
91232
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Bedrock: ${getErrorMessage2(error)}`, false, "finished");
|
|
91209
91233
|
} finally {
|
|
91210
91234
|
ctx.setCommandRunning(false);
|
|
91211
91235
|
}
|
|
@@ -91231,7 +91255,7 @@ Example: /connect minimax <api_key>...`, false);
|
|
|
91231
91255
|
|
|
91232
91256
|
` + `The models are populated in /model → "All Available Models"`, true, "finished");
|
|
91233
91257
|
} catch (error) {
|
|
91234
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create MiniMax provider: ${
|
|
91258
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create MiniMax provider: ${getErrorMessage2(error)}`, false, "finished");
|
|
91235
91259
|
} finally {
|
|
91236
91260
|
ctx.setCommandRunning(false);
|
|
91237
91261
|
}
|
|
@@ -91298,7 +91322,7 @@ Use /connect codex to authenticate.`, false);
|
|
|
91298
91322
|
|
|
91299
91323
|
` + `Provider '${OPENAI_CODEX_PROVIDER_NAME}' removed from Letta.`, true, "finished");
|
|
91300
91324
|
} catch (error) {
|
|
91301
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from ChatGPT: ${
|
|
91325
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from ChatGPT: ${getErrorMessage2(error)}`, false, "finished");
|
|
91302
91326
|
} finally {
|
|
91303
91327
|
ctx.setCommandRunning(false);
|
|
91304
91328
|
}
|
|
@@ -91326,7 +91350,7 @@ The '${CLAUDE_PROVIDER_NAME}' provider does not exist in your Letta account.`, f
|
|
|
91326
91350
|
|
|
91327
91351
|
Note: /connect claude has been replaced with /connect codex for OpenAI ChatGPT Plus/Pro.`, true, "finished");
|
|
91328
91352
|
} catch (error) {
|
|
91329
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Claude: ${
|
|
91353
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Claude: ${getErrorMessage2(error)}`, false, "finished");
|
|
91330
91354
|
} finally {
|
|
91331
91355
|
ctx.setCommandRunning(false);
|
|
91332
91356
|
}
|
|
@@ -91347,7 +91371,7 @@ Use /connect zai <api_key> to connect.`, false);
|
|
|
91347
91371
|
|
|
91348
91372
|
` + `Provider '${ZAI_PROVIDER_NAME}' removed from Letta.`, true, "finished");
|
|
91349
91373
|
} catch (error) {
|
|
91350
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Zai: ${
|
|
91374
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from Zai: ${getErrorMessage2(error)}`, false, "finished");
|
|
91351
91375
|
} finally {
|
|
91352
91376
|
ctx.setCommandRunning(false);
|
|
91353
91377
|
}
|
|
@@ -91373,7 +91397,7 @@ Example: /connect zai <api_key>...`, false);
|
|
|
91373
91397
|
|
|
91374
91398
|
` + `The models are populated in /model → "All Available Models"`, true, "finished");
|
|
91375
91399
|
} catch (error) {
|
|
91376
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create Zai provider: ${
|
|
91400
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create Zai provider: ${getErrorMessage2(error)}`, false, "finished");
|
|
91377
91401
|
} finally {
|
|
91378
91402
|
ctx.setCommandRunning(false);
|
|
91379
91403
|
}
|
|
@@ -91401,7 +91425,7 @@ Example: /connect openrouter sk-or-v1-...`, false);
|
|
|
91401
91425
|
|
|
91402
91426
|
` + `The models are populated in /model → "All Available Models"`, true, "finished");
|
|
91403
91427
|
} catch (error) {
|
|
91404
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create OpenRouter provider: ${
|
|
91428
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to create OpenRouter provider: ${getErrorMessage2(error)}`, false, "finished");
|
|
91405
91429
|
} finally {
|
|
91406
91430
|
ctx.setCommandRunning(false);
|
|
91407
91431
|
}
|
|
@@ -91422,7 +91446,7 @@ Use /connect openrouter <api_key> to connect.`, false);
|
|
|
91422
91446
|
|
|
91423
91447
|
` + `Provider '${OPENROUTER_PROVIDER_NAME}' removed from Letta.`, true, "finished");
|
|
91424
91448
|
} catch (error) {
|
|
91425
|
-
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from OpenRouter: ${
|
|
91449
|
+
updateCommandResult3(ctx.buffersRef, ctx.refreshDerived, cmdId, msg, `✗ Failed to disconnect from OpenRouter: ${getErrorMessage2(error)}`, false, "finished");
|
|
91426
91450
|
} finally {
|
|
91427
91451
|
ctx.setCommandRunning(false);
|
|
91428
91452
|
}
|
|
@@ -102181,6 +102205,9 @@ var DEFAULT_LOCAL_PROJECT_SETTINGS2 = {
|
|
|
102181
102205
|
lastAgent: null
|
|
102182
102206
|
};
|
|
102183
102207
|
var DEFAULT_LETTA_API_URL2 = "https://api.letta.com";
|
|
102208
|
+
function isSubagentProcess2() {
|
|
102209
|
+
return process.env.LETTA_CODE_AGENT_ROLE === "subagent";
|
|
102210
|
+
}
|
|
102184
102211
|
function normalizeBaseUrl2(baseUrl) {
|
|
102185
102212
|
let normalized = baseUrl.replace(/^https?:\/\//, "");
|
|
102186
102213
|
normalized = normalized.replace(/\/$/, "");
|
|
@@ -102213,14 +102240,18 @@ class SettingsManager2 {
|
|
|
102213
102240
|
}
|
|
102214
102241
|
this.initialized = true;
|
|
102215
102242
|
await this.checkSecretsSupport();
|
|
102216
|
-
|
|
102243
|
+
if (!isSubagentProcess2()) {
|
|
102244
|
+
await this.migrateTokensToSecrets();
|
|
102245
|
+
}
|
|
102217
102246
|
this.migrateToAgentsArray();
|
|
102218
102247
|
} catch (error) {
|
|
102219
102248
|
console.error("Error loading settings, using defaults:", error);
|
|
102220
102249
|
this.settings = { ...DEFAULT_SETTINGS2 };
|
|
102221
102250
|
this.initialized = true;
|
|
102222
102251
|
await this.checkSecretsSupport();
|
|
102223
|
-
|
|
102252
|
+
if (!isSubagentProcess2()) {
|
|
102253
|
+
await this.migrateTokensToSecrets();
|
|
102254
|
+
}
|
|
102224
102255
|
this.migrateToAgentsArray();
|
|
102225
102256
|
}
|
|
102226
102257
|
}
|
|
@@ -103750,7 +103781,8 @@ Auto-update failed due to filesystem issue (ENOTEMPTY).`);
|
|
|
103750
103781
|
sleeptime: { type: "boolean" },
|
|
103751
103782
|
"from-af": { type: "string" },
|
|
103752
103783
|
memfs: { type: "boolean" },
|
|
103753
|
-
"no-memfs": { type: "boolean" }
|
|
103784
|
+
"no-memfs": { type: "boolean" },
|
|
103785
|
+
"max-turns": { type: "string" }
|
|
103754
103786
|
},
|
|
103755
103787
|
strict: true,
|
|
103756
103788
|
allowPositionals: true
|
|
@@ -104777,4 +104809,4 @@ Error during initialization: ${message}`);
|
|
|
104777
104809
|
}
|
|
104778
104810
|
main();
|
|
104779
104811
|
|
|
104780
|
-
//# debugId=
|
|
104812
|
+
//# debugId=8B604F61633624E964756E2164756E21
|