u
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user