@letta-ai/letta-code 0.34.57 → 0.34.59
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/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/memory-filesystem.d.ts +2 -0
- package/dist/types/agent/memory-filesystem.d.ts.map +1 -1
- package/dist/types/agent/memory-runtime.d.ts.map +1 -1
- package/dist/types/backend/api/monitors.d.ts +17 -0
- package/dist/types/backend/api/monitors.d.ts.map +1 -0
- package/dist/types/experiments/manager.d.ts.map +1 -1
- package/dist/types/experiments/types.d.ts +1 -1
- package/dist/types/experiments/types.d.ts.map +1 -1
- package/dist/types/tools/impl/github-pull-request-cloud.d.ts +3 -0
- package/dist/types/tools/impl/github-pull-request-cloud.d.ts.map +1 -1
- package/dist/types/tools/impl/github-pull-request-diff.d.ts +2 -1
- package/dist/types/tools/impl/github-pull-request-diff.d.ts.map +1 -1
- package/dist/types/tools/impl/github-pull-request-types.d.ts +14 -0
- package/dist/types/tools/impl/github-pull-request-types.d.ts.map +1 -1
- package/dist/types/tools/impl/github-workflow-run.d.ts +23 -0
- package/dist/types/tools/impl/github-workflow-run.d.ts.map +1 -0
- package/dist/types/tools/impl/kill-bash.d.ts.map +1 -1
- package/dist/types/tools/impl/memory.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-result.d.ts +10 -0
- package/dist/types/tools/impl/monitor-result.d.ts.map +1 -0
- package/dist/types/tools/impl/monitor-script.d.ts +1 -0
- package/dist/types/tools/impl/monitor-script.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor-state.d.ts +16 -0
- package/dist/types/tools/impl/monitor-state.d.ts.map +1 -0
- package/dist/types/tools/impl/monitor-url-cloud.d.ts +0 -1
- package/dist/types/tools/impl/monitor-url-cloud.d.ts.map +1 -1
- package/dist/types/tools/impl/monitor.d.ts +1 -0
- package/dist/types/tools/impl/monitor.d.ts.map +1 -1
- package/dist/types/tools/impl/process_manager.d.ts +2 -0
- package/dist/types/tools/impl/process_manager.d.ts.map +1 -1
- package/dist/types/tools/impl/remote-external-coding-agent.d.ts.map +1 -1
- package/dist/types/tools/impl/task-stop.d.ts.map +1 -1
- package/dist/types/tools/impl/watch-pr.d.ts +2 -0
- package/dist/types/tools/impl/watch-pr.d.ts.map +1 -1
- package/dist/types/tools/task-tool-assets.d.ts +2 -2
- package/dist/types/tools/task-tool-assets.d.ts.map +1 -1
- package/dist/types/tools/toolset.d.ts +2 -0
- package/dist/types/tools/toolset.d.ts.map +1 -1
- package/dist/types/types/protocol_v2.d.ts +1 -1
- package/dist/types/types/protocol_v2.d.ts.map +1 -1
- package/dist/types/utils/memory-access.d.ts +4 -0
- package/dist/types/utils/memory-access.d.ts.map +1 -0
- package/letta.js +982 -423
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -6135,7 +6135,7 @@ var package_default;
|
|
|
6135
6135
|
var init_package = __esm(() => {
|
|
6136
6136
|
package_default = {
|
|
6137
6137
|
name: "@letta-ai/letta-code",
|
|
6138
|
-
version: "0.34.
|
|
6138
|
+
version: "0.34.59",
|
|
6139
6139
|
lettaStartupLogProtocol: 1,
|
|
6140
6140
|
lettaConfigDirProtocol: 1,
|
|
6141
6141
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
@@ -100022,7 +100022,9 @@ async function applyMemfsFlags(agentId, memfsFlag, options) {
|
|
|
100022
100022
|
if (!isGitRepo2(agentId)) {
|
|
100023
100023
|
await cloneMemoryRepo2(agentId);
|
|
100024
100024
|
} else if (options?.pullOnExistingRepo) {
|
|
100025
|
-
const result = await pullMemory2(agentId
|
|
100025
|
+
const result = await pullMemory2(agentId, {
|
|
100026
|
+
throwOnFailure: options?.throwOnPullFailure
|
|
100027
|
+
});
|
|
100026
100028
|
pullSummary = result.summary;
|
|
100027
100029
|
} else {
|
|
100028
100030
|
installMemoryGitHooks(getScopedMemoryFilesystemRoot(agentId));
|
|
@@ -203260,7 +203262,7 @@ var init_mcp_client = __esm(() => {
|
|
|
203260
203262
|
init_streamableHttp();
|
|
203261
203263
|
DEFAULT_CLIENT_INFO = {
|
|
203262
203264
|
name: "letta-code",
|
|
203263
|
-
version: "0.34.
|
|
203265
|
+
version: "0.34.59"
|
|
203264
203266
|
};
|
|
203265
203267
|
});
|
|
203266
203268
|
|
|
@@ -207511,7 +207513,7 @@ Do not use this tool for root memory files (already loaded) or skills/ (use Skil
|
|
|
207511
207513
|
var init_Memory = () => {};
|
|
207512
207514
|
|
|
207513
207515
|
// src/tools/descriptions/Monitor.md
|
|
207514
|
-
var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: indefinitely ("every time an ERROR line appears": `tail -f`, `inotifywait -m`, `while true`), or until a known end ("each CI step result, stop when the run completes": a command that emits lines and then exits). For a single notification ("tell me when the server is ready"), run a command that exits when the condition is true, e.g. `until grep -q "Ready" dev.log; do sleep 0.5; done`, in the background with your shell tool; you get one completion notification. An unbounded command used for a single notification stays armed until timeout, and `tail -f log | grep -m 1 ...` can hang the same way.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Every pipe stage must flush per line or matches sit in its buffer unseen: `grep` needs `--line-buffered`, `awk` needs `fflush()`. `| head -N` delivers nothing until N matches accumulate.\n- In poll loops, handle transient failures (`curl ... || true`). Poll remote APIs every 30s+, local checks every 0.5–1s.\n- Only stdout is the event stream. Stderr goes to the output file named in the result, without notifications; merge it with `2>&1` for commands you run directly so failures reach your filter.\n- Every stdout line is a conversation message, so filter to the lines you\'d act on. Lines within 200ms are batched into one notification. Monitors that produce too many events are stopped automatically; restart with a tighter filter.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that greps only for the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `grep -E --line-buffered "elapsed_steps=|Traceback|Error|FAILED|Killed|OOM"`, and in poll loops emit on every terminal status (`succeeded|failed|cancelled|timeout`).\n\nExit ends the watch (exit code is reported). Timeout → killed. Set `persistent: true` for session-length watches (log tails, long-lived event streams). In managed Cloud sandboxes, every monitor, including persistent ones, stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox\'s monitor cap); elsewhere persistent monitors run until TaskStop or session end. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, set `backup_after_seconds` (e.g. 900). If the monitor goes that long without an event, a durable Wake brings you back to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nInstead of `command`, `ws` streams each WebSocket text frame as an event (prefer it over `websocat`), and `script` runs a JavaScript watch loop with CodeMode\'s globals plus `emit(text)` and `sleep(ms)`; `decide()` spends money on every call, so call it only when an observed change needs judgment.\n
|
|
207516
|
+
var Monitor_default = 'Start a background monitor that streams events from a long-running script. Each stdout line is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: indefinitely ("every time an ERROR line appears": `tail -f`, `inotifywait -m`, `while true`), or until a known end ("each CI step result, stop when the run completes": a command that emits lines and then exits). For a single notification ("tell me when the server is ready"), run a command that exits when the condition is true, e.g. `until grep -q "Ready" dev.log; do sleep 0.5; done`, in the background with your shell tool; you get one completion notification. An unbounded command used for a single notification stays armed until timeout, and `tail -f log | grep -m 1 ...` can hang the same way.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Every pipe stage must flush per line or matches sit in its buffer unseen: `grep` needs `--line-buffered`, `awk` needs `fflush()`. `| head -N` delivers nothing until N matches accumulate.\n- In poll loops, handle transient failures (`curl ... || true`). Poll remote APIs every 30s+, local checks every 0.5–1s.\n- Only stdout is the event stream. Stderr goes to the output file named in the result, without notifications; merge it with `2>&1` for commands you run directly so failures reach your filter.\n- Every stdout line is a conversation message, so filter to the lines you\'d act on. Lines within 200ms are batched into one notification. Monitors that produce too many events are stopped automatically; restart with a tighter filter.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that greps only for the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `grep -E --line-buffered "elapsed_steps=|Traceback|Error|FAILED|Killed|OOM"`, and in poll loops emit on every terminal status (`succeeded|failed|cancelled|timeout`).\n\nExit ends the watch (exit code is reported). Timeout → killed. Set `persistent: true` for session-length watches (log tails, long-lived event streams). In managed Cloud sandboxes, every monitor, including persistent ones, stops after {{MONITOR_MAX_TIMEOUT}} (this sandbox\'s monitor cap); elsewhere persistent monitors run until TaskStop or session end. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, set `backup_after_seconds` (e.g. 900). If the monitor goes that long without an event, a durable Wake brings you back to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nInstead of `command`, `ws` streams each WebSocket text frame as an event (prefer it over `websocat`), and `script` runs a JavaScript watch loop with CodeMode\'s globals plus `emit(text)` and `sleep(ms)`; `decide()` spends money on every call, so call it only when an observed change needs judgment.\n';
|
|
207515
207517
|
var init_Monitor = () => {};
|
|
207516
207518
|
|
|
207517
207519
|
// src/tools/descriptions/Read.md
|
|
@@ -207647,6 +207649,8 @@ Use WatchPR instead of writing a Monitor or shell polling loop when you need ong
|
|
|
207647
207649
|
The initial result includes current blockers and changes since the previous watch ended for the same agent, conversation, and PR, when a locally saved snapshot is at most seven days old. The first snapshot is never merge-ready: readiness requires a second consecutive read on the same head, so \`awaiting a second same-head readiness read\` is expected at startup. Later changes arrive as task notifications in this conversation. It uses the locally authenticated \`gh\` CLI and keeps watching after checks become green because reviews, comments, conflicts, and new pushes can still arrive. Green checks are not the same as a mergeable PR, so report the PR as ready, green, or mergeable only once the watcher reports it merge-ready.
|
|
207648
207650
|
|
|
207649
207651
|
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.
|
|
207652
|
+
|
|
207653
|
+
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.
|
|
207650
207654
|
`;
|
|
207651
207655
|
var init_WatchPR = () => {};
|
|
207652
207656
|
|
|
@@ -208436,6 +208440,12 @@ var init_manager = __esm(() => {
|
|
|
208436
208440
|
init_settings_manager();
|
|
208437
208441
|
ENABLED_TOGGLE_VALUES = new Set(["1", "true", "yes"]);
|
|
208438
208442
|
EXPERIMENT_DEFINITIONS = [
|
|
208443
|
+
{
|
|
208444
|
+
id: "cloud_monitors",
|
|
208445
|
+
label: "Cloud monitors",
|
|
208446
|
+
description: "Use Cloud URL monitors instead of local command, WebSocket, and script monitors.",
|
|
208447
|
+
envVar: "LETTA_CLOUD_MONITORS"
|
|
208448
|
+
},
|
|
208439
208449
|
{
|
|
208440
208450
|
id: "artifacts",
|
|
208441
208451
|
label: "artifacts",
|
|
@@ -216961,6 +216971,84 @@ var init_subagent_tool_policy = __esm(() => {
|
|
|
216961
216971
|
init_subagent_depth();
|
|
216962
216972
|
});
|
|
216963
216973
|
|
|
216974
|
+
// src/tools/descriptions/MonitorCloud.md
|
|
216975
|
+
var MonitorCloud_default = 'Start a background monitor that streams events from a public http(s) URL. Each change to the HTTP status or body is an event — you keep working and notifications arrive in the chat. Events arrive on their own schedule and are not replies from the user, even if one lands while you\'re waiting for the user to answer a question.\n\nUse Monitor when you need one notification per occurrence: until the timeout ("every time the status changes"), or until a known end ("each CI step result, stop when the run completes": use `match` with `stop_on_match: true`). For a single notification ("tell me when the server is ready"), use `match` with `stop_on_match: true`.\n\nFor open github.com pull requests, use WatchPR instead. It covers the whole PR surface and keeps watching after CI finishes. Use Monitor only when WatchPR does not apply.\n\n- Cloud polls the URL with GET every 60s by default. Set `interval_seconds` to 60 or more. The first response is the baseline; by default, it notifies only when the HTTP status or body changes.\n- Use `select` to compare one JSON field instead of the whole body, and `match` to be notified when it reaches a value, with `stop_on_match` to finish after that. The first response is checked against `match` too, so a pipeline that already finished notifies right away. A value that keeps matching does not notify again.\n- Every event is a conversation message, so filter to the events you\'d act on.\n\n**Coverage — silence is not success.** When watching a job for an outcome, your filter must match every terminal state, not just the happy path. A monitor that matches only the success marker stays silent through a crashloop, a hung process, or an unexpected exit — and silence looks identical to "still running." Match failures too, e.g. `select: "0.status"`, `match: {"equals": ["success", "failed", "canceled"]}`, `stop_on_match: true`.\n\nA match ends the watch when `stop_on_match` is true. Timeout → killed. Set `timeout_ms` for longer watches; the default is 24 hours and the maximum is 7 days. Call Monitor again to re-arm it if you still need to watch. For much longer Cloud waits, schedule a Wake or cron (which does not keep the sandbox running between turns) and combine it with shorter monitors. Use TaskStop to cancel early.\n\nWhen someone is waiting on the result, schedule a Wake or cron to check the real state, so a queued, hung, or dead watch can\'t leave them waiting in silence.\n\nFor an authenticated API, pass `headers` that reference agent secrets as `$NAME`, the same as in shell commands: `{"PRIVATE-TOKEN": "$GITLAB_TOKEN"}`. Cloud fills them in on every poll, so the token is never written into the monitor.\n';
|
|
216976
|
+
var init_MonitorCloud = () => {};
|
|
216977
|
+
|
|
216978
|
+
// src/tools/schemas/MonitorCloud.json
|
|
216979
|
+
var MonitorCloud_default2;
|
|
216980
|
+
var init_MonitorCloud2 = __esm(() => {
|
|
216981
|
+
MonitorCloud_default2 = {
|
|
216982
|
+
type: "object",
|
|
216983
|
+
properties: {
|
|
216984
|
+
description: {
|
|
216985
|
+
type: "string",
|
|
216986
|
+
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`."
|
|
216987
|
+
},
|
|
216988
|
+
timeout_ms: {
|
|
216989
|
+
type: "integer",
|
|
216990
|
+
minimum: 1000,
|
|
216991
|
+
default: 86400000,
|
|
216992
|
+
description: "Kill the monitor after this deadline. Default 86400000ms. Maximum 7 days."
|
|
216993
|
+
},
|
|
216994
|
+
url: {
|
|
216995
|
+
type: "string",
|
|
216996
|
+
description: "Public http(s) URL to poll with GET. By default it notifies only when the HTTP status or body changes; use select and match to narrow that. timeout_ms defaults to 24 hours here, up to 7 days."
|
|
216997
|
+
},
|
|
216998
|
+
interval_seconds: {
|
|
216999
|
+
type: "integer",
|
|
217000
|
+
minimum: 60,
|
|
217001
|
+
default: 60,
|
|
217002
|
+
description: "Seconds between polls of url."
|
|
217003
|
+
},
|
|
217004
|
+
headers: {
|
|
217005
|
+
type: "object",
|
|
217006
|
+
additionalProperties: {
|
|
217007
|
+
type: "string"
|
|
217008
|
+
},
|
|
217009
|
+
description: `Request headers for url, at most 10. Reference agent secrets as $NAME, as in shell commands, e.g. {"PRIVATE-TOKEN": "$GITLAB_TOKEN"} or {"Authorization": "Bearer $CI_TOKEN"}. Cloud fills them in on every poll; the value is never sent from here. Credential headers must use a secret reference. Headers are dropped if a redirect leaves the URL's origin.`
|
|
217010
|
+
},
|
|
217011
|
+
select: {
|
|
217012
|
+
type: "string",
|
|
217013
|
+
description: "For url: a dot-separated path into the JSON response (numbers index arrays), e.g. 0.status. Only that value is compared and reported, so unrelated fields changing does not notify."
|
|
217014
|
+
},
|
|
217015
|
+
match: {
|
|
217016
|
+
type: "object",
|
|
217017
|
+
properties: {
|
|
217018
|
+
equals: {
|
|
217019
|
+
type: "array",
|
|
217020
|
+
items: {
|
|
217021
|
+
type: "string"
|
|
217022
|
+
},
|
|
217023
|
+
description: "Matches when the value is one of these."
|
|
217024
|
+
},
|
|
217025
|
+
contains: {
|
|
217026
|
+
type: "string",
|
|
217027
|
+
description: "Matches when the value contains this text."
|
|
217028
|
+
},
|
|
217029
|
+
gt: {
|
|
217030
|
+
type: "number",
|
|
217031
|
+
description: "Matches when the value is a number greater than this."
|
|
217032
|
+
},
|
|
217033
|
+
lt: {
|
|
217034
|
+
type: "number",
|
|
217035
|
+
description: "Matches when the value is a number less than this."
|
|
217036
|
+
}
|
|
217037
|
+
},
|
|
217038
|
+
additionalProperties: false,
|
|
217039
|
+
description: 'For url: notify when the compared value starts to meet every given test, instead of on every change. The first response is checked too, and a value that keeps matching does not notify again. List every terminal state, e.g. equals ["success", "failed", "canceled"].'
|
|
217040
|
+
},
|
|
217041
|
+
stop_on_match: {
|
|
217042
|
+
type: "boolean",
|
|
217043
|
+
description: "For url with match: stop after the first match notice."
|
|
217044
|
+
}
|
|
217045
|
+
},
|
|
217046
|
+
required: ["description", "url"],
|
|
217047
|
+
additionalProperties: false,
|
|
217048
|
+
$schema: "http://json-schema.org/draft-07/schema#"
|
|
217049
|
+
};
|
|
217050
|
+
});
|
|
217051
|
+
|
|
216964
217052
|
// src/tools/task-tool-assets.ts
|
|
216965
217053
|
function stripComputerFromTaskSchema(schema) {
|
|
216966
217054
|
const properties = schema.properties;
|
|
@@ -216971,6 +217059,12 @@ function stripComputerFromTaskSchema(schema) {
|
|
|
216971
217059
|
return { ...schema, properties: rest2 };
|
|
216972
217060
|
}
|
|
216973
217061
|
async function resolveBackendSpecificToolAssets(name, description, inputSchema) {
|
|
217062
|
+
if (name === "Monitor" && experimentManager.isEnabled("cloud_monitors")) {
|
|
217063
|
+
return {
|
|
217064
|
+
description: MonitorCloud_default.trim(),
|
|
217065
|
+
inputSchema: MonitorCloud_default2
|
|
217066
|
+
};
|
|
217067
|
+
}
|
|
216974
217068
|
if (name !== "Task") {
|
|
216975
217069
|
return { description, inputSchema };
|
|
216976
217070
|
}
|
|
@@ -216990,6 +217084,9 @@ async function resolveBackendSpecificToolAssets(name, description, inputSchema)
|
|
|
216990
217084
|
}
|
|
216991
217085
|
var init_task_tool_assets = __esm(() => {
|
|
216992
217086
|
init_backend2();
|
|
217087
|
+
init_manager();
|
|
217088
|
+
init_MonitorCloud();
|
|
217089
|
+
init_MonitorCloud2();
|
|
216993
217090
|
});
|
|
216994
217091
|
|
|
216995
217092
|
// src/tools/tool-name-mapping.ts
|
|
@@ -217012,9 +217109,25 @@ var init_tool_name_mapping = __esm(() => {
|
|
|
217012
217109
|
};
|
|
217013
217110
|
});
|
|
217014
217111
|
|
|
217112
|
+
// src/utils/memory-access.ts
|
|
217113
|
+
function isMemoryUnavailable(agentId) {
|
|
217114
|
+
return unavailableAgents.has(agentId);
|
|
217115
|
+
}
|
|
217116
|
+
function markMemoryUnavailable(agentId) {
|
|
217117
|
+
unavailableAgents.add(agentId);
|
|
217118
|
+
}
|
|
217119
|
+
function isMemoryAccessRefusal(error4) {
|
|
217120
|
+
const message = error4 instanceof Error ? error4.message : String(error4);
|
|
217121
|
+
return /(?:returned error:|HTTP(?: status)?)[ :]*(?:401|403)\b|authentication failed|permission denied \(publickey\)/i.test(message);
|
|
217122
|
+
}
|
|
217123
|
+
var unavailableAgents;
|
|
217124
|
+
var init_memory_access = __esm(() => {
|
|
217125
|
+
unavailableAgents = new Set;
|
|
217126
|
+
});
|
|
217127
|
+
|
|
217015
217128
|
// src/agent/memory-runtime.ts
|
|
217016
217129
|
function isActiveMemfsEnabled(agentId) {
|
|
217017
|
-
return getBackend().capabilities.localMemfs || settingsManager.isMemfsEnabled(agentId);
|
|
217130
|
+
return !isMemoryUnavailable(agentId) && (getBackend().capabilities.localMemfs || settingsManager.isMemfsEnabled(agentId));
|
|
217018
217131
|
}
|
|
217019
217132
|
function getActiveMemoryDirectory(agentId) {
|
|
217020
217133
|
return isActiveMemfsEnabled(agentId) ? getScopedMemoryFilesystemRoot(agentId) : undefined;
|
|
@@ -217025,6 +217138,7 @@ function isLocalMemfsActive() {
|
|
|
217025
217138
|
var init_memory_runtime = __esm(() => {
|
|
217026
217139
|
init_backend2();
|
|
217027
217140
|
init_settings_manager();
|
|
217141
|
+
init_memory_access();
|
|
217028
217142
|
init_memory_filesystem2();
|
|
217029
217143
|
});
|
|
217030
217144
|
|
|
@@ -217254,6 +217368,10 @@ ${clampContent(content, fullPath, LIMITS.READ_OUTPUT_CHARS - open4.length - clos
|
|
|
217254
217368
|
${close}`;
|
|
217255
217369
|
}
|
|
217256
217370
|
async function memory(args) {
|
|
217371
|
+
const agentId = getCurrentAgentId();
|
|
217372
|
+
if (agentId && isMemoryUnavailable(agentId)) {
|
|
217373
|
+
return { content: "Memory is not available on this machine." };
|
|
217374
|
+
}
|
|
217257
217375
|
validateRequiredParams(args, ["path"], "Memory");
|
|
217258
217376
|
const memoryDir = resolveMemoryToolDirectory();
|
|
217259
217377
|
if (!memoryDir) {
|
|
@@ -217308,6 +217426,7 @@ var init_memory4 = __esm(() => {
|
|
|
217308
217426
|
init_context();
|
|
217309
217427
|
init_memory_format();
|
|
217310
217428
|
init_memory_runtime();
|
|
217429
|
+
init_memory_access();
|
|
217311
217430
|
init_truncation();
|
|
217312
217431
|
MAX_FILE_BYTES = 10 * 1024 * 1024;
|
|
217313
217432
|
});
|
|
@@ -234139,6 +234258,23 @@ var init_monitor_event_stream = __esm(() => {
|
|
|
234139
234258
|
MONITOR_EVENT_BUFFER_CHARS = 1024 * 1024;
|
|
234140
234259
|
});
|
|
234141
234260
|
|
|
234261
|
+
// src/tools/impl/monitor-result.ts
|
|
234262
|
+
function buildMonitorResult(taskId, timeoutMs, persistent, outputFile) {
|
|
234263
|
+
const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
|
|
234264
|
+
return {
|
|
234265
|
+
content: [
|
|
234266
|
+
{
|
|
234267
|
+
type: "text",
|
|
234268
|
+
text: `Monitor started (task ${taskId}, ${lifetime}). You will be notified on each event. Keep working — do not poll or sleep. Events may arrive while you are waiting for the user — an event is not their reply.${outputFile ? `
|
|
234269
|
+
Output file: ${outputFile}` : ""}`
|
|
234270
|
+
}
|
|
234271
|
+
],
|
|
234272
|
+
taskId,
|
|
234273
|
+
timeoutMs,
|
|
234274
|
+
persistent
|
|
234275
|
+
};
|
|
234276
|
+
}
|
|
234277
|
+
|
|
234142
234278
|
// src/tools/impl/monitor-script.ts
|
|
234143
234279
|
function createCallLimiter(signal) {
|
|
234144
234280
|
let tokens = TOOL_CALL_BURST;
|
|
@@ -234207,7 +234343,7 @@ async function startScriptMonitor(args, hooks) {
|
|
|
234207
234343
|
await releaseToolContext(toolContextId);
|
|
234208
234344
|
throw error4;
|
|
234209
234345
|
});
|
|
234210
|
-
const taskId = getNextMonitorId();
|
|
234346
|
+
const taskId = args.taskId ?? getNextMonitorId();
|
|
234211
234347
|
const outputFile = createBackgroundOutputFile(taskId);
|
|
234212
234348
|
const output = hooks.createOutput(outputFile);
|
|
234213
234349
|
const scope = resolveNotificationScope(args.parentScope);
|
|
@@ -234366,6 +234502,103 @@ var init_monitor_script = __esm(() => {
|
|
|
234366
234502
|
init_process_manager();
|
|
234367
234503
|
});
|
|
234368
234504
|
|
|
234505
|
+
// src/backend/api/monitors.ts
|
|
234506
|
+
function createMonitorState(input, actingUserId) {
|
|
234507
|
+
return apiRequest("POST", "/v1/monitors", input, {
|
|
234508
|
+
actingUserId,
|
|
234509
|
+
signal: AbortSignal.timeout(15000)
|
|
234510
|
+
});
|
|
234511
|
+
}
|
|
234512
|
+
function updateMonitorState(id, input, actingUserId) {
|
|
234513
|
+
return apiRequest("PATCH", `/v1/monitors/${encodeURIComponent(id)}`, input, {
|
|
234514
|
+
actingUserId,
|
|
234515
|
+
signal: AbortSignal.timeout(15000)
|
|
234516
|
+
});
|
|
234517
|
+
}
|
|
234518
|
+
var init_monitors = __esm(() => {
|
|
234519
|
+
init_request();
|
|
234520
|
+
});
|
|
234521
|
+
|
|
234522
|
+
// src/tools/impl/monitor-state.ts
|
|
234523
|
+
async function withMonitorState(input, start) {
|
|
234524
|
+
if (resolveBackendMode() === "local")
|
|
234525
|
+
return start(getNextMonitorId());
|
|
234526
|
+
const runtime = getRuntimeContext();
|
|
234527
|
+
const scope = !input.parentScope && runtime?.agentId === null && runtime.conversationId ? { agentId: null, conversationId: runtime.conversationId } : resolveNotificationScope(input.parentScope);
|
|
234528
|
+
if (!scope)
|
|
234529
|
+
throw new Error("A conversation is required to start a cloud monitor");
|
|
234530
|
+
const actingUserId = getRuntimeActingUserAttribution();
|
|
234531
|
+
const secrets2 = {
|
|
234532
|
+
...captureSecretRedactions(scope.agentId ?? undefined),
|
|
234533
|
+
...input.secretEnv
|
|
234534
|
+
};
|
|
234535
|
+
const record4 = await createMonitorState({
|
|
234536
|
+
agent_id: scope.agentId || null,
|
|
234537
|
+
conversation_id: scope.conversationId,
|
|
234538
|
+
description: scrubSecretsFromString(input.description, secrets2),
|
|
234539
|
+
command: scrubSecretsFromString(input.command, secrets2),
|
|
234540
|
+
kind: input.kind,
|
|
234541
|
+
persistent: input.persistent,
|
|
234542
|
+
status: "running",
|
|
234543
|
+
device_id: getRuntimeContext()?.environmentDeviceId ?? null,
|
|
234544
|
+
started_at: new Date().toISOString(),
|
|
234545
|
+
output_file: null,
|
|
234546
|
+
exit_code: null
|
|
234547
|
+
}, actingUserId);
|
|
234548
|
+
const id = record4.monitor_id;
|
|
234549
|
+
try {
|
|
234550
|
+
input.signal?.throwIfAborted();
|
|
234551
|
+
const result3 = await start(id);
|
|
234552
|
+
const process21 = backgroundProcesses.get(id);
|
|
234553
|
+
if (!process21)
|
|
234554
|
+
throw new Error("Monitor did not register its process");
|
|
234555
|
+
let pending2 = Promise.resolve();
|
|
234556
|
+
process21.persistState = () => {
|
|
234557
|
+
const state2 = {
|
|
234558
|
+
status: process21.status,
|
|
234559
|
+
exit_code: process21.exitCode,
|
|
234560
|
+
output_file: process21.outputFile ?? null
|
|
234561
|
+
};
|
|
234562
|
+
pending2 = pending2.catch(() => {}).then(async () => {
|
|
234563
|
+
await updateMonitorState(id, state2, actingUserId);
|
|
234564
|
+
});
|
|
234565
|
+
return pending2;
|
|
234566
|
+
};
|
|
234567
|
+
await process21.persistState();
|
|
234568
|
+
return result3;
|
|
234569
|
+
} catch (error4) {
|
|
234570
|
+
const process21 = backgroundProcesses.get(id);
|
|
234571
|
+
if (process21) {
|
|
234572
|
+
process21.completionNotificationSuppressed = true;
|
|
234573
|
+
process21.status = "failed";
|
|
234574
|
+
process21.process.kill("SIGTERM");
|
|
234575
|
+
notifyBackgroundProcessStateChanged(process21.runtimeScope);
|
|
234576
|
+
scheduleBackgroundProcessCleanup(id);
|
|
234577
|
+
}
|
|
234578
|
+
await updateMonitorState(id, {
|
|
234579
|
+
status: "failed",
|
|
234580
|
+
exit_code: null,
|
|
234581
|
+
output_file: process21?.outputFile ?? null
|
|
234582
|
+
}, actingUserId).catch((persistenceError) => {
|
|
234583
|
+
console.error("Failed to persist monitor state:", persistenceError);
|
|
234584
|
+
});
|
|
234585
|
+
throw error4;
|
|
234586
|
+
}
|
|
234587
|
+
}
|
|
234588
|
+
async function persistMonitorState(process21) {
|
|
234589
|
+
await process21.persistState?.().catch((error4) => {
|
|
234590
|
+
console.error("Failed to persist monitor state:", error4);
|
|
234591
|
+
});
|
|
234592
|
+
}
|
|
234593
|
+
var init_monitor_state = __esm(() => {
|
|
234594
|
+
init_monitors();
|
|
234595
|
+
init_backend_mode();
|
|
234596
|
+
init_runtime_context();
|
|
234597
|
+
init_secret_substitution();
|
|
234598
|
+
init_task_notifications();
|
|
234599
|
+
init_process_manager();
|
|
234600
|
+
});
|
|
234601
|
+
|
|
234369
234602
|
// src/tools/impl/monitor-timeout.ts
|
|
234370
234603
|
function getMonitorMaxTimeoutMs() {
|
|
234371
234604
|
const seconds = process.env.LETTA_MONITOR_MAX_TIMEOUT_SECONDS;
|
|
@@ -234488,14 +234721,6 @@ function buildCloudSource(args, url2) {
|
|
|
234488
234721
|
}
|
|
234489
234722
|
return source;
|
|
234490
234723
|
}
|
|
234491
|
-
function notifyDescription(source) {
|
|
234492
|
-
const what = source.select ? `the value at ${source.select.path}` : "the HTTP status or body";
|
|
234493
|
-
if (!source.notify_when) {
|
|
234494
|
-
return `The first response is the baseline; you will be notified only when ${what} changes`;
|
|
234495
|
-
}
|
|
234496
|
-
const then = source.stop_on_match ? ", and then it stops" : "; it notifies again each time a match begins";
|
|
234497
|
-
return `You will be notified when ${what} first matches, including on the first poll${then}`;
|
|
234498
|
-
}
|
|
234499
234724
|
function validateUrlMonitorArgs(args) {
|
|
234500
234725
|
if (typeof args.description !== "string") {
|
|
234501
234726
|
throw new Error("Monitor description is required");
|
|
@@ -234541,7 +234766,6 @@ async function startCloudUrlMonitor(args, deps = {}) {
|
|
|
234541
234766
|
if (!isSavedConversation(scope.conversationId)) {
|
|
234542
234767
|
throw new Error("Monitor url needs a saved conversation and is not available in the agent's default conversation. Use command with a polling loop instead.");
|
|
234543
234768
|
}
|
|
234544
|
-
const intervalSeconds = source.interval_seconds;
|
|
234545
234769
|
const timeoutMs = args.timeout_ms ?? DEFAULT_URL_MONITOR_TIMEOUT_MS;
|
|
234546
234770
|
const request3 = deps.request ?? apiRequest;
|
|
234547
234771
|
const created = await request3("POST", cloudMonitorsPath(scope.conversationId), {
|
|
@@ -234551,30 +234775,18 @@ async function startCloudUrlMonitor(args, deps = {}) {
|
|
|
234551
234775
|
...args.toolCallId && { tool_call_id: args.toolCallId }
|
|
234552
234776
|
}, actingUserRequestOptions(scope.actingUserId));
|
|
234553
234777
|
const taskId = created.id;
|
|
234554
|
-
return
|
|
234555
|
-
content: [
|
|
234556
|
-
{
|
|
234557
|
-
type: "text",
|
|
234558
|
-
text: `Cloud monitor started (task ${taskId}, polls every ${intervalSeconds}s, timeout ${timeoutMs}ms). ${notifyDescription(source)}, even if this sandbox stops. Keep working — do not poll or sleep. Stop it with TaskStop.`
|
|
234559
|
-
}
|
|
234560
|
-
],
|
|
234561
|
-
taskId,
|
|
234562
|
-
timeoutMs,
|
|
234563
|
-
persistent: false
|
|
234564
|
-
};
|
|
234778
|
+
return buildMonitorResult(taskId, timeoutMs, false);
|
|
234565
234779
|
}
|
|
234566
234780
|
async function stopCloudUrlMonitor(taskId, deps = {}) {
|
|
234567
234781
|
if (!(deps.isCloud ?? isLettaCloud2)()) {
|
|
234568
234782
|
return {
|
|
234569
|
-
killed: false
|
|
234570
|
-
output: `No task ${taskId} is running here, and Cloud monitors can only be stopped when connected to Letta Cloud.`
|
|
234783
|
+
killed: false
|
|
234571
234784
|
};
|
|
234572
234785
|
}
|
|
234573
234786
|
const conversationId = (deps.scope ?? resolveNotificationScope)()?.conversationId;
|
|
234574
234787
|
if (!conversationId || !isSavedConversation(conversationId)) {
|
|
234575
234788
|
return {
|
|
234576
|
-
killed: false
|
|
234577
|
-
output: `No Cloud monitor ${taskId} was found in this conversation.`
|
|
234789
|
+
killed: false
|
|
234578
234790
|
};
|
|
234579
234791
|
}
|
|
234580
234792
|
const request3 = deps.request ?? apiRequest;
|
|
@@ -234584,19 +234796,17 @@ async function stopCloudUrlMonitor(taskId, deps = {}) {
|
|
|
234584
234796
|
} catch (error4) {
|
|
234585
234797
|
if (error4 instanceof ApiRequestError && error4.status === 404) {
|
|
234586
234798
|
return {
|
|
234587
|
-
killed: false
|
|
234588
|
-
output: `No Cloud monitor ${taskId} was found in this conversation.`
|
|
234799
|
+
killed: false
|
|
234589
234800
|
};
|
|
234590
234801
|
}
|
|
234591
234802
|
throw error4;
|
|
234592
234803
|
}
|
|
234593
234804
|
if (stopped.status !== "cancelled") {
|
|
234594
234805
|
return {
|
|
234595
|
-
killed: false
|
|
234596
|
-
output: `Cloud monitor ${taskId} had already stopped (${stopped.status}).`
|
|
234806
|
+
killed: false
|
|
234597
234807
|
};
|
|
234598
234808
|
}
|
|
234599
|
-
return { killed: true
|
|
234809
|
+
return { killed: true };
|
|
234600
234810
|
}
|
|
234601
234811
|
var URL_MONITOR_MIN_INTERVAL_SECONDS = 60, DEFAULT_URL_MONITOR_TIMEOUT_MS = 86400000, SECRET_REFERENCE, CREDENTIAL_HEADER;
|
|
234602
234812
|
var init_monitor_url_cloud = __esm(() => {
|
|
@@ -234615,21 +234825,6 @@ import { WebSocket as WebSocket4 } from "ws";
|
|
|
234615
234825
|
function getMonitorTimeoutEvent(timeoutMs, tool = "Monitor") {
|
|
234616
234826
|
return isManagedCloudRuntime() && timeoutMs === getMonitorMaxTimeoutMs() ? `${tool} stopped at the ${timeoutMs / 3600000}-hour Cloud sandbox limit. If you still need to watch, simply re-arm it by calling ${tool} again. For much longer waits, schedule a Wake or cron, which does not keep the sandbox running between turns.` : "[Monitor timed out — re-arm if needed.]";
|
|
234617
234827
|
}
|
|
234618
|
-
function buildMonitorResult(taskId, timeoutMs, persistent, outputFile) {
|
|
234619
|
-
const lifetime = persistent ? "persistent — runs until TaskStop or session end" : `timeout ${timeoutMs}ms`;
|
|
234620
|
-
return {
|
|
234621
|
-
content: [
|
|
234622
|
-
{
|
|
234623
|
-
type: "text",
|
|
234624
|
-
text: `Monitor started (task ${taskId}, ${lifetime}). You will be notified on each event. Keep working — do not poll or sleep. Events may arrive while you are waiting for the user — an event is not their reply.
|
|
234625
|
-
Output file: ${outputFile}`
|
|
234626
|
-
}
|
|
234627
|
-
],
|
|
234628
|
-
taskId,
|
|
234629
|
-
timeoutMs,
|
|
234630
|
-
persistent
|
|
234631
|
-
};
|
|
234632
|
-
}
|
|
234633
234828
|
function validUtf8Prefix(buffer, maxBytes) {
|
|
234634
234829
|
let end = Math.min(buffer.length, maxBytes);
|
|
234635
234830
|
while (end > Math.max(0, maxBytes - 4)) {
|
|
@@ -234744,15 +234939,8 @@ function normalizeMonitorArgs(args) {
|
|
|
234744
234939
|
const hasCommand = typeof normalized.command === "string" && normalized.command.length > 0;
|
|
234745
234940
|
const hasWebSocket = normalized.ws !== undefined && !(typeof normalized.ws === "object" && normalized.ws !== null && normalized.ws.url === "");
|
|
234746
234941
|
if (Number(hasCommand) + Number(hasWebSocket) + Number(hasScript) !== 1) {
|
|
234747
|
-
throw new Error("Monitor requires exactly one of command, ws, or script
|
|
234748
|
-
}
|
|
234749
|
-
if (normalized.interval_seconds !== undefined) {
|
|
234750
|
-
throw new Error("Monitor interval_seconds is only supported with url");
|
|
234751
|
-
}
|
|
234752
|
-
if (normalized.headers !== undefined || normalized.select !== undefined || normalized.match !== undefined || normalized.stop_on_match !== undefined) {
|
|
234753
|
-
throw new Error("Monitor headers, select, match and stop_on_match are only supported with url");
|
|
234942
|
+
throw new Error("Monitor requires exactly one of command, ws, or script");
|
|
234754
234943
|
}
|
|
234755
|
-
delete normalized.url;
|
|
234756
234944
|
if (!hasScript) {
|
|
234757
234945
|
delete normalized.script;
|
|
234758
234946
|
delete normalized.args;
|
|
@@ -234852,6 +235040,7 @@ function queueCommandCompletion(params) {
|
|
|
234852
235040
|
function markMonitorFinished(taskId, processState, status, exitCode) {
|
|
234853
235041
|
processState.status = status;
|
|
234854
235042
|
processState.exitCode = exitCode;
|
|
235043
|
+
persistMonitorState(processState);
|
|
234855
235044
|
cancelMonitorBackup(taskId);
|
|
234856
235045
|
scrubCompletedBackgroundOutput(processState);
|
|
234857
235046
|
notifyBackgroundProcessStateChanged(processState.runtimeScope);
|
|
@@ -234873,7 +235062,7 @@ function startCommandMonitor(args) {
|
|
|
234873
235062
|
}
|
|
234874
235063
|
noteExpectedWorktreeForLauncher(launcher, cwd2);
|
|
234875
235064
|
const sandboxed = applyShellSandbox(launcher, cwd2, env6);
|
|
234876
|
-
const taskId =
|
|
235065
|
+
const taskId = args.taskId;
|
|
234877
235066
|
const outputFile = createBackgroundOutputFile(taskId);
|
|
234878
235067
|
const output = new MonitorOutputWriter(outputFile);
|
|
234879
235068
|
const scope = resolveNotificationScope(args.parentScope);
|
|
@@ -235042,7 +235231,7 @@ function startCommandMonitor(args) {
|
|
|
235042
235231
|
function startWebSocketMonitor(args) {
|
|
235043
235232
|
assertBackgroundProcessCapacity();
|
|
235044
235233
|
const source = args.ws;
|
|
235045
|
-
const taskId =
|
|
235234
|
+
const taskId = args.taskId;
|
|
235046
235235
|
const outputFile = createBackgroundOutputFile(taskId);
|
|
235047
235236
|
const output = new MonitorOutputWriter(outputFile);
|
|
235048
235237
|
const scope = resolveNotificationScope(args.parentScope);
|
|
@@ -235214,6 +235403,7 @@ async function startScriptSource(args) {
|
|
|
235214
235403
|
const { taskId, outputFile } = await startScriptMonitor({
|
|
235215
235404
|
description: args.description,
|
|
235216
235405
|
script: args.script,
|
|
235406
|
+
taskId: args.taskId,
|
|
235217
235407
|
args: args.args,
|
|
235218
235408
|
timeout_ms: args.timeout_ms,
|
|
235219
235409
|
persistent: args.persistent,
|
|
@@ -235235,12 +235425,41 @@ function backupScopeFor(taskId) {
|
|
|
235235
235425
|
}
|
|
235236
235426
|
async function monitor(args) {
|
|
235237
235427
|
args.signal?.throwIfAborted();
|
|
235238
|
-
|
|
235428
|
+
const cloud = experimentManager.isEnabled("cloud_monitors");
|
|
235429
|
+
const forbidden = cloud ? [
|
|
235430
|
+
"command",
|
|
235431
|
+
"ws",
|
|
235432
|
+
"script",
|
|
235433
|
+
"args",
|
|
235434
|
+
"persistent",
|
|
235435
|
+
"backup_after_seconds",
|
|
235436
|
+
"backup_prompt"
|
|
235437
|
+
] : [
|
|
235438
|
+
"url",
|
|
235439
|
+
"interval_seconds",
|
|
235440
|
+
"headers",
|
|
235441
|
+
"select",
|
|
235442
|
+
"match",
|
|
235443
|
+
"stop_on_match"
|
|
235444
|
+
];
|
|
235445
|
+
for (const key2 of forbidden) {
|
|
235446
|
+
if (args[key2] !== undefined) {
|
|
235447
|
+
throw new Error(`Monitor ${key2} is not supported in ${cloud ? "Cloud" : "local"} mode`);
|
|
235448
|
+
}
|
|
235449
|
+
}
|
|
235450
|
+
if (cloud) {
|
|
235239
235451
|
return startCloudUrlMonitor(args);
|
|
235240
235452
|
}
|
|
235241
235453
|
const normalized = normalizeMonitorArgs(args);
|
|
235242
235454
|
installMonitorProcessExitCleanup();
|
|
235243
|
-
const result3 =
|
|
235455
|
+
const result3 = await withMonitorState({
|
|
235456
|
+
...normalized,
|
|
235457
|
+
kind: normalized.script !== undefined ? "script" : normalized.command !== undefined ? "command" : "websocket",
|
|
235458
|
+
command: normalized.command ?? normalized.script ?? (normalized.ws ? webSocketDisplayUrl(normalized.ws.url) : "")
|
|
235459
|
+
}, (taskId) => {
|
|
235460
|
+
const sourceArgs = { ...normalized, taskId };
|
|
235461
|
+
return normalized.script !== undefined ? startScriptSource(sourceArgs) : normalized.command !== undefined ? startCommandMonitor(sourceArgs) : startWebSocketMonitor(sourceArgs);
|
|
235462
|
+
});
|
|
235244
235463
|
if (normalized.backup_after_seconds === undefined)
|
|
235245
235464
|
return result3;
|
|
235246
235465
|
const note = await armMonitorBackup({
|
|
@@ -235270,6 +235489,10 @@ function stopMonitorsForProcessExit() {
|
|
|
235270
235489
|
} catch {}
|
|
235271
235490
|
}
|
|
235272
235491
|
}
|
|
235492
|
+
async function shutdownMonitors() {
|
|
235493
|
+
stopMonitorsForProcessExit();
|
|
235494
|
+
await Promise.all([...backgroundProcesses.values()].filter((process21) => process21.kind === "monitor").map(persistMonitorState));
|
|
235495
|
+
}
|
|
235273
235496
|
function installMonitorProcessExitCleanup() {
|
|
235274
235497
|
if (monitorProcessExitCleanupInstalled)
|
|
235275
235498
|
return;
|
|
@@ -235279,6 +235502,7 @@ function installMonitorProcessExitCleanup() {
|
|
|
235279
235502
|
var MIN_TIMEOUT_MS = 1000, DEFAULT_TIMEOUT_MS3 = 300000, MONITOR_OUTPUT_FILE_BYTES, WEBSOCKET_MAX_PAYLOAD_BYTES, WEBSOCKET_PROTOCOL_PATTERN, monitorProcessExitCleanupInstalled = false;
|
|
235280
235503
|
var init_monitor = __esm(() => {
|
|
235281
235504
|
init_strip_ansi();
|
|
235505
|
+
init_manager();
|
|
235282
235506
|
init_runtime_context();
|
|
235283
235507
|
init_secret_substitution();
|
|
235284
235508
|
init_message_queue_bridge();
|
|
@@ -235288,6 +235512,7 @@ var init_monitor = __esm(() => {
|
|
|
235288
235512
|
init_monitor_backup();
|
|
235289
235513
|
init_monitor_event_stream();
|
|
235290
235514
|
init_monitor_script();
|
|
235515
|
+
init_monitor_state();
|
|
235291
235516
|
init_monitor_timeout();
|
|
235292
235517
|
init_monitor_url_cloud();
|
|
235293
235518
|
init_process_manager();
|
|
@@ -239900,7 +240125,7 @@ class CodexAppServerClient {
|
|
|
239900
240125
|
await this.request("initialize", {
|
|
239901
240126
|
clientInfo: {
|
|
239902
240127
|
name: "letta-code",
|
|
239903
|
-
version: "0.34.
|
|
240128
|
+
version: "0.34.59"
|
|
239904
240129
|
},
|
|
239905
240130
|
capabilities: null
|
|
239906
240131
|
});
|
|
@@ -241435,7 +241660,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
241435
241660
|
return `${SYSTEM_REMINDER_OPEN}
|
|
241436
241661
|
MCP servers with available tools: ${rendered}
|
|
241437
241662
|
Do not automatically store results of principal-restricted operations in shared memory.
|
|
241438
|
-
Find tools (with schemas) with \`letta mcp search "<what you want to do>"\`, list one server's tools with \`letta mcp tools <server>\` (\`--full\` includes schemas, \`letta mcp schema <tool-name>\` fetches one), and invoke one with \`letta mcp call <tool-name> --args '{"key":"value"}'\`.
|
|
241663
|
+
Find tools (with schemas) with \`letta mcp search "<what you want to do>"\`, list one server's tools with \`letta mcp tools <server>\` (\`--full\` includes schemas, \`letta mcp schema <tool-name>\` fetches one), and invoke one with \`letta mcp call <tool-name> --args '{"key":"value"}'\`. For large or quote-heavy arguments, use \`--args-file <path>\` (\`-\` for stdin) instead of \`--args\`. Exit code 2 means the tool returned an error result: read its \`content\`, fix the arguments, and retry (exit 1 is a CLI/usage error).
|
|
241439
241664
|
${SYSTEM_REMINDER_CLOSE}`;
|
|
241440
241665
|
}
|
|
241441
241666
|
async function listMcpServersForAgent(agentId, _state, deps = {}) {
|
|
@@ -244431,7 +244656,7 @@ async function fetchParentConversationMessages(params) {
|
|
|
244431
244656
|
}
|
|
244432
244657
|
return messages.reverse();
|
|
244433
244658
|
}
|
|
244434
|
-
function
|
|
244659
|
+
function contentText3(content) {
|
|
244435
244660
|
if (typeof content === "string")
|
|
244436
244661
|
return content;
|
|
244437
244662
|
if (!Array.isArray(content))
|
|
@@ -244457,7 +244682,7 @@ function renderToolCall(call) {
|
|
|
244457
244682
|
}
|
|
244458
244683
|
function renderToolResult(result3) {
|
|
244459
244684
|
const raw2 = result3.tool_return ?? result3.func_response;
|
|
244460
|
-
const text2 = typeof raw2 === "string" ? raw2 :
|
|
244685
|
+
const text2 = typeof raw2 === "string" ? raw2 : contentText3(raw2) || (raw2 == null ? "" : JSON.stringify(raw2));
|
|
244461
244686
|
return {
|
|
244462
244687
|
type: "tool_result",
|
|
244463
244688
|
call_id: result3.tool_call_id ?? undefined,
|
|
@@ -244493,11 +244718,11 @@ function userEvents(text2, speaker) {
|
|
|
244493
244718
|
function renderMessage(message2) {
|
|
244494
244719
|
switch (message2.message_type) {
|
|
244495
244720
|
case "user_message": {
|
|
244496
|
-
const text2 =
|
|
244721
|
+
const text2 = contentText3(message2.content).replace(SYSTEM_REMINDER_PATTERN, "").trim();
|
|
244497
244722
|
return userEvents(text2, message2.name ?? undefined);
|
|
244498
244723
|
}
|
|
244499
244724
|
case "assistant_message": {
|
|
244500
|
-
const text2 =
|
|
244725
|
+
const text2 = contentText3(message2.content).trim();
|
|
244501
244726
|
return text2 ? [
|
|
244502
244727
|
{
|
|
244503
244728
|
type: "message",
|
|
@@ -245240,8 +245465,19 @@ async function defaultResolveComputer(computer, scope) {
|
|
|
245240
245465
|
if (!isCloudEnvironmentSelector(computer))
|
|
245241
245466
|
return resolveEnvironmentConnectionId(computer);
|
|
245242
245467
|
const client = await getClient();
|
|
245243
|
-
const
|
|
245244
|
-
const
|
|
245468
|
+
const parentConversationId = scope.conversationId && scope.conversationId !== "default" ? scope.conversationId : undefined;
|
|
245469
|
+
const createParams = {
|
|
245470
|
+
agent_id: scope.agentId,
|
|
245471
|
+
hidden: true,
|
|
245472
|
+
...parentConversationId ? { parent_conversation_id: parentConversationId } : {}
|
|
245473
|
+
};
|
|
245474
|
+
const conversation = await client.conversations.create(createParams).catch((error4) => {
|
|
245475
|
+
if (!parentConversationId || !error4 || typeof error4 !== "object" || !("status" in error4) || error4.status !== 403) {
|
|
245476
|
+
throw error4;
|
|
245477
|
+
}
|
|
245478
|
+
const fallbackParams = { agent_id: scope.agentId, hidden: true };
|
|
245479
|
+
return client.conversations.create(fallbackParams);
|
|
245480
|
+
});
|
|
245245
245481
|
return resolveAgentSandboxConnectionId(scope.agentId, {
|
|
245246
245482
|
conversationId: conversation.id
|
|
245247
245483
|
});
|
|
@@ -245475,21 +245711,27 @@ async function launchRemoteExternalCodingAgent(params, deps) {
|
|
|
245475
245711
|
});
|
|
245476
245712
|
return { success: false, error: error4 };
|
|
245477
245713
|
};
|
|
245478
|
-
let connectionId;
|
|
245479
|
-
let deviceId;
|
|
245480
|
-
let supportsSteering;
|
|
245481
|
-
let sendsForkContext;
|
|
245482
|
-
|
|
245483
|
-
|
|
245714
|
+
let connectionId = "";
|
|
245715
|
+
let deviceId = "";
|
|
245716
|
+
let supportsSteering = false;
|
|
245717
|
+
let sendsForkContext = false;
|
|
245718
|
+
const resolveComputer = deps.resolveComputer ?? defaultResolveComputer;
|
|
245719
|
+
function configureComputer(resolved) {
|
|
245484
245720
|
if (resolved.environment.metadata?.launch_subagent_notify_caller !== true)
|
|
245485
|
-
return
|
|
245721
|
+
return formatOutdatedComputerError(type, computer);
|
|
245486
245722
|
sendsForkContext = resolved.environment.metadata?.external_fork_context === true;
|
|
245487
245723
|
if (params.forkContext && !sendsForkContext)
|
|
245488
|
-
return
|
|
245724
|
+
return `Update Letta Code on ${computer} to fork external workers with destination-local history files.`;
|
|
245489
245725
|
sendsForkContext ||= (compareSemver(resolved.environment.metadata?.lettaCodeVersion ?? "", "0.34.40") ?? -1) >= 0;
|
|
245490
245726
|
connectionId = resolved.connectionId;
|
|
245491
245727
|
deviceId = resolved.environment.deviceId;
|
|
245492
245728
|
supportsSteering = resolved.environment.metadata?.subagent_message === true;
|
|
245729
|
+
return;
|
|
245730
|
+
}
|
|
245731
|
+
try {
|
|
245732
|
+
const outdated = configureComputer(await resolveComputer(computer, parentScope));
|
|
245733
|
+
if (outdated)
|
|
245734
|
+
return fail2("outdated_computer", outdated);
|
|
245493
245735
|
} catch (error4) {
|
|
245494
245736
|
return fail2("resolve_computer", errorMessage5(error4));
|
|
245495
245737
|
}
|
|
@@ -245502,27 +245744,53 @@ async function launchRemoteExternalCodingAgent(params, deps) {
|
|
|
245502
245744
|
} catch (error4) {
|
|
245503
245745
|
return fail2("connect", `Can't reach ${computer}: ${errorMessage5(error4)}`);
|
|
245504
245746
|
}
|
|
245505
|
-
const
|
|
245506
|
-
|
|
245747
|
+
const createFollower = () => {
|
|
245748
|
+
const next = new RemoteSubagentFollower(parentScope, toolCallId, connect, deps.reconnectDelayMs ?? 2000);
|
|
245749
|
+
next.attach(client);
|
|
245750
|
+
return next;
|
|
245751
|
+
};
|
|
245752
|
+
let follower = createFollower();
|
|
245753
|
+
const launch = () => client.launchSubagent({
|
|
245754
|
+
request_id: `launch-subagent-${randomUUID46()}`,
|
|
245755
|
+
runtime: {
|
|
245756
|
+
agent_id: parentScope.agentId,
|
|
245757
|
+
conversation_id: parentScope.conversationId,
|
|
245758
|
+
...parentScope.actingUserId ? { acting_user_id: parentScope.actingUserId } : {}
|
|
245759
|
+
},
|
|
245760
|
+
args: {
|
|
245761
|
+
...sendsForkContext ? { harness: type, fork_context: params.forkContext === true } : { subagent_type: type },
|
|
245762
|
+
prompt: params.prompt,
|
|
245763
|
+
description: params.description,
|
|
245764
|
+
...params.model ? { model: params.model } : {},
|
|
245765
|
+
...params.mcp ? { mcp: params.mcp } : {}
|
|
245766
|
+
},
|
|
245767
|
+
tool_call_id: toolCallId,
|
|
245768
|
+
notify: "caller"
|
|
245769
|
+
});
|
|
245507
245770
|
let launched;
|
|
245508
245771
|
try {
|
|
245509
|
-
|
|
245510
|
-
|
|
245511
|
-
|
|
245512
|
-
|
|
245513
|
-
|
|
245514
|
-
|
|
245515
|
-
|
|
245516
|
-
|
|
245517
|
-
|
|
245518
|
-
|
|
245519
|
-
|
|
245520
|
-
|
|
245521
|
-
|
|
245522
|
-
|
|
245523
|
-
|
|
245524
|
-
|
|
245525
|
-
|
|
245772
|
+
try {
|
|
245773
|
+
launched = await launch();
|
|
245774
|
+
} catch (error4) {
|
|
245775
|
+
follower.close();
|
|
245776
|
+
let resolved;
|
|
245777
|
+
try {
|
|
245778
|
+
resolved = await resolveComputer(isCloudEnvironmentSelector(computer) ? deviceId : computer, parentScope);
|
|
245779
|
+
} catch (resolveError) {
|
|
245780
|
+
if (/\boffline\b/i.test(errorMessage5(resolveError)))
|
|
245781
|
+
throw new Error(`${computer} disconnected during the launch: ${errorMessage5(resolveError)}`);
|
|
245782
|
+
throw resolveError;
|
|
245783
|
+
}
|
|
245784
|
+
if (resolved.connectionId === connectionId)
|
|
245785
|
+
throw error4;
|
|
245786
|
+
const outdated = configureComputer(resolved);
|
|
245787
|
+
if (outdated)
|
|
245788
|
+
throw new Error(outdated);
|
|
245789
|
+
params.signal?.throwIfAborted();
|
|
245790
|
+
client = await connect();
|
|
245791
|
+
follower = createFollower();
|
|
245792
|
+
launched = await launch();
|
|
245793
|
+
}
|
|
245526
245794
|
} catch (error4) {
|
|
245527
245795
|
follower.close();
|
|
245528
245796
|
return fail2("launch_request", `Couldn't launch ${type} on ${computer}: ${errorMessage5(error4)}`);
|
|
@@ -245605,6 +245873,7 @@ async function connectQualifiedTarget(agentId, parentScope, deps) {
|
|
|
245605
245873
|
throw new Error(formatOutdatedSteeringError(target.computer));
|
|
245606
245874
|
return {
|
|
245607
245875
|
target,
|
|
245876
|
+
lettaCodeVersion: resolved.environment.metadata?.lettaCodeVersion,
|
|
245608
245877
|
client: await (deps.connect ?? defaultConnect)(resolved.connectionId, parentScope)
|
|
245609
245878
|
};
|
|
245610
245879
|
}
|
|
@@ -245636,7 +245905,7 @@ async function sendRemoteExternalCodingAgentMessage(params, deps = {}) {
|
|
|
245636
245905
|
} catch (error4) {
|
|
245637
245906
|
const target = parseExternalCodingAgentId(params.agentId);
|
|
245638
245907
|
reportExternalWorkerLaunchFailure({
|
|
245639
|
-
stage: "follow_up",
|
|
245908
|
+
stage: error4 instanceof OutdatedRemoteWorkerError ? "outdated_computer" : "follow_up",
|
|
245640
245909
|
harness: target?.type ?? "unknown",
|
|
245641
245910
|
computer: target?.computer,
|
|
245642
245911
|
error: error4,
|
|
@@ -245649,7 +245918,7 @@ async function sendRemoteExternalCodingAgentMessage(params, deps = {}) {
|
|
|
245649
245918
|
}
|
|
245650
245919
|
async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
245651
245920
|
const requestId = `subagent-message-${randomUUID46()}`;
|
|
245652
|
-
const { target, client } = await connectQualifiedTarget(params.agentId, params.parentScope, deps);
|
|
245921
|
+
const { target, client, lettaCodeVersion } = await connectQualifiedTarget(params.agentId, params.parentScope, deps);
|
|
245653
245922
|
const toolCallId = params.toolCallId ?? `remote-followup-${randomUUID46()}`;
|
|
245654
245923
|
const connect = async () => {
|
|
245655
245924
|
const resolved = await (deps.resolveComputer ?? resolveQualifiedComputer)(target.computer, params.parentScope);
|
|
@@ -245677,6 +245946,9 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
245677
245946
|
}
|
|
245678
245947
|
if (!response.success) {
|
|
245679
245948
|
follower.close();
|
|
245949
|
+
if (response.error === "Subagent does not belong to this conversation" && (compareSemver(lettaCodeVersion ?? "", "0.34.54") ?? -1) < 0) {
|
|
245950
|
+
throw new OutdatedRemoteWorkerError(`${target.computer} is running Letta Code ${lettaCodeVersion ?? "(unknown version)"}, which doesn't keep track of finished or restarted workers, so it can't resume this one. Update Letta Code on ${target.computer}, or launch a new worker.`);
|
|
245951
|
+
}
|
|
245680
245952
|
throw new Error(response.error);
|
|
245681
245953
|
}
|
|
245682
245954
|
if (response.delivery === "steered") {
|
|
@@ -245741,7 +246013,7 @@ async function deliverRemoteExternalCodingAgentMessage(params, deps) {
|
|
|
245741
246013
|
outputFile: tracked.outputFile
|
|
245742
246014
|
};
|
|
245743
246015
|
}
|
|
245744
|
-
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, MAX_RECONNECT_DELAY_MS = 30000;
|
|
246016
|
+
var REMOTE_EXTERNAL_WORKER_STOPPED, DISPLAY_NAMES, RemoteWorkerLostError, OutdatedRemoteWorkerError, MAX_RECONNECT_DELAY_MS = 30000;
|
|
245745
246017
|
var init_remote_external_coding_agent = __esm(() => {
|
|
245746
246018
|
init_subagent_state();
|
|
245747
246019
|
init_app_server_client();
|
|
@@ -245762,6 +246034,8 @@ var init_remote_external_coding_agent = __esm(() => {
|
|
|
245762
246034
|
};
|
|
245763
246035
|
RemoteWorkerLostError = class RemoteWorkerLostError extends Error {
|
|
245764
246036
|
};
|
|
246037
|
+
OutdatedRemoteWorkerError = class OutdatedRemoteWorkerError extends Error {
|
|
246038
|
+
};
|
|
245765
246039
|
});
|
|
245766
246040
|
|
|
245767
246041
|
// src/tools/impl/subagent-computer.ts
|
|
@@ -245828,6 +246102,7 @@ function killBackgroundProcess(shell_id) {
|
|
|
245828
246102
|
proc.status = "failed";
|
|
245829
246103
|
}
|
|
245830
246104
|
proc.process.kill("SIGTERM");
|
|
246105
|
+
persistMonitorState(proc);
|
|
245831
246106
|
if (proc.kind === "monitor")
|
|
245832
246107
|
cancelMonitorBackup(shell_id);
|
|
245833
246108
|
clearBackgroundProcessCleanup(shell_id);
|
|
@@ -245846,6 +246121,7 @@ function killBackgroundProcess(shell_id) {
|
|
|
245846
246121
|
}
|
|
245847
246122
|
var init_kill_bash = __esm(() => {
|
|
245848
246123
|
init_monitor_backup();
|
|
246124
|
+
init_monitor_state();
|
|
245849
246125
|
init_process_manager();
|
|
245850
246126
|
});
|
|
245851
246127
|
|
|
@@ -246070,6 +246346,15 @@ async function task_stop(args, deps = {}) {
|
|
|
246070
246346
|
return (deps.stopCloudMonitor ?? stopCloudUrlMonitor)(task_id);
|
|
246071
246347
|
}
|
|
246072
246348
|
const killed = killBackgroundProcess(task_id);
|
|
246349
|
+
try {
|
|
246350
|
+
if (killed)
|
|
246351
|
+
await process21?.persistState?.();
|
|
246352
|
+
} catch {
|
|
246353
|
+
return {
|
|
246354
|
+
killed,
|
|
246355
|
+
output: "Monitor stopped, but its server state could not be saved"
|
|
246356
|
+
};
|
|
246357
|
+
}
|
|
246073
246358
|
return {
|
|
246074
246359
|
killed,
|
|
246075
246360
|
...killed && process21?.kind === "tool" ? { output: "Stopped" } : {}
|
|
@@ -248692,7 +248977,7 @@ function createGitHubPullRequestSnapshotFetcher(deps = {}) {
|
|
|
248692
248977
|
if (unsupported || !shouldFetchCloud())
|
|
248693
248978
|
return fetchGh(ref, options);
|
|
248694
248979
|
let waited = false;
|
|
248695
|
-
const cooldownError = new
|
|
248980
|
+
const cooldownError = new GitHubPullRequestSnapshotPending;
|
|
248696
248981
|
const cooldown = async (retryAt) => {
|
|
248697
248982
|
if (waited) {
|
|
248698
248983
|
throw cooldownError;
|
|
@@ -248738,7 +249023,7 @@ function createGitHubPullRequestSnapshotFetcher(deps = {}) {
|
|
|
248738
249023
|
}
|
|
248739
249024
|
};
|
|
248740
249025
|
}
|
|
248741
|
-
var DEFAULT_COOLDOWN_MS = 30000, MAX_COOLDOWN_MS = 60000;
|
|
249026
|
+
var GitHubPullRequestSnapshotPending, DEFAULT_COOLDOWN_MS = 30000, MAX_COOLDOWN_MS = 60000;
|
|
248742
249027
|
var init_github_pull_request_cloud = __esm(() => {
|
|
248743
249028
|
init_letta_client();
|
|
248744
249029
|
init_client4();
|
|
@@ -248746,6 +249031,12 @@ var init_github_pull_request_cloud = __esm(() => {
|
|
|
248746
249031
|
init_backend_mode();
|
|
248747
249032
|
init_telemetry();
|
|
248748
249033
|
init_github_pull_request_watch();
|
|
249034
|
+
GitHubPullRequestSnapshotPending = class GitHubPullRequestSnapshotPending extends Error {
|
|
249035
|
+
constructor() {
|
|
249036
|
+
super("Cloud PR snapshot is still cooling down");
|
|
249037
|
+
this.name = "GitHubPullRequestSnapshotPending";
|
|
249038
|
+
}
|
|
249039
|
+
};
|
|
248749
249040
|
});
|
|
248750
249041
|
|
|
248751
249042
|
// src/tools/impl/github-pull-request-diff.ts
|
|
@@ -248773,40 +249064,44 @@ function matchesCurrentFailure(attempt2, currentFailures) {
|
|
|
248773
249064
|
function sameKnownValue(previous, current) {
|
|
248774
249065
|
return current === "UNKNOWN" || previous === current;
|
|
248775
249066
|
}
|
|
248776
|
-
function diffGitHubPullRequestSnapshots(previous, current) {
|
|
249067
|
+
function diffGitHubPullRequestSnapshots(previous, current, notifyOn) {
|
|
248777
249068
|
const events = [];
|
|
249069
|
+
const add2 = (kind, ...lines) => {
|
|
249070
|
+
if (!notifyOn || notifyOn.includes(kind))
|
|
249071
|
+
events.push(...lines);
|
|
249072
|
+
};
|
|
248778
249073
|
const headChanged = previous.headSha !== current.headSha;
|
|
248779
249074
|
if (headChanged) {
|
|
248780
|
-
|
|
249075
|
+
add2("push", `PR head changed from ${shortGitHubPullRequestSha(previous.headSha)} to ${shortGitHubPullRequestSha(current.headSha)}. ${githubPullRequestCheckSummary(current)}; ${githubPullRequestBlockerSummary(current)}.`);
|
|
248781
249076
|
const currentFailures = current.checks.filter((check) => check.phase === "failure");
|
|
248782
249077
|
for (const attempt2 of current.checkAttempts) {
|
|
248783
249078
|
if (attempt2.phase === "failure" && !matchesCurrentFailure(attempt2, currentFailures)) {
|
|
248784
|
-
|
|
249079
|
+
add2("checks", `Check attempt failed on new head before the next poll: ${attempt2.name} (${attempt2.result}).${checkUrl(attempt2)}`);
|
|
248785
249080
|
}
|
|
248786
249081
|
}
|
|
248787
249082
|
}
|
|
248788
249083
|
if (previous.state !== current.state) {
|
|
248789
|
-
|
|
249084
|
+
add2(current.state === "MERGED" ? "merged" : "closed", current.state === "MERGED" ? `PR merged at ${shortGitHubPullRequestSha(current.headSha)}: ${current.ref.url}` : current.state === "CLOSED" ? `PR closed without merge at ${shortGitHubPullRequestSha(current.headSha)}: ${current.ref.url}` : `PR reopened at ${shortGitHubPullRequestSha(current.headSha)}: ${current.ref.url}`);
|
|
248790
249085
|
}
|
|
248791
249086
|
if (previous.isDraft !== current.isDraft) {
|
|
248792
|
-
|
|
249087
|
+
add2("state", current.isDraft ? "PR moved back to draft." : "PR marked ready for review.");
|
|
248793
249088
|
}
|
|
248794
249089
|
const previousComments = new Map(previous.comments.map((comment2) => [comment2.id, comment2]));
|
|
248795
249090
|
for (const comment2 of current.comments) {
|
|
248796
249091
|
const old = previousComments.get(comment2.id);
|
|
248797
249092
|
if (!old) {
|
|
248798
|
-
|
|
249093
|
+
add2("comment", commentEvent("New PR comment", comment2));
|
|
248799
249094
|
} else if (old.updatedAt !== comment2.updatedAt) {
|
|
248800
|
-
|
|
249095
|
+
add2("comment", commentEvent("PR comment edited", comment2));
|
|
248801
249096
|
}
|
|
248802
249097
|
}
|
|
248803
249098
|
const previousReviews = new Map(previous.reviews.map((review) => [review.id, review]));
|
|
248804
249099
|
for (const review of current.reviews) {
|
|
248805
249100
|
const old = previousReviews.get(review.id);
|
|
248806
249101
|
if (!old) {
|
|
248807
|
-
|
|
249102
|
+
add2("review", commentEvent(`New ${review.state.toLowerCase()} review`, review));
|
|
248808
249103
|
} else if (old.state !== review.state || old.updatedAt !== review.updatedAt) {
|
|
248809
|
-
|
|
249104
|
+
add2("review", commentEvent(`Review changed to ${review.state.toLowerCase()}`, review));
|
|
248810
249105
|
}
|
|
248811
249106
|
}
|
|
248812
249107
|
const previousThreads = new Map(previous.reviewThreads.map((thread) => [thread.id, thread]));
|
|
@@ -248814,19 +249109,19 @@ function diffGitHubPullRequestSnapshots(previous, current) {
|
|
|
248814
249109
|
const old = previousThreads.get(thread.id);
|
|
248815
249110
|
if (old && old.isResolved !== thread.isResolved) {
|
|
248816
249111
|
const url2 = thread.comments.at(-1)?.url ?? current.ref.url;
|
|
248817
|
-
|
|
249112
|
+
add2("review", thread.isResolved ? `Review thread resolved: ${url2}` : `Review thread reopened: ${url2}`);
|
|
248818
249113
|
}
|
|
248819
249114
|
const oldComments = new Map(old?.comments.map((comment2) => [comment2.id, comment2]) ?? []);
|
|
248820
249115
|
for (const comment2 of thread.comments) {
|
|
248821
249116
|
const oldComment = oldComments.get(comment2.id);
|
|
248822
249117
|
if (!oldComment) {
|
|
248823
|
-
|
|
249118
|
+
add2("comment", inlineCommentEvent(comment2));
|
|
248824
249119
|
} else {
|
|
248825
249120
|
if (oldComment.updatedAt !== comment2.updatedAt) {
|
|
248826
|
-
|
|
249121
|
+
add2("comment", inlineCommentEvent(comment2, "Inline review comment edited"));
|
|
248827
249122
|
}
|
|
248828
249123
|
if (oldComment.outdated !== comment2.outdated) {
|
|
248829
|
-
|
|
249124
|
+
add2("comment", comment2.outdated ? `Review comment became outdated: ${comment2.url}` : `Review comment is current again: ${comment2.url}`);
|
|
248830
249125
|
}
|
|
248831
249126
|
}
|
|
248832
249127
|
}
|
|
@@ -248839,39 +249134,42 @@ function diffGitHubPullRequestSnapshots(previous, current) {
|
|
|
248839
249134
|
for (const check of current.checks) {
|
|
248840
249135
|
const old = previousChecks.get(check.key);
|
|
248841
249136
|
if (check.phase === "pending" && old && old.phase !== "pending") {
|
|
248842
|
-
|
|
249137
|
+
add2("checks", `Check rerun started: ${check.name}.${checkUrl(check)}`);
|
|
248843
249138
|
}
|
|
248844
249139
|
if ((!old || old.phase !== "failure") && check.phase === "failure") {
|
|
248845
|
-
|
|
249140
|
+
add2("checks", `Check failed: ${check.name} (${check.result}).${checkUrl(check)}`);
|
|
248846
249141
|
} else if (old?.phase === "failure" && (check.phase === "success" || check.phase === "neutral")) {
|
|
248847
|
-
|
|
249142
|
+
add2("checks", `Check recovered: ${check.name} (${check.result}).${checkUrl(check)}`);
|
|
248848
249143
|
}
|
|
248849
249144
|
}
|
|
248850
249145
|
if (previousPending > 0 && currentPending === 0) {
|
|
248851
|
-
|
|
249146
|
+
add2("checks_done", `Current-head checks finished: ${githubPullRequestCheckSummary(current)}.`);
|
|
248852
249147
|
}
|
|
248853
249148
|
const previousAttempts = new Set(previous.checkAttempts.map((attempt2) => attempt2.key));
|
|
248854
249149
|
for (const attempt2 of current.checkAttempts) {
|
|
248855
249150
|
if (attempt2.phase === "failure" && !previousAttempts.has(attempt2.key) && !matchesCurrentFailure(attempt2, currentFailures)) {
|
|
248856
|
-
|
|
249151
|
+
add2("checks", `Check attempt failed before the next poll: ${attempt2.name} (${attempt2.result}).${checkUrl(attempt2)}`);
|
|
248857
249152
|
}
|
|
248858
249153
|
}
|
|
248859
249154
|
}
|
|
248860
249155
|
if (!sameKnownValue(previous.mergeable, current.mergeable)) {
|
|
248861
|
-
|
|
249156
|
+
add2("conflict", current.mergeable === "CONFLICTING" ? "PR now has merge conflicts." : `PR mergeability changed to ${current.mergeable}.`);
|
|
248862
249157
|
}
|
|
248863
249158
|
if (!sameKnownValue(previous.mergeStateStatus, current.mergeStateStatus)) {
|
|
248864
|
-
|
|
249159
|
+
add2("state", `GitHub merge state changed from ${previous.mergeStateStatus} to ${current.mergeStateStatus}.`);
|
|
248865
249160
|
}
|
|
248866
249161
|
if (previous.reviewDecision !== current.reviewDecision) {
|
|
248867
|
-
|
|
249162
|
+
add2("review", `Review decision changed from ${previous.reviewDecision} to ${current.reviewDecision}.`);
|
|
248868
249163
|
}
|
|
248869
249164
|
const wasReady = isGitHubPullRequestReady(previous);
|
|
248870
249165
|
const isReady = isGitHubPullRequestReady(current);
|
|
248871
249166
|
if (!wasReady && isReady) {
|
|
248872
|
-
|
|
249167
|
+
add2("state", `PR is merge-ready on head ${shortGitHubPullRequestSha(current.headSha)} after a fresh read: ${current.ref.url}`);
|
|
248873
249168
|
} else if (wasReady && !isReady) {
|
|
248874
|
-
|
|
249169
|
+
add2("state", `PR is no longer merge-ready on head ${shortGitHubPullRequestSha(current.headSha)}: ${githubPullRequestBlockerSummary(current)}; ${githubPullRequestCheckSummary(current)}.`);
|
|
249170
|
+
}
|
|
249171
|
+
if (headChanged && notifyOn?.includes("checks_done") && pendingGitHubPullRequestChecks(current).length === 0) {
|
|
249172
|
+
add2("checks_done", `Current-head checks finished: ${githubPullRequestCheckSummary(current)}.`);
|
|
248875
249173
|
}
|
|
248876
249174
|
return {
|
|
248877
249175
|
events,
|
|
@@ -248881,6 +249179,130 @@ function diffGitHubPullRequestSnapshots(previous, current) {
|
|
|
248881
249179
|
var MAX_SUMMARY_BODY_CHARS = 240;
|
|
248882
249180
|
var init_github_pull_request_diff = () => {};
|
|
248883
249181
|
|
|
249182
|
+
// src/tools/impl/github-workflow-run.ts
|
|
249183
|
+
import { execFile as execFile17 } from "node:child_process";
|
|
249184
|
+
import { promisify as promisify17 } from "node:util";
|
|
249185
|
+
function parseGitHubWorkflowRunUrl(value) {
|
|
249186
|
+
const url2 = new URL(value);
|
|
249187
|
+
const match3 = url2.pathname.match(/^\/([^/]+)\/([^/]+)\/actions\/runs\/([1-9]\d*)\/?$/);
|
|
249188
|
+
if (url2.protocol !== "https:" || url2.hostname !== "github.com" || url2.username || url2.password || !match3) {
|
|
249189
|
+
throw new Error("WatchPR url must look like https://github.com/owner/repo/actions/runs/123");
|
|
249190
|
+
}
|
|
249191
|
+
const [, owner, repo, id] = match3;
|
|
249192
|
+
if (!owner || !repo || !id || !Number.isSafeInteger(Number(id)))
|
|
249193
|
+
throw new Error("Invalid workflow run URL");
|
|
249194
|
+
return {
|
|
249195
|
+
owner,
|
|
249196
|
+
repo,
|
|
249197
|
+
number: Number(id),
|
|
249198
|
+
url: `https://github.com/${owner}/${repo}/actions/runs/${id}`
|
|
249199
|
+
};
|
|
249200
|
+
}
|
|
249201
|
+
function workflowRunSnapshot(ref, run) {
|
|
249202
|
+
if (!run.status || !run.headSha || !Array.isArray(run.jobs))
|
|
249203
|
+
throw new Error("Invalid workflow run snapshot");
|
|
249204
|
+
return {
|
|
249205
|
+
ref,
|
|
249206
|
+
headSha: run.headSha,
|
|
249207
|
+
state: run.status === "completed" ? "CLOSED" : "OPEN",
|
|
249208
|
+
isDraft: false,
|
|
249209
|
+
mergeable: "UNKNOWN",
|
|
249210
|
+
mergeStateStatus: "UNKNOWN",
|
|
249211
|
+
reviewDecision: "NONE",
|
|
249212
|
+
readinessConfirmed: false,
|
|
249213
|
+
checks: [],
|
|
249214
|
+
checkAttempts: [],
|
|
249215
|
+
comments: [],
|
|
249216
|
+
reviews: [],
|
|
249217
|
+
reviewThreads: [],
|
|
249218
|
+
workflowRun: run
|
|
249219
|
+
};
|
|
249220
|
+
}
|
|
249221
|
+
function describeWorkflowRun(snapshot2) {
|
|
249222
|
+
const run = snapshot2.workflowRun;
|
|
249223
|
+
if (!run)
|
|
249224
|
+
throw new Error("Missing workflow run");
|
|
249225
|
+
const failures = run.jobs.filter((job) => job.conclusion === "failure").map((job) => {
|
|
249226
|
+
const steps = (job.steps ?? []).filter((step) => step.conclusion === "failure").map((step) => step.name);
|
|
249227
|
+
return `${job.name}${steps.length ? ` (${steps.join(", ")})` : ""}`;
|
|
249228
|
+
});
|
|
249229
|
+
return `Workflow run ${snapshot2.ref.url}: ${run.status}${run.conclusion ? ` (${run.conclusion})` : ""}.${failures.length ? ` Failed jobs/steps: ${failures.join("; ")}.` : ""}`;
|
|
249230
|
+
}
|
|
249231
|
+
async function requestRun(ref, signal) {
|
|
249232
|
+
const client = await getClient();
|
|
249233
|
+
try {
|
|
249234
|
+
const response = await client.post("/v1/integrations/github/pull-request-snapshots", {
|
|
249235
|
+
body: {
|
|
249236
|
+
pull_requests: [],
|
|
249237
|
+
workflow_runs: [
|
|
249238
|
+
{ owner: ref.owner, repo: ref.repo, number: ref.number }
|
|
249239
|
+
]
|
|
249240
|
+
},
|
|
249241
|
+
signal,
|
|
249242
|
+
maxRetries: 0,
|
|
249243
|
+
timeout: 30000
|
|
249244
|
+
});
|
|
249245
|
+
return response.workflow_runs?.find((item) => item.owner.toLowerCase() === ref.owner.toLowerCase() && item.repo.toLowerCase() === ref.repo.toLowerCase() && item.number === ref.number);
|
|
249246
|
+
} catch (error4) {
|
|
249247
|
+
if (error4 instanceof APIError && [400, 404, 422, 501].includes(error4.status ?? 0))
|
|
249248
|
+
return;
|
|
249249
|
+
throw error4;
|
|
249250
|
+
}
|
|
249251
|
+
}
|
|
249252
|
+
function createGitHubWorkflowRunFetcher(deps = {}) {
|
|
249253
|
+
let unsupported = false;
|
|
249254
|
+
let hasSnapshot = false;
|
|
249255
|
+
const runGh = deps.runGh ?? (async (args, options) => (await promisify17(execFile17)("gh", args, {
|
|
249256
|
+
...options,
|
|
249257
|
+
timeout: 30000,
|
|
249258
|
+
maxBuffer: 5 * 1024 * 1024,
|
|
249259
|
+
encoding: "utf8",
|
|
249260
|
+
windowsHide: true
|
|
249261
|
+
})).stdout);
|
|
249262
|
+
return async (ref, options) => {
|
|
249263
|
+
if (!unsupported && (deps.isCloud ?? (() => resolveBackendMode() === "api" && isCloudServerUrl()))()) {
|
|
249264
|
+
try {
|
|
249265
|
+
const entry = await (deps.request ?? requestRun)(ref, options.signal);
|
|
249266
|
+
if (entry) {
|
|
249267
|
+
if (entry.inaccessible)
|
|
249268
|
+
throw new Error(`Cloud could not access ${ref.url}`);
|
|
249269
|
+
if (entry.stale || entry.retry_at)
|
|
249270
|
+
throw new GitHubPullRequestSnapshotPending;
|
|
249271
|
+
if (!entry.snapshot)
|
|
249272
|
+
throw new Error("Cloud returned no workflow run snapshot");
|
|
249273
|
+
const snapshot3 = workflowRunSnapshot(ref, entry.snapshot);
|
|
249274
|
+
hasSnapshot = true;
|
|
249275
|
+
return snapshot3;
|
|
249276
|
+
}
|
|
249277
|
+
unsupported = true;
|
|
249278
|
+
} catch (error4) {
|
|
249279
|
+
options.signal?.throwIfAborted();
|
|
249280
|
+
if (hasSnapshot || !(error4 instanceof APIConnectionError || error4 instanceof GitHubPullRequestSnapshotPending))
|
|
249281
|
+
throw error4;
|
|
249282
|
+
}
|
|
249283
|
+
}
|
|
249284
|
+
const run = JSON.parse(await runGh([
|
|
249285
|
+
"run",
|
|
249286
|
+
"view",
|
|
249287
|
+
String(ref.number),
|
|
249288
|
+
"-R",
|
|
249289
|
+
`${ref.owner}/${ref.repo}`,
|
|
249290
|
+
"--json",
|
|
249291
|
+
"status,conclusion,headSha,jobs"
|
|
249292
|
+
], options));
|
|
249293
|
+
const snapshot2 = workflowRunSnapshot(ref, run);
|
|
249294
|
+
hasSnapshot = true;
|
|
249295
|
+
return snapshot2;
|
|
249296
|
+
};
|
|
249297
|
+
}
|
|
249298
|
+
var init_github_workflow_run = __esm(() => {
|
|
249299
|
+
init_letta_client();
|
|
249300
|
+
init_client4();
|
|
249301
|
+
init_server_url();
|
|
249302
|
+
init_backend_mode();
|
|
249303
|
+
init_github_pull_request_cloud();
|
|
249304
|
+
});
|
|
249305
|
+
|
|
248884
249306
|
// src/tools/impl/watch-pr.ts
|
|
248885
249307
|
import { createHash as createHash12, randomUUID as randomUUID48 } from "node:crypto";
|
|
248886
249308
|
import {
|
|
@@ -248945,7 +249367,7 @@ function saveSnapshot(path32, snapshot2) {
|
|
|
248945
249367
|
} catch {}
|
|
248946
249368
|
}
|
|
248947
249369
|
}
|
|
248948
|
-
function resumedChanges(path32, initial2) {
|
|
249370
|
+
function resumedChanges(path32, initial2, notifyOn) {
|
|
248949
249371
|
if (!path32)
|
|
248950
249372
|
return "";
|
|
248951
249373
|
try {
|
|
@@ -248953,7 +249375,7 @@ function resumedChanges(path32, initial2) {
|
|
|
248953
249375
|
const age = Date.now() - saved.savedAt;
|
|
248954
249376
|
if (!Number.isFinite(age) || age < 0 || age > 7 * 24 * 3600000)
|
|
248955
249377
|
return "";
|
|
248956
|
-
const changes = diffGitHubPullRequestSnapshots(saved.snapshot, initial2).events;
|
|
249378
|
+
const changes = diffGitHubPullRequestSnapshots(saved.snapshot, initial2, notifyOn).events;
|
|
248957
249379
|
if (!changes.length)
|
|
248958
249380
|
return "";
|
|
248959
249381
|
let text2 = changes.map((line) => line.length > MONITOR_EVENT_LINE_CHARS ? `${line.slice(0, MONITOR_EVENT_LINE_CHARS)}...(truncated)` : line).join(`
|
|
@@ -248974,9 +249396,11 @@ async function watch_pr(args, deps = {}) {
|
|
|
248974
249396
|
if (typeof args.url !== "string") {
|
|
248975
249397
|
throw new Error("WatchPR url is required");
|
|
248976
249398
|
}
|
|
248977
|
-
const
|
|
249399
|
+
const isRun = args.url.includes("/actions/runs/");
|
|
249400
|
+
const ref = isRun ? parseGitHubWorkflowRunUrl(args.url) : parseGitHubPullRequestUrl(args.url);
|
|
249401
|
+
const describe2 = isRun ? describeWorkflowRun : describeGitHubPullRequestSnapshot;
|
|
248978
249402
|
const cwd2 = getCurrentWorkingDirectory();
|
|
248979
|
-
const fetchSnapshot = deps.fetchSnapshot ?? createGitHubPullRequestSnapshotFetcher();
|
|
249403
|
+
const fetchSnapshot = deps.fetchSnapshot ?? (isRun ? createGitHubWorkflowRunFetcher() : createGitHubPullRequestSnapshotFetcher());
|
|
248980
249404
|
const runtimeContext = getRuntimeContext();
|
|
248981
249405
|
const parentScope = args.parentScope ?? (runtimeContext?.agentId ? {
|
|
248982
249406
|
agentId: runtimeContext.agentId,
|
|
@@ -248985,7 +249409,7 @@ async function watch_pr(args, deps = {}) {
|
|
|
248985
249409
|
const scope = resolveNotificationScope(parentScope);
|
|
248986
249410
|
let snapshotPath;
|
|
248987
249411
|
try {
|
|
248988
|
-
snapshotPath = scope ? join74(resolveGlobalConfigDir(), "cache", "watch-pr", `${createHash12("sha256").update(JSON.stringify([
|
|
249412
|
+
snapshotPath = scope && !isRun ? join74(resolveGlobalConfigDir(), "cache", "watch-pr", `${createHash12("sha256").update(JSON.stringify([
|
|
248989
249413
|
scope.agentId,
|
|
248990
249414
|
scope.conversationId,
|
|
248991
249415
|
ref.owner.toLowerCase(),
|
|
@@ -248995,195 +249419,250 @@ async function watch_pr(args, deps = {}) {
|
|
|
248995
249419
|
} catch {}
|
|
248996
249420
|
const initial2 = await fetchSnapshot(ref, { cwd: cwd2, signal: args.signal });
|
|
248997
249421
|
args.signal?.throwIfAborted();
|
|
248998
|
-
const changesSincePreviousWatch = resumedChanges(snapshotPath, initial2);
|
|
249422
|
+
const changesSincePreviousWatch = resumedChanges(snapshotPath, initial2, args.notify_on);
|
|
249423
|
+
if (isRun && initial2.state !== "OPEN") {
|
|
249424
|
+
return {
|
|
249425
|
+
content: [{ type: "text", text: describe2(initial2) }],
|
|
249426
|
+
taskId: "",
|
|
249427
|
+
url: ref.url,
|
|
249428
|
+
headSha: initial2.headSha,
|
|
249429
|
+
persistent: false
|
|
249430
|
+
};
|
|
249431
|
+
}
|
|
248999
249432
|
if (initial2.state !== "OPEN") {
|
|
249000
249433
|
saveSnapshot(snapshotPath, initial2);
|
|
249001
249434
|
throw new Error(`WatchPR did not start because ${ref.url} is already ${initial2.state.toLowerCase()}.`);
|
|
249002
249435
|
}
|
|
249003
249436
|
assertBackgroundProcessCapacity();
|
|
249004
249437
|
installMonitorProcessExitCleanup();
|
|
249005
|
-
const
|
|
249006
|
-
const outputFile = createBackgroundOutputFile(taskId);
|
|
249007
|
-
const output = deps.createOutputWriter?.(outputFile) ?? new MonitorOutputWriter(outputFile);
|
|
249008
|
-
if (!output.append(`[initial snapshot]
|
|
249009
|
-
${describeGitHubPullRequestSnapshot(initial2)}${changesSincePreviousWatch}
|
|
249010
|
-
`)) {
|
|
249011
|
-
rmSync19(outputFile, { force: true });
|
|
249012
|
-
throw new Error(`WatchPR could not write its output file: ${outputFile}`);
|
|
249013
|
-
}
|
|
249014
|
-
saveSnapshot(snapshotPath, initial2);
|
|
249015
|
-
const actingUserId = getRuntimeActingUserAttribution();
|
|
249016
|
-
const description = `PR ${ref.owner}/${ref.repo}#${ref.number} checks, reviews, and mergeability`;
|
|
249017
|
-
const controller = new AbortController;
|
|
249018
|
-
const secrets2 = {};
|
|
249019
|
-
let processState;
|
|
249438
|
+
const description = isRun ? `Workflow run ${ref.owner}/${ref.repo}#${ref.number}` : `PR ${ref.owner}/${ref.repo}#${ref.number} checks, reviews, and mergeability`;
|
|
249020
249439
|
const persistent = !isManagedCloudRuntime();
|
|
249021
|
-
|
|
249022
|
-
|
|
249023
|
-
|
|
249024
|
-
|
|
249025
|
-
|
|
249026
|
-
|
|
249027
|
-
|
|
249028
|
-
|
|
249029
|
-
|
|
249030
|
-
|
|
249031
|
-
|
|
249032
|
-
|
|
249033
|
-
|
|
249034
|
-
|
|
249035
|
-
|
|
249036
|
-
|
|
249037
|
-
|
|
249440
|
+
return withMonitorState({
|
|
249441
|
+
description,
|
|
249442
|
+
persistent,
|
|
249443
|
+
command: ref.url,
|
|
249444
|
+
kind: "github_pull_request",
|
|
249445
|
+
parentScope,
|
|
249446
|
+
signal: args.signal
|
|
249447
|
+
}, (taskId) => {
|
|
249448
|
+
const outputFile = createBackgroundOutputFile(taskId);
|
|
249449
|
+
const output = deps.createOutputWriter?.(outputFile) ?? new MonitorOutputWriter(outputFile);
|
|
249450
|
+
if (!output.append(`[initial snapshot]
|
|
249451
|
+
${describe2(initial2)}${changesSincePreviousWatch}
|
|
249452
|
+
`)) {
|
|
249453
|
+
rmSync19(outputFile, { force: true });
|
|
249454
|
+
throw new Error(`WatchPR could not write its output file: ${outputFile}`);
|
|
249455
|
+
}
|
|
249456
|
+
saveSnapshot(snapshotPath, initial2);
|
|
249457
|
+
const actingUserId = getRuntimeActingUserAttribution();
|
|
249458
|
+
const controller = new AbortController;
|
|
249459
|
+
const secrets2 = {};
|
|
249460
|
+
let processState;
|
|
249461
|
+
const maxTimeoutMs = getMonitorMaxTimeoutMs();
|
|
249462
|
+
let timeout;
|
|
249463
|
+
const events = createMonitorEventStream({
|
|
249464
|
+
emit(event) {
|
|
249465
|
+
queueMonitorEvent({
|
|
249466
|
+
taskId,
|
|
249467
|
+
event,
|
|
249468
|
+
scope,
|
|
249469
|
+
actingUserId,
|
|
249470
|
+
secrets: secrets2
|
|
249471
|
+
});
|
|
249472
|
+
},
|
|
249473
|
+
stopSource() {
|
|
249474
|
+
if (!processState || processState.status !== "running")
|
|
249475
|
+
return;
|
|
249476
|
+
processState.completionNotificationSuppressed = true;
|
|
249477
|
+
output.append(`
|
|
249038
249478
|
[stopped: output rate too high]
|
|
249039
249479
|
`);
|
|
249040
|
-
|
|
249041
|
-
controller.abort();
|
|
249042
|
-
}
|
|
249043
|
-
});
|
|
249044
|
-
const emit = (lines) => {
|
|
249045
|
-
if (lines.length === 0 || processState.status !== "running")
|
|
249046
|
-
return;
|
|
249047
|
-
const text2 = scrubSecretsFromString(`${lines.join(`
|
|
249048
|
-
`)}
|
|
249049
|
-
`, {});
|
|
249050
|
-
if (!output.append(text2)) {
|
|
249051
|
-
processState.completionNotificationSuppressed = true;
|
|
249052
|
-
markMonitorFinished(taskId, processState, "failed", null);
|
|
249053
|
-
controller.abort();
|
|
249054
|
-
return;
|
|
249055
|
-
}
|
|
249056
|
-
events.onData(text2);
|
|
249057
|
-
};
|
|
249058
|
-
processState = {
|
|
249059
|
-
process: {
|
|
249060
|
-
kill() {
|
|
249061
|
-
clearTimeout(timeout);
|
|
249062
|
-
events.cancel();
|
|
249480
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249063
249481
|
controller.abort();
|
|
249064
249482
|
}
|
|
249065
|
-
}
|
|
249066
|
-
|
|
249067
|
-
|
|
249068
|
-
exitCode: null,
|
|
249069
|
-
startTime: new Date,
|
|
249070
|
-
outputFile,
|
|
249071
|
-
runtimeScope: scope,
|
|
249072
|
-
actingUserId,
|
|
249073
|
-
kind: "monitor",
|
|
249074
|
-
description,
|
|
249075
|
-
monitorSource: "github_pull_request",
|
|
249076
|
-
persistent,
|
|
249077
|
-
secrets: secrets2
|
|
249078
|
-
};
|
|
249079
|
-
backgroundProcesses.set(taskId, processState);
|
|
249080
|
-
notifyBackgroundProcessStateChanged(scope);
|
|
249081
|
-
if (!persistent) {
|
|
249082
|
-
timeout = setTimeout(() => {
|
|
249083
|
-
if (processState.status !== "running")
|
|
249483
|
+
});
|
|
249484
|
+
const emit = (lines) => {
|
|
249485
|
+
if (lines.length === 0 || processState.status !== "running")
|
|
249084
249486
|
return;
|
|
249085
|
-
|
|
249086
|
-
|
|
249487
|
+
const text2 = scrubSecretsFromString(`${lines.join(`
|
|
249488
|
+
`)}
|
|
249489
|
+
`, {});
|
|
249490
|
+
if (!output.append(text2)) {
|
|
249491
|
+
processState.completionNotificationSuppressed = true;
|
|
249492
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249493
|
+
controller.abort();
|
|
249087
249494
|
return;
|
|
249088
|
-
|
|
249089
|
-
|
|
249090
|
-
|
|
249091
|
-
|
|
249092
|
-
|
|
249093
|
-
|
|
249094
|
-
|
|
249095
|
-
|
|
249096
|
-
|
|
249097
|
-
|
|
249098
|
-
|
|
249099
|
-
|
|
249100
|
-
|
|
249101
|
-
|
|
249102
|
-
|
|
249103
|
-
|
|
249104
|
-
|
|
249105
|
-
|
|
249106
|
-
|
|
249107
|
-
|
|
249108
|
-
|
|
249495
|
+
}
|
|
249496
|
+
events.onData(text2);
|
|
249497
|
+
};
|
|
249498
|
+
processState = {
|
|
249499
|
+
process: {
|
|
249500
|
+
kill() {
|
|
249501
|
+
clearTimeout(timeout);
|
|
249502
|
+
events.cancel();
|
|
249503
|
+
controller.abort();
|
|
249504
|
+
}
|
|
249505
|
+
},
|
|
249506
|
+
command: ref.url,
|
|
249507
|
+
status: "running",
|
|
249508
|
+
exitCode: null,
|
|
249509
|
+
startTime: new Date,
|
|
249510
|
+
outputFile,
|
|
249511
|
+
runtimeScope: scope,
|
|
249512
|
+
actingUserId,
|
|
249513
|
+
kind: "monitor",
|
|
249514
|
+
description,
|
|
249515
|
+
monitorSource: "github_pull_request",
|
|
249516
|
+
persistent,
|
|
249517
|
+
secrets: secrets2
|
|
249518
|
+
};
|
|
249519
|
+
backgroundProcesses.set(taskId, processState);
|
|
249520
|
+
notifyBackgroundProcessStateChanged(scope);
|
|
249521
|
+
if (!persistent) {
|
|
249522
|
+
timeout = setTimeout(() => {
|
|
249109
249523
|
if (processState.status !== "running")
|
|
249110
249524
|
return;
|
|
249111
|
-
|
|
249112
|
-
cwd: cwd2,
|
|
249113
|
-
signal: controller.signal
|
|
249114
|
-
});
|
|
249525
|
+
events.finish();
|
|
249115
249526
|
if (processState.status !== "running")
|
|
249116
249527
|
return;
|
|
249117
|
-
|
|
249118
|
-
|
|
249119
|
-
|
|
249120
|
-
|
|
249121
|
-
}
|
|
249122
|
-
|
|
249123
|
-
|
|
249124
|
-
|
|
249125
|
-
|
|
249126
|
-
|
|
249127
|
-
|
|
249128
|
-
|
|
249129
|
-
|
|
249130
|
-
|
|
249131
|
-
|
|
249132
|
-
|
|
249133
|
-
|
|
249134
|
-
|
|
249135
|
-
|
|
249528
|
+
const event = getMonitorTimeoutEvent(maxTimeoutMs, "WatchPR");
|
|
249529
|
+
output.append(`
|
|
249530
|
+
${event}
|
|
249531
|
+
`);
|
|
249532
|
+
queueMonitorEvent({ taskId, event, scope, actingUserId, secrets: secrets2 });
|
|
249533
|
+
processState.completionNotificationSuppressed = true;
|
|
249534
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249535
|
+
processState.process.kill();
|
|
249536
|
+
}, maxTimeoutMs);
|
|
249537
|
+
unrefTimer(timeout);
|
|
249538
|
+
}
|
|
249539
|
+
const wait = deps.wait ?? defaultWait;
|
|
249540
|
+
const now2 = deps.now ?? Date.now;
|
|
249541
|
+
(async () => {
|
|
249542
|
+
let previous = initial2;
|
|
249543
|
+
let lastFreshSnapshotAt = now2();
|
|
249544
|
+
let freshnessNoticeSent = false;
|
|
249545
|
+
let nextPollMs = WATCH_POLL_MS;
|
|
249546
|
+
let failedPolls = 0;
|
|
249547
|
+
let failureStartedAt;
|
|
249548
|
+
let lastNotifiedError;
|
|
249549
|
+
while (processState.status === "running") {
|
|
249550
|
+
try {
|
|
249551
|
+
await wait(controller.signal, nextPollMs);
|
|
249552
|
+
if (processState.status !== "running")
|
|
249553
|
+
return;
|
|
249554
|
+
const current = await fetchSnapshot(ref, {
|
|
249555
|
+
cwd: cwd2,
|
|
249556
|
+
signal: controller.signal
|
|
249557
|
+
});
|
|
249558
|
+
if (processState.status !== "running")
|
|
249559
|
+
return;
|
|
249560
|
+
lastFreshSnapshotAt = now2();
|
|
249561
|
+
if (freshnessNoticeSent) {
|
|
249562
|
+
emit(["WatchPR is receiving PR updates again."]);
|
|
249563
|
+
freshnessNoticeSent = false;
|
|
249564
|
+
}
|
|
249565
|
+
nextPollMs = WATCH_POLL_MS;
|
|
249566
|
+
if (lastNotifiedError !== undefined) {
|
|
249567
|
+
emit([
|
|
249568
|
+
`WatchPR recovered after ${failedPolls} failed poll${failedPolls === 1 ? "" : "s"}.`
|
|
249569
|
+
]);
|
|
249136
249570
|
}
|
|
249137
|
-
|
|
249138
|
-
|
|
249139
|
-
|
|
249140
|
-
|
|
249141
|
-
|
|
249142
|
-
|
|
249143
|
-
|
|
249144
|
-
|
|
249145
|
-
|
|
249146
|
-
|
|
249571
|
+
failedPolls = 0;
|
|
249572
|
+
failureStartedAt = undefined;
|
|
249573
|
+
lastNotifiedError = undefined;
|
|
249574
|
+
const sameHead = current.headSha === previous.headSha;
|
|
249575
|
+
const stableCurrent = { ...current, readinessConfirmed: false };
|
|
249576
|
+
stableCurrent.readinessConfirmed = Boolean(sameHead && hasGitHubPullRequestReadyConditions(previous) && hasGitHubPullRequestReadyConditions(stableCurrent));
|
|
249577
|
+
saveSnapshot(snapshotPath, stableCurrent);
|
|
249578
|
+
const diff2 = isRun ? {
|
|
249579
|
+
events: previous.workflowRun?.status !== current.workflowRun?.status || previous.workflowRun?.conclusion !== current.workflowRun?.conclusion ? [describe2(current)] : [],
|
|
249580
|
+
terminal: current.state !== "OPEN"
|
|
249581
|
+
} : diffGitHubPullRequestSnapshots(previous, stableCurrent, args.notify_on);
|
|
249582
|
+
emit(diff2.events);
|
|
249583
|
+
previous = stableCurrent;
|
|
249584
|
+
if (diff2.terminal) {
|
|
249585
|
+
events.finish();
|
|
249586
|
+
if (processState.status === "running") {
|
|
249587
|
+
markMonitorFinished(taskId, processState, "completed", 0);
|
|
249588
|
+
}
|
|
249589
|
+
return;
|
|
249590
|
+
}
|
|
249591
|
+
} catch (error4) {
|
|
249592
|
+
if (controller.signal.aborted || processState.status !== "running") {
|
|
249593
|
+
return;
|
|
249594
|
+
}
|
|
249595
|
+
if (!freshnessNoticeSent && now2() - lastFreshSnapshotAt >= WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS) {
|
|
249596
|
+
emit([
|
|
249597
|
+
"WatchPR hasn't received fresh PR data for 30 minutes; still watching."
|
|
249598
|
+
]);
|
|
249599
|
+
freshnessNoticeSent = true;
|
|
249600
|
+
}
|
|
249601
|
+
if (error4 instanceof GitHubPullRequestSnapshotPending) {
|
|
249602
|
+
nextPollMs = WATCH_POLL_MS;
|
|
249603
|
+
if (!output.append(`[poll pending] Waiting for fresh PR data
|
|
249147
249604
|
`)) {
|
|
249148
|
-
|
|
249149
|
-
|
|
249150
|
-
|
|
249151
|
-
|
|
249152
|
-
|
|
249153
|
-
|
|
249154
|
-
|
|
249155
|
-
|
|
249605
|
+
processState.completionNotificationSuppressed = true;
|
|
249606
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249607
|
+
controller.abort();
|
|
249608
|
+
return;
|
|
249609
|
+
}
|
|
249610
|
+
continue;
|
|
249611
|
+
}
|
|
249612
|
+
failedPolls += 1;
|
|
249613
|
+
nextPollMs = pollDelayMs(failedPolls);
|
|
249614
|
+
failureStartedAt ??= now2();
|
|
249615
|
+
const message2 = errorText(error4);
|
|
249616
|
+
if (!output.append(`[poll error ${failedPolls}] ${message2}
|
|
249617
|
+
`)) {
|
|
249618
|
+
processState.completionNotificationSuppressed = true;
|
|
249619
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249620
|
+
controller.abort();
|
|
249621
|
+
return;
|
|
249622
|
+
}
|
|
249623
|
+
if (now2() - failureStartedAt >= WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS && message2 !== lastNotifiedError) {
|
|
249624
|
+
emit([
|
|
249625
|
+
`WatchPR could not refresh ${ref.url}: ${message2}. Retrying.`
|
|
249626
|
+
]);
|
|
249627
|
+
lastNotifiedError = message2;
|
|
249628
|
+
}
|
|
249156
249629
|
}
|
|
249157
249630
|
}
|
|
249158
|
-
}
|
|
249159
|
-
|
|
249160
|
-
|
|
249161
|
-
|
|
249162
|
-
|
|
249163
|
-
|
|
249164
|
-
|
|
249165
|
-
|
|
249166
|
-
|
|
249167
|
-
|
|
249168
|
-
|
|
249169
|
-
|
|
249170
|
-
|
|
249171
|
-
|
|
249172
|
-
|
|
249631
|
+
})().catch((error4) => {
|
|
249632
|
+
if (processState.status !== "running")
|
|
249633
|
+
return;
|
|
249634
|
+
emit([
|
|
249635
|
+
`WatchPR stopped after an unexpected error: ${errorText(error4)}`
|
|
249636
|
+
]);
|
|
249637
|
+
events.finish();
|
|
249638
|
+
if (processState.status === "running") {
|
|
249639
|
+
markMonitorFinished(taskId, processState, "failed", null);
|
|
249640
|
+
}
|
|
249641
|
+
}).finally(() => clearTimeout(timeout));
|
|
249642
|
+
return {
|
|
249643
|
+
content: [
|
|
249644
|
+
{
|
|
249645
|
+
type: "text",
|
|
249646
|
+
text: isRun ? `WatchPR started (task ${taskId}). It reports workflow run status changes and completion with conclusion and failed jobs/steps.
|
|
249647
|
+
|
|
249648
|
+
${describe2(initial2)}
|
|
249649
|
+
|
|
249650
|
+
Output file: ${outputFile}` : `WatchPR started (task ${taskId}). ${args.notify_on ? `It will report ${args.notify_on.join(", ")} and watcher errors.` : "It will keep watching after CI finishes and report new failures, reviews, comments, conflicts, head changes, merge-state changes, and watcher errors."} It stops when the PR merges/closes, on TaskStop, or when this session ends.${persistent ? "" : ` A hard ${maxTimeoutMs / 3600000}-hour limit applies in this Cloud sandbox; call WatchPR again to re-arm it, or use Wake or cron for much longer waits.`}
|
|
249173
249651
|
|
|
249174
249652
|
Current state:
|
|
249175
|
-
${
|
|
249653
|
+
${describe2(initial2)}${changesSincePreviousWatch}
|
|
249176
249654
|
|
|
249177
249655
|
Output file: ${outputFile}`
|
|
249178
|
-
|
|
249179
|
-
|
|
249180
|
-
|
|
249181
|
-
|
|
249182
|
-
|
|
249183
|
-
|
|
249184
|
-
|
|
249656
|
+
}
|
|
249657
|
+
],
|
|
249658
|
+
taskId,
|
|
249659
|
+
url: ref.url,
|
|
249660
|
+
headSha: initial2.headSha,
|
|
249661
|
+
persistent
|
|
249662
|
+
};
|
|
249663
|
+
});
|
|
249185
249664
|
}
|
|
249186
|
-
var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS;
|
|
249665
|
+
var WATCH_POLL_MS = 30000, WATCH_MAX_POLL_MS, WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS, WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS;
|
|
249187
249666
|
var init_watch_pr = __esm(() => {
|
|
249188
249667
|
init_runtime_context();
|
|
249189
249668
|
init_secret_substitution();
|
|
@@ -249192,12 +249671,15 @@ var init_watch_pr = __esm(() => {
|
|
|
249192
249671
|
init_github_pull_request_cloud();
|
|
249193
249672
|
init_github_pull_request_diff();
|
|
249194
249673
|
init_github_pull_request_watch();
|
|
249674
|
+
init_github_workflow_run();
|
|
249195
249675
|
init_monitor();
|
|
249196
249676
|
init_monitor_event_stream();
|
|
249677
|
+
init_monitor_state();
|
|
249197
249678
|
init_monitor_timeout();
|
|
249198
249679
|
init_process_manager();
|
|
249199
249680
|
WATCH_MAX_POLL_MS = 5 * 60000;
|
|
249200
249681
|
WATCH_REFRESH_ERROR_NOTIFY_AFTER_MS = 5 * 60000;
|
|
249682
|
+
WATCH_FRESH_SNAPSHOT_NOTIFY_AFTER_MS = 30 * 60000;
|
|
249201
249683
|
});
|
|
249202
249684
|
|
|
249203
249685
|
// src/tools/workflow/sdk-loader.ts
|
|
@@ -250785,57 +251267,6 @@ var init_Monitor2 = __esm(() => {
|
|
|
250785
251267
|
},
|
|
250786
251268
|
args: {
|
|
250787
251269
|
description: "Optional input exposed to script as args."
|
|
250788
|
-
},
|
|
250789
|
-
url: {
|
|
250790
|
-
type: "string",
|
|
250791
|
-
description: "Public http(s) URL that Letta Cloud polls with GET. By default it notifies only when the HTTP status or body changes; use select and match to narrow that. timeout_ms defaults to 24 hours here, up to 7 days. Cannot be combined with command, ws, or script."
|
|
250792
|
-
},
|
|
250793
|
-
interval_seconds: {
|
|
250794
|
-
type: "integer",
|
|
250795
|
-
minimum: 60,
|
|
250796
|
-
default: 60,
|
|
250797
|
-
description: "Seconds between polls of url."
|
|
250798
|
-
},
|
|
250799
|
-
headers: {
|
|
250800
|
-
type: "object",
|
|
250801
|
-
additionalProperties: {
|
|
250802
|
-
type: "string"
|
|
250803
|
-
},
|
|
250804
|
-
description: `Request headers for url, at most 10. Reference agent secrets as $NAME, as in shell commands, e.g. {"PRIVATE-TOKEN": "$GITLAB_TOKEN"} or {"Authorization": "Bearer $CI_TOKEN"}. Cloud fills them in on every poll; the value is never sent from here. Credential headers must use a secret reference. Headers are dropped if a redirect leaves the URL's origin.`
|
|
250805
|
-
},
|
|
250806
|
-
select: {
|
|
250807
|
-
type: "string",
|
|
250808
|
-
description: "For url: a dot-separated path into the JSON response (numbers index arrays), e.g. 0.status. Only that value is compared and reported, so unrelated fields changing does not notify."
|
|
250809
|
-
},
|
|
250810
|
-
match: {
|
|
250811
|
-
type: "object",
|
|
250812
|
-
properties: {
|
|
250813
|
-
equals: {
|
|
250814
|
-
type: "array",
|
|
250815
|
-
items: {
|
|
250816
|
-
type: "string"
|
|
250817
|
-
},
|
|
250818
|
-
description: "Matches when the value is one of these."
|
|
250819
|
-
},
|
|
250820
|
-
contains: {
|
|
250821
|
-
type: "string",
|
|
250822
|
-
description: "Matches when the value contains this text."
|
|
250823
|
-
},
|
|
250824
|
-
gt: {
|
|
250825
|
-
type: "number",
|
|
250826
|
-
description: "Matches when the value is a number greater than this."
|
|
250827
|
-
},
|
|
250828
|
-
lt: {
|
|
250829
|
-
type: "number",
|
|
250830
|
-
description: "Matches when the value is a number less than this."
|
|
250831
|
-
}
|
|
250832
|
-
},
|
|
250833
|
-
additionalProperties: false,
|
|
250834
|
-
description: 'For url: notify when the compared value starts to meet every given test, instead of on every change. The first response is checked too, and a value that keeps matching does not notify again. List every terminal state, e.g. equals ["success", "failed", "canceled"].'
|
|
250835
|
-
},
|
|
250836
|
-
stop_on_match: {
|
|
250837
|
-
type: "boolean",
|
|
250838
|
-
description: "For url with match: stop after the first match notice."
|
|
250839
251270
|
}
|
|
250840
251271
|
},
|
|
250841
251272
|
required: ["description"],
|
|
@@ -251290,7 +251721,26 @@ var init_WatchPR2 = __esm(() => {
|
|
|
251290
251721
|
properties: {
|
|
251291
251722
|
url: {
|
|
251292
251723
|
type: "string",
|
|
251293
|
-
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."
|
|
251724
|
+
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."
|
|
251725
|
+
},
|
|
251726
|
+
notify_on: {
|
|
251727
|
+
type: "array",
|
|
251728
|
+
minItems: 1,
|
|
251729
|
+
items: {
|
|
251730
|
+
type: "string",
|
|
251731
|
+
enum: [
|
|
251732
|
+
"merged",
|
|
251733
|
+
"closed",
|
|
251734
|
+
"conflict",
|
|
251735
|
+
"checks_done",
|
|
251736
|
+
"review",
|
|
251737
|
+
"comment",
|
|
251738
|
+
"push",
|
|
251739
|
+
"state",
|
|
251740
|
+
"checks"
|
|
251741
|
+
]
|
|
251742
|
+
},
|
|
251743
|
+
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."
|
|
251294
251744
|
}
|
|
251295
251745
|
},
|
|
251296
251746
|
required: ["url"],
|
|
@@ -267482,9 +267932,10 @@ async function prepareToolExecutionContextForScope(params) {
|
|
|
267482
267932
|
} = params;
|
|
267483
267933
|
const clientToolset = mergeClientToolsetFields(requestClientToolset, getStoredClientPreferences(agentId, conversationId).toolset);
|
|
267484
267934
|
const backend3 = getBackend();
|
|
267485
|
-
const
|
|
267935
|
+
const readScopeState = params.readScopeState ?? ((read2) => read2());
|
|
267936
|
+
const agent = agentId ? cachedAgent ?? await readScopeState(() => backend3.retrieveAgent(agentId)) : null;
|
|
267486
267937
|
const agentTarget = modelTargetFromCarrier(agent);
|
|
267487
|
-
const conversationTarget = conversationId && conversationId !== "default" ? modelTargetFromCarrier(await backend3.retrieveConversation(conversationId)) : { model: null, providerType: null, openAICompatibleProxy: false };
|
|
267938
|
+
const conversationTarget = conversationId && conversationId !== "default" ? modelTargetFromCarrier(await readScopeState(() => backend3.retrieveConversation(conversationId))) : { model: null, providerType: null, openAICompatibleProxy: false };
|
|
267488
267939
|
const explicitModel = normalizeModelHandle(overrideModel);
|
|
267489
267940
|
const cachedModel = normalizeModelHandle(cachedEffectiveModel);
|
|
267490
267941
|
const effectiveModel = explicitModel ?? cachedModel ?? conversationTarget.model ?? agentTarget.model;
|
|
@@ -439077,6 +439528,7 @@ async function syncMemfsForAgent(agentId) {
|
|
|
439077
439528
|
debugWarn("memfs-sync", `Agent ${agentId} is missing the memfs tag on Letta Cloud — repairing (auto-enabling memfs).`);
|
|
439078
439529
|
await applyMemfsFlags2(agentId, true, {
|
|
439079
439530
|
pullOnExistingRepo: true,
|
|
439531
|
+
throwOnPullFailure: true,
|
|
439080
439532
|
agentTags: agent.tags ?? []
|
|
439081
439533
|
});
|
|
439082
439534
|
debugLog("memfs-sync", `Memfs repair complete for agent ${agentId}`);
|
|
@@ -439085,19 +439537,26 @@ async function syncMemfsForAgent(agentId) {
|
|
|
439085
439537
|
debugLog("memfs-sync", `Syncing memfs for agent ${agentId}`);
|
|
439086
439538
|
await applyMemfsFlags2(agentId, undefined, {
|
|
439087
439539
|
pullOnExistingRepo: true,
|
|
439540
|
+
throwOnPullFailure: true,
|
|
439088
439541
|
agentTags: agent.tags,
|
|
439089
439542
|
skipPromptUpdate: true
|
|
439090
439543
|
});
|
|
439091
439544
|
debugLog("memfs-sync", `Memfs sync complete for agent ${agentId}`);
|
|
439092
439545
|
}
|
|
439093
439546
|
async function ensureMemfsSyncedForAgent(listener, agentId) {
|
|
439547
|
+
if (isMemoryUnavailable(agentId))
|
|
439548
|
+
return false;
|
|
439094
439549
|
const existing = listener.memfsSyncedAgents.get(agentId);
|
|
439095
439550
|
if (existing) {
|
|
439096
439551
|
return existing;
|
|
439097
439552
|
}
|
|
439098
439553
|
const promise2 = syncMemfsForAgent(agentId).then(() => true, (err) => {
|
|
439099
439554
|
debugWarn("memfs-sync", `Failed to sync memfs for agent ${agentId}: ${err instanceof Error ? err.message : String(err)}`);
|
|
439100
|
-
|
|
439555
|
+
if (isMemoryAccessRefusal(err)) {
|
|
439556
|
+
markMemoryUnavailable(agentId);
|
|
439557
|
+
} else {
|
|
439558
|
+
listener.memfsSyncedAgents.delete(agentId);
|
|
439559
|
+
}
|
|
439101
439560
|
return false;
|
|
439102
439561
|
});
|
|
439103
439562
|
listener.memfsSyncedAgents.set(agentId, promise2);
|
|
@@ -439105,6 +439564,7 @@ async function ensureMemfsSyncedForAgent(listener, agentId) {
|
|
|
439105
439564
|
}
|
|
439106
439565
|
var init_memfs_sync = __esm(() => {
|
|
439107
439566
|
init_debug();
|
|
439567
|
+
init_memory_access();
|
|
439108
439568
|
});
|
|
439109
439569
|
|
|
439110
439570
|
// src/websocket/listener/mod-adapter.ts
|
|
@@ -440893,6 +441353,46 @@ var init_recovery = __esm(() => {
|
|
|
440893
441353
|
init_recovery_debug();
|
|
440894
441354
|
});
|
|
440895
441355
|
|
|
441356
|
+
// src/websocket/listener/recovery-read.ts
|
|
441357
|
+
async function retryApprovalRecoveryRead(read2, assertCurrent, signal) {
|
|
441358
|
+
for (let attempt2 = 0;; attempt2++) {
|
|
441359
|
+
assertCurrent();
|
|
441360
|
+
try {
|
|
441361
|
+
const result3 = await read2();
|
|
441362
|
+
assertCurrent();
|
|
441363
|
+
return result3;
|
|
441364
|
+
} catch (error4) {
|
|
441365
|
+
assertCurrent();
|
|
441366
|
+
const detail = extractConflictDetail(error4);
|
|
441367
|
+
if (attempt2 >= LLM_API_ERROR_MAX_RETRIES || !shouldRetryPreStreamTransientError({
|
|
441368
|
+
status: error4 instanceof APIError ? error4.status : undefined,
|
|
441369
|
+
detail
|
|
441370
|
+
}))
|
|
441371
|
+
throw error4;
|
|
441372
|
+
await new Promise((resolve37) => {
|
|
441373
|
+
const done = () => {
|
|
441374
|
+
clearTimeout(timer);
|
|
441375
|
+
signal.removeEventListener("abort", done);
|
|
441376
|
+
resolve37();
|
|
441377
|
+
};
|
|
441378
|
+
const timer = setTimeout(done, getRetryDelayMs2({
|
|
441379
|
+
category: "transient_provider",
|
|
441380
|
+
attempt: attempt2 + 1,
|
|
441381
|
+
detail
|
|
441382
|
+
}));
|
|
441383
|
+
signal.addEventListener("abort", done, { once: true });
|
|
441384
|
+
if (signal.aborted)
|
|
441385
|
+
done();
|
|
441386
|
+
});
|
|
441387
|
+
}
|
|
441388
|
+
}
|
|
441389
|
+
}
|
|
441390
|
+
var init_recovery_read = __esm(() => {
|
|
441391
|
+
init_error();
|
|
441392
|
+
init_turn_recovery_policy();
|
|
441393
|
+
init_constants3();
|
|
441394
|
+
});
|
|
441395
|
+
|
|
440896
441396
|
// src/websocket/listener/skill-injection.ts
|
|
440897
441397
|
function injectQueuedSkillContent(messages, context3) {
|
|
440898
441398
|
const skillContents = consumeQueuedSkillContent();
|
|
@@ -441058,7 +441558,7 @@ async function tryResumeBusyConversationStream(params) {
|
|
|
441058
441558
|
async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
|
|
441059
441559
|
if (!runtime.agentId && runtime.conversationId === "default")
|
|
441060
441560
|
return null;
|
|
441061
|
-
const getResumeDataImpl = deps.getResumeData ?? getResumeDataFromBackend;
|
|
441561
|
+
const getResumeDataImpl = (...args) => retryApprovalRecoveryRead(() => (deps.getResumeData ?? getResumeDataFromBackend)(...args), assertCurrentTurnLease, turnLease.signal);
|
|
441062
441562
|
const prepareToolExecutionContext = deps.prepareToolExecutionContext ?? prepareToolExecutionContextForScope;
|
|
441063
441563
|
const sendApprovalContinuation = deps.sendApprovalContinuation ?? sendApprovalContinuationWithRetry;
|
|
441064
441564
|
const drainRecoveryStream = deps.drainRecoveryStream ?? drainRecoveryStreamWithEmission;
|
|
@@ -441071,10 +441571,10 @@ async function resolveStaleApprovals(runtime, socket, turnLease, deps = {}) {
|
|
|
441071
441571
|
const backend3 = getBackend();
|
|
441072
441572
|
let agent;
|
|
441073
441573
|
try {
|
|
441074
|
-
agent = await retrieveResumeState(runtime.agentId, runtime.conversationId, {
|
|
441574
|
+
agent = await retryApprovalRecoveryRead(() => retrieveResumeState(runtime.agentId, runtime.conversationId, {
|
|
441075
441575
|
retrieveAgent: deps.retrieveAgent ?? backend3.retrieveAgent.bind(backend3),
|
|
441076
441576
|
retrieveConversation: deps.retrieveConversation ?? backend3.retrieveConversation.bind(backend3)
|
|
441077
|
-
});
|
|
441577
|
+
}), assertCurrentTurnLease, turnLease.signal);
|
|
441078
441578
|
} catch (err) {
|
|
441079
441579
|
assertCurrentTurnLease();
|
|
441080
441580
|
if (isBackendNotFoundError2(err)) {
|
|
@@ -441550,6 +442050,7 @@ var init_send = __esm(() => {
|
|
|
441550
442050
|
init_protocol_outbound();
|
|
441551
442051
|
init_recorded_tool_results();
|
|
441552
442052
|
init_recovery();
|
|
442053
|
+
init_recovery_read();
|
|
441553
442054
|
init_skill_injection();
|
|
441554
442055
|
init_turn_input_state();
|
|
441555
442056
|
init_turn_status();
|
|
@@ -444888,7 +445389,7 @@ async function runListenerTurnCleanup(params) {
|
|
|
444888
445389
|
await runPostTurnMemorySync({
|
|
444889
445390
|
conversationId,
|
|
444890
445391
|
agentId,
|
|
444891
|
-
isEnabled: (id) => settingsManager.isMemfsEnabled(id),
|
|
445392
|
+
isEnabled: (id) => !isMemoryUnavailable(id) && settingsManager.isMemfsEnabled(id),
|
|
444892
445393
|
debugLabel: "Post-turn listener memory sync",
|
|
444893
445394
|
onMemoryPushed: () => {
|
|
444894
445395
|
const transport3 = runtime.listener.transport ?? runtime.listener.socket;
|
|
@@ -444906,6 +445407,7 @@ async function runListenerTurnCleanup(params) {
|
|
|
444906
445407
|
var init_turn_cleanup = __esm(() => {
|
|
444907
445408
|
init_memory_git_sync();
|
|
444908
445409
|
init_settings_manager();
|
|
445410
|
+
init_memory_access();
|
|
444909
445411
|
init_channel_runtime_tools();
|
|
444910
445412
|
init_connection();
|
|
444911
445413
|
init_permission_mode();
|
|
@@ -445622,12 +446124,12 @@ function rowToolCalls(row, index, diagnostics2) {
|
|
|
445622
446124
|
}
|
|
445623
446125
|
return calls;
|
|
445624
446126
|
}
|
|
445625
|
-
function
|
|
446127
|
+
function contentText4(content) {
|
|
445626
446128
|
if (typeof content === "string") {
|
|
445627
446129
|
if (content.startsWith(CONTENT_JSON_PREFIX)) {
|
|
445628
446130
|
const encoded = content.slice(CONTENT_JSON_PREFIX.length);
|
|
445629
446131
|
try {
|
|
445630
|
-
return
|
|
446132
|
+
return contentText4(JSON.parse(encoded));
|
|
445631
446133
|
} catch {
|
|
445632
446134
|
return encoded;
|
|
445633
446135
|
}
|
|
@@ -445713,7 +446215,7 @@ var init_hermes = __esm(() => {
|
|
|
445713
446215
|
});
|
|
445714
446216
|
};
|
|
445715
446217
|
if (row.role === "user") {
|
|
445716
|
-
const content =
|
|
446218
|
+
const content = contentText4(row.content);
|
|
445717
446219
|
if (content) {
|
|
445718
446220
|
emit({
|
|
445719
446221
|
type: "message",
|
|
@@ -445733,7 +446235,7 @@ var init_hermes = __esm(() => {
|
|
|
445733
446235
|
...timestamp ? { timestamp } : {}
|
|
445734
446236
|
});
|
|
445735
446237
|
}
|
|
445736
|
-
const content =
|
|
446238
|
+
const content = contentText4(row.content);
|
|
445737
446239
|
if (content) {
|
|
445738
446240
|
emit({
|
|
445739
446241
|
type: "message",
|
|
@@ -445756,7 +446258,7 @@ var init_hermes = __esm(() => {
|
|
|
445756
446258
|
if (row.role === "tool") {
|
|
445757
446259
|
emit({
|
|
445758
446260
|
type: "tool_result",
|
|
445759
|
-
content:
|
|
446261
|
+
content: contentText4(row.content),
|
|
445760
446262
|
...typeof row.tool_call_id === "string" && row.tool_call_id ? { callId: row.tool_call_id } : {},
|
|
445761
446263
|
...timestamp ? { timestamp } : {}
|
|
445762
446264
|
});
|
|
@@ -449017,11 +449519,11 @@ import { randomUUID as randomUUID54 } from "node:crypto";
|
|
|
449017
449519
|
import { existsSync as existsSync62 } from "node:fs";
|
|
449018
449520
|
import { mkdir as mkdir13 } from "node:fs/promises";
|
|
449019
449521
|
import { dirname as dirname37, isAbsolute as isAbsolute26, join as join97, resolve as resolve37 } from "node:path";
|
|
449020
|
-
import { promisify as
|
|
449522
|
+
import { promisify as promisify18 } from "node:util";
|
|
449021
449523
|
async function runGit4(cwd2, args) {
|
|
449022
449524
|
try {
|
|
449023
449525
|
const allArgs = [...GIT_DISABLE_COMMIT_SIGNING_ARGS, ...args];
|
|
449024
|
-
const { stdout, stderr } = await
|
|
449526
|
+
const { stdout, stderr } = await execFile18("git", allArgs, {
|
|
449025
449527
|
cwd: cwd2,
|
|
449026
449528
|
env: {
|
|
449027
449529
|
...process.env,
|
|
@@ -449390,7 +449892,7 @@ async function finalizeReflectionMemoryWorktreeUnlocked(worktree, options) {
|
|
|
449390
449892
|
async function finalizeReflectionMemoryWorktree(worktree, options) {
|
|
449391
449893
|
return withMemoryOperation(worktree.parentMemoryDir, () => finalizeReflectionMemoryWorktreeUnlocked(worktree, options));
|
|
449392
449894
|
}
|
|
449393
|
-
var
|
|
449895
|
+
var execFile18, GIT_TIMEOUT_MS = 30000, HARNESS_GIT_ENV;
|
|
449394
449896
|
var init_memory_worktree = __esm(() => {
|
|
449395
449897
|
init_memory_auth();
|
|
449396
449898
|
init_memory_git();
|
|
@@ -449398,7 +449900,7 @@ var init_memory_worktree = __esm(() => {
|
|
|
449398
449900
|
init_memory_operation();
|
|
449399
449901
|
init_memfs_git_proxy();
|
|
449400
449902
|
init_debug();
|
|
449401
|
-
|
|
449903
|
+
execFile18 = promisify18(execFileCb3);
|
|
449402
449904
|
HARNESS_GIT_ENV = {
|
|
449403
449905
|
GIT_AUTHOR_NAME: "Letta Code",
|
|
449404
449906
|
GIT_AUTHOR_EMAIL: "noreply@letta.com",
|
|
@@ -451184,6 +451686,10 @@ async function prepareListenerTurn(params) {
|
|
|
451184
451686
|
excludeInteractiveTools: msg.excludeInteractiveTools
|
|
451185
451687
|
}, toolOwner.toolPolicy);
|
|
451186
451688
|
const preparedToolContext = await prepareToolExecutionContextForScope({
|
|
451689
|
+
readScopeState: (read2) => retryApprovalRecoveryRead(read2, () => {
|
|
451690
|
+
if (isInterrupted())
|
|
451691
|
+
throw new Error("Cancelled by user");
|
|
451692
|
+
}, turnLease.signal),
|
|
451187
451693
|
connectionId: executionConnectionId,
|
|
451188
451694
|
environmentDeviceId,
|
|
451189
451695
|
agentId,
|
|
@@ -451284,6 +451790,7 @@ var init_turn_setup = __esm(() => {
|
|
|
451284
451790
|
init_image_policy();
|
|
451285
451791
|
init_interrupts();
|
|
451286
451792
|
init_mod_adapter2();
|
|
451793
|
+
init_recovery_read();
|
|
451287
451794
|
init_runtime6();
|
|
451288
451795
|
init_turn_events();
|
|
451289
451796
|
init_turn_input_state();
|
|
@@ -452531,7 +453038,7 @@ var init_inbound_dispatch = __esm(() => {
|
|
|
452531
453038
|
});
|
|
452532
453039
|
|
|
452533
453040
|
// src/utils/machine-metadata.ts
|
|
452534
|
-
import { execFile as
|
|
453041
|
+
import { execFile as execFile19 } from "node:child_process";
|
|
452535
453042
|
import { readFile as readFile25 } from "node:fs/promises";
|
|
452536
453043
|
import { cpus, totalmem } from "node:os";
|
|
452537
453044
|
function getMachineMetadata() {
|
|
@@ -452549,7 +453056,7 @@ function localSources() {
|
|
|
452549
453056
|
memoryBytes: Math.min(totalmem(), limit4 || Number.POSITIVE_INFINITY),
|
|
452550
453057
|
read: (path41, signal) => readFile25(path41, { encoding: "utf8", signal }),
|
|
452551
453058
|
run: (command, args, signal) => new Promise((resolve38, reject2) => {
|
|
452552
|
-
|
|
453059
|
+
execFile19(command, args, {
|
|
452553
453060
|
encoding: "utf8",
|
|
452554
453061
|
signal,
|
|
452555
453062
|
killSignal: "SIGKILL",
|
|
@@ -453210,7 +453717,6 @@ async function completeInitialConnectionStartup(listener, connection, transport3
|
|
|
453210
453717
|
async function replaySubscribedConnectionState(listener, transport3, runtime, scope, options = {}) {
|
|
453211
453718
|
const connection = findListenerConnectionByTransport(listener, transport3);
|
|
453212
453719
|
const isCurrent = () => !connection || listener.connections.get(connection.id) === connection && (connection.writer === transport3 || connection.streamWriter === transport3) && !connection.cancellation.signal.aborted;
|
|
453213
|
-
await (options.refreshGitContext ?? refreshDeviceGitContext)(listener, scope);
|
|
453214
453720
|
if (!isCurrent())
|
|
453215
453721
|
return;
|
|
453216
453722
|
if (connection) {
|
|
@@ -453222,12 +453728,28 @@ async function replaySubscribedConnectionState(listener, transport3, runtime, sc
|
|
|
453222
453728
|
if (!isCurrent())
|
|
453223
453729
|
return;
|
|
453224
453730
|
}
|
|
453731
|
+
const gitContextBefore = JSON.stringify(buildDeviceStatus(listener, scope).git_context);
|
|
453225
453732
|
emitStateSync(transport3, listener, scope, {
|
|
453226
453733
|
forceDeviceStatus: options.forceDeviceStatus,
|
|
453227
453734
|
...connection ? { routing: toListenerConnection(connection.id) } : {}
|
|
453228
453735
|
});
|
|
453736
|
+
(async () => {
|
|
453737
|
+
await (options.refreshGitContext ?? refreshDeviceGitContext)(listener, scope);
|
|
453738
|
+
if (!isCurrent())
|
|
453739
|
+
return;
|
|
453740
|
+
if (JSON.stringify(buildDeviceStatus(listener, scope).git_context) === gitContextBefore)
|
|
453741
|
+
return;
|
|
453742
|
+
emitDeviceStatusUpdate(transport3, listener, scope, connection ? toListenerConnection(connection.id) : undefined);
|
|
453743
|
+
})().catch((error4) => {
|
|
453744
|
+
trackBoundaryError({
|
|
453745
|
+
errorType: "listener_git_context_refresh_failed",
|
|
453746
|
+
error: error4,
|
|
453747
|
+
context: "listener_state_replay"
|
|
453748
|
+
});
|
|
453749
|
+
});
|
|
453229
453750
|
}
|
|
453230
453751
|
var init_connection_state_sync = __esm(() => {
|
|
453752
|
+
init_error_reporting();
|
|
453231
453753
|
init_approval();
|
|
453232
453754
|
init_connection();
|
|
453233
453755
|
init_protocol_outbound();
|
|
@@ -453593,7 +454115,7 @@ var init_control_inputs = __esm(() => {
|
|
|
453593
454115
|
});
|
|
453594
454116
|
|
|
453595
454117
|
// src/websocket/listener/grep-in-files.ts
|
|
453596
|
-
import { execFile as
|
|
454118
|
+
import { execFile as execFile20 } from "node:child_process";
|
|
453597
454119
|
import { createRequire as createRequire8 } from "node:module";
|
|
453598
454120
|
import * as path42 from "node:path";
|
|
453599
454121
|
import { fileURLToPath as fileURLToPath10 } from "node:url";
|
|
@@ -453649,7 +454171,7 @@ async function runGrepInFiles(args) {
|
|
|
453649
454171
|
}
|
|
453650
454172
|
function runRipgrep2(rgArgs) {
|
|
453651
454173
|
return new Promise((resolve38, reject2) => {
|
|
453652
|
-
const child =
|
|
454174
|
+
const child = execFile20(rgPath, rgArgs, {
|
|
453653
454175
|
maxBuffer: 50 * 1024 * 1024,
|
|
453654
454176
|
windowsHide: true
|
|
453655
454177
|
}, (error4, stdout, _stderr) => {
|
|
@@ -458796,8 +459318,8 @@ var init_cron3 = __esm(() => {
|
|
|
458796
459318
|
});
|
|
458797
459319
|
|
|
458798
459320
|
// src/websocket/listener/commands/git-branches.ts
|
|
458799
|
-
import { execFile as
|
|
458800
|
-
import { promisify as
|
|
459321
|
+
import { execFile as execFile21 } from "node:child_process";
|
|
459322
|
+
import { promisify as promisify19 } from "node:util";
|
|
458801
459323
|
function handleGitBranchCommand(parsed, context3) {
|
|
458802
459324
|
const { socket, runtime, safeSocketSend, runDetachedListenerTask: runDetachedListenerTask2 } = context3;
|
|
458803
459325
|
if (isSearchBranchesCommand(parsed)) {
|
|
@@ -458805,7 +459327,7 @@ function handleGitBranchCommand(parsed, context3) {
|
|
|
458805
459327
|
try {
|
|
458806
459328
|
const cwd2 = parsed.cwd ?? getBootWorkingDirectory(runtime);
|
|
458807
459329
|
const maxResults = parsed.max_results ?? 20;
|
|
458808
|
-
const execFileAsync12 =
|
|
459330
|
+
const execFileAsync12 = promisify19(execFile21);
|
|
458809
459331
|
const { stdout } = await execFileAsync12("git", ["branch", "-a", "--format=%(refname:short)\t%(HEAD)"], {
|
|
458810
459332
|
cwd: cwd2,
|
|
458811
459333
|
encoding: "utf-8",
|
|
@@ -458845,7 +459367,7 @@ function handleGitBranchCommand(parsed, context3) {
|
|
|
458845
459367
|
runDetachedListenerTask2("checkout_branch", async () => {
|
|
458846
459368
|
try {
|
|
458847
459369
|
const cwd2 = parsed.cwd ?? getBootWorkingDirectory(runtime);
|
|
458848
|
-
const execFileAsync12 =
|
|
459370
|
+
const execFileAsync12 = promisify19(execFile21);
|
|
458849
459371
|
const args = parsed.create ? ["checkout", "-b", parsed.branch] : ["checkout", parsed.branch];
|
|
458850
459372
|
await execFileAsync12("git", args, {
|
|
458851
459373
|
cwd: cwd2,
|
|
@@ -459154,8 +459676,8 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459154
459676
|
runDetachedListenerTask2("memory_history", async () => {
|
|
459155
459677
|
const { getScopedMemoryFilesystemRoot: getScopedMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
459156
459678
|
const { execFile: execFileCb4 } = await import("node:child_process");
|
|
459157
|
-
const { promisify:
|
|
459158
|
-
const execFileAsync12 =
|
|
459679
|
+
const { promisify: promisify20 } = await import("node:util");
|
|
459680
|
+
const execFileAsync12 = promisify20(execFileCb4);
|
|
459159
459681
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459160
459682
|
const limit4 = parsed.limit ?? 50;
|
|
459161
459683
|
const gitArgs = ["log", `--max-count=${limit4}`, "--format=%H|%s|%aI|%an"];
|
|
@@ -459190,8 +459712,8 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459190
459712
|
runDetachedListenerTask2("memory_file_at_ref", async () => {
|
|
459191
459713
|
const { getScopedMemoryFilesystemRoot: getScopedMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
459192
459714
|
const { execFile: execFileCb4 } = await import("node:child_process");
|
|
459193
|
-
const { promisify:
|
|
459194
|
-
const execFileAsync12 =
|
|
459715
|
+
const { promisify: promisify20 } = await import("node:util");
|
|
459716
|
+
const execFileAsync12 = promisify20(execFileCb4);
|
|
459195
459717
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459196
459718
|
try {
|
|
459197
459719
|
const { stdout } = await execFileAsync12("git", ["show", `${parsed.ref}:${parsed.file_path}`], { cwd: memoryRoot, timeout: 1e4 });
|
|
@@ -459221,8 +459743,8 @@ function handleMemoryProtocolCommand(parsed, context3) {
|
|
|
459221
459743
|
runDetachedListenerTask2("memory_commit_diff", async () => {
|
|
459222
459744
|
const { getScopedMemoryFilesystemRoot: getScopedMemoryFilesystemRoot2 } = await Promise.resolve().then(() => (init_memory_filesystem2(), exports_memory_filesystem));
|
|
459223
459745
|
const { execFile: execFileCb4 } = await import("node:child_process");
|
|
459224
|
-
const { promisify:
|
|
459225
|
-
const execFileAsync12 =
|
|
459746
|
+
const { promisify: promisify20 } = await import("node:util");
|
|
459747
|
+
const execFileAsync12 = promisify20(execFileCb4);
|
|
459226
459748
|
const memoryRoot = getScopedMemoryFilesystemRoot2(parsed.agent_id);
|
|
459227
459749
|
try {
|
|
459228
459750
|
const { stdout } = await execFileAsync12("git", ["show", parsed.sha, "--format=", "--no-color"], { cwd: memoryRoot, timeout: 1e4 });
|
|
@@ -459547,12 +460069,14 @@ var init_memory5 = __esm(() => {
|
|
|
459547
460069
|
function createMemfsSyncedTaskRunner(parsed, runtime, runDetachedListenerTask2) {
|
|
459548
460070
|
const command = parsed;
|
|
459549
460071
|
const agentId = command.agent_id;
|
|
459550
|
-
if (typeof agentId !== "string" || command.type === "enable_memfs") {
|
|
460072
|
+
if (typeof agentId !== "string" || command.type === "enable_memfs" && !isMemoryUnavailable(agentId)) {
|
|
459551
460073
|
return runDetachedListenerTask2;
|
|
459552
460074
|
}
|
|
459553
460075
|
return (commandName, task2) => {
|
|
459554
460076
|
runDetachedListenerTask2(commandName, async () => {
|
|
459555
|
-
await ensureMemfsSyncedForAgent(runtime, agentId)
|
|
460077
|
+
if (!await ensureMemfsSyncedForAgent(runtime, agentId)) {
|
|
460078
|
+
throw new Error("Memory is not available on this machine.");
|
|
460079
|
+
}
|
|
459556
460080
|
await task2();
|
|
459557
460081
|
});
|
|
459558
460082
|
};
|
|
@@ -459565,6 +460089,7 @@ function handleMemfsSyncedMemoryProtocolCommand(parsed, context3) {
|
|
|
459565
460089
|
});
|
|
459566
460090
|
}
|
|
459567
460091
|
var init_memory_command_sync = __esm(() => {
|
|
460092
|
+
init_memory_access();
|
|
459568
460093
|
init_memfs_sync();
|
|
459569
460094
|
init_memory5();
|
|
459570
460095
|
});
|
|
@@ -460741,10 +461266,20 @@ async function handleRuntimeStartCommand(parsed, context3) {
|
|
|
460741
461266
|
let startResponseSent = false;
|
|
460742
461267
|
try {
|
|
460743
461268
|
validateRuntimeStartShape(parsed);
|
|
460744
|
-
agent = await resolveRuntimeStartAgent(parsed, created);
|
|
460745
461269
|
const backend3 = getBackend();
|
|
460746
461270
|
const createEphemeral = context3.createEphemeralConversation ?? backend3.createEphemeralConversation?.bind(backend3) ?? createEphemeralConversation;
|
|
460747
|
-
|
|
461271
|
+
const retrieveConversation = context3.retrieveConversation ?? ((id) => backend3.retrieveConversation(id));
|
|
461272
|
+
let retrievedConversation;
|
|
461273
|
+
if (hasString(parsed.conversation_id) && parsed.conversation_id !== "default") {
|
|
461274
|
+
[agent, retrievedConversation] = await Promise.all([
|
|
461275
|
+
resolveRuntimeStartAgent(parsed, created),
|
|
461276
|
+
retrieveConversation(parsed.conversation_id)
|
|
461277
|
+
]);
|
|
461278
|
+
} else {
|
|
461279
|
+
agent = await resolveRuntimeStartAgent(parsed, created);
|
|
461280
|
+
}
|
|
461281
|
+
const cachedConversation = retrievedConversation;
|
|
461282
|
+
conversation = await resolveRuntimeStartConversation(parsed, agent, created, createEphemeral, cachedConversation ? async () => cachedConversation : retrieveConversation);
|
|
460748
461283
|
conversation = await applyRuntimeStartConversationSourceTags(parsed, conversation);
|
|
460749
461284
|
runtimeScope = buildRuntimeScope(agent, conversation);
|
|
460750
461285
|
const { connectionId } = context3;
|
|
@@ -462075,6 +462610,12 @@ async function stopMonitor(command) {
|
|
|
462075
462610
|
return { ...response, success: true };
|
|
462076
462611
|
if (!killBackgroundProcess(command.process_id))
|
|
462077
462612
|
return { ...response, error: "Monitor could not be stopped" };
|
|
462613
|
+
let persistenceError;
|
|
462614
|
+
try {
|
|
462615
|
+
await process21.persistState?.();
|
|
462616
|
+
} catch {
|
|
462617
|
+
persistenceError = "Monitor stopped, but its server state could not be saved";
|
|
462618
|
+
}
|
|
462078
462619
|
addToMessageQueue({
|
|
462079
462620
|
kind: "task_notification",
|
|
462080
462621
|
agentId: command.runtime.agent_id,
|
|
@@ -462085,7 +462626,12 @@ async function stopMonitor(command) {
|
|
|
462085
462626
|
event: "The user cancelled this Monitor. Do not restart it unless the user asks."
|
|
462086
462627
|
})
|
|
462087
462628
|
});
|
|
462088
|
-
return {
|
|
462629
|
+
return {
|
|
462630
|
+
...response,
|
|
462631
|
+
success: !persistenceError,
|
|
462632
|
+
stopped: true,
|
|
462633
|
+
...persistenceError ? { error: persistenceError } : {}
|
|
462634
|
+
};
|
|
462089
462635
|
}
|
|
462090
462636
|
var init_stop_monitor = __esm(() => {
|
|
462091
462637
|
init_message_queue_bridge();
|
|
@@ -462109,7 +462655,7 @@ async function handleMonitorStopCommand(command, runtime) {
|
|
|
462109
462655
|
}
|
|
462110
462656
|
return stopMonitor(command);
|
|
462111
462657
|
}
|
|
462112
|
-
var
|
|
462658
|
+
var init_monitors2 = __esm(() => {
|
|
462113
462659
|
init_stop_monitor();
|
|
462114
462660
|
init_runtime6();
|
|
462115
462661
|
});
|
|
@@ -462129,19 +462675,25 @@ function finishUntrackedNativeCapture2(completion, reservation, source, sessionI
|
|
|
462129
462675
|
completion.then(() => reservation.capture(), () => reservation.capture()).catch((error4) => reportNativeSessionCaptureFailure(source, sessionId, error4));
|
|
462130
462676
|
}
|
|
462131
462677
|
function findOwnedTask(runtime, agentId) {
|
|
462132
|
-
const subagent = getSubagents().find((entry) => entry.agentId === agentId && entry.parentAgentId === runtime.agentId
|
|
462678
|
+
const subagent = getSubagents().find((entry) => entry.agentId === agentId && entry.parentAgentId === runtime.agentId);
|
|
462133
462679
|
if (!subagent)
|
|
462134
462680
|
return;
|
|
462135
462681
|
return [...backgroundTasks.entries()].find(([, task2]) => task2.subagentId === subagent.id);
|
|
462136
462682
|
}
|
|
462137
|
-
function
|
|
462683
|
+
function nativeSessionOwner(agentId) {
|
|
462138
462684
|
const target = parseExternalCodingAgentId(agentId);
|
|
462139
462685
|
if (!target || target.computer)
|
|
462140
|
-
return
|
|
462686
|
+
return;
|
|
462141
462687
|
if (target.type !== "claude-code" && target.type !== "codex")
|
|
462142
|
-
return
|
|
462143
|
-
|
|
462144
|
-
|
|
462688
|
+
return;
|
|
462689
|
+
return getNativeSessionOwner(target.type === "claude-code" ? "claude_code" : "codex", target.sessionId);
|
|
462690
|
+
}
|
|
462691
|
+
function ownsNativeSession(runtime, agentId) {
|
|
462692
|
+
return nativeSessionOwner(agentId)?.agentId === runtime.agentId;
|
|
462693
|
+
}
|
|
462694
|
+
function subagentAccessError(agentId) {
|
|
462695
|
+
const known = getSubagents().some((entry) => entry.agentId === agentId) || nativeSessionOwner(agentId);
|
|
462696
|
+
return known ? "Subagent does not belong to this conversation" : `Subagent ${agentId} was not found on this computer`;
|
|
462145
462697
|
}
|
|
462146
462698
|
function runtimeContext(parent, command) {
|
|
462147
462699
|
return {
|
|
@@ -462175,7 +462727,7 @@ async function handleSubagentMessageCommand(command, parent, deps = {}) {
|
|
|
462175
462727
|
if (parent.agentId !== command.runtime.agent_id || parent.conversationId !== command.runtime.conversation_id)
|
|
462176
462728
|
throw new Error("Parent runtime does not match the message request");
|
|
462177
462729
|
if (!findOwnedTask(parent, command.agent_id) && !ownsNativeSession(parent, command.agent_id))
|
|
462178
|
-
throw new Error(
|
|
462730
|
+
throw new Error(subagentAccessError(command.agent_id));
|
|
462179
462731
|
const target = parseExternalCodingAgentId(command.agent_id);
|
|
462180
462732
|
if (!target || target.computer || !isExternalCodingAgentType(target.type))
|
|
462181
462733
|
throw new Error("Invalid external coding agent ID");
|
|
@@ -462328,7 +462880,7 @@ async function handleSubagentStopCommand(command, parent) {
|
|
|
462328
462880
|
stopped: nativeStopped,
|
|
462329
462881
|
cleanup_confirmed: true
|
|
462330
462882
|
};
|
|
462331
|
-
return { ...base2, error:
|
|
462883
|
+
return { ...base2, error: subagentAccessError(command.agent_id) };
|
|
462332
462884
|
}
|
|
462333
462885
|
const [taskId, task2] = owned;
|
|
462334
462886
|
if (task2.status !== "running")
|
|
@@ -462369,7 +462921,7 @@ function handleReadSubagentEventsCommand(command) {
|
|
|
462369
462921
|
subagent_id: command.subagent_id
|
|
462370
462922
|
};
|
|
462371
462923
|
const subagent = getSubagents().find((entry) => entry.id === command.subagent_id);
|
|
462372
|
-
if (!subagent || subagent.parentAgentId !== command.runtime.agent_id
|
|
462924
|
+
if (!subagent || subagent.parentAgentId !== command.runtime.agent_id)
|
|
462373
462925
|
return {
|
|
462374
462926
|
...base2,
|
|
462375
462927
|
success: false,
|
|
@@ -462501,7 +463053,7 @@ async function handleTaskControlCommand(command, context3) {
|
|
|
462501
463053
|
}
|
|
462502
463054
|
}
|
|
462503
463055
|
var init_task_control = __esm(() => {
|
|
462504
|
-
|
|
463056
|
+
init_monitors2();
|
|
462505
463057
|
init_stop_conversation();
|
|
462506
463058
|
init_subagent_control();
|
|
462507
463059
|
init_subagent_events2();
|
|
@@ -467915,6 +468467,7 @@ async function runListenSubcommand(argv, appServer) {
|
|
|
467915
468467
|
}
|
|
467916
468468
|
} catch {}
|
|
467917
468469
|
await cancelBackgroundMemoryTasks();
|
|
468470
|
+
await shutdownMonitors();
|
|
467918
468471
|
await flushRemoteSettingsWrites();
|
|
467919
468472
|
await releaseManualListenerLock();
|
|
467920
468473
|
await flushListenerTelemetryEnd(`listener_${signal.toLowerCase()}`);
|
|
@@ -467928,6 +468481,7 @@ async function runListenSubcommand(argv, appServer) {
|
|
|
467928
468481
|
await closeChannelGateway();
|
|
467929
468482
|
} catch {}
|
|
467930
468483
|
await cancelBackgroundMemoryTasks();
|
|
468484
|
+
await shutdownMonitors();
|
|
467931
468485
|
await flushRemoteSettingsWrites();
|
|
467932
468486
|
await releaseManualListenerLock();
|
|
467933
468487
|
await flushListenerTelemetryEnd(exitReason);
|
|
@@ -468431,6 +468985,7 @@ var init_listen = __esm(async () => {
|
|
|
468431
468985
|
init_settings_manager();
|
|
468432
468986
|
init_telemetry();
|
|
468433
468987
|
init_memory_task_lifecycle();
|
|
468988
|
+
init_monitor();
|
|
468434
468989
|
init_service_protocol();
|
|
468435
468990
|
init_debug();
|
|
468436
468991
|
init_startup_log_boundary();
|
|
@@ -469142,10 +469697,10 @@ async function runMemorySubcommand(argv, deps = {}) {
|
|
|
469142
469697
|
return 1;
|
|
469143
469698
|
}
|
|
469144
469699
|
const { execFile: execFileCb4 } = await import("node:child_process");
|
|
469145
|
-
const { promisify:
|
|
469146
|
-
const
|
|
469700
|
+
const { promisify: promisify20 } = await import("node:util");
|
|
469701
|
+
const execFile22 = promisify20(execFileCb4);
|
|
469147
469702
|
const dir = getScopedMemoryFilesystemRoot(agentId);
|
|
469148
|
-
const { stdout } = await
|
|
469703
|
+
const { stdout } = await execFile22("git", ["diff"], { cwd: dir });
|
|
469149
469704
|
if (stdout.trim()) {
|
|
469150
469705
|
console.log(stdout);
|
|
469151
469706
|
return 2;
|
|
@@ -475308,15 +475863,15 @@ function resolveSkillSourceSpecifier(input) {
|
|
|
475308
475863
|
}
|
|
475309
475864
|
return null;
|
|
475310
475865
|
}
|
|
475311
|
-
async function
|
|
475866
|
+
async function execFile22(command, args, options = {}) {
|
|
475312
475867
|
const { execFile: execFileCb4 } = await import("node:child_process");
|
|
475313
|
-
const { promisify:
|
|
475314
|
-
return
|
|
475868
|
+
const { promisify: promisify20 } = await import("node:util");
|
|
475869
|
+
return promisify20(execFileCb4)(command, args, options);
|
|
475315
475870
|
}
|
|
475316
475871
|
async function resolveBranchAndSubdir(location) {
|
|
475317
475872
|
if (!location.subdir)
|
|
475318
475873
|
return location;
|
|
475319
|
-
const { stdout } = await
|
|
475874
|
+
const { stdout } = await execFile22("git", ["ls-remote", "--heads", location.repoUrl], {
|
|
475320
475875
|
timeout: 60000
|
|
475321
475876
|
});
|
|
475322
475877
|
const branches = stdout.split(`
|
|
@@ -475343,7 +475898,7 @@ async function cloneSkillSource(location) {
|
|
|
475343
475898
|
args.push("--branch", resolvedLocation.branch);
|
|
475344
475899
|
}
|
|
475345
475900
|
args.push(resolvedLocation.repoUrl, tmpDir);
|
|
475346
|
-
await
|
|
475901
|
+
await execFile22("git", args, { timeout: 120000 });
|
|
475347
475902
|
const sourceDir = resolvedLocation.subdir ? join107(tmpDir, resolvedLocation.subdir) : tmpDir;
|
|
475348
475903
|
return { tmpDir, sourceDir };
|
|
475349
475904
|
}
|
|
@@ -475456,7 +476011,7 @@ async function downloadClawHubSkillSource(location) {
|
|
|
475456
476011
|
throw new Error(`ClawHub download failed for ${location.slug}@${version3}: ${response.status}`);
|
|
475457
476012
|
}
|
|
475458
476013
|
writeFileSync47(zipPath, Buffer.from(await response.arrayBuffer()));
|
|
475459
|
-
const { stdout } = await
|
|
476014
|
+
const { stdout } = await execFile22("unzip", ["-Z1", zipPath], {
|
|
475460
476015
|
timeout: 30000
|
|
475461
476016
|
});
|
|
475462
476017
|
const members = stdout.split(`
|
|
@@ -475465,7 +476020,7 @@ async function downloadClawHubSkillSource(location) {
|
|
|
475465
476020
|
throw new Error(`ClawHub download was empty for ${location.slug}@${version3}`);
|
|
475466
476021
|
}
|
|
475467
476022
|
members.forEach(assertSafeZipMember);
|
|
475468
|
-
await
|
|
476023
|
+
await execFile22("unzip", ["-q", zipPath, "-d", sourceDir], {
|
|
475469
476024
|
timeout: 30000
|
|
475470
476025
|
});
|
|
475471
476026
|
return { tmpDir, sourceDir };
|
|
@@ -483416,6 +483971,7 @@ async function sendScopedApprovalMessages(params) {
|
|
|
483416
483971
|
});
|
|
483417
483972
|
}
|
|
483418
483973
|
async function flushAndExit(code) {
|
|
483974
|
+
await shutdownMonitors();
|
|
483419
483975
|
const flushWritable = (stream11) => new Promise((resolve41) => {
|
|
483420
483976
|
if (stream11.destroyed || stream11.writableEnded)
|
|
483421
483977
|
return resolve41();
|
|
@@ -486287,6 +486843,7 @@ var init_headless = __esm(() => {
|
|
|
486287
486843
|
init_runtime_execution_settings();
|
|
486288
486844
|
init_settings_manager();
|
|
486289
486845
|
init_memory_task_lifecycle();
|
|
486846
|
+
init_monitor();
|
|
486290
486847
|
init_manager2();
|
|
486291
486848
|
init_toolset();
|
|
486292
486849
|
init_debug();
|
|
@@ -487586,7 +488143,7 @@ import { existsSync as existsSync75 } from "node:fs";
|
|
|
487586
488143
|
import { appendFile as appendFile3, chmod, mkdir as mkdir18, writeFile as writeFile21 } from "node:fs/promises";
|
|
487587
488144
|
import { homedir as homedir34 } from "node:os";
|
|
487588
488145
|
import { join as join113 } from "node:path";
|
|
487589
|
-
import { promisify as
|
|
488146
|
+
import { promisify as promisify20 } from "node:util";
|
|
487590
488147
|
function getReflectionArenaHfCacheRoot(env6 = process.env, fallbackHome = homedir34()) {
|
|
487591
488148
|
return join113(resolveGlobalConfigDir(env6, fallbackHome), "reflection-arena", "hf-upload");
|
|
487592
488149
|
}
|
|
@@ -487612,7 +488169,7 @@ function formatTokenStatus(token2) {
|
|
|
487612
488169
|
}
|
|
487613
488170
|
async function runGit6(cwd2, args, env6) {
|
|
487614
488171
|
try {
|
|
487615
|
-
await
|
|
488172
|
+
await execFile23("git", args, {
|
|
487616
488173
|
cwd: cwd2,
|
|
487617
488174
|
env: env6,
|
|
487618
488175
|
encoding: "utf-8",
|
|
@@ -487697,12 +488254,12 @@ async function maybeUploadReflectionArenaChoiceToHf(row) {
|
|
|
487697
488254
|
};
|
|
487698
488255
|
}
|
|
487699
488256
|
}
|
|
487700
|
-
var
|
|
488257
|
+
var execFile23, HF_REPO_ID = "letta-ai/reflection-arena", HF_REPO_URL, GIT_TIMEOUT_MS2 = 60000, HF_CACHE_ROOT, HF_REPO_DIR, HF_DATASET_PATH = "data/choices.jsonl";
|
|
487701
488258
|
var init_reflection_arena_hf_upload = __esm(() => {
|
|
487702
488259
|
init_secrets_store();
|
|
487703
488260
|
init_settings_path();
|
|
487704
488261
|
init_version();
|
|
487705
|
-
|
|
488262
|
+
execFile23 = promisify20(execFileCb4);
|
|
487706
488263
|
HF_REPO_URL = `https://huggingface.co/datasets/${HF_REPO_ID}`;
|
|
487707
488264
|
HF_CACHE_ROOT = getReflectionArenaHfCacheRoot();
|
|
487708
488265
|
HF_REPO_DIR = join113(HF_CACHE_ROOT, "repo");
|
|
@@ -487713,7 +488270,7 @@ import { execFile as execFileCb5 } from "node:child_process";
|
|
|
487713
488270
|
import { randomInt as randomInt2, randomUUID as randomUUID67 } from "node:crypto";
|
|
487714
488271
|
import { appendFile as appendFile4, mkdir as mkdir19, readFile as readFile34, writeFile as writeFile22 } from "node:fs/promises";
|
|
487715
488272
|
import { join as join114 } from "node:path";
|
|
487716
|
-
import { promisify as
|
|
488273
|
+
import { promisify as promisify21 } from "node:util";
|
|
487717
488274
|
function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
487718
488275
|
const excluded = new Set(excludedModels);
|
|
487719
488276
|
const candidates = REFLECTION_ARENA_COMPARISON_MODEL_POOL.filter((entry) => !excluded.has(entry.model));
|
|
@@ -487730,7 +488287,7 @@ function sampleReflectionArenaComparisonModel(excludedModels = []) {
|
|
|
487730
488287
|
}
|
|
487731
488288
|
async function getGitOutput(cwd2, args) {
|
|
487732
488289
|
try {
|
|
487733
|
-
const { stdout } = await
|
|
488290
|
+
const { stdout } = await execFile24("git", args, {
|
|
487734
488291
|
cwd: cwd2,
|
|
487735
488292
|
encoding: "utf-8",
|
|
487736
488293
|
timeout: 30000,
|
|
@@ -488286,7 +488843,7 @@ async function finalizeReflectionArenaChoice(options) {
|
|
|
488286
488843
|
run: completedRun
|
|
488287
488844
|
};
|
|
488288
488845
|
}
|
|
488289
|
-
var
|
|
488846
|
+
var execFile24, REFLECTION_ARENA_TELEMETRY_TRANSCRIPT_MAX_CHARS = 1e6, REFLECTION_ARENA_MODEL_A_DEFAULT = "letta/auto-memory", REFLECTION_ARENA_COMPARISON_FALLBACK_MODEL = "lc-anthropic/claude-sonnet-5", REFLECTION_ARENA_COMPARISON_MODEL_POOL, ANSI_BOLD = "\x1B[1m", ANSI_CYAN = "\x1B[36m", ANSI_MAGENTA = "\x1B[35m", ANSI_RESET_BOLD = "\x1B[22m", ANSI_RESET_FOREGROUND = "\x1B[39m", REFLECTION_ARENA_CANDIDATE_COUNT = 2, REFLECTION_ARENA_CHOICE_QUESTION = "Which reflection should be merged?", REFLECTION_ARENA_NOTES_QUESTION = "Optional feedback for this choice?", updateLocks;
|
|
488290
488847
|
var init_reflection_arena = __esm(() => {
|
|
488291
488848
|
init_memory_worktree();
|
|
488292
488849
|
init_app_urls();
|
|
@@ -488297,7 +488854,7 @@ var init_reflection_arena = __esm(() => {
|
|
|
488297
488854
|
init_telemetry();
|
|
488298
488855
|
init_debug();
|
|
488299
488856
|
init_settings_path();
|
|
488300
|
-
|
|
488857
|
+
execFile24 = promisify21(execFileCb5);
|
|
488301
488858
|
REFLECTION_ARENA_COMPARISON_MODEL_POOL = [
|
|
488302
488859
|
{ model: "lc-anthropic/claude-sonnet-5", weight: 1 },
|
|
488303
488860
|
{ model: "lc-anthropic/claude-opus-4-8", weight: 3 },
|
|
@@ -504698,7 +505255,7 @@ __export(exports_generate_memory_viewer, {
|
|
|
504698
505255
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
504699
505256
|
import { chmodSync as chmodSync11, existsSync as existsSync78, mkdirSync as mkdirSync60, writeFileSync as writeFileSync52 } from "node:fs";
|
|
504700
505257
|
import { join as join118 } from "node:path";
|
|
504701
|
-
import { promisify as
|
|
505258
|
+
import { promisify as promisify22 } from "node:util";
|
|
504702
505259
|
function messagesFromOverview(overview) {
|
|
504703
505260
|
return overview.messages?.map((message2) => ({
|
|
504704
505261
|
id: message2.id,
|
|
@@ -504725,7 +505282,7 @@ function contextFromOverview(overview, model2, contextWindow) {
|
|
|
504725
505282
|
}
|
|
504726
505283
|
async function runGitSafe(cwd2, args) {
|
|
504727
505284
|
try {
|
|
504728
|
-
const { stdout } = await
|
|
505285
|
+
const { stdout } = await execFile25("git", args, {
|
|
504729
505286
|
cwd: cwd2,
|
|
504730
505287
|
maxBuffer: 10 * 1024 * 1024,
|
|
504731
505288
|
timeout: 60000
|
|
@@ -505037,7 +505594,7 @@ async function generateAndOpenMemoryViewer(agentId, options) {
|
|
|
505037
505594
|
}
|
|
505038
505595
|
return { filePath, opened: !skipOpen };
|
|
505039
505596
|
}
|
|
505040
|
-
var
|
|
505597
|
+
var execFile25, VIEWERS_DIR, MAX_COMMITS = 500, RECENT_DIFF_COUNT = 50, PER_DIFF_CAP = 1e5, TOTAL_PAYLOAD_CAP = 5000000, RECORD_SEP = "\x1E", REFLECTION_PATTERN;
|
|
505041
505598
|
var init_generate_memory_viewer = __esm(() => {
|
|
505042
505599
|
init_memory_filesystem2();
|
|
505043
505600
|
init_memory_format();
|
|
@@ -505050,7 +505607,7 @@ var init_generate_memory_viewer = __esm(() => {
|
|
|
505050
505607
|
init_context_usage();
|
|
505051
505608
|
init_local_memory_context();
|
|
505052
505609
|
init_memory_viewer_template();
|
|
505053
|
-
|
|
505610
|
+
execFile25 = promisify22(execFileCb6);
|
|
505054
505611
|
VIEWERS_DIR = join118(resolveGlobalConfigDir(), "viewers");
|
|
505055
505612
|
REFLECTION_PATTERN = /\(reflection\)|🔮|reflection:/i;
|
|
505056
505613
|
});
|
|
@@ -515722,10 +516279,10 @@ __export(exports_generate_diff_viewer, {
|
|
|
515722
516279
|
import { execFile as execFileCb7 } from "node:child_process";
|
|
515723
516280
|
import { chmodSync as chmodSync12, existsSync as existsSync80, mkdirSync as mkdirSync61, writeFileSync as writeFileSync53 } from "node:fs";
|
|
515724
516281
|
import { isAbsolute as isAbsolute28, join as join122, resolve as resolve42 } from "node:path";
|
|
515725
|
-
import { promisify as
|
|
516282
|
+
import { promisify as promisify23 } from "node:util";
|
|
515726
516283
|
async function runGit8(cwd2, args) {
|
|
515727
516284
|
try {
|
|
515728
|
-
const { stdout } = await
|
|
516285
|
+
const { stdout } = await execFile26("git", args, {
|
|
515729
516286
|
cwd: cwd2,
|
|
515730
516287
|
maxBuffer: GIT_MAX_BUFFER,
|
|
515731
516288
|
timeout: GIT_TIMEOUT_MS3
|
|
@@ -515964,7 +516521,7 @@ async function generateAndOpenDiffViewer(targetPath) {
|
|
|
515964
516521
|
}
|
|
515965
516522
|
return { filePath, opened: !skipOpen, fileCount: rendered.files.length };
|
|
515966
516523
|
}
|
|
515967
|
-
var
|
|
516524
|
+
var execFile26, VIEWERS_DIR2, GIT_TIMEOUT_MS3 = 60000, GIT_MAX_BUFFER, MAX_RENDERED_FILES = 100, DIFF_UNSAFE_CSS = `
|
|
515968
516525
|
:host {
|
|
515969
516526
|
--diffs-addition-color-override: #15803d;
|
|
515970
516527
|
--diffs-deletion-color-override: #b91c1c;
|
|
@@ -516019,7 +516576,7 @@ var execFile25, VIEWERS_DIR2, GIT_TIMEOUT_MS3 = 60000, GIT_MAX_BUFFER, MAX_RENDE
|
|
|
516019
516576
|
var init_generate_diff_viewer = __esm(() => {
|
|
516020
516577
|
init_settings_path();
|
|
516021
516578
|
init_diff_viewer_template();
|
|
516022
|
-
|
|
516579
|
+
execFile26 = promisify23(execFileCb7);
|
|
516023
516580
|
VIEWERS_DIR2 = join122(resolveGlobalConfigDir(), "viewers");
|
|
516024
516581
|
GIT_MAX_BUFFER = 50 * 1024 * 1024;
|
|
516025
516582
|
});
|
|
@@ -517215,11 +517772,13 @@ function saveLastSessionBeforeExit(conversationId) {
|
|
|
517215
517772
|
async function prepareSessionExit(conversationId) {
|
|
517216
517773
|
saveLastSessionBeforeExit(conversationId);
|
|
517217
517774
|
await cancelBackgroundMemoryTasks();
|
|
517775
|
+
await shutdownMonitors();
|
|
517218
517776
|
}
|
|
517219
517777
|
var init_session3 = __esm(() => {
|
|
517220
517778
|
init_context();
|
|
517221
517779
|
init_settings_manager();
|
|
517222
517780
|
init_memory_task_lifecycle();
|
|
517781
|
+
init_monitor();
|
|
517223
517782
|
});
|
|
517224
517783
|
|
|
517225
517784
|
// src/cli/app/use-agent-mcp-servers.ts
|
|
@@ -526056,10 +526615,10 @@ __export(exports_worktree_diff_list, {
|
|
|
526056
526615
|
});
|
|
526057
526616
|
import { execFile as execFileCb8 } from "node:child_process";
|
|
526058
526617
|
import { basename as basename34 } from "node:path";
|
|
526059
|
-
import { promisify as
|
|
526618
|
+
import { promisify as promisify24 } from "node:util";
|
|
526060
526619
|
async function runGit9(cwd2, args) {
|
|
526061
526620
|
try {
|
|
526062
|
-
const { stdout } = await
|
|
526621
|
+
const { stdout } = await execFile27("git", args, {
|
|
526063
526622
|
cwd: cwd2,
|
|
526064
526623
|
maxBuffer: GIT_MAX_BUFFER2,
|
|
526065
526624
|
timeout: GIT_TIMEOUT_MS4
|
|
@@ -526188,9 +526747,9 @@ async function listWorktreeDiffOptions(cwd2 = process.cwd()) {
|
|
|
526188
526747
|
const worktrees = parseWorktreeList(output, currentPath);
|
|
526189
526748
|
return Promise.all(worktrees.map((worktree) => summarizeWorktree(worktree)));
|
|
526190
526749
|
}
|
|
526191
|
-
var
|
|
526750
|
+
var execFile27, GIT_TIMEOUT_MS4 = 60000, GIT_MAX_BUFFER2;
|
|
526192
526751
|
var init_worktree_diff_list = __esm(() => {
|
|
526193
|
-
|
|
526752
|
+
execFile27 = promisify24(execFileCb8);
|
|
526194
526753
|
GIT_MAX_BUFFER2 = 10 * 1024 * 1024;
|
|
526195
526754
|
});
|
|
526196
526755
|
|
|
@@ -536144,4 +536703,4 @@ function registerBunOAuthFlows() {
|
|
|
536144
536703
|
registerBunOAuthFlows();
|
|
536145
536704
|
await init_src5().then(() => exports_src2);
|
|
536146
536705
|
|
|
536147
|
-
//# debugId=
|
|
536706
|
+
//# debugId=F2C2B5566F98148D64756E2164756E21
|