@letta-ai/letta-code 0.10.4 → 0.10.5

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 CHANGED
@@ -1,5 +1,4 @@
1
- #!/bin/sh
2
- ":" //#; exec /usr/bin/env sh -c 'command -v bun >/dev/null && exec bun "$0" "$@" || exec node "$0" "$@"' "$0" "$@"
1
+ #!/usr/bin/env node
3
2
  // @bun
4
3
  import { createRequire } from "node:module";
5
4
  var __create = Object.create;
@@ -3234,7 +3233,7 @@ var package_default;
3234
3233
  var init_package = __esm(() => {
3235
3234
  package_default = {
3236
3235
  name: "@letta-ai/letta-code",
3237
- version: "0.10.4",
3236
+ version: "0.10.5",
3238
3237
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
3239
3238
  type: "module",
3240
3239
  bin: {
@@ -28032,7 +28031,12 @@ var import_react16, useInput = (inputHandler, options = {}) => {
28032
28031
  27: "escape",
28033
28032
  127: "backspace"
28034
28033
  };
28035
- const name = csiUKeyMap[keycode] || "";
28034
+ let name = csiUKeyMap[keycode] || "";
28035
+ if (!name && keycode >= 97 && keycode <= 122) {
28036
+ name = String.fromCharCode(keycode);
28037
+ } else if (!name && keycode >= 65 && keycode <= 90) {
28038
+ name = String.fromCharCode(keycode + 32);
28039
+ }
28036
28040
  if (name) {
28037
28041
  keypress = {
28038
28042
  name,
@@ -51647,7 +51651,17 @@ async function handleHeadlessCommand(argv, model, skillsDirectory) {
51647
51651
  try {
51648
51652
  const run = await client.runs.retrieve(lastRunId);
51649
51653
  const metaError = run.metadata?.error;
51650
- if (metaError?.error_type === "llm_error") {
51654
+ const errorType = metaError?.error_type ?? metaError?.error?.error_type;
51655
+ const detail = metaError?.detail ?? metaError?.error?.detail ?? "";
51656
+ const llmProviderPatterns = [
51657
+ "Anthropic API error",
51658
+ "OpenAI API error",
51659
+ "Google Vertex API error",
51660
+ "overloaded",
51661
+ "api_error"
51662
+ ];
51663
+ const isLlmErrorFromDetail = errorType === "internal_error" && llmProviderPatterns.some((pattern) => detail.includes(pattern));
51664
+ if (errorType === "llm_error" || isLlmErrorFromDetail) {
51651
51665
  const attempt = llmApiErrorRetries + 1;
51652
51666
  const baseDelayMs = 1000;
51653
51667
  const delayMs = baseDelayMs * 2 ** (attempt - 1);
@@ -55496,41 +55510,6 @@ function PasteAwareTextInput({
55496
55510
  insertNewlineAtCursor();
55497
55511
  return;
55498
55512
  }
55499
- {
55500
- const prefix = "\x1B[13;";
55501
- if (sequence.startsWith(prefix) && sequence.endsWith("u")) {
55502
- const mod = sequence.slice(prefix.length, -1);
55503
- if (mod.length === 1 && mod >= "2" && mod <= "8") {
55504
- insertNewlineAtCursor();
55505
- return;
55506
- }
55507
- }
55508
- }
55509
- if (sequence === "\x1B[99;5u") {
55510
- internal_eventEmitter.emit("input", "\x03");
55511
- return;
55512
- }
55513
- if (sequence.startsWith("\x1B[99;5:")) {
55514
- return;
55515
- }
55516
- if (sequence === "\x1B[118;5u") {
55517
- const clip = tryImportClipboardImageMac();
55518
- if (clip) {
55519
- const at = Math.max(0, Math.min(caretOffsetRef.current, displayValueRef.current.length));
55520
- const newDisplay = displayValueRef.current.slice(0, at) + clip + displayValueRef.current.slice(at);
55521
- displayValueRef.current = newDisplay;
55522
- setDisplayValue(newDisplay);
55523
- setActualValue(newDisplay);
55524
- onChangeRef.current(newDisplay);
55525
- const nextCaret = at + clip.length;
55526
- setNudgeCursorOffset(nextCaret);
55527
- caretOffsetRef.current = nextCaret;
55528
- }
55529
- return;
55530
- }
55531
- if (sequence.startsWith("\x1B[118;5:")) {
55532
- return;
55533
- }
55534
55513
  {
55535
55514
  const arrowMatch = sequence.match(/^\x1b\[1;\d+:[12]([ABCD])$/);
55536
55515
  if (arrowMatch) {
@@ -61354,92 +61333,7 @@ var init_dist4 = __esm(async () => {
61354
61333
  });
61355
61334
 
61356
61335
  // src/cli/components/AgentInfoBar.tsx
61357
- function AgentInfoBar({
61358
- agentId,
61359
- agentName,
61360
- serverUrl
61361
- }) {
61362
- const isPinned = import_react41.useMemo(() => {
61363
- if (!agentId)
61364
- return false;
61365
- const localPinned = settingsManager.getLocalPinnedAgents();
61366
- const globalPinned = settingsManager.getGlobalPinnedAgents();
61367
- return localPinned.includes(agentId) || globalPinned.includes(agentId);
61368
- }, [agentId]);
61369
- const isCloudUser = serverUrl?.includes("api.letta.com");
61370
- const showBottomBar = agentId && agentId !== "loading";
61371
- if (!showBottomBar) {
61372
- return null;
61373
- }
61374
- return /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61375
- flexDirection: "column",
61376
- borderStyle: "round",
61377
- borderColor: colors.command.border,
61378
- paddingX: 1,
61379
- children: [
61380
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61381
- children: [
61382
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61383
- bold: true,
61384
- children: agentName || "Unnamed"
61385
- }, undefined, false, undefined, this),
61386
- isPinned ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61387
- color: "green",
61388
- children: " (pinned ✓)"
61389
- }, undefined, false, undefined, this) : agentName === DEFAULT_AGENT_NAME || !agentName ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61390
- color: "gray",
61391
- children: " (type /pin to give your agent a real name!)"
61392
- }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61393
- color: "gray",
61394
- children: " (type /pin to pin agent)"
61395
- }, undefined, false, undefined, this)
61396
- ]
61397
- }, undefined, true, undefined, this),
61398
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61399
- children: [
61400
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61401
- dimColor: true,
61402
- children: agentId
61403
- }, undefined, false, undefined, this),
61404
- isCloudUser && /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(jsx_dev_runtime19.Fragment, {
61405
- children: [
61406
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61407
- dimColor: true,
61408
- children: " · "
61409
- }, undefined, false, undefined, this),
61410
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(dist_default4, {
61411
- url: `https://app.letta.com/agents/${agentId}`,
61412
- children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61413
- color: colors.link.text,
61414
- children: "Open in ADE ↗"
61415
- }, undefined, false, undefined, this)
61416
- }, undefined, false, undefined, this),
61417
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61418
- dimColor: true,
61419
- children: " · "
61420
- }, undefined, false, undefined, this),
61421
- /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(dist_default4, {
61422
- url: "https://app.letta.com/settings/organization/usage",
61423
- children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61424
- color: colors.link.text,
61425
- children: "View usage ↗"
61426
- }, undefined, false, undefined, this)
61427
- }, undefined, false, undefined, this)
61428
- ]
61429
- }, undefined, true, undefined, this),
61430
- !isCloudUser && /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61431
- dimColor: true,
61432
- children: [
61433
- " · ",
61434
- serverUrl
61435
- ]
61436
- }, undefined, true, undefined, this)
61437
- ]
61438
- }, undefined, true, undefined, this)
61439
- ]
61440
- }, undefined, true, undefined, this);
61441
- }
61442
- var import_react41, jsx_dev_runtime19;
61336
+ var import_react41, jsx_dev_runtime19, AgentInfoBar;
61443
61337
  var init_AgentInfoBar = __esm(async () => {
61444
61338
  init_constants();
61445
61339
  init_colors();
@@ -61450,6 +61344,86 @@ var init_AgentInfoBar = __esm(async () => {
61450
61344
  ]);
61451
61345
  import_react41 = __toESM(require_react(), 1);
61452
61346
  jsx_dev_runtime19 = __toESM(require_jsx_dev_runtime(), 1);
61347
+ AgentInfoBar = import_react41.memo(function AgentInfoBar2({
61348
+ agentId,
61349
+ agentName,
61350
+ serverUrl
61351
+ }) {
61352
+ const isPinned = import_react41.useMemo(() => {
61353
+ if (!agentId)
61354
+ return false;
61355
+ const localPinned = settingsManager.getLocalPinnedAgents();
61356
+ const globalPinned = settingsManager.getGlobalPinnedAgents();
61357
+ return localPinned.includes(agentId) || globalPinned.includes(agentId);
61358
+ }, [agentId]);
61359
+ const isCloudUser = serverUrl?.includes("api.letta.com");
61360
+ const showBottomBar = agentId && agentId !== "loading";
61361
+ if (!showBottomBar) {
61362
+ return null;
61363
+ }
61364
+ return /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61365
+ flexDirection: "column",
61366
+ borderStyle: "round",
61367
+ borderColor: colors.command.border,
61368
+ paddingX: 1,
61369
+ children: [
61370
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61371
+ children: [
61372
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61373
+ bold: true,
61374
+ children: agentName || "Unnamed"
61375
+ }, undefined, false, undefined, this),
61376
+ isPinned ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61377
+ color: "green",
61378
+ children: " (pinned ✓)"
61379
+ }, undefined, false, undefined, this) : agentName === DEFAULT_AGENT_NAME || !agentName ? /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61380
+ color: "gray",
61381
+ children: " (type /pin to give your agent a real name!)"
61382
+ }, undefined, false, undefined, this) : /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61383
+ color: "gray",
61384
+ children: " (type /pin to pin agent)"
61385
+ }, undefined, false, undefined, this),
61386
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61387
+ dimColor: true,
61388
+ children: [
61389
+ " · ",
61390
+ agentId
61391
+ ]
61392
+ }, undefined, true, undefined, this)
61393
+ ]
61394
+ }, undefined, true, undefined, this),
61395
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61396
+ children: isCloudUser && /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(jsx_dev_runtime19.Fragment, {
61397
+ children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(dist_default4, {
61398
+ url: `https://app.letta.com/agents/${agentId}`,
61399
+ children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61400
+ children: "Open in ADE ↗ "
61401
+ }, undefined, false, undefined, this)
61402
+ }, undefined, false, undefined, this)
61403
+ }, undefined, false, undefined, this)
61404
+ }, undefined, false, undefined, this),
61405
+ /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Box_default, {
61406
+ children: [
61407
+ isCloudUser && /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(jsx_dev_runtime19.Fragment, {
61408
+ children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(dist_default4, {
61409
+ url: "https://app.letta.com/settings/organization/usage",
61410
+ children: /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61411
+ children: "View usage ↗ "
61412
+ }, undefined, false, undefined, this)
61413
+ }, undefined, false, undefined, this)
61414
+ }, undefined, false, undefined, this),
61415
+ !isCloudUser && /* @__PURE__ */ jsx_dev_runtime19.jsxDEV(Text, {
61416
+ dimColor: true,
61417
+ children: [
61418
+ " · ",
61419
+ serverUrl
61420
+ ]
61421
+ }, undefined, true, undefined, this)
61422
+ ]
61423
+ }, undefined, true, undefined, this)
61424
+ ]
61425
+ }, undefined, true, undefined, this);
61426
+ });
61453
61427
  });
61454
61428
 
61455
61429
  // src/cli/helpers/fileSearch.ts
@@ -61555,6 +61529,7 @@ function useAutocompleteNavigation({
61555
61529
  }) {
61556
61530
  const [selectedIndex, setSelectedIndex] = import_react42.useState(0);
61557
61531
  const prevMatchCountRef = import_react42.useRef(0);
61532
+ const prevIsActiveRef = import_react42.useRef(false);
61558
61533
  import_react42.useEffect(() => {
61559
61534
  if (matches.length !== prevMatchCountRef.current) {
61560
61535
  setSelectedIndex(0);
@@ -61563,7 +61538,11 @@ function useAutocompleteNavigation({
61563
61538
  }, [matches.length]);
61564
61539
  import_react42.useEffect(() => {
61565
61540
  if (manageActiveState) {
61566
- onActiveChange?.(matches.length > 0);
61541
+ const isActive = matches.length > 0;
61542
+ if (isActive !== prevIsActiveRef.current) {
61543
+ prevIsActiveRef.current = isActive;
61544
+ onActiveChange?.(isActive);
61545
+ }
61567
61546
  }
61568
61547
  }, [matches.length, onActiveChange, manageActiveState]);
61569
61548
  use_input_default((_input, key) => {
@@ -69610,7 +69589,21 @@ async function isRetriableError(stopReason, lastRunId) {
69610
69589
  const client = await getClient2();
69611
69590
  const run = await client.runs.retrieve(lastRunId);
69612
69591
  const metaError = run.metadata?.error;
69613
- return metaError?.error_type === "llm_error";
69592
+ const errorType = metaError?.error_type ?? metaError?.error?.error_type;
69593
+ if (errorType === "llm_error")
69594
+ return true;
69595
+ const detail = metaError?.detail ?? metaError?.error?.detail ?? "";
69596
+ const llmProviderPatterns = [
69597
+ "Anthropic API error",
69598
+ "OpenAI API error",
69599
+ "Google Vertex API error",
69600
+ "overloaded",
69601
+ "api_error"
69602
+ ];
69603
+ if (errorType === "internal_error" && llmProviderPatterns.some((pattern) => detail.includes(pattern))) {
69604
+ return true;
69605
+ }
69606
+ return false;
69614
69607
  } catch {
69615
69608
  return false;
69616
69609
  }
@@ -76866,4 +76859,4 @@ Error during initialization: ${message}`);
76866
76859
  }
76867
76860
  main();
76868
76861
 
76869
- //# debugId=170BE8B32E63799C64756E2164756E21
76862
+ //# debugId=A782073D32CB043264756E2164756E21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.10.4",
3
+ "version": "0.10.5",
4
4
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -80,7 +80,15 @@ const useInput = (inputHandler, options = {}) => {
80
80
  127: 'backspace',
81
81
  };
82
82
 
83
- const name = csiUKeyMap[keycode] || '';
83
+ let name = csiUKeyMap[keycode] || '';
84
+
85
+ // Handle letter keycodes (a-z: 97-122, A-Z: 65-90)
86
+ if (!name && keycode >= 97 && keycode <= 122) {
87
+ name = String.fromCharCode(keycode); // lowercase letter
88
+ } else if (!name && keycode >= 65 && keycode <= 90) {
89
+ name = String.fromCharCode(keycode + 32); // convert to lowercase
90
+ }
91
+
84
92
  if (name) {
85
93
  keypress = {
86
94
  name,