This commit is contained in:
seb
2026-10-16 15:22:13 +02:00
parent bed19f8b10
commit 5ed634990e
9 changed files with 118 additions and 300 deletions

View File

@@ -1,6 +1,6 @@
import fs from 'fs';
import path from 'path';
import { defineTool, ToolError } from 'libllmorbiter';
import { defineTool, ToolError, DirectReturnError } from 'libllmorbiter';
import { isReadOnlyDatabasePath } from './vfs.js';
import { isSkillPath, renderSkill, parseSkill, SKILL_EXT, skillFileName } from './skill.js';
import { prepareVfs, syncVfsToDb } from './vfs.js';
@@ -64,9 +64,9 @@ function toLines(text) {
/**
* Creates the patch tool bound to a company's virtual filesystem.
* @param {{ googleAuthId: number }} ctx
* @param {{ googleAuthId: number, conversationId?: number }} ctx
*/
export function createPatchTool({ googleAuthId }) {
export function createPatchTool({ googleAuthId, conversationId }) {
return defineTool({
name: 'patch',
description: TOOL_DESCRIPTIONS.patch,
@@ -197,9 +197,10 @@ export function createPatchTool({ googleAuthId }) {
let original = '';
if (!isCreate) {
try {
const readVal = await requestDraftRead({ userId: googleAuthId, name: draftInfo.name });
const readVal = await requestDraftRead({ userId: googleAuthId, conversationId, name: draftInfo.name });
original = typeof readVal === 'string' ? readVal : JSON.stringify(readVal ?? {}, null, 2);
} catch (err) {
if (err instanceof DirectReturnError) throw err;
const cached = getCachedDraft({ userId: googleAuthId, name: draftInfo.name });
if (cached) {
original = typeof cached.content === 'string' ? cached.content : JSON.stringify(cached.content ?? {}, null, 2);