@letta-ai/letta-code 0.34.61 → 0.34.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels-public.js +2 -1
- package/dist/channels-public.js.map +3 -3
- package/dist/mcp-client.js +2 -2
- package/dist/mcp-client.js.map +1 -1
- package/dist/mcp-oauth.js +2 -2
- package/dist/mcp-oauth.js.map +1 -1
- package/dist/types/agent/subagents/remote-turn-wait.d.ts.map +1 -1
- package/dist/types/backend/api/monitors.d.ts +11 -2
- package/dist/types/backend/api/monitors.d.ts.map +1 -1
- package/dist/types/channels/xml.d.ts +5 -0
- package/dist/types/channels/xml.d.ts.map +1 -1
- package/dist/types/channels-public.d.ts +1 -0
- package/dist/types/channels-public.d.ts.map +1 -1
- package/dist/types/cli/helpers/session-context.d.ts +2 -1
- package/dist/types/cli/helpers/session-context.d.ts.map +1 -1
- package/dist/types/cron/runner.d.ts +12 -14
- package/dist/types/cron/runner.d.ts.map +1 -1
- package/dist/types/cron/scheduler.d.ts.map +1 -1
- package/dist/types/queue/queue-runtime.d.ts +1 -1
- package/dist/types/queue/queue-runtime.d.ts.map +1 -1
- package/dist/types/queue/turn-queue-runtime.d.ts +4 -0
- package/dist/types/queue/turn-queue-runtime.d.ts.map +1 -1
- package/dist/types/runtime-context.d.ts +4 -0
- package/dist/types/runtime-context.d.ts.map +1 -1
- package/dist/types/tools/external-tool-background.d.ts.map +1 -1
- package/dist/types/tools/impl/claude-steer-timeouts.d.ts +20 -0
- package/dist/types/tools/impl/claude-steer-timeouts.d.ts.map +1 -0
- package/dist/types/tools/impl/claude-stream-session-types.d.ts +112 -0
- package/dist/types/tools/impl/claude-stream-session-types.d.ts.map +1 -0
- package/dist/types/tools/impl/claude-stream-session.d.ts +2 -46
- package/dist/types/tools/impl/claude-stream-session.d.ts.map +1 -1
- package/dist/types/tools/impl/external-coding-agent.d.ts +2 -2
- package/dist/types/tools/impl/external-coding-agent.d.ts.map +1 -1
- package/dist/types/tools/impl/fork-prompt.d.ts +4 -0
- package/dist/types/tools/impl/fork-prompt.d.ts.map +1 -0
- package/dist/types/tools/impl/kill-bash.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-args.d.ts +32 -0
- package/dist/types/tools/impl/monitor-args.d.ts.map +1 -0
- package/dist/types/tools/impl/monitor-resume.d.ts +7 -0
- package/dist/types/tools/impl/monitor-resume.d.ts.map +1 -0
- package/dist/types/tools/impl/monitor-script.d.ts +1 -1
- package/dist/types/tools/impl/monitor-script.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-state.d.ts +4 -0
- package/dist/types/tools/impl/monitor-state.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-timeout.d.ts +1 -0
- package/dist/types/tools/impl/monitor-timeout.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor.d.ts +2 -32
- package/dist/types/tools/impl/monitor.d.ts.map +1 -1
- package/dist/types/tools/impl/process_manager.d.ts +1 -0
- package/dist/types/tools/impl/process_manager.d.ts.map +1 -1
- package/dist/types/tools/impl/remote-external-coding-agent.d.ts +1 -1
- package/dist/types/tools/impl/remote-external-coding-agent.d.ts.map +1 -1
- package/dist/types/tools/impl/send-agent-message.d.ts.map +1 -1
- package/dist/types/tools/impl/shell-env.d.ts.map +1 -1
- package/dist/types/tools/impl/subagent-computer.d.ts +5 -5
- package/dist/types/tools/impl/task.d.ts.map +1 -1
- package/dist/types/tools/impl/wake.d.ts.map +1 -1
- package/dist/types/tools/impl/watch-pr.d.ts +2 -1
- package/dist/types/tools/impl/watch-pr.d.ts.map +1 -1
- package/dist/types/tools/task-tool-assets.d.ts +1 -1
- package/dist/types/tools/task-tool-assets.d.ts.map +1 -1
- package/dist/types/tools/toolset-catalog.d.ts +1 -1
- package/dist/types/tools/toolset.d.ts +1 -1
- package/dist/types/tools/toolset.d.ts.map +1 -1
- package/dist/types/types/subagent-protocol.d.ts +1 -1
- package/dist/types/types/subagent-protocol.d.ts.map +1 -1
- package/dist/types/utils/message-queue-bridge.d.ts +1 -1
- package/dist/types/utils/message-queue-bridge.d.ts.map +1 -1
- package/dist/types/utils/task-notifications.d.ts +5 -0
- package/dist/types/utils/task-notifications.d.ts.map +1 -1
- package/dist/types/websocket/listener/interrupted-turn-disk-reserve.d.ts +6 -0
- package/dist/types/websocket/listener/interrupted-turn-disk-reserve.d.ts.map +1 -0
- package/dist/types/websocket/listener/interrupted-turn-record.d.ts.map +1 -1
- package/letta.js +846 -401
- package/npm-shrinkwrap.json +5 -5
- package/package.json +2 -2
- package/scripts/source-file-size-baseline.json +1 -1
- package/skills/scheduling-tasks/SKILL.md +6 -20
package/letta.js
CHANGED
|
@@ -4892,6 +4892,10 @@ import { homedir as homedir2, tmpdir } from "node:os";
|
|
|
4892
4892
|
function getRuntimeContext() {
|
|
4893
4893
|
return runtimeContextStorage.getStore();
|
|
4894
4894
|
}
|
|
4895
|
+
function getRuntimeSessionSource() {
|
|
4896
|
+
const source = getRuntimeContext()?.sessionSource ?? process.env.LETTA_RUNTIME_SESSION_SOURCE;
|
|
4897
|
+
return source === "interactive-cli" || source === "headless" || source === "listen" ? source : undefined;
|
|
4898
|
+
}
|
|
4895
4899
|
function getRuntimeActingUserId() {
|
|
4896
4900
|
const context = getRuntimeContext();
|
|
4897
4901
|
if (context?.suppressActingUserFallback)
|
|
@@ -6135,7 +6139,7 @@ var package_default;
|
|
|
6135
6139
|
var init_package = __esm(() => {
|
|
6136
6140
|
package_default = {
|
|
6137
6141
|
name: "@letta-ai/letta-code",
|
|
6138
|
-
version: "0.34.
|
|
6142
|
+
version: "0.34.63",
|
|
6139
6143
|
lettaStartupLogProtocol: 1,
|
|
6140
6144
|
lettaConfigDirProtocol: 1,
|
|
6141
6145
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -6422,7 +6426,7 @@ var init_package = __esm(() => {
|
|
|
6422
6426
|
},
|
|
6423
6427
|
lettaLifecycleProtocol: 1,
|
|
6424
6428
|
lettaRuntimeGraphProtocol: 1,
|
|
6425
|
-
lettaRuntimeGraphSha512: "sha512-
|
|
6429
|
+
lettaRuntimeGraphSha512: "sha512-llGcPR13/WPW010yGdtNGC7Apobzktid+4Ka3zhviUWYP60+sHx9ovVyADbq+eHG9wrgZn9zRpo+7kdJ4mnElw==",
|
|
6426
6430
|
patchedDependencies: {
|
|
6427
6431
|
"@earendil-works/pi-ai@1.5.2": "patches/@earendil-works%2Fpi-ai@1.5.2.patch"
|
|
6428
6432
|
}
|
|
@@ -164885,6 +164889,21 @@ function formatTaskNotification(notification) {
|
|
|
164885
164889
|
</task-notification>${notification.outputFile ? `
|
|
164886
164890
|
Full transcript available at: ${notification.outputFile}` : ""}`;
|
|
164887
164891
|
}
|
|
164892
|
+
function subagentResultReminder() {
|
|
164893
|
+
const reminder = process.env.LETTA_SUBAGENT_RESULT_REMINDER;
|
|
164894
|
+
return reminder ? `
|
|
164895
|
+
|
|
164896
|
+
<system-reminder>
|
|
164897
|
+
${reminder}
|
|
164898
|
+
</system-reminder>` : "";
|
|
164899
|
+
}
|
|
164900
|
+
function taskNotificationMessage(text2) {
|
|
164901
|
+
const parts = text2.split(/(?<=<\/task-notification>)\n(?=Full transcript available at:)/).map((part) => ({ type: "text", text: part }));
|
|
164902
|
+
const reminder = subagentResultReminder();
|
|
164903
|
+
if (reminder)
|
|
164904
|
+
parts.push({ type: "text", text: reminder.trimStart() });
|
|
164905
|
+
return { text: text2, content: parts };
|
|
164906
|
+
}
|
|
164888
164907
|
function formatMonitorEventNotification(notification) {
|
|
164889
164908
|
return `<task-notification>
|
|
164890
164909
|
<task-id>${escapeXml(notification.taskId)}</task-id>
|
|
@@ -203338,7 +203357,7 @@ var init_mcp_client = __esm(() => {
|
|
|
203338
203357
|
init_streamableHttp();
|
|
203339
203358
|
DEFAULT_CLIENT_INFO = {
|
|
203340
203359
|
name: "letta-code",
|
|
203341
|
-
version: "0.34.
|
|
203360
|
+
version: "0.34.63"
|
|
203342
203361
|
};
|
|
203343
203362
|
});
|
|
203344
203363
|
|
|
@@ -207246,6 +207265,129 @@ var init_durable_file_lock = __esm(() => {
|
|
|
207246
207265
|
readCurrentDurableLockOwner = createCurrentDurableLockOwner();
|
|
207247
207266
|
});
|
|
207248
207267
|
|
|
207268
|
+
// src/utils/disk-reserve.ts
|
|
207269
|
+
import {
|
|
207270
|
+
closeSync as closeSync6,
|
|
207271
|
+
existsSync as existsSync34,
|
|
207272
|
+
mkdirSync as mkdirSync30,
|
|
207273
|
+
openSync as openSync6,
|
|
207274
|
+
statSync as statSync14,
|
|
207275
|
+
unlinkSync as unlinkSync9,
|
|
207276
|
+
writeSync as writeSync3
|
|
207277
|
+
} from "node:fs";
|
|
207278
|
+
import { dirname as dirname17 } from "node:path";
|
|
207279
|
+
function device(path12) {
|
|
207280
|
+
let candidate = path12;
|
|
207281
|
+
while (!existsSync34(candidate)) {
|
|
207282
|
+
const parent = dirname17(candidate);
|
|
207283
|
+
if (parent === candidate)
|
|
207284
|
+
break;
|
|
207285
|
+
candidate = parent;
|
|
207286
|
+
}
|
|
207287
|
+
return statSync14(candidate).dev;
|
|
207288
|
+
}
|
|
207289
|
+
|
|
207290
|
+
class DiskReserve {
|
|
207291
|
+
path;
|
|
207292
|
+
notify;
|
|
207293
|
+
bytes;
|
|
207294
|
+
constructor(path12, notify2, bytes = DISK_RESERVE_BYTES) {
|
|
207295
|
+
this.path = path12;
|
|
207296
|
+
this.notify = notify2;
|
|
207297
|
+
this.bytes = bytes;
|
|
207298
|
+
}
|
|
207299
|
+
release(writePath) {
|
|
207300
|
+
try {
|
|
207301
|
+
if (device(writePath) !== device(this.path))
|
|
207302
|
+
return false;
|
|
207303
|
+
unlinkSync9(this.path);
|
|
207304
|
+
try {
|
|
207305
|
+
this.notify();
|
|
207306
|
+
} catch {}
|
|
207307
|
+
return true;
|
|
207308
|
+
} catch {
|
|
207309
|
+
return false;
|
|
207310
|
+
}
|
|
207311
|
+
}
|
|
207312
|
+
update(sample2) {
|
|
207313
|
+
try {
|
|
207314
|
+
if (device(sample2.path) !== device(this.path))
|
|
207315
|
+
return false;
|
|
207316
|
+
const used = 1 - sample2.availableBytes / sample2.totalBytes;
|
|
207317
|
+
if (used >= 0.95) {
|
|
207318
|
+
return this.release(sample2.path);
|
|
207319
|
+
}
|
|
207320
|
+
if (used >= 0.9 || sample2.availableBytes - this.bytes <= sample2.totalBytes * 0.1 || sample2.availableBytes - this.bytes < 1024 ** 3 || existsSync34(this.path))
|
|
207321
|
+
return false;
|
|
207322
|
+
mkdirSync30(dirname17(this.path), { recursive: true });
|
|
207323
|
+
const fd = openSync6(this.path, "wx", 384);
|
|
207324
|
+
try {
|
|
207325
|
+
const chunk2 = Buffer.alloc(Math.min(this.bytes, 1024 ** 2));
|
|
207326
|
+
let remaining = this.bytes;
|
|
207327
|
+
while (remaining > 0) {
|
|
207328
|
+
const written = writeSync3(fd, chunk2, 0, Math.min(remaining, chunk2.length));
|
|
207329
|
+
if (written === 0)
|
|
207330
|
+
throw new Error("Reserve allocation made no progress");
|
|
207331
|
+
remaining -= written;
|
|
207332
|
+
}
|
|
207333
|
+
} catch {
|
|
207334
|
+
try {
|
|
207335
|
+
unlinkSync9(this.path);
|
|
207336
|
+
} catch {}
|
|
207337
|
+
} finally {
|
|
207338
|
+
closeSync6(fd);
|
|
207339
|
+
}
|
|
207340
|
+
} catch {}
|
|
207341
|
+
return false;
|
|
207342
|
+
}
|
|
207343
|
+
}
|
|
207344
|
+
function setDiskReserve(reserve) {
|
|
207345
|
+
activeReserve = reserve;
|
|
207346
|
+
}
|
|
207347
|
+
function updateDiskReserve(sample2) {
|
|
207348
|
+
return activeReserve?.update(sample2) ?? false;
|
|
207349
|
+
}
|
|
207350
|
+
function withDiskReserveRetry(path12, operation) {
|
|
207351
|
+
try {
|
|
207352
|
+
return operation();
|
|
207353
|
+
} catch (error4) {
|
|
207354
|
+
if (isManagedCloudRuntime() && typeof error4 === "object" && error4 !== null && "code" in error4 && error4.code === "ENOSPC") {
|
|
207355
|
+
activeReserve?.release(path12);
|
|
207356
|
+
return operation();
|
|
207357
|
+
}
|
|
207358
|
+
throw error4;
|
|
207359
|
+
}
|
|
207360
|
+
}
|
|
207361
|
+
var DISK_RESERVE_BYTES, activeReserve = null;
|
|
207362
|
+
var init_disk_reserve = __esm(() => {
|
|
207363
|
+
DISK_RESERVE_BYTES = 512 * 1024 ** 2;
|
|
207364
|
+
});
|
|
207365
|
+
|
|
207366
|
+
// src/websocket/listener/interrupted-turn-disk-reserve.ts
|
|
207367
|
+
function withInterruptedTurnDiskReserve(directory, store2) {
|
|
207368
|
+
const wrapped = { ...store2 };
|
|
207369
|
+
for (const key2 of writes) {
|
|
207370
|
+
const operation = store2[key2];
|
|
207371
|
+
wrapped[key2] = (...args) => withDiskReserveRetry(directory, () => operation(...args));
|
|
207372
|
+
}
|
|
207373
|
+
return wrapped;
|
|
207374
|
+
}
|
|
207375
|
+
var writes;
|
|
207376
|
+
var init_interrupted_turn_disk_reserve = __esm(() => {
|
|
207377
|
+
init_disk_reserve();
|
|
207378
|
+
writes = [
|
|
207379
|
+
"write",
|
|
207380
|
+
"writeWithRecoveryAuthority",
|
|
207381
|
+
"writeRecoveryLineageSnapshot",
|
|
207382
|
+
"mergeSettledRecoveryResult",
|
|
207383
|
+
"markRecoveryClaimCompletionPending",
|
|
207384
|
+
"retireRecoveryClaimCompletion",
|
|
207385
|
+
"remove",
|
|
207386
|
+
"compactRetiredRecoverySidecar",
|
|
207387
|
+
"removeRetiredRecoverySidecar"
|
|
207388
|
+
];
|
|
207389
|
+
});
|
|
207390
|
+
|
|
207249
207391
|
// src/websocket/listener/interrupted-turn-input-ownership.ts
|
|
207250
207392
|
import { readdirSync as readdirSync11 } from "node:fs";
|
|
207251
207393
|
import { join as join46 } from "node:path";
|
|
@@ -207589,7 +207731,7 @@ Do not use this tool for root memory files (already loaded) or skills/ (use Skil
|
|
|
207589
207731
|
var init_Memory = () => {};
|
|
207590
207732
|
|
|
207591
207733
|
// src/tools/descriptions/Monitor.md
|
|
207592
|
-
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';
|
|
207734
|
+
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\nPass `resume` with a paused monitor id to restart it with its saved arguments.\n';
|
|
207593
207735
|
var init_Monitor = () => {};
|
|
207594
207736
|
|
|
207595
207737
|
// src/tools/descriptions/Read.md
|
|
@@ -207712,7 +207854,7 @@ var ViewImage_default = `View a local image file from the filesystem when visual
|
|
|
207712
207854
|
var init_ViewImage = () => {};
|
|
207713
207855
|
|
|
207714
207856
|
// src/tools/descriptions/Wake.md
|
|
207715
|
-
var Wake_default = "Schedule a future turn for the current conversation. Wake is the durable, time-based counterpart to Monitor: use Monitor when ongoing work can emit an event, and Wake when you need to act at a future time even if nothing emits one.\n\nWake is always self-bound. It cannot target another agent, conversation, or computer.\n\n- `create`: provide `name`, `prompt`, and exactly one of `after_seconds`, `scheduled_at`, or `cron`.\n- `list`: list active and paused wakes for this conversation.\n- `cancel`: provide the `id` returned by create or list.\n\nWrite `prompt` as a note to your future self, not a script: what you are waiting on, what you planned and why, and what to check before acting. When the wake fires, the situation or people's wishes may have changed since you wrote it.\n\nUse `after_seconds` for ordinary follow-ups. `scheduled_at` must be RFC 3339 with `Z` or an explicit UTC offset. `cron` is a recurring five-field UTC expression and cannot run more often than hourly. For calendar requests such as \"tomorrow at 9am,\" resolve the time in the user's timezone (inferred from context), pass an explicit offset, and state the timezone you used.\n\
|
|
207857
|
+
var Wake_default = "Schedule a future turn for the current conversation. Wake is the durable, time-based counterpart to Monitor: use Monitor when ongoing work can emit an event, and Wake when you need to act at a future time even if nothing emits one.\n\nWake is always self-bound. It cannot target another agent, conversation, or computer.\n\n- `create`: provide `name`, `prompt`, and exactly one of `after_seconds`, `scheduled_at`, or `cron`.\n- `list`: list active and paused wakes for this conversation.\n- `cancel`: provide the `id` returned by create or list.\n\nWrite `prompt` as a note to your future self, not a script: what you are waiting on, what you planned and why, and what to check before acting. When the wake fires, the situation or people's wishes may have changed since you wrote it.\n\nUse `after_seconds` for ordinary follow-ups. `scheduled_at` must be RFC 3339 with `Z` or an explicit UTC offset. `cron` is a recurring five-field UTC expression and cannot run more often than hourly. For calendar requests such as \"tomorrow at 9am,\" resolve the time in the user's timezone (inferred from context), pass an explicit offset, and state the timezone you used.\n\nFor schedules targeting other conversations or computers, load the `scheduling-tasks` skill.\n";
|
|
207716
207858
|
var init_Wake = () => {};
|
|
207717
207859
|
|
|
207718
207860
|
// src/tools/descriptions/WatchPR.md
|
|
@@ -207727,6 +207869,8 @@ The initial result includes current blockers and changes since the previous watc
|
|
|
207727
207869
|
Pass a URL ending at the PR number, such as \`https://github.com/owner/repo/pull/123\`. Remove \`/files\`, \`/commits\`, \`/checks\`, and other suffixes. The watcher is read-only and errors if the PR is already merged or closed.
|
|
207728
207870
|
|
|
207729
207871
|
Use \`notify_on\` to limit PR notifications (for example \`["merged", "closed", "conflict"]\` or \`["checks_done"]\`); watcher errors still report. For several PRs, start one watch per URL. Workflow run URLs (\`https://github.com/owner/repo/actions/runs/123\`) report status changes and completion with conclusion and failed jobs/steps, including runs without a PR. Reruns remain a separate action.
|
|
207872
|
+
|
|
207873
|
+
Pass \`resume\` with a paused monitor id to restart it with its saved arguments.
|
|
207730
207874
|
`;
|
|
207731
207875
|
var init_WatchPR = () => {};
|
|
207732
207876
|
|
|
@@ -208566,7 +208710,7 @@ var init_manager = __esm(() => {
|
|
|
208566
208710
|
|
|
208567
208711
|
// src/tools/impl/artifact-files.ts
|
|
208568
208712
|
import { mkdir as mkdir9, readFile as readFile11, stat as stat5, writeFile as writeFile12 } from "node:fs/promises";
|
|
208569
|
-
import { dirname as
|
|
208713
|
+
import { dirname as dirname19, isAbsolute as isAbsolute10, join as join47, relative as relative4, resolve as resolve14 } from "node:path";
|
|
208570
208714
|
function assertArtifactsExperimentEnabled(toolName2) {
|
|
208571
208715
|
if (!experimentManager.isEnabled("artifacts")) {
|
|
208572
208716
|
throw new Error(`${toolName2}: artifacts experiment is disabled. Enable it with /experiments in Letta Code Desktop.`);
|
|
@@ -208635,7 +208779,7 @@ async function write_artifact_file(args) {
|
|
|
208635
208779
|
const { absolutePath, relativePath } = resolveArtifactPath(args.path);
|
|
208636
208780
|
const encoding = getEncoding(args.encoding);
|
|
208637
208781
|
const buffer = Buffer.from(args.content, encoding);
|
|
208638
|
-
await mkdir9(
|
|
208782
|
+
await mkdir9(dirname19(absolutePath), { recursive: true });
|
|
208639
208783
|
await writeFile12(absolutePath, buffer);
|
|
208640
208784
|
return {
|
|
208641
208785
|
path: relativePath,
|
|
@@ -209681,15 +209825,15 @@ import { spawnSync as spawnSync4 } from "node:child_process";
|
|
|
209681
209825
|
import {
|
|
209682
209826
|
chmodSync as chmodSync8,
|
|
209683
209827
|
createWriteStream as createWriteStream3,
|
|
209684
|
-
existsSync as
|
|
209685
|
-
mkdirSync as
|
|
209828
|
+
existsSync as existsSync35,
|
|
209829
|
+
mkdirSync as mkdirSync31,
|
|
209686
209830
|
readdirSync as readdirSync12,
|
|
209687
209831
|
renameSync as renameSync9,
|
|
209688
209832
|
rmSync as rmSync13
|
|
209689
209833
|
} from "node:fs";
|
|
209690
209834
|
import { createRequire as createRequire4 } from "node:module";
|
|
209691
209835
|
import { arch as arch3, platform as platform5 } from "node:os";
|
|
209692
|
-
import { dirname as
|
|
209836
|
+
import { dirname as dirname20, isAbsolute as isAbsolute11, join as join48 } from "node:path";
|
|
209693
209837
|
import { Readable as Readable3 } from "node:stream";
|
|
209694
209838
|
import { pipeline as pipeline4 } from "node:stream/promises";
|
|
209695
209839
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
@@ -209727,7 +209871,7 @@ function getRipgrepPath(options = {}) {
|
|
|
209727
209871
|
const env6 = options.env ?? process.env;
|
|
209728
209872
|
const config2 = RIPGREP_CONFIG;
|
|
209729
209873
|
const managedPath = join48(getManagedToolsDir(env6), binaryName(config2));
|
|
209730
|
-
if (
|
|
209874
|
+
if (existsSync35(managedPath) && commandWorks(managedPath, env6)) {
|
|
209731
209875
|
return managedPath;
|
|
209732
209876
|
}
|
|
209733
209877
|
const systemBinaryNames = config2.systemBinaryNames ?? [config2.binaryName];
|
|
@@ -209737,7 +209881,7 @@ function getRipgrepPath(options = {}) {
|
|
|
209737
209881
|
}
|
|
209738
209882
|
}
|
|
209739
209883
|
const bundledPath = getBundledRipgrepPath();
|
|
209740
|
-
if (bundledPath &&
|
|
209884
|
+
if (bundledPath && existsSync35(bundledPath) && commandWorks(bundledPath, env6)) {
|
|
209741
209885
|
return bundledPath;
|
|
209742
209886
|
}
|
|
209743
209887
|
return null;
|
|
@@ -209821,7 +209965,7 @@ function getWindowsTarCommand2() {
|
|
|
209821
209965
|
const systemRoot = process.env.SystemRoot ?? process.env.WINDIR;
|
|
209822
209966
|
if (systemRoot) {
|
|
209823
209967
|
const systemTar = join48(systemRoot, "System32", "tar.exe");
|
|
209824
|
-
if (
|
|
209968
|
+
if (existsSync35(systemTar)) {
|
|
209825
209969
|
return systemTar;
|
|
209826
209970
|
}
|
|
209827
209971
|
}
|
|
@@ -209886,14 +210030,14 @@ async function downloadRipgrep() {
|
|
|
209886
210030
|
throw new Error(`Unsupported platform: ${plat}/${architecture}`);
|
|
209887
210031
|
}
|
|
209888
210032
|
const toolsDir = getManagedToolsDir();
|
|
209889
|
-
|
|
210033
|
+
mkdirSync31(toolsDir, { recursive: true });
|
|
209890
210034
|
const downloadUrl = `https://github.com/${config2.repo}/releases/download/${config2.tagPrefix}${version3}/${assetName}`;
|
|
209891
210035
|
const archivePath = join48(toolsDir, assetName);
|
|
209892
210036
|
const binaryFileName = binaryName(config2);
|
|
209893
210037
|
const binaryPath = join48(toolsDir, binaryFileName);
|
|
209894
210038
|
await downloadFile3(downloadUrl, archivePath);
|
|
209895
210039
|
const extractDir = join48(toolsDir, `extract_tmp_${config2.binaryName}_${process.pid}_${Date.now()}_${Math.random().toString(36).slice(2, 10)}`);
|
|
209896
|
-
|
|
210040
|
+
mkdirSync31(extractDir, { recursive: true });
|
|
209897
210041
|
try {
|
|
209898
210042
|
if (assetName.endsWith(".tar.gz")) {
|
|
209899
210043
|
extractTarGzArchive2(archivePath, extractDir, assetName);
|
|
@@ -209907,7 +210051,7 @@ async function downloadRipgrep() {
|
|
|
209907
210051
|
join48(extractedDir, binaryFileName),
|
|
209908
210052
|
join48(extractDir, binaryFileName)
|
|
209909
210053
|
];
|
|
209910
|
-
let extractedBinary = extractedBinaryCandidates.find((candidate) =>
|
|
210054
|
+
let extractedBinary = extractedBinaryCandidates.find((candidate) => existsSync35(candidate));
|
|
209911
210055
|
if (!extractedBinary) {
|
|
209912
210056
|
extractedBinary = findBinaryRecursively2(extractDir, binaryFileName) ?? undefined;
|
|
209913
210057
|
}
|
|
@@ -209964,7 +210108,7 @@ function getRipgrepBinDir(options = {}) {
|
|
|
209964
210108
|
const rgPath = getRipgrepPath(options);
|
|
209965
210109
|
if (!rgPath || !isAbsolute11(rgPath))
|
|
209966
210110
|
return;
|
|
209967
|
-
return
|
|
210111
|
+
return dirname20(rgPath);
|
|
209968
210112
|
}
|
|
209969
210113
|
var TOOLS_DIR_ENV = "LETTA_CODE_TOOLS_DIR", OFFLINE_ENV = "LETTA_CODE_OFFLINE", NETWORK_TIMEOUT_MS = 1e4, DOWNLOAD_TIMEOUT_MS = 120000, APP_USER_AGENT = "letta-code", RIPGREP_CONFIG;
|
|
209970
210114
|
var init_ripgrep_manager = __esm(() => {
|
|
@@ -210003,7 +210147,7 @@ __export(exports_shell_env, {
|
|
|
210003
210147
|
getLettaShimDir: () => getLettaShimDir,
|
|
210004
210148
|
ensureLettaShimDir: () => ensureLettaShimDir
|
|
210005
210149
|
});
|
|
210006
|
-
import { mkdirSync as
|
|
210150
|
+
import { mkdirSync as mkdirSync32, writeFileSync as writeFileSync25 } from "node:fs";
|
|
210007
210151
|
import { createRequire as createRequire5 } from "node:module";
|
|
210008
210152
|
import { tmpdir as tmpdir10 } from "node:os";
|
|
210009
210153
|
import * as path14 from "node:path";
|
|
@@ -210097,7 +210241,7 @@ function ensureLettaShimDir(invocation, electronExecPath = process.versions.elec
|
|
|
210097
210241
|
if (!invocation.command)
|
|
210098
210242
|
return null;
|
|
210099
210243
|
const shimDir = getLettaShimDir();
|
|
210100
|
-
|
|
210244
|
+
mkdirSync32(shimDir, { recursive: true });
|
|
210101
210245
|
if (process.platform === "win32") {
|
|
210102
210246
|
const cmdPath = path14.join(shimDir, "letta.cmd");
|
|
210103
210247
|
const quotedCommand = `"${invocation.command.replaceAll('"', '""')}"`;
|
|
@@ -210210,6 +210354,11 @@ function getShellEnv() {
|
|
|
210210
210354
|
env6[pathKey] = existingPath ? `${pathPrefixes.join(shellPathDelimiter())}${shellPathDelimiter()}${existingPath}` : pathPrefixes.join(shellPathDelimiter());
|
|
210211
210355
|
}
|
|
210212
210356
|
env6.USER_CWD = getCurrentWorkingDirectory();
|
|
210357
|
+
const sessionSource = getRuntimeSessionSource();
|
|
210358
|
+
if (sessionSource)
|
|
210359
|
+
env6.LETTA_RUNTIME_SESSION_SOURCE = sessionSource;
|
|
210360
|
+
else
|
|
210361
|
+
delete env6.LETTA_RUNTIME_SESSION_SOURCE;
|
|
210213
210362
|
const environmentDeviceId = getRuntimeContext()?.environmentDeviceId?.trim();
|
|
210214
210363
|
if (environmentDeviceId) {
|
|
210215
210364
|
env6.LETTA_RUNTIME_ENVIRONMENT_DEVICE_ID = environmentDeviceId;
|
|
@@ -210641,7 +210790,7 @@ var init_mcp_originator_resolver = __esm(() => {
|
|
|
210641
210790
|
|
|
210642
210791
|
// src/backend/api/mcp-subprocess-broker.ts
|
|
210643
210792
|
import { randomBytes as randomBytes4, timingSafeEqual } from "node:crypto";
|
|
210644
|
-
import { chmodSync as chmodSync9, existsSync as
|
|
210793
|
+
import { chmodSync as chmodSync9, existsSync as existsSync36, unlinkSync as unlinkSync10, writeFileSync as writeFileSync26 } from "node:fs";
|
|
210645
210794
|
import { readFile as readFile12 } from "node:fs/promises";
|
|
210646
210795
|
import {
|
|
210647
210796
|
createServer as createServer5,
|
|
@@ -210876,9 +211025,9 @@ function createMcpSubprocessBroker(options) {
|
|
|
210876
211025
|
try {
|
|
210877
211026
|
server2.close();
|
|
210878
211027
|
} catch {}
|
|
210879
|
-
if (
|
|
211028
|
+
if (existsSync36(socket)) {
|
|
210880
211029
|
try {
|
|
210881
|
-
|
|
211030
|
+
unlinkSync10(socket);
|
|
210882
211031
|
} catch {}
|
|
210883
211032
|
}
|
|
210884
211033
|
}
|
|
@@ -211830,7 +211979,7 @@ var init_seatbelt = __esm(() => {
|
|
|
211830
211979
|
|
|
211831
211980
|
// src/sandbox/availability.ts
|
|
211832
211981
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
211833
|
-
import { existsSync as
|
|
211982
|
+
import { existsSync as existsSync37 } from "node:fs";
|
|
211834
211983
|
import { delimiter as delimiter4, isAbsolute as isAbsolute13, join as join51 } from "node:path";
|
|
211835
211984
|
function detectSandboxBackend(options = {}) {
|
|
211836
211985
|
const platform7 = options.platform ?? process.platform;
|
|
@@ -211862,7 +212011,7 @@ function warnSandboxBackendUnavailable(availability, context3) {
|
|
|
211862
212011
|
}
|
|
211863
212012
|
function probe(platform7) {
|
|
211864
212013
|
if (platform7 === "darwin") {
|
|
211865
|
-
if (
|
|
212014
|
+
if (existsSync37(SANDBOX_EXEC_PATH)) {
|
|
211866
212015
|
return { backend: "seatbelt", reason: "sandbox-exec available" };
|
|
211867
212016
|
}
|
|
211868
212017
|
return {
|
|
@@ -211897,13 +212046,13 @@ function probeBwrap() {
|
|
|
211897
212046
|
return { backend: "bwrap", bwrapPath, reason: "bwrap available" };
|
|
211898
212047
|
}
|
|
211899
212048
|
function resolveExecutableOnPath(executable, envPath = process.env.PATH) {
|
|
211900
|
-
if (isAbsolute13(executable) &&
|
|
212049
|
+
if (isAbsolute13(executable) && existsSync37(executable))
|
|
211901
212050
|
return executable;
|
|
211902
212051
|
for (const dir of (envPath ?? "").split(delimiter4)) {
|
|
211903
212052
|
if (!dir)
|
|
211904
212053
|
continue;
|
|
211905
212054
|
const candidate = join51(dir, executable);
|
|
211906
|
-
if (
|
|
212055
|
+
if (existsSync37(candidate))
|
|
211907
212056
|
return candidate;
|
|
211908
212057
|
}
|
|
211909
212058
|
return null;
|
|
@@ -211916,7 +212065,7 @@ var init_availability = __esm(() => {
|
|
|
211916
212065
|
|
|
211917
212066
|
// src/permissions/memory-paths.ts
|
|
211918
212067
|
import { homedir as homedir10 } from "node:os";
|
|
211919
|
-
import { basename as basename19, dirname as
|
|
212068
|
+
import { basename as basename19, dirname as dirname22, isAbsolute as isAbsolute14, resolve as resolve16 } from "node:path";
|
|
211920
212069
|
function normalizeMemoryPath(path16) {
|
|
211921
212070
|
const resolvedPath = resolve16(expandHomePath(path16));
|
|
211922
212071
|
const normalized = resolvedPath.replace(/\\/g, "/");
|
|
@@ -211963,7 +212112,7 @@ function addRootAndSiblingWorktree(root2, acc) {
|
|
|
211963
212112
|
acc.add(normalizedRoot);
|
|
211964
212113
|
const leaf = basename19(normalizedRoot);
|
|
211965
212114
|
if (leaf === "memory") {
|
|
211966
|
-
acc.add(normalizeMemoryPath(resolve16(
|
|
212115
|
+
acc.add(normalizeMemoryPath(resolve16(dirname22(normalizedRoot), "memory-worktrees")));
|
|
211967
212116
|
}
|
|
211968
212117
|
}
|
|
211969
212118
|
function getExplicitEnvRoots(env6) {
|
|
@@ -212042,9 +212191,9 @@ var init_memory_paths = __esm(() => {
|
|
|
212042
212191
|
});
|
|
212043
212192
|
|
|
212044
212193
|
// src/permissions/sandbox-policy.ts
|
|
212045
|
-
import { existsSync as
|
|
212194
|
+
import { existsSync as existsSync38, realpathSync as realpathSync6 } from "node:fs";
|
|
212046
212195
|
import { homedir as homedir11 } from "node:os";
|
|
212047
|
-
import { basename as basename20, dirname as
|
|
212196
|
+
import { basename as basename20, dirname as dirname23, isAbsolute as isAbsolute15, join as join52, resolve as resolve17 } from "node:path";
|
|
212048
212197
|
function getCrossBackendAgentsTreeRoots(options = {}) {
|
|
212049
212198
|
const homeDir = options.homeDir;
|
|
212050
212199
|
const env6 = options.env ?? process.env;
|
|
@@ -212072,9 +212221,9 @@ function canonicalizeRoot(input) {
|
|
|
212072
212221
|
const abs = isAbsolute15(input) ? input : resolve17(input);
|
|
212073
212222
|
let dir = abs;
|
|
212074
212223
|
const tail2 = [];
|
|
212075
|
-
while (!
|
|
212224
|
+
while (!existsSync38(dir)) {
|
|
212076
212225
|
tail2.unshift(basename20(dir));
|
|
212077
|
-
const parent =
|
|
212226
|
+
const parent = dirname23(dir);
|
|
212078
212227
|
if (parent === dir) {
|
|
212079
212228
|
return normalizeSandboxPath(abs);
|
|
212080
212229
|
}
|
|
@@ -212108,8 +212257,8 @@ function deriveSelfAgentRootsForTrees(memoryRoots, agentsTreeRoots = getCrossBac
|
|
|
212108
212257
|
const containingTree = canonicalTrees.find((tree) => canon !== tree && isWithinRoot(canon, tree));
|
|
212109
212258
|
if (containingTree) {
|
|
212110
212259
|
const leaf = basename20(canon);
|
|
212111
|
-
const parentLeaf = basename20(
|
|
212112
|
-
out.add(leaf === "memory" || leaf === "memory-worktrees" ?
|
|
212260
|
+
const parentLeaf = basename20(dirname23(canon));
|
|
212261
|
+
out.add(leaf === "memory" || leaf === "memory-worktrees" ? dirname23(canon) : parentLeaf === "memory-worktrees" || parentLeaf === "memory" && leaf === ".git" ? dirname23(dirname23(canon)) : canon);
|
|
212113
212262
|
continue;
|
|
212114
212263
|
}
|
|
212115
212264
|
if (!isTreeOrAncestorOfTree(canon, canonicalTrees)) {
|
|
@@ -212872,7 +213021,7 @@ var init_cross_agent_guard = __esm(() => {
|
|
|
212872
213021
|
});
|
|
212873
213022
|
|
|
212874
213023
|
// src/permissions/workspace-sandbox.ts
|
|
212875
|
-
import { statSync as
|
|
213024
|
+
import { statSync as statSync15 } from "node:fs";
|
|
212876
213025
|
import { isAbsolute as isAbsolute16, resolve as resolve18 } from "node:path";
|
|
212877
213026
|
function resolveWorkspaceSandbox(input, options = {}) {
|
|
212878
213027
|
if (!isAbsolute16(input.root) || !isAbsolute16(input.isolationRoot)) {
|
|
@@ -212880,10 +213029,10 @@ function resolveWorkspaceSandbox(input, options = {}) {
|
|
|
212880
213029
|
}
|
|
212881
213030
|
const root2 = canonicalizeRoot(input.root);
|
|
212882
213031
|
const isolationRoot = canonicalizeRoot(input.isolationRoot);
|
|
212883
|
-
if (!
|
|
213032
|
+
if (!statSync15(root2, { throwIfNoEntry: false })?.isDirectory()) {
|
|
212884
213033
|
throw new Error("workspace sandbox root must be an existing directory");
|
|
212885
213034
|
}
|
|
212886
|
-
if (!
|
|
213035
|
+
if (!statSync15(isolationRoot, { throwIfNoEntry: false })?.isDirectory()) {
|
|
212887
213036
|
throw new Error("workspace sandbox isolation root must be an existing directory");
|
|
212888
213037
|
}
|
|
212889
213038
|
if (root2 === isolationRoot || !root2.startsWith(`${isolationRoot}/`)) {
|
|
@@ -213915,104 +214064,6 @@ var init_client_tool_serialization = __esm(() => {
|
|
|
213915
214064
|
init_debug();
|
|
213916
214065
|
});
|
|
213917
214066
|
|
|
213918
|
-
// src/utils/disk-reserve.ts
|
|
213919
|
-
import {
|
|
213920
|
-
closeSync as closeSync6,
|
|
213921
|
-
existsSync as existsSync39,
|
|
213922
|
-
mkdirSync as mkdirSync33,
|
|
213923
|
-
openSync as openSync6,
|
|
213924
|
-
statSync as statSync16,
|
|
213925
|
-
unlinkSync as unlinkSync11,
|
|
213926
|
-
writeSync as writeSync3
|
|
213927
|
-
} from "node:fs";
|
|
213928
|
-
import { dirname as dirname23 } from "node:path";
|
|
213929
|
-
function device(path17) {
|
|
213930
|
-
let candidate = path17;
|
|
213931
|
-
while (!existsSync39(candidate)) {
|
|
213932
|
-
const parent = dirname23(candidate);
|
|
213933
|
-
if (parent === candidate)
|
|
213934
|
-
break;
|
|
213935
|
-
candidate = parent;
|
|
213936
|
-
}
|
|
213937
|
-
return statSync16(candidate).dev;
|
|
213938
|
-
}
|
|
213939
|
-
|
|
213940
|
-
class DiskReserve {
|
|
213941
|
-
path;
|
|
213942
|
-
notify;
|
|
213943
|
-
bytes;
|
|
213944
|
-
constructor(path17, notify2, bytes = DISK_RESERVE_BYTES) {
|
|
213945
|
-
this.path = path17;
|
|
213946
|
-
this.notify = notify2;
|
|
213947
|
-
this.bytes = bytes;
|
|
213948
|
-
}
|
|
213949
|
-
release(writePath) {
|
|
213950
|
-
try {
|
|
213951
|
-
if (device(writePath) !== device(this.path))
|
|
213952
|
-
return false;
|
|
213953
|
-
unlinkSync11(this.path);
|
|
213954
|
-
try {
|
|
213955
|
-
this.notify();
|
|
213956
|
-
} catch {}
|
|
213957
|
-
return true;
|
|
213958
|
-
} catch {
|
|
213959
|
-
return false;
|
|
213960
|
-
}
|
|
213961
|
-
}
|
|
213962
|
-
update(sample2) {
|
|
213963
|
-
try {
|
|
213964
|
-
if (device(sample2.path) !== device(this.path))
|
|
213965
|
-
return false;
|
|
213966
|
-
const used = 1 - sample2.availableBytes / sample2.totalBytes;
|
|
213967
|
-
if (used >= 0.95) {
|
|
213968
|
-
return this.release(sample2.path);
|
|
213969
|
-
}
|
|
213970
|
-
if (used >= 0.9 || sample2.availableBytes - this.bytes <= sample2.totalBytes * 0.1 || sample2.availableBytes - this.bytes < 1024 ** 3 || existsSync39(this.path))
|
|
213971
|
-
return false;
|
|
213972
|
-
mkdirSync33(dirname23(this.path), { recursive: true });
|
|
213973
|
-
const fd = openSync6(this.path, "wx", 384);
|
|
213974
|
-
try {
|
|
213975
|
-
const chunk2 = Buffer.alloc(Math.min(this.bytes, 1024 ** 2));
|
|
213976
|
-
let remaining = this.bytes;
|
|
213977
|
-
while (remaining > 0) {
|
|
213978
|
-
const written = writeSync3(fd, chunk2, 0, Math.min(remaining, chunk2.length));
|
|
213979
|
-
if (written === 0)
|
|
213980
|
-
throw new Error("Reserve allocation made no progress");
|
|
213981
|
-
remaining -= written;
|
|
213982
|
-
}
|
|
213983
|
-
} catch {
|
|
213984
|
-
try {
|
|
213985
|
-
unlinkSync11(this.path);
|
|
213986
|
-
} catch {}
|
|
213987
|
-
} finally {
|
|
213988
|
-
closeSync6(fd);
|
|
213989
|
-
}
|
|
213990
|
-
} catch {}
|
|
213991
|
-
return false;
|
|
213992
|
-
}
|
|
213993
|
-
}
|
|
213994
|
-
function setDiskReserve(reserve) {
|
|
213995
|
-
activeReserve = reserve;
|
|
213996
|
-
}
|
|
213997
|
-
function updateDiskReserve(sample2) {
|
|
213998
|
-
return activeReserve?.update(sample2) ?? false;
|
|
213999
|
-
}
|
|
214000
|
-
function withDiskReserveRetry(path17, operation) {
|
|
214001
|
-
try {
|
|
214002
|
-
return operation();
|
|
214003
|
-
} catch (error4) {
|
|
214004
|
-
if (isManagedCloudRuntime() && typeof error4 === "object" && error4 !== null && "code" in error4 && error4.code === "ENOSPC") {
|
|
214005
|
-
activeReserve?.release(path17);
|
|
214006
|
-
return operation();
|
|
214007
|
-
}
|
|
214008
|
-
throw error4;
|
|
214009
|
-
}
|
|
214010
|
-
}
|
|
214011
|
-
var DISK_RESERVE_BYTES, activeReserve = null;
|
|
214012
|
-
var init_disk_reserve = __esm(() => {
|
|
214013
|
-
DISK_RESERVE_BYTES = 512 * 1024 ** 2;
|
|
214014
|
-
});
|
|
214015
|
-
|
|
214016
214067
|
// src/reminders/disk-space.ts
|
|
214017
214068
|
import { statfs } from "node:fs/promises";
|
|
214018
214069
|
import { join as join54 } from "node:path";
|
|
@@ -216484,6 +216535,74 @@ var init_tool_registry = __esm(() => {
|
|
|
216484
216535
|
MOD_TOOLS_KEY = Symbol.for("@letta/modTools");
|
|
216485
216536
|
});
|
|
216486
216537
|
|
|
216538
|
+
// src/queue/turn-queue-runtime.ts
|
|
216539
|
+
function stringifyUnexpectedContent(content) {
|
|
216540
|
+
try {
|
|
216541
|
+
return JSON.stringify(content) ?? String(content);
|
|
216542
|
+
} catch {
|
|
216543
|
+
return String(content);
|
|
216544
|
+
}
|
|
216545
|
+
}
|
|
216546
|
+
function appendContentParts(target, content) {
|
|
216547
|
+
if (typeof content === "string") {
|
|
216548
|
+
target.push({ type: "text", text: content });
|
|
216549
|
+
return;
|
|
216550
|
+
}
|
|
216551
|
+
if (!Array.isArray(content)) {
|
|
216552
|
+
if (content === null || content === undefined)
|
|
216553
|
+
return;
|
|
216554
|
+
target.push({ type: "text", text: stringifyUnexpectedContent(content) });
|
|
216555
|
+
return;
|
|
216556
|
+
}
|
|
216557
|
+
target.push(...content);
|
|
216558
|
+
}
|
|
216559
|
+
function escapeResultText(text2) {
|
|
216560
|
+
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
216561
|
+
}
|
|
216562
|
+
function buildTaskNotificationContent(item) {
|
|
216563
|
+
return item.content ?? item.text;
|
|
216564
|
+
}
|
|
216565
|
+
function buildExternalToolNotificationContent(item) {
|
|
216566
|
+
if (item.content === undefined)
|
|
216567
|
+
return item.text;
|
|
216568
|
+
const parts = [
|
|
216569
|
+
{ type: "text", text: item.text },
|
|
216570
|
+
{ type: "text", text: `
|
|
216571
|
+
<external-tool-result>` }
|
|
216572
|
+
];
|
|
216573
|
+
const content = typeof item.content === "string" ? [{ type: "text", text: item.content }] : item.content;
|
|
216574
|
+
for (const part of content) {
|
|
216575
|
+
parts.push(part.type === "text" ? { type: "text", text: `<text>${escapeResultText(part.text)}</text>` } : part);
|
|
216576
|
+
}
|
|
216577
|
+
parts.push({ type: "text", text: "</external-tool-result>" });
|
|
216578
|
+
return parts;
|
|
216579
|
+
}
|
|
216580
|
+
function mergeQueuedTurnInput(queued, options) {
|
|
216581
|
+
if (queued.length === 0) {
|
|
216582
|
+
return null;
|
|
216583
|
+
}
|
|
216584
|
+
const separatorText = options.separatorText ?? `
|
|
216585
|
+
`;
|
|
216586
|
+
const mergedParts = [];
|
|
216587
|
+
let isFirst = true;
|
|
216588
|
+
for (const item of queued) {
|
|
216589
|
+
if (!isFirst) {
|
|
216590
|
+
mergedParts.push({ type: "text", text: separatorText });
|
|
216591
|
+
}
|
|
216592
|
+
isFirst = false;
|
|
216593
|
+
if (item.kind === "task_notification") {
|
|
216594
|
+
appendContentParts(mergedParts, buildTaskNotificationContent(item));
|
|
216595
|
+
continue;
|
|
216596
|
+
}
|
|
216597
|
+
if (item.kind === "cron_prompt") {
|
|
216598
|
+
mergedParts.push({ type: "text", text: item.text });
|
|
216599
|
+
continue;
|
|
216600
|
+
}
|
|
216601
|
+
appendContentParts(mergedParts, options.normalizeUserContent(item.content));
|
|
216602
|
+
}
|
|
216603
|
+
return mergedParts.length > 0 ? mergedParts : null;
|
|
216604
|
+
}
|
|
216605
|
+
|
|
216487
216606
|
// src/tools/external-tool-background.ts
|
|
216488
216607
|
function interruptedExternalToolResult(toolName2) {
|
|
216489
216608
|
return {
|
|
@@ -216617,16 +216736,22 @@ async function autoBackgroundExternalTool(toolName2, tool, operation, options) {
|
|
|
216617
216736
|
if (entry.completionNotificationSuppressed || await options?.shouldEnqueue?.() === false)
|
|
216618
216737
|
return;
|
|
216619
216738
|
const content = truncateByChars(raw2, LIMITS.TOOL_RETURN_MAX_CHARS + 1000, toolName2);
|
|
216739
|
+
const text2 = formatTaskNotification({
|
|
216740
|
+
taskId,
|
|
216741
|
+
status,
|
|
216742
|
+
summary: `${label} ${toolName2} ${status}`,
|
|
216743
|
+
result: content.content,
|
|
216744
|
+
usage: { durationMs: Date.now() - startedAt }
|
|
216745
|
+
});
|
|
216620
216746
|
enqueue({
|
|
216621
216747
|
kind: "task_notification",
|
|
216622
|
-
text:
|
|
216623
|
-
|
|
216624
|
-
|
|
216625
|
-
|
|
216626
|
-
|
|
216627
|
-
|
|
216628
|
-
}
|
|
216629
|
-
...richContent ? { content: richContent } : {},
|
|
216748
|
+
text: text2,
|
|
216749
|
+
...richContent ? {
|
|
216750
|
+
content: buildExternalToolNotificationContent({
|
|
216751
|
+
text: text2,
|
|
216752
|
+
content: richContent
|
|
216753
|
+
})
|
|
216754
|
+
} : {},
|
|
216630
216755
|
...scope
|
|
216631
216756
|
});
|
|
216632
216757
|
});
|
|
@@ -217141,6 +217266,14 @@ async function resolveBackendSpecificToolAssets(name, description, inputSchema)
|
|
|
217141
217266
|
inputSchema: MonitorCloud_default2
|
|
217142
217267
|
};
|
|
217143
217268
|
}
|
|
217269
|
+
if (name === "Wake" && getRuntimeSessionSource() === "interactive-cli" && process.env.LETTA_DESKTOP_MODE !== "1") {
|
|
217270
|
+
return {
|
|
217271
|
+
description: `${description.trimEnd()}
|
|
217272
|
+
|
|
217273
|
+
Wakes fire only while this session is running.`,
|
|
217274
|
+
inputSchema
|
|
217275
|
+
};
|
|
217276
|
+
}
|
|
217144
217277
|
if (name !== "Task") {
|
|
217145
217278
|
return { description, inputSchema };
|
|
217146
217279
|
}
|
|
@@ -217161,6 +217294,7 @@ async function resolveBackendSpecificToolAssets(name, description, inputSchema)
|
|
|
217161
217294
|
var init_task_tool_assets = __esm(() => {
|
|
217162
217295
|
init_backend2();
|
|
217163
217296
|
init_manager();
|
|
217297
|
+
init_runtime_context();
|
|
217164
217298
|
init_MonitorCloud();
|
|
217165
217299
|
init_MonitorCloud2();
|
|
217166
217300
|
});
|
|
@@ -233595,20 +233729,49 @@ function isManagedCloudSandbox(env6 = process.env) {
|
|
|
233595
233729
|
}
|
|
233596
233730
|
function resolveCronRunner(params) {
|
|
233597
233731
|
const { managedCloudSandbox, backendMode, cloudSchedulesSupported } = params;
|
|
233598
|
-
if (
|
|
233732
|
+
if (managedCloudSandbox) {
|
|
233733
|
+
if (backendMode === "local") {
|
|
233734
|
+
return {
|
|
233735
|
+
error: "Scheduling requires the API backend. Configure it, then retry."
|
|
233736
|
+
};
|
|
233737
|
+
}
|
|
233738
|
+
if (cloudSchedulesSupported === false) {
|
|
233739
|
+
return {
|
|
233740
|
+
error: "Scheduling is unavailable. Check the server connection, then retry."
|
|
233741
|
+
};
|
|
233742
|
+
}
|
|
233743
|
+
return { runner: "cloud", reason: "managed Cloud sandbox" };
|
|
233744
|
+
}
|
|
233745
|
+
if (backendMode === "local" || params.localSchedulesAllowed) {
|
|
233599
233746
|
return { runner: "local", reason: "local execution environment" };
|
|
233600
233747
|
}
|
|
233601
|
-
if (
|
|
233602
|
-
return {
|
|
233603
|
-
error: "
|
|
233748
|
+
if (cloudSchedulesSupported === false) {
|
|
233749
|
+
return params.cloudServer === false ? { runner: "local", reason: "server has no schedule routes" } : {
|
|
233750
|
+
error: "Scheduling is unavailable. Check the server connection, then retry."
|
|
233604
233751
|
};
|
|
233605
233752
|
}
|
|
233606
|
-
if (
|
|
233753
|
+
if (params.listenerDeviceId) {
|
|
233607
233754
|
return {
|
|
233608
|
-
|
|
233755
|
+
runner: "cloud",
|
|
233756
|
+
reason: "registered listener",
|
|
233757
|
+
targetDeviceId: params.listenerDeviceId
|
|
233609
233758
|
};
|
|
233610
233759
|
}
|
|
233611
|
-
return {
|
|
233760
|
+
return {
|
|
233761
|
+
error: "Register this computer with `letta server`, then retry."
|
|
233762
|
+
};
|
|
233763
|
+
}
|
|
233764
|
+
function allowsLocalCloudSchedules() {
|
|
233765
|
+
return process.env.LETTA_DESKTOP_MODE === "1" || getRuntimeSessionSource() === "interactive-cli";
|
|
233766
|
+
}
|
|
233767
|
+
function getLocalCronExecutionError(action = "run") {
|
|
233768
|
+
if (isManagedCloudSandbox()) {
|
|
233769
|
+
return `This schedule cannot ${action === "run" ? "run" : `be ${action}`} here. Create a replacement with Wake or letta cron.`;
|
|
233770
|
+
}
|
|
233771
|
+
if (resolveBackendMode() === "api" && isCloudServerUrl() && !allowsLocalCloudSchedules()) {
|
|
233772
|
+
return `This schedule cannot ${action === "run" ? "run" : `be ${action}`} here. Create a replacement with Wake or letta cron.`;
|
|
233773
|
+
}
|
|
233774
|
+
return;
|
|
233612
233775
|
}
|
|
233613
233776
|
async function ensureSettingsForCloud() {
|
|
233614
233777
|
const { settingsManager: settingsManager2 } = await Promise.resolve().then(() => (init_settings_manager(), exports_settings_manager));
|
|
@@ -233626,37 +233789,53 @@ async function probeCloudScheduleSupport(agentId) {
|
|
|
233626
233789
|
}
|
|
233627
233790
|
}
|
|
233628
233791
|
async function resolveCronRunnerForAgent(agentId) {
|
|
233629
|
-
const backendMode = resolveBackendMode();
|
|
233792
|
+
const backendMode = isLocalAgentId(agentId) ? "local" : resolveBackendMode();
|
|
233630
233793
|
const managedCloudSandbox = isManagedCloudSandbox();
|
|
233631
|
-
const
|
|
233632
|
-
|
|
233633
|
-
|
|
233794
|
+
const localSchedulesAllowed = allowsLocalCloudSchedules();
|
|
233795
|
+
const cloudServer = isCloudServerUrl();
|
|
233796
|
+
if (backendMode === "local" || !managedCloudSandbox && localSchedulesAllowed) {
|
|
233797
|
+
return resolveCronRunner({
|
|
233798
|
+
managedCloudSandbox,
|
|
233799
|
+
backendMode,
|
|
233800
|
+
localSchedulesAllowed
|
|
233801
|
+
});
|
|
233802
|
+
}
|
|
233803
|
+
const deviceId = getRuntimeContext()?.environmentDeviceId?.trim() || process.env.LETTA_RUNTIME_ENVIRONMENT_DEVICE_ID?.trim();
|
|
233804
|
+
let listenerDeviceId;
|
|
233805
|
+
if (!managedCloudSandbox && deviceId) {
|
|
233806
|
+
const environment = await lookupEnvironmentForTarget(deviceId);
|
|
233807
|
+
if (environment && validateTargetDevice(deviceId, environment).ok) {
|
|
233808
|
+
listenerDeviceId = deviceId;
|
|
233809
|
+
}
|
|
233634
233810
|
}
|
|
233635
233811
|
await ensureSettingsForCloud();
|
|
233636
233812
|
const cloudSchedulesSupported = await probeCloudScheduleSupport(agentId);
|
|
233637
233813
|
return resolveCronRunner({
|
|
233638
233814
|
managedCloudSandbox,
|
|
233639
233815
|
backendMode,
|
|
233640
|
-
cloudSchedulesSupported
|
|
233816
|
+
cloudSchedulesSupported,
|
|
233817
|
+
listenerDeviceId,
|
|
233818
|
+
localSchedulesAllowed,
|
|
233819
|
+
cloudServer
|
|
233641
233820
|
});
|
|
233642
233821
|
}
|
|
233643
233822
|
function validateTargetDevice(deviceId, environment) {
|
|
233644
233823
|
if (deviceId === SYNTHETIC_CLOUD_DEVICE_ID) {
|
|
233645
233824
|
return {
|
|
233646
233825
|
ok: false,
|
|
233647
|
-
error:
|
|
233826
|
+
error: "Choose a computer from `letta computers list`."
|
|
233648
233827
|
};
|
|
233649
233828
|
}
|
|
233650
233829
|
if (deviceId === SYNTHETIC_LOCAL_PLACEHOLDER_ID) {
|
|
233651
233830
|
return {
|
|
233652
233831
|
ok: false,
|
|
233653
|
-
error:
|
|
233832
|
+
error: "Choose a connected computer from `letta computers list`. Run `letta server` on that computer to connect it."
|
|
233654
233833
|
};
|
|
233655
233834
|
}
|
|
233656
233835
|
if (environment?.organizationId === "local") {
|
|
233657
233836
|
return {
|
|
233658
233837
|
ok: false,
|
|
233659
|
-
error: `Device ${deviceId} is
|
|
233838
|
+
error: `Device ${deviceId} is not connected to your account. Run \`letta server\` on that computer to connect it.`
|
|
233660
233839
|
};
|
|
233661
233840
|
}
|
|
233662
233841
|
return { ok: true };
|
|
@@ -233704,11 +233883,17 @@ async function resolveCronCreatePlacement(params) {
|
|
|
233704
233883
|
const targetDeviceId = params.targetDeviceId?.trim() || undefined;
|
|
233705
233884
|
if (targetDeviceId && resolved.runner !== "cloud") {
|
|
233706
233885
|
return {
|
|
233707
|
-
error: "--computer
|
|
233886
|
+
error: "--computer isn't available here."
|
|
233887
|
+
};
|
|
233888
|
+
}
|
|
233889
|
+
if (!targetDeviceId) {
|
|
233890
|
+
return {
|
|
233891
|
+
runner: resolved.runner,
|
|
233892
|
+
...resolved.targetDeviceId && {
|
|
233893
|
+
targetDeviceId: resolved.targetDeviceId
|
|
233894
|
+
}
|
|
233708
233895
|
};
|
|
233709
233896
|
}
|
|
233710
|
-
if (!targetDeviceId)
|
|
233711
|
-
return { runner: resolved.runner };
|
|
233712
233897
|
const selectorValidity = validateTargetDevice(targetDeviceId, null);
|
|
233713
233898
|
if (!selectorValidity.ok)
|
|
233714
233899
|
return selectorValidity;
|
|
@@ -233735,7 +233920,7 @@ function buildCloudScheduleInput(params) {
|
|
|
233735
233920
|
} else {
|
|
233736
233921
|
const scheduledAt = params.scheduledFor?.getTime();
|
|
233737
233922
|
if (!scheduledAt || Number.isNaN(scheduledAt)) {
|
|
233738
|
-
throw new Error("One-shot
|
|
233923
|
+
throw new Error("One-shot schedules require a resolved --at time.");
|
|
233739
233924
|
}
|
|
233740
233925
|
schedule = { type: "one-time", scheduled_at: scheduledAt };
|
|
233741
233926
|
}
|
|
@@ -233755,11 +233940,13 @@ function buildCloudScheduleInput(params) {
|
|
|
233755
233940
|
notes
|
|
233756
233941
|
};
|
|
233757
233942
|
}
|
|
233758
|
-
var
|
|
233943
|
+
var SYNTHETIC_CLOUD_DEVICE_ID = "__letta_cloud__", SYNTHETIC_LOCAL_PLACEHOLDER_ID = "local", CLOUD_CRON_UTC_NOTE = "Recurring schedules interpret cron expressions in UTC.", CLOUD_DEVICE_OFFLINE_NOTE = "If the target computer is offline when the schedule fires, that occurrence fails (TARGET_DEVICE_UNAVAILABLE) and does not run.";
|
|
233759
233944
|
var init_runner = __esm(() => {
|
|
233760
233945
|
init_request();
|
|
233761
233946
|
init_schedules();
|
|
233947
|
+
init_server_url();
|
|
233762
233948
|
init_backend_mode();
|
|
233949
|
+
init_runtime_context();
|
|
233763
233950
|
});
|
|
233764
233951
|
|
|
233765
233952
|
// src/tools/impl/wake.ts
|
|
@@ -233843,7 +234030,6 @@ function promptFromCloudSchedule(schedule) {
|
|
|
233843
234030
|
function localWakeRecord(task) {
|
|
233844
234031
|
return {
|
|
233845
234032
|
id: task.id,
|
|
233846
|
-
runner: "local",
|
|
233847
234033
|
name: task.name,
|
|
233848
234034
|
prompt: task.prompt,
|
|
233849
234035
|
recurring: task.recurring,
|
|
@@ -233855,7 +234041,6 @@ function localWakeRecord(task) {
|
|
|
233855
234041
|
function cloudWakeRecord(schedule) {
|
|
233856
234042
|
return {
|
|
233857
234043
|
id: schedule.id,
|
|
233858
|
-
runner: "cloud",
|
|
233859
234044
|
name: schedule.name ?? null,
|
|
233860
234045
|
prompt: promptFromCloudSchedule(schedule),
|
|
233861
234046
|
recurring: schedule.schedule.type === "recurring",
|
|
@@ -233884,7 +234069,7 @@ async function listCurrentWakes(scope, args, deps) {
|
|
|
233884
234069
|
if (error4 instanceof ApiRequestError && (error4.status === 404 || error4.status === 405)) {
|
|
233885
234070
|
return { wakes, warnings };
|
|
233886
234071
|
}
|
|
233887
|
-
warnings.push(`
|
|
234072
|
+
warnings.push(`Wakes could not be listed: ${error4 instanceof Error ? error4.message : String(error4)}`);
|
|
233888
234073
|
}
|
|
233889
234074
|
return { wakes, warnings };
|
|
233890
234075
|
}
|
|
@@ -233937,8 +234122,7 @@ async function createWake(args, scope, deps) {
|
|
|
233937
234122
|
action: "created",
|
|
233938
234123
|
id: created2.id,
|
|
233939
234124
|
name,
|
|
233940
|
-
|
|
233941
|
-
execution_target: targetDeviceId ?? CLOUD_EXECUTION_TARGET,
|
|
234125
|
+
...targetDeviceId && { execution_target: targetDeviceId },
|
|
233942
234126
|
conversation_id: scope.conversationId,
|
|
233943
234127
|
recurring: timing2.recurring,
|
|
233944
234128
|
...created2.next_scheduled_at && {
|
|
@@ -233959,12 +234143,14 @@ async function createWake(args, scope, deps) {
|
|
|
233959
234143
|
scheduled_for: timing2.scheduledFor
|
|
233960
234144
|
};
|
|
233961
234145
|
const created = (deps.addLocal ?? addTask)(input);
|
|
233962
|
-
const warnings = [
|
|
234146
|
+
const warnings = [
|
|
234147
|
+
...current.warnings,
|
|
234148
|
+
created.warning ? "This wake only fires while this session is running." : undefined
|
|
234149
|
+
].filter((warning) => Boolean(warning));
|
|
233963
234150
|
return result2("success", {
|
|
233964
234151
|
action: "created",
|
|
233965
234152
|
id: created.task.id,
|
|
233966
234153
|
name,
|
|
233967
|
-
runner: "local",
|
|
233968
234154
|
conversation_id: scope.conversationId,
|
|
233969
234155
|
recurring: timing2.recurring,
|
|
233970
234156
|
scheduled_at: created.task.scheduled_for,
|
|
@@ -233984,7 +234170,6 @@ async function cancelWake(args, scope, deps) {
|
|
|
233984
234170
|
return result2("success", {
|
|
233985
234171
|
action: "cancelled",
|
|
233986
234172
|
id,
|
|
233987
|
-
runner: "local",
|
|
233988
234173
|
warnings: []
|
|
233989
234174
|
});
|
|
233990
234175
|
}
|
|
@@ -234008,7 +234193,6 @@ async function cancelWake(args, scope, deps) {
|
|
|
234008
234193
|
return result2("success", {
|
|
234009
234194
|
action: "cancelled",
|
|
234010
234195
|
id,
|
|
234011
|
-
runner: "cloud",
|
|
234012
234196
|
warnings: []
|
|
234013
234197
|
});
|
|
234014
234198
|
}
|
|
@@ -234362,6 +234546,110 @@ Output file: ${outputFile}` : ""}`
|
|
|
234362
234546
|
};
|
|
234363
234547
|
}
|
|
234364
234548
|
|
|
234549
|
+
// src/backend/api/monitors.ts
|
|
234550
|
+
function isLegacyMonitorValidation(error4, operation) {
|
|
234551
|
+
if (!(error4 instanceof ApiRequestError) || error4.status !== 400)
|
|
234552
|
+
return false;
|
|
234553
|
+
try {
|
|
234554
|
+
const body3 = JSON.parse(error4.responseText);
|
|
234555
|
+
if (body3.detail === "Invalid request")
|
|
234556
|
+
return true;
|
|
234557
|
+
return body3.issues?.some((issue2) => operation === "create" ? issue2.code === "unrecognized_keys" && Boolean(issue2.keys?.length) && issue2.keys?.every((key2) => key2 === "args" || key2 === "expires_at") : issue2.code === "invalid_enum_value" && issue2.path?.[0] === "status") ?? false;
|
|
234558
|
+
} catch {
|
|
234559
|
+
return false;
|
|
234560
|
+
}
|
|
234561
|
+
}
|
|
234562
|
+
async function createMonitorState(input, actingUserId) {
|
|
234563
|
+
try {
|
|
234564
|
+
return await apiRequest("POST", "/v1/monitors", input, {
|
|
234565
|
+
actingUserId,
|
|
234566
|
+
signal: AbortSignal.timeout(15000)
|
|
234567
|
+
});
|
|
234568
|
+
} catch (error4) {
|
|
234569
|
+
if (!isLegacyMonitorValidation(error4, "create"))
|
|
234570
|
+
throw error4;
|
|
234571
|
+
const { args: _args, expires_at: _expires, ...legacy } = input;
|
|
234572
|
+
return apiRequest("POST", "/v1/monitors", legacy, {
|
|
234573
|
+
actingUserId,
|
|
234574
|
+
signal: AbortSignal.timeout(15000)
|
|
234575
|
+
});
|
|
234576
|
+
}
|
|
234577
|
+
}
|
|
234578
|
+
async function updateMonitorState(id, input, actingUserId) {
|
|
234579
|
+
const path28 = `/v1/monitors/${encodeURIComponent(id)}`;
|
|
234580
|
+
try {
|
|
234581
|
+
return await apiRequest("PATCH", path28, input, {
|
|
234582
|
+
actingUserId,
|
|
234583
|
+
signal: AbortSignal.timeout(15000)
|
|
234584
|
+
});
|
|
234585
|
+
} catch (error4) {
|
|
234586
|
+
if (!isLegacyMonitorValidation(error4, "update") || !["expired", "stopped", "paused"].includes(input.status))
|
|
234587
|
+
throw error4;
|
|
234588
|
+
return apiRequest("PATCH", path28, { ...input, status: "failed" }, { actingUserId, signal: AbortSignal.timeout(15000) });
|
|
234589
|
+
}
|
|
234590
|
+
}
|
|
234591
|
+
async function retrieveMonitorState(id) {
|
|
234592
|
+
try {
|
|
234593
|
+
return await apiRequest("GET", `/v1/monitors/${encodeURIComponent(id)}`, undefined, { signal: AbortSignal.timeout(15000) });
|
|
234594
|
+
} catch (error4) {
|
|
234595
|
+
if (error4 instanceof ApiRequestError && error4.status === 404)
|
|
234596
|
+
throw new Error(`Monitor ${id} was not found or this server does not support monitor resume.`);
|
|
234597
|
+
throw error4;
|
|
234598
|
+
}
|
|
234599
|
+
}
|
|
234600
|
+
function listMonitorStates(scope) {
|
|
234601
|
+
return apiRequest("GET", "/v1/monitors", undefined, {
|
|
234602
|
+
query: { ...scope, limit: 200 },
|
|
234603
|
+
signal: AbortSignal.timeout(15000)
|
|
234604
|
+
});
|
|
234605
|
+
}
|
|
234606
|
+
var init_monitors = __esm(() => {
|
|
234607
|
+
init_request();
|
|
234608
|
+
});
|
|
234609
|
+
|
|
234610
|
+
// src/tools/impl/monitor-resume.ts
|
|
234611
|
+
async function readResumableMonitor(id, parentScope) {
|
|
234612
|
+
if (resolveBackendMode() === "local")
|
|
234613
|
+
throw new Error("Saved monitor resume requires the API backend.");
|
|
234614
|
+
const record4 = await retrieveMonitorState(id);
|
|
234615
|
+
const runtime = getRuntimeContext();
|
|
234616
|
+
const scope = runtime?.agentId === null && runtime.conversationId ? { agentId: null, conversationId: runtime.conversationId } : resolveNotificationScope(parentScope);
|
|
234617
|
+
if (scope && (record4.agent_id !== scope.agentId || (record4.conversation_id ?? "default") !== scope.conversationId))
|
|
234618
|
+
throw new Error("Resume the monitor in its original conversation.");
|
|
234619
|
+
if (record4.status === "expired")
|
|
234620
|
+
throw new Error(`Monitor ${id} has expired; start a new monitor instead.`);
|
|
234621
|
+
if (record4.status !== "paused")
|
|
234622
|
+
throw new Error(`Monitor ${id} is ${record4.status}; only paused monitors can resume.`);
|
|
234623
|
+
if (record4.expires_at && Date.parse(record4.expires_at) <= Date.now()) {
|
|
234624
|
+
await updateMonitorState(id, {
|
|
234625
|
+
status: "expired",
|
|
234626
|
+
exit_code: null,
|
|
234627
|
+
output_file: record4.output_file
|
|
234628
|
+
});
|
|
234629
|
+
throw new Error(`Monitor ${id} has expired; start a new monitor instead.`);
|
|
234630
|
+
}
|
|
234631
|
+
if (!record4.args || !Object.keys(record4.args).length)
|
|
234632
|
+
throw new Error(`Monitor ${id} has no saved tool arguments; start a new monitor instead.`);
|
|
234633
|
+
return record4;
|
|
234634
|
+
}
|
|
234635
|
+
function savedMonitorArgs(input) {
|
|
234636
|
+
const omitted = new Set([
|
|
234637
|
+
"parentScope",
|
|
234638
|
+
"signal",
|
|
234639
|
+
"secretEnv",
|
|
234640
|
+
"variableEnv",
|
|
234641
|
+
"toolCallId",
|
|
234642
|
+
"resume"
|
|
234643
|
+
]);
|
|
234644
|
+
return Object.fromEntries(Object.entries(input).filter(([key2]) => !omitted.has(key2)));
|
|
234645
|
+
}
|
|
234646
|
+
var init_monitor_resume = __esm(() => {
|
|
234647
|
+
init_monitors();
|
|
234648
|
+
init_backend_mode();
|
|
234649
|
+
init_runtime_context();
|
|
234650
|
+
init_task_notifications();
|
|
234651
|
+
});
|
|
234652
|
+
|
|
234365
234653
|
// src/tools/impl/monitor-script.ts
|
|
234366
234654
|
function createCallLimiter(signal) {
|
|
234367
234655
|
let tokens = TOOL_CALL_BURST;
|
|
@@ -234444,7 +234732,7 @@ async function startScriptMonitor(args, hooks) {
|
|
|
234444
234732
|
processState.completionNotificationSuppressed = true;
|
|
234445
234733
|
if (note)
|
|
234446
234734
|
output.append(note);
|
|
234447
|
-
hooks.markFinished(taskId, processState, "failed", null);
|
|
234735
|
+
hooks.markFinished(taskId, processState, reason === "timeout" ? "expired" : "failed", null);
|
|
234448
234736
|
controller.abort(new Error(reason));
|
|
234449
234737
|
};
|
|
234450
234738
|
const events = createMonitorEventStream({
|
|
@@ -234589,23 +234877,6 @@ var init_monitor_script = __esm(() => {
|
|
|
234589
234877
|
init_process_manager();
|
|
234590
234878
|
});
|
|
234591
234879
|
|
|
234592
|
-
// src/backend/api/monitors.ts
|
|
234593
|
-
function createMonitorState(input, actingUserId) {
|
|
234594
|
-
return apiRequest("POST", "/v1/monitors", input, {
|
|
234595
|
-
actingUserId,
|
|
234596
|
-
signal: AbortSignal.timeout(15000)
|
|
234597
|
-
});
|
|
234598
|
-
}
|
|
234599
|
-
function updateMonitorState(id, input, actingUserId) {
|
|
234600
|
-
return apiRequest("PATCH", `/v1/monitors/${encodeURIComponent(id)}`, input, {
|
|
234601
|
-
actingUserId,
|
|
234602
|
-
signal: AbortSignal.timeout(15000)
|
|
234603
|
-
});
|
|
234604
|
-
}
|
|
234605
|
-
var init_monitors = __esm(() => {
|
|
234606
|
-
init_request();
|
|
234607
|
-
});
|
|
234608
|
-
|
|
234609
234880
|
// src/tools/impl/monitor-state.ts
|
|
234610
234881
|
async function withMonitorState(input, start) {
|
|
234611
234882
|
if (resolveBackendMode() === "local")
|
|
@@ -234619,7 +234890,8 @@ async function withMonitorState(input, start) {
|
|
|
234619
234890
|
...captureSecretRedactions(scope.agentId ?? undefined),
|
|
234620
234891
|
...input.secretEnv
|
|
234621
234892
|
};
|
|
234622
|
-
const
|
|
234893
|
+
const startedAt = new Date().toISOString();
|
|
234894
|
+
const record4 = input.resumeRecord ?? await createMonitorState({
|
|
234623
234895
|
agent_id: scope.agentId || null,
|
|
234624
234896
|
conversation_id: scope.conversationId,
|
|
234625
234897
|
description: scrubSecretsFromString(input.description, secrets2),
|
|
@@ -234628,12 +234900,24 @@ async function withMonitorState(input, start) {
|
|
|
234628
234900
|
persistent: input.persistent,
|
|
234629
234901
|
status: "running",
|
|
234630
234902
|
device_id: getRuntimeContext()?.environmentDeviceId ?? null,
|
|
234631
|
-
started_at:
|
|
234903
|
+
started_at: startedAt,
|
|
234904
|
+
expires_at: input.timeoutMs ? new Date(Date.now() + input.timeoutMs).toISOString() : null,
|
|
234905
|
+
args: JSON.parse(JSON.stringify(input.args ?? {}, (_key, value) => typeof value === "string" ? scrubSecretsFromString(value, secrets2) : value)),
|
|
234632
234906
|
output_file: null,
|
|
234633
234907
|
exit_code: null
|
|
234634
234908
|
}, actingUserId);
|
|
234635
234909
|
const id = record4.monitor_id;
|
|
234910
|
+
if (backgroundProcesses.get(id)?.status === "running")
|
|
234911
|
+
throw new Error(`Monitor ${id} is already running on this host`);
|
|
234636
234912
|
try {
|
|
234913
|
+
if (input.resumeRecord) {
|
|
234914
|
+
await updateMonitorState(id, {
|
|
234915
|
+
status: "running",
|
|
234916
|
+
exit_code: null,
|
|
234917
|
+
output_file: record4.output_file,
|
|
234918
|
+
device_id: getRuntimeContext()?.environmentDeviceId ?? record4.device_id
|
|
234919
|
+
}, actingUserId);
|
|
234920
|
+
}
|
|
234637
234921
|
input.signal?.throwIfAborted();
|
|
234638
234922
|
const result3 = await start(id);
|
|
234639
234923
|
const process21 = backgroundProcesses.get(id);
|
|
@@ -234641,8 +234925,11 @@ async function withMonitorState(input, start) {
|
|
|
234641
234925
|
throw new Error("Monitor did not register its process");
|
|
234642
234926
|
let pending2 = Promise.resolve();
|
|
234643
234927
|
process21.persistState = () => {
|
|
234928
|
+
let status = process21.monitorEndStatus ?? process21.status;
|
|
234929
|
+
if (record4.args === undefined && ["expired", "stopped", "paused"].includes(status))
|
|
234930
|
+
status = "failed";
|
|
234644
234931
|
const state2 = {
|
|
234645
|
-
status
|
|
234932
|
+
status,
|
|
234646
234933
|
exit_code: process21.exitCode,
|
|
234647
234934
|
output_file: process21.outputFile ?? null
|
|
234648
234935
|
};
|
|
@@ -234707,6 +234994,9 @@ function formatMonitorMaxTimeout(timeoutMs = getMonitorMaxTimeoutMs()) {
|
|
|
234707
234994
|
function applyMonitorMaxTimeout(text2, timeoutMs = getMonitorMaxTimeoutMs()) {
|
|
234708
234995
|
return text2.replaceAll("{{MONITOR_MAX_TIMEOUT}}", formatMonitorMaxTimeout(timeoutMs));
|
|
234709
234996
|
}
|
|
234997
|
+
function getMonitorTimeoutEvent(timeoutMs, tool = "Monitor") {
|
|
234998
|
+
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.]";
|
|
234999
|
+
}
|
|
234710
235000
|
var HOUR_MS = 3600000, DAY_MS, DEFAULT_MAX_TIMEOUT_MS, SEVEN_DAYS_MS;
|
|
234711
235001
|
var init_monitor_timeout = __esm(() => {
|
|
234712
235002
|
DAY_MS = 24 * HOUR_MS;
|
|
@@ -234909,9 +235199,6 @@ var init_monitor_url_cloud = __esm(() => {
|
|
|
234909
235199
|
// src/tools/impl/monitor.ts
|
|
234910
235200
|
import { appendFileSync as appendFileSync7, readFileSync as readFileSync38, writeFileSync as writeFileSync30 } from "node:fs";
|
|
234911
235201
|
import { WebSocket as WebSocket4 } from "ws";
|
|
234912
|
-
function getMonitorTimeoutEvent(timeoutMs, tool = "Monitor") {
|
|
234913
|
-
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.]";
|
|
234914
|
-
}
|
|
234915
235202
|
function validUtf8Prefix(buffer, maxBytes) {
|
|
234916
235203
|
let end = Math.min(buffer.length, maxBytes);
|
|
234917
235204
|
while (end > Math.max(0, maxBytes - 4)) {
|
|
@@ -235000,13 +235287,14 @@ function validateWebSocketSource(source) {
|
|
|
235000
235287
|
function normalizeMonitorArgs(args) {
|
|
235001
235288
|
const normalized = {
|
|
235002
235289
|
...args,
|
|
235290
|
+
description: args.description ?? "",
|
|
235003
235291
|
timeout_ms: args.timeout_ms ?? DEFAULT_TIMEOUT_MS3,
|
|
235004
235292
|
persistent: args.persistent ?? false
|
|
235005
235293
|
};
|
|
235006
|
-
if (typeof
|
|
235294
|
+
if (typeof args.description !== "string") {
|
|
235007
235295
|
throw new Error("Monitor description is required");
|
|
235008
235296
|
}
|
|
235009
|
-
if (typeof normalized.timeout_ms !== "number" || !Number.isFinite(normalized.timeout_ms) || normalized.timeout_ms < MIN_TIMEOUT_MS || !normalized.persistent && normalized.timeout_ms > getMonitorMaxTimeoutMs()) {
|
|
235297
|
+
if (typeof normalized.timeout_ms !== "number" || !Number.isFinite(normalized.timeout_ms) || normalized.timeout_ms < (args.resume ? 1 : MIN_TIMEOUT_MS) || !normalized.persistent && normalized.timeout_ms > getMonitorMaxTimeoutMs()) {
|
|
235010
235298
|
throw new Error(`Monitor timeout_ms must be between ${MIN_TIMEOUT_MS} and ${getMonitorMaxTimeoutMs()}`);
|
|
235011
235299
|
}
|
|
235012
235300
|
if (typeof normalized.persistent !== "boolean") {
|
|
@@ -235125,7 +235413,9 @@ function queueCommandCompletion(params) {
|
|
|
235125
235413
|
});
|
|
235126
235414
|
}
|
|
235127
235415
|
function markMonitorFinished(taskId, processState, status, exitCode) {
|
|
235128
|
-
processState.status = status;
|
|
235416
|
+
processState.status = status === "expired" ? "failed" : status;
|
|
235417
|
+
if (status === "expired")
|
|
235418
|
+
processState.monitorEndStatus = "expired";
|
|
235129
235419
|
processState.exitCode = exitCode;
|
|
235130
235420
|
persistMonitorState(processState);
|
|
235131
235421
|
cancelMonitorBackup(taskId);
|
|
@@ -235300,7 +235590,7 @@ function startCommandMonitor(args) {
|
|
|
235300
235590
|
[error] ${message}
|
|
235301
235591
|
`);
|
|
235302
235592
|
}
|
|
235303
|
-
markMonitorFinished(taskId, processState, "failed", null);
|
|
235593
|
+
markMonitorFinished(taskId, processState, shellError.killed ? "expired" : "failed", null);
|
|
235304
235594
|
if (!shellError.killed) {
|
|
235305
235595
|
queueCommandCompletion({
|
|
235306
235596
|
taskId,
|
|
@@ -235356,7 +235646,7 @@ function startWebSocketMonitor(args) {
|
|
|
235356
235646
|
output.append(`
|
|
235357
235647
|
[stopped: output rate too high]
|
|
235358
235648
|
`);
|
|
235359
|
-
markMonitorFinished(taskId, processState, "
|
|
235649
|
+
markMonitorFinished(taskId, processState, "expired", null);
|
|
235360
235650
|
closeSocket();
|
|
235361
235651
|
}
|
|
235362
235652
|
});
|
|
@@ -235402,7 +235692,7 @@ function startWebSocketMonitor(args) {
|
|
|
235402
235692
|
secrets: secrets2
|
|
235403
235693
|
});
|
|
235404
235694
|
processState.completionNotificationSuppressed = true;
|
|
235405
|
-
markMonitorFinished(taskId, processState, "
|
|
235695
|
+
markMonitorFinished(taskId, processState, "expired", null);
|
|
235406
235696
|
closeSocket();
|
|
235407
235697
|
return;
|
|
235408
235698
|
}
|
|
@@ -235411,7 +235701,7 @@ function startWebSocketMonitor(args) {
|
|
|
235411
235701
|
`);
|
|
235412
235702
|
if (!wrote) {
|
|
235413
235703
|
processState.completionNotificationSuppressed = true;
|
|
235414
|
-
markMonitorFinished(taskId, processState, "
|
|
235704
|
+
markMonitorFinished(taskId, processState, "expired", null);
|
|
235415
235705
|
closeSocket();
|
|
235416
235706
|
return;
|
|
235417
235707
|
}
|
|
@@ -235479,7 +235769,7 @@ function startWebSocketMonitor(args) {
|
|
|
235479
235769
|
[timeout after ${args.timeout_ms}ms]
|
|
235480
235770
|
`);
|
|
235481
235771
|
processState.completionNotificationSuppressed = true;
|
|
235482
|
-
markMonitorFinished(taskId, processState, "
|
|
235772
|
+
markMonitorFinished(taskId, processState, "expired", null);
|
|
235483
235773
|
closeSocket();
|
|
235484
235774
|
}, args.timeout_ms);
|
|
235485
235775
|
unrefTimer(timeout);
|
|
@@ -235511,6 +235801,23 @@ function backupScopeFor(taskId) {
|
|
|
235511
235801
|
return { ...runtimeScope, actingUserId: processState.actingUserId };
|
|
235512
235802
|
}
|
|
235513
235803
|
async function monitor(args) {
|
|
235804
|
+
const resumeRecord = args.resume ? await readResumableMonitor(args.resume, args.parentScope) : undefined;
|
|
235805
|
+
if (resumeRecord) {
|
|
235806
|
+
if (resumeRecord.kind === "github_pull_request")
|
|
235807
|
+
throw new Error("Use WatchPR to resume this monitor.");
|
|
235808
|
+
args = {
|
|
235809
|
+
...resumeRecord.args,
|
|
235810
|
+
resume: resumeRecord.monitor_id,
|
|
235811
|
+
parentScope: args.parentScope,
|
|
235812
|
+
signal: args.signal,
|
|
235813
|
+
secretEnv: args.secretEnv,
|
|
235814
|
+
variableEnv: args.variableEnv
|
|
235815
|
+
};
|
|
235816
|
+
if (resumeRecord.expires_at) {
|
|
235817
|
+
args.timeout_ms = Math.max(1, Date.parse(resumeRecord.expires_at) - Date.now());
|
|
235818
|
+
args.persistent = false;
|
|
235819
|
+
}
|
|
235820
|
+
}
|
|
235514
235821
|
args.signal?.throwIfAborted();
|
|
235515
235822
|
const cloud = experimentManager.isEnabled("cloud_monitors");
|
|
235516
235823
|
const forbidden = cloud ? [
|
|
@@ -235535,12 +235842,17 @@ async function monitor(args) {
|
|
|
235535
235842
|
}
|
|
235536
235843
|
}
|
|
235537
235844
|
if (cloud) {
|
|
235538
|
-
|
|
235845
|
+
if (!args.description)
|
|
235846
|
+
throw new Error("Monitor description is required");
|
|
235847
|
+
return startCloudUrlMonitor({ ...args, description: args.description });
|
|
235539
235848
|
}
|
|
235540
235849
|
const normalized = normalizeMonitorArgs(args);
|
|
235541
235850
|
installMonitorProcessExitCleanup();
|
|
235542
235851
|
const result3 = await withMonitorState({
|
|
235543
235852
|
...normalized,
|
|
235853
|
+
resumeRecord,
|
|
235854
|
+
timeoutMs: normalized.persistent ? 0 : normalized.timeout_ms,
|
|
235855
|
+
args: savedMonitorArgs(normalized),
|
|
235544
235856
|
kind: normalized.script !== undefined ? "script" : normalized.command !== undefined ? "command" : "websocket",
|
|
235545
235857
|
command: normalized.command ?? normalized.script ?? (normalized.ws ? webSocketDisplayUrl(normalized.ws.url) : "")
|
|
235546
235858
|
}, (taskId) => {
|
|
@@ -235570,6 +235882,7 @@ function stopMonitorsForProcessExit() {
|
|
|
235570
235882
|
continue;
|
|
235571
235883
|
}
|
|
235572
235884
|
processState.completionNotificationSuppressed = true;
|
|
235885
|
+
processState.monitorEndStatus = isManagedCloudRuntime() ? "paused" : "stopped";
|
|
235573
235886
|
processState.status = "failed";
|
|
235574
235887
|
try {
|
|
235575
235888
|
processState.process.kill("SIGKILL");
|
|
@@ -235598,6 +235911,7 @@ var init_monitor = __esm(() => {
|
|
|
235598
235911
|
init_bash();
|
|
235599
235912
|
init_monitor_backup();
|
|
235600
235913
|
init_monitor_event_stream();
|
|
235914
|
+
init_monitor_resume();
|
|
235601
235915
|
init_monitor_script();
|
|
235602
235916
|
init_monitor_state();
|
|
235603
235917
|
init_monitor_timeout();
|
|
@@ -238107,14 +238421,14 @@ function createRemoteIdleNotifier(subagentId, parentScope) {
|
|
|
238107
238421
|
addToMessageQueue({
|
|
238108
238422
|
kind: "task_notification",
|
|
238109
238423
|
...scope,
|
|
238110
|
-
|
|
238424
|
+
...taskNotificationMessage(formatTaskNotification({
|
|
238111
238425
|
taskId: subagentId,
|
|
238112
238426
|
status: "running",
|
|
238113
238427
|
summary: `Agent loop stopped with ${count} background process${count === 1 ? "" : "es"} still running`,
|
|
238114
238428
|
result: `${text2}
|
|
238115
238429
|
|
|
238116
238430
|
The child agent's loop has stopped with ${count} background process${count === 1 ? "" : "es"} still running. It will resume when they finish, and a final notification will follow.`
|
|
238117
|
-
})
|
|
238431
|
+
}))
|
|
238118
238432
|
});
|
|
238119
238433
|
};
|
|
238120
238434
|
}
|
|
@@ -238797,6 +239111,12 @@ function withNativeCliPath(env6, platform7 = process.platform) {
|
|
|
238797
239111
|
}
|
|
238798
239112
|
var init_native_cli_env = () => {};
|
|
238799
239113
|
|
|
239114
|
+
// src/tools/impl/claude-steer-timeouts.ts
|
|
239115
|
+
var CLAUDE_TURN_START_TIMEOUT_MS = 60000, CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS = 30000, REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS, CLAUDE_TURN_START_TIMEOUT_ERROR = "Claude turn did not become interruptible", CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR = "Claude interrupt acknowledgement timed out";
|
|
239116
|
+
var init_claude_steer_timeouts = __esm(() => {
|
|
239117
|
+
REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS = CLAUDE_TURN_START_TIMEOUT_MS + CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS + 30000;
|
|
239118
|
+
});
|
|
239119
|
+
|
|
238800
239120
|
// src/tools/impl/external-llm-trace-payload.ts
|
|
238801
239121
|
function traceCaptureEnabled(env6, baseUrl, apiKey) {
|
|
238802
239122
|
return env6.LETTA_CODE_TELEM !== "0" && env6.LETTA_CODE_TELEM !== "false" && env6.DO_NOT_TRACK !== "1" && isCloudServerUrl(baseUrl) && Boolean(apiKey);
|
|
@@ -239418,6 +239738,7 @@ function markTurnStarted(session3) {
|
|
|
239418
239738
|
if (session3.awaitingReplacementStart) {
|
|
239419
239739
|
session3.awaitingReplacementStart = false;
|
|
239420
239740
|
session3.pendingSteers = 0;
|
|
239741
|
+
session3.queuedSteer = false;
|
|
239421
239742
|
session3.suppressedResult = undefined;
|
|
239422
239743
|
}
|
|
239423
239744
|
resolveTurnWaiters(session3);
|
|
@@ -239435,7 +239756,7 @@ function waitForTurnStart(session3, signal) {
|
|
|
239435
239756
|
}
|
|
239436
239757
|
return new Promise((resolve34, reject2) => {
|
|
239437
239758
|
const waiter = { resolve: finishResolve, reject: finishReject };
|
|
239438
|
-
const timeout = setTimeout(() => finishReject(new Error(
|
|
239759
|
+
const timeout = setTimeout(() => finishReject(new Error(CLAUDE_TURN_START_TIMEOUT_ERROR)), CLAUDE_TURN_START_TIMEOUT_MS);
|
|
239439
239760
|
timeout.unref?.();
|
|
239440
239761
|
const abort = () => finishReject(signal?.reason instanceof Error ? signal.reason : new Error("Claude steering cancelled"));
|
|
239441
239762
|
function cleanup() {
|
|
@@ -239643,8 +239964,13 @@ function finishResult(session3, value) {
|
|
|
239643
239964
|
function handleResult(session3, value) {
|
|
239644
239965
|
session3.interruptible = false;
|
|
239645
239966
|
session3.resultCount++;
|
|
239646
|
-
if (session3.
|
|
239967
|
+
if (session3.queuedSteer && session3.acknowledgesInputs && session3.latestInputStarted) {
|
|
239968
|
+
session3.pendingSteers = 0;
|
|
239969
|
+
session3.queuedSteer = false;
|
|
239970
|
+
} else if (session3.pendingSteers > 0) {
|
|
239647
239971
|
session3.pendingSteers--;
|
|
239972
|
+
if (session3.pendingSteers === 0)
|
|
239973
|
+
session3.queuedSteer = false;
|
|
239648
239974
|
session3.suppressedResult = value;
|
|
239649
239975
|
return;
|
|
239650
239976
|
}
|
|
@@ -239708,6 +240034,7 @@ async function launchSession(options, deps) {
|
|
|
239708
240034
|
latestInputStarted: false,
|
|
239709
240035
|
acknowledgesInputs: false,
|
|
239710
240036
|
pendingSteers: 0,
|
|
240037
|
+
queuedSteer: false,
|
|
239711
240038
|
interruptible: false,
|
|
239712
240039
|
awaitingReplacementStart: false,
|
|
239713
240040
|
suppressedResult: undefined,
|
|
@@ -239716,6 +240043,7 @@ async function launchSession(options, deps) {
|
|
|
239716
240043
|
provisionalResult: undefined,
|
|
239717
240044
|
idleOnBackgroundTasks: false,
|
|
239718
240045
|
backgroundCapMs: deps.backgroundTaskWaitCapMs ?? BACKGROUND_TASK_WAIT_CAP_MS,
|
|
240046
|
+
controlResponseTimeoutMs: deps.controlResponseTimeoutMs ?? CLAUDE_CONTROL_RESPONSE_TIMEOUT_MS,
|
|
239719
240047
|
backgroundCapTimer: undefined,
|
|
239720
240048
|
turnWaiters: new Set,
|
|
239721
240049
|
writeLock: Promise.resolve(),
|
|
@@ -239869,7 +240197,7 @@ async function runClaudeTurn(options, deps = {}) {
|
|
|
239869
240197
|
}
|
|
239870
240198
|
}
|
|
239871
240199
|
async function steerSession(session3, prompt, signal) {
|
|
239872
|
-
|
|
240200
|
+
return withWriteLock(session3, async () => {
|
|
239873
240201
|
signal?.throwIfAborted();
|
|
239874
240202
|
await waitForTurnStart(session3, signal);
|
|
239875
240203
|
if (session3.idleOnBackgroundTasks) {
|
|
@@ -239878,7 +240206,7 @@ async function steerSession(session3, prompt, signal) {
|
|
|
239878
240206
|
}
|
|
239879
240207
|
session3.idleOnBackgroundTasks = false;
|
|
239880
240208
|
await writeInput(session3, prompt);
|
|
239881
|
-
return;
|
|
240209
|
+
return "steered";
|
|
239882
240210
|
}
|
|
239883
240211
|
if (session3.settled || sessions.get(session3.sessionId) !== session3) {
|
|
239884
240212
|
throw new Error("Claude Code session is no longer active");
|
|
@@ -239891,13 +240219,16 @@ async function steerSession(session3, prompt, signal) {
|
|
|
239891
240219
|
session3.interruptible = false;
|
|
239892
240220
|
const resultCount = session3.resultCount;
|
|
239893
240221
|
let interruptAcknowledged = false;
|
|
240222
|
+
let ackTimedOut = false;
|
|
239894
240223
|
const rejectOnAbort = () => {
|
|
239895
240224
|
session3.pendingControls.get(requestId)?.reject(signal?.reason instanceof Error ? signal.reason : new Error("Claude steering cancelled"));
|
|
239896
240225
|
};
|
|
239897
240226
|
signal?.addEventListener("abort", rejectOnAbort, { once: true });
|
|
239898
240227
|
const timeout = setTimeout(() => {
|
|
239899
|
-
session3.pendingControls.get(requestId)
|
|
239900
|
-
|
|
240228
|
+
const pending2 = session3.pendingControls.get(requestId);
|
|
240229
|
+
ackTimedOut = Boolean(pending2);
|
|
240230
|
+
pending2?.reject(new Error(CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR));
|
|
240231
|
+
}, session3.controlResponseTimeoutMs);
|
|
239901
240232
|
timeout.unref?.();
|
|
239902
240233
|
try {
|
|
239903
240234
|
await writeRaw(session3.transport.process.stdin, `${JSON.stringify({ type: "control_request", request_id: requestId, request: { subtype: "interrupt" } })}
|
|
@@ -239908,7 +240239,10 @@ async function steerSession(session3, prompt, signal) {
|
|
|
239908
240239
|
await writeInput(session3, prompt);
|
|
239909
240240
|
session3.awaitingReplacementStart = true;
|
|
239910
240241
|
session3.suppressedResult = undefined;
|
|
240242
|
+
return "steered";
|
|
239911
240243
|
} catch (error4) {
|
|
240244
|
+
if (ackTimedOut && !signal?.aborted && !session3.settled && sessions.get(session3.sessionId) === session3 && await queueSteerPrompt(session3, prompt))
|
|
240245
|
+
return "queued";
|
|
239912
240246
|
session3.pendingSteers = Math.max(0, session3.pendingSteers - 1);
|
|
239913
240247
|
if (interruptAcknowledged) {
|
|
239914
240248
|
session3.abortController.abort(error4);
|
|
@@ -239930,6 +240264,17 @@ async function steerSession(session3, prompt, signal) {
|
|
|
239930
240264
|
}
|
|
239931
240265
|
});
|
|
239932
240266
|
}
|
|
240267
|
+
async function queueSteerPrompt(session3, prompt) {
|
|
240268
|
+
try {
|
|
240269
|
+
await writeInput(session3, prompt);
|
|
240270
|
+
} catch {
|
|
240271
|
+
return false;
|
|
240272
|
+
}
|
|
240273
|
+
session3.suppressedResult = undefined;
|
|
240274
|
+
session3.awaitingReplacementStart = false;
|
|
240275
|
+
session3.queuedSteer = session3.pendingSteers > 0;
|
|
240276
|
+
return true;
|
|
240277
|
+
}
|
|
239933
240278
|
async function deliverClaudeMessage(options, deps, launch) {
|
|
239934
240279
|
for (;; ) {
|
|
239935
240280
|
const existing = sessions.get(options.sessionId);
|
|
@@ -239940,8 +240285,12 @@ async function deliverClaudeMessage(options, deps, launch) {
|
|
|
239940
240285
|
continue;
|
|
239941
240286
|
}
|
|
239942
240287
|
try {
|
|
239943
|
-
await steerSession(existing, options.prompt, options.signal);
|
|
239944
|
-
return {
|
|
240288
|
+
const delivery = await steerSession(existing, options.prompt, options.signal);
|
|
240289
|
+
return {
|
|
240290
|
+
mode: "steered",
|
|
240291
|
+
queued: delivery === "queued",
|
|
240292
|
+
session: existing
|
|
240293
|
+
};
|
|
239945
240294
|
} catch (error4) {
|
|
239946
240295
|
if (sessions.get(options.sessionId) === existing && !existing.settled)
|
|
239947
240296
|
throw error4;
|
|
@@ -239955,6 +240304,9 @@ async function deliverClaudeMessage(options, deps, launch) {
|
|
|
239955
240304
|
}
|
|
239956
240305
|
return { mode: "resumed", session: session3 };
|
|
239957
240306
|
}
|
|
240307
|
+
function steeredReceipt(sessionId, queued) {
|
|
240308
|
+
return { mode: "steered", sessionId, ...queued ? { queued: true } : {} };
|
|
240309
|
+
}
|
|
239958
240310
|
function trackedReceipt(session3) {
|
|
239959
240311
|
return {
|
|
239960
240312
|
mode: "resumed",
|
|
@@ -239969,14 +240321,14 @@ async function sendClaudeMessage(options, deps = {}) {
|
|
|
239969
240321
|
options.signal?.throwIfAborted();
|
|
239970
240322
|
const steered = await deliverClaudeMessage(options, deps);
|
|
239971
240323
|
if (steered)
|
|
239972
|
-
return
|
|
240324
|
+
return steeredReceipt(options.sessionId, steered.queued);
|
|
239973
240325
|
if (options.beforeStart)
|
|
239974
240326
|
await options.beforeStart();
|
|
239975
240327
|
const delivered = await deliverClaudeMessage(options, deps, () => launchSession({ ...options, resumeSessionId: options.sessionId }, deps));
|
|
239976
240328
|
if (!delivered)
|
|
239977
240329
|
throw new Error("Claude Code session did not start");
|
|
239978
240330
|
if (delivered.mode === "steered" && !options.beforeStart)
|
|
239979
|
-
return
|
|
240331
|
+
return steeredReceipt(options.sessionId, delivered.queued);
|
|
239980
240332
|
return trackedReceipt(delivered.session);
|
|
239981
240333
|
}
|
|
239982
240334
|
async function stopClaudeSession(sessionId) {
|
|
@@ -239987,10 +240339,11 @@ async function stopClaudeSession(sessionId) {
|
|
|
239987
240339
|
await confirmProcessExit(session3.exit, "Claude Code");
|
|
239988
240340
|
return true;
|
|
239989
240341
|
}
|
|
239990
|
-
var sessions,
|
|
240342
|
+
var sessions, BACKGROUND_TASK_WAIT_CAP_MS, SETTLED_EXIT_GRACE_MS = 1e4;
|
|
239991
240343
|
var init_claude_stream_session = __esm(() => {
|
|
239992
240344
|
init_subagent_process();
|
|
239993
240345
|
init_native_cli_env();
|
|
240346
|
+
init_claude_steer_timeouts();
|
|
239994
240347
|
init_external_llm_trace_launch();
|
|
239995
240348
|
sessions = new Map;
|
|
239996
240349
|
BACKGROUND_TASK_WAIT_CAP_MS = 35 * 60000;
|
|
@@ -240231,7 +240584,7 @@ class CodexAppServerClient {
|
|
|
240231
240584
|
await this.request("initialize", {
|
|
240232
240585
|
clientInfo: {
|
|
240233
240586
|
name: "letta-code",
|
|
240234
|
-
version: "0.34.
|
|
240587
|
+
version: "0.34.63"
|
|
240235
240588
|
},
|
|
240236
240589
|
capabilities: null
|
|
240237
240590
|
});
|
|
@@ -244266,9 +244619,9 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
244266
244619
|
`;
|
|
244267
244620
|
}
|
|
244268
244621
|
return `${SYSTEM_REMINDER_OPEN}
|
|
244269
|
-
You have been forked from the primary conversational thread to run as an independent subagent
|
|
244622
|
+
You have been forked from the primary conversational thread to run as an independent subagent — you are NOT the primary agent.
|
|
244270
244623
|
|
|
244271
|
-
|
|
244624
|
+
The task in the user message below tells you what to do now; use the inherited conversation history as the source for everything else. If the task conflicts with what people said in the history, follow what people said in the history. Do not resume unrelated work from the history.
|
|
244272
244625
|
|
|
244273
244626
|
You inherit the primary agent's toolset.
|
|
244274
244627
|
|
|
@@ -244972,7 +245325,7 @@ async function prependParentContext(params) {
|
|
|
244972
245325
|
const recent = selectRecentMessages(preview, INLINE_CHARACTER_LIMIT - (summaryRecord ? summaryRecord.length + 1 : 0));
|
|
244973
245326
|
return {
|
|
244974
245327
|
prompt: [
|
|
244975
|
-
"The following JSONL is a read-only record of the parent's conversation
|
|
245328
|
+
"The following JSONL is a read-only record of the parent's conversation. The task after the history block tells you what to do now; use the history as the source for everything else. If the task conflicts with what people said in the history, follow what people said in the history. Do not resume unrelated work from the history.",
|
|
244976
245329
|
"Records marked injected came from the harness, not the human. Tool calls and results are linked by call_id. Records marked truncated have omitted content; use the commands below to read further.",
|
|
244977
245330
|
`This shows the parent's current context: the latest compaction summary when available, followed by its most recent in-context messages, up to 50,000 characters (an oversized summary is kept whole). If context lookup failed, it shows a recent-history fallback instead. For earlier or omitted history, search with \`letta messages search --query "<words>" --agent ${params.parentAgentId} --conversation ${params.parentConversationId}\`, or page back with \`letta messages list --agent ${params.parentAgentId} --conversation ${params.parentConversationId}\`. To ask the parent something or report back mid-task, run \`letta -p --agent ${params.parentAgentId} --conversation ${params.parentConversationId} --no-wait "<message>"\`.`,
|
|
244978
245331
|
"<parent_history>",
|
|
@@ -245008,6 +245361,14 @@ var init_external_fork_context = __esm(() => {
|
|
|
245008
245361
|
init_backend2();
|
|
245009
245362
|
});
|
|
245010
245363
|
|
|
245364
|
+
// src/tools/impl/fork-prompt.ts
|
|
245365
|
+
function validateForkPrompt(prompt, forked) {
|
|
245366
|
+
if (!forked || prompt.length <= FORK_PROMPT_CHARACTER_LIMIT)
|
|
245367
|
+
return;
|
|
245368
|
+
return `Forked prompt is ${prompt.length} characters; the limit is ${FORK_PROMPT_CHARACTER_LIMIT}. The agent already has the conversation. Send only the go, what done looks like, and what to read.`;
|
|
245369
|
+
}
|
|
245370
|
+
var FORK_PROMPT_CHARACTER_LIMIT = 2000;
|
|
245371
|
+
|
|
245011
245372
|
// src/agent/memory-conflict-repair.ts
|
|
245012
245373
|
import { execFile as execFile15 } from "node:child_process";
|
|
245013
245374
|
import { randomUUID as randomUUID44 } from "node:crypto";
|
|
@@ -245637,7 +245998,11 @@ function classifyRemoteExternalWorkerControlError(error4) {
|
|
|
245637
245998
|
}
|
|
245638
245999
|
if (error4 instanceof OutdatedRemoteWorkerError)
|
|
245639
246000
|
return "outdated_computer";
|
|
246001
|
+
if (error4 instanceof RemoteFollowUpTimeoutError)
|
|
246002
|
+
return "steer_timeout";
|
|
245640
246003
|
const message2 = errorMessage5(error4);
|
|
246004
|
+
if (message2 === CLAUDE_TURN_START_TIMEOUT_ERROR || message2 === CLAUDE_INTERRUPT_ACK_TIMEOUT_ERROR)
|
|
246005
|
+
return "worker_busy";
|
|
245641
246006
|
if (/^Computer ".*" is offline(?:\.|$)/.test(message2) || message2.startsWith("Timed out waiting for cloud sandbox "))
|
|
245642
246007
|
return "computer_offline";
|
|
245643
246008
|
if (/^Computer ".*" not found(?:\.|$)/.test(message2))
|
|
@@ -246067,9 +246432,12 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246067
246432
|
agent_id: bareAgentId,
|
|
246068
246433
|
message: params.message,
|
|
246069
246434
|
tool_call_id: toolCallId
|
|
246070
|
-
});
|
|
246435
|
+
}, { timeoutMs: REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS });
|
|
246071
246436
|
} catch (error4) {
|
|
246072
246437
|
follower.close();
|
|
246438
|
+
if (errorMessage5(error4) === `Timed out waiting for ${requestId}`) {
|
|
246439
|
+
throw new RemoteFollowUpTimeoutError(`${target.computer} didn't confirm the follow-up within ${Math.round(REMOTE_SUBAGENT_MESSAGE_TIMEOUT_MS / 1000)}s. The message may not have been delivered; check the worker's output, or send it again.`);
|
|
246440
|
+
}
|
|
246073
246441
|
throw error4;
|
|
246074
246442
|
}
|
|
246075
246443
|
if (!response.success) {
|
|
@@ -246079,9 +246447,9 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246079
246447
|
}
|
|
246080
246448
|
throw new Error(response.error);
|
|
246081
246449
|
}
|
|
246082
|
-
if (response.delivery === "steered") {
|
|
246450
|
+
if (response.delivery === "steered" || response.delivery === "queued") {
|
|
246083
246451
|
follower.close();
|
|
246084
|
-
return { delivery:
|
|
246452
|
+
return { delivery: response.delivery };
|
|
246085
246453
|
}
|
|
246086
246454
|
follower.markLaunched();
|
|
246087
246455
|
const completion = follower.waitForTerminal(undefined, () => {
|
|
@@ -246141,7 +246509,7 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
246141
246509
|
outputFile: tracked.outputFile
|
|
246142
246510
|
};
|
|
246143
246511
|
}
|
|
246144
|
-
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, OutdatedRemoteWorkerError, MAX_RECONNECT_DELAY_MS = 30000;
|
|
246512
|
+
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, OutdatedRemoteWorkerError, RemoteFollowUpTimeoutError, MAX_RECONNECT_DELAY_MS = 30000;
|
|
246145
246513
|
var init_remote_external_coding_agent = __esm(() => {
|
|
246146
246514
|
init_subagent_state();
|
|
246147
246515
|
init_app_server_client();
|
|
@@ -246151,6 +246519,7 @@ var init_remote_external_coding_agent = __esm(() => {
|
|
|
246151
246519
|
init_headless_environment_response();
|
|
246152
246520
|
init_headless_listener_launch();
|
|
246153
246521
|
init_error_reporting();
|
|
246522
|
+
init_claude_steer_timeouts();
|
|
246154
246523
|
init_external_coding_agent();
|
|
246155
246524
|
init_remote_subagent_events();
|
|
246156
246525
|
REMOTE_EXTERNAL_WORKER_STOPPED = Symbol("remote external worker stopped");
|
|
@@ -246164,6 +246533,8 @@ var init_remote_external_coding_agent = __esm(() => {
|
|
|
246164
246533
|
};
|
|
246165
246534
|
OutdatedRemoteWorkerError = class OutdatedRemoteWorkerError extends Error {
|
|
246166
246535
|
};
|
|
246536
|
+
RemoteFollowUpTimeoutError = class RemoteFollowUpTimeoutError extends Error {
|
|
246537
|
+
};
|
|
246167
246538
|
});
|
|
246168
246539
|
|
|
246169
246540
|
// src/tools/impl/subagent-computer.ts
|
|
@@ -246171,7 +246542,7 @@ function isLocalComputerSelector(value) {
|
|
|
246171
246542
|
return LOCAL_COMPUTER_SELECTORS.has(value.trim().toLowerCase());
|
|
246172
246543
|
}
|
|
246173
246544
|
function acceptsDefaultComputer(input) {
|
|
246174
|
-
return input.subagentType !== "memory" &&
|
|
246545
|
+
return input.subagentType !== "memory" && input.subagentType !== "recall" && input.config.launchProfile !== "memory-subagent";
|
|
246175
246546
|
}
|
|
246176
246547
|
function resolveSubagentComputer(input) {
|
|
246177
246548
|
const requested = typeof input.requested === "string" ? input.requested.trim() : "";
|
|
@@ -246226,6 +246597,8 @@ function killBackgroundProcess(shell_id) {
|
|
|
246226
246597
|
const previousNotificationSuppression = proc.completionNotificationSuppressed;
|
|
246227
246598
|
try {
|
|
246228
246599
|
proc.completionNotificationSuppressed = true;
|
|
246600
|
+
if (proc.kind === "monitor")
|
|
246601
|
+
proc.monitorEndStatus = "stopped";
|
|
246229
246602
|
if (retainsEntry) {
|
|
246230
246603
|
proc.status = "failed";
|
|
246231
246604
|
}
|
|
@@ -246242,6 +246615,7 @@ function killBackgroundProcess(shell_id) {
|
|
|
246242
246615
|
notifyBackgroundProcessStateChanged(proc.runtimeScope);
|
|
246243
246616
|
return true;
|
|
246244
246617
|
} catch {
|
|
246618
|
+
proc.monitorEndStatus = undefined;
|
|
246245
246619
|
proc.status = previousStatus;
|
|
246246
246620
|
proc.completionNotificationSuppressed = previousNotificationSuppression;
|
|
246247
246621
|
return false;
|
|
@@ -246811,7 +247185,7 @@ ${formatSubagentError(result3.error || "Subagent execution failed")}`;
|
|
|
246811
247185
|
});
|
|
246812
247186
|
addToMessageQueueFn({
|
|
246813
247187
|
kind: "task_notification",
|
|
246814
|
-
|
|
247188
|
+
...taskNotificationMessage(notificationXml),
|
|
246815
247189
|
agentId: resolvedParentScope?.agentId,
|
|
246816
247190
|
conversationId: resolvedParentScope?.conversationId,
|
|
246817
247191
|
actingUserId: bgTask.actingUserId,
|
|
@@ -246872,7 +247246,7 @@ ${formatSubagentError(errorMessage6)}`,
|
|
|
246872
247246
|
});
|
|
246873
247247
|
addToMessageQueueFn({
|
|
246874
247248
|
kind: "task_notification",
|
|
246875
|
-
|
|
247249
|
+
...taskNotificationMessage(notificationXml),
|
|
246876
247250
|
agentId: resolvedParentScope?.agentId,
|
|
246877
247251
|
conversationId: resolvedParentScope?.conversationId,
|
|
246878
247252
|
actingUserId: bgTask.actingUserId,
|
|
@@ -246940,6 +247314,9 @@ async function launchSubagent(args) {
|
|
|
246940
247314
|
error: `Invalid subagent_type "${configName}". Available subagent types: ${listSubagentTypes(Object.keys(allConfigs))}. Omit subagent_type for the default agent.`
|
|
246941
247315
|
};
|
|
246942
247316
|
}
|
|
247317
|
+
const promptError = validateForkPrompt(inputPrompt, Boolean(config2.fork));
|
|
247318
|
+
if (promptError)
|
|
247319
|
+
return { success: false, error: promptError };
|
|
246943
247320
|
if (prepared && (!args.conversation_id || args.conversation_id === "default" || args.model !== undefined)) {
|
|
246944
247321
|
return {
|
|
246945
247322
|
success: false,
|
|
@@ -247167,7 +247544,7 @@ Conversation ID: ${result3.conversation_id}` : "";
|
|
|
247167
247544
|
Output file: ${result3.output_file}
|
|
247168
247545
|
Event log: ${taskEventsFileFor(result3.output_file)}
|
|
247169
247546
|
|
|
247170
|
-
You will be notified automatically when this task completes — a <task-notification> message will be delivered with the result. No need to poll or sleep-wait; continue with your current work. To see what it is doing meanwhile, Read the output file: one line per tool call, tool result, and message, live. For exact details (full tool arguments and outputs, such as a command's error), read the event log
|
|
247547
|
+
You will be notified automatically when this task completes — a <task-notification> message will be delivered with the result. No need to poll or sleep-wait; continue with your current work. To see what it is doing meanwhile, Read the output file: one line per tool call, tool result, and message, live. For exact details (full tool arguments and outputs, such as a command's error), read the event log.${subagentResultReminder()}`;
|
|
247171
247548
|
}
|
|
247172
247549
|
var init_task = __esm(() => {
|
|
247173
247550
|
init_context();
|
|
@@ -247362,7 +247739,8 @@ async function send_agent_message(args, deps = {}) {
|
|
|
247362
247739
|
content: JSON.stringify({
|
|
247363
247740
|
status: "accepted",
|
|
247364
247741
|
agent_id: args.agent_id,
|
|
247365
|
-
delivery: receipt3.delivery === "steered" ? "remote/steer" : "remote/resume",
|
|
247742
|
+
delivery: receipt3.delivery === "queued" ? "remote/queued" : receipt3.delivery === "steered" ? "remote/steer" : "remote/resume",
|
|
247743
|
+
...receipt3.delivery === "queued" ? { note: QUEUED_NOTE } : {},
|
|
247366
247744
|
...receipt3.taskId ? { task_id: receipt3.taskId } : {},
|
|
247367
247745
|
...receipt3.outputFile ? { output_file: receipt3.outputFile } : {}
|
|
247368
247746
|
}),
|
|
@@ -247528,7 +247906,8 @@ async function send_agent_message(args, deps = {}) {
|
|
|
247528
247906
|
content: JSON.stringify({
|
|
247529
247907
|
status: "accepted",
|
|
247530
247908
|
agent_id: args.agent_id,
|
|
247531
|
-
delivery: "stream/interrupt"
|
|
247909
|
+
delivery: receipt2.queued ? "stream/queued" : "stream/interrupt",
|
|
247910
|
+
...receipt2.queued ? { note: QUEUED_NOTE } : {}
|
|
247532
247911
|
}),
|
|
247533
247912
|
status: "success"
|
|
247534
247913
|
};
|
|
@@ -247657,7 +248036,7 @@ async function send_agent_message(args, deps = {}) {
|
|
|
247657
248036
|
};
|
|
247658
248037
|
}
|
|
247659
248038
|
}
|
|
247660
|
-
var FULL_CONVERSATION_ID;
|
|
248039
|
+
var QUEUED_NOTE = "The worker is in a long tool call and hasn't stopped yet. Your message is queued and will be handled when it does; don't resend it.", FULL_CONVERSATION_ID;
|
|
247661
248040
|
var init_send_agent_message = __esm(() => {
|
|
247662
248041
|
init_child_send_tracking();
|
|
247663
248042
|
init_subagent_launcher();
|
|
@@ -249520,6 +249899,17 @@ ${text2}`;
|
|
|
249520
249899
|
}
|
|
249521
249900
|
}
|
|
249522
249901
|
async function watch_pr(args, deps = {}) {
|
|
249902
|
+
const resumeRecord = args.resume ? await readResumableMonitor(args.resume, args.parentScope) : undefined;
|
|
249903
|
+
if (resumeRecord) {
|
|
249904
|
+
if (resumeRecord.kind !== "github_pull_request")
|
|
249905
|
+
throw new Error("Use Monitor to resume this monitor.");
|
|
249906
|
+
args = {
|
|
249907
|
+
...resumeRecord.args,
|
|
249908
|
+
resume: resumeRecord.monitor_id,
|
|
249909
|
+
parentScope: args.parentScope,
|
|
249910
|
+
signal: args.signal
|
|
249911
|
+
};
|
|
249912
|
+
}
|
|
249523
249913
|
args.signal?.throwIfAborted();
|
|
249524
249914
|
if (typeof args.url !== "string") {
|
|
249525
249915
|
throw new Error("WatchPR url is required");
|
|
@@ -249548,10 +249938,16 @@ async function watch_pr(args, deps = {}) {
|
|
|
249548
249938
|
const initial2 = await fetchSnapshot(ref, { cwd: cwd2, signal: args.signal });
|
|
249549
249939
|
args.signal?.throwIfAborted();
|
|
249550
249940
|
const changesSincePreviousWatch = resumedChanges(snapshotPath, initial2, args.notify_on);
|
|
249551
|
-
if (isRun && initial2.state !== "OPEN") {
|
|
249941
|
+
if ((isRun || resumeRecord) && initial2.state !== "OPEN") {
|
|
249942
|
+
if (resumeRecord)
|
|
249943
|
+
await updateMonitorState(resumeRecord.monitor_id, {
|
|
249944
|
+
status: "completed",
|
|
249945
|
+
exit_code: 0,
|
|
249946
|
+
output_file: resumeRecord.output_file
|
|
249947
|
+
});
|
|
249552
249948
|
return {
|
|
249553
249949
|
content: [{ type: "text", text: describe2(initial2) }],
|
|
249554
|
-
taskId: "",
|
|
249950
|
+
taskId: resumeRecord?.monitor_id ?? "",
|
|
249555
249951
|
url: ref.url,
|
|
249556
249952
|
headSha: initial2.headSha,
|
|
249557
249953
|
persistent: false
|
|
@@ -249564,10 +249960,16 @@ async function watch_pr(args, deps = {}) {
|
|
|
249564
249960
|
assertBackgroundProcessCapacity();
|
|
249565
249961
|
installMonitorProcessExitCleanup();
|
|
249566
249962
|
const description = isRun ? `Workflow run ${ref.owner}/${ref.repo}#${ref.number}` : `PR ${ref.owner}/${ref.repo}#${ref.number} checks, reviews, and mergeability`;
|
|
249567
|
-
const persistent = !isManagedCloudRuntime();
|
|
249963
|
+
const persistent = !resumeRecord?.expires_at && !isManagedCloudRuntime();
|
|
249568
249964
|
return withMonitorState({
|
|
249569
249965
|
description,
|
|
249570
249966
|
persistent,
|
|
249967
|
+
resumeRecord,
|
|
249968
|
+
timeoutMs: persistent ? 0 : getMonitorMaxTimeoutMs(),
|
|
249969
|
+
args: {
|
|
249970
|
+
url: args.url,
|
|
249971
|
+
...args.notify_on ? { notify_on: args.notify_on } : {}
|
|
249972
|
+
},
|
|
249571
249973
|
command: ref.url,
|
|
249572
249974
|
kind: "github_pull_request",
|
|
249573
249975
|
parentScope,
|
|
@@ -249586,7 +249988,7 @@ ${describe2(initial2)}${changesSincePreviousWatch}
|
|
|
249586
249988
|
const controller = new AbortController;
|
|
249587
249989
|
const secrets2 = {};
|
|
249588
249990
|
let processState;
|
|
249589
|
-
const maxTimeoutMs = getMonitorMaxTimeoutMs();
|
|
249991
|
+
const maxTimeoutMs = resumeRecord?.expires_at ? Math.max(1, Date.parse(resumeRecord.expires_at) - Date.now()) : getMonitorMaxTimeoutMs();
|
|
249590
249992
|
let timeout;
|
|
249591
249993
|
const events = createMonitorEventStream({
|
|
249592
249994
|
emit(event) {
|
|
@@ -249659,7 +250061,7 @@ ${event}
|
|
|
249659
250061
|
`);
|
|
249660
250062
|
queueMonitorEvent({ taskId, event, scope, actingUserId, secrets: secrets2 });
|
|
249661
250063
|
processState.completionNotificationSuppressed = true;
|
|
249662
|
-
markMonitorFinished(taskId, processState, "
|
|
250064
|
+
markMonitorFinished(taskId, processState, "expired", null);
|
|
249663
250065
|
processState.process.kill();
|
|
249664
250066
|
}, maxTimeoutMs);
|
|
249665
250067
|
unrefTimer(timeout);
|
|
@@ -249792,6 +250194,7 @@ Output file: ${outputFile}`
|
|
|
249792
250194
|
}
|
|
249793
250195
|
var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS, WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS;
|
|
249794
250196
|
var init_watch_pr = __esm(() => {
|
|
250197
|
+
init_monitors();
|
|
249795
250198
|
init_runtime_context();
|
|
249796
250199
|
init_secret_substitution();
|
|
249797
250200
|
init_settings_path();
|
|
@@ -249802,6 +250205,7 @@ var init_watch_pr = __esm(() => {
|
|
|
249802
250205
|
init_github_workflow_run();
|
|
249803
250206
|
init_monitor();
|
|
249804
250207
|
init_monitor_event_stream();
|
|
250208
|
+
init_monitor_resume();
|
|
249805
250209
|
init_monitor_state();
|
|
249806
250210
|
init_monitor_timeout();
|
|
249807
250211
|
init_process_manager();
|
|
@@ -251343,7 +251747,7 @@ var init_Monitor2 = __esm(() => {
|
|
|
251343
251747
|
properties: {
|
|
251344
251748
|
description: {
|
|
251345
251749
|
type: "string",
|
|
251346
|
-
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`."
|
|
251750
|
+
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`. Required unless `resume` is set."
|
|
251347
251751
|
},
|
|
251348
251752
|
timeout_ms: {
|
|
251349
251753
|
type: "number",
|
|
@@ -251395,11 +251799,15 @@ var init_Monitor2 = __esm(() => {
|
|
|
251395
251799
|
},
|
|
251396
251800
|
args: {
|
|
251397
251801
|
description: "Optional input exposed to script as args."
|
|
251802
|
+
},
|
|
251803
|
+
resume: {
|
|
251804
|
+
type: "string",
|
|
251805
|
+
description: "Resume a paused monitor by its saved monitor id. Omit the other arguments."
|
|
251398
251806
|
}
|
|
251399
251807
|
},
|
|
251400
|
-
required: ["description"],
|
|
251401
251808
|
additionalProperties: false,
|
|
251402
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
251809
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
251810
|
+
required: []
|
|
251403
251811
|
};
|
|
251404
251812
|
});
|
|
251405
251813
|
|
|
@@ -251568,7 +251976,7 @@ var init_Task2 = __esm(() => {
|
|
|
251568
251976
|
},
|
|
251569
251977
|
fork_context: {
|
|
251570
251978
|
type: "boolean",
|
|
251571
|
-
description: "
|
|
251979
|
+
description: "Whether the new agent starts from this conversation. A fork gives it the source: what people actually said, the evidence gathered so far, and the decisions and corrections made along the way. A brief is your retelling of that, and anything you leave out or reword never reaches the worker. So fork whenever the task comes out of this conversation, however long or noisy it is; the fork is trimmed to fit. If you notice yourself writing a brief to explain the conversation, that's the cue to fork. Skip forking only when the task has nothing to do with this conversation, or the worker shouldn't see what's in it. Applies when creating a Letta Code subagent without subagent_type. Cannot be applied to existing agents or threads. Defaults to true for new default Letta agents and external workers; existing agent or conversation targets resume without forking."
|
|
251572
251980
|
},
|
|
251573
251981
|
model: {
|
|
251574
251982
|
type: "string",
|
|
@@ -251849,7 +252257,7 @@ var init_WatchPR2 = __esm(() => {
|
|
|
251849
252257
|
properties: {
|
|
251850
252258
|
url: {
|
|
251851
252259
|
type: "string",
|
|
251852
|
-
description: "Open github.com pull request URL ending at the PR number, for example https://github.com/owner/repo/pull/123. Remove sub-page suffixes such as /files or /commits. Also accepts https://github.com/owner/repo/actions/runs/123."
|
|
252260
|
+
description: "Open github.com pull request URL ending at the PR number, for example https://github.com/owner/repo/pull/123. Remove sub-page suffixes such as /files or /commits. Also accepts https://github.com/owner/repo/actions/runs/123. Required unless `resume` is set."
|
|
251853
252261
|
},
|
|
251854
252262
|
notify_on: {
|
|
251855
252263
|
type: "array",
|
|
@@ -251869,11 +252277,15 @@ var init_WatchPR2 = __esm(() => {
|
|
|
251869
252277
|
]
|
|
251870
252278
|
},
|
|
251871
252279
|
description: "PR events to report; omitted reports all. checks_done reports when no checks remain pending, including pass/fail. Workflow runs always report status and completion."
|
|
252280
|
+
},
|
|
252281
|
+
resume: {
|
|
252282
|
+
type: "string",
|
|
252283
|
+
description: "Resume a paused monitor by its saved monitor id. Omit the other arguments."
|
|
251872
252284
|
}
|
|
251873
252285
|
},
|
|
251874
|
-
required: ["url"],
|
|
251875
252286
|
additionalProperties: false,
|
|
251876
|
-
$schema: "http://json-schema.org/draft-07/schema#"
|
|
252287
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
252288
|
+
required: []
|
|
251877
252289
|
};
|
|
251878
252290
|
});
|
|
251879
252291
|
|
|
@@ -253029,7 +253441,7 @@ function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(
|
|
|
253029
253441
|
snapshotSidecar
|
|
253030
253442
|
});
|
|
253031
253443
|
const rawSnapshot = () => listInterruptedTurnMainSnapshot(directory, readRecord2);
|
|
253032
|
-
return {
|
|
253444
|
+
return withInterruptedTurnDiskReserve(directory, {
|
|
253033
253445
|
list() {
|
|
253034
253446
|
try {
|
|
253035
253447
|
const rawRecords = rawSnapshot().records;
|
|
@@ -253422,7 +253834,7 @@ function createInterruptedTurnStore(directory = defaultInterruptedTurnDirectory(
|
|
|
253422
253834
|
release();
|
|
253423
253835
|
}
|
|
253424
253836
|
}
|
|
253425
|
-
};
|
|
253837
|
+
});
|
|
253426
253838
|
}
|
|
253427
253839
|
function recordListenerWork(runtime, update2, phase, expectedRevision, recoveryLineageId, store3 = createInterruptedTurnStore()) {
|
|
253428
253840
|
if (!runtime.agentId || !runtime.listener.connectionId?.startsWith("conn-"))
|
|
@@ -253560,6 +253972,7 @@ var init_interrupted_turn_record = __esm(() => {
|
|
|
253560
253972
|
init_error_reporting();
|
|
253561
253973
|
init_debug();
|
|
253562
253974
|
init_durable_file_lock();
|
|
253975
|
+
init_interrupted_turn_disk_reserve();
|
|
253563
253976
|
init_interrupted_turn_input_ownership();
|
|
253564
253977
|
init_interrupted_turn_revision();
|
|
253565
253978
|
init_interrupted_turn_schema();
|
|
@@ -257106,71 +257519,6 @@ function withMessageAttribution(message2, actingUserId) {
|
|
|
257106
257519
|
return { ...message2, attribution: { acting_user_id: actingUserId } };
|
|
257107
257520
|
}
|
|
257108
257521
|
|
|
257109
|
-
// src/queue/turn-queue-runtime.ts
|
|
257110
|
-
function stringifyUnexpectedContent(content) {
|
|
257111
|
-
try {
|
|
257112
|
-
return JSON.stringify(content) ?? String(content);
|
|
257113
|
-
} catch {
|
|
257114
|
-
return String(content);
|
|
257115
|
-
}
|
|
257116
|
-
}
|
|
257117
|
-
function appendContentParts(target, content) {
|
|
257118
|
-
if (typeof content === "string") {
|
|
257119
|
-
target.push({ type: "text", text: content });
|
|
257120
|
-
return;
|
|
257121
|
-
}
|
|
257122
|
-
if (!Array.isArray(content)) {
|
|
257123
|
-
if (content === null || content === undefined)
|
|
257124
|
-
return;
|
|
257125
|
-
target.push({ type: "text", text: stringifyUnexpectedContent(content) });
|
|
257126
|
-
return;
|
|
257127
|
-
}
|
|
257128
|
-
target.push(...content);
|
|
257129
|
-
}
|
|
257130
|
-
function escapeResultText(text2) {
|
|
257131
|
-
return text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
257132
|
-
}
|
|
257133
|
-
function buildTaskNotificationContent(item) {
|
|
257134
|
-
if (item.content === undefined)
|
|
257135
|
-
return item.text;
|
|
257136
|
-
const parts = [
|
|
257137
|
-
{ type: "text", text: item.text },
|
|
257138
|
-
{ type: "text", text: `
|
|
257139
|
-
<external-tool-result>` }
|
|
257140
|
-
];
|
|
257141
|
-
const content = typeof item.content === "string" ? [{ type: "text", text: item.content }] : item.content;
|
|
257142
|
-
for (const part of content) {
|
|
257143
|
-
parts.push(part.type === "text" ? { type: "text", text: `<text>${escapeResultText(part.text)}</text>` } : part);
|
|
257144
|
-
}
|
|
257145
|
-
parts.push({ type: "text", text: "</external-tool-result>" });
|
|
257146
|
-
return parts;
|
|
257147
|
-
}
|
|
257148
|
-
function mergeQueuedTurnInput(queued2, options) {
|
|
257149
|
-
if (queued2.length === 0) {
|
|
257150
|
-
return null;
|
|
257151
|
-
}
|
|
257152
|
-
const separatorText = options.separatorText ?? `
|
|
257153
|
-
`;
|
|
257154
|
-
const mergedParts = [];
|
|
257155
|
-
let isFirst = true;
|
|
257156
|
-
for (const item of queued2) {
|
|
257157
|
-
if (!isFirst) {
|
|
257158
|
-
mergedParts.push({ type: "text", text: separatorText });
|
|
257159
|
-
}
|
|
257160
|
-
isFirst = false;
|
|
257161
|
-
if (item.kind === "task_notification") {
|
|
257162
|
-
appendContentParts(mergedParts, buildTaskNotificationContent(item));
|
|
257163
|
-
continue;
|
|
257164
|
-
}
|
|
257165
|
-
if (item.kind === "cron_prompt") {
|
|
257166
|
-
mergedParts.push({ type: "text", text: item.text });
|
|
257167
|
-
continue;
|
|
257168
|
-
}
|
|
257169
|
-
appendContentParts(mergedParts, options.normalizeUserContent(item.content));
|
|
257170
|
-
}
|
|
257171
|
-
return mergedParts.length > 0 ? mergedParts : null;
|
|
257172
|
-
}
|
|
257173
|
-
|
|
257174
257522
|
// src/websocket/helpers/listener-queue-adapter.ts
|
|
257175
257523
|
function getListenerBlockedReason(lifecycle, pendingApprovalsLen) {
|
|
257176
257524
|
if (lifecycle.kind === "cancelling") {
|
|
@@ -258577,11 +258925,12 @@ function handleTaskPreflight(task2, now2) {
|
|
|
258577
258925
|
return handleInvalidRecurringTask(task2, now2) || handleMissedOneShot(task2, now2);
|
|
258578
258926
|
}
|
|
258579
258927
|
async function runCronTaskNow(taskId) {
|
|
258580
|
-
|
|
258928
|
+
const executionError = getLocalCronExecutionError();
|
|
258929
|
+
if (executionError) {
|
|
258581
258930
|
return {
|
|
258582
258931
|
success: false,
|
|
258583
258932
|
found: false,
|
|
258584
|
-
error:
|
|
258933
|
+
error: executionError
|
|
258585
258934
|
};
|
|
258586
258935
|
}
|
|
258587
258936
|
const task2 = getTask(taskId);
|
|
@@ -258700,7 +259049,7 @@ function tick2(state2, socket, opts, processQueuedTurn) {
|
|
|
258700
259049
|
}
|
|
258701
259050
|
}
|
|
258702
259051
|
function startScheduler(socket, opts, processQueuedTurn, _retryCount = 0) {
|
|
258703
|
-
if (
|
|
259052
|
+
if (getLocalCronExecutionError()) {
|
|
258704
259053
|
return;
|
|
258705
259054
|
}
|
|
258706
259055
|
listenerFireContext = { socket, opts, processQueuedTurn };
|
|
@@ -258914,11 +259263,9 @@ Add options:
|
|
|
258914
259263
|
--conversation <id> Conversation target (omit or "new" for a fresh
|
|
258915
259264
|
conversation per fire; "self" for the current
|
|
258916
259265
|
conversation; "default" for the agent default)
|
|
258917
|
-
--computer <id>
|
|
258918
|
-
|
|
258919
|
-
|
|
258920
|
-
time, that run fails (no Cloud sandbox fallback);
|
|
258921
|
-
omit --computer to run in the Cloud sandbox.
|
|
259266
|
+
--computer <id> Run on another connected computer (deviceId, id, or
|
|
259267
|
+
name from \`letta computers list\`). If it is offline
|
|
259268
|
+
at fire time, that run fails.
|
|
258922
259269
|
|
|
258923
259270
|
List/filter options:
|
|
258924
259271
|
--agent <id> Filter by agent ID
|
|
@@ -258951,8 +259298,7 @@ function formatCloudScheduleOutput(schedule) {
|
|
|
258951
259298
|
const targetDeviceId = schedule.target_device_id ?? null;
|
|
258952
259299
|
return {
|
|
258953
259300
|
id: schedule.id,
|
|
258954
|
-
|
|
258955
|
-
execution_target: targetDeviceId ?? CLOUD_EXECUTION_TARGET,
|
|
259301
|
+
...targetDeviceId && { execution_target: targetDeviceId },
|
|
258956
259302
|
...targetDeviceId && { target_device_id: targetDeviceId },
|
|
258957
259303
|
agent_id: schedule.agent_id,
|
|
258958
259304
|
conversation_id: schedule.conversation_id ?? "default",
|
|
@@ -259071,11 +259417,11 @@ async function handleAdd(values4) {
|
|
|
259071
259417
|
cron,
|
|
259072
259418
|
recurring,
|
|
259073
259419
|
prompt,
|
|
259074
|
-
scheduled_for: scheduledFor
|
|
259420
|
+
scheduled_for: scheduledFor,
|
|
259421
|
+
timezone: "UTC"
|
|
259075
259422
|
});
|
|
259076
259423
|
const output = {
|
|
259077
259424
|
id: result3.task.id,
|
|
259078
|
-
runner: "local",
|
|
259079
259425
|
status: result3.task.status,
|
|
259080
259426
|
cron: result3.task.cron,
|
|
259081
259427
|
recurring: result3.task.recurring,
|
|
@@ -259093,10 +259439,10 @@ async function handleAdd(values4) {
|
|
|
259093
259439
|
output.note = note;
|
|
259094
259440
|
}
|
|
259095
259441
|
if (result3.warning) {
|
|
259096
|
-
output.warning =
|
|
259442
|
+
output.warning = "This task only fires while this session is running.";
|
|
259097
259443
|
}
|
|
259098
259444
|
console.log(JSON.stringify(output, null, 2));
|
|
259099
|
-
console.error("Created
|
|
259445
|
+
console.error("Created schedule. It only fires while this session is running.");
|
|
259100
259446
|
return 0;
|
|
259101
259447
|
} catch (err) {
|
|
259102
259448
|
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -259125,8 +259471,7 @@ async function handleCloudAdd(params) {
|
|
|
259125
259471
|
const targetDeviceId = result3.target_device_id ?? built.input.target_device_id ?? null;
|
|
259126
259472
|
const output = {
|
|
259127
259473
|
id: result3.id,
|
|
259128
|
-
|
|
259129
|
-
execution_target: targetDeviceId ?? CLOUD_EXECUTION_TARGET,
|
|
259474
|
+
...targetDeviceId && { execution_target: targetDeviceId },
|
|
259130
259475
|
...targetDeviceId && { target_device_id: targetDeviceId },
|
|
259131
259476
|
agent_id: params.agentId,
|
|
259132
259477
|
conversation_id: params.conversationId,
|
|
@@ -259143,10 +259488,10 @@ async function handleCloudAdd(params) {
|
|
|
259143
259488
|
output.notes = notes;
|
|
259144
259489
|
}
|
|
259145
259490
|
console.log(JSON.stringify(output, null, 2));
|
|
259146
|
-
console.error(targetDeviceId ? `Created
|
|
259491
|
+
console.error(targetDeviceId ? `Created schedule on computer "${targetDeviceId}". If it is offline at fire time, that run fails.` : "Created schedule.");
|
|
259147
259492
|
return 0;
|
|
259148
259493
|
} catch (err) {
|
|
259149
|
-
console.error(`Error: failed to create
|
|
259494
|
+
console.error(`Error: failed to create schedule: ${err instanceof Error ? err.message : String(err)}`);
|
|
259150
259495
|
console.error("No schedule was created. Retry the request.");
|
|
259151
259496
|
return 1;
|
|
259152
259497
|
}
|
|
@@ -259159,7 +259504,7 @@ async function handleList(values4) {
|
|
|
259159
259504
|
const output = listTasks({
|
|
259160
259505
|
agent_id: agentId,
|
|
259161
259506
|
conversation_id: conversationId
|
|
259162
|
-
}).map((task2) => ({ ...task2
|
|
259507
|
+
}).map((task2) => ({ ...task2 }));
|
|
259163
259508
|
if (agentId && canManageCloudSchedules(agentId)) {
|
|
259164
259509
|
try {
|
|
259165
259510
|
await ensureSettingsForCloud2();
|
|
@@ -259169,9 +259514,9 @@ async function handleList(values4) {
|
|
|
259169
259514
|
}
|
|
259170
259515
|
} catch (err) {
|
|
259171
259516
|
if (err instanceof ApiRequestError && (err.status === 404 || err.status === 405)) {
|
|
259172
|
-
console.error("Note:
|
|
259517
|
+
console.error("Note: Schedules not listed (server does not serve the schedule routes, or this agent is not visible to the current credential).");
|
|
259173
259518
|
} else {
|
|
259174
|
-
console.error(`Warning:
|
|
259519
|
+
console.error(`Warning: Schedules not listed: ${err instanceof Error ? err.message : String(err)}`);
|
|
259175
259520
|
}
|
|
259176
259521
|
}
|
|
259177
259522
|
}
|
|
@@ -259187,7 +259532,7 @@ async function handleGet(values4, positionals) {
|
|
|
259187
259532
|
const agentId = resolveCronAgentId(values4.agent);
|
|
259188
259533
|
const task2 = getTask(taskRef);
|
|
259189
259534
|
if (task2) {
|
|
259190
|
-
console.log(JSON.stringify({ ...task2
|
|
259535
|
+
console.log(JSON.stringify({ ...task2 }, null, 2));
|
|
259191
259536
|
return 0;
|
|
259192
259537
|
}
|
|
259193
259538
|
if (agentId && canManageCloudSchedules(agentId)) {
|
|
@@ -259211,7 +259556,7 @@ async function handleGet(values4, positionals) {
|
|
|
259211
259556
|
if (resolved?.store === "local") {
|
|
259212
259557
|
const task3 = getTask(resolved.id);
|
|
259213
259558
|
if (task3) {
|
|
259214
|
-
console.log(JSON.stringify({ ...task3
|
|
259559
|
+
console.log(JSON.stringify({ ...task3 }, null, 2));
|
|
259215
259560
|
return 0;
|
|
259216
259561
|
}
|
|
259217
259562
|
}
|
|
@@ -259251,7 +259596,7 @@ async function handleRuns(values4) {
|
|
|
259251
259596
|
}
|
|
259252
259597
|
const agentId = resolveCronAgentId(values4.agent);
|
|
259253
259598
|
if (!agentId) {
|
|
259254
|
-
console.error(`Error: --agent or LETTA_AGENT_ID is required to look up
|
|
259599
|
+
console.error(`Error: --agent or LETTA_AGENT_ID is required to look up schedule runs for task ${id}.`);
|
|
259255
259600
|
return 1;
|
|
259256
259601
|
}
|
|
259257
259602
|
if (!canManageCloudSchedules(agentId)) {
|
|
@@ -259262,7 +259607,6 @@ async function handleRuns(values4) {
|
|
|
259262
259607
|
await ensureSettingsForCloud2();
|
|
259263
259608
|
const response = await listCloudScheduleHistory(agentId, id, { limit: limit4 });
|
|
259264
259609
|
console.log(JSON.stringify({
|
|
259265
|
-
runner: "cloud",
|
|
259266
259610
|
entries: response.history,
|
|
259267
259611
|
has_next_page: response.has_next_page
|
|
259268
259612
|
}, null, 2));
|
|
@@ -259283,7 +259627,7 @@ async function handleDelete(values4, positionals) {
|
|
|
259283
259627
|
}
|
|
259284
259628
|
const found = deleteTask(taskRef);
|
|
259285
259629
|
if (found) {
|
|
259286
|
-
console.log(JSON.stringify({ deleted: taskRef
|
|
259630
|
+
console.log(JSON.stringify({ deleted: taskRef }));
|
|
259287
259631
|
return 0;
|
|
259288
259632
|
}
|
|
259289
259633
|
const agentId = resolveCronAgentId(values4.agent);
|
|
@@ -259292,7 +259636,7 @@ async function handleDelete(values4, positionals) {
|
|
|
259292
259636
|
await ensureSettingsForCloud2();
|
|
259293
259637
|
await getCloudSchedule(agentId, taskRef);
|
|
259294
259638
|
await deleteCloudSchedule(agentId, taskRef);
|
|
259295
|
-
console.log(JSON.stringify({ deleted: taskRef
|
|
259639
|
+
console.log(JSON.stringify({ deleted: taskRef }));
|
|
259296
259640
|
return 0;
|
|
259297
259641
|
} catch (err) {
|
|
259298
259642
|
if (!(err instanceof ApiRequestError && err.status === 404)) {
|
|
@@ -259307,7 +259651,7 @@ async function handleDelete(values4, positionals) {
|
|
|
259307
259651
|
return 1;
|
|
259308
259652
|
}
|
|
259309
259653
|
if (resolved?.store === "local" && deleteTask(resolved.id)) {
|
|
259310
|
-
console.log(JSON.stringify({ deleted: resolved.id, name: taskRef
|
|
259654
|
+
console.log(JSON.stringify({ deleted: resolved.id, name: taskRef }));
|
|
259311
259655
|
return 0;
|
|
259312
259656
|
}
|
|
259313
259657
|
if (resolved?.store === "cloud" && agentId) {
|
|
@@ -259315,8 +259659,7 @@ async function handleDelete(values4, positionals) {
|
|
|
259315
259659
|
await deleteCloudSchedule(agentId, resolved.id);
|
|
259316
259660
|
console.log(JSON.stringify({
|
|
259317
259661
|
deleted: resolved.id,
|
|
259318
|
-
name: taskRef
|
|
259319
|
-
runner: "cloud"
|
|
259662
|
+
name: taskRef
|
|
259320
259663
|
}));
|
|
259321
259664
|
return 0;
|
|
259322
259665
|
} catch (err) {
|
|
@@ -259344,15 +259687,13 @@ async function handleDeleteAll(values4) {
|
|
|
259344
259687
|
cloudDeleted += 1;
|
|
259345
259688
|
}
|
|
259346
259689
|
} catch (err) {
|
|
259347
|
-
console.error(`Error: failed to delete
|
|
259348
|
-
console.error(`Deleted so far: ${localDeleted
|
|
259690
|
+
console.error(`Error: failed to delete schedules: ${err instanceof Error ? err.message : String(err)}`);
|
|
259691
|
+
console.error(`Deleted so far: ${localDeleted + cloudDeleted}.`);
|
|
259349
259692
|
return 1;
|
|
259350
259693
|
}
|
|
259351
259694
|
}
|
|
259352
259695
|
console.log(JSON.stringify({
|
|
259353
259696
|
deleted: localDeleted + cloudDeleted,
|
|
259354
|
-
local_deleted: localDeleted,
|
|
259355
|
-
cloud_deleted: cloudDeleted,
|
|
259356
259697
|
agent_id: agentId
|
|
259357
259698
|
}));
|
|
259358
259699
|
return 0;
|
|
@@ -268101,6 +268442,7 @@ async function prepareToolExecutionContextForScope(params) {
|
|
|
268101
268442
|
modAdapters,
|
|
268102
268443
|
agent,
|
|
268103
268444
|
runtimeContext: {
|
|
268445
|
+
sessionSource: getRuntimeSessionSource(),
|
|
268104
268446
|
connectionId,
|
|
268105
268447
|
environmentDeviceId,
|
|
268106
268448
|
agentId,
|
|
@@ -268164,6 +268506,7 @@ var init_toolset = __esm(() => {
|
|
|
268164
268506
|
init_model_handles();
|
|
268165
268507
|
init_backend2();
|
|
268166
268508
|
init_context2();
|
|
268509
|
+
init_runtime_context();
|
|
268167
268510
|
init_settings_manager();
|
|
268168
268511
|
init_client_preferences();
|
|
268169
268512
|
init_manager2();
|
|
@@ -396607,7 +396950,7 @@ ${newComment.split(`
|
|
|
396607
396950
|
let returnType;
|
|
396608
396951
|
const parameters = [];
|
|
396609
396952
|
const callArguments = [];
|
|
396610
|
-
let
|
|
396953
|
+
let writes2;
|
|
396611
396954
|
usagesInScope.forEach((usage, name) => {
|
|
396612
396955
|
let typeNode;
|
|
396613
396956
|
if (!isJS) {
|
|
@@ -396618,7 +396961,7 @@ ${newComment.split(`
|
|
|
396618
396961
|
const paramDecl = factory.createParameterDeclaration(undefined, undefined, name, undefined, typeNode);
|
|
396619
396962
|
parameters.push(paramDecl);
|
|
396620
396963
|
if (usage.usage === 2) {
|
|
396621
|
-
(
|
|
396964
|
+
(writes2 || (writes2 = [])).push(usage);
|
|
396622
396965
|
}
|
|
396623
396966
|
callArguments.push(factory.createIdentifier(name));
|
|
396624
396967
|
});
|
|
@@ -396630,7 +396973,7 @@ ${newComment.split(`
|
|
|
396630
396973
|
const contextualType = checker.getContextualType(node);
|
|
396631
396974
|
returnType = checker.typeToTypeNode(contextualType, scope, 1, 8);
|
|
396632
396975
|
}
|
|
396633
|
-
const { body: body3, returnValueProperty } = transformFunctionBody(node, exposedVariableDeclarations,
|
|
396976
|
+
const { body: body3, returnValueProperty } = transformFunctionBody(node, exposedVariableDeclarations, writes2, substitutions, !!(range4.facts & 1));
|
|
396634
396977
|
suppressLeadingAndTrailingTrivia(body3);
|
|
396635
396978
|
let newFunction;
|
|
396636
396979
|
const callThis = !!(range4.facts & 16);
|
|
@@ -396673,7 +397016,7 @@ ${newComment.split(`
|
|
|
396673
397016
|
if (isInJSXContent(node)) {
|
|
396674
397017
|
call = factory.createJsxExpression(undefined, call);
|
|
396675
397018
|
}
|
|
396676
|
-
if (exposedVariableDeclarations.length && !
|
|
397019
|
+
if (exposedVariableDeclarations.length && !writes2) {
|
|
396677
397020
|
Debug.assert(!returnValueProperty, "Expected no returnValueProperty");
|
|
396678
397021
|
Debug.assert(!(range4.facts & 1), "Expected RangeFacts.HasReturn flag to be unset");
|
|
396679
397022
|
if (exposedVariableDeclarations.length === 1) {
|
|
@@ -396697,7 +397040,7 @@ ${newComment.split(`
|
|
|
396697
397040
|
}
|
|
396698
397041
|
newNodes.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createObjectBindingPattern(bindingElements), undefined, typeLiteral, call)], commonNodeFlags)));
|
|
396699
397042
|
}
|
|
396700
|
-
} else if (exposedVariableDeclarations.length ||
|
|
397043
|
+
} else if (exposedVariableDeclarations.length || writes2) {
|
|
396701
397044
|
if (exposedVariableDeclarations.length) {
|
|
396702
397045
|
for (const variableDeclaration of exposedVariableDeclarations) {
|
|
396703
397046
|
let flags = variableDeclaration.parent.flags;
|
|
@@ -396710,7 +397053,7 @@ ${newComment.split(`
|
|
|
396710
397053
|
if (returnValueProperty) {
|
|
396711
397054
|
newNodes.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(returnValueProperty, undefined, getTypeDeepCloneUnionUndefined(returnType))], 1)));
|
|
396712
397055
|
}
|
|
396713
|
-
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations,
|
|
397056
|
+
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes2);
|
|
396714
397057
|
if (returnValueProperty) {
|
|
396715
397058
|
assignments.unshift(factory.createShorthandPropertyAssignment(returnValueProperty));
|
|
396716
397059
|
}
|
|
@@ -396892,8 +397235,8 @@ ${newComment.split(`
|
|
|
396892
397235
|
return functionReference;
|
|
396893
397236
|
}
|
|
396894
397237
|
}
|
|
396895
|
-
function transformFunctionBody(body3, exposedVariableDeclarations,
|
|
396896
|
-
const hasWritesOrVariableDeclarations =
|
|
397238
|
+
function transformFunctionBody(body3, exposedVariableDeclarations, writes2, substitutions, hasReturn2) {
|
|
397239
|
+
const hasWritesOrVariableDeclarations = writes2 !== undefined || exposedVariableDeclarations.length > 0;
|
|
396897
397240
|
if (isBlock(body3) && !hasWritesOrVariableDeclarations && substitutions.size === 0) {
|
|
396898
397241
|
return { body: factory.createBlock(body3.statements, true), returnValueProperty: undefined };
|
|
396899
397242
|
}
|
|
@@ -396903,7 +397246,7 @@ ${newComment.split(`
|
|
|
396903
397246
|
if (hasWritesOrVariableDeclarations || substitutions.size) {
|
|
396904
397247
|
const rewrittenStatements = visitNodes2(statements, visitor, isStatement).slice();
|
|
396905
397248
|
if (hasWritesOrVariableDeclarations && !hasReturn2 && isStatement(body3)) {
|
|
396906
|
-
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations,
|
|
397249
|
+
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes2);
|
|
396907
397250
|
if (assignments.length === 1) {
|
|
396908
397251
|
rewrittenStatements.push(factory.createReturnStatement(assignments[0].name));
|
|
396909
397252
|
} else {
|
|
@@ -396916,7 +397259,7 @@ ${newComment.split(`
|
|
|
396916
397259
|
}
|
|
396917
397260
|
function visitor(node) {
|
|
396918
397261
|
if (!ignoreReturns && isReturnStatement(node) && hasWritesOrVariableDeclarations) {
|
|
396919
|
-
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations,
|
|
397262
|
+
const assignments = getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes2);
|
|
396920
397263
|
if (node.expression) {
|
|
396921
397264
|
if (!returnValueProperty) {
|
|
396922
397265
|
returnValueProperty = "__return";
|
|
@@ -397010,9 +397353,9 @@ ${newComment.split(`
|
|
|
397010
397353
|
Debug.assert(curr !== scope, "Didn't encounter a block-like before encountering scope");
|
|
397011
397354
|
}
|
|
397012
397355
|
}
|
|
397013
|
-
function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations,
|
|
397356
|
+
function getPropertyAssignmentsForWritesAndVariableDeclarations(exposedVariableDeclarations, writes2) {
|
|
397014
397357
|
const variableAssignments = map3(exposedVariableDeclarations, (v2) => factory.createShorthandPropertyAssignment(v2.symbol.name));
|
|
397015
|
-
const writeAssignments = map3(
|
|
397358
|
+
const writeAssignments = map3(writes2, (w3) => factory.createShorthandPropertyAssignment(w3.symbol.name));
|
|
397016
397359
|
return variableAssignments === undefined ? writeAssignments : writeAssignments === undefined ? variableAssignments : variableAssignments.concat(writeAssignments);
|
|
397017
397360
|
}
|
|
397018
397361
|
function isReadonlyArray4(v2) {
|
|
@@ -459210,9 +459553,9 @@ async function handleCronCommand(parsed, socket, safeSocketSend) {
|
|
|
459210
459553
|
}
|
|
459211
459554
|
if (parsed.type === "cron_add") {
|
|
459212
459555
|
try {
|
|
459213
|
-
|
|
459214
|
-
|
|
459215
|
-
|
|
459556
|
+
const executionError = getLocalCronExecutionError("created");
|
|
459557
|
+
if (executionError)
|
|
459558
|
+
throw new Error(executionError);
|
|
459216
459559
|
const scheduledFor = parsed.scheduled_for ? new Date(parsed.scheduled_for) : undefined;
|
|
459217
459560
|
if (scheduledFor && Number.isNaN(scheduledFor.getTime())) {
|
|
459218
459561
|
throw new Error("Invalid scheduled_for timestamp");
|
|
@@ -459320,8 +459663,9 @@ async function handleCronCommand(parsed, socket, safeSocketSend) {
|
|
|
459320
459663
|
if (parsed.type === "cron_pause" || parsed.type === "cron_resume") {
|
|
459321
459664
|
const responseType = parsed.type === "cron_pause" ? "cron_pause_response" : "cron_resume_response";
|
|
459322
459665
|
try {
|
|
459323
|
-
|
|
459324
|
-
|
|
459666
|
+
const executionError = getLocalCronExecutionError("resumed");
|
|
459667
|
+
if (parsed.type === "cron_resume" && executionError) {
|
|
459668
|
+
throw new Error(executionError);
|
|
459325
459669
|
}
|
|
459326
459670
|
let scheduledFor;
|
|
459327
459671
|
if (parsed.type === "cron_resume" && parsed.scheduled_for !== undefined) {
|
|
@@ -462958,7 +463302,11 @@ async function handleSubagentMessageCommand(command, parent, deps = {}) {
|
|
|
462958
463302
|
}, { env: worker?.env });
|
|
462959
463303
|
}));
|
|
462960
463304
|
if (receipt.mode === "steered")
|
|
462961
|
-
return {
|
|
463305
|
+
return {
|
|
463306
|
+
...base2,
|
|
463307
|
+
success: true,
|
|
463308
|
+
delivery: "queued" in receipt && receipt.queued ? "queued" : "steered"
|
|
463309
|
+
};
|
|
462962
463310
|
if (!receipt.completion || !receipt.interrupt)
|
|
462963
463311
|
throw new Error("External coding agent returned an incomplete receipt");
|
|
462964
463312
|
const secretEnv = worker?.secretEnv;
|
|
@@ -468559,6 +468907,7 @@ function shouldAcquireStandaloneListenerLock() {
|
|
|
468559
468907
|
return shouldAcquireManualListenerLock(getSpawnerListenerInstanceId(), process.env.LETTA_DESKTOP_MODE === "1");
|
|
468560
468908
|
}
|
|
468561
468909
|
async function runListenSubcommand(argv, appServer) {
|
|
468910
|
+
process.env.LETTA_RUNTIME_SESSION_SOURCE = "listen";
|
|
468562
468911
|
const lifecycleRequested = hasJsonlLifecycleIntent(argv);
|
|
468563
468912
|
if (lifecycleRequested)
|
|
468564
468913
|
suppressStartupLogMarker();
|
|
@@ -472736,8 +473085,96 @@ var init_mods = __esm(() => {
|
|
|
472736
473085
|
};
|
|
472737
473086
|
});
|
|
472738
473087
|
|
|
472739
|
-
// src/cli/subcommands/
|
|
473088
|
+
// src/cli/subcommands/monitors.ts
|
|
472740
473089
|
import { parseArgs as parseArgs16 } from "node:util";
|
|
473090
|
+
async function runMonitorsSubcommand(argv, deps = {}) {
|
|
473091
|
+
const print = deps.print ?? console.log;
|
|
473092
|
+
try {
|
|
473093
|
+
const { values: values4, positionals } = parseArgs16({
|
|
473094
|
+
args: argv,
|
|
473095
|
+
allowPositionals: true,
|
|
473096
|
+
options: {
|
|
473097
|
+
agent: { type: "string" },
|
|
473098
|
+
status: { type: "string" },
|
|
473099
|
+
json: { type: "boolean" },
|
|
473100
|
+
help: { type: "boolean", short: "h" }
|
|
473101
|
+
}
|
|
473102
|
+
});
|
|
473103
|
+
if (values4.help || !positionals.length || positionals[0] === "help") {
|
|
473104
|
+
print(HELP);
|
|
473105
|
+
return values4.help || positionals[0] === "help" ? 0 : 1;
|
|
473106
|
+
}
|
|
473107
|
+
await (deps.initializeSettings ?? (() => settingsManager.initialize()))();
|
|
473108
|
+
if (positionals[0] === "resume" && positionals.length === 2) {
|
|
473109
|
+
const record5 = await (deps.read ?? readResumableMonitor)(positionals[1] ?? "");
|
|
473110
|
+
const tool = record5.kind === "github_pull_request" ? "WatchPR" : "Monitor";
|
|
473111
|
+
print(`Run this tool call in the original conversation's running harness:
|
|
473112
|
+
${tool}(${JSON.stringify({ resume: record5.monitor_id })})`);
|
|
473113
|
+
return 0;
|
|
473114
|
+
}
|
|
473115
|
+
if (positionals[0] !== "list" || positionals.length !== 1)
|
|
473116
|
+
throw new Error(HELP);
|
|
473117
|
+
const scope = { status: values4.status };
|
|
473118
|
+
if (values4.agent)
|
|
473119
|
+
scope.agent_id = values4.agent;
|
|
473120
|
+
else {
|
|
473121
|
+
scope.conversation_id = process.env.CONVERSATION_ID || process.env.LETTA_CONVERSATION_ID;
|
|
473122
|
+
if (!scope.conversation_id)
|
|
473123
|
+
throw new Error("Set CONVERSATION_ID or pass --agent <id>.");
|
|
473124
|
+
if (scope.conversation_id === "default") {
|
|
473125
|
+
scope.agent_id = process.env.LETTA_AGENT_ID || process.env.AGENT_ID;
|
|
473126
|
+
if (!scope.agent_id)
|
|
473127
|
+
throw new Error("The default conversation also requires LETTA_AGENT_ID or AGENT_ID.");
|
|
473128
|
+
}
|
|
473129
|
+
}
|
|
473130
|
+
const list = deps.list ?? listMonitorStates;
|
|
473131
|
+
const records2 = [];
|
|
473132
|
+
for (;; ) {
|
|
473133
|
+
const page = await list(scope);
|
|
473134
|
+
records2.push(...page);
|
|
473135
|
+
if (page.length < 200)
|
|
473136
|
+
break;
|
|
473137
|
+
scope.after = page.at(-1)?.monitor_id;
|
|
473138
|
+
}
|
|
473139
|
+
if (values4.json)
|
|
473140
|
+
print(JSON.stringify(records2, null, 2));
|
|
473141
|
+
else {
|
|
473142
|
+
const clean = (value) => Array.from(value ?? "-", (char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127 ? " " : char).join("");
|
|
473143
|
+
print([
|
|
473144
|
+
"ID\tKIND\tDESCRIPTION\tSTATUS\tSTARTED\tEXPIRES\tCOMMAND / PR",
|
|
473145
|
+
...records2.map((row) => [
|
|
473146
|
+
row.monitor_id,
|
|
473147
|
+
row.kind,
|
|
473148
|
+
row.description,
|
|
473149
|
+
row.status,
|
|
473150
|
+
row.started_at,
|
|
473151
|
+
row.expires_at,
|
|
473152
|
+
row.command
|
|
473153
|
+
].map(clean).join("\t"))
|
|
473154
|
+
].join(`
|
|
473155
|
+
`));
|
|
473156
|
+
}
|
|
473157
|
+
return 0;
|
|
473158
|
+
} catch (error4) {
|
|
473159
|
+
console.error(error4 instanceof Error ? error4.message : String(error4));
|
|
473160
|
+
return 1;
|
|
473161
|
+
}
|
|
473162
|
+
}
|
|
473163
|
+
var HELP = `Usage:
|
|
473164
|
+
letta monitors list [--agent <id>] [--status <s>] [--json]
|
|
473165
|
+
letta monitors resume <id>
|
|
473166
|
+
|
|
473167
|
+
List defaults to $CONVERSATION_ID / $LETTA_CONVERSATION_ID; --agent lists agent-wide records.
|
|
473168
|
+
Resume prints the exact tool call to run in the owning conversation's live harness.
|
|
473169
|
+
-h, --help Show this help`;
|
|
473170
|
+
var init_monitors3 = __esm(() => {
|
|
473171
|
+
init_monitors();
|
|
473172
|
+
init_settings_manager();
|
|
473173
|
+
init_monitor_resume();
|
|
473174
|
+
});
|
|
473175
|
+
|
|
473176
|
+
// src/cli/subcommands/permissions.ts
|
|
473177
|
+
import { parseArgs as parseArgs17 } from "node:util";
|
|
472741
473178
|
function printUsage12() {
|
|
472742
473179
|
console.log(`Usage:
|
|
472743
473180
|
letta permissions [--agent <id>]
|
|
@@ -472813,7 +473250,7 @@ async function buildPermissionsReport(agentId, request4 = apiRequest, actingUser
|
|
|
472813
473250
|
async function runPermissionsSubcommand(argv, deps = {}) {
|
|
472814
473251
|
let values4;
|
|
472815
473252
|
try {
|
|
472816
|
-
({ values: values4 } =
|
|
473253
|
+
({ values: values4 } = parseArgs17({
|
|
472817
473254
|
args: argv,
|
|
472818
473255
|
options: {
|
|
472819
473256
|
agent: { type: "string" },
|
|
@@ -472936,7 +473373,7 @@ var init_sandbox_files = __esm(() => {
|
|
|
472936
473373
|
// src/cli/subcommands/sandbox.ts
|
|
472937
473374
|
import { readFile as readFile29, stat as stat15, writeFile as writeFile19 } from "node:fs/promises";
|
|
472938
473375
|
import { basename as basename30, resolve as resolve40 } from "node:path";
|
|
472939
|
-
import { parseArgs as
|
|
473376
|
+
import { parseArgs as parseArgs18 } from "node:util";
|
|
472940
473377
|
function printUsage13() {
|
|
472941
473378
|
console.log(`
|
|
472942
473379
|
Usage:
|
|
@@ -472974,7 +473411,7 @@ Notes:
|
|
|
472974
473411
|
`.trim());
|
|
472975
473412
|
}
|
|
472976
473413
|
function parseSandboxArgs(argv) {
|
|
472977
|
-
return
|
|
473414
|
+
return parseArgs18({
|
|
472978
473415
|
args: argv,
|
|
472979
473416
|
options: SANDBOX_OPTIONS,
|
|
472980
473417
|
strict: true,
|
|
@@ -473205,7 +473642,7 @@ var init_sandbox2 = __esm(() => {
|
|
|
473205
473642
|
});
|
|
473206
473643
|
|
|
473207
473644
|
// src/cli/subcommands/secret.ts
|
|
473208
|
-
import { parseArgs as
|
|
473645
|
+
import { parseArgs as parseArgs19 } from "node:util";
|
|
473209
473646
|
function printUsage14() {
|
|
473210
473647
|
console.log(`
|
|
473211
473648
|
Usage:
|
|
@@ -473231,7 +473668,7 @@ Notes:
|
|
|
473231
473668
|
`.trim());
|
|
473232
473669
|
}
|
|
473233
473670
|
function parseSecretArgs(argv) {
|
|
473234
|
-
return
|
|
473671
|
+
return parseArgs19({
|
|
473235
473672
|
args: argv,
|
|
473236
473673
|
options: SECRET_OPTIONS,
|
|
473237
473674
|
strict: true,
|
|
@@ -474004,7 +474441,7 @@ var init_setup7 = __esm(async () => {
|
|
|
474004
474441
|
// src/cli/subcommands/shared-memory.ts
|
|
474005
474442
|
import { existsSync as existsSync71 } from "node:fs";
|
|
474006
474443
|
import { join as join107 } from "node:path";
|
|
474007
|
-
import { parseArgs as
|
|
474444
|
+
import { parseArgs as parseArgs20 } from "node:util";
|
|
474008
474445
|
function printUsage16() {
|
|
474009
474446
|
console.log(`
|
|
474010
474447
|
Usage:
|
|
@@ -474040,7 +474477,7 @@ Examples:
|
|
|
474040
474477
|
`.trim());
|
|
474041
474478
|
}
|
|
474042
474479
|
function parseSharedMemoryArgs(argv) {
|
|
474043
|
-
return
|
|
474480
|
+
return parseArgs20({
|
|
474044
474481
|
args: argv,
|
|
474045
474482
|
options: SHARED_MEMORY_OPTIONS,
|
|
474046
474483
|
strict: true,
|
|
@@ -475803,7 +476240,7 @@ import {
|
|
|
475803
476240
|
import { mkdir as mkdir16, readdir as readdir13 } from "node:fs/promises";
|
|
475804
476241
|
import { tmpdir as tmpdir15 } from "node:os";
|
|
475805
476242
|
import { basename as basename31, dirname as dirname42, join as join108, normalize as normalize5, resolve as resolve41, sep as sep9 } from "node:path";
|
|
475806
|
-
import { parseArgs as
|
|
476243
|
+
import { parseArgs as parseArgs21, TextDecoder as TextDecoder2, TextEncoder as TextEncoder2 } from "node:util";
|
|
475807
476244
|
function printUsage17() {
|
|
475808
476245
|
console.log(`
|
|
475809
476246
|
Usage:
|
|
@@ -475831,7 +476268,7 @@ Options:
|
|
|
475831
476268
|
`.trim());
|
|
475832
476269
|
}
|
|
475833
476270
|
function parseSkillsArgs(argv) {
|
|
475834
|
-
return
|
|
476271
|
+
return parseArgs21({
|
|
475835
476272
|
args: argv,
|
|
475836
476273
|
options: SKILLS_OPTIONS,
|
|
475837
476274
|
strict: true,
|
|
@@ -476662,10 +477099,10 @@ var init_skills6 = __esm(() => {
|
|
|
476662
477099
|
});
|
|
476663
477100
|
|
|
476664
477101
|
// src/cli/subcommands/steps.ts
|
|
476665
|
-
import { parseArgs as
|
|
477102
|
+
import { parseArgs as parseArgs22 } from "node:util";
|
|
476666
477103
|
async function runStepsSubcommand(argv, deps = {}) {
|
|
476667
477104
|
try {
|
|
476668
|
-
const { positionals, values: values4 } =
|
|
477105
|
+
const { positionals, values: values4 } = parseArgs22({
|
|
476669
477106
|
args: argv,
|
|
476670
477107
|
options: {
|
|
476671
477108
|
help: { type: "boolean", short: "h" },
|
|
@@ -476715,7 +477152,7 @@ var init_steps4 = __esm(() => {
|
|
|
476715
477152
|
});
|
|
476716
477153
|
|
|
476717
477154
|
// src/cli/subcommands/teleport.ts
|
|
476718
|
-
import { parseArgs as
|
|
477155
|
+
import { parseArgs as parseArgs23 } from "node:util";
|
|
476719
477156
|
function printUsage18() {
|
|
476720
477157
|
console.log(`
|
|
476721
477158
|
Usage:
|
|
@@ -476739,7 +477176,7 @@ Notes:
|
|
|
476739
477176
|
`.trim());
|
|
476740
477177
|
}
|
|
476741
477178
|
function parseTeleportArgs(argv) {
|
|
476742
|
-
return
|
|
477179
|
+
return parseArgs23({
|
|
476743
477180
|
args: argv,
|
|
476744
477181
|
options: TELEPORT_OPTIONS,
|
|
476745
477182
|
strict: true,
|
|
@@ -477257,7 +477694,7 @@ var init_review = () => {};
|
|
|
477257
477694
|
|
|
477258
477695
|
// src/cli/subcommands/trajectories.ts
|
|
477259
477696
|
import { readFile as readFile33 } from "node:fs/promises";
|
|
477260
|
-
import { parseArgs as
|
|
477697
|
+
import { parseArgs as parseArgs24 } from "node:util";
|
|
477261
477698
|
function printUsage19() {
|
|
477262
477699
|
console.log(`
|
|
477263
477700
|
Usage:
|
|
@@ -477396,7 +477833,7 @@ ${results.length} session(s) matched "${keyword}"`);
|
|
|
477396
477833
|
return 0;
|
|
477397
477834
|
}
|
|
477398
477835
|
function parseTrajectoriesArgs(argv) {
|
|
477399
|
-
return
|
|
477836
|
+
return parseArgs24({
|
|
477400
477837
|
args: argv,
|
|
477401
477838
|
options: TRAJECTORIES_OPTIONS,
|
|
477402
477839
|
strict: true,
|
|
@@ -477519,10 +477956,10 @@ var init_trajectories = __esm(() => {
|
|
|
477519
477956
|
});
|
|
477520
477957
|
|
|
477521
477958
|
// src/cli/subcommands/usage.ts
|
|
477522
|
-
import { parseArgs as
|
|
477959
|
+
import { parseArgs as parseArgs25 } from "node:util";
|
|
477523
477960
|
async function runUsageSubcommand(argv) {
|
|
477524
477961
|
try {
|
|
477525
|
-
const { values: values4 } =
|
|
477962
|
+
const { values: values4 } = parseArgs25({
|
|
477526
477963
|
args: argv,
|
|
477527
477964
|
options: { help: { type: "boolean", short: "h" } },
|
|
477528
477965
|
strict: true,
|
|
@@ -477580,7 +478017,7 @@ var init_usage3 = __esm(() => {
|
|
|
477580
478017
|
});
|
|
477581
478018
|
|
|
477582
478019
|
// src/cli/subcommands/variable.ts
|
|
477583
|
-
import { parseArgs as
|
|
478020
|
+
import { parseArgs as parseArgs26 } from "node:util";
|
|
477584
478021
|
function printUsage20() {
|
|
477585
478022
|
console.log(`
|
|
477586
478023
|
Usage:
|
|
@@ -477600,7 +478037,7 @@ Variables are plain values, visible to the agent and never redacted. Use secrets
|
|
|
477600
478037
|
`.trim());
|
|
477601
478038
|
}
|
|
477602
478039
|
function parseVariableArgs(argv) {
|
|
477603
|
-
return
|
|
478040
|
+
return parseArgs26({
|
|
477604
478041
|
args: argv,
|
|
477605
478042
|
options: SECRET_OPTIONS2,
|
|
477606
478043
|
strict: true,
|
|
@@ -482274,14 +482711,14 @@ var exports_channel_gateway = {};
|
|
|
482274
482711
|
__export(exports_channel_gateway, {
|
|
482275
482712
|
runChannelGatewaySubcommand: () => runChannelGatewaySubcommand
|
|
482276
482713
|
});
|
|
482277
|
-
import { parseArgs as
|
|
482714
|
+
import { parseArgs as parseArgs27 } from "node:util";
|
|
482278
482715
|
function isGatewayCommandEnvelope(value) {
|
|
482279
482716
|
return Boolean(value && typeof value === "object" && "type" in value && value.type === "command" && "requestId" in value && typeof value.requestId === "string" && "command" in value && value.command && typeof value.command === "object");
|
|
482280
482717
|
}
|
|
482281
482718
|
async function runChannelGatewaySubcommand(argv) {
|
|
482282
482719
|
let values4;
|
|
482283
482720
|
try {
|
|
482284
|
-
({ values: values4 } =
|
|
482721
|
+
({ values: values4 } = parseArgs27({
|
|
482285
482722
|
args: argv,
|
|
482286
482723
|
strict: true,
|
|
482287
482724
|
allowPositionals: false,
|
|
@@ -482424,6 +482861,7 @@ function subcommandNeedsEarlyBackendMode(command) {
|
|
|
482424
482861
|
case "permissions":
|
|
482425
482862
|
case "remote":
|
|
482426
482863
|
case "sandbox":
|
|
482864
|
+
case "monitors":
|
|
482427
482865
|
case "variable":
|
|
482428
482866
|
case "secret":
|
|
482429
482867
|
case "server":
|
|
@@ -482500,6 +482938,8 @@ async function runSubcommand(argv) {
|
|
|
482500
482938
|
return runSharedMemorySubcommand(rest2);
|
|
482501
482939
|
case "skills":
|
|
482502
482940
|
return runSkillsSubcommand(rest2);
|
|
482941
|
+
case "monitors":
|
|
482942
|
+
return runMonitorsSubcommand(rest2);
|
|
482503
482943
|
case "cron":
|
|
482504
482944
|
return runCronSubcommand(rest2);
|
|
482505
482945
|
case "channels":
|
|
@@ -482531,6 +482971,7 @@ var init_router = __esm(async () => {
|
|
|
482531
482971
|
init_messages10();
|
|
482532
482972
|
init_model2();
|
|
482533
482973
|
init_mods();
|
|
482974
|
+
init_monitors3();
|
|
482534
482975
|
init_permissions2();
|
|
482535
482976
|
init_sandbox2();
|
|
482536
482977
|
init_secret();
|
|
@@ -482814,6 +483255,15 @@ function createStartupBackend(backend3, usesRemoteComputer, actingUserId = resol
|
|
|
482814
483255
|
}
|
|
482815
483256
|
var init_headless_startup_backend = () => {};
|
|
482816
483257
|
|
|
483258
|
+
// src/queue/queued-message-line.ts
|
|
483259
|
+
function serializeQueuedMessageAsUserLine(message2) {
|
|
483260
|
+
return JSON.stringify({
|
|
483261
|
+
type: "user",
|
|
483262
|
+
message: { role: "user", content: message2.content ?? message2.text },
|
|
483263
|
+
_queuedKind: message2.kind
|
|
483264
|
+
});
|
|
483265
|
+
}
|
|
483266
|
+
|
|
482817
483267
|
// src/utils/headless-stdout-guard.ts
|
|
482818
483268
|
function installHeadlessStdoutGuard() {
|
|
482819
483269
|
process.stdout.on("error", (err) => {
|
|
@@ -484002,7 +484452,8 @@ function toBidirectionalQueuedInput(content, queuedKind) {
|
|
|
484002
484452
|
if (queuedKind === "task_notification") {
|
|
484003
484453
|
return {
|
|
484004
484454
|
kind: "task_notification",
|
|
484005
|
-
text: contentToTaskNotificationText(content)
|
|
484455
|
+
text: contentToTaskNotificationText(content),
|
|
484456
|
+
content
|
|
484006
484457
|
};
|
|
484007
484458
|
}
|
|
484008
484459
|
return {
|
|
@@ -486087,7 +486538,8 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
486087
486538
|
msgQueueRuntime.enqueue({
|
|
486088
486539
|
kind: "task_notification",
|
|
486089
486540
|
source: "task_notification",
|
|
486090
|
-
text: input.text
|
|
486541
|
+
text: input.text,
|
|
486542
|
+
content: input.content
|
|
486091
486543
|
});
|
|
486092
486544
|
} else if (input.kind === "cron_prompt") {
|
|
486093
486545
|
msgQueueRuntime.enqueue({
|
|
@@ -486103,14 +486555,6 @@ async function runBidirectionalMode(agent, conversationId, effectiveModel, _outp
|
|
|
486103
486555
|
});
|
|
486104
486556
|
}
|
|
486105
486557
|
}
|
|
486106
|
-
const serializeQueuedMessageAsUserLine = (queuedMessage) => JSON.stringify({
|
|
486107
|
-
type: "user",
|
|
486108
|
-
message: {
|
|
486109
|
-
role: "user",
|
|
486110
|
-
content: queuedMessage.text
|
|
486111
|
-
},
|
|
486112
|
-
_queuedKind: queuedMessage.kind
|
|
486113
|
-
});
|
|
486114
486558
|
setMessageQueueAdder((queuedMessage) => {
|
|
486115
486559
|
const syntheticUserLine = serializeQueuedMessageAsUserLine(queuedMessage);
|
|
486116
486560
|
maybeNotifyBlocked(syntheticUserLine);
|
|
@@ -513213,7 +513657,7 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
513213
513657
|
let shellSemanticKind = null;
|
|
513214
513658
|
let hasShellDescription = false;
|
|
513215
513659
|
if (!isQuestionTool(rawName)) {
|
|
513216
|
-
const
|
|
513660
|
+
const parseArgs28 = () => {
|
|
513217
513661
|
if (!argsText.trim()) {
|
|
513218
513662
|
return { formatted: null, parseable: true };
|
|
513219
513663
|
}
|
|
@@ -513227,7 +513671,7 @@ var init_ToolCallMessageRich = __esm(async () => {
|
|
|
513227
513671
|
return { formatted: null, parseable: false };
|
|
513228
513672
|
}
|
|
513229
513673
|
};
|
|
513230
|
-
const { formatted, parseable } =
|
|
513674
|
+
const { formatted, parseable } = parseArgs28();
|
|
513231
513675
|
const argsComplete = parseable || line.phase === "running" || line.phase === "finished" || !isStreaming;
|
|
513232
513676
|
if (!argsComplete) {
|
|
513233
513677
|
args = "(…)";
|
|
@@ -515361,7 +515805,7 @@ function updateCommandResult(buffersRef, refreshDerived, cmdId, input, output, s
|
|
|
515361
515805
|
buffersRef.current.byId.set(cmdId, line);
|
|
515362
515806
|
refreshDerived();
|
|
515363
515807
|
}
|
|
515364
|
-
function
|
|
515808
|
+
function parseArgs28(msg) {
|
|
515365
515809
|
return msg.trim().split(/\s+/).filter(Boolean);
|
|
515366
515810
|
}
|
|
515367
515811
|
function formatConnectUsage() {
|
|
@@ -515746,7 +516190,7 @@ ${formatBedrockUsage2()}`, false);
|
|
|
515746
516190
|
}
|
|
515747
516191
|
}
|
|
515748
516192
|
async function handleConnect(ctx, msg) {
|
|
515749
|
-
const parts =
|
|
516193
|
+
const parts = parseArgs28(msg);
|
|
515750
516194
|
const providerToken = parts[1];
|
|
515751
516195
|
if (!providerToken) {
|
|
515752
516196
|
addCommandResult(ctx.buffersRef, ctx.refreshDerived, msg, formatConnectUsage(), false);
|
|
@@ -533412,6 +533856,7 @@ Note: Flags should use double dashes for full names (e.g., --yolo, not -yolo)`);
|
|
|
533412
533856
|
});
|
|
533413
533857
|
const requestedMemoryPromptMode = memfsFlag ? "memfs" : undefined;
|
|
533414
533858
|
const shouldAutoEnableMemfsForNewAgent = !memfsFlag;
|
|
533859
|
+
process.env.LETTA_RUNTIME_SESSION_SOURCE = isHeadless ? "headless" : "interactive-cli";
|
|
533415
533860
|
telemetry.setSurface(getTerminalTelemetrySurface(isHeadless));
|
|
533416
533861
|
telemetry.init({ handleSigint: !isHeadless });
|
|
533417
533862
|
if (!isHeadless) {
|
|
@@ -536884,4 +537329,4 @@ function registerBunOAuthFlows() {
|
|
|
536884
537329
|
registerBunOAuthFlows();
|
|
536885
537330
|
await init_src5().then(() => exports_src2);
|
|
536886
537331
|
|
|
536887
|
-
//# debugId=
|
|
537332
|
+
//# debugId=17512937B3B5F6D064756E2164756E21
|