@letta-ai/letta-code 0.34.57 → 0.34.58

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
@@ -6135,7 +6135,7 @@ var package_default;
6135
6135
  var init_package = __esm(() => {
6136
6136
  package_default = {
6137
6137
  name: "@letta-ai/letta-code",
6138
- version: "0.34.57",
6138
+ version: "0.34.58",
6139
6139
  lettaStartupLogProtocol: 1,
6140
6140
  lettaConfigDirProtocol: 1,
6141
6141
  description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
@@ -203260,7 +203260,7 @@ var init_mcp_client = __esm(() => {
203260
203260
  init_streamableHttp();
203261
203261
  DEFAULT_CLIENT_INFO = {
203262
203262
  name: "letta-code",
203263
- version: "0.34.57"
203263
+ version: "0.34.58"
203264
203264
  };
203265
203265
  });
203266
203266
 
@@ -207511,7 +207511,7 @@ Do not use this tool for root memory files (already loaded) or skills/ (use Skil
207511
207511
  var init_Memory = () => {};
207512
207512
 
207513
207513
  // src/tools/descriptions/Monitor.md
207514
- var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: indefinitely ("every time an ERROR line appears": `tail -f`, `inotifywait -m`, `while true`), or until a known end ("each CI step result, stop when the run completes": a command that emits lines and then exits). For a single notification ("tell me when the server is ready"), run a command that exits when the condition is true, e.g. `until grep -q "Ready" dev.log; do sleep 0.5; done`, in the background with your shell tool; you get one completion notification. An unbounded command used for a single notification stays armed until timeout, and `tail -f log | grep -m 1 ...` can hang the same way.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Every pipe stage must flush per line or matches sit in its buffer unseen: `grep` needs `--line-buffered`, `awk` needs `fflush()`. `| head -N` delivers nothing until N matches accumulate.\n- In poll loops, handle transient failures (`curl ... || true`). Poll remote APIs every 30s+, local checks every 0.5–1s.\n- Only stdout is the event stream. Stderr goes to the output file named in the result, without notifications; merge it with `2>&1` for commands you run directly so failures reach your filter.\n- Every stdout line is a conversation message, so filter to the lines you\'d act on. Lines within 200ms are batched into one notification. Monitors that produce too many events are stopped automatically; restart with a tighter filter.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that greps only for the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `grep -E --line-buffered "elapsed_steps=|Traceback|Error|FAILED|Killed|OOM"`, and in poll loops emit on every terminal status (`succeeded|failed|cancelled|timeout`).\n\nExit ends the watch (exit code is reported). Timeout → killed. Set `persistent: true` for session-length watches (log tails, long-lived event streams). In managed Cloud sandboxes, every monitor, including persistent ones, stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox\'s monitor cap); elsewhere persistent monitors run until TaskStop or session end. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, set `backup_after_seconds` (e.g. 900). If the monitor goes that long without an event, a durable Wake brings you back to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nInstead of `command`, `ws` streams each WebSocket text frame as an event (prefer it over `websocat`), and `script` runs a JavaScript watch loop with CodeMode\'s globals plus `emit(text)` and `sleep(ms)`; `decide()` spends money on every call, so call it only when an observed change needs judgment.\n\nTo watch a public http(s) URL, prefer `url` over a command loop that polls it. A `url` monitor runs in Letta Cloud, keeps running when this sandbox or machine stops, and notifies you only when the HTTP status or body changes. It is available only when connected to Letta Cloud.\n\nFor an authenticated API, pass `headers` that reference agent secrets as `$NAME`, the same as in shell commands: `{"PRIVATE-TOKEN": "$GITLAB_TOKEN"}`. Cloud fills them in on every poll, so the token is never written into the monitor. Use `select` to compare one JSON field instead of the whole body, and `match` to be notified when it reaches a value, with `stop_on_match` to finish after that. For a CI pipeline: `select: "0.status"`, `match: {"equals": ["success", "failed", "canceled"]}`, `stop_on_match: true`. The first response is checked against `match` too, so a pipeline that already finished notifies right away. Match every terminal state, not just success.\n';
207514
+ var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: indefinitely ("every time an ERROR line appears": `tail -f`, `inotifywait -m`, `while true`), or until a known end ("each CI step result, stop when the run completes": a command that emits lines and then exits). For a single notification ("tell me when the server is ready"), run a command that exits when the condition is true, e.g. `until grep -q "Ready" dev.log; do sleep 0.5; done`, in the background with your shell tool; you get one completion notification. An unbounded command used for a single notification stays armed until timeout, and `tail -f log | grep -m 1 ...` can hang the same way.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Every pipe stage must flush per line or matches sit in its buffer unseen: `grep` needs `--line-buffered`, `awk` needs `fflush()`. `| head -N` delivers nothing until N matches accumulate.\n- In poll loops, handle transient failures (`curl ... || true`). Poll remote APIs every 30s+, local checks every 0.5–1s.\n- Only stdout is the event stream. Stderr goes to the output file named in the result, without notifications; merge it with `2>&1` for commands you run directly so failures reach your filter.\n- Every stdout line is a conversation message, so filter to the lines you\'d act on. Lines within 200ms are batched into one notification. Monitors that produce too many events are stopped automatically; restart with a tighter filter.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that greps only for the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `grep -E --line-buffered "elapsed_steps=|Traceback|Error|FAILED|Killed|OOM"`, and in poll loops emit on every terminal status (`succeeded|failed|cancelled|timeout`).\n\nExit ends the watch (exit code is reported). Timeout → killed. Set `persistent: true` for session-length watches (log tails, long-lived event streams). In managed Cloud sandboxes, every monitor, including persistent ones, stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox\'s monitor cap); elsewhere persistent monitors run until TaskStop or session end. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, set `backup_after_seconds` (e.g. 900). If the monitor goes that long without an event, a durable Wake brings you back to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nInstead of `command`, `ws` streams each WebSocket text frame as an event (prefer it over `websocat`), and `script` runs a JavaScript watch loop with CodeMode\'s globals plus `emit(text)` and `sleep(ms)`; `decide()` spends money on every call, so call it only when an observed change needs judgment.\n';
207515
207515
  var init_Monitor = () => {};
207516
207516
 
207517
207517
  // src/tools/descriptions/Read.md
@@ -208436,6 +208436,12 @@ var init_manager = __esm(() => {
208436
208436
  init_settings_manager();
208437
208437
  ENABLED_TOGGLE_VALUES = new Set(["1", "true", "yes"]);
208438
208438
  EXPERIMENT_DEFINITIONS = [
208439
+ {
208440
+ id: "cloud_monitors",
208441
+ label: "Cloud monitors",
208442
+ description: "Use Cloud URL monitors instead of local command, WebSocket, and script monitors.",
208443
+ envVar: "LETTA_CLOUD_MONITORS"
208444
+ },
208439
208445
  {
208440
208446
  id: "artifacts",
208441
208447
  label: "artifacts",
@@ -216961,6 +216967,84 @@ var init_subagent_tool_policy = __esm(() => {
216961
216967
  init_subagent_depth();
216962
216968
  });
216963
216969
 
216970
+ // src/tools/descriptions/MonitorCloud.md
216971
+ var MonitorCloud_default = 'Start a background monitor that streams events from a public http(s) URL. Each change to the HTTP status or body is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: until the timeout ("every time the status changes"), or until a known end ("each CI step result, stop when the run completes": use `match` with `stop_on_match: true`). For a single notification ("tell me when the server is ready"), use `match` with `stop_on_match: true`.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Cloud polls the URL with GET every 60s by default. Set `interval_seconds` to 60 or more. The first response is the baseline; by default, it notifies only when the HTTP status or body changes.\n- Use `select` to compare one JSON field instead of the whole body, and `match` to be notified when it reaches a value, with `stop_on_match` to finish after that. The first response is checked against `match` too, so a pipeline that already finished notifies right away. A value that keeps matching does not notify again.\n- Every event is a conversation message, so filter to the events you\'d act on.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that matches only the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `select: "0.status"`, `match: {"equals": ["success", "failed", "canceled"]}`, `stop_on_match: true`.\n\nA match ends the watch when `stop_on_match` is true. Timeout → killed. Set `timeout_ms` for longer watches; the default is 24 hours and the maximum is 7 days. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, schedule a Wake or cron to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nFor an authenticated API, pass `headers` that reference agent secrets as `$NAME`, the same as in shell commands: `{"PRIVATE-TOKEN": "$GITLAB_TOKEN"}`. Cloud fills them in on every poll, so the token is never written into the monitor.\n';
216972
+ var init_MonitorCloud = () => {};
216973
+
216974
+ // src/tools/schemas/MonitorCloud.json
216975
+ var MonitorCloud_default2;
216976
+ var init_MonitorCloud2 = __esm(() => {
216977
+ MonitorCloud_default2 = {
216978
+ type: "object",
216979
+ properties: {
216980
+ description: {
216981
+ type: "string",
216982
+ description: "Clear, concise user-facing description of the update you are waiting for. This may be shown directly in chat, so make it grammatical by itself. Describe the expected event, not the polling command or monitor implementation. Prefer `CI results and review comments for the auth fix`, `Deployment completion or failure`, or `New errors in the API logs` over internal labels like `PR checks and state transitions`."
216983
+ },
216984
+ timeout_ms: {
216985
+ type: "integer",
216986
+ minimum: 1000,
216987
+ default: 86400000,
216988
+ description: "Kill the monitor after this deadline. Default 86400000ms. Maximum 7 days."
216989
+ },
216990
+ url: {
216991
+ type: "string",
216992
+ description: "Public http(s) URL to poll with GET. By default it notifies only when the HTTP status or body changes; use select and match to narrow that. timeout_ms defaults to 24 hours here, up to 7 days."
216993
+ },
216994
+ interval_seconds: {
216995
+ type: "integer",
216996
+ minimum: 60,
216997
+ default: 60,
216998
+ description: "Seconds between polls of url."
216999
+ },
217000
+ headers: {
217001
+ type: "object",
217002
+ additionalProperties: {
217003
+ type: "string"
217004
+ },
217005
+ description: `Request headers for url, at most 10. Reference agent secrets as $NAME, as in shell commands, e.g. {"PRIVATE-TOKEN": "$GITLAB_TOKEN"} or {"Authorization": "Bearer $CI_TOKEN"}. Cloud fills them in on every poll; the value is never sent from here. Credential headers must use a secret reference. Headers are dropped if a redirect leaves the URL's origin.`
217006
+ },
217007
+ select: {
217008
+ type: "string",
217009
+ description: "For url: a dot-separated path into the JSON response (numbers index arrays), e.g. 0.status. Only that value is compared and reported, so unrelated fields changing does not notify."
217010
+ },
217011
+ match: {
217012
+ type: "object",
217013
+ properties: {
217014
+ equals: {
217015
+ type: "array",
217016
+ items: {
217017
+ type: "string"
217018
+ },
217019
+ description: "Matches when the value is one of these."
217020
+ },
217021
+ contains: {
217022
+ type: "string",
217023
+ description: "Matches when the value contains this text."
217024
+ },
217025
+ gt: {
217026
+ type: "number",
217027
+ description: "Matches when the value is a number greater than this."
217028
+ },
217029
+ lt: {
217030
+ type: "number",
217031
+ description: "Matches when the value is a number less than this."
217032
+ }
217033
+ },
217034
+ additionalProperties: false,
217035
+ description: 'For url: notify when the compared value starts to meet every given test, instead of on every change. The first response is checked too, and a value that keeps matching does not notify again. List every terminal state, e.g. equals ["success", "failed", "canceled"].'
217036
+ },
217037
+ stop_on_match: {
217038
+ type: "boolean",
217039
+ description: "For url with match: stop after the first match notice."
217040
+ }
217041
+ },
217042
+ required: ["description", "url"],
217043
+ additionalProperties: false,
217044
+ $schema: "http://json-schema.org/draft-07/schema#"
217045
+ };
217046
+ });
217047
+
216964
217048
  // src/tools/task-tool-assets.ts
216965
217049
  function stripComputerFromTaskSchema(schema) {
216966
217050
  const properties = schema.properties;
@@ -216971,6 +217055,12 @@ function stripComputerFromTaskSchema(schema) {
216971
217055
  return { ...schema, properties: rest2 };
216972
217056
  }
216973
217057
  async function resolveBackendSpecificToolAssets(name, description, inputSchema) {
217058
+ if (name === "Monitor" && experimentManager.isEnabled("cloud_monitors")) {
217059
+ return {
217060
+ description: MonitorCloud_default.trim(),
217061
+ inputSchema: MonitorCloud_default2
217062
+ };
217063
+ }
216974
217064
  if (name !== "Task") {
216975
217065
  return { description, inputSchema };
216976
217066
  }
@@ -216990,6 +217080,9 @@ async function resolveBackendSpecificToolAssets(name, description, inputSchema)
216990
217080
  }
216991
217081
  var init_task_tool_assets = __esm(() => {
216992
217082
  init_backend2();
217083
+ init_manager();
217084
+ init_MonitorCloud();
217085
+ init_MonitorCloud2();
216993
217086
  });
216994
217087
 
216995
217088
  // src/tools/tool-name-mapping.ts
@@ -234139,6 +234232,23 @@ var init_monitor_event_stream = __esm(() => {
234139
234232
  MONITOR_EVENT_BUFFER_CHARS = 1024 * 1024;
234140
234233
  });
234141
234234
 
234235
+ // src/tools/impl/monitor-result.ts
234236
+ function buildMonitorResult(taskId, timeoutMs, persistent, outputFile) {
234237
+ const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
234238
+ return {
234239
+ content: [
234240
+ {
234241
+ type: "text",
234242
+ text: `Monitor started (task ${taskId}, ${lifetime}). You will be notified on each event. Keep working — do not poll or sleep. Events may arrive while you are waiting for the user — an event is not their reply.${outputFile ? `
234243
+ Output file: ${outputFile}` : ""}`
234244
+ }
234245
+ ],
234246
+ taskId,
234247
+ timeoutMs,
234248
+ persistent
234249
+ };
234250
+ }
234251
+
234142
234252
  // src/tools/impl/monitor-script.ts
234143
234253
  function createCallLimiter(signal) {
234144
234254
  let tokens = TOOL_CALL_BURST;
@@ -234488,14 +234598,6 @@ function buildCloudSource(args, url2) {
234488
234598
  }
234489
234599
  return source;
234490
234600
  }
234491
- function notifyDescription(source) {
234492
- const what = source.select ? `the value at ${source.select.path}` : "the HTTP status or body";
234493
- if (!source.notify_when) {
234494
- return `The first response is the baseline; you will be notified only when ${what} changes`;
234495
- }
234496
- const then = source.stop_on_match ? ", and then it stops" : "; it notifies again each time a match begins";
234497
- return `You will be notified when ${what} first matches, including on the first poll${then}`;
234498
- }
234499
234601
  function validateUrlMonitorArgs(args) {
234500
234602
  if (typeof args.description !== "string") {
234501
234603
  throw new Error("Monitor description is required");
@@ -234541,7 +234643,6 @@ async function startCloudUrlMonitor(args, deps = {}) {
234541
234643
  if (!isSavedConversation(scope.conversationId)) {
234542
234644
  throw new Error("Monitor url needs a saved conversation and is not available in the agent's default conversation. Use command with a polling loop instead.");
234543
234645
  }
234544
- const intervalSeconds = source.interval_seconds;
234545
234646
  const timeoutMs = args.timeout_ms ?? DEFAULT_URL_MONITOR_TIMEOUT_MS;
234546
234647
  const request3 = deps.request ?? apiRequest;
234547
234648
  const created = await request3("POST", cloudMonitorsPath(scope.conversationId), {
@@ -234551,30 +234652,18 @@ async function startCloudUrlMonitor(args, deps = {}) {
234551
234652
  ...args.toolCallId && { tool_call_id: args.toolCallId }
234552
234653
  }, actingUserRequestOptions(scope.actingUserId));
234553
234654
  const taskId = created.id;
234554
- return {
234555
- content: [
234556
- {
234557
- type: "text",
234558
- text: `Cloud monitor started (task ${taskId}, polls every ${intervalSeconds}s, timeout ${timeoutMs}ms). ${notifyDescription(source)}, even if this sandbox stops. Keep working — do not poll or sleep. Stop it with TaskStop.`
234559
- }
234560
- ],
234561
- taskId,
234562
- timeoutMs,
234563
- persistent: false
234564
- };
234655
+ return buildMonitorResult(taskId, timeoutMs, false);
234565
234656
  }
234566
234657
  async function stopCloudUrlMonitor(taskId, deps = {}) {
234567
234658
  if (!(deps.isCloud ?? isLettaCloud2)()) {
234568
234659
  return {
234569
- killed: false,
234570
- output: `No task ${taskId} is running here, and Cloud monitors can only be stopped when connected to Letta Cloud.`
234660
+ killed: false
234571
234661
  };
234572
234662
  }
234573
234663
  const conversationId = (deps.scope ?? resolveNotificationScope)()?.conversationId;
234574
234664
  if (!conversationId || !isSavedConversation(conversationId)) {
234575
234665
  return {
234576
- killed: false,
234577
- output: `No Cloud monitor ${taskId} was found in this conversation.`
234666
+ killed: false
234578
234667
  };
234579
234668
  }
234580
234669
  const request3 = deps.request ?? apiRequest;
@@ -234584,19 +234673,17 @@ async function stopCloudUrlMonitor(taskId, deps = {}) {
234584
234673
  } catch (error4) {
234585
234674
  if (error4 instanceof ApiRequestError && error4.status === 404) {
234586
234675
  return {
234587
- killed: false,
234588
- output: `No Cloud monitor ${taskId} was found in this conversation.`
234676
+ killed: false
234589
234677
  };
234590
234678
  }
234591
234679
  throw error4;
234592
234680
  }
234593
234681
  if (stopped.status !== "cancelled") {
234594
234682
  return {
234595
- killed: false,
234596
- output: `Cloud monitor ${taskId} had already stopped (${stopped.status}).`
234683
+ killed: false
234597
234684
  };
234598
234685
  }
234599
- return { killed: true, output: `Stopped Cloud monitor ${taskId}.` };
234686
+ return { killed: true };
234600
234687
  }
234601
234688
  var URL_MONITOR_MIN_INTERVAL_SECONDS = 60, DEFAULT_URL_MONITOR_TIMEOUT_MS = 86400000, SECRET_REFERENCE, CREDENTIAL_HEADER;
234602
234689
  var init_monitor_url_cloud = __esm(() => {
@@ -234615,21 +234702,6 @@ import { WebSocket as WebSocket4 } from "ws";
234615
234702
  function getMonitorTimeoutEvent(timeoutMs, tool = "Monitor") {
234616
234703
  return isManagedCloudRuntime() && timeoutMs === getMonitorMaxTimeoutMs() ? `${tool} stopped at the ${timeoutMs / 3600000}-hour Cloud sandbox limit. If you still need to watch, simply re-arm it by calling ${tool} again. For much longer waits, schedule a Wake or cron, which does not keep the sandbox running between turns.` : "[Monitor timed out — re-arm if needed.]";
234617
234704
  }
234618
- function buildMonitorResult(taskId, timeoutMs, persistent, outputFile) {
234619
- const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
234620
- return {
234621
- content: [
234622
- {
234623
- type: "text",
234624
- text: `Monitor started (task ${taskId}, ${lifetime}). You will be notified on each event. Keep working — do not poll or sleep. Events may arrive while you are waiting for the user — an event is not their reply.
234625
- Output file: ${outputFile}`
234626
- }
234627
- ],
234628
- taskId,
234629
- timeoutMs,
234630
- persistent
234631
- };
234632
- }
234633
234705
  function validUtf8Prefix(buffer, maxBytes) {
234634
234706
  let end = Math.min(buffer.length, maxBytes);
234635
234707
  while (end > Math.max(0, maxBytes - 4)) {
@@ -234744,15 +234816,8 @@ function normalizeMonitorArgs(args) {
234744
234816
  const hasCommand = typeof normalized.command === "string" && normalized.command.length > 0;
234745
234817
  const hasWebSocket = normalized.ws !== undefined && !(typeof normalized.ws === "object" && normalized.ws !== null && normalized.ws.url === "");
234746
234818
  if (Number(hasCommand) + Number(hasWebSocket) + Number(hasScript) !== 1) {
234747
- throw new Error("Monitor requires exactly one of command, ws, or script, or url");
234748
- }
234749
- if (normalized.interval_seconds !== undefined) {
234750
- throw new Error("Monitor interval_seconds is only supported with url");
234819
+ throw new Error("Monitor requires exactly one of command, ws, or script");
234751
234820
  }
234752
- if (normalized.headers !== undefined || normalized.select !== undefined || normalized.match !== undefined || normalized.stop_on_match !== undefined) {
234753
- throw new Error("Monitor headers, select, match and stop_on_match are only supported with url");
234754
- }
234755
- delete normalized.url;
234756
234821
  if (!hasScript) {
234757
234822
  delete normalized.script;
234758
234823
  delete normalized.args;
@@ -235235,7 +235300,29 @@ function backupScopeFor(taskId) {
235235
235300
  }
235236
235301
  async function monitor(args) {
235237
235302
  args.signal?.throwIfAborted();
235238
- if (typeof args.url === "string" && args.url !== "") {
235303
+ const cloud = experimentManager.isEnabled("cloud_monitors");
235304
+ const forbidden = cloud ? [
235305
+ "command",
235306
+ "ws",
235307
+ "script",
235308
+ "args",
235309
+ "persistent",
235310
+ "backup_after_seconds",
235311
+ "backup_prompt"
235312
+ ] : [
235313
+ "url",
235314
+ "interval_seconds",
235315
+ "headers",
235316
+ "select",
235317
+ "match",
235318
+ "stop_on_match"
235319
+ ];
235320
+ for (const key2 of forbidden) {
235321
+ if (args[key2] !== undefined) {
235322
+ throw new Error(`Monitor ${key2} is not supported in ${cloud ? "Cloud" : "local"} mode`);
235323
+ }
235324
+ }
235325
+ if (cloud) {
235239
235326
  return startCloudUrlMonitor(args);
235240
235327
  }
235241
235328
  const normalized = normalizeMonitorArgs(args);
@@ -235279,6 +235366,7 @@ function installMonitorProcessExitCleanup() {
235279
235366
  var MIN_TIMEOUT_MS = 1000, DEFAULT_TIMEOUT_MS3 = 300000, MONITOR_OUTPUT_FILE_BYTES, WEBSOCKET_MAX_PAYLOAD_BYTES, WEBSOCKET_PROTOCOL_PATTERN, monitorProcessExitCleanupInstalled = false;
235280
235367
  var init_monitor = __esm(() => {
235281
235368
  init_strip_ansi();
235369
+ init_manager();
235282
235370
  init_runtime_context();
235283
235371
  init_secret_substitution();
235284
235372
  init_message_queue_bridge();
@@ -239900,7 +239988,7 @@ class CodexAppServerClient {
239900
239988
  await this.request("initialize", {
239901
239989
  clientInfo: {
239902
239990
  name: "letta-code",
239903
- version: "0.34.57"
239991
+ version: "0.34.58"
239904
239992
  },
239905
239993
  capabilities: null
239906
239994
  });
@@ -244431,7 +244519,7 @@ async function fetchParentConversationMessages(params) {
244431
244519
  }
244432
244520
  return messages.reverse();
244433
244521
  }
244434
- function contentText2(content) {
244522
+ function contentText3(content) {
244435
244523
  if (typeof content === "string")
244436
244524
  return content;
244437
244525
  if (!Array.isArray(content))
@@ -244457,7 +244545,7 @@ function renderToolCall(call) {
244457
244545
  }
244458
244546
  function renderToolResult(result3) {
244459
244547
  const raw2 = result3.tool_return ?? result3.func_response;
244460
- const text2 = typeof raw2 === "string" ? raw2 : contentText2(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
244548
+ const text2 = typeof raw2 === "string" ? raw2 : contentText3(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
244461
244549
  return {
244462
244550
  type: "tool_result",
244463
244551
  call_id: result3.tool_call_id ?? undefined,
@@ -244493,11 +244581,11 @@ function userEvents(text2, speaker) {
244493
244581
  function renderMessage(message2) {
244494
244582
  switch (message2.message_type) {
244495
244583
  case "user_message": {
244496
- const text2 = contentText2(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
244584
+ const text2 = contentText3(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
244497
244585
  return userEvents(text2, message2.name ?? undefined);
244498
244586
  }
244499
244587
  case "assistant_message": {
244500
- const text2 = contentText2(message2.content).trim();
244588
+ const text2 = contentText3(message2.content).trim();
244501
244589
  return text2 ? [
244502
244590
  {
244503
244591
  type: "message",
@@ -248692,7 +248780,7 @@ function createGitHubPullRequestSnapshotFetcher(deps = {}) {
248692
248780
  if (unsupported || !shouldFetchCloud())
248693
248781
  return fetchGh(ref, options);
248694
248782
  let waited = false;
248695
- const cooldownError = new Error("Cloud PR snapshot is still cooling down");
248783
+ const cooldownError = new GitHubPullRequestSnapshotPending;
248696
248784
  const cooldown = async (retryAt) => {
248697
248785
  if (waited) {
248698
248786
  throw cooldownError;
@@ -248738,7 +248826,7 @@ function createGitHubPullRequestSnapshotFetcher(deps = {}) {
248738
248826
  }
248739
248827
  };
248740
248828
  }
248741
- var DEFAULT_COOLDOWN_MS = 30000, MAX_COOLDOWN_MS = 60000;
248829
+ var GitHubPullRequestSnapshotPending, DEFAULT_COOLDOWN_MS = 30000, MAX_COOLDOWN_MS = 60000;
248742
248830
  var init_github_pull_request_cloud = __esm(() => {
248743
248831
  init_letta_client();
248744
248832
  init_client4();
@@ -248746,6 +248834,12 @@ var init_github_pull_request_cloud = __esm(() => {
248746
248834
  init_backend_mode();
248747
248835
  init_telemetry();
248748
248836
  init_github_pull_request_watch();
248837
+ GitHubPullRequestSnapshotPending = class GitHubPullRequestSnapshotPending extends Error {
248838
+ constructor() {
248839
+ super("Cloud PR snapshot is still cooling down");
248840
+ this.name = "GitHubPullRequestSnapshotPending";
248841
+ }
248842
+ };
248749
248843
  });
248750
248844
 
248751
248845
  // src/tools/impl/github-pull-request-diff.ts
@@ -249100,12 +249194,15 @@ ${event}
249100
249194
  const now2 = deps.now ?? Date.now;
249101
249195
  (async () => {
249102
249196
  let previous = initial2;
249197
+ let lastFreshSnapshotAt = now2();
249198
+ let freshnessNoticeSent = false;
249199
+ let nextPollMs = WATCH_POLL_MS;
249103
249200
  let failedPolls = 0;
249104
249201
  let failureStartedAt;
249105
249202
  let lastNotifiedError;
249106
249203
  while (processState.status === "running") {
249107
249204
  try {
249108
- await wait(controller.signal, pollDelayMs(failedPolls));
249205
+ await wait(controller.signal, nextPollMs);
249109
249206
  if (processState.status !== "running")
249110
249207
  return;
249111
249208
  const current = await fetchSnapshot(ref, {
@@ -249114,6 +249211,12 @@ ${event}
249114
249211
  });
249115
249212
  if (processState.status !== "running")
249116
249213
  return;
249214
+ lastFreshSnapshotAt = now2();
249215
+ if (freshnessNoticeSent) {
249216
+ emit(["WatchPR is receiving PR updates again."]);
249217
+ freshnessNoticeSent = false;
249218
+ }
249219
+ nextPollMs = WATCH_POLL_MS;
249117
249220
  if (lastNotifiedError !== undefined) {
249118
249221
  emit([
249119
249222
  `WatchPR recovered after ${failedPolls} failed poll${failedPolls === 1 ? "" : "s"}.`
@@ -249140,7 +249243,25 @@ ${event}
249140
249243
  if (controller.signal.aborted || processState.status !== "running") {
249141
249244
  return;
249142
249245
  }
249246
+ if (!freshnessNoticeSent && now2() - lastFreshSnapshotAt >= WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS) {
249247
+ emit([
249248
+ "WatchPR hasn't received fresh PR data for 30 minutes; still watching."
249249
+ ]);
249250
+ freshnessNoticeSent = true;
249251
+ }
249252
+ if (error4 instanceof GitHubPullRequestSnapshotPending) {
249253
+ nextPollMs = WATCH_POLL_MS;
249254
+ if (!output.append(`[poll pending] Waiting for fresh PR data
249255
+ `)) {
249256
+ processState.completionNotificationSuppressed = true;
249257
+ markMonitorFinished(taskId, processState, "failed", null);
249258
+ controller.abort();
249259
+ return;
249260
+ }
249261
+ continue;
249262
+ }
249143
249263
  failedPolls += 1;
249264
+ nextPollMs = pollDelayMs(failedPolls);
249144
249265
  failureStartedAt ??= now2();
249145
249266
  const message2 = errorText(error4);
249146
249267
  if (!output.append(`[poll error ${failedPolls}] ${message2}
@@ -249183,7 +249304,7 @@ Output file: ${outputFile}`
249183
249304
  persistent
249184
249305
  };
249185
249306
  }
249186
- var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS;
249307
+ var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS, WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS;
249187
249308
  var init_watch_pr = __esm(() => {
249188
249309
  init_runtime_context();
249189
249310
  init_secret_substitution();
@@ -249198,6 +249319,7 @@ var init_watch_pr = __esm(() => {
249198
249319
  init_process_manager();
249199
249320
  WATCH_MAX_POLL_MS = 5 * 60000;
249200
249321
  WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS = 5 * 60000;
249322
+ WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS = 30 * 60000;
249201
249323
  });
249202
249324
 
249203
249325
  // src/tools/workflow/sdk-loader.ts
@@ -250785,57 +250907,6 @@ var init_Monitor2 = __esm(() => {
250785
250907
  },
250786
250908
  args: {
250787
250909
  description: "Optional input exposed to script as args."
250788
- },
250789
- url: {
250790
- type: "string",
250791
- description: "Public http(s) URL that Letta Cloud polls with GET. By default it notifies only when the HTTP status or body changes; use select and match to narrow that. timeout_ms defaults to 24 hours here, up to 7 days. Cannot be combined with command, ws, or script."
250792
- },
250793
- interval_seconds: {
250794
- type: "integer",
250795
- minimum: 60,
250796
- default: 60,
250797
- description: "Seconds between polls of url."
250798
- },
250799
- headers: {
250800
- type: "object",
250801
- additionalProperties: {
250802
- type: "string"
250803
- },
250804
- description: `Request headers for url, at most 10. Reference agent secrets as $NAME, as in shell commands, e.g. {"PRIVATE-TOKEN": "$GITLAB_TOKEN"} or {"Authorization": "Bearer $CI_TOKEN"}. Cloud fills them in on every poll; the value is never sent from here. Credential headers must use a secret reference. Headers are dropped if a redirect leaves the URL's origin.`
250805
- },
250806
- select: {
250807
- type: "string",
250808
- description: "For url: a dot-separated path into the JSON response (numbers index arrays), e.g. 0.status. Only that value is compared and reported, so unrelated fields changing does not notify."
250809
- },
250810
- match: {
250811
- type: "object",
250812
- properties: {
250813
- equals: {
250814
- type: "array",
250815
- items: {
250816
- type: "string"
250817
- },
250818
- description: "Matches when the value is one of these."
250819
- },
250820
- contains: {
250821
- type: "string",
250822
- description: "Matches when the value contains this text."
250823
- },
250824
- gt: {
250825
- type: "number",
250826
- description: "Matches when the value is a number greater than this."
250827
- },
250828
- lt: {
250829
- type: "number",
250830
- description: "Matches when the value is a number less than this."
250831
- }
250832
- },
250833
- additionalProperties: false,
250834
- description: 'For url: notify when the compared value starts to meet every given test, instead of on every change. The first response is checked too, and a value that keeps matching does not notify again. List every terminal state, e.g. equals ["success", "failed", "canceled"].'
250835
- },
250836
- stop_on_match: {
250837
- type: "boolean",
250838
- description: "For url with match: stop after the first match notice."
250839
250910
  }
250840
250911
  },
250841
250912
  required: ["description"],
@@ -445622,12 +445693,12 @@ function rowToolCalls(row, index, diagnostics2) {
445622
445693
  }
445623
445694
  return calls;
445624
445695
  }
445625
- function contentText3(content) {
445696
+ function contentText4(content) {
445626
445697
  if (typeof content === "string") {
445627
445698
  if (content.startsWith(CONTENT_JSON_PREFIX)) {
445628
445699
  const encoded = content.slice(CONTENT_JSON_PREFIX.length);
445629
445700
  try {
445630
- return contentText3(JSON.parse(encoded));
445701
+ return contentText4(JSON.parse(encoded));
445631
445702
  } catch {
445632
445703
  return encoded;
445633
445704
  }
@@ -445713,7 +445784,7 @@ var init_hermes = __esm(() => {
445713
445784
  });
445714
445785
  };
445715
445786
  if (row.role === "user") {
445716
- const content = contentText3(row.content);
445787
+ const content = contentText4(row.content);
445717
445788
  if (content) {
445718
445789
  emit({
445719
445790
  type: "message",
@@ -445733,7 +445804,7 @@ var init_hermes = __esm(() => {
445733
445804
  ...timestamp ? { timestamp } : {}
445734
445805
  });
445735
445806
  }
445736
- const content = contentText3(row.content);
445807
+ const content = contentText4(row.content);
445737
445808
  if (content) {
445738
445809
  emit({
445739
445810
  type: "message",
@@ -445756,7 +445827,7 @@ var init_hermes = __esm(() => {
445756
445827
  if (row.role === "tool") {
445757
445828
  emit({
445758
445829
  type: "tool_result",
445759
- content: contentText3(row.content),
445830
+ content: contentText4(row.content),
445760
445831
  ...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
445761
445832
  ...timestamp ? { timestamp } : {}
445762
445833
  });
@@ -536144,4 +536215,4 @@ function registerBunOAuthFlows() {
536144
536215
  registerBunOAuthFlows();
536145
536216
  await init_src5().then(() => exports_src2);
536146
536217
 
536147
- //# debugId=C40CE847F39A40A264756E2164756E21
536218
+ //# debugId=8A80CC6321F2F8A164756E2164756E21
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.34.57",
3
+ "version": "0.34.58",
4
4
  "lockfileVersion": 3,
5
5
  "packages": {
6
6
  "node_modules/@alcalzone/ansi-tokenize": {
@@ -5083,7 +5083,7 @@
5083
5083
  },
5084
5084
  "": {
5085
5085
  "name": "@letta-ai/letta-code",
5086
- "version": "0.34.57",
5086
+ "version": "0.34.58",
5087
5087
  "dependencies": {
5088
5088
  "@cursor/sdk": "1.1.0",
5089
5089
  "@earendil-works/pi-ai": "^1.5.2",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letta-ai/letta-code",
3
- "version": "0.34.57",
3
+ "version": "0.34.58",
4
4
  "lettaStartupLogProtocol": 1,
5
5
  "lettaConfigDirProtocol": 1,
6
6
  "description": "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",