@letta-ai/letta-code 0.31.8 → 0.31.9
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/types/agent/subagents/manager.d.ts +7 -1
- package/dist/types/agent/subagents/manager.d.ts.map +1 -1
- package/dist/types/tools/impl/task.d.ts +7 -0
- package/dist/types/tools/impl/task.d.ts.map +1 -1
- package/letta.js +376 -163
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -5509,7 +5509,7 @@ var package_default;
|
|
|
5509
5509
|
var init_package = __esm(() => {
|
|
5510
5510
|
package_default = {
|
|
5511
5511
|
name: "@letta-ai/letta-code",
|
|
5512
|
-
version: "0.31.
|
|
5512
|
+
version: "0.31.9",
|
|
5513
5513
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
5514
5514
|
type: "module",
|
|
5515
5515
|
packageManager: "bun@1.3.10",
|
|
@@ -89144,6 +89144,37 @@ Agent({ subagent_type: "fork", description: "Implement component B", prompt: "..
|
|
|
89144
89144
|
|
|
89145
89145
|
Note: \`fork\` cannot be combined with \`agent_id\` or \`conversation_id\`.
|
|
89146
89146
|
|
|
89147
|
+
## Running on Another Computer
|
|
89148
|
+
|
|
89149
|
+
Pass \`computer\` to run the subagent's turn on another connected computer instead of this machine. Works with any subagent type. The call fails fast if the named device is offline, ambiguous, or too old to support routing.
|
|
89150
|
+
|
|
89151
|
+
\`computer: "cloud"\` provisions a Cloud sandbox for the subagent's conversation and runs the turn there. Sandboxes are per-conversation: this is a separate machine from wherever you are running now, even if you are already in a Cloud sandbox.
|
|
89152
|
+
|
|
89153
|
+
Omit \`computer\` to run the subagent on the current machine. That is the default and the right choice for almost all tasks — the subagent shares your working directory and files. Only set \`computer\` when the task specifically needs another machine (its files, its OS, or an isolated sandbox).
|
|
89154
|
+
|
|
89155
|
+
\`\`\`typescript
|
|
89156
|
+
// Fork this conversation and run the work on a connected computer
|
|
89157
|
+
Agent({
|
|
89158
|
+
subagent_type: "fork",
|
|
89159
|
+
computer: "office-mac",
|
|
89160
|
+
description: "Run integration tests",
|
|
89161
|
+
prompt: "Run the integration suite in the checkout on this machine and report failures."
|
|
89162
|
+
})
|
|
89163
|
+
|
|
89164
|
+
// Deploy an existing agent into a fresh Cloud sandbox
|
|
89165
|
+
Agent({
|
|
89166
|
+
agent_id: "agent-abc123",
|
|
89167
|
+
computer: "cloud",
|
|
89168
|
+
description: "Build release artifacts",
|
|
89169
|
+
prompt: "Build and upload the release artifacts."
|
|
89170
|
+
})
|
|
89171
|
+
\`\`\`
|
|
89172
|
+
|
|
89173
|
+
Behavior notes:
|
|
89174
|
+
- The remote turn runs with the remote machine's working directory, tools, and skills. Subagent-type tool restrictions (e.g. recall's read-only toolset) travel with the turn on current servers; older servers ignore them.
|
|
89175
|
+
- The remote turn's final assistant message is returned as the task result. Token and step statistics are not available for remote runs.
|
|
89176
|
+
- The wait tracks turn liveness (new messages, run activity, device online) with an absolute one-hour ceiling rather than a fixed timeout.
|
|
89177
|
+
|
|
89147
89178
|
## Concurrency and Safety:
|
|
89148
89179
|
|
|
89149
89180
|
- **Safe**: Multiple read-only agents (e.g. recall, history-analyzer) running in parallel
|
|
@@ -114705,6 +114736,9 @@ function buildSubagentArgs(type3, config, model, userPrompt, existingAgentId, ex
|
|
|
114705
114736
|
if (options.backendMode) {
|
|
114706
114737
|
args.push("--backend", options.backendMode);
|
|
114707
114738
|
}
|
|
114739
|
+
if (options.environment) {
|
|
114740
|
+
args.push("--environment", options.environment);
|
|
114741
|
+
}
|
|
114708
114742
|
if (isDeployingExisting) {
|
|
114709
114743
|
if (existingConversationId) {
|
|
114710
114744
|
args.push("--conv", existingConversationId);
|
|
@@ -114765,7 +114799,7 @@ function buildSubagentArgs(type3, config, model, userPrompt, existingAgentId, ex
|
|
|
114765
114799
|
}
|
|
114766
114800
|
return args;
|
|
114767
114801
|
}
|
|
114768
|
-
async function executeSubagent(type3, config, model, userPrompt, subagentId, isRetry = false, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride) {
|
|
114802
|
+
async function executeSubagent(type3, config, model, userPrompt, subagentId, isRetry = false, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride, environment2) {
|
|
114769
114803
|
const withModel = (result) => model ? { ...result, model } : result;
|
|
114770
114804
|
if (signal?.aborted) {
|
|
114771
114805
|
return withModel({
|
|
@@ -114792,7 +114826,8 @@ async function executeSubagent(type3, config, model, userPrompt, subagentId, isR
|
|
|
114792
114826
|
backendMode,
|
|
114793
114827
|
promptTransport: "stdin",
|
|
114794
114828
|
parentAgentId,
|
|
114795
|
-
systemPromptOverride
|
|
114829
|
+
systemPromptOverride,
|
|
114830
|
+
environment: environment2
|
|
114796
114831
|
});
|
|
114797
114832
|
const launcher = resolveSubagentLauncher(cliArgs);
|
|
114798
114833
|
const settings3 = await settingsManager.getSettingsWithSecureTokens();
|
|
@@ -114913,12 +114948,12 @@ async function executeSubagent(type3, config, model, userPrompt, subagentId, isR
|
|
|
114913
114948
|
agentId: parentAgentIdOverride
|
|
114914
114949
|
});
|
|
114915
114950
|
if (primaryModel) {
|
|
114916
|
-
return executeSubagent(type3, config, primaryModel, userPrompt, subagentId, true, signal, undefined, undefined, maxTurns, parentAgentIdOverride, transcriptPath);
|
|
114951
|
+
return executeSubagent(type3, config, primaryModel, userPrompt, subagentId, true, signal, undefined, undefined, maxTurns, parentAgentIdOverride, transcriptPath, undefined, undefined, environment2);
|
|
114917
114952
|
}
|
|
114918
114953
|
}
|
|
114919
114954
|
if (!isRetry && isSubagentStdoutLostError(stderr)) {
|
|
114920
114955
|
debugWarn("subagent", `Subagent ${subagentId} lost stdout before its result envelope; retrying once`);
|
|
114921
|
-
return executeSubagent(type3, config, model, userPrompt, subagentId, true, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride);
|
|
114956
|
+
return executeSubagent(type3, config, model, userPrompt, subagentId, true, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride, environment2);
|
|
114922
114957
|
}
|
|
114923
114958
|
const propagatedError = state.finalError?.trim();
|
|
114924
114959
|
const fallbackError = stderr || `Subagent exited with code ${exitCode}`;
|
|
@@ -114963,7 +114998,7 @@ async function executeSubagent(type3, config, model, userPrompt, subagentId, isR
|
|
|
114963
114998
|
debugWarn("subagent", `parseResultFromStdout failed for ${subagentId}: ${result.error}. ` + `stdout first 500 chars: ${stdout.slice(0, 500)}`);
|
|
114964
114999
|
if (!isRetry && looksLikeTruncatedStreamJson(stdout)) {
|
|
114965
115000
|
debugWarn("subagent", `Subagent ${subagentId} stdout ends mid-line with no result envelope; retrying once`);
|
|
114966
|
-
return executeSubagent(type3, config, model, userPrompt, subagentId, true, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride);
|
|
115001
|
+
return executeSubagent(type3, config, model, userPrompt, subagentId, true, signal, existingAgentId, existingConversationId, maxTurns, parentAgentIdOverride, transcriptPath, memoryScope, systemPromptOverride, environment2);
|
|
114967
115002
|
}
|
|
114968
115003
|
}
|
|
114969
115004
|
return withModel(result);
|
|
@@ -115022,7 +115057,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
115022
115057
|
|
|
115023
115058
|
`;
|
|
115024
115059
|
}
|
|
115025
|
-
async function spawnSubagent(type3, prompt, userModel, subagentId, signal, existingAgentId, existingConversationId, maxTurns, forkedContext, parentAgentId, transcriptPath, parentConversationId, memoryScope, systemPromptOverride) {
|
|
115060
|
+
async function spawnSubagent(type3, prompt, userModel, subagentId, signal, existingAgentId, existingConversationId, maxTurns, forkedContext, parentAgentId, transcriptPath, parentConversationId, memoryScope, systemPromptOverride, environment2) {
|
|
115026
115061
|
const allConfigs = await getAllSubagentConfigs();
|
|
115027
115062
|
let config = allConfigs[type3];
|
|
115028
115063
|
if (!config) {
|
|
@@ -115087,7 +115122,7 @@ async function spawnSubagent(type3, prompt, userModel, subagentId, signal, exist
|
|
|
115087
115122
|
conversationId: existingConversationId
|
|
115088
115123
|
});
|
|
115089
115124
|
}
|
|
115090
|
-
const result = await executeSubagent(type3, config, model, finalPrompt, subagentId, false, signal, existingAgentId, existingConversationId, maxTurns, resolvedParentAgentId, transcriptPath, memoryScope, effectiveSystemPromptOverride);
|
|
115125
|
+
const result = await executeSubagent(type3, config, model, finalPrompt, subagentId, false, signal, existingAgentId, existingConversationId, maxTurns, resolvedParentAgentId, transcriptPath, memoryScope, effectiveSystemPromptOverride, environment2);
|
|
115091
115126
|
return result;
|
|
115092
115127
|
}
|
|
115093
115128
|
var NO_BASE_TOOL_SUBAGENT_TYPES;
|
|
@@ -115260,6 +115295,7 @@ function spawnBackgroundSubagentTask(args) {
|
|
|
115260
115295
|
onComplete,
|
|
115261
115296
|
transcriptPath,
|
|
115262
115297
|
memoryScope,
|
|
115298
|
+
environment: environment2,
|
|
115263
115299
|
deps
|
|
115264
115300
|
} = args;
|
|
115265
115301
|
const shouldEmitCompletionNotification = emitCompletionNotification ?? !silentCompletion;
|
|
@@ -115293,7 +115329,7 @@ function spawnBackgroundSubagentTask(args) {
|
|
|
115293
115329
|
backgroundTasks.set(taskId, bgTask);
|
|
115294
115330
|
writeTaskTranscriptStart(outputFile, description, subagentType);
|
|
115295
115331
|
const parentAgentIdForSpawn = resolvedParentScope?.agentId;
|
|
115296
|
-
spawnSubagentFn(subagentType, prompt, model, subagentId, abortController.signal, existingAgentId, existingConversationId, maxTurns, forkedContext, parentAgentIdForSpawn, transcriptPath, resolvedParentScope?.conversationId, memoryScope, systemPromptOverride).then(async (result) => {
|
|
115332
|
+
spawnSubagentFn(subagentType, prompt, model, subagentId, abortController.signal, existingAgentId, existingConversationId, maxTurns, forkedContext, parentAgentIdForSpawn, transcriptPath, resolvedParentScope?.conversationId, memoryScope, systemPromptOverride, environment2).then(async (result) => {
|
|
115297
115333
|
await copyGitHubPullRequestTagsFn(result.conversationId, resolvedParentScope?.conversationId);
|
|
115298
115334
|
bgTask.status = result.success ? "completed" : "failed";
|
|
115299
115335
|
if (result.error) {
|
|
@@ -115525,7 +115561,8 @@ async function task(args) {
|
|
|
115525
115561
|
existingConversationId: effectiveConversationId,
|
|
115526
115562
|
maxTurns: args.max_turns,
|
|
115527
115563
|
forkedContext: config.fork,
|
|
115528
|
-
parentScope: resolvedParentScope
|
|
115564
|
+
parentScope: resolvedParentScope,
|
|
115565
|
+
environment: typeof args.computer === "string" && args.computer.trim() ? args.computer.trim() : undefined
|
|
115529
115566
|
});
|
|
115530
115567
|
await waitForBackgroundSubagentLink(subagentId, null, signal);
|
|
115531
115568
|
const linkedAgent = getSnapshot().agents.find((a) => a.id === subagentId);
|
|
@@ -117167,6 +117204,10 @@ var init_Task2 = __esm(() => {
|
|
|
117167
117204
|
conversation_id: {
|
|
117168
117205
|
type: "string",
|
|
117169
117206
|
description: "Resume from an existing conversation. Does NOT require agent_id (conversation IDs are unique and encode the agent)."
|
|
117207
|
+
},
|
|
117208
|
+
computer: {
|
|
117209
|
+
type: "string",
|
|
117210
|
+
description: `Run the subagent on another connected computer instead of this machine. Pass a computer name/connection ID, or "cloud" to provision a Cloud sandbox for the subagent's conversation. Fails fast if the device is offline or does not support routing. Omit this field to run on the current machine (the default) — only set it when the task specifically needs to run elsewhere.`
|
|
117170
117211
|
}
|
|
117171
117212
|
},
|
|
117172
117213
|
required: ["description", "prompt", "subagent_type"],
|
|
@@ -394179,6 +394220,29 @@ function buildTeleportContinuationMessages(params) {
|
|
|
394179
394220
|
}
|
|
394180
394221
|
];
|
|
394181
394222
|
}
|
|
394223
|
+
function escapeSystemReminderText(value) {
|
|
394224
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
394225
|
+
}
|
|
394226
|
+
function buildTeleportFailureMessages(params) {
|
|
394227
|
+
const messages = [];
|
|
394228
|
+
if (params.approvals && params.approvals.length > 0) {
|
|
394229
|
+
messages.push({
|
|
394230
|
+
type: "approval",
|
|
394231
|
+
approvals: params.approvals,
|
|
394232
|
+
otid: params.teleportId
|
|
394233
|
+
});
|
|
394234
|
+
}
|
|
394235
|
+
messages.push({
|
|
394236
|
+
role: "system",
|
|
394237
|
+
content: `<system-reminder>Teleportation failed.
|
|
394238
|
+
|
|
394239
|
+
Error: ${escapeSystemReminderText(params.error)}
|
|
394240
|
+
|
|
394241
|
+
Continue the existing task from this environment now.</system-reminder>`,
|
|
394242
|
+
otid: `${params.teleportId}:failed`
|
|
394243
|
+
});
|
|
394244
|
+
return messages;
|
|
394245
|
+
}
|
|
394182
394246
|
function getPendingTeleports(runtime) {
|
|
394183
394247
|
runtime.pendingTeleports ??= new Map;
|
|
394184
394248
|
return runtime.pendingTeleports;
|
|
@@ -394357,11 +394421,43 @@ function takeFailedTeleport(params) {
|
|
|
394357
394421
|
params.listener.pendingTeleports?.delete(params.teleportId);
|
|
394358
394422
|
return pending;
|
|
394359
394423
|
}
|
|
394424
|
+
function handleTeleportFailure(params) {
|
|
394425
|
+
const pending = takeFailedTeleport({
|
|
394426
|
+
listener: params.listener,
|
|
394427
|
+
teleportId: params.command.teleport_id,
|
|
394428
|
+
agentId: params.command.runtime.agent_id,
|
|
394429
|
+
conversationId: params.command.runtime.conversation_id
|
|
394430
|
+
});
|
|
394431
|
+
if (!pending)
|
|
394432
|
+
return;
|
|
394433
|
+
const runtime = params.getOrCreateScopedRuntime(params.listener, pending.agentId, pending.conversationId);
|
|
394434
|
+
emitLoopErrorNotice(params.socket, runtime, {
|
|
394435
|
+
message: `Teleport failed: ${params.command.error}`,
|
|
394436
|
+
stopReason: "error",
|
|
394437
|
+
isTerminal: false,
|
|
394438
|
+
agentId: pending.agentId,
|
|
394439
|
+
conversationId: pending.conversationId
|
|
394440
|
+
});
|
|
394441
|
+
params.runDetachedListenerTask("teleport_failed", async () => {
|
|
394442
|
+
await params.processIncomingMessage({
|
|
394443
|
+
type: "message",
|
|
394444
|
+
connectionId: pending.connectionId,
|
|
394445
|
+
agentId: pending.agentId,
|
|
394446
|
+
conversationId: pending.conversationId,
|
|
394447
|
+
messages: buildTeleportFailureMessages({
|
|
394448
|
+
teleportId: params.command.teleport_id,
|
|
394449
|
+
error: params.command.error,
|
|
394450
|
+
approvals: pending.continuation?.approvals
|
|
394451
|
+
})
|
|
394452
|
+
}, params.socket, runtime, params.onStatusChange, pending.connectionId);
|
|
394453
|
+
});
|
|
394454
|
+
}
|
|
394360
394455
|
var TELEPORT_RECOVERY_TTL_MS;
|
|
394361
394456
|
var init_teleport = __esm(() => {
|
|
394362
394457
|
init_connection();
|
|
394363
394458
|
init_permission_mode();
|
|
394364
394459
|
init_protocol_outbound();
|
|
394460
|
+
init_recoverable_notices();
|
|
394365
394461
|
init_runtime();
|
|
394366
394462
|
init_transport();
|
|
394367
394463
|
TELEPORT_RECOVERY_TTL_MS = 5 * 60000;
|
|
@@ -409763,31 +409859,15 @@ function createListenerMessageHandler(params) {
|
|
|
409763
409859
|
return;
|
|
409764
409860
|
}
|
|
409765
409861
|
if (parsed.type === "teleport_failed") {
|
|
409766
|
-
|
|
409862
|
+
handleTeleportFailure({
|
|
409767
409863
|
listener: runtime,
|
|
409768
|
-
|
|
409769
|
-
|
|
409770
|
-
|
|
409864
|
+
command: parsed,
|
|
409865
|
+
socket,
|
|
409866
|
+
onStatusChange: opts.onStatusChange,
|
|
409867
|
+
getOrCreateScopedRuntime: getOrCreateScopedRuntime2,
|
|
409868
|
+
runDetachedListenerTask,
|
|
409869
|
+
processIncomingMessage
|
|
409771
409870
|
});
|
|
409772
|
-
const approvals = pending?.continuation?.approvals;
|
|
409773
|
-
if (pending && approvals && approvals.length > 0) {
|
|
409774
|
-
const scopedRuntime = getOrCreateScopedRuntime2(runtime, pending.agentId, pending.conversationId);
|
|
409775
|
-
runDetachedListenerTask("teleport_failed", async () => {
|
|
409776
|
-
await processIncomingMessage({
|
|
409777
|
-
type: "message",
|
|
409778
|
-
connectionId: pending.connectionId,
|
|
409779
|
-
agentId: pending.agentId,
|
|
409780
|
-
conversationId: pending.conversationId,
|
|
409781
|
-
messages: [
|
|
409782
|
-
{
|
|
409783
|
-
type: "approval",
|
|
409784
|
-
approvals,
|
|
409785
|
-
otid: parsed.teleport_id
|
|
409786
|
-
}
|
|
409787
|
-
]
|
|
409788
|
-
}, socket, scopedRuntime, opts.onStatusChange, pending.connectionId);
|
|
409789
|
-
});
|
|
409790
|
-
}
|
|
409791
409871
|
return;
|
|
409792
409872
|
}
|
|
409793
409873
|
if (parsed.type === "external_tool_call_response") {
|
|
@@ -432006,7 +432086,7 @@ var init_mcp_client = __esm(() => {
|
|
|
432006
432086
|
init_streamableHttp();
|
|
432007
432087
|
DEFAULT_CLIENT_INFO = {
|
|
432008
432088
|
name: "letta-code",
|
|
432009
|
-
version: "0.31.
|
|
432089
|
+
version: "0.31.9"
|
|
432010
432090
|
};
|
|
432011
432091
|
});
|
|
432012
432092
|
|
|
@@ -439183,7 +439263,7 @@ Notes:
|
|
|
439183
439263
|
- Operates on the current agent/conversation from LETTA_AGENT_ID /
|
|
439184
439264
|
LETTA_CONVERSATION_ID (or AGENT_ID / CONVERSATION_ID), falling back to the
|
|
439185
439265
|
last active session.
|
|
439186
|
-
- Requires a Letta Cloud agent and
|
|
439266
|
+
- Requires a Letta Cloud agent and an active conversation.
|
|
439187
439267
|
- list: prints accessible online remote environments as JSON.
|
|
439188
439268
|
- cloud: teleports to the agent's Cloud sandbox.
|
|
439189
439269
|
- local: teleports to the one online Desktop environment. Desktop Remote
|
|
@@ -439219,7 +439299,7 @@ function resolveTeleportSession(env4, fallback) {
|
|
|
439219
439299
|
if (isLocalAgentId(session.agentId)) {
|
|
439220
439300
|
throw new Error("Teleport requires a Letta Cloud agent");
|
|
439221
439301
|
}
|
|
439222
|
-
if (!session.conversationId || session.conversationId === "
|
|
439302
|
+
if (!session.conversationId || session.conversationId === "new") {
|
|
439223
439303
|
throw new Error("Teleport requires an active conversation");
|
|
439224
439304
|
}
|
|
439225
439305
|
return session;
|
|
@@ -445579,7 +445659,43 @@ var init_local_backend_mod_events = __esm(() => {
|
|
|
445579
445659
|
init_local_backend();
|
|
445580
445660
|
});
|
|
445581
445661
|
|
|
445662
|
+
// src/backend/api/agents.ts
|
|
445663
|
+
async function getAgentContextOverview(agentId, options) {
|
|
445664
|
+
return apiRequest("GET", `/v1/agents/${agentId}/context`, undefined, {
|
|
445665
|
+
signal: options?.signal
|
|
445666
|
+
});
|
|
445667
|
+
}
|
|
445668
|
+
async function createMinimalAgent(apiKey, name) {
|
|
445669
|
+
return apiRequest("POST", "/v1/agents", { name }, {
|
|
445670
|
+
baseUrl: "https://api.letta.com",
|
|
445671
|
+
apiKey
|
|
445672
|
+
});
|
|
445673
|
+
}
|
|
445674
|
+
async function getAgentRuntimeStatus(agentId, conversationIds) {
|
|
445675
|
+
return apiRequest("GET", `/v1/agents/${encodeURIComponent(agentId)}/runtime-status`, undefined, { query: { conversation_ids: conversationIds.join(",") } });
|
|
445676
|
+
}
|
|
445677
|
+
var init_agents7 = __esm(() => {
|
|
445678
|
+
init_request();
|
|
445679
|
+
});
|
|
445680
|
+
|
|
445582
445681
|
// src/headless-environment-response.ts
|
|
445682
|
+
import { randomUUID as randomUUID35 } from "node:crypto";
|
|
445683
|
+
function buildEnvironmentCreateMessageBody(params) {
|
|
445684
|
+
const clientToolAllowlist = toolFilter.getEnabledTools();
|
|
445685
|
+
return {
|
|
445686
|
+
agentId: params.agentId,
|
|
445687
|
+
conversationId: params.conversationId,
|
|
445688
|
+
...clientToolAllowlist !== null ? { client_tool_allowlist: clientToolAllowlist } : {},
|
|
445689
|
+
messages: [
|
|
445690
|
+
{
|
|
445691
|
+
role: "user",
|
|
445692
|
+
content: params.content,
|
|
445693
|
+
client_message_id: randomUUID35(),
|
|
445694
|
+
otid: params.otid
|
|
445695
|
+
}
|
|
445696
|
+
]
|
|
445697
|
+
};
|
|
445698
|
+
}
|
|
445583
445699
|
function pageItems5(page) {
|
|
445584
445700
|
if (Array.isArray(page))
|
|
445585
445701
|
return page;
|
|
@@ -445628,12 +445744,42 @@ function messageSequenceId(message) {
|
|
|
445628
445744
|
const sequenceId = message.seq_id;
|
|
445629
445745
|
return typeof sequenceId === "number" ? sequenceId : null;
|
|
445630
445746
|
}
|
|
445747
|
+
function resolveEnvironmentMaxWaitMs() {
|
|
445748
|
+
const raw2 = process.env.LETTA_ENVIRONMENT_TIMEOUT_MS;
|
|
445749
|
+
if (raw2) {
|
|
445750
|
+
const parsed = Number(raw2);
|
|
445751
|
+
if (Number.isFinite(parsed) && parsed > 0)
|
|
445752
|
+
return parsed;
|
|
445753
|
+
}
|
|
445754
|
+
return DEFAULT_MAX_WAIT_MS;
|
|
445755
|
+
}
|
|
445756
|
+
function isTerminalRunStatus(status) {
|
|
445757
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
445758
|
+
}
|
|
445759
|
+
function isRuntimeTurnOver(status) {
|
|
445760
|
+
return status.state === "IDLE" || status.loop_state?.status === "WAITING_ON_INPUT";
|
|
445761
|
+
}
|
|
445631
445762
|
async function waitForEnvironmentAssistantMessage(params) {
|
|
445632
|
-
const
|
|
445763
|
+
const now2 = params.deps?.now ?? Date.now;
|
|
445764
|
+
const sleep10 = params.deps?.sleep ?? ((ms) => new Promise((resolve38) => setTimeout(resolve38, ms)));
|
|
445765
|
+
const fetchEnvironment = params.deps?.getEnvironmentConnection ?? getEnvironmentConnection;
|
|
445766
|
+
const fetchRuntimeStatus = params.deps?.getAgentRuntimeStatus ?? getAgentRuntimeStatus;
|
|
445767
|
+
const maxWaitMs = params.maxWaitMs ?? resolveEnvironmentMaxWaitMs();
|
|
445768
|
+
const inactivityTimeoutMs = params.inactivityTimeoutMs ?? DEFAULT_INACTIVITY_TIMEOUT_MS;
|
|
445633
445769
|
const pollIntervalMs = params.pollIntervalMs ?? 1000;
|
|
445634
|
-
const
|
|
445770
|
+
const onlineCheckIntervalMs = params.onlineCheckIntervalMs ?? DEFAULT_ONLINE_CHECK_INTERVAL_MS;
|
|
445771
|
+
const runStatusIntervalMs = params.runStatusIntervalMs ?? DEFAULT_RUN_STATUS_INTERVAL_MS;
|
|
445772
|
+
const startedAt = now2();
|
|
445773
|
+
let lastProgressAt = startedAt;
|
|
445774
|
+
let lastOnlineCheckAt = startedAt;
|
|
445775
|
+
let lastRunStatusCheckAt = 0;
|
|
445776
|
+
let lastRuntimeStatusCheckAt = 0;
|
|
445777
|
+
let mode = "unknown";
|
|
445778
|
+
let runtimeTurnOverAt = null;
|
|
445779
|
+
let highestSequenceId = null;
|
|
445780
|
+
let completedWithoutTextAt = null;
|
|
445635
445781
|
let inputSequenceId = null;
|
|
445636
|
-
while (
|
|
445782
|
+
while (true) {
|
|
445637
445783
|
const page = params.conversationId === "default" ? await params.backend.listAgentMessages(params.agentId, {
|
|
445638
445784
|
conversation_id: "default",
|
|
445639
445785
|
limit: 50,
|
|
@@ -445643,10 +445789,19 @@ async function waitForEnvironmentAssistantMessage(params) {
|
|
|
445643
445789
|
order: "desc"
|
|
445644
445790
|
});
|
|
445645
445791
|
const messages = pageItems5(page);
|
|
445792
|
+
for (const message of messages) {
|
|
445793
|
+
const sequenceId = messageSequenceId(message);
|
|
445794
|
+
if (sequenceId !== null && (highestSequenceId === null || sequenceId > highestSequenceId)) {
|
|
445795
|
+
highestSequenceId = sequenceId;
|
|
445796
|
+
lastProgressAt = now2();
|
|
445797
|
+
}
|
|
445798
|
+
}
|
|
445646
445799
|
if (inputSequenceId === null) {
|
|
445647
445800
|
const inputMessage = messages.find((message) => isUserMessage(message) && message.otid === params.otid);
|
|
445648
445801
|
inputSequenceId = inputMessage ? messageSequenceId(inputMessage) : null;
|
|
445649
445802
|
}
|
|
445803
|
+
let assistant;
|
|
445804
|
+
let newestRunId = null;
|
|
445650
445805
|
if (inputSequenceId !== null) {
|
|
445651
445806
|
const anchorSequenceId = inputSequenceId;
|
|
445652
445807
|
const newerMessages = messages.filter((message) => {
|
|
@@ -445662,25 +445817,104 @@ async function waitForEnvironmentAssistantMessage(params) {
|
|
|
445662
445817
|
return closest;
|
|
445663
445818
|
return closest === null || sequenceId < closest ? sequenceId : closest;
|
|
445664
445819
|
}, null);
|
|
445665
|
-
const
|
|
445820
|
+
const turnMessages = newerMessages.filter((message) => {
|
|
445666
445821
|
const sequenceId = messageSequenceId(message);
|
|
445667
|
-
return
|
|
445668
|
-
})
|
|
445669
|
-
|
|
445670
|
-
|
|
445671
|
-
|
|
445672
|
-
|
|
445822
|
+
return sequenceId !== null && (nextUserSequenceId === null || sequenceId < nextUserSequenceId);
|
|
445823
|
+
});
|
|
445824
|
+
assistant = turnMessages.filter((message) => isAssistantMessage2(message)).sort((a2, b3) => (messageSequenceId(b3) ?? 0) - (messageSequenceId(a2) ?? 0))[0];
|
|
445825
|
+
newestRunId = messageRunId(assistant) ?? turnMessages.sort((a2, b3) => (messageSequenceId(b3) ?? 0) - (messageSequenceId(a2) ?? 0)).map((message) => messageRunId(message)).find((id2) => id2 !== null) ?? null;
|
|
445826
|
+
}
|
|
445827
|
+
if (mode !== "runs") {
|
|
445828
|
+
const shouldCheckRuntimeStatus = assistant !== undefined || lastRuntimeStatusCheckAt === 0 || now2() - lastRuntimeStatusCheckAt >= runStatusIntervalMs;
|
|
445829
|
+
if (shouldCheckRuntimeStatus) {
|
|
445830
|
+
lastRuntimeStatusCheckAt = now2();
|
|
445831
|
+
let snapshot = null;
|
|
445832
|
+
try {
|
|
445833
|
+
snapshot = await fetchRuntimeStatus(params.agentId, [
|
|
445834
|
+
params.conversationId
|
|
445835
|
+
]);
|
|
445836
|
+
} catch (error5) {
|
|
445837
|
+
if (error5 instanceof ApiRequestError && error5.status === 404) {
|
|
445838
|
+
mode = "runs";
|
|
445839
|
+
}
|
|
445840
|
+
}
|
|
445841
|
+
if (snapshot) {
|
|
445842
|
+
mode = "runtime-status";
|
|
445843
|
+
const status = snapshot.statuses.find((entry) => entry.conversation_id === params.conversationId) ?? (snapshot.statuses.length === 1 ? snapshot.statuses[0] : null) ?? null;
|
|
445844
|
+
if (status && !isRuntimeTurnOver(status)) {
|
|
445845
|
+
lastProgressAt = now2();
|
|
445846
|
+
runtimeTurnOverAt = null;
|
|
445847
|
+
} else if (status && inputSequenceId !== null) {
|
|
445848
|
+
const text2 = assistant ? extractMessageText(assistant).trim() : "";
|
|
445849
|
+
if (text2.length > 0) {
|
|
445850
|
+
let stopReason = null;
|
|
445851
|
+
if (newestRunId) {
|
|
445852
|
+
try {
|
|
445853
|
+
const run = await params.backend.retrieveRun(newestRunId);
|
|
445854
|
+
stopReason = run.stop_reason ?? null;
|
|
445855
|
+
} catch {}
|
|
445856
|
+
}
|
|
445857
|
+
return { text: text2, stopReason };
|
|
445858
|
+
}
|
|
445859
|
+
runtimeTurnOverAt ??= now2();
|
|
445860
|
+
if (now2() - runtimeTurnOverAt >= COMPLETED_WITHOUT_TEXT_GRACE_MS) {
|
|
445861
|
+
throw new Error("Environment turn ended without an assistant reply " + `(runtime state ${status.state})`);
|
|
445862
|
+
}
|
|
445863
|
+
}
|
|
445864
|
+
}
|
|
445865
|
+
}
|
|
445866
|
+
}
|
|
445867
|
+
if (mode !== "runtime-status" && inputSequenceId !== null) {
|
|
445868
|
+
const shouldCheckRun = newestRunId !== null && (assistant !== undefined || now2() - lastRunStatusCheckAt >= runStatusIntervalMs);
|
|
445869
|
+
if (newestRunId && shouldCheckRun) {
|
|
445870
|
+
lastRunStatusCheckAt = now2();
|
|
445871
|
+
const run = await params.backend.retrieveRun(newestRunId);
|
|
445872
|
+
if (!isTerminalRunStatus(run.status)) {
|
|
445873
|
+
lastProgressAt = now2();
|
|
445874
|
+
} else if (run.stop_reason !== "requires_approval") {
|
|
445673
445875
|
const text2 = assistant ? extractMessageText(assistant).trim() : "";
|
|
445674
445876
|
if (text2.length > 0) {
|
|
445675
445877
|
return { text: text2, stopReason: run.stop_reason ?? null };
|
|
445676
445878
|
}
|
|
445879
|
+
if (run.status === "failed" || run.status === "cancelled") {
|
|
445880
|
+
throw new Error(`Environment turn run ${newestRunId} ${run.status} without an assistant reply` + (run.stop_reason ? ` (stop reason: ${run.stop_reason})` : ""));
|
|
445881
|
+
}
|
|
445882
|
+
completedWithoutTextAt ??= now2();
|
|
445883
|
+
if (now2() - completedWithoutTextAt >= COMPLETED_WITHOUT_TEXT_GRACE_MS) {
|
|
445884
|
+
throw new Error(`Environment turn run ${newestRunId} completed without an assistant reply`);
|
|
445885
|
+
}
|
|
445677
445886
|
}
|
|
445678
445887
|
}
|
|
445679
445888
|
}
|
|
445680
|
-
|
|
445889
|
+
if (params.deviceId && now2() - lastOnlineCheckAt >= onlineCheckIntervalMs) {
|
|
445890
|
+
lastOnlineCheckAt = now2();
|
|
445891
|
+
let offline = false;
|
|
445892
|
+
try {
|
|
445893
|
+
const connection = await fetchEnvironment(params.deviceId);
|
|
445894
|
+
offline = !isEnvironmentOnline(connection);
|
|
445895
|
+
} catch {}
|
|
445896
|
+
if (offline) {
|
|
445897
|
+
throw new Error(`Environment device ${params.deviceId} went offline before the turn completed`);
|
|
445898
|
+
}
|
|
445899
|
+
}
|
|
445900
|
+
if (now2() - lastProgressAt >= inactivityTimeoutMs) {
|
|
445901
|
+
throw new Error(`No activity from the environment turn for ${inactivityTimeoutMs}ms (no new messages and no running run); giving up`);
|
|
445902
|
+
}
|
|
445903
|
+
if (now2() - startedAt >= maxWaitMs) {
|
|
445904
|
+
throw new Error(`Environment turn did not complete within ${maxWaitMs}ms (set LETTA_ENVIRONMENT_TIMEOUT_MS to raise the ceiling)`);
|
|
445905
|
+
}
|
|
445906
|
+
await sleep10(pollIntervalMs);
|
|
445681
445907
|
}
|
|
445682
|
-
throw new Error("Timed out waiting for environment turn completion");
|
|
445683
445908
|
}
|
|
445909
|
+
var DEFAULT_MAX_WAIT_MS, DEFAULT_INACTIVITY_TIMEOUT_MS, DEFAULT_ONLINE_CHECK_INTERVAL_MS = 30000, DEFAULT_RUN_STATUS_INTERVAL_MS = 1e4, COMPLETED_WITHOUT_TEXT_GRACE_MS = 15000;
|
|
445910
|
+
var init_headless_environment_response = __esm(() => {
|
|
445911
|
+
init_agents7();
|
|
445912
|
+
init_environments2();
|
|
445913
|
+
init_request();
|
|
445914
|
+
init_filter();
|
|
445915
|
+
DEFAULT_MAX_WAIT_MS = 60 * 60000;
|
|
445916
|
+
DEFAULT_INACTIVITY_TIMEOUT_MS = 10 * 60000;
|
|
445917
|
+
});
|
|
445684
445918
|
|
|
445685
445919
|
// src/agent/ephemeral-conversation.ts
|
|
445686
445920
|
async function buildEphemeralConversationCreateBody(options) {
|
|
@@ -446712,7 +446946,7 @@ __export(exports_headless, {
|
|
|
446712
446946
|
decideInterruptAction: () => decideInterruptAction,
|
|
446713
446947
|
__headlessTestUtils: () => __headlessTestUtils
|
|
446714
446948
|
});
|
|
446715
|
-
import { randomUUID as
|
|
446949
|
+
import { randomUUID as randomUUID36 } from "node:crypto";
|
|
446716
446950
|
function trackHeadlessBoundaryError(errorType, error5, context3) {
|
|
446717
446951
|
trackBoundaryError({
|
|
446718
446952
|
errorType,
|
|
@@ -446734,7 +446968,7 @@ async function reportStartupErrorAndExit(errorType, error5, context3, outputForm
|
|
|
446734
446968
|
message,
|
|
446735
446969
|
stop_reason: "error",
|
|
446736
446970
|
session_id: "startup",
|
|
446737
|
-
uuid: `startup-error-${
|
|
446971
|
+
uuid: `startup-error-${randomUUID36()}`
|
|
446738
446972
|
};
|
|
446739
446973
|
await writeWireMessageAsync(errorMsg);
|
|
446740
446974
|
} else {
|
|
@@ -446833,7 +447067,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
|
|
|
446833
447067
|
message: options.reason,
|
|
446834
447068
|
stop_reason: "cancelled",
|
|
446835
447069
|
session_id: options.sessionId,
|
|
446836
|
-
uuid: `error-turn-start-cancel-${
|
|
447070
|
+
uuid: `error-turn-start-cancel-${randomUUID36()}`
|
|
446837
447071
|
};
|
|
446838
447072
|
await writeWireMessageAsync(errorMsg);
|
|
446839
447073
|
const resultMsg = {
|
|
@@ -446848,7 +447082,7 @@ async function emitHeadlessTurnStartCancellationOutput(options) {
|
|
|
446848
447082
|
conversation_id: options.conversationId,
|
|
446849
447083
|
run_ids: [],
|
|
446850
447084
|
usage: null,
|
|
446851
|
-
uuid: `result-turn-start-cancel-${
|
|
447085
|
+
uuid: `result-turn-start-cancel-${randomUUID36()}`,
|
|
446852
447086
|
stop_reason: "cancelled"
|
|
446853
447087
|
};
|
|
446854
447088
|
await writeWireMessageAsync(resultMsg);
|
|
@@ -446877,7 +447111,7 @@ function writeBidirectionalTurnStartCancellation(options) {
|
|
|
446877
447111
|
message: options.reason,
|
|
446878
447112
|
stop_reason: "cancelled",
|
|
446879
447113
|
session_id: options.sessionId,
|
|
446880
|
-
uuid: `error-turn-start-cancel-${
|
|
447114
|
+
uuid: `error-turn-start-cancel-${randomUUID36()}`
|
|
446881
447115
|
};
|
|
446882
447116
|
writeWireMessage(errorMsg);
|
|
446883
447117
|
const resultMsg = {
|
|
@@ -446892,7 +447126,7 @@ function writeBidirectionalTurnStartCancellation(options) {
|
|
|
446892
447126
|
conversation_id: options.conversationId,
|
|
446893
447127
|
run_ids: [],
|
|
446894
447128
|
usage: null,
|
|
446895
|
-
uuid: `result-turn-start-cancel-${
|
|
447129
|
+
uuid: `result-turn-start-cancel-${randomUUID36()}`,
|
|
446896
447130
|
stop_reason: "cancelled"
|
|
446897
447131
|
};
|
|
446898
447132
|
writeWireMessage(resultMsg);
|
|
@@ -447771,7 +448005,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
447771
448005
|
const approvalInput = {
|
|
447772
448006
|
type: "approval",
|
|
447773
448007
|
approvals: denialResults,
|
|
447774
|
-
otid:
|
|
448008
|
+
otid: randomUUID36()
|
|
447775
448009
|
};
|
|
447776
448010
|
const approvalMessages = [approvalInput];
|
|
447777
448011
|
{
|
|
@@ -447784,7 +448018,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
447784
448018
|
type: "text",
|
|
447785
448019
|
text: sc.content
|
|
447786
448020
|
})),
|
|
447787
|
-
otid:
|
|
448021
|
+
otid: randomUUID36()
|
|
447788
448022
|
});
|
|
447789
448023
|
}
|
|
447790
448024
|
}
|
|
@@ -447817,7 +448051,7 @@ Current session AGENT_ID=${process.env.AGENT_ID}; --backend local switches to a
|
|
|
447817
448051
|
message: `Failed to resolve pending approvals on resume: ${approvalError instanceof Error ? approvalError.message : String(approvalError)}`,
|
|
447818
448052
|
stop_reason: "error",
|
|
447819
448053
|
session_id: sessionId,
|
|
447820
|
-
uuid: `error-pre-loop-approval-${
|
|
448054
|
+
uuid: `error-pre-loop-approval-${randomUUID36()}`
|
|
447821
448055
|
};
|
|
447822
448056
|
writeWireMessage(errorMsg);
|
|
447823
448057
|
} else {
|
|
@@ -447956,26 +448190,20 @@ ${loadedContents.join(`
|
|
|
447956
448190
|
}
|
|
447957
448191
|
await exitHeadless(1, "headless_environment_unsupported");
|
|
447958
448192
|
}
|
|
447959
|
-
const otid =
|
|
447960
|
-
await sendEnvironmentMessage(connectionId, {
|
|
448193
|
+
const otid = randomUUID36();
|
|
448194
|
+
await sendEnvironmentMessage(connectionId, buildEnvironmentCreateMessageBody({
|
|
447961
448195
|
agentId: agent.id,
|
|
447962
448196
|
conversationId,
|
|
447963
|
-
|
|
447964
|
-
|
|
447965
|
-
|
|
447966
|
-
content: contentParts,
|
|
447967
|
-
client_message_id: randomUUID35(),
|
|
447968
|
-
otid
|
|
447969
|
-
}
|
|
447970
|
-
]
|
|
447971
|
-
});
|
|
448197
|
+
content: contentParts,
|
|
448198
|
+
otid
|
|
448199
|
+
}));
|
|
447972
448200
|
const environmentResult = await waitForEnvironmentAssistantMessage({
|
|
447973
448201
|
backend: backend3,
|
|
447974
448202
|
agentId: agent.id,
|
|
447975
448203
|
conversationId,
|
|
447976
|
-
otid
|
|
448204
|
+
otid,
|
|
448205
|
+
deviceId: environment2.deviceId
|
|
447977
448206
|
});
|
|
447978
|
-
const resultText2 = environmentResult.text;
|
|
447979
448207
|
const stats2 = sessionStats.getSnapshot();
|
|
447980
448208
|
if (outputFormat === "json") {
|
|
447981
448209
|
await writeFinalHeadlessStdout(`${JSON.stringify({
|
|
@@ -447985,7 +448213,7 @@ ${loadedContents.join(`
|
|
|
447985
448213
|
duration_ms: Math.round(stats2.totalWallMs),
|
|
447986
448214
|
duration_api_ms: Math.round(stats2.totalApiMs),
|
|
447987
448215
|
num_turns: 1,
|
|
447988
|
-
result:
|
|
448216
|
+
result: environmentResult.text,
|
|
447989
448217
|
agent_id: publicAgentId,
|
|
447990
448218
|
conversation_id: conversationId,
|
|
447991
448219
|
environment: responseEnvironment,
|
|
@@ -448001,7 +448229,7 @@ ${loadedContents.join(`
|
|
|
448001
448229
|
duration_ms: Math.round(stats2.totalWallMs),
|
|
448002
448230
|
duration_api_ms: Math.round(stats2.totalApiMs),
|
|
448003
448231
|
num_turns: 1,
|
|
448004
|
-
result:
|
|
448232
|
+
result: environmentResult.text,
|
|
448005
448233
|
agent_id: publicAgentId,
|
|
448006
448234
|
conversation_id: conversationId,
|
|
448007
448235
|
environment: responseEnvironment,
|
|
@@ -448012,7 +448240,7 @@ ${loadedContents.join(`
|
|
|
448012
448240
|
};
|
|
448013
448241
|
writeWireMessage(resultEvent);
|
|
448014
448242
|
} else {
|
|
448015
|
-
await writeFinalHeadlessStdout(`${
|
|
448243
|
+
await writeFinalHeadlessStdout(`${environmentResult.text}
|
|
448016
448244
|
`);
|
|
448017
448245
|
}
|
|
448018
448246
|
await exitHeadless(0, "headless_environment_message_complete");
|
|
@@ -448021,7 +448249,7 @@ ${loadedContents.join(`
|
|
|
448021
448249
|
{
|
|
448022
448250
|
role: "user",
|
|
448023
448251
|
content: contentParts,
|
|
448024
|
-
otid:
|
|
448252
|
+
otid: randomUUID36()
|
|
448025
448253
|
}
|
|
448026
448254
|
];
|
|
448027
448255
|
const recoveredApprovalResults = queuedRecoveredApprovalResults ?? [];
|
|
@@ -448030,7 +448258,7 @@ ${loadedContents.join(`
|
|
|
448030
448258
|
{
|
|
448031
448259
|
type: "approval",
|
|
448032
448260
|
approvals: recoveredApprovalResults,
|
|
448033
|
-
otid:
|
|
448261
|
+
otid: randomUUID36()
|
|
448034
448262
|
},
|
|
448035
448263
|
...currentInput
|
|
448036
448264
|
];
|
|
@@ -448076,7 +448304,7 @@ ${loadedContents.join(`
|
|
|
448076
448304
|
message: `Maximum turns limit reached (${buffers.usage.stepCount}/${maxTurns} steps)`,
|
|
448077
448305
|
stop_reason: "max_steps",
|
|
448078
448306
|
session_id: sessionId,
|
|
448079
|
-
uuid: `error-max-turns-${
|
|
448307
|
+
uuid: `error-max-turns-${randomUUID36()}`
|
|
448080
448308
|
};
|
|
448081
448309
|
await writeWireMessageAsync(errorMsg);
|
|
448082
448310
|
} else {
|
|
@@ -448093,7 +448321,7 @@ ${loadedContents.join(`
|
|
|
448093
448321
|
message: "Interrupted by SIGINT",
|
|
448094
448322
|
stop_reason: "cancelled",
|
|
448095
448323
|
session_id: sessionId,
|
|
448096
|
-
uuid: `error-interrupted-${
|
|
448324
|
+
uuid: `error-interrupted-${randomUUID36()}`
|
|
448097
448325
|
};
|
|
448098
448326
|
await writeWireMessageAsync(errorMsg);
|
|
448099
448327
|
} else {
|
|
@@ -448122,7 +448350,7 @@ ${loadedContents.join(`
|
|
|
448122
448350
|
type: "text",
|
|
448123
448351
|
text: sc.content
|
|
448124
448352
|
})),
|
|
448125
|
-
otid:
|
|
448353
|
+
otid: randomUUID36()
|
|
448126
448354
|
}
|
|
448127
448355
|
];
|
|
448128
448356
|
}
|
|
@@ -448167,7 +448395,7 @@ ${loadedContents.join(`
|
|
|
448167
448395
|
recovery_type: "approval_pending",
|
|
448168
448396
|
message: "Detected pending approval conflict on send; resolving before retry",
|
|
448169
448397
|
session_id: sessionId,
|
|
448170
|
-
uuid: `recovery-pre-stream-${
|
|
448398
|
+
uuid: `recovery-pre-stream-${randomUUID36()}`
|
|
448171
448399
|
};
|
|
448172
448400
|
writeWireMessage(recoveryMsg);
|
|
448173
448401
|
} else {
|
|
@@ -448200,7 +448428,7 @@ ${loadedContents.join(`
|
|
|
448200
448428
|
max_attempts: CONVERSATION_BUSY_MAX_RETRIES,
|
|
448201
448429
|
delay_ms: retryDelayMs,
|
|
448202
448430
|
session_id: sessionId,
|
|
448203
|
-
uuid: `retry-conversation-busy-${
|
|
448431
|
+
uuid: `retry-conversation-busy-${randomUUID36()}`
|
|
448204
448432
|
};
|
|
448205
448433
|
writeWireMessage(retryMsg);
|
|
448206
448434
|
} else {
|
|
@@ -448228,7 +448456,7 @@ ${loadedContents.join(`
|
|
|
448228
448456
|
max_attempts: LLM_API_ERROR_MAX_RETRIES2,
|
|
448229
448457
|
delay_ms: delayMs,
|
|
448230
448458
|
session_id: sessionId,
|
|
448231
|
-
uuid: `retry-pre-stream-${
|
|
448459
|
+
uuid: `retry-pre-stream-${randomUUID36()}`
|
|
448232
448460
|
};
|
|
448233
448461
|
writeWireMessage(retryMsg);
|
|
448234
448462
|
} else {
|
|
@@ -448254,7 +448482,7 @@ ${loadedContents.join(`
|
|
|
448254
448482
|
stop_reason: "error",
|
|
448255
448483
|
run_id: errorInfo.run_id,
|
|
448256
448484
|
session_id: sessionId,
|
|
448257
|
-
uuid:
|
|
448485
|
+
uuid: randomUUID36(),
|
|
448258
448486
|
...errorInfo.error_type && errorInfo.run_id && {
|
|
448259
448487
|
api_error: {
|
|
448260
448488
|
message_type: "error_message",
|
|
@@ -448276,7 +448504,7 @@ ${loadedContents.join(`
|
|
|
448276
448504
|
message: "Detected pending approval conflict; auto-denying stale approval and retrying",
|
|
448277
448505
|
run_id: recoveryRunId ?? undefined,
|
|
448278
448506
|
session_id: sessionId,
|
|
448279
|
-
uuid: `recovery-${recoveryRunId ||
|
|
448507
|
+
uuid: `recovery-${recoveryRunId || randomUUID36()}`
|
|
448280
448508
|
};
|
|
448281
448509
|
writeWireMessage(recoveryMsg);
|
|
448282
448510
|
approvalPendingRecovery = true;
|
|
@@ -448294,7 +448522,7 @@ ${loadedContents.join(`
|
|
|
448294
448522
|
type: "stream_event",
|
|
448295
448523
|
event: chunk2,
|
|
448296
448524
|
session_id: sessionId,
|
|
448297
|
-
uuid: uuid3 ||
|
|
448525
|
+
uuid: uuid3 || randomUUID36()
|
|
448298
448526
|
};
|
|
448299
448527
|
writeWireMessage(streamEvent);
|
|
448300
448528
|
} else {
|
|
@@ -448302,7 +448530,7 @@ ${loadedContents.join(`
|
|
|
448302
448530
|
type: "message",
|
|
448303
448531
|
...chunk2,
|
|
448304
448532
|
session_id: sessionId,
|
|
448305
|
-
uuid: uuid3 ||
|
|
448533
|
+
uuid: uuid3 || randomUUID36()
|
|
448306
448534
|
};
|
|
448307
448535
|
writeWireMessage(msg);
|
|
448308
448536
|
}
|
|
@@ -448346,7 +448574,7 @@ ${loadedContents.join(`
|
|
|
448346
448574
|
{
|
|
448347
448575
|
role: "user",
|
|
448348
448576
|
content: continueMessage,
|
|
448349
|
-
otid:
|
|
448577
|
+
otid: randomUUID36()
|
|
448350
448578
|
}
|
|
448351
448579
|
];
|
|
448352
448580
|
const continueTurnStartEmission = await emitHeadlessTurnStart({
|
|
@@ -448418,7 +448646,7 @@ ${loadedContents.join(`
|
|
|
448418
448646
|
const approvalInputWithOtid = {
|
|
448419
448647
|
type: "approval",
|
|
448420
448648
|
approvals: executedResults,
|
|
448421
|
-
otid:
|
|
448649
|
+
otid: randomUUID36()
|
|
448422
448650
|
};
|
|
448423
448651
|
currentInput = [approvalInputWithOtid];
|
|
448424
448652
|
continue;
|
|
@@ -448451,7 +448679,7 @@ ${loadedContents.join(`
|
|
|
448451
448679
|
delay_ms: 0,
|
|
448452
448680
|
run_id: lastRunId ?? undefined,
|
|
448453
448681
|
session_id: sessionId,
|
|
448454
|
-
uuid: `retry-${lastRunId ||
|
|
448682
|
+
uuid: `retry-${lastRunId || randomUUID36()}`
|
|
448455
448683
|
};
|
|
448456
448684
|
writeWireMessage(retryMsg);
|
|
448457
448685
|
} else {
|
|
@@ -448479,7 +448707,7 @@ ${loadedContents.join(`
|
|
|
448479
448707
|
delay_ms: delayMs,
|
|
448480
448708
|
run_id: lastRunId ?? undefined,
|
|
448481
448709
|
session_id: sessionId,
|
|
448482
|
-
uuid: `retry-${lastRunId ||
|
|
448710
|
+
uuid: `retry-${lastRunId || randomUUID36()}`
|
|
448483
448711
|
};
|
|
448484
448712
|
writeWireMessage(retryMsg);
|
|
448485
448713
|
} else {
|
|
@@ -448500,7 +448728,7 @@ ${loadedContents.join(`
|
|
|
448500
448728
|
message: "Tool call ID mismatch; fetching actual pending approvals and resyncing",
|
|
448501
448729
|
run_id: lastRunId ?? undefined,
|
|
448502
448730
|
session_id: sessionId,
|
|
448503
|
-
uuid: `recovery-${lastRunId ||
|
|
448731
|
+
uuid: `recovery-${lastRunId || randomUUID36()}`
|
|
448504
448732
|
};
|
|
448505
448733
|
writeWireMessage(recoveryMsg);
|
|
448506
448734
|
} else {
|
|
@@ -448517,7 +448745,7 @@ ${loadedContents.join(`
|
|
|
448517
448745
|
stop_reason: stopReason,
|
|
448518
448746
|
run_id: lastRunId ?? undefined,
|
|
448519
448747
|
session_id: sessionId,
|
|
448520
|
-
uuid: `error-${lastRunId ||
|
|
448748
|
+
uuid: `error-${lastRunId || randomUUID36()}`
|
|
448521
448749
|
};
|
|
448522
448750
|
await writeWireMessageAsync(errorMsg);
|
|
448523
448751
|
} else {
|
|
@@ -448559,7 +448787,7 @@ ${loadedContents.join(`
|
|
|
448559
448787
|
const nudgeMessage = {
|
|
448560
448788
|
role: "system",
|
|
448561
448789
|
content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
|
|
448562
|
-
otid:
|
|
448790
|
+
otid: randomUUID36()
|
|
448563
448791
|
};
|
|
448564
448792
|
currentInput = [...currentInput, nudgeMessage];
|
|
448565
448793
|
}
|
|
@@ -448572,7 +448800,7 @@ ${loadedContents.join(`
|
|
|
448572
448800
|
delay_ms: delayMs,
|
|
448573
448801
|
run_id: lastRunId ?? undefined,
|
|
448574
448802
|
session_id: sessionId,
|
|
448575
|
-
uuid: `retry-empty-${lastRunId ||
|
|
448803
|
+
uuid: `retry-empty-${lastRunId || randomUUID36()}`
|
|
448576
448804
|
};
|
|
448577
448805
|
writeWireMessage(retryMsg);
|
|
448578
448806
|
} else {
|
|
@@ -448599,7 +448827,7 @@ ${loadedContents.join(`
|
|
|
448599
448827
|
delay_ms: delayMs,
|
|
448600
448828
|
run_id: lastRunId ?? undefined,
|
|
448601
448829
|
session_id: sessionId,
|
|
448602
|
-
uuid: `retry-${lastRunId ||
|
|
448830
|
+
uuid: `retry-${lastRunId || randomUUID36()}`
|
|
448603
448831
|
};
|
|
448604
448832
|
writeWireMessage(retryMsg);
|
|
448605
448833
|
} else {
|
|
@@ -448629,7 +448857,7 @@ ${loadedContents.join(`
|
|
|
448629
448857
|
delay_ms: delayMs,
|
|
448630
448858
|
run_id: lastRunId ?? undefined,
|
|
448631
448859
|
session_id: sessionId,
|
|
448632
|
-
uuid: `retry-${lastRunId ||
|
|
448860
|
+
uuid: `retry-${lastRunId || randomUUID36()}`
|
|
448633
448861
|
};
|
|
448634
448862
|
writeWireMessage(retryMsg);
|
|
448635
448863
|
} else {
|
|
@@ -448678,7 +448906,7 @@ ${loadedContents.join(`
|
|
|
448678
448906
|
stop_reason: stopReason,
|
|
448679
448907
|
run_id: lastRunId ?? undefined,
|
|
448680
448908
|
session_id: sessionId,
|
|
448681
|
-
uuid: `error-${lastRunId ||
|
|
448909
|
+
uuid: `error-${lastRunId || randomUUID36()}`
|
|
448682
448910
|
};
|
|
448683
448911
|
await writeWireMessageAsync(errorMsg);
|
|
448684
448912
|
} else {
|
|
@@ -448697,7 +448925,7 @@ ${loadedContents.join(`
|
|
|
448697
448925
|
stop_reason: "error",
|
|
448698
448926
|
run_id: lastKnownRunId ?? undefined,
|
|
448699
448927
|
session_id: sessionId,
|
|
448700
|
-
uuid: `error-${lastKnownRunId ||
|
|
448928
|
+
uuid: `error-${lastKnownRunId || randomUUID36()}`
|
|
448701
448929
|
};
|
|
448702
448930
|
await writeWireMessageAsync(errorMsg);
|
|
448703
448931
|
} else {
|
|
@@ -448894,7 +449122,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
448894
449122
|
const approvalInput = {
|
|
448895
449123
|
type: "approval",
|
|
448896
449124
|
approvals: denialResults,
|
|
448897
|
-
otid:
|
|
449125
|
+
otid: randomUUID36()
|
|
448898
449126
|
};
|
|
448899
449127
|
const approvalMessages = [approvalInput];
|
|
448900
449128
|
{
|
|
@@ -448907,7 +449135,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
448907
449135
|
type: "text",
|
|
448908
449136
|
text: sc.content
|
|
448909
449137
|
})),
|
|
448910
|
-
otid:
|
|
449138
|
+
otid: randomUUID36()
|
|
448911
449139
|
});
|
|
448912
449140
|
}
|
|
448913
449141
|
}
|
|
@@ -448965,7 +449193,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
448965
449193
|
reason,
|
|
448966
449194
|
cleared_count: clearedCount,
|
|
448967
449195
|
session_id: sessionId,
|
|
448968
|
-
uuid: `q-clr-${
|
|
449196
|
+
uuid: `q-clr-${randomUUID36()}`
|
|
448969
449197
|
})
|
|
448970
449198
|
}
|
|
448971
449199
|
});
|
|
@@ -448995,7 +449223,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
448995
449223
|
reason: "runtime_busy",
|
|
448996
449224
|
queue_len: Math.max(1, queueLen),
|
|
448997
449225
|
session_id: sessionId,
|
|
448998
|
-
uuid: `q-blk-${
|
|
449226
|
+
uuid: `q-blk-${randomUUID36()}`
|
|
448999
449227
|
});
|
|
449000
449228
|
}
|
|
449001
449229
|
function enqueueForTracking(input) {
|
|
@@ -449067,7 +449295,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449067
449295
|
request_id: interruptRequestId
|
|
449068
449296
|
},
|
|
449069
449297
|
session_id: sessionId,
|
|
449070
|
-
uuid:
|
|
449298
|
+
uuid: randomUUID36()
|
|
449071
449299
|
};
|
|
449072
449300
|
writeWireMessage(interruptResponse);
|
|
449073
449301
|
return;
|
|
@@ -449170,7 +449398,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449170
449398
|
const approvalInput = {
|
|
449171
449399
|
type: "approval",
|
|
449172
449400
|
approvals: denialResults,
|
|
449173
|
-
otid:
|
|
449401
|
+
otid: randomUUID36()
|
|
449174
449402
|
};
|
|
449175
449403
|
const approvalStream = await sendScopedApprovalMessages({
|
|
449176
449404
|
agentId: agent.id,
|
|
@@ -449209,7 +449437,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449209
449437
|
message: "Invalid JSON input",
|
|
449210
449438
|
stop_reason: "error",
|
|
449211
449439
|
session_id: sessionId,
|
|
449212
|
-
uuid:
|
|
449440
|
+
uuid: randomUUID36()
|
|
449213
449441
|
};
|
|
449214
449442
|
writeWireMessage(errorMsg2);
|
|
449215
449443
|
continue;
|
|
@@ -449235,7 +449463,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449235
449463
|
}
|
|
449236
449464
|
},
|
|
449237
449465
|
session_id: sessionId,
|
|
449238
|
-
uuid:
|
|
449466
|
+
uuid: randomUUID36()
|
|
449239
449467
|
};
|
|
449240
449468
|
writeWireMessage(initResponse);
|
|
449241
449469
|
} else if (subtype === "interrupt") {
|
|
@@ -449252,7 +449480,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449252
449480
|
request_id: requestId ?? ""
|
|
449253
449481
|
},
|
|
449254
449482
|
session_id: sessionId,
|
|
449255
|
-
uuid:
|
|
449483
|
+
uuid: randomUUID36()
|
|
449256
449484
|
};
|
|
449257
449485
|
writeWireMessage(interruptResponse);
|
|
449258
449486
|
} else if (subtype === "register_external_tools") {
|
|
@@ -449300,7 +449528,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449300
449528
|
response: { registered: tools.length }
|
|
449301
449529
|
},
|
|
449302
449530
|
session_id: sessionId,
|
|
449303
|
-
uuid:
|
|
449531
|
+
uuid: randomUUID36()
|
|
449304
449532
|
};
|
|
449305
449533
|
writeWireMessage(registerResponse);
|
|
449306
449534
|
} else if (subtype === "bootstrap_session_state") {
|
|
@@ -449356,7 +449584,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449356
449584
|
response: recovery
|
|
449357
449585
|
},
|
|
449358
449586
|
session_id: sessionId,
|
|
449359
|
-
uuid:
|
|
449587
|
+
uuid: randomUUID36()
|
|
449360
449588
|
};
|
|
449361
449589
|
writeWireMessage(recoveryResponse);
|
|
449362
449590
|
} catch (error5) {
|
|
@@ -449368,7 +449596,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449368
449596
|
error: error5 instanceof Error ? error5.message : String(error5)
|
|
449369
449597
|
},
|
|
449370
449598
|
session_id: sessionId,
|
|
449371
|
-
uuid:
|
|
449599
|
+
uuid: randomUUID36()
|
|
449372
449600
|
};
|
|
449373
449601
|
writeWireMessage(recoveryError);
|
|
449374
449602
|
}
|
|
@@ -449381,7 +449609,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449381
449609
|
error: `Unknown control request subtype: ${subtype}`
|
|
449382
449610
|
},
|
|
449383
449611
|
session_id: sessionId,
|
|
449384
|
-
uuid:
|
|
449612
|
+
uuid: randomUUID36()
|
|
449385
449613
|
};
|
|
449386
449614
|
writeWireMessage(errorResponse);
|
|
449387
449615
|
}
|
|
@@ -449436,7 +449664,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449436
449664
|
try {
|
|
449437
449665
|
const buffers = createBuffers(agent.id);
|
|
449438
449666
|
const startTime = performance.now();
|
|
449439
|
-
const userOtid =
|
|
449667
|
+
const userOtid = randomUUID36();
|
|
449440
449668
|
const userTranscriptText = extractTelemetryInputText(userContent);
|
|
449441
449669
|
if (userTranscriptText.length > 0) {
|
|
449442
449670
|
const userLineId = `user-${userOtid}`;
|
|
@@ -449558,7 +449786,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449558
449786
|
recovery_type: "approval_pending",
|
|
449559
449787
|
message: "Detected pending approval conflict on send; resolving before retry",
|
|
449560
449788
|
session_id: sessionId,
|
|
449561
|
-
uuid: `recovery-bidir-${
|
|
449789
|
+
uuid: `recovery-bidir-${randomUUID36()}`
|
|
449562
449790
|
};
|
|
449563
449791
|
writeWireMessage(recoveryMsg);
|
|
449564
449792
|
await resolveAllPendingApprovals();
|
|
@@ -449581,7 +449809,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449581
449809
|
max_attempts: LLM_API_ERROR_MAX_RETRIES2,
|
|
449582
449810
|
delay_ms: delayMs,
|
|
449583
449811
|
session_id: sessionId,
|
|
449584
|
-
uuid: `retry-bidir-${
|
|
449812
|
+
uuid: `retry-bidir-${randomUUID36()}`
|
|
449585
449813
|
};
|
|
449586
449814
|
writeWireMessage(retryMsg);
|
|
449587
449815
|
await new Promise((resolve40) => setTimeout(resolve40, delayMs));
|
|
@@ -449603,7 +449831,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449603
449831
|
stop_reason: "error",
|
|
449604
449832
|
run_id: errorInfo.run_id,
|
|
449605
449833
|
session_id: sessionId,
|
|
449606
|
-
uuid:
|
|
449834
|
+
uuid: randomUUID36(),
|
|
449607
449835
|
...errorInfo.error_type && errorInfo.run_id && {
|
|
449608
449836
|
api_error: {
|
|
449609
449837
|
message_type: "error_message",
|
|
@@ -449631,7 +449859,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449631
449859
|
type: "stream_event",
|
|
449632
449860
|
event: chunk2,
|
|
449633
449861
|
session_id: sessionId,
|
|
449634
|
-
uuid: uuid3 ||
|
|
449862
|
+
uuid: uuid3 || randomUUID36()
|
|
449635
449863
|
};
|
|
449636
449864
|
writeWireMessage(streamEvent);
|
|
449637
449865
|
} else {
|
|
@@ -449639,7 +449867,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449639
449867
|
type: "message",
|
|
449640
449868
|
...chunk2,
|
|
449641
449869
|
session_id: sessionId,
|
|
449642
|
-
uuid: uuid3 ||
|
|
449870
|
+
uuid: uuid3 || randomUUID36()
|
|
449643
449871
|
};
|
|
449644
449872
|
writeWireMessage(msg);
|
|
449645
449873
|
}
|
|
@@ -449708,7 +449936,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449708
449936
|
const approvalInputWithOtid = {
|
|
449709
449937
|
type: "approval",
|
|
449710
449938
|
approvals: executedResults,
|
|
449711
|
-
otid:
|
|
449939
|
+
otid: randomUUID36()
|
|
449712
449940
|
};
|
|
449713
449941
|
currentInput = [approvalInputWithOtid];
|
|
449714
449942
|
continue;
|
|
@@ -449771,7 +449999,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449771
449999
|
message: errorDetails,
|
|
449772
450000
|
stop_reason: "error",
|
|
449773
450001
|
session_id: sessionId,
|
|
449774
|
-
uuid:
|
|
450002
|
+
uuid: randomUUID36()
|
|
449775
450003
|
};
|
|
449776
450004
|
writeWireMessage(errorMsg2);
|
|
449777
450005
|
const errorResultMsg = {
|
|
@@ -449814,7 +450042,7 @@ async function runBidirectionalMode(agent, conversationId, _outputFormat, includ
|
|
|
449814
450042
|
message: `Unknown message type: ${message.type}`,
|
|
449815
450043
|
stop_reason: "error",
|
|
449816
450044
|
session_id: sessionId,
|
|
449817
|
-
uuid:
|
|
450045
|
+
uuid: randomUUID36()
|
|
449818
450046
|
};
|
|
449819
450047
|
writeWireMessage(errorMsg);
|
|
449820
450048
|
}
|
|
@@ -449850,6 +450078,7 @@ var init_headless = __esm(async () => {
|
|
|
449850
450078
|
init_reflection_transcript();
|
|
449851
450079
|
init_local_backend_mod_events();
|
|
449852
450080
|
init_constants2();
|
|
450081
|
+
init_headless_environment_response();
|
|
449853
450082
|
init_headless_reflection_settings();
|
|
449854
450083
|
init_diff_preview();
|
|
449855
450084
|
init_format_denial();
|
|
@@ -451312,7 +451541,7 @@ var init_reflection_arena_hf_upload = __esm(() => {
|
|
|
451312
451541
|
|
|
451313
451542
|
// src/cli/helpers/reflection-arena.ts
|
|
451314
451543
|
import { execFile as execFileCb6 } from "node:child_process";
|
|
451315
|
-
import { randomInt as randomInt2, randomUUID as
|
|
451544
|
+
import { randomInt as randomInt2, randomUUID as randomUUID37 } from "node:crypto";
|
|
451316
451545
|
import { appendFile as appendFile3, mkdir as mkdir18, readFile as readFile30, writeFile as writeFile21 } from "node:fs/promises";
|
|
451317
451546
|
import { homedir as homedir47 } from "node:os";
|
|
451318
451547
|
import { join as join85 } from "node:path";
|
|
@@ -451674,7 +451903,7 @@ async function startReflectionArenaRun(options) {
|
|
|
451674
451903
|
}
|
|
451675
451904
|
let releaseReservation = true;
|
|
451676
451905
|
try {
|
|
451677
|
-
const runId =
|
|
451906
|
+
const runId = randomUUID37().slice(0, 8);
|
|
451678
451907
|
const labels = shuffledLabels();
|
|
451679
451908
|
const prepared = await Promise.all([
|
|
451680
451909
|
prepareReflectionMemoryWorktreeLaunch({
|
|
@@ -464303,22 +464532,6 @@ var init_InputRich = __esm(async () => {
|
|
|
464303
464532
|
EventEmitter5.defaultMaxListeners = 20;
|
|
464304
464533
|
});
|
|
464305
464534
|
|
|
464306
|
-
// src/backend/api/agents.ts
|
|
464307
|
-
async function getAgentContextOverview(agentId, options) {
|
|
464308
|
-
return apiRequest("GET", `/v1/agents/${agentId}/context`, undefined, {
|
|
464309
|
-
signal: options?.signal
|
|
464310
|
-
});
|
|
464311
|
-
}
|
|
464312
|
-
async function createMinimalAgent(apiKey, name) {
|
|
464313
|
-
return apiRequest("POST", "/v1/agents", { name }, {
|
|
464314
|
-
baseUrl: "https://api.letta.com",
|
|
464315
|
-
apiKey
|
|
464316
|
-
});
|
|
464317
|
-
}
|
|
464318
|
-
var init_agents7 = __esm(() => {
|
|
464319
|
-
init_request();
|
|
464320
|
-
});
|
|
464321
|
-
|
|
464322
464535
|
// src/cli/commands/install-github-app.ts
|
|
464323
464536
|
import { execFileSync as execFileSync7 } from "node:child_process";
|
|
464324
464537
|
import {
|
|
@@ -476777,12 +476990,12 @@ var init_ExitStats = __esm(async () => {
|
|
|
476777
476990
|
});
|
|
476778
476991
|
|
|
476779
476992
|
// src/cli/app/ids.ts
|
|
476780
|
-
import { randomUUID as
|
|
476993
|
+
import { randomUUID as randomUUID38 } from "node:crypto";
|
|
476781
476994
|
function uid(prefix) {
|
|
476782
476995
|
return `${prefix}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
|
476783
476996
|
}
|
|
476784
476997
|
function createClientOtid() {
|
|
476785
|
-
return
|
|
476998
|
+
return randomUUID38();
|
|
476786
476999
|
}
|
|
476787
477000
|
function appendOptimisticUserLine(buffers, text2, otid) {
|
|
476788
477001
|
if (!text2) {
|
|
@@ -493670,7 +493883,7 @@ var init_notifications = __esm(() => {
|
|
|
493670
493883
|
});
|
|
493671
493884
|
|
|
493672
493885
|
// src/cli/app/use-approval-flow.ts
|
|
493673
|
-
import { randomUUID as
|
|
493886
|
+
import { randomUUID as randomUUID39 } from "node:crypto";
|
|
493674
493887
|
function useApprovalFlow(ctx) {
|
|
493675
493888
|
const {
|
|
493676
493889
|
abortControllerRef,
|
|
@@ -494182,7 +494395,7 @@ function useApprovalFlow(ctx) {
|
|
|
494182
494395
|
{
|
|
494183
494396
|
type: "approval",
|
|
494184
494397
|
approvals: allResults,
|
|
494185
|
-
otid:
|
|
494398
|
+
otid: randomUUID39()
|
|
494186
494399
|
}
|
|
494187
494400
|
]);
|
|
494188
494401
|
} catch (error5) {
|
|
@@ -495581,7 +495794,7 @@ var init_system_reminders = __esm(() => {
|
|
|
495581
495794
|
});
|
|
495582
495795
|
|
|
495583
495796
|
// src/cli/app/use-conversation-loop.ts
|
|
495584
|
-
import { randomUUID as
|
|
495797
|
+
import { randomUUID as randomUUID40 } from "node:crypto";
|
|
495585
495798
|
function sleep10(ms) {
|
|
495586
495799
|
return new Promise((resolve43) => setTimeout(resolve43, ms));
|
|
495587
495800
|
}
|
|
@@ -495885,16 +496098,16 @@ function useConversationLoop(ctx) {
|
|
|
495885
496098
|
currentInput = [
|
|
495886
496099
|
...lastSentInputRef.current.map((m4) => ({
|
|
495887
496100
|
...m4,
|
|
495888
|
-
otid:
|
|
496101
|
+
otid: randomUUID40()
|
|
495889
496102
|
})),
|
|
495890
496103
|
...currentInput.map((m4) => m4.type === "message" && m4.role === "user" ? {
|
|
495891
496104
|
...m4,
|
|
495892
|
-
otid:
|
|
496105
|
+
otid: randomUUID40(),
|
|
495893
496106
|
content: [
|
|
495894
496107
|
{ type: "text", text: INTERRUPT_RECOVERY_ALERT },
|
|
495895
496108
|
...typeof m4.content === "string" ? [{ type: "text", text: m4.content }] : Array.isArray(m4.content) ? m4.content : []
|
|
495896
496109
|
]
|
|
495897
|
-
} : { ...m4, otid:
|
|
496110
|
+
} : { ...m4, otid: randomUUID40() })
|
|
495898
496111
|
];
|
|
495899
496112
|
pendingInterruptRecoveryConversationIdRef.current = null;
|
|
495900
496113
|
lastSentInputRef.current = [
|
|
@@ -495933,7 +496146,7 @@ function useConversationLoop(ctx) {
|
|
|
495933
496146
|
type: "text",
|
|
495934
496147
|
text: sc.content
|
|
495935
496148
|
})),
|
|
495936
|
-
otid:
|
|
496149
|
+
otid: randomUUID40()
|
|
495937
496150
|
}
|
|
495938
496151
|
];
|
|
495939
496152
|
}
|
|
@@ -496292,7 +496505,7 @@ ${feedback}
|
|
|
496292
496505
|
});
|
|
496293
496506
|
buffersRef.current.order.push(statusId);
|
|
496294
496507
|
refreshDerived();
|
|
496295
|
-
const hookMessageOtid =
|
|
496508
|
+
const hookMessageOtid = randomUUID40();
|
|
496296
496509
|
setTimeout(() => {
|
|
496297
496510
|
processConversation([
|
|
496298
496511
|
{
|
|
@@ -496319,7 +496532,7 @@ ${feedback}
|
|
|
496319
496532
|
turnEndContinue = undefined;
|
|
496320
496533
|
}
|
|
496321
496534
|
if (turnEndContinue) {
|
|
496322
|
-
const continueOtid =
|
|
496535
|
+
const continueOtid = randomUUID40();
|
|
496323
496536
|
setTimeout(() => {
|
|
496324
496537
|
processConversation([
|
|
496325
496538
|
{
|
|
@@ -496673,7 +496886,7 @@ ${feedback}
|
|
|
496673
496886
|
{
|
|
496674
496887
|
type: "approval",
|
|
496675
496888
|
approvals: allResults,
|
|
496676
|
-
otid:
|
|
496889
|
+
otid: randomUUID40()
|
|
496677
496890
|
}
|
|
496678
496891
|
], {
|
|
496679
496892
|
allowReentry: true,
|
|
@@ -496878,7 +497091,7 @@ ${feedback}
|
|
|
496878
497091
|
type: "message",
|
|
496879
497092
|
role: "system",
|
|
496880
497093
|
content: `<system-reminder>The previous response was empty. Please provide a response with either text content or a tool call.</system-reminder>`,
|
|
496881
|
-
otid:
|
|
497094
|
+
otid: randomUUID40()
|
|
496882
497095
|
}
|
|
496883
497096
|
];
|
|
496884
497097
|
}
|
|
@@ -497153,7 +497366,7 @@ var init_use_conversation_loop = __esm(async () => {
|
|
|
497153
497366
|
});
|
|
497154
497367
|
|
|
497155
497368
|
// src/cli/app/use-conversation-switching.ts
|
|
497156
|
-
import { randomUUID as
|
|
497369
|
+
import { randomUUID as randomUUID41 } from "node:crypto";
|
|
497157
497370
|
function useConversationSwitching(ctx) {
|
|
497158
497371
|
const {
|
|
497159
497372
|
abortControllerRef,
|
|
@@ -497228,7 +497441,7 @@ function useConversationSwitching(ctx) {
|
|
|
497228
497441
|
{
|
|
497229
497442
|
role: "user",
|
|
497230
497443
|
content: question,
|
|
497231
|
-
otid:
|
|
497444
|
+
otid: randomUUID41()
|
|
497232
497445
|
}
|
|
497233
497446
|
];
|
|
497234
497447
|
let approvalRecoveryRetries = 0;
|
|
@@ -502733,7 +502946,7 @@ var init_conversation_switch_alert = __esm(() => {
|
|
|
502733
502946
|
});
|
|
502734
502947
|
|
|
502735
502948
|
// src/cli/app/use-submit-handler.ts
|
|
502736
|
-
import { randomUUID as
|
|
502949
|
+
import { randomUUID as randomUUID42 } from "node:crypto";
|
|
502737
502950
|
import { existsSync as existsSync74, readFileSync as readFileSync46, renameSync as renameSync8, writeFileSync as writeFileSync39 } from "node:fs";
|
|
502738
502951
|
import { tmpdir as tmpdir13 } from "node:os";
|
|
502739
502952
|
import { join as join94 } from "node:path";
|
|
@@ -503154,7 +503367,7 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
503154
503367
|
content: buildTextParts(`${SYSTEM_REMINDER_OPEN}
|
|
503155
503368
|
${prompt}
|
|
503156
503369
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
503157
|
-
otid:
|
|
503370
|
+
otid: randomUUID42()
|
|
503158
503371
|
}
|
|
503159
503372
|
]);
|
|
503160
503373
|
} catch (error5) {
|
|
@@ -503218,7 +503431,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
503218
503431
|
type: "message",
|
|
503219
503432
|
role: "user",
|
|
503220
503433
|
content: buildTextParts(buildModCommandPrompt(result3)),
|
|
503221
|
-
otid:
|
|
503434
|
+
otid: randomUUID42()
|
|
503222
503435
|
}
|
|
503223
503436
|
]);
|
|
503224
503437
|
} else if (result3.type === "output") {
|
|
@@ -503263,7 +503476,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
503263
503476
|
${SYSTEM_REMINDER_OPEN}
|
|
503264
503477
|
${request2}
|
|
503265
503478
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
503266
|
-
otid:
|
|
503479
|
+
otid: randomUUID42()
|
|
503267
503480
|
}
|
|
503268
503481
|
]);
|
|
503269
503482
|
} catch (error5) {
|
|
@@ -503532,7 +503745,7 @@ ${SYSTEM_REMINDER_CLOSE}`),
|
|
|
503532
503745
|
${SYSTEM_REMINDER_OPEN}
|
|
503533
503746
|
${request2}
|
|
503534
503747
|
${SYSTEM_REMINDER_CLOSE}`),
|
|
503535
|
-
otid:
|
|
503748
|
+
otid: randomUUID42()
|
|
503536
503749
|
}
|
|
503537
503750
|
]);
|
|
503538
503751
|
} catch (error5) {
|
|
@@ -504377,7 +504590,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
504377
504590
|
type: "message",
|
|
504378
504591
|
role: "user",
|
|
504379
504592
|
content: buildTextParts(skillMessage),
|
|
504380
|
-
otid:
|
|
504593
|
+
otid: randomUUID42()
|
|
504381
504594
|
}
|
|
504382
504595
|
]);
|
|
504383
504596
|
} catch (error5) {
|
|
@@ -504415,7 +504628,7 @@ ${SYSTEM_REMINDER_CLOSE}`;
|
|
|
504415
504628
|
type: "message",
|
|
504416
504629
|
role: "user",
|
|
504417
504630
|
content: rememberParts,
|
|
504418
|
-
otid:
|
|
504631
|
+
otid: randomUUID42()
|
|
504419
504632
|
}
|
|
504420
504633
|
]);
|
|
504421
504634
|
} catch (error5) {
|
|
@@ -504831,7 +505044,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
|
|
|
504831
505044
|
type: "message",
|
|
504832
505045
|
role: "user",
|
|
504833
505046
|
content: buildTextParts(initMessage),
|
|
504834
|
-
otid:
|
|
505047
|
+
otid: randomUUID42()
|
|
504835
505048
|
}
|
|
504836
505049
|
]);
|
|
504837
505050
|
} catch (error5) {
|
|
@@ -504998,7 +505211,7 @@ Resumed reflection arena choice prompt for run ${run2.runId}.`, true);
|
|
|
504998
505211
|
type: "message",
|
|
504999
505212
|
role: "user",
|
|
505000
505213
|
content: buildTextParts(wrapSkillPrompt2(matchedSkill.id, skillContent, userRequest)),
|
|
505001
|
-
otid:
|
|
505214
|
+
otid: randomUUID42()
|
|
505002
505215
|
}
|
|
505003
505216
|
]);
|
|
505004
505217
|
} catch (error5) {
|
|
@@ -505149,7 +505362,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
505149
505362
|
initialInput.push({
|
|
505150
505363
|
type: "approval",
|
|
505151
505364
|
approvals: eagerRecoveryDenials,
|
|
505152
|
-
otid:
|
|
505365
|
+
otid: randomUUID42()
|
|
505153
505366
|
});
|
|
505154
505367
|
}
|
|
505155
505368
|
const queuedApprovalInput = consumeQueuedApprovalInputForCurrentConversation();
|
|
@@ -512702,4 +512915,4 @@ function registerBunOAuthFlows() {
|
|
|
512702
512915
|
registerBunOAuthFlows();
|
|
512703
512916
|
await init_src5().then(() => exports_src2);
|
|
512704
512917
|
|
|
512705
|
-
//# debugId=
|
|
512918
|
+
//# debugId=201C7804F30F08EC64756E2164756E21
|