feat: misc tool alignment (#137)
This commit is contained in:
@@ -212,4 +212,29 @@ export function backfillBuffers(buffers: Buffers, history: Message[]): void {
|
||||
break; // ignore other message types
|
||||
}
|
||||
}
|
||||
|
||||
// Mark stray tool calls as closed
|
||||
// Walk backwards: any pending tool_call before the first "transition" (non-pending-tool-call) is stray
|
||||
let foundTransition = false;
|
||||
for (let i = buffers.order.length - 1; i >= 0; i--) {
|
||||
const lineId = buffers.order[i];
|
||||
if (!lineId) continue;
|
||||
const line = buffers.byId.get(lineId);
|
||||
|
||||
if (line?.kind === "tool_call" && line.phase === "ready") {
|
||||
if (foundTransition) {
|
||||
// This is a stray - mark it closed
|
||||
buffers.byId.set(lineId, {
|
||||
...line,
|
||||
phase: "finished",
|
||||
resultText: "[Tool return not found in history]",
|
||||
resultOk: false,
|
||||
});
|
||||
}
|
||||
// else: legit pending, leave it
|
||||
} else {
|
||||
// Hit something that's not a pending tool_call - transition point
|
||||
foundTransition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
117
src/cli/helpers/planName.ts
Normal file
117
src/cli/helpers/planName.ts
Normal file
@@ -0,0 +1,117 @@
|
||||
import { homedir } from "node:os";
|
||||
|
||||
const adjectives = [
|
||||
"bold",
|
||||
"bright",
|
||||
"calm",
|
||||
"clever",
|
||||
"crisp",
|
||||
"daring",
|
||||
"eager",
|
||||
"fair",
|
||||
"gentle",
|
||||
"happy",
|
||||
"keen",
|
||||
"lively",
|
||||
"merry",
|
||||
"nimble",
|
||||
"playful",
|
||||
"quick",
|
||||
"radiant",
|
||||
"serene",
|
||||
"swift",
|
||||
"vivid",
|
||||
"warm",
|
||||
"witty",
|
||||
"zealous",
|
||||
"agile",
|
||||
"breezy",
|
||||
"charming",
|
||||
"dazzling",
|
||||
"elegant",
|
||||
"fancy",
|
||||
"golden",
|
||||
"humble",
|
||||
"jolly",
|
||||
"kind",
|
||||
"lucky",
|
||||
"mystic",
|
||||
"noble",
|
||||
"peaceful",
|
||||
"quiet",
|
||||
"rolling",
|
||||
"shiny",
|
||||
"tender",
|
||||
"upbeat",
|
||||
"valiant",
|
||||
"whimsy",
|
||||
"youthful",
|
||||
"zesty",
|
||||
];
|
||||
|
||||
const nouns = [
|
||||
"apple",
|
||||
"brook",
|
||||
"cloud",
|
||||
"dawn",
|
||||
"elm",
|
||||
"fern",
|
||||
"grove",
|
||||
"hill",
|
||||
"iris",
|
||||
"jade",
|
||||
"kite",
|
||||
"lake",
|
||||
"maple",
|
||||
"nest",
|
||||
"oak",
|
||||
"pine",
|
||||
"quartz",
|
||||
"river",
|
||||
"stone",
|
||||
"tide",
|
||||
"umbra",
|
||||
"vine",
|
||||
"wave",
|
||||
"yarn",
|
||||
"zenith",
|
||||
"acorn",
|
||||
"birch",
|
||||
"coral",
|
||||
"dune",
|
||||
"ember",
|
||||
"frost",
|
||||
"glade",
|
||||
"harbor",
|
||||
"ivy",
|
||||
"jasper",
|
||||
"kelp",
|
||||
"lotus",
|
||||
"moss",
|
||||
"nova",
|
||||
"opal",
|
||||
"pebble",
|
||||
"plum",
|
||||
"reed",
|
||||
"sage",
|
||||
"thorn",
|
||||
"violet",
|
||||
"willow",
|
||||
"zephyr",
|
||||
];
|
||||
|
||||
function randomElement<T>(arr: T[]): T {
|
||||
return arr[Math.floor(Math.random() * arr.length)] as T;
|
||||
}
|
||||
|
||||
export function generatePlanName(): string {
|
||||
const adj1 = randomElement(adjectives);
|
||||
const adj2 = randomElement(adjectives);
|
||||
const noun = randomElement(nouns);
|
||||
return `${adj1}-${adj2}-${noun}`;
|
||||
}
|
||||
|
||||
export function generatePlanFilePath(): string {
|
||||
const name = generatePlanName();
|
||||
return `${homedir()}/.letta/plans/${name}.md`;
|
||||
}
|
||||
Reference in New Issue
Block a user