chore: uptick
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { atom } from 'nanostores'
|
||||
|
||||
export interface ClarifyRequest {
|
||||
requestId: string
|
||||
question: string
|
||||
choices: string[] | null
|
||||
sessionId: string | null
|
||||
}
|
||||
|
||||
// Holds the request_id (and metadata) for the most recent in-flight
|
||||
// clarify call. The inline ClarifyTool component (rendered inside the
|
||||
// assistant message stream) reads this to know which request_id to send
|
||||
// back over `clarify.respond`.
|
||||
export const $clarifyRequest = atom<ClarifyRequest | null>(null)
|
||||
|
||||
export function setClarifyRequest(request: ClarifyRequest): void {
|
||||
$clarifyRequest.set(request)
|
||||
}
|
||||
|
||||
export function clearClarifyRequest(requestId?: string): void {
|
||||
const current = $clarifyRequest.get()
|
||||
|
||||
if (!current) {
|
||||
return
|
||||
}
|
||||
|
||||
if (requestId && current.requestId !== requestId) {
|
||||
return
|
||||
}
|
||||
|
||||
$clarifyRequest.set(null)
|
||||
}
|
||||
@@ -10,6 +10,7 @@ export interface ComposerAttachment {
|
||||
refText?: string
|
||||
previewUrl?: string
|
||||
path?: string
|
||||
attachedSessionId?: string
|
||||
}
|
||||
|
||||
export const $composerDraft = atom('')
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { atom } from 'nanostores'
|
||||
|
||||
import type { HermesGateway } from '@/hermes'
|
||||
|
||||
// The active gateway instance, exposed for inline message-stream components
|
||||
// (e.g. inline ClarifyTool) that need to call gateway methods without having
|
||||
// the instance threaded down through props from `ChatView`.
|
||||
export const $gateway = atom<HermesGateway | null>(null)
|
||||
|
||||
export function setGateway(gateway: HermesGateway | null): void {
|
||||
if ($gateway.get() === gateway) {
|
||||
return
|
||||
}
|
||||
|
||||
$gateway.set(gateway)
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { atom } from 'nanostores'
|
||||
|
||||
export interface PreviewTarget {
|
||||
kind: 'file' | 'url'
|
||||
label: string
|
||||
source: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export const $previewTarget = atom<PreviewTarget | null>(null)
|
||||
|
||||
export function setPreviewTarget(target: PreviewTarget | null) {
|
||||
$previewTarget.set(target)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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
|
||||
Reference in New Issue
Block a user