@letta-ai/letta-code 0.25.1 → 0.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/letta.js +487 -137
- package/package.json +1 -1
package/letta.js
CHANGED
|
@@ -3143,7 +3143,7 @@ var package_default;
|
|
|
3143
3143
|
var init_package = __esm(() => {
|
|
3144
3144
|
package_default = {
|
|
3145
3145
|
name: "@letta-ai/letta-code",
|
|
3146
|
-
version: "0.25.
|
|
3146
|
+
version: "0.25.2",
|
|
3147
3147
|
description: "Letta Code is a CLI tool for interacting with stateful Letta agents from the terminal.",
|
|
3148
3148
|
type: "module",
|
|
3149
3149
|
bin: {
|
|
@@ -5397,6 +5397,11 @@ var init_manager = __esm(() => {
|
|
|
5397
5397
|
init_settings_manager();
|
|
5398
5398
|
ENABLED_TOGGLE_VALUES = new Set(["1", "true", "yes"]);
|
|
5399
5399
|
EXPERIMENT_DEFINITIONS = [
|
|
5400
|
+
{
|
|
5401
|
+
id: "conversation_titles",
|
|
5402
|
+
label: "conversation titles",
|
|
5403
|
+
description: "Generate conversation titles from the transcript with letta/auto (uses your credits)."
|
|
5404
|
+
},
|
|
5400
5405
|
{
|
|
5401
5406
|
id: "node",
|
|
5402
5407
|
label: "node",
|
|
@@ -5772,6 +5777,7 @@ __export(exports_memoryGit, {
|
|
|
5772
5777
|
normalizeCredentialBaseUrl: () => normalizeCredentialBaseUrl,
|
|
5773
5778
|
maybeUpdateMemoryRemoteOrigin: () => maybeUpdateMemoryRemoteOrigin,
|
|
5774
5779
|
isRetryableGitTransientError: () => isRetryableGitTransientError,
|
|
5780
|
+
isRepairableMemfsRemoteUrl: () => isRepairableMemfsRemoteUrl,
|
|
5775
5781
|
isMissingCwdGitError: () => isMissingCwdGitError,
|
|
5776
5782
|
isMemfsRemoteUrlForAgent: () => isMemfsRemoteUrlForAgent,
|
|
5777
5783
|
isMemfsGitNetworkCommand: () => isMemfsGitNetworkCommand,
|
|
@@ -5844,6 +5850,17 @@ function isMemfsRemoteUrlForAgent(remoteUrl, agentId) {
|
|
|
5844
5850
|
const escapedAgentId = escapeRegex(agentId);
|
|
5845
5851
|
return new RegExp(`^https?://[^\\s]+/v1/git/${escapedAgentId}/state\\.git$`, "i").test(normalized);
|
|
5846
5852
|
}
|
|
5853
|
+
function isRepairableMemfsRemoteUrl(remoteUrl, agentId) {
|
|
5854
|
+
const normalized = normalizeRemoteUrl(remoteUrl);
|
|
5855
|
+
const escapedAgentId = escapeRegex(agentId);
|
|
5856
|
+
if (isMemfsRemoteUrlForAgent(normalized, agentId)) {
|
|
5857
|
+
return true;
|
|
5858
|
+
}
|
|
5859
|
+
if (new RegExp(`^https?://[^\\s]+/v1/git/${escapedAgentId}$`, "i").test(normalized)) {
|
|
5860
|
+
return true;
|
|
5861
|
+
}
|
|
5862
|
+
return /^https?:\/\/[^\s]+\/v1\/git$/i.test(normalized);
|
|
5863
|
+
}
|
|
5847
5864
|
function getGitRemoteUrl(agentId, baseUrl) {
|
|
5848
5865
|
const resolvedBaseUrl = (baseUrl ?? getMemfsServerUrl()).trim().replace(/\/+$/, "");
|
|
5849
5866
|
return `${resolvedBaseUrl}/v1/git/${agentId}/state.git`;
|
|
@@ -5859,7 +5876,7 @@ async function maybeUpdateMemoryRemoteOrigin(repoDir, agentId) {
|
|
|
5859
5876
|
if (!currentOrigin) {
|
|
5860
5877
|
return;
|
|
5861
5878
|
}
|
|
5862
|
-
if (!
|
|
5879
|
+
if (!isRepairableMemfsRemoteUrl(currentOrigin, agentId)) {
|
|
5863
5880
|
return;
|
|
5864
5881
|
}
|
|
5865
5882
|
const expectedOrigin = normalizeRemoteUrl(getGitRemoteUrl(agentId));
|
|
@@ -6228,6 +6245,10 @@ function isNonFastForwardPushError(error) {
|
|
|
6228
6245
|
const message = error instanceof Error ? error.message : String(error);
|
|
6229
6246
|
return NON_FAST_FORWARD_PUSH_ERROR_RE.test(message);
|
|
6230
6247
|
}
|
|
6248
|
+
function isRecoverableMemoryPullHistoryError(error) {
|
|
6249
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
6250
|
+
return UNRELATED_HISTORY_PULL_ERROR_RE.test(message) || NO_UPSTREAM_PULL_ERROR_RE.test(message);
|
|
6251
|
+
}
|
|
6231
6252
|
async function prepareMemoryRepoForGitOps(memoryDir, agentId, token) {
|
|
6232
6253
|
await maybeUpdateMemoryRemoteOrigin(memoryDir, agentId);
|
|
6233
6254
|
await configureLocalCredentialHelper(memoryDir, token);
|
|
@@ -6235,6 +6256,55 @@ async function prepareMemoryRepoForGitOps(memoryDir, agentId, token) {
|
|
|
6235
6256
|
installPostCommitHook(memoryDir);
|
|
6236
6257
|
await ensureLocalMemfsGitConfig(memoryDir, agentId);
|
|
6237
6258
|
}
|
|
6259
|
+
async function recoverMemoryPullByResettingToRemote(memoryDir, token) {
|
|
6260
|
+
const { stdout: status } = await runGit(memoryDir, ["status", "--porcelain"]);
|
|
6261
|
+
if (status.trim()) {
|
|
6262
|
+
throw new Error("Local memory repo has uncommitted changes; refusing to auto-reset unrelated history.");
|
|
6263
|
+
}
|
|
6264
|
+
await runGitWithRetry(memoryDir, ["fetch", "origin", "main"], token, {
|
|
6265
|
+
operation: "fetch memory repo for reset"
|
|
6266
|
+
});
|
|
6267
|
+
const { stdout: remoteShaOut } = await runGit(memoryDir, [
|
|
6268
|
+
"rev-parse",
|
|
6269
|
+
"--verify",
|
|
6270
|
+
"refs/remotes/origin/main"
|
|
6271
|
+
]);
|
|
6272
|
+
const remoteSha = remoteShaOut.trim();
|
|
6273
|
+
if (!remoteSha) {
|
|
6274
|
+
throw new Error("Remote memory repo did not advertise origin/main.");
|
|
6275
|
+
}
|
|
6276
|
+
let backupRef = null;
|
|
6277
|
+
try {
|
|
6278
|
+
const { stdout: localShaOut } = await runGit(memoryDir, [
|
|
6279
|
+
"rev-parse",
|
|
6280
|
+
"--verify",
|
|
6281
|
+
"HEAD"
|
|
6282
|
+
]);
|
|
6283
|
+
const localSha = localShaOut.trim();
|
|
6284
|
+
if (localSha && localSha !== remoteSha) {
|
|
6285
|
+
backupRef = `refs/letta-backup/pre-sync-${Date.now()}`;
|
|
6286
|
+
await runGit(memoryDir, ["update-ref", backupRef, localSha]);
|
|
6287
|
+
}
|
|
6288
|
+
} catch {}
|
|
6289
|
+
await runGit(memoryDir, ["reset", "--hard", "refs/remotes/origin/main"]);
|
|
6290
|
+
try {
|
|
6291
|
+
await runGit(memoryDir, [
|
|
6292
|
+
"branch",
|
|
6293
|
+
"--set-upstream-to",
|
|
6294
|
+
"origin/main",
|
|
6295
|
+
"main"
|
|
6296
|
+
]);
|
|
6297
|
+
} catch {}
|
|
6298
|
+
return backupRef ? `Recovered memory repo by resetting to origin/main (${remoteSha.slice(0, 7)}). Previous local HEAD was preserved at ${backupRef}.` : `Recovered memory repo by resetting to origin/main (${remoteSha.slice(0, 7)}).`;
|
|
6299
|
+
}
|
|
6300
|
+
async function hasMergeBaseWithUpstream(memoryDir) {
|
|
6301
|
+
try {
|
|
6302
|
+
await runGit(memoryDir, ["merge-base", "HEAD", "@{u}"]);
|
|
6303
|
+
return true;
|
|
6304
|
+
} catch {
|
|
6305
|
+
return false;
|
|
6306
|
+
}
|
|
6307
|
+
}
|
|
6238
6308
|
async function prepareLocalOnlyMemoryRepoForGitOps(memoryDir, author) {
|
|
6239
6309
|
installPreCommitHook(memoryDir);
|
|
6240
6310
|
installPostCommitHook(memoryDir);
|
|
@@ -6567,11 +6637,33 @@ async function pullMemory(agentId) {
|
|
|
6567
6637
|
summary: updated ? output.trim() : "Already up to date"
|
|
6568
6638
|
};
|
|
6569
6639
|
} catch {
|
|
6640
|
+
if (!await hasMergeBaseWithUpstream(dir)) {
|
|
6641
|
+
try {
|
|
6642
|
+
return {
|
|
6643
|
+
updated: true,
|
|
6644
|
+
summary: await recoverMemoryPullByResettingToRemote(dir, token)
|
|
6645
|
+
};
|
|
6646
|
+
} catch (recoverErr) {
|
|
6647
|
+
const recoverMsg = recoverErr instanceof Error ? recoverErr.message : String(recoverErr);
|
|
6648
|
+
debugWarn("memfs-git", `Automatic memory repo reset failed: ${recoverMsg}`);
|
|
6649
|
+
}
|
|
6650
|
+
}
|
|
6570
6651
|
debugWarn("memfs-git", "Fast-forward pull failed, trying rebase");
|
|
6571
6652
|
try {
|
|
6572
6653
|
const { stdout, stderr } = await runGitWithRetry(dir, ["pull", "--rebase"], token, { operation: "pull --rebase" });
|
|
6573
6654
|
return { updated: true, summary: (stdout + stderr).trim() };
|
|
6574
6655
|
} catch (rebaseErr) {
|
|
6656
|
+
if (isRecoverableMemoryPullHistoryError(rebaseErr)) {
|
|
6657
|
+
try {
|
|
6658
|
+
return {
|
|
6659
|
+
updated: true,
|
|
6660
|
+
summary: await recoverMemoryPullByResettingToRemote(dir, token)
|
|
6661
|
+
};
|
|
6662
|
+
} catch (recoverErr) {
|
|
6663
|
+
const recoverMsg = recoverErr instanceof Error ? recoverErr.message : String(recoverErr);
|
|
6664
|
+
debugWarn("memfs-git", `Automatic memory repo reset failed: ${recoverMsg}`);
|
|
6665
|
+
}
|
|
6666
|
+
}
|
|
6575
6667
|
const msg = rebaseErr instanceof Error ? rebaseErr.message : String(rebaseErr);
|
|
6576
6668
|
debugWarn("memfs-git", `Pull failed: ${msg}`);
|
|
6577
6669
|
return {
|
|
@@ -6649,7 +6741,7 @@ async function removeGitMemoryTag(agentId) {
|
|
|
6649
6741
|
debugWarn("memfs-git", `Failed to remove git-memory tag: ${err instanceof Error ? err.message : String(err)}`);
|
|
6650
6742
|
}
|
|
6651
6743
|
}
|
|
6652
|
-
var execFile, GIT_MEMORY_ENABLED_TAG = "git-memory-enabled", RETRYABLE_GIT_HTTP_ERROR_RE, RETRYABLE_GIT_NETWORK_ERROR_RE, MISSING_CWD_GIT_ERROR_RE, NON_FAST_FORWARD_PUSH_ERROR_RE, AGENT_DISPLAY_NAME_TIMEOUT_MS = 3000, PRE_COMMIT_HOOK_SCRIPT = `#!/usr/bin/env bash
|
|
6744
|
+
var execFile, GIT_MEMORY_ENABLED_TAG = "git-memory-enabled", RETRYABLE_GIT_HTTP_ERROR_RE, RETRYABLE_GIT_NETWORK_ERROR_RE, MISSING_CWD_GIT_ERROR_RE, NON_FAST_FORWARD_PUSH_ERROR_RE, UNRELATED_HISTORY_PULL_ERROR_RE, NO_UPSTREAM_PULL_ERROR_RE, AGENT_DISPLAY_NAME_TIMEOUT_MS = 3000, PRE_COMMIT_HOOK_SCRIPT = `#!/usr/bin/env bash
|
|
6653
6745
|
# Validate frontmatter in staged memory .md files
|
|
6654
6746
|
# Installed by Letta Code CLI
|
|
6655
6747
|
|
|
@@ -6814,6 +6906,8 @@ var init_memoryGit = __esm(() => {
|
|
|
6814
6906
|
RETRYABLE_GIT_NETWORK_ERROR_RE = /(remote end hung up unexpectedly|connection reset by peer|operation timed out|timed out)/i;
|
|
6815
6907
|
MISSING_CWD_GIT_ERROR_RE = /(Unable to read current working directory: No such file or directory|\buv_cwd\b|\bcwd\b.*\bENOENT\b)/i;
|
|
6816
6908
|
NON_FAST_FORWARD_PUSH_ERROR_RE = /(non-fast-forward|fetch first|failed to push some refs|updates were rejected|remote contains work that you do not have locally|tip of your current branch is behind)/i;
|
|
6909
|
+
UNRELATED_HISTORY_PULL_ERROR_RE = /(no common commits|refusing to merge unrelated histories)/i;
|
|
6910
|
+
NO_UPSTREAM_PULL_ERROR_RE = /(there is no tracking information for the current branch|no upstream configured|no tracking branch)/i;
|
|
6817
6911
|
});
|
|
6818
6912
|
|
|
6819
6913
|
// node_modules/@ai-sdk/provider/dist/index.mjs
|
|
@@ -55335,7 +55429,7 @@ assistant: Clients are marked as failed in the \`connectToServer\` function in s
|
|
|
55335
55429
|
var init_source_claude = () => {};
|
|
55336
55430
|
|
|
55337
55431
|
// src/agent/prompts/source_codex.md
|
|
55338
|
-
var source_codex_default = `You are Codex, a coding agent based on GPT-5. You and the user share
|
|
55432
|
+
var source_codex_default = `You are Codex, a coding agent based on GPT-5. You and the user share one workspace, and your job is to collaborate with them until their goal is genuinely handled.
|
|
55339
55433
|
|
|
55340
55434
|
# Personality
|
|
55341
55435
|
|
|
@@ -55348,107 +55442,148 @@ You are guided by these core values:
|
|
|
55348
55442
|
- Rigor: You expect technical arguments to be coherent and defensible, and you surface gaps or weak assumptions politely with emphasis on creating clarity and moving the task forward.
|
|
55349
55443
|
|
|
55350
55444
|
## Interaction Style
|
|
55351
|
-
You communicate
|
|
55445
|
+
You communicate respectfully, focusing on the task at hand. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps.
|
|
55352
55446
|
|
|
55353
|
-
You avoid cheerleading, motivational language,
|
|
55447
|
+
You avoid cheerleading, motivational language, artificial reassurance, and general fluffiness. You don't comment on user requests, positively or negatively, unless there is reason for escalation.
|
|
55354
55448
|
|
|
55355
55449
|
## Escalation
|
|
55356
55450
|
You may challenge the user to raise their technical bar, but you never patronize or dismiss their concerns. When presenting an alternative approach or solution to the user, you explain the reasoning behind the approach, so your thoughts are demonstrably correct. You maintain a pragmatic mindset when discussing these tradeoffs, and so are willing to work with the user after concerns have been noted.
|
|
55357
55451
|
|
|
55358
|
-
# General
|
|
55359
55452
|
|
|
55360
|
-
|
|
55361
|
-
|
|
55453
|
+
# General
|
|
55454
|
+
You bring a senior engineer’s judgment to the work, but you let it arrive through attention rather than premature certainty. You read the codebase first, resist easy assumptions, and let the shape of the existing system teach you how to move.
|
|
55455
|
+
|
|
55456
|
+
- When you search for text or files, you reach first for \`rg\` or \`rg --files\`; they are much faster than alternatives like \`grep\`. If \`rg\` is unavailable, you use the next best tool without fuss.
|
|
55457
|
+
- You parallelize tool calls whenever you can, especially file reads such as \`cat\`, \`rg\`, \`sed\`, \`ls\`, \`git show\`, \`nl\`, and \`wc\`. You use \`multi_tool_use.parallel\` for that parallelism, and only that. Do not chain shell commands with separators like \`echo "====";\`; the output becomes noisy in a way that makes the user’s side of the conversation worse.
|
|
55458
|
+
|
|
55459
|
+
## Engineering judgment
|
|
55460
|
+
|
|
55461
|
+
When the user leaves implementation details open, you choose conservatively and in sympathy with the codebase already in front of you:
|
|
55462
|
+
|
|
55463
|
+
- You prefer the repo’s existing patterns, frameworks, and local helper APIs over inventing a new style of abstraction.
|
|
55464
|
+
- For structured data, you use structured APIs or parsers instead of ad hoc string manipulation whenever the codebase or standard toolchain gives you a reasonable option.
|
|
55465
|
+
- You keep edits closely scoped to the modules, ownership boundaries, and behavioral surface implied by the request and surrounding code. You leave unrelated refactors and metadata churn alone unless they are truly needed to finish safely.
|
|
55466
|
+
- You add an abstraction only when it removes real complexity, reduces meaningful duplication, or clearly matches an established local pattern.
|
|
55467
|
+
- You let test coverage scale with risk and blast radius: you keep it focused for narrow changes, and you broaden it when the implementation touches shared behavior, cross-module contracts, or user-facing workflows.
|
|
55468
|
+
|
|
55469
|
+
## Frontend guidance
|
|
55470
|
+
|
|
55471
|
+
You follow these instructions when building applications with a frontend experience:
|
|
55472
|
+
|
|
55473
|
+
### Build with empathy
|
|
55474
|
+
- If working with an existing design or given a design framework in context, you pay careful attention to existing conventions and ensure that what you build is consistent with the frameworks used and design of the existing application.
|
|
55475
|
+
- You think deeply about the audience of what you are building and use that to decide what features to build and when designing layout, components, visual style, on-screen text, and interaction patterns. Using your application should feel rich and sophisticated.
|
|
55476
|
+
- You make sure that the frontend design is tailored for the domain and subject matter of the application. For example, SaaS, CRM, and other operational tools should feel quiet, utilitarian, and work-focused rather than illustrative or editorial: avoid oversized hero sections, decorative card-heavy layouts, and marketing-style composition, and instead prioritize dense but organized information, restrained visual styling, predictable navigation, and interfaces built for scanning, comparison, and repeated action. A game can be more illustrative, expressive, animated, and playful.
|
|
55477
|
+
- You make sure that common workflows within the app are ergonomic and efficient, yet comprehensive -- the user of your application should be able to seamlessly navigate in and out of different views and pages in the application.
|
|
55478
|
+
|
|
55479
|
+
### Design instructions
|
|
55480
|
+
- You make sure to use icons in buttons for tools, swatches for color, segmented controls for modes, toggles/checkboxes for binary settings, sliders/steppers/inputs for numeric values, menus for option sets, tabs for views, and text or icon+text buttons only for clear commands (unless otherwise specified). Cards are kept at 8px border radius or less unless the existing design system requires otherwise.
|
|
55481
|
+
- You do not use rounded rectangular UI elements with text inside if you could use a familiar symbol or icon instead (examples include arrow icons for undo/redo, B/I icons for bold/italics, save/download/zoom icons). You build tooltips which name/describe unfamiliar icons when the user hovers over it.
|
|
55482
|
+
- You use lucide icons inside buttons whenever one exists instead of manually-drawn SVG icons. If there is a library enabled in an existing application, you use icons from that library.
|
|
55483
|
+
- You build feature-complete controls, states, and views that a target user would naturally expect from the application.
|
|
55484
|
+
- You do not use visible, in-app text to describe the application's features, functionality, keyboard shortcuts, styling, visual elements, or how to use the application.
|
|
55485
|
+
- You should not make a landing page unless absolutely required; when asked for a site, app, game, or tool, build the actual usable experience as the first screen, not marketing or explanatory content.
|
|
55486
|
+
- When making a hero page, you use a relevant image, generated bitmap image, or immersive full-bleed interactive scene as the background with text over it that is not in a card; never use a split text/media layout where a card is one side and text is on another side, never put hero text or the primary experience in a card, never use a gradient/SVG hero page, and do not create an SVG hero illustration when a real or generated image can carry the subject.
|
|
55487
|
+
- On branded, product, venue, portfolio, or object-focused pages, the brand/product/place/object must be a first-viewport signal, not only tiny nav text or an eyebrow. Hero content must leave a hint of the next section's content visible on every mobile and desktop viewport, including wide desktop.
|
|
55488
|
+
- For landing-page heroes, make the H1 the brand/product/place/person name or a literal offer/category; put descriptive value props in supporting copy, not the headline.
|
|
55489
|
+
- Websites and games must use visual assets. You can use image search, known relevant images, or generated bitmap images instead of SVGs, unless making a game. Primary images and media should reveal the actual product, place, object, state, gameplay, or person; you refrain from dark, blurred, cropped, stock-like, or purely atmospheric media when the user needs to inspect the real thing. For highly specific game assets you use custom SVG/Three.js/etc.
|
|
55490
|
+
- For games or interactive tools with well-established rules, physics, parsing, or AI engines, you use a proven existing library for the core domain logic instead of hand-rolling it, unless the user explicitly asks for a from-scratch implementation.
|
|
55491
|
+
- You use Three.js for 3D elements, and make the primary 3D scene full-bleed or unframed and not inside a decorative card/preview container. Before finishing, you verify with Playwright screenshots and canvas-pixel checks across desktop/mobile viewports that it is nonblank, correctly framed, interactive/moving, and that referenced assets render as intended without overlapping.
|
|
55492
|
+
- You do not put UI cards inside other cards. Do not style page sections as floating cards. Only use cards for individual repeated items, modals, and genuinely framed tools. Page sections must be full-width bands or unframed layouts with constrained inner content.
|
|
55493
|
+
- You do not add discrete orbs, gradient orbs, or bokeh blobs as decoration or backgrounds.
|
|
55494
|
+
- You make sure that text fits within its parent UI element on all mobile and desktop viewports. Move it to a new line if needed, and if it still does not fit inside the UI element, use dynamic sizing so the longest word fits. Text must also not occlude preceding or subsequent content. Despite this, you check that text inside a UI button/card looks professionally designed and polished.
|
|
55495
|
+
- Match display text to its container: reserve hero-scale type for true heroes, and use smaller, tighter headings inside compact panels, cards, sidebars, dashboards, and tool surfaces.
|
|
55496
|
+
- You define stable dimensions with responsive constraints (such as aspect-ratio, grid tracks, min/max, or container-relative sizing) for fixed-format UI elements like boards, grids, toolbars, icon buttons, counters, or tiles, so hover states, labels, icons, pieces, loading text, or dynamic content cannot resize or shift the layout.
|
|
55497
|
+
- You do not scale font size with viewport width. Letter spacing must be 0, not negative.
|
|
55498
|
+
- You do not make one-note palettes: avoid UIs dominated by variations of a single hue family, and limit dominant purple/purple-blue gradients, beige/cream/sand/tan, dark blue/slate, and brown/orange/espresso palettes; scan CSS colors before finalizing and revise if the page reads as one of these themes.
|
|
55499
|
+
- You make sure that UI elements and on-screen text do not overlap with each other in an incoherent manner. This is extremely important as it leads to a jarring user experience.
|
|
55500
|
+
|
|
55501
|
+
When building a site or app that needs a dev server to run properly, you start the local dev server after implementation and give the user the URL so they can try it. If there's already a server on that port, you use another one. For a website where just opening the HTML will work, you don't start a dev server, and instead give the user a link to the HTML file that can open in their browser.
|
|
55362
55502
|
|
|
55363
55503
|
## Editing constraints
|
|
55364
55504
|
|
|
55365
|
-
-
|
|
55366
|
-
-
|
|
55367
|
-
-
|
|
55368
|
-
- Do not use Python to read
|
|
55505
|
+
- You default to ASCII when editing or creating files. You introduce non-ASCII or other Unicode characters only when there is a clear reason and the file already lives in that character set.
|
|
55506
|
+
- You add succinct code comments only where the code is not self-explanatory. You avoid empty narration like "Assigns the value to the variable", but you do leave a short orienting comment before a complex block if it would save the user from tedious parsing. You use that tool sparingly.
|
|
55507
|
+
- Use \`apply_patch\` for manual code edits. Do not create or edit files with \`cat\` or other shell write tricks. Formatting commands and bulk mechanical rewrites do not need \`apply_patch\`.
|
|
55508
|
+
- Do not use Python to read or write files when a simple shell command or \`apply_patch\` is enough.
|
|
55369
55509
|
- You may be in a dirty git worktree.
|
|
55370
|
-
|
|
55371
|
-
|
|
55372
|
-
|
|
55373
|
-
|
|
55374
|
-
-
|
|
55375
|
-
-
|
|
55376
|
-
-
|
|
55377
|
-
- You struggle using the git interactive console. **ALWAYS** prefer using non-interactive git commands.
|
|
55510
|
+
* NEVER revert existing changes you did not make unless explicitly requested, since these changes were made by the user.
|
|
55511
|
+
* If asked to make a commit or code edits and there are unrelated changes to your work or changes that you didn't make in those files, you don't revert those changes.
|
|
55512
|
+
* If the changes are in files you've touched recently, you read carefully and understand how you can work with the changes rather than reverting them.
|
|
55513
|
+
* If the changes are in unrelated files, you just ignore them and don't revert them.
|
|
55514
|
+
- While working, you may encounter changes you did not make. You assume they came from the user or from generated output, and you do NOT revert them. If they are unrelated to your task, you ignore them. If they affect your task, you work **with** them instead of undoing them. Only ask the user how to proceed if those changes make the task impossible to complete.
|
|
55515
|
+
- Never use destructive commands like \`git reset --hard\` or \`git checkout --\` unless the user has clearly asked for that operation. If the request is ambiguous, ask for approval first.
|
|
55516
|
+
- You are clumsy in the git interactive console. Prefer non-interactive git commands whenever you can.
|
|
55378
55517
|
|
|
55379
55518
|
## Special user requests
|
|
55380
55519
|
|
|
55381
|
-
- If the user makes a simple request
|
|
55382
|
-
- If the user asks for a "review", default to a code
|
|
55520
|
+
- If the user makes a simple request that can be answered directly by a terminal command, such as asking for the time via \`date\`, you go ahead and do that.
|
|
55521
|
+
- If the user asks for a "review", you default to a code-review stance: you prioritize bugs, risks, behavioral regressions, and missing tests. Findings should lead the response, with summaries kept brief and placed only after the issues are listed. Present findings first, ordered by severity and grounded in file/line references; then add open questions or assumptions; then include a change summary as secondary context. If you find no issues, you say that clearly and mention any remaining test gaps or residual risk.
|
|
55383
55522
|
|
|
55384
|
-
##
|
|
55385
|
-
|
|
55386
|
-
When doing frontend design tasks, avoid collapsing into "AI slop" or safe, average-looking layouts.
|
|
55387
|
-
Aim for interfaces that feel intentional, bold, and a bit surprising.
|
|
55388
|
-
- Typography: Use expressive, purposeful fonts and avoid default stacks (Inter, Roboto, Arial, system).
|
|
55389
|
-
- Color & Look: Choose a clear visual direction; define CSS variables; avoid purple-on-white defaults. No purple bias or dark mode bias.
|
|
55390
|
-
- Motion: Use a few meaningful animations (page-load, staggered reveals) instead of generic micro-motions.
|
|
55391
|
-
- Background: Don't rely on flat, single-color backgrounds; use gradients, shapes, or subtle patterns to build atmosphere.
|
|
55392
|
-
- Overall: Avoid boilerplate layouts and interchangeable UI patterns. Vary themes, type families, and visual languages across outputs.
|
|
55393
|
-
- Ensure the page loads properly on both desktop and mobile
|
|
55523
|
+
## Autonomy and persistence
|
|
55524
|
+
You stay with the work until the task is handled end to end within the current turn whenever that is feasible. Do not stop at analysis or half-finished fixes. Do not end your turn while \`exec_command\` sessions needed for the user’s request are still running. You carry the work through implementation, verification, and a clear account of the outcome unless the user explicitly pauses or redirects you.
|
|
55394
55525
|
|
|
55395
|
-
|
|
55526
|
+
Unless the user explicitly asks for a plan, asks a question about the code, is brainstorming possible approaches, or otherwise makes clear that they do not want code changes yet, you assume they want you to make the change or run the tools needed to solve the problem. In those cases, do not stop at a proposal; implement the fix. If you hit a blocker, you try to work through it yourself before handing the problem back.
|
|
55396
55527
|
|
|
55397
55528
|
# Working with the user
|
|
55398
55529
|
|
|
55399
|
-
You
|
|
55400
|
-
-
|
|
55401
|
-
- After you have completed all your work, send a message to the \`final\` channel.
|
|
55402
|
-
You are producing plain text that will later be styled by the program you run in. Formatting should make results easy to scan, but not feel mechanical. Use judgment to decide how much structure adds value. Follow the formatting rules exactly.
|
|
55530
|
+
You have two channels for staying in conversation with the user:
|
|
55531
|
+
- You share updates in \`commentary\` channel.
|
|
55532
|
+
- After you have completed all of your work, you send a message to the \`final\` channel.
|
|
55403
55533
|
|
|
55404
|
-
|
|
55405
|
-
Persist until the task is fully handled end-to-end within the current turn whenever feasible: do not stop at analysis or partial fixes; carry changes through implementation, verification, and a clear explanation of outcomes unless the user explicitly pauses or redirects you.
|
|
55534
|
+
The user may send messages while you are working. If those messages conflict, you let the newest one steer the current turn. If they do not conflict, you make sure your work and final answer honor every user request since your last turn. This matters especially after long-running resumes or context compaction. If the newest message asks for status, you give that update and then keep moving unless the user explicitly asks you to pause, stop, or only report status.
|
|
55406
55535
|
|
|
55407
|
-
|
|
55536
|
+
Before sending a final response after a resume, interruption, or context transition, you do a quick sanity check: you make sure your final answer and tool actions are answering the newest request, not an older ghost still lingering in the thread.
|
|
55537
|
+
|
|
55538
|
+
When you run out of context, the tool automatically compacts the conversation. That means time never runs out, though sometimes you may see a summary instead of the full thread. When that happens, you assume compaction occurred while you were working. Do not restart from scratch; you continue naturally and make reasonable assumptions about anything missing from the summary.
|
|
55408
55539
|
|
|
55409
55540
|
## Formatting rules
|
|
55410
55541
|
|
|
55542
|
+
You are writing plain text that will later be styled by the program you run in. Let formatting make the answer easy to scan without turning it into something stiff or mechanical. Use judgment about how much structure actually helps, and follow these rules exactly.
|
|
55543
|
+
|
|
55411
55544
|
- You may format with GitHub-flavored Markdown.
|
|
55412
|
-
-
|
|
55413
|
-
-
|
|
55414
|
-
- Headers are optional
|
|
55415
|
-
-
|
|
55545
|
+
- You add structure only when the task calls for it. You let the shape of the answer match the shape of the problem; if the task is tiny, a one-liner may be enough. Otherwise, you prefer short paragraphs by default; they leave a little air in the page. You order sections from general to specific to supporting detail.
|
|
55546
|
+
- Avoid nested bullets unless the user explicitly asks for them. Keep lists flat. If you need hierarchy, split content into separate lists or sections, or place the detail on the next line after a colon instead of nesting it. For numbered lists, use only the \`1. 2. 3.\` style, never \`1)\`. This does not apply to generated artifacts such as PR descriptions, release notes, changelogs, or user-requested docs; preserve those native formats when needed.
|
|
55547
|
+
- Headers are optional; you use them only when they genuinely help. If you do use one, make it short Title Case (1-3 words), wrap it in **…**, and do not add a blank line.
|
|
55548
|
+
- You use monospace commands/paths/env vars/code ids, inline examples, and literal keyword bullets by wrapping them in backticks.
|
|
55416
55549
|
- Code samples or multi-line snippets should be wrapped in fenced code blocks. Include an info string as often as possible.
|
|
55417
|
-
-
|
|
55418
|
-
*
|
|
55419
|
-
*
|
|
55420
|
-
*
|
|
55421
|
-
*
|
|
55422
|
-
* Do not
|
|
55423
|
-
*
|
|
55424
|
-
|
|
55425
|
-
- Don't use emojis or em dashes unless explicitly instructed.
|
|
55550
|
+
- When referencing a real local file, prefer a clickable markdown link.
|
|
55551
|
+
* Clickable file links should look like [app.py](/abs/path/app.py:12): plain label, absolute target, with optional line number inside the target.
|
|
55552
|
+
* If a file path has spaces, wrap the target in angle brackets: [My Report.md](</abs/path/My Project/My Report.md:3>).
|
|
55553
|
+
* Do not wrap markdown links in backticks, or put backticks inside the label or target. This confuses the markdown renderer.
|
|
55554
|
+
* Do not use URIs like file://, vscode://, or https:// for file links.
|
|
55555
|
+
* Do not provide ranges of lines.
|
|
55556
|
+
* Avoid repeating the same filename multiple times when one grouping is clearer.
|
|
55557
|
+
- Don’t use emojis or em dashes unless explicitly instructed.
|
|
55426
55558
|
|
|
55427
55559
|
## Final answer instructions
|
|
55428
|
-
|
|
55429
|
-
|
|
55560
|
+
|
|
55561
|
+
In your final answer, you keep the light on the things that matter most. Avoid long-winded explanation. In casual conversation, you just talk like a person. For simple or single-file tasks, you prefer one or two short paragraphs plus an optional verification line. Do not default to bullets. When there are only one or two concrete changes, a clean prose close-out is usually the most humane shape.
|
|
55562
|
+
|
|
55563
|
+
- You suggest follow ups if useful and they build on the users request, but never end your answer with an "If you want" sentence.
|
|
55564
|
+
- When you talk about your work, you use plain, idiomatic engineering prose with some life in it. You avoid coined metaphors, internal jargon, slash-heavy noun stacks, and over-hyphenated compounds unless you are quoting source text. In particular, do not lean on words like "seam", "cut", or "safe-cut" as generic explanatory filler.
|
|
55430
55565
|
- The user does not see command execution outputs. When asked to show the output of a command (e.g. \`git show\`), relay the important details in your answer or summarize the key lines so the user understands the result.
|
|
55431
55566
|
- Never tell the user to "save/copy this file", the user is on the same machine and has access to the same files as you have.
|
|
55432
|
-
- If the user asks for a code explanation,
|
|
55433
|
-
-
|
|
55434
|
-
-
|
|
55435
|
-
-
|
|
55436
|
-
-
|
|
55437
|
-
- If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps. When suggesting multiple options, use numeric lists for the suggestions so the user can quickly respond with a single number.
|
|
55567
|
+
- If the user asks for a code explanation, you include code references as appropriate.
|
|
55568
|
+
- If you weren't able to do something, for example run tests, you tell the user.
|
|
55569
|
+
- Never overwhelm the user with answers that are over 50-70 lines long; provide the highest-signal context instead of describing everything exhaustively.
|
|
55570
|
+
- Tone of your final answer must match your personality.
|
|
55571
|
+
- Never talk about goblins, gremlins, raccoons, trolls, ogres, pigeons, or other animals or creatures unless it is absolutely and unambiguously relevant to the user's query.
|
|
55438
55572
|
|
|
55439
|
-
## Intermediary updates
|
|
55573
|
+
## Intermediary updates
|
|
55440
55574
|
|
|
55441
55575
|
- Intermediary updates go to the \`commentary\` channel.
|
|
55442
55576
|
- User updates are short updates while you are working, they are NOT final answers.
|
|
55443
|
-
- You
|
|
55444
|
-
-
|
|
55445
|
-
-
|
|
55446
|
-
-
|
|
55447
|
-
- When exploring,
|
|
55448
|
-
-
|
|
55577
|
+
- You treat messages to the user while you are working as a place to think out loud in a calm, companionable way. You casually explain what you are doing and why in one or two sentences.
|
|
55578
|
+
- Never praise your plan by contrasting it with an implied worse alternative. For example, never use platitudes like "I will do <this good thing> rather than <this obviously bad thing>", "I will do <X>, not <Y>".
|
|
55579
|
+
- Never talk about goblins, gremlins, raccoons, trolls, ogres, pigeons, or other animals or creatures unless it is absolutely and unambiguously relevant to the user's query.
|
|
55580
|
+
- You provide user updates frequently, every 30s.
|
|
55581
|
+
- When exploring, such as searching or reading files, you provide user updates as you go. You explain what context you are gathering and what you are learning. You vary your sentence structure so the updates do not fall into a drumbeat, and in particular you do not start each one the same way.
|
|
55582
|
+
- When working for a while, you keep updates informative and varied, but you stay concise.
|
|
55583
|
+
- Once you have enough context, and if the work is substantial, you offer a longer plan. This is the only user update that may run past two sentences and include formatting.
|
|
55584
|
+
- If you create a checklist or task list, you update item statuses incrementally as each item is completed rather than marking every item done only at the end.
|
|
55449
55585
|
- Before performing file edits of any kind, you provide updates explaining what edits you are making.
|
|
55450
|
-
-
|
|
55451
|
-
- Tone of your updates MUST match your personality.
|
|
55586
|
+
- Tone of your updates must match your personality.
|
|
55452
55587
|
`;
|
|
55453
55588
|
var init_source_codex = () => {};
|
|
55454
55589
|
|
|
@@ -57712,7 +57847,9 @@ async function updateAgentLLMConfig(agentId, modelHandle, updateArgs, options) {
|
|
|
57712
57847
|
max_tokens: updateArgs.max_output_tokens
|
|
57713
57848
|
}
|
|
57714
57849
|
});
|
|
57715
|
-
const finalAgent = await backend.retrieveAgent(agentId
|
|
57850
|
+
const finalAgent = await backend.retrieveAgent(agentId, {
|
|
57851
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
57852
|
+
});
|
|
57716
57853
|
return finalAgent;
|
|
57717
57854
|
}
|
|
57718
57855
|
async function updateConversationLLMConfig(conversationId, modelHandle, updateArgs, options) {
|
|
@@ -57785,7 +57922,9 @@ async function updateAgentSystemPrompt(agentId, systemPromptId) {
|
|
|
57785
57922
|
settingsManager2.clearSystemPromptPreset(agentId);
|
|
57786
57923
|
}
|
|
57787
57924
|
}
|
|
57788
|
-
const agent = await backend.retrieveAgent(agentId
|
|
57925
|
+
const agent = await backend.retrieveAgent(agentId, {
|
|
57926
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
57927
|
+
});
|
|
57789
57928
|
return {
|
|
57790
57929
|
success: true,
|
|
57791
57930
|
message: "System prompt applied successfully",
|
|
@@ -133158,9 +133297,20 @@ function isCloudflareEdge52xHtmlError2(text2) {
|
|
|
133158
133297
|
return hasCloudflare && hasHtml && has52xCode;
|
|
133159
133298
|
}
|
|
133160
133299
|
function isCloudflareEdge52xErrorText(text2) {
|
|
133161
|
-
return CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN.test(text2) || isCloudflareEdge52xHtmlError2(text2);
|
|
133300
|
+
return CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN.test(text2) || CLOUDFLARE_JSON_5XX_PATTERN2.test(text2) || isCloudflareEdge52xHtmlError2(text2);
|
|
133162
133301
|
}
|
|
133163
133302
|
function parseCloudflareEdgeError2(text2) {
|
|
133303
|
+
if (CLOUDFLARE_JSON_5XX_PATTERN2.test(text2)) {
|
|
133304
|
+
try {
|
|
133305
|
+
const obj = JSON.parse(text2);
|
|
133306
|
+
return {
|
|
133307
|
+
code: String(obj.status),
|
|
133308
|
+
statusText: obj.error_name || obj.title || undefined,
|
|
133309
|
+
host: obj.zone || undefined,
|
|
133310
|
+
rayId: obj.ray_id || undefined
|
|
133311
|
+
};
|
|
133312
|
+
} catch {}
|
|
133313
|
+
}
|
|
133164
133314
|
if (!isCloudflareEdge52xHtmlError2(text2))
|
|
133165
133315
|
return;
|
|
133166
133316
|
const code = text2.match(/^\s*(502|52[0-6])\s*<!doctype html/i)?.[1] ?? text2.match(/error code\s*(502|52[0-6])/i)?.[1] ?? text2.match(/\|\s*(502|52[0-6])\s*:/i)?.[1];
|
|
@@ -133579,7 +133729,7 @@ function getRetryStatusMessage(errorDetail) {
|
|
|
133579
133729
|
if (!errorDetail)
|
|
133580
133730
|
return DEFAULT_RETRY_MESSAGE;
|
|
133581
133731
|
if (isCloudflareEdge52xErrorText(errorDetail))
|
|
133582
|
-
return
|
|
133732
|
+
return "Cloudflare transient error, retrying...";
|
|
133583
133733
|
if (checkZaiError(errorDetail))
|
|
133584
133734
|
return "Z.ai API error, retrying...";
|
|
133585
133735
|
if (errorDetail.includes("Anthropic API is overloaded"))
|
|
@@ -133605,7 +133755,7 @@ function createAgentLink2(runId, agentId, conversationId) {
|
|
|
133605
133755
|
const url2 = buildChatUrl(agentId, { conversationId });
|
|
133606
133756
|
return `View agent: \x1B]8;;${url2}\x1B\\${agentId}\x1B]8;;\x1B\\ (run: ${runId})`;
|
|
133607
133757
|
}
|
|
133608
|
-
var LETTA_USAGE_URL2, LETTA_AGENTS_URL2, CLOUDFLARE_EDGE_5XX_MARKER_PATTERN2, CLOUDFLARE_EDGE_5XX_TITLE_PATTERN2, CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN, CHATGPT_USAGE_LIMIT_HINT2 = "Switch models with /model, or connect your own provider keys with /connect.", ENCRYPTED_CONTENT_HINT2, DEFAULT_RETRY_MESSAGE = "Unexpected downstream LLM API error, retrying...", ENDPOINT_TYPE_DISPLAY_NAMES;
|
|
133758
|
+
var LETTA_USAGE_URL2, LETTA_AGENTS_URL2, CLOUDFLARE_EDGE_5XX_MARKER_PATTERN2, CLOUDFLARE_EDGE_5XX_TITLE_PATTERN2, CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN, CLOUDFLARE_JSON_5XX_PATTERN2, CHATGPT_USAGE_LIMIT_HINT2 = "Switch models with /model, or connect your own provider keys with /connect.", ENCRYPTED_CONTENT_HINT2, DEFAULT_RETRY_MESSAGE = "Unexpected downstream LLM API error, retrying...", ENDPOINT_TYPE_DISPLAY_NAMES;
|
|
133609
133759
|
var init_errorFormatter = __esm(() => {
|
|
133610
133760
|
init_error();
|
|
133611
133761
|
init_errorContext();
|
|
@@ -133615,6 +133765,7 @@ var init_errorFormatter = __esm(() => {
|
|
|
133615
133765
|
CLOUDFLARE_EDGE_5XX_MARKER_PATTERN2 = /(^|\s)(502|52[0-6])\s*<!doctype html|error code\s*(502|52[0-6])/i;
|
|
133616
133766
|
CLOUDFLARE_EDGE_5XX_TITLE_PATTERN2 = /\|\s*(502|52[0-6])\s*:/i;
|
|
133617
133767
|
CLOUDFLARE_EDGE_5XX_FORMATTED_PATTERN = /\bCloudflare\s+(502|52[0-6])\b/i;
|
|
133768
|
+
CLOUDFLARE_JSON_5XX_PATTERN2 = /"cloudflare_error"\s*:\s*true/s;
|
|
133618
133769
|
ENCRYPTED_CONTENT_HINT2 = [
|
|
133619
133770
|
"",
|
|
133620
133771
|
"This occurs when the conversation contains messages with encrypted",
|
|
@@ -138101,7 +138252,7 @@ function extractTelemetryInputText(content) {
|
|
|
138101
138252
|
}
|
|
138102
138253
|
|
|
138103
138254
|
// src/websocket/listener/constants.ts
|
|
138104
|
-
var MAX_RETRY_DURATION_MS, INITIAL_RETRY_DELAY_MS = 1000, MAX_RETRY_DELAY_MS = 30000, SYSTEM_REMINDER_RE, LLM_API_ERROR_MAX_RETRIES = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, MAX_PRE_STREAM_RECOVERY = 2, MAX_POST_STOP_APPROVAL_RECOVERY = 2
|
|
138255
|
+
var MAX_RETRY_DURATION_MS, INITIAL_RETRY_DELAY_MS = 1000, MAX_RETRY_DELAY_MS = 30000, SYSTEM_REMINDER_RE, LLM_API_ERROR_MAX_RETRIES = 3, EMPTY_RESPONSE_MAX_RETRIES = 2, MAX_PRE_STREAM_RECOVERY = 2, MAX_POST_STOP_APPROVAL_RECOVERY = 2;
|
|
138105
138256
|
var init_constants2 = __esm(() => {
|
|
138106
138257
|
MAX_RETRY_DURATION_MS = 5 * 60 * 1000;
|
|
138107
138258
|
SYSTEM_REMINDER_RE = /<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
@@ -139805,16 +139956,23 @@ var init_secrets_sync = __esm(() => {
|
|
|
139805
139956
|
|
|
139806
139957
|
// src/websocket/listener/recovery.ts
|
|
139807
139958
|
function isApprovalToolCallDesyncError(detail) {
|
|
139808
|
-
|
|
139809
|
-
|
|
139959
|
+
return isInvalidToolCallIdsError(detail) || isApprovalPendingError(detail);
|
|
139960
|
+
}
|
|
139961
|
+
function getApprovalToolCallDesyncErrorText(errorInfo) {
|
|
139962
|
+
const detail = errorInfo.detail;
|
|
139963
|
+
if (typeof detail === "string" && isApprovalToolCallDesyncError(detail)) {
|
|
139964
|
+
return detail;
|
|
139810
139965
|
}
|
|
139811
|
-
|
|
139966
|
+
const message = errorInfo.message;
|
|
139967
|
+
if (typeof message === "string" && isApprovalToolCallDesyncError(message)) {
|
|
139968
|
+
return message;
|
|
139969
|
+
}
|
|
139970
|
+
return null;
|
|
139812
139971
|
}
|
|
139813
139972
|
function shouldAttemptPostStopApprovalRecovery(params) {
|
|
139814
|
-
const approvalDesyncDetected = isApprovalToolCallDesyncError(params.runErrorDetail) || isApprovalToolCallDesyncError(params.latestErrorText);
|
|
139815
|
-
const genericNoRunError = params.stopReason === "error" && params.runIdsSeen === 0;
|
|
139973
|
+
const approvalDesyncDetected = isApprovalToolCallDesyncError(params.runErrorDetail) || isApprovalToolCallDesyncError(params.latestErrorText) || isApprovalToolCallDesyncError(params.fallbackError);
|
|
139816
139974
|
return shouldAttemptApprovalRecovery({
|
|
139817
|
-
approvalPendingDetected: approvalDesyncDetected
|
|
139975
|
+
approvalPendingDetected: approvalDesyncDetected,
|
|
139818
139976
|
retries: params.retries,
|
|
139819
139977
|
maxRetries: MAX_POST_STOP_APPROVAL_RECOVERY
|
|
139820
139978
|
});
|
|
@@ -143605,18 +143763,23 @@ async function handleIncomingMessage(msg, socket, runtime, onStatusChange, conne
|
|
|
143605
143763
|
}
|
|
143606
143764
|
}
|
|
143607
143765
|
if (errorInfo) {
|
|
143608
|
-
|
|
143609
|
-
|
|
143610
|
-
|
|
143611
|
-
|
|
143612
|
-
|
|
143613
|
-
|
|
143614
|
-
|
|
143615
|
-
|
|
143616
|
-
|
|
143617
|
-
|
|
143618
|
-
|
|
143619
|
-
|
|
143766
|
+
const recoverableApprovalErrorText = getApprovalToolCallDesyncErrorText(errorInfo);
|
|
143767
|
+
latestErrorText = recoverableApprovalErrorText || errorInfo.detail || errorInfo.message || latestErrorText;
|
|
143768
|
+
if (!recoverableApprovalErrorText) {
|
|
143769
|
+
emitLoopErrorNotice(socket, runtime, {
|
|
143770
|
+
message: errorInfo.message || "Stream error",
|
|
143771
|
+
stopReason: errorInfo.error_type || "error",
|
|
143772
|
+
isTerminal: false,
|
|
143773
|
+
runId: runId || errorInfo.run_id,
|
|
143774
|
+
agentId,
|
|
143775
|
+
conversationId,
|
|
143776
|
+
errorInfo,
|
|
143777
|
+
cancelRequested: runtime.cancelRequested,
|
|
143778
|
+
abortSignal: turnAbortSignal
|
|
143779
|
+
});
|
|
143780
|
+
} else {
|
|
143781
|
+
debugLog("recovery", "Suppressing streamed approval conflict while post-stop recovery runs: %s", recoverableApprovalErrorText);
|
|
143782
|
+
}
|
|
143620
143783
|
}
|
|
143621
143784
|
if (shouldOutput) {
|
|
143622
143785
|
const normalizedChunk = normalizeToolReturnWireMessage(chunk);
|
|
@@ -143634,6 +143797,7 @@ async function handleIncomingMessage(msg, socket, runtime, onStatusChange, conne
|
|
|
143634
143797
|
}, runtime.contextTracker);
|
|
143635
143798
|
const stopReason = result.stopReason;
|
|
143636
143799
|
const approvals = result.approvals || [];
|
|
143800
|
+
const fallbackError = result.fallbackError ?? null;
|
|
143637
143801
|
lastApprovalContinuationAccepted = false;
|
|
143638
143802
|
if (stopReason === "end_turn" && runtime.cancelRequested) {
|
|
143639
143803
|
finalizeInterruptedTurn(socket, runtime, {
|
|
@@ -143676,13 +143840,14 @@ async function handleIncomingMessage(msg, socket, runtime, onStatusChange, conne
|
|
|
143676
143840
|
if (stopReason !== "requires_approval") {
|
|
143677
143841
|
const lastRunId = runId || msgRunIds[msgRunIds.length - 1] || null;
|
|
143678
143842
|
const runErrorInfo = lastRunId ? await fetchRunErrorInfo(lastRunId) : null;
|
|
143679
|
-
const errorDetail = latestErrorText || runErrorInfo?.detail || runErrorInfo?.message || null;
|
|
143843
|
+
const errorDetail = latestErrorText || runErrorInfo?.detail || runErrorInfo?.message || fallbackError || null;
|
|
143680
143844
|
if (shouldAttemptPostStopApprovalRecovery({
|
|
143681
143845
|
stopReason,
|
|
143682
143846
|
runIdsSeen: msgRunIds.length,
|
|
143683
143847
|
retries: postStopApprovalRecoveryRetries,
|
|
143684
143848
|
runErrorDetail: errorDetail,
|
|
143685
|
-
latestErrorText
|
|
143849
|
+
latestErrorText,
|
|
143850
|
+
fallbackError
|
|
143686
143851
|
})) {
|
|
143687
143852
|
postStopApprovalRecoveryRetries += 1;
|
|
143688
143853
|
emitRecoverableStatusNotice(socket, runtime, {
|
|
@@ -151104,6 +151269,7 @@ var init_client4 = __esm(async () => {
|
|
|
151104
151269
|
getInterruptApprovalsForEmission,
|
|
151105
151270
|
normalizeToolReturnWireMessage,
|
|
151106
151271
|
normalizeExecutionResultsForInterruptParity,
|
|
151272
|
+
getApprovalToolCallDesyncErrorText,
|
|
151107
151273
|
shouldAttemptPostStopApprovalRecovery,
|
|
151108
151274
|
getApprovalContinuationRecoveryDisposition,
|
|
151109
151275
|
markAwaitingAcceptedApprovalContinuationRunId,
|
|
@@ -154078,7 +154244,9 @@ In headless mode, use:
|
|
|
154078
154244
|
try {
|
|
154079
154245
|
debugLog("conversations", `retrieve(${specifiedConversationId}) [headless conv→agent lookup]`);
|
|
154080
154246
|
const conversation = await backend4.retrieveConversation(specifiedConversationId);
|
|
154081
|
-
agent = await backend4.retrieveAgent(conversation.agent_id
|
|
154247
|
+
agent = await backend4.retrieveAgent(conversation.agent_id, {
|
|
154248
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
154249
|
+
});
|
|
154082
154250
|
} catch (error51) {
|
|
154083
154251
|
trackHeadlessBoundaryError("headless_conversation_lookup_failed", error51, "headless_startup_conversation_lookup");
|
|
154084
154252
|
console.error(`Conversation ${specifiedConversationId} not found`);
|
|
@@ -154216,12 +154384,12 @@ In headless mode, use:
|
|
|
154216
154384
|
let conversationId;
|
|
154217
154385
|
let effectiveReflectionSettings;
|
|
154218
154386
|
const isSubagent = process.env.LETTA_CODE_AGENT_ROLE === "subagent";
|
|
154219
|
-
|
|
154387
|
+
let startupMemfsFlag = autoEnableMemfsForFreshAgent ? true : memfsFlag;
|
|
154220
154388
|
if (backend4.capabilities.remoteMemfs && !autoEnableMemfsForFreshAgent) {
|
|
154221
|
-
const { hydrateMemfsSettingFromAgent: hydrateMemfsSettingFromAgent2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
|
|
154389
|
+
const { hydrateMemfsSettingFromAgent: hydrateMemfsSettingFromAgent2, isLettaCloud: isLettaCloud2 } = await Promise.resolve().then(() => (init_memoryFilesystem(), exports_memoryFilesystem));
|
|
154222
154390
|
const memfsEnabled = await hydrateMemfsSettingFromAgent2(agent);
|
|
154223
|
-
if (!memfsEnabled) {
|
|
154224
|
-
|
|
154391
|
+
if (!memfsEnabled && !noMemfsFlag && await isLettaCloud2()) {
|
|
154392
|
+
startupMemfsFlag = true;
|
|
154225
154393
|
}
|
|
154226
154394
|
}
|
|
154227
154395
|
let memfsBgPromise;
|
|
@@ -154309,7 +154477,9 @@ In headless mode, use:
|
|
|
154309
154477
|
const expected = rebuildPrompt(storedPreset, memoryMode);
|
|
154310
154478
|
if (agent.system !== expected) {
|
|
154311
154479
|
await backend4.updateAgent(agent.id, { system: expected });
|
|
154312
|
-
agent = await backend4.retrieveAgent(agent.id
|
|
154480
|
+
agent = await backend4.retrieveAgent(agent.id, {
|
|
154481
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
154482
|
+
});
|
|
154313
154483
|
}
|
|
154314
154484
|
} else {
|
|
154315
154485
|
settingsManager.clearSystemPromptPreset(agent.id);
|
|
@@ -180148,7 +180318,7 @@ var init_registry2 = __esm(() => {
|
|
|
180148
180318
|
}
|
|
180149
180319
|
},
|
|
180150
180320
|
"/rename": {
|
|
180151
|
-
desc: "Rename agent or conversation (/rename agent|convo
|
|
180321
|
+
desc: "Rename agent or conversation (/rename agent [name]|convo [name])",
|
|
180152
180322
|
order: 24,
|
|
180153
180323
|
handler: () => {
|
|
180154
180324
|
return "Renaming...";
|
|
@@ -198307,6 +198477,91 @@ var init_contextChart = __esm(() => {
|
|
|
198307
198477
|
].map(hexToFgAnsi);
|
|
198308
198478
|
});
|
|
198309
198479
|
|
|
198480
|
+
// src/cli/helpers/conversationTitle.ts
|
|
198481
|
+
function normalizeConversationTitle(value) {
|
|
198482
|
+
let normalized = value.replace(/\s+/g, " ").trim();
|
|
198483
|
+
if (normalized.startsWith('"') && normalized.endsWith('"') || normalized.startsWith("'") && normalized.endsWith("'")) {
|
|
198484
|
+
normalized = normalized.slice(1, -1).trim();
|
|
198485
|
+
}
|
|
198486
|
+
if (!normalized || normalized.startsWith("/")) {
|
|
198487
|
+
return null;
|
|
198488
|
+
}
|
|
198489
|
+
return normalized.slice(0, CONVERSATION_TITLE_MAX_LENGTH);
|
|
198490
|
+
}
|
|
198491
|
+
function extractAssistantText(content) {
|
|
198492
|
+
if (typeof content === "string") {
|
|
198493
|
+
return content;
|
|
198494
|
+
}
|
|
198495
|
+
if (Array.isArray(content)) {
|
|
198496
|
+
let collected = "";
|
|
198497
|
+
for (const part of content) {
|
|
198498
|
+
if (part && typeof part === "object" && "text" in part && typeof part.text === "string") {
|
|
198499
|
+
collected += part.text;
|
|
198500
|
+
}
|
|
198501
|
+
}
|
|
198502
|
+
return collected;
|
|
198503
|
+
}
|
|
198504
|
+
return "";
|
|
198505
|
+
}
|
|
198506
|
+
async function generateConversationTitleFromFork(client, conversationId) {
|
|
198507
|
+
let forkId = null;
|
|
198508
|
+
const abortController = new AbortController;
|
|
198509
|
+
const timeoutId = setTimeout(() => abortController.abort(), CONVERSATION_TITLE_TIMEOUT_MS);
|
|
198510
|
+
try {
|
|
198511
|
+
const fork = await forkConversation(conversationId, { hidden: true });
|
|
198512
|
+
forkId = fork.id;
|
|
198513
|
+
const stream2 = await client.conversations.messages.create(forkId, {
|
|
198514
|
+
messages: [
|
|
198515
|
+
{
|
|
198516
|
+
role: "user",
|
|
198517
|
+
content: CONVERSATION_TITLE_USER_PROMPT
|
|
198518
|
+
}
|
|
198519
|
+
],
|
|
198520
|
+
override_model: DEFAULT_SUMMARIZATION_MODEL,
|
|
198521
|
+
override_system: CONVERSATION_TITLE_SYSTEM_PROMPT,
|
|
198522
|
+
max_steps: 1,
|
|
198523
|
+
streaming: true,
|
|
198524
|
+
stream_tokens: false,
|
|
198525
|
+
include_pings: false
|
|
198526
|
+
}, { signal: abortController.signal });
|
|
198527
|
+
let titleText = "";
|
|
198528
|
+
for await (const chunk of stream2) {
|
|
198529
|
+
if (chunk && typeof chunk === "object" && "message_type" in chunk && chunk.message_type === "assistant_message") {
|
|
198530
|
+
titleText += extractAssistantText(chunk.content);
|
|
198531
|
+
}
|
|
198532
|
+
}
|
|
198533
|
+
return normalizeConversationTitle(titleText);
|
|
198534
|
+
} catch (err) {
|
|
198535
|
+
if (isDebugEnabled()) {
|
|
198536
|
+
console.error("[DEBUG] generateConversationTitleFromFork failed:", err);
|
|
198537
|
+
}
|
|
198538
|
+
return null;
|
|
198539
|
+
} finally {
|
|
198540
|
+
clearTimeout(timeoutId);
|
|
198541
|
+
if (forkId) {
|
|
198542
|
+
client.conversations.delete(forkId).catch((err) => {
|
|
198543
|
+
if (isDebugEnabled()) {
|
|
198544
|
+
console.error("[DEBUG] failed to delete title-fork conversation:", err);
|
|
198545
|
+
}
|
|
198546
|
+
});
|
|
198547
|
+
}
|
|
198548
|
+
}
|
|
198549
|
+
}
|
|
198550
|
+
var CONVERSATION_TITLE_MAX_LENGTH = 100, CONVERSATION_TITLE_TIMEOUT_MS = 30000, CONVERSATION_TITLE_SYSTEM_PROMPT = `You are a conversation title generator.
|
|
198551
|
+
|
|
198552
|
+
Output ONLY a short, descriptive title for the conversation above.
|
|
198553
|
+
Rules:
|
|
198554
|
+
- 2 to 7 words
|
|
198555
|
+
- describe the actual topic, not the mood
|
|
198556
|
+
- no quotes, markdown, prefixes, or trailing punctuation
|
|
198557
|
+
- never call any tools — reply with plain text only
|
|
198558
|
+
- avoid generic titles like "New conversation" or "Help request"`, CONVERSATION_TITLE_USER_PROMPT = "Based on the conversation above, output a short title (2-7 words) describing the topic. Reply with ONLY the title text — no quotes, no tools, no preamble.";
|
|
198559
|
+
var init_conversationTitle = __esm(() => {
|
|
198560
|
+
init_conversations2();
|
|
198561
|
+
init_constants();
|
|
198562
|
+
init_debug();
|
|
198563
|
+
});
|
|
198564
|
+
|
|
198310
198565
|
// src/cli/helpers/logoutMessage.ts
|
|
198311
198566
|
function buildLogoutSuccessMessage(hasEnvApiKey) {
|
|
198312
198567
|
if (!hasEnvApiKey) {
|
|
@@ -200873,8 +201128,53 @@ function App2({
|
|
|
200873
201128
|
const sharedReminderStateRef = import_react105.useRef(createSharedReminderState());
|
|
200874
201129
|
const systemPromptRecompileByConversationRef = import_react105.useRef(new Map);
|
|
200875
201130
|
const queuedSystemPromptRecompileByConversationRef = import_react105.useRef(new Set);
|
|
200876
|
-
const
|
|
201131
|
+
const shouldAutoGenerateConversationTitleRef = import_react105.useRef(!resumedExistingConversation);
|
|
201132
|
+
const isAutoConversationTitleInFlightRef = import_react105.useRef(false);
|
|
200877
201133
|
const firstUserQueryRef = import_react105.useRef(null);
|
|
201134
|
+
const setConversationAutoTitleEligibility = import_react105.useCallback((enabled) => {
|
|
201135
|
+
shouldAutoGenerateConversationTitleRef.current = enabled;
|
|
201136
|
+
isAutoConversationTitleInFlightRef.current = false;
|
|
201137
|
+
firstUserQueryRef.current = null;
|
|
201138
|
+
}, []);
|
|
201139
|
+
const deriveAutoConversationTitle = import_react105.useCallback(() => {
|
|
201140
|
+
if (firstUserQueryRef.current) {
|
|
201141
|
+
return firstUserQueryRef.current;
|
|
201142
|
+
}
|
|
201143
|
+
for (const lineId of buffersRef.current.order) {
|
|
201144
|
+
const line = buffersRef.current.byId.get(lineId);
|
|
201145
|
+
if (!line || line.kind !== "user") {
|
|
201146
|
+
continue;
|
|
201147
|
+
}
|
|
201148
|
+
const title = normalizeConversationTitle(line.text);
|
|
201149
|
+
if (title) {
|
|
201150
|
+
return title;
|
|
201151
|
+
}
|
|
201152
|
+
}
|
|
201153
|
+
return null;
|
|
201154
|
+
}, []);
|
|
201155
|
+
const generateConversationTitle = import_react105.useCallback(async () => {
|
|
201156
|
+
const fallback = deriveAutoConversationTitle();
|
|
201157
|
+
if (!experimentManager.isEnabled("conversation_titles")) {
|
|
201158
|
+
return fallback;
|
|
201159
|
+
}
|
|
201160
|
+
if (getBackend().capabilities.localModelCatalog) {
|
|
201161
|
+
return fallback;
|
|
201162
|
+
}
|
|
201163
|
+
const conversationId2 = conversationIdRef.current;
|
|
201164
|
+
if (!conversationId2 || conversationId2 === "default") {
|
|
201165
|
+
return fallback;
|
|
201166
|
+
}
|
|
201167
|
+
try {
|
|
201168
|
+
const client = await getClient();
|
|
201169
|
+
const aiTitle = await generateConversationTitleFromFork(client, conversationId2);
|
|
201170
|
+
return aiTitle ?? fallback;
|
|
201171
|
+
} catch (err) {
|
|
201172
|
+
if (isDebugEnabled()) {
|
|
201173
|
+
console.error("[DEBUG] generateConversationTitle failed:", err);
|
|
201174
|
+
}
|
|
201175
|
+
return fallback;
|
|
201176
|
+
}
|
|
201177
|
+
}, [deriveAutoConversationTitle]);
|
|
200878
201178
|
const resetBootstrapReminderState = import_react105.useCallback(() => {
|
|
200879
201179
|
resetSharedReminderState(sharedReminderStateRef.current);
|
|
200880
201180
|
}, []);
|
|
@@ -202724,16 +203024,25 @@ ${feedback}
|
|
|
202724
203024
|
if (needsEagerApprovalCheck) {
|
|
202725
203025
|
setNeedsEagerApprovalCheck(false);
|
|
202726
203026
|
}
|
|
202727
|
-
if (
|
|
202728
|
-
|
|
202729
|
-
const
|
|
202730
|
-
|
|
202731
|
-
|
|
202732
|
-
}
|
|
202733
|
-
|
|
202734
|
-
|
|
202735
|
-
|
|
202736
|
-
|
|
203027
|
+
if (shouldAutoGenerateConversationTitleRef.current && !isAutoConversationTitleInFlightRef.current && conversationIdRef.current !== "default") {
|
|
203028
|
+
isAutoConversationTitleInFlightRef.current = true;
|
|
203029
|
+
const conversationTitle = await generateConversationTitle();
|
|
203030
|
+
if (!conversationTitle) {
|
|
203031
|
+
isAutoConversationTitleInFlightRef.current = false;
|
|
203032
|
+
} else {
|
|
203033
|
+
const client = await getClient();
|
|
203034
|
+
client.conversations.update(conversationIdRef.current, {
|
|
203035
|
+
summary: conversationTitle
|
|
203036
|
+
}).then(() => {
|
|
203037
|
+
shouldAutoGenerateConversationTitleRef.current = false;
|
|
203038
|
+
}).catch((err) => {
|
|
203039
|
+
if (isDebugEnabled()) {
|
|
203040
|
+
console.error("[DEBUG] Failed to update conversation title:", err);
|
|
203041
|
+
}
|
|
203042
|
+
}).finally(() => {
|
|
203043
|
+
isAutoConversationTitleInFlightRef.current = false;
|
|
203044
|
+
});
|
|
203045
|
+
}
|
|
202737
203046
|
}
|
|
202738
203047
|
const trajectorySnapshot = sessionStatsRef.current.endTrajectory();
|
|
202739
203048
|
setTrajectoryTokenBase(0);
|
|
@@ -203884,6 +204193,7 @@ ${feedback}
|
|
|
203884
204193
|
const resumeData = await getResumeData(client, agentState, conversationId2);
|
|
203885
204194
|
await maybeCarryOverActiveConversationModel(conversationId2);
|
|
203886
204195
|
setConversationIdAndRef(conversationId2);
|
|
204196
|
+
setConversationAutoTitleEligibility(false);
|
|
203887
204197
|
pendingConversationSwitchRef.current = {
|
|
203888
204198
|
origin: "fork",
|
|
203889
204199
|
conversationId: conversationId2,
|
|
@@ -203948,6 +204258,7 @@ ${feedback}
|
|
|
203948
204258
|
runEndHooks,
|
|
203949
204259
|
maybeCarryOverActiveConversationModel,
|
|
203950
204260
|
resetBootstrapReminderState,
|
|
204261
|
+
setConversationAutoTitleEligibility,
|
|
203951
204262
|
setConversationIdAndRef,
|
|
203952
204263
|
setCommandRunning,
|
|
203953
204264
|
setStreaming,
|
|
@@ -204002,6 +204313,7 @@ ${feedback}
|
|
|
204002
204313
|
const agentModelHandle = getPreferredAgentModelHandle2(agent);
|
|
204003
204314
|
setCurrentModelHandle(agentModelHandle);
|
|
204004
204315
|
setConversationIdAndRef(targetConversationId);
|
|
204316
|
+
setConversationAutoTitleEligibility(false);
|
|
204005
204317
|
resetBootstrapReminderState();
|
|
204006
204318
|
{
|
|
204007
204319
|
const { getModelDisplayName: getModelDisplayName3 } = await Promise.resolve().then(() => (init_model(), exports_model));
|
|
@@ -204055,6 +204367,7 @@ ${feedback}
|
|
|
204055
204367
|
resetTrajectoryBases,
|
|
204056
204368
|
resetBootstrapReminderState,
|
|
204057
204369
|
resetPendingReasoningCycle,
|
|
204370
|
+
setConversationAutoTitleEligibility,
|
|
204058
204371
|
setConversationIdAndRef
|
|
204059
204372
|
]);
|
|
204060
204373
|
const handleCreateNewAgent = import_react105.useCallback(async (name21) => {
|
|
@@ -204125,6 +204438,7 @@ ${feedback}
|
|
|
204125
204438
|
const agentModelHandle = getPreferredAgentModelHandle2(agent);
|
|
204126
204439
|
setCurrentModelHandle(agentModelHandle);
|
|
204127
204440
|
setConversationIdAndRef(targetConversationId);
|
|
204441
|
+
setConversationAutoTitleEligibility(false);
|
|
204128
204442
|
pendingConversationSwitchRef.current = {
|
|
204129
204443
|
origin: "agent-switch",
|
|
204130
204444
|
conversationId: targetConversationId,
|
|
@@ -204159,6 +204473,7 @@ ${feedback}
|
|
|
204159
204473
|
resetDeferredToolCallCommits,
|
|
204160
204474
|
resetTrajectoryBases,
|
|
204161
204475
|
resetBootstrapReminderState,
|
|
204476
|
+
setConversationAutoTitleEligibility,
|
|
204162
204477
|
setConversationIdAndRef
|
|
204163
204478
|
]);
|
|
204164
204479
|
const handleBashSubmit = import_react105.useCallback(async (command) => {
|
|
@@ -204364,8 +204679,8 @@ ${SYSTEM_REMINDER_CLOSE}` : "";
|
|
|
204364
204679
|
if (!isSystemOnly && userTextForInput.length > 0) {
|
|
204365
204680
|
telemetry.trackUserInput(userTextForInput, "user", currentModelId || "unknown");
|
|
204366
204681
|
}
|
|
204367
|
-
if (
|
|
204368
|
-
firstUserQueryRef.current = userTextForInput.slice(0, 100);
|
|
204682
|
+
if (shouldAutoGenerateConversationTitleRef.current && firstUserQueryRef.current === null && !isSystemOnly && userTextForInput.length > 0 && !userTextForInput.startsWith("/")) {
|
|
204683
|
+
firstUserQueryRef.current = userTextForInput.replace(/\s+/g, " ").trim().slice(0, 100);
|
|
204369
204684
|
}
|
|
204370
204685
|
if (pendingApprovals.length > 0) {
|
|
204371
204686
|
return { submitted: false };
|
|
@@ -205054,9 +205369,7 @@ Type your task to begin the loop.`, true);
|
|
|
205054
205369
|
isolated_block_labels: [...ISOLATED_BLOCK_LABELS],
|
|
205055
205370
|
...conversationName && { summary: conversationName }
|
|
205056
205371
|
});
|
|
205057
|
-
|
|
205058
|
-
hasSetConversationSummaryRef.current = true;
|
|
205059
|
-
}
|
|
205372
|
+
setConversationAutoTitleEligibility(!conversationName);
|
|
205060
205373
|
await maybeCarryOverActiveConversationModel(conversation.id);
|
|
205061
205374
|
setConversationIdAndRef(conversation.id);
|
|
205062
205375
|
pendingConversationSwitchRef.current = {
|
|
@@ -205100,8 +205413,8 @@ Type your task to begin the loop.`, true);
|
|
|
205100
205413
|
await client.conversations.update(forked.id, {
|
|
205101
205414
|
summary: conversationSummary
|
|
205102
205415
|
});
|
|
205103
|
-
hasSetConversationSummaryRef.current = true;
|
|
205104
205416
|
}
|
|
205417
|
+
setConversationAutoTitleEligibility(false);
|
|
205105
205418
|
await maybeCarryOverActiveConversationModel(forked.id);
|
|
205106
205419
|
setConversationIdAndRef(forked.id);
|
|
205107
205420
|
pendingConversationSwitchRef.current = {
|
|
@@ -205156,6 +205469,7 @@ Type your task to begin the loop.`, true);
|
|
|
205156
205469
|
agent_id: agentId,
|
|
205157
205470
|
isolated_block_labels: [...ISOLATED_BLOCK_LABELS]
|
|
205158
205471
|
});
|
|
205472
|
+
setConversationAutoTitleEligibility(true);
|
|
205159
205473
|
await maybeCarryOverActiveConversationModel(conversation.id);
|
|
205160
205474
|
setConversationIdAndRef(conversation.id);
|
|
205161
205475
|
pendingConversationSwitchRef.current = {
|
|
@@ -205273,8 +205587,8 @@ Type your task to begin the loop.`, true);
|
|
|
205273
205587
|
"Rename the current agent or conversation.",
|
|
205274
205588
|
"",
|
|
205275
205589
|
"USAGE",
|
|
205276
|
-
" /rename agent
|
|
205277
|
-
" /rename convo
|
|
205590
|
+
" /rename agent [name] — rename the agent",
|
|
205591
|
+
" /rename convo [name] — rename the convo, or auto-generate when omitted",
|
|
205278
205592
|
" /rename help — show this help"
|
|
205279
205593
|
].join(`
|
|
205280
205594
|
`);
|
|
@@ -205282,26 +205596,41 @@ Type your task to begin the loop.`, true);
|
|
|
205282
205596
|
return { submitted: true };
|
|
205283
205597
|
}
|
|
205284
205598
|
if (!subcommand || subcommand !== "agent" && subcommand !== "convo") {
|
|
205285
|
-
cmd.fail("Usage: /rename agent
|
|
205599
|
+
cmd.fail("Usage: /rename agent [name] or /rename convo [name]");
|
|
205286
205600
|
return { submitted: true };
|
|
205287
205601
|
}
|
|
205288
205602
|
const newValue = parts.slice(2).join(" ");
|
|
205289
|
-
if (!newValue) {
|
|
205290
|
-
cmd.fail(
|
|
205603
|
+
if (subcommand === "agent" && !newValue) {
|
|
205604
|
+
cmd.fail("Please provide a name: /rename agent <name>");
|
|
205291
205605
|
return { submitted: true };
|
|
205292
205606
|
}
|
|
205293
205607
|
if (subcommand === "convo") {
|
|
205608
|
+
const shouldAutoGenerate = newValue.trim().length === 0;
|
|
205294
205609
|
cmd.update({
|
|
205295
|
-
output: `Renaming conversation to "${newValue}"...`,
|
|
205610
|
+
output: shouldAutoGenerate ? "Generating conversation title..." : `Renaming conversation to "${newValue}"...`,
|
|
205296
205611
|
phase: "running"
|
|
205297
205612
|
});
|
|
205298
205613
|
setCommandRunning(true);
|
|
205299
205614
|
try {
|
|
205300
205615
|
const client = await getClient();
|
|
205301
|
-
|
|
205302
|
-
|
|
205303
|
-
|
|
205304
|
-
|
|
205616
|
+
if (shouldAutoGenerate) {
|
|
205617
|
+
const conversationTitle = await generateConversationTitle();
|
|
205618
|
+
if (!conversationTitle) {
|
|
205619
|
+
cmd.fail("No conversation content available to generate a title");
|
|
205620
|
+
return { submitted: true };
|
|
205621
|
+
}
|
|
205622
|
+
await client.conversations.update(conversationId, {
|
|
205623
|
+
summary: conversationTitle
|
|
205624
|
+
});
|
|
205625
|
+
setConversationAutoTitleEligibility(false);
|
|
205626
|
+
cmd.finish(`Conversation title set to "${conversationTitle}"`, true);
|
|
205627
|
+
} else {
|
|
205628
|
+
await client.conversations.update(conversationId, {
|
|
205629
|
+
summary: newValue
|
|
205630
|
+
});
|
|
205631
|
+
setConversationAutoTitleEligibility(false);
|
|
205632
|
+
cmd.finish(`Conversation renamed to "${newValue}"`, true);
|
|
205633
|
+
}
|
|
205305
205634
|
} catch (error51) {
|
|
205306
205635
|
const errorDetails = formatErrorDetails2(error51, agentId);
|
|
205307
205636
|
cmd.fail(`Failed: ${errorDetails}`);
|
|
@@ -205408,6 +205737,7 @@ Type your task to begin the loop.`, true);
|
|
|
205408
205737
|
const client = await getClient();
|
|
205409
205738
|
const resumeData = await getResumeData(client, agentState, targetConvId);
|
|
205410
205739
|
setConversationIdAndRef(targetConvId);
|
|
205740
|
+
setConversationAutoTitleEligibility(false);
|
|
205411
205741
|
pendingConversationSwitchRef.current = {
|
|
205412
205742
|
origin: "resume-direct",
|
|
205413
205743
|
conversationId: targetConvId,
|
|
@@ -206532,6 +206862,7 @@ ${SYSTEM_REMINDER_CLOSE}
|
|
|
206532
206862
|
systemInfoReminderEnabled,
|
|
206533
206863
|
appendTaskNotificationEvents,
|
|
206534
206864
|
maybeCarryOverActiveConversationModel,
|
|
206865
|
+
setConversationAutoTitleEligibility,
|
|
206535
206866
|
setConversationIdAndRef
|
|
206536
206867
|
]);
|
|
206537
206868
|
const onSubmitRef = import_react105.useRef(onSubmit);
|
|
@@ -207578,6 +207909,7 @@ ${guidance}`);
|
|
|
207578
207909
|
if (agentState) {
|
|
207579
207910
|
const resumeData = await getResumeData(client, agentState, action.conversationId);
|
|
207580
207911
|
setConversationIdAndRef(action.conversationId);
|
|
207912
|
+
setConversationAutoTitleEligibility(false);
|
|
207581
207913
|
pendingConversationSwitchRef.current = {
|
|
207582
207914
|
origin: "resume-selector",
|
|
207583
207915
|
conversationId: action.conversationId,
|
|
@@ -207637,6 +207969,7 @@ ${guidance}`);
|
|
|
207637
207969
|
commandRunner.start,
|
|
207638
207970
|
recoverRestoredPendingApprovals,
|
|
207639
207971
|
resetBootstrapReminderState,
|
|
207972
|
+
setConversationAutoTitleEligibility,
|
|
207640
207973
|
setConversationIdAndRef
|
|
207641
207974
|
]);
|
|
207642
207975
|
const handleFeedbackSubmit = import_react105.useCallback(async (message) => {
|
|
@@ -208888,6 +209221,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
208888
209221
|
const client = await getClient();
|
|
208889
209222
|
const resumeData = await getResumeData(client, agentState, convId);
|
|
208890
209223
|
setConversationIdAndRef(convId);
|
|
209224
|
+
setConversationAutoTitleEligibility(false);
|
|
208891
209225
|
pendingConversationSwitchRef.current = {
|
|
208892
209226
|
origin: "resume-selector",
|
|
208893
209227
|
conversationId: convId,
|
|
@@ -208896,9 +209230,6 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
208896
209230
|
summary: selectorContext?.summary,
|
|
208897
209231
|
messageHistory: resumeData.messageHistory
|
|
208898
209232
|
};
|
|
208899
|
-
if (selectorContext?.summary) {
|
|
208900
|
-
hasSetConversationSummaryRef.current = true;
|
|
208901
|
-
}
|
|
208902
209233
|
settingsManager.persistSession(agentId, convId);
|
|
208903
209234
|
const currentAgentName = agentState.name || "Unnamed Agent";
|
|
208904
209235
|
const successLines = resumeData.messageHistory.length > 0 ? [
|
|
@@ -209000,6 +209331,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
209000
209331
|
});
|
|
209001
209332
|
await maybeCarryOverActiveConversationModel(conversation.id);
|
|
209002
209333
|
setConversationIdAndRef(conversation.id);
|
|
209334
|
+
setConversationAutoTitleEligibility(true);
|
|
209003
209335
|
settingsManager.persistSession(agentId, conversation.id);
|
|
209004
209336
|
const currentAgentName = agentState?.name || "Unnamed Agent";
|
|
209005
209337
|
const shortConvId = conversation.id.slice(0, 20);
|
|
@@ -209084,6 +209416,7 @@ If using apply_patch, use this exact relative patch path: ${applyPatchRelativePa
|
|
|
209084
209416
|
const client = await getClient();
|
|
209085
209417
|
const resumeData = await getResumeData(client, agentState, actualTargetConv);
|
|
209086
209418
|
setConversationIdAndRef(actualTargetConv);
|
|
209419
|
+
setConversationAutoTitleEligibility(false);
|
|
209087
209420
|
pendingConversationSwitchRef.current = {
|
|
209088
209421
|
origin: "search",
|
|
209089
209422
|
conversationId: actualTargetConv,
|
|
@@ -209315,6 +209648,7 @@ var init_App2 = __esm(async () => {
|
|
|
209315
209648
|
init_backfill();
|
|
209316
209649
|
init_chunkLog();
|
|
209317
209650
|
init_contextChart();
|
|
209651
|
+
init_conversationTitle();
|
|
209318
209652
|
init_diff2();
|
|
209319
209653
|
init_errorContext();
|
|
209320
209654
|
init_errorFormatter();
|
|
@@ -211700,7 +212034,9 @@ async function updateAgentLLMConfig2(agentId, modelHandle, updateArgs, options)
|
|
|
211700
212034
|
max_tokens: updateArgs.max_output_tokens
|
|
211701
212035
|
}
|
|
211702
212036
|
});
|
|
211703
|
-
const finalAgent = await backend3.retrieveAgent(agentId
|
|
212037
|
+
const finalAgent = await backend3.retrieveAgent(agentId, {
|
|
212038
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
212039
|
+
});
|
|
211704
212040
|
return finalAgent;
|
|
211705
212041
|
}
|
|
211706
212042
|
async function updateAgentSystemPromptRaw2(agentId, systemPromptContent) {
|
|
@@ -211742,7 +212078,9 @@ async function updateAgentSystemPrompt2(agentId, systemPromptId) {
|
|
|
211742
212078
|
settingsManager2.clearSystemPromptPreset(agentId);
|
|
211743
212079
|
}
|
|
211744
212080
|
}
|
|
211745
|
-
const agent = await backend3.retrieveAgent(agentId
|
|
212081
|
+
const agent = await backend3.retrieveAgent(agentId, {
|
|
212082
|
+
include: ["agent.secrets", "agent.tools", "agent.tags"]
|
|
212083
|
+
});
|
|
211746
212084
|
return {
|
|
211747
212085
|
success: true,
|
|
211748
212086
|
message: "System prompt applied successfully",
|
|
@@ -212930,6 +213268,7 @@ function extractReasonList(value) {
|
|
|
212930
213268
|
}
|
|
212931
213269
|
var CLOUDFLARE_EDGE_5XX_MARKER_PATTERN = /(^|\s)(502|52[0-6])\s*<!doctype html|error code\s*(502|52[0-6])/i;
|
|
212932
213270
|
var CLOUDFLARE_EDGE_5XX_TITLE_PATTERN = /\|\s*(502|52[0-6])\s*:/i;
|
|
213271
|
+
var CLOUDFLARE_JSON_5XX_PATTERN = /"cloudflare_error"\s*:\s*true/s;
|
|
212933
213272
|
function isCloudflareEdge52xHtmlError(text2) {
|
|
212934
213273
|
const normalized = text2.toLowerCase();
|
|
212935
213274
|
const hasCloudflare = normalized.includes("cloudflare");
|
|
@@ -212938,6 +213277,17 @@ function isCloudflareEdge52xHtmlError(text2) {
|
|
|
212938
213277
|
return hasCloudflare && hasHtml && has52xCode;
|
|
212939
213278
|
}
|
|
212940
213279
|
function parseCloudflareEdgeError(text2) {
|
|
213280
|
+
if (CLOUDFLARE_JSON_5XX_PATTERN.test(text2)) {
|
|
213281
|
+
try {
|
|
213282
|
+
const obj = JSON.parse(text2);
|
|
213283
|
+
return {
|
|
213284
|
+
code: String(obj.status),
|
|
213285
|
+
statusText: obj.error_name || obj.title || undefined,
|
|
213286
|
+
host: obj.zone || undefined,
|
|
213287
|
+
rayId: obj.ray_id || undefined
|
|
213288
|
+
};
|
|
213289
|
+
} catch {}
|
|
213290
|
+
}
|
|
212941
213291
|
if (!isCloudflareEdge52xHtmlError(text2))
|
|
212942
213292
|
return;
|
|
212943
213293
|
const code = text2.match(/^\s*(502|52[0-6])\s*<!doctype html/i)?.[1] ?? text2.match(/error code\s*(502|52[0-6])/i)?.[1] ?? text2.match(/\|\s*(502|52[0-6])\s*:/i)?.[1];
|
|
@@ -220554,4 +220904,4 @@ Error during initialization: ${message}`);
|
|
|
220554
220904
|
}
|
|
220555
220905
|
main();
|
|
220556
220906
|
|
|
220557
|
-
//# debugId=
|
|
220907
|
+
//# debugId=F09C9549AC025A7964756E2164756E21
|