@letta-ai/letta-code 0.34.74 → 0.34.76

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
@@ -6156,7 +6156,7 @@ var package_default;
6156
6156
  var init_package = __esm(() => {
6157
6157
  package_default = {
6158
6158
  name: "@letta-ai/letta-code",
6159
- version: "0.34.74",
6159
+ version: "0.34.76",
6160
6160
  lettaStartupLogProtocol: 1,
6161
6161
  lettaConfigDirProtocol: 1,
6162
6162
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
@@ -6410,7 +6410,7 @@ var init_package = __esm(() => {
6410
6410
  },
6411
6411
  lettaLifecycleProtocol: 1,
6412
6412
  lettaRuntimeGraphProtocol: 1,
6413
- lettaRuntimeGraphSha512: "sha512-A9722B8R/W8jbb1l8M1paZcN1TkORcpTNLsAtQ1nKQN/zXjuCAQQBHUZvX5bXzbxg0QScb3/U1xqNCtyNsd5sQ==",
6413
+ lettaRuntimeGraphSha512: "sha512-K0fGAAQKChkUuniz2QJadssvSJdREgANwvR1Kth6SCY7C/K+Coy7HMTuON5QpKHfrpxekJWRMWG55yORzW/7uA==",
6414
6414
  patchedDependencies: {
6415
6415
  "@earendil-works/pi-ai@1.6.0": "patches/@earendil-works%2Fpi-ai@1.6.0.patch"
6416
6416
  }
@@ -212280,7 +212280,7 @@ var init_mcp_client = __esm(() => {
212280
212280
  init_streamableHttp();
212281
212281
  DEFAULT_CLIENT_INFO = {
212282
212282
  name: "letta-code",
212283
- version: "0.34.74"
212283
+ version: "0.34.76"
212284
212284
  };
212285
212285
  });
212286
212286
 
@@ -238756,9 +238756,13 @@ function enqueueInboundUserMessage(runtime, incoming, actingUserId, options = {}
238756
238756
  if (!enqueuedItem) {
238757
238757
  return false;
238758
238758
  }
238759
+ markLocalTurnScope(runtime);
238759
238760
  runtime.queuedMessagesByItemId.set(enqueuedItem.id, incoming);
238760
238761
  return true;
238761
238762
  }
238763
+ var init_inbound_queue = __esm(() => {
238764
+ init_runtime6();
238765
+ });
238762
238766
 
238763
238767
  // src/websocket/listener/turn-correlation.ts
238764
238768
  function takeDequeuedClientMessageIds(runtime, batchId) {
@@ -238827,6 +238831,7 @@ function createTurnCorrelation(runtime, message, batchId) {
238827
238831
  }
238828
238832
  var MAX_CLIENT_MESSAGE_IDS_PER_RUN = 32, MAX_RECENT_RUN_CORRELATIONS = 32, MAX_RECENT_CONVERSATIONS = 256;
238829
238833
  var init_turn_correlation = __esm(() => {
238834
+ init_inbound_queue();
238830
238835
  init_runtime6();
238831
238836
  });
238832
238837
 
@@ -244122,6 +244127,47 @@ var init_monitor_event_stream = __esm(() => {
244122
244127
  MONITOR_EVENT_BUFFER_CHARS = 1024 * 1024;
244123
244128
  });
244124
244129
 
244130
+ // src/tools/impl/monitor-pr-hint.ts
244131
+ function prUrl(repo, number6) {
244132
+ return `https://github.com/${repo}/pull/${number6}`;
244133
+ }
244134
+ function monitorPullRequestHint(command) {
244135
+ let url2;
244136
+ let matched = false;
244137
+ const api2 = command.match(GH_API_PULL);
244138
+ if (api2?.[1] && api2[2]) {
244139
+ matched = true;
244140
+ url2 = prUrl(api2[1], api2[2]);
244141
+ }
244142
+ const pr = matched ? null : command.match(GH_PR_SUBCOMMAND);
244143
+ if (pr) {
244144
+ const args = pr[1] ?? "";
244145
+ const direct = args.match(PR_URL);
244146
+ const number6 = args.match(PR_NUMBER_ARG)?.[1];
244147
+ const repo = pr[0].match(REPO_FLAG)?.[1];
244148
+ matched = true;
244149
+ if (direct?.[1] && direct[2])
244150
+ url2 = prUrl(direct[1], direct[2]);
244151
+ else if (number6 && repo)
244152
+ url2 = prUrl(repo, number6);
244153
+ }
244154
+ if (!matched && GH_PR_STATUS.test(command))
244155
+ matched = true;
244156
+ if (!matched)
244157
+ return;
244158
+ const target = url2 ?? "that pull request";
244159
+ return `This command polls a GitHub pull request. WatchPR also reports reviews, comments, conflicts and pushes; stop this monitor with TaskStop and call WatchPR on ${target} instead.`;
244160
+ }
244161
+ var REPO_FLAG, PR_URL, GH_PR_SUBCOMMAND, PR_NUMBER_ARG, GH_PR_STATUS, GH_API_PULL;
244162
+ var init_monitor_pr_hint = __esm(() => {
244163
+ REPO_FLAG = /(?:^|\s)(?:-R|--repo)(?:\s+|=)["']?([\w.-]+\/[\w.-]+)/;
244164
+ PR_URL = /https?:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/;
244165
+ GH_PR_SUBCOMMAND = /\bgh\b[^\n;|&]*?\bpr\s+(?:view|checks)\b([^\n;|&)]*)/;
244166
+ PR_NUMBER_ARG = /(?:^|\s)["']?#?(\d+)(?=["']?(?:\s|$))/;
244167
+ GH_PR_STATUS = /\bgh\s+pr\s+status\b/;
244168
+ GH_API_PULL = /\bgh\s+api\b[^\n;|&]*?\brepos\/([\w.-]+\/[\w.-]+)\/pulls\/(\d+)\b/;
244169
+ });
244170
+
244125
244171
  // src/tools/impl/monitor-result.ts
244126
244172
  function buildMonitorResult(taskId, timeoutMs, persistent, outputFile) {
244127
244173
  const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
@@ -245475,20 +245521,24 @@ async function monitor(args) {
245475
245521
  const sourceArgs = { ...normalized, taskId };
245476
245522
  return normalized.script !== undefined ? startScriptSource(sourceArgs) : normalized.command !== undefined ? startCommandMonitor(sourceArgs) : startWebSocketMonitor(sourceArgs);
245477
245523
  });
245478
- if (normalized.backup_after_seconds === undefined)
245479
- return result3;
245480
- const note = await armMonitorBackup({
245481
- taskId: result3.taskId,
245482
- description: normalized.description,
245483
- afterSeconds: normalized.backup_after_seconds,
245484
- prompt: normalized.backup_prompt,
245485
- scope: backupScopeFor(result3.taskId),
245486
- isRunning: () => backgroundProcesses.get(result3.taskId)?.status === "running"
245487
- });
245524
+ const notes = [];
245525
+ if (normalized.backup_after_seconds !== undefined) {
245526
+ notes.push(await armMonitorBackup({
245527
+ taskId: result3.taskId,
245528
+ description: normalized.description,
245529
+ afterSeconds: normalized.backup_after_seconds,
245530
+ prompt: normalized.backup_prompt,
245531
+ scope: backupScopeFor(result3.taskId),
245532
+ isRunning: () => backgroundProcesses.get(result3.taskId)?.status === "running"
245533
+ }));
245534
+ }
245535
+ const prHint = monitorPullRequestHint(normalized.command ?? normalized.script ?? "");
245536
+ if (prHint)
245537
+ notes.push(prHint);
245488
245538
  const first = result3.content[0];
245489
- if (first)
245490
- first.text = `${first.text}
245491
- ${note}`;
245539
+ if (first && notes.length > 0)
245540
+ first.text = [first.text, ...notes].join(`
245541
+ `);
245492
245542
  return result3;
245493
245543
  }
245494
245544
  function stopMonitorOnShutdown(processState) {
@@ -245540,6 +245590,7 @@ var init_monitor = __esm(() => {
245540
245590
  init_bash();
245541
245591
  init_monitor_backup();
245542
245592
  init_monitor_event_stream();
245593
+ init_monitor_pr_hint();
245543
245594
  init_monitor_resume();
245544
245595
  init_monitor_script();
245545
245596
  init_monitor_state();
@@ -251033,7 +251084,7 @@ class CodexAppServerClient {
251033
251084
  await this.request("initialize", {
251034
251085
  clientInfo: {
251035
251086
  name: "letta-code",
251036
- version: "0.34.74"
251087
+ version: "0.34.76"
251037
251088
  },
251038
251089
  capabilities: null
251039
251090
  });
@@ -263786,7 +263837,7 @@ function recordedToolResults(record5, pendingToolCallIds) {
263786
263837
  type: "approval",
263787
263838
  tool_call_id: id,
263788
263839
  approve: false,
263789
- reason: STALE_APPROVAL_RECOVERY_DENIAL_REASON
263840
+ reason: record5.toolCallIds.includes(id) && record5.unstartedToolCallIds?.includes(id) === false ? STARTED_TOOL_CALL_RECOVERY_DENIAL_REASON : STALE_APPROVAL_RECOVERY_DENIAL_REASON
263790
263841
  });
263791
263842
  }
263792
263843
  var init_recorded_tool_results = __esm(() => {
@@ -265252,6 +265303,9 @@ __export(exports_runtime, {
265252
265303
  setActiveRuntime: () => setActiveRuntime,
265253
265304
  safeEmitWsEvent: () => safeEmitWsEvent,
265254
265305
  nextEventSeq: () => nextEventSeq,
265306
+ markSidebandOnlyScope: () => markSidebandOnlyScope,
265307
+ markLocalTurnScope: () => markLocalTurnScope,
265308
+ isSidebandOnlyScope: () => isSidebandOnlyScope,
265255
265309
  invalidateExternalToolNotifications: () => invalidateExternalToolNotifications,
265256
265310
  hasInterruptedCacheForScope: () => hasInterruptedCacheForScope,
265257
265311
  getRuntimeAuthorityEpoch: () => getRuntimeAuthorityEpoch,
@@ -265409,6 +265463,20 @@ function getConversationRuntimeKey(agentId, conversationId) {
265409
265463
  const normalizedAgentId = normalizeCwdAgentId(agentId);
265410
265464
  return `agent:${normalizedAgentId ?? "__unknown__"}::conversation:${normalizedConversationId}`;
265411
265465
  }
265466
+ function isSidebandOnlyScope(listener, key4) {
265467
+ return sidebandScopesByListener.get(listener)?.has(key4) ?? false;
265468
+ }
265469
+ function markSidebandOnlyScope(listener, key4) {
265470
+ let scopes = sidebandScopesByListener.get(listener);
265471
+ if (!scopes) {
265472
+ scopes = new Set;
265473
+ sidebandScopesByListener.set(listener, scopes);
265474
+ }
265475
+ scopes.add(key4);
265476
+ }
265477
+ function markLocalTurnScope(runtime) {
265478
+ sidebandScopesByListener.get(runtime.listener)?.delete(runtime.key);
265479
+ }
265412
265480
  function createConversationRuntime(listener, agentId, conversationId) {
265413
265481
  const normalizedAgentId = normalizeCwdAgentId(agentId);
265414
265482
  const normalizedConversationId = normalizeConversationId(conversationId);
@@ -265591,7 +265659,7 @@ function hasInterruptedCacheForScope(runtime, params) {
265591
265659
  function getPendingControlRequestCount(runtime, params) {
265592
265660
  return getPendingControlRequests(runtime, params).length;
265593
265661
  }
265594
- var activeRuntime = null, activeRuntimeAuthorityEpoch = 0, authorityEpochByRuntime, WORKTREE_WATCHER_IDLE_STOP_MS, watcherIdleStopsByListener, __watcherIdleStopTestUtils;
265662
+ var activeRuntime = null, activeRuntimeAuthorityEpoch = 0, authorityEpochByRuntime, WORKTREE_WATCHER_IDLE_STOP_MS, watcherIdleStopsByListener, __watcherIdleStopTestUtils, sidebandScopesByListener;
265595
265663
  var init_runtime6 = __esm(() => {
265596
265664
  init_ws_event_redaction();
265597
265665
  init_background_process_snapshot();
@@ -265616,6 +265684,7 @@ var init_runtime6 = __esm(() => {
265616
265684
  return watcherIdleStopsByListener.get(listener)?.has(scopeKey2) ?? false;
265617
265685
  }
265618
265686
  };
265687
+ sidebandScopesByListener = new WeakMap;
265619
265688
  });
265620
265689
 
265621
265690
  // src/websocket/listener/startup-frame-buffer.ts
@@ -268831,6 +268900,7 @@ var init_queue = __esm(() => {
268831
268900
  init_debug();
268832
268901
  init_connection();
268833
268902
  init_image_policy();
268903
+ init_inbound_queue();
268834
268904
  init_protocol_outbound();
268835
268905
  init_runtime6();
268836
268906
  init_transport2();
@@ -269420,6 +269490,7 @@ var discardQueuedItem = (runtime, item) => {
269420
269490
  var init_conversation_runtime = __esm(() => {
269421
269491
  init_queue_runtime();
269422
269492
  init_debug();
269493
+ init_inbound_queue();
269423
269494
  init_input_disposition();
269424
269495
  init_input_disposition_retention();
269425
269496
  init_input_terminal_journal();
@@ -269634,24 +269705,24 @@ async function fireCronTask(task2, timing2, socket, opts, processQueuedTurn, tri
269634
269705
  });
269635
269706
  return false;
269636
269707
  }
269637
- const rawRuntime = getOrCreateConversationRuntime(listener, task2.agent_id, targetConversationId);
269638
- if (!rawRuntime) {
269708
+ if (isSidebandOnlyScope(listener, getConversationRuntimeKey(task2.agent_id, targetConversationId))) {
269639
269709
  setLastRunOutcome(task2.id, {
269640
269710
  outcome: "failed",
269641
269711
  reason: "runtime_unavailable",
269642
269712
  runAt: timing2.schedulerNow,
269643
- error: "Conversation runtime unavailable"
269713
+ error: "Conversation is only held for remote worker control"
269644
269714
  });
269645
269715
  safeAppendCronRunLogForTask(task2, {
269646
269716
  status: "error",
269647
269717
  outcome: "failed",
269648
269718
  reason: "runtime_unavailable",
269649
- error: "Conversation runtime unavailable",
269719
+ error: "Conversation is only held for remote worker control",
269650
269720
  runAtMs: timing2.schedulerNow.getTime(),
269651
269721
  scheduledFor: task2.scheduled_for
269652
269722
  });
269653
269723
  return false;
269654
269724
  }
269725
+ const rawRuntime = getOrCreateConversationRuntime(listener, task2.agent_id, targetConversationId);
269655
269726
  const conversationRuntime = ensureConversationQueueRuntime(listener, rawRuntime);
269656
269727
  if (trigger === "automatic" && getTask(task2.id)?.status !== "active") {
269657
269728
  return false;
@@ -274006,6 +274077,48 @@ var init_approval = __esm(() => {
274006
274077
  init_turn_status();
274007
274078
  });
274008
274079
 
274080
+ // src/tools/interactive-policy.ts
274081
+ var INTERACTIVE_USER_INPUT_TOOL_NAMES;
274082
+ var init_interactive_policy = __esm(() => {
274083
+ INTERACTIVE_USER_INPUT_TOOL_NAMES = [
274084
+ "AskUserQuestionAsync"
274085
+ ];
274086
+ });
274087
+
274088
+ // src/tools/tool-policy.ts
274089
+ function intersectToolAllowlists(ceiling, narrower) {
274090
+ return narrower.filter((name) => ceiling.some((allowed) => getInternalToolName(allowed) === getInternalToolName(name)));
274091
+ }
274092
+ function resolveTurnToolSelection(turn, policy) {
274093
+ const base2 = turn.clientToolset?.base ?? policy?.toolset?.base;
274094
+ const include = turn.clientToolset?.include ?? policy?.toolset?.include;
274095
+ const clientToolset = base2 === undefined && include === undefined ? undefined : {
274096
+ ...base2 !== undefined ? { base: base2 } : {},
274097
+ ...include !== undefined ? { include: [...include] } : {}
274098
+ };
274099
+ const policyAllowlist = policy?.allowlist;
274100
+ const clientToolAllowlist = policyAllowlist === undefined ? turn.clientToolAllowlist : turn.clientToolAllowlist === undefined ? [...policyAllowlist] : intersectToolAllowlists(policyAllowlist, turn.clientToolAllowlist);
274101
+ const excludeInteractiveTools = turn.excludeInteractiveTools ?? policy?.exclude_interactive;
274102
+ return {
274103
+ ...clientToolset ? { clientToolset } : {},
274104
+ ...clientToolAllowlist !== undefined ? { clientToolAllowlist } : {},
274105
+ ...excludeInteractiveTools !== undefined ? { excludeInteractiveTools } : {}
274106
+ };
274107
+ }
274108
+ function mergeClientToolsetFields(primary, fallback) {
274109
+ const base2 = primary?.base ?? fallback?.base;
274110
+ const include = primary?.include ?? fallback?.include;
274111
+ if (base2 === undefined && include === undefined)
274112
+ return;
274113
+ return {
274114
+ ...base2 !== undefined ? { base: base2 } : {},
274115
+ ...include !== undefined ? { include } : {}
274116
+ };
274117
+ }
274118
+ var init_tool_policy = __esm(() => {
274119
+ init_tool_name_mapping();
274120
+ });
274121
+
274009
274122
  // src/websocket/listener/external-tools.ts
274010
274123
  function createExternalToolNotificationState() {
274011
274124
  return {
@@ -274288,6 +274401,17 @@ function resolveRuntimeToolOwner(runtime, runtimeScope, submittingConnectionId)
274288
274401
  ...owner.toolPolicy ? { toolPolicy: owner.toolPolicy } : {}
274289
274402
  };
274290
274403
  }
274404
+ function resolveRuntimeToolContextOptions(runtime, scope, connectionId, overrides = {}) {
274405
+ const owner = resolveRuntimeToolOwner(runtime, scope, connectionId);
274406
+ const selection = resolveTurnToolSelection(overrides, owner.toolPolicy);
274407
+ return {
274408
+ externalToolOwnerConnectionId: owner.connectionId,
274409
+ clientToolset: selection.clientToolset,
274410
+ clientToolAllowlist: selection.clientToolAllowlist,
274411
+ ...selection.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
274412
+ foregroundYieldMs: owner.toolPolicy?.foreground_yield_ms
274413
+ };
274414
+ }
274291
274415
  function updateRuntimeExternalTools(runtime, connectionId, updates) {
274292
274416
  for (const update2 of updates) {
274293
274417
  for (const runtimeScope of update2.runtimes) {
@@ -274387,7 +274511,9 @@ var EXTERNAL_TOOL_CALL_TIMEOUT_MS, registeredToolsByRuntime, lastSubmittingConne
274387
274511
  var init_external_tools = __esm(() => {
274388
274512
  init_external_tool_background_eligibility();
274389
274513
  init_foreground_yield();
274514
+ init_interactive_policy();
274390
274515
  init_manager2();
274516
+ init_tool_policy();
274391
274517
  init_debug();
274392
274518
  init_connection();
274393
274519
  init_runtime6();
@@ -279063,40 +279189,6 @@ var init_stream2 = __esm(() => {
279063
279189
  init_stream_terminal_eof_guard();
279064
279190
  });
279065
279191
 
279066
- // src/tools/tool-policy.ts
279067
- function intersectToolAllowlists(ceiling, narrower) {
279068
- return narrower.filter((name) => ceiling.some((allowed) => getInternalToolName(allowed) === getInternalToolName(name)));
279069
- }
279070
- function resolveTurnToolSelection(turn, policy) {
279071
- const base2 = turn.clientToolset?.base ?? policy?.toolset?.base;
279072
- const include = turn.clientToolset?.include ?? policy?.toolset?.include;
279073
- const clientToolset = base2 === undefined && include === undefined ? undefined : {
279074
- ...base2 !== undefined ? { base: base2 } : {},
279075
- ...include !== undefined ? { include: [...include] } : {}
279076
- };
279077
- const policyAllowlist = policy?.allowlist;
279078
- const clientToolAllowlist = policyAllowlist === undefined ? turn.clientToolAllowlist : turn.clientToolAllowlist === undefined ? [...policyAllowlist] : intersectToolAllowlists(policyAllowlist, turn.clientToolAllowlist);
279079
- const excludeInteractiveTools = turn.excludeInteractiveTools ?? policy?.exclude_interactive;
279080
- return {
279081
- ...clientToolset ? { clientToolset } : {},
279082
- ...clientToolAllowlist !== undefined ? { clientToolAllowlist } : {},
279083
- ...excludeInteractiveTools !== undefined ? { excludeInteractiveTools } : {}
279084
- };
279085
- }
279086
- function mergeClientToolsetFields(primary, fallback) {
279087
- const base2 = primary?.base ?? fallback?.base;
279088
- const include = primary?.include ?? fallback?.include;
279089
- if (base2 === undefined && include === undefined)
279090
- return;
279091
- return {
279092
- ...base2 !== undefined ? { base: base2 } : {},
279093
- ...include !== undefined ? { include } : {}
279094
- };
279095
- }
279096
- var init_tool_policy = __esm(() => {
279097
- init_tool_name_mapping();
279098
- });
279099
-
279100
279192
  // src/tools/toolset.ts
279101
279193
  var exports_toolset = {};
279102
279194
  __export(exports_toolset, {
@@ -452441,6 +452533,7 @@ async function executeRecoveredApprovalContinuation(params) {
452441
452533
  return;
452442
452534
  }
452443
452535
  const preparedToolContext = await prepareToolExecutionContext({
452536
+ ...resolveRuntimeToolContextOptions(runtime.listener, scope, selectedDeliveryOwnerId ?? opts?.connectionId),
452444
452537
  connectionId: resolveTurnExecutionConnectionId(runtime.listener, scope, opts?.connectionId),
452445
452538
  agentId: recovered.agentId,
452446
452539
  conversationId: recovered.conversationId,
@@ -452999,9 +453092,12 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
452999
453092
  agent_id: runtime.agentId,
453000
453093
  conversation_id: recoveryConversationId
453001
453094
  };
453095
+ if (await getRecoveryEligibility(runtime) !== "owned")
453096
+ return null;
453002
453097
  const modAdapters = runtime.agentId ? await ensureListenerModAdaptersForAgent(runtime.listener, runtime.agentId) : [];
453003
453098
  const preparedToolContext = await prepareToolExecutionContext({
453004
453099
  connectionId: resolveTurnExecutionConnectionId(runtime.listener, scope, runtime.activeConnectionId ?? undefined),
453100
+ ...resolveRuntimeToolContextOptions(runtime.listener, scope),
453005
453101
  agentId: runtime.agentId,
453006
453102
  conversationId: recoveryConversationId,
453007
453103
  workingDirectory: recoveryWorkingDirectory,
@@ -453019,6 +453115,8 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
453019
453115
  const recoveryActingUserId = recoveryRecord?.actingUserId;
453020
453116
  pendingApprovals = await filterStillPending(pendingApprovals);
453021
453117
  while (pendingApprovals.length > 0) {
453118
+ if (await getRecoveryEligibility(runtime) !== "owned")
453119
+ return null;
453022
453120
  assertCurrentTurnLease();
453023
453121
  const recoveryBatchId = resolveRecoveryBatchId(runtime, pendingApprovals);
453024
453122
  if (!recoveryBatchId) {
@@ -453429,6 +453527,7 @@ var init_send = __esm(() => {
453429
453527
  init_protocol_outbound();
453430
453528
  init_recorded_tool_results();
453431
453529
  init_recovery();
453530
+ init_recovery_ownership();
453432
453531
  init_recovery_read();
453433
453532
  init_skill_injection();
453434
453533
  init_turn_input_state();
@@ -462649,6 +462748,16 @@ async function startTurnInput(params) {
462649
462748
  stream: sender.accept(result3)
462650
462749
  };
462651
462750
  }
462751
+ function getPostStopErrorDetails(latestErrorInfo, runErrorInfo2, fallbackError) {
462752
+ const errorDetail3 = getApprovalToolCallDesyncErrorText(latestErrorInfo ?? {}) || latestErrorInfo?.detail || latestErrorInfo?.message || runErrorInfo2?.detail || runErrorInfo2?.message || fallbackError || null;
462753
+ const retryErrorDetail = [
462754
+ latestErrorInfo?.detail,
462755
+ latestErrorInfo?.message,
462756
+ runErrorInfo2?.detail,
462757
+ runErrorInfo2?.message
462758
+ ].find(isProviderStreamTimeoutDetail) ?? errorDetail3;
462759
+ return { errorDetail: errorDetail3, retryErrorDetail };
462760
+ }
462652
462761
  function getProviderRetryLimit(errorDetail3) {
462653
462762
  return isProviderStreamTimeoutDetail(errorDetail3) ? 1 : LLM_API_ERROR_MAX_RETRIES;
462654
462763
  }
@@ -462744,6 +462853,7 @@ var init_turn_send = __esm(() => {
462744
462853
  init_queue();
462745
462854
  init_recoverable_notices();
462746
462855
  init_recovery();
462856
+ init_recovery_error_policy();
462747
462857
  init_send();
462748
462858
  init_skill_injection();
462749
462859
  init_turn_input_state();
@@ -462771,14 +462881,6 @@ function buildListenReminderContext(params) {
462771
462881
  };
462772
462882
  }
462773
462883
 
462774
- // src/tools/interactive-policy.ts
462775
- var INTERACTIVE_USER_INPUT_TOOL_NAMES;
462776
- var init_interactive_policy = __esm(() => {
462777
- INTERACTIVE_USER_INPUT_TOOL_NAMES = [
462778
- "AskUserQuestionAsync"
462779
- ];
462780
- });
462781
-
462782
462884
  // src/telemetry/input.ts
462783
462885
  function extractTelemetryInputText(content) {
462784
462886
  if (typeof content === "string") {
@@ -462940,6 +463042,7 @@ async function prepareListenerTurn(params) {
462940
463042
  if (isInterrupted()) {
462941
463043
  return { kind: "interrupted" };
462942
463044
  }
463045
+ markLocalTurnScope(runtime);
462943
463046
  setCurrentAgentId(agentId);
462944
463047
  setCurrentAgentName(listenAgentMetadata?.name ?? null);
462945
463048
  setConversationId(conversationId);
@@ -463101,12 +463204,6 @@ async function prepareListenerTurn(params) {
463101
463204
  if (connectionId) {
463102
463205
  recordRuntimeSubmittingConnection(runtime.listener, toolRuntimeScope, connectionId);
463103
463206
  }
463104
- const toolOwner = resolveRuntimeToolOwner(runtime.listener, toolRuntimeScope, connectionId);
463105
- const toolSelection = resolveTurnToolSelection({
463106
- clientToolset: msg.clientToolset,
463107
- clientToolAllowlist: msg.clientToolAllowlist,
463108
- excludeInteractiveTools: msg.excludeInteractiveTools
463109
- }, toolOwner.toolPolicy);
463110
463207
  const preparedToolContext = await prepareToolExecutionContextForScope({
463111
463208
  readScopeState: (read2) => retryApprovalRecoveryRead(read2, () => {
463112
463209
  if (isInterrupted())
@@ -463121,10 +463218,7 @@ async function prepareListenerTurn(params) {
463121
463218
  mcpOriginatorSuperRunId: getEffectiveMcpOriginatorId(msg),
463122
463219
  resolveClientMessageIds,
463123
463220
  turnStartedAt: msg.receivedAt,
463124
- externalToolOwnerConnectionId: toolOwner.connectionId,
463125
- clientToolset: toolSelection.clientToolset,
463126
- clientToolAllowlist: toolSelection.clientToolAllowlist,
463127
- ...toolSelection.excludeInteractiveTools ? { exclude: [...INTERACTIVE_USER_INPUT_TOOL_NAMES] } : {},
463221
+ ...resolveRuntimeToolContextOptions(runtime.listener, toolRuntimeScope, connectionId, msg),
463128
463222
  workingDirectory,
463129
463223
  permissionModeState,
463130
463224
  skillsDirectory: listenerOptions?.skillsDirectory,
@@ -463132,7 +463226,6 @@ async function prepareListenerTurn(params) {
463132
463226
  bundledSkills: runtime.bundledSkills,
463133
463227
  workspaceSandbox: runtime.workspaceSandbox,
463134
463228
  executionSettings: runtime.executionSettings,
463135
- foregroundYieldMs: toolOwner.toolPolicy?.foreground_yield_ms,
463136
463229
  cachedAgent,
463137
463230
  ...agentId ? { modContext: createListenerAgentModContext(agentId) } : {},
463138
463231
  modAdapters,
@@ -463203,8 +463296,6 @@ var init_turn_setup = __esm(() => {
463203
463296
  init_runtime_context();
463204
463297
  init_error_reporting();
463205
463298
  init_client_preferences();
463206
- init_interactive_policy();
463207
- init_tool_policy();
463208
463299
  init_toolset();
463209
463300
  init_debug();
463210
463301
  init_shell_context();
@@ -463584,23 +463675,22 @@ async function handleIncomingMessageInner(msg, socket, runtime, onStatusChange,
463584
463675
  break;
463585
463676
  }
463586
463677
  const latestErrorInfo = result3.errorInfo;
463587
- const errorDetail3 = getApprovalToolCallDesyncErrorText(latestErrorInfo ?? {}) || latestErrorInfo?.detail || latestErrorInfo?.message || runErrorInfo2?.detail || runErrorInfo2?.message || fallbackError || null;
463588
- const retryErrorDetail = [
463589
- latestErrorInfo?.detail,
463590
- latestErrorInfo?.message,
463591
- runErrorInfo2?.detail,
463592
- runErrorInfo2?.message
463593
- ].find(isProviderStreamTimeoutDetail) ?? errorDetail3;
463678
+ const { errorDetail: errorDetail3, retryErrorDetail } = getPostStopErrorDetails(latestErrorInfo, runErrorInfo2, fallbackError);
463594
463679
  const quotaError = latestErrorInfo ?? runErrorInfo2 ?? errorDetail3;
463595
463680
  const deploymentInterrupted = isCloudApiDeploymentInterrupted(latestErrorInfo) || isCloudApiDeploymentInterrupted(runErrorInfo2);
463596
- if (!deploymentInterrupted && shouldAttemptPostStopApprovalRecovery({
463681
+ const shouldRecoverApproval = !deploymentInterrupted && shouldAttemptPostStopApprovalRecovery({
463597
463682
  stopReason,
463598
463683
  runIdsSeen: msgRunIds.length,
463599
463684
  retries: postStopApprovalRecoveryRetries,
463600
463685
  runErrorDetail: errorDetail3,
463601
463686
  latestErrorText: latestErrorInfo?.detail ?? latestErrorInfo?.message ?? null,
463602
463687
  fallbackError
463603
- })) {
463688
+ });
463689
+ const ownsApprovalRecovery = shouldRecoverApproval && await getRecoveryEligibility(runtime) === "owned";
463690
+ if (shouldRecoverApproval && finishIfInterrupted(lastRunId || runtime.activeRunId)) {
463691
+ break;
463692
+ }
463693
+ if (ownsApprovalRecovery) {
463604
463694
  postStopApprovalRecoveryRetries += 1;
463605
463695
  emitRecoverableStatusNotice(socket, runtime, {
463606
463696
  kind: "stale_approval_conflict_recovery",
@@ -464048,6 +464138,7 @@ var init_turn = __esm(() => {
464048
464138
  init_protocol_outbound();
464049
464139
  init_recoverable_notices();
464050
464140
  init_recovery();
464141
+ init_recovery_ownership();
464051
464142
  init_runtime6();
464052
464143
  init_send();
464053
464144
  init_skill_injection();
@@ -464462,6 +464553,7 @@ var init_inbound_dispatch = __esm(() => {
464462
464553
  init_mcp_originator_tokens();
464463
464554
  init_debug();
464464
464555
  init_connection();
464556
+ init_inbound_queue();
464465
464557
  init_input_disposition();
464466
464558
  init_input_disposition_ownership();
464467
464559
  init_input_disposition_rollback();
@@ -472727,6 +472819,7 @@ async function handleRuntimeStartCommand(parsed, context3) {
472727
472819
  expectInboundTeleport(scopedRuntime, parsed.teleport_id);
472728
472820
  }
472729
472821
  assertConnectionOpen();
472822
+ markLocalTurnScope(scopedRuntime);
472730
472823
  subscribeListenerConnection(context3.runtime, connectionId, runtimeScope);
472731
472824
  registerRuntimeExternalTools(context3.runtime, connectionId, runtimeScope, parsed.external_tools ?? [], parsed.tool_policy);
472732
472825
  if (parsed.wait_for_replay) {
@@ -472792,6 +472885,7 @@ var init_runtime_start = __esm(() => {
472792
472885
  init_external_tools();
472793
472886
  init_permission_mode();
472794
472887
  init_queue();
472888
+ init_runtime6();
472795
472889
  init_runtime_start_validation();
472796
472890
  init_teleport();
472797
472891
  LEGACY_SUMMARY_PREFIX_BY_SOURCE_TAG = {
@@ -473717,6 +473811,7 @@ async function routeInputFrame(deps) {
473717
473811
  var init_input_frame_router = __esm(() => {
473718
473812
  init_mcp_originator_tokens();
473719
473813
  init_inbound_dispatch();
473814
+ init_inbound_queue();
473720
473815
  init_input_ack();
473721
473816
  init_input_disposition();
473722
473817
  init_input_disposition_rollback();
@@ -474511,7 +474606,14 @@ async function handleTaskControlCommand(command, context3) {
474511
474606
  safeSocketSend(socket, response2, response2.type, command.type);
474512
474607
  return;
474513
474608
  }
474514
- const parent = getOrCreateScopedRuntime2(runtime, command.runtime.agent_id, command.runtime.conversation_id);
474609
+ const { agent_id, conversation_id } = command.runtime;
474610
+ const sidebandOnly = command.type !== "launch_subagent" || command.notify === "caller";
474611
+ if (sidebandOnly && !getConversationRuntime(runtime, agent_id, conversation_id)) {
474612
+ markSidebandOnlyScope(runtime, getConversationRuntimeKey(agent_id, conversation_id));
474613
+ }
474614
+ const parent = getOrCreateScopedRuntime2(runtime, agent_id, conversation_id);
474615
+ if (!sidebandOnly)
474616
+ markLocalTurnScope(parent);
474515
474617
  const response = command.type === "launch_subagent" ? await handleLaunchSubagentCommand(command, parent, connectionId) : command.type === "subagent_message" ? await handleSubagentMessageCommand(command, parent) : await handleSubagentStopCommand(command, parent);
474516
474618
  sendReply(response);
474517
474619
  };
@@ -474522,6 +474624,7 @@ async function handleTaskControlCommand(command, context3) {
474522
474624
  }
474523
474625
  }
474524
474626
  var init_task_control = __esm(() => {
474627
+ init_runtime6();
474525
474628
  init_monitors2();
474526
474629
  init_stop_conversation();
474527
474630
  init_subagent_control();
@@ -475145,7 +475248,8 @@ function installProcessEventRouting(params) {
475145
475248
  setMessageQueueAdder((queuedMessage) => {
475146
475249
  if (!queuedMessage.agentId || !queuedMessage.conversationId)
475147
475250
  return;
475148
- if (isRuntimeTeleportPending(runtime, queuedMessage.agentId, queuedMessage.conversationId))
475251
+ const key4 = getConversationRuntimeKey(queuedMessage.agentId, queuedMessage.conversationId);
475252
+ if (isSidebandOnlyScope(runtime, key4) || isRuntimeTeleportPending(runtime, queuedMessage.agentId, queuedMessage.conversationId))
475149
475253
  return;
475150
475254
  const targetRuntime = getOrCreateScopedRuntime(runtime, queuedMessage.agentId, queuedMessage.conversationId);
475151
475255
  if (!targetRuntime?.queueRuntime)
@@ -475173,7 +475277,7 @@ function getMostRecentlyActiveConversation(runtime) {
475173
475277
  let latest = null;
475174
475278
  let latestAt = -1;
475175
475279
  for (const conversationRuntime of runtime.conversationRuntimes.values()) {
475176
- if (!conversationRuntime.agentId)
475280
+ if (!conversationRuntime.agentId || isSidebandOnlyScope(runtime, conversationRuntime.key))
475177
475281
  continue;
475178
475282
  const activeAt = conversationRuntime.isProcessing ? Number.POSITIVE_INFINITY : conversationRuntime.contextTracker.contextTokensHistory.at(-1)?.timestamp ?? 0;
475179
475283
  if (activeAt > latestAt) {
@@ -476209,7 +476313,12 @@ async function recoverApprovalStateForSync(runtime, scope, deps = {}, opts = {})
476209
476313
  clearRecoveredApprovalState(runtime);
476210
476314
  return "deferred";
476211
476315
  }
476212
- runtime.pendingInterruptedResults = buildFreshDenialApprovals(pendingApprovals, STALE_APPROVAL_RECOVERY_DENIAL_REASON);
476316
+ runtime.pendingInterruptedResults = staleDenialDecisions.filter((decision) => decision.type === "deny").map(({ approval, reason }) => ({
476317
+ type: "approval",
476318
+ tool_call_id: approval.toolCallId,
476319
+ approve: false,
476320
+ reason
476321
+ }));
476213
476322
  runtime.pendingInterruptedContext = {
476214
476323
  agentId: scope.agent_id,
476215
476324
  conversationId: scope.conversation_id,
@@ -476250,7 +476359,8 @@ var init_recovery_sync = __esm(() => {
476250
476359
  async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
476251
476360
  const syncScopedRuntime = getOrCreateScopedRuntime(listenerRuntime, scope.agent_id, scope.conversation_id);
476252
476361
  const recoverFn = opts?.recoverApprovalStateForSync ?? recoverApprovalStateForSync;
476253
- if (opts?.recoverApprovals ?? true) {
476362
+ const canRecover = !isSidebandOnlyScope(listenerRuntime, syncScopedRuntime.key);
476363
+ if (canRecover && (opts?.recoverApprovals ?? true)) {
476254
476364
  try {
476255
476365
  await recoverFn(syncScopedRuntime, scope, undefined, {
476256
476366
  resumeInterruptedTurn: opts?.resumeInterruptedTurn === true
@@ -476266,7 +476376,7 @@ async function replaySyncStateForRuntime(listenerRuntime, socket, scope, opts) {
476266
476376
  }
476267
476377
  }
476268
476378
  }
476269
- if (syncScopedRuntime.recoveredApprovalState && (syncScopedRuntime.recoveredApprovalState.autoDecisions?.length ?? 0) > 0) {
476379
+ if (canRecover && syncScopedRuntime.recoveredApprovalState && (syncScopedRuntime.recoveredApprovalState.autoDecisions?.length ?? 0) > 0) {
476270
476380
  let signalLeaseReady;
476271
476381
  let releaseLeaseBarrier;
476272
476382
  const leaseReady = new Promise((resolve39) => {
@@ -476315,6 +476425,7 @@ var init_sync_replay = __esm(() => {
476315
476425
  init_conversation_runtime();
476316
476426
  init_recovery();
476317
476427
  init_recovery_sync();
476428
+ init_runtime6();
476318
476429
  init_turn();
476319
476430
  init_warmup();
476320
476431
  });
@@ -548281,4 +548392,4 @@ function registerBunOAuthFlows() {
548281
548392
  registerBunOAuthFlows();
548282
548393
  await init_src5().then(() => exports_src2);
548283
548394
 
548284
- //# debugId=928B7A44932DBCE064756E2164756E21
548395
+ //# debugId=B5002FC0CB07EA2264756E2164756E21
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.34.74",
3
+ "version": "0.34.76",
4
4
  "lockfileVersion": 3,
5
5
  "packages": {
6
6
  "node_modules/@alcalzone/ansi-tokenize": {
@@ -2184,9 +2184,9 @@
2184
2184
  "license": "MIT"
2185
2185
  },
2186
2186
  "node_modules/brace-expansion": {
2187
- "version": "5.1.0",
2188
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.0.tgz",
2189
- "integrity": "sha512-aa11Dv491GKnYqxaul3aRJ0szew7yMJMfZPnqD44NjGrZXoj62l41OEDDpdpC4eE2P88vBFfLuSyRhpG91NUvg==",
2187
+ "version": "5.1.2",
2188
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.1.2.tgz",
2189
+ "integrity": "sha512-ELhY3JEerIBbhgW+rh0/8glkZAaMqn1x3BAvp3yTULSEGozMK/5PT6WTdBgsdvJqwwmv7MAQNOydfYbvK1Vgfw==",
2190
2190
  "license": "MIT",
2191
2191
  "dependencies": {
2192
2192
  "balanced-match": "^4.0.2"
@@ -5091,7 +5091,7 @@
5091
5091
  },
5092
5092
  "": {
5093
5093
  "name": "@letta-ai/letta-code",
5094
- "version": "0.34.74",
5094
+ "version": "0.34.76",
5095
5095
  "dependencies": {
5096
5096
  "@cursor/sdk": "1.1.0",
5097
5097
  "@earendil-works/pi-ai": "^1.6.0",