24 lines
513 B
TypeScript
24 lines
513 B
TypeScript
import { atom } from 'nanostores'
|
|
|
|
const $toolDiffs = atom<Record<string, string>>({})
|
|
|
|
export function recordToolDiff(toolCallId: string, diff: string) {
|
|
if (!toolCallId || !diff) {
|
|
return
|
|
}
|
|
|
|
const current = $toolDiffs.get()
|
|
|
|
if (current[toolCallId] === diff) {
|
|
return
|
|
}
|
|
|
|
$toolDiffs.set({ ...current, [toolCallId]: diff })
|
|
}
|
|
|
|
export function getToolDiff(toolCallId: string): string {
|
|
return toolCallId ? $toolDiffs.get()[toolCallId] || '' : ''
|
|
}
|
|
|
|
export const $toolInlineDiffs = $toolDiffs
|