char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
0afb805b1
char/aliceai-t5-moe
1/** 2* Unified exports for all utility functions 3* Import utilities from '$lib/utils' for cleaner imports 4* 5* For browser-only utilities (pdf-processing, audio-recording, svg-to-png, 6* webp-to-png, process-uploaded-files, convert-files-to-extra), use: 7* import { ... } from '$lib/utils/browser-only' 8*/ 9 10// API utilities 11export { getAuthHeaders , getJsonHeaders , sanitizeHeaders } from './api-headers' ; 12export { ApiError , apiFetch , apiFetchWithParams , apiPost } from './api-fetch' ; 13export { validateApiKey } from './api-key-validation' ; 14 15// Attachment utilities 16export { getAttachmentDisplayItems , isMcpPrompt , isMcpResource } from './attachment-display' ; 17export { isTextFile , isImageFile , isPdfFile , isAudioFile , isVideoFile } from './attachment-type' ; 18 19// Textarea utilities 20export { default as autoResizeTextarea } from './autoresize-textarea' ; 21 22// Branching utilities 23export { 24filterByLeafNodeId , 25findMessageById , 26findLeafNode , 27findDescendantMessages , 28getMessageSiblings , 29buildSiblingInfoMap 30} from './branching' ; 31 32// Code 33export { 34highlightCode , 35detectIncompleteCodeBlock , 36splitGluedClosingCodeFences , 37trimCodePadding , 38type IncompleteCodeBlock 39} from './code' ; 40 41// Config helpers 42export { setConfigValue , getConfigValue , configToParameterRecord } from './config-helpers' ; 43 44// CORS Proxy 45export { buildProxiedUrl , buildProxiedHeaders } from './cors-proxy' ; 46 47// URL utilities 48export { extractRootDomain , sanitizeExternalUrl , canonicalizeServerUrl } from './url' ; 49 50// Progress helpers 51export { modelLoadFraction , modelLoadProgressText } from './progress' ; 52 53// Conversation utilities 54export { 55createMessageCountMap , 56getMessageCount , 57getConversationModel , 58buildConversationTree , 59type ConversationTreeItem 60} from './conversation-utils' ; 61 62// Clipboard utilities 63export { 64copyToClipboard , 65copyCodeToClipboard , 66formatMessageForClipboard , 67parseClipboardContent , 68hasClipboardAttachments 69} from './clipboard' ; 70 71// File preview utilities 72export { getFileTypeLabel } from './file-preview' ; 73export { getPreviewText , generateConversationTitle } from './text' ; 74 75// File type utilities 76export { 77getFileTypeCategory , 78getFileTypeCategoryByExtension , 79getFileTypeByExtension , 80isFileTypeSupported 81} from './file-type' ; 82 83// Formatting utilities 84export { 85formatFileSize , 86formatParameters , 87formatNumber , 88formatJsonPretty , 89formatTime , 90formatPerformanceTime , 91formatAttachmentText 92} from './formatters' ; 93 94// IME utilities 95export { isIMEComposing } from './is-ime-composing' ; 96 97// LaTeX utilities 98export { maskInlineLaTeX , preprocessLaTeX } from './latex-protection' ; 99 100// Modality file validation utilities 101export { 102isFileTypeSupportedByModel , 103filterFilesByModalities , 104generateModalityErrorMessage 105} from './modality-file-validation' ; 106 107// Model name utilities 108export { normalizeModelName , isValidModelName } from './model-names' ; 109 110// Portal utilities 111export { portalToBody } from './portal-to-body' ; 112 113// Precision utilities 114export { normalizeFloatingPoint , normalizeNumber } from './precision' ; 115 116// Syntax highlighting utilities 117export { getLanguageFromFilename } from './syntax-highlight-language' ; 118 119// Text file utilities 120export { isTextFileByName , readFileAsText , isLikelyTextFile } from './text-files' ; 121 122// Debounce utilities 123export { debounce } from './debounce' ; 124 125// Sanitization utilities 126export { sanitizeKeyValuePairKey , sanitizeKeyValuePairValue } from './sanitize' ; 127 128// Image error fallback utilities 129export { getImageErrorFallbackHtml } from './image-error-fallback' ; 130 131// SSE-with-JSON stream iterator (used by server tool streaming, decoupled 132// from chat.service.ts which embeds its own SSE parser for resume support) 133export { extractSseDataPayload , parseSseJsonStream , splitSseRecords } from './sse' ; 134 135// Stream session identity (conversation-id based) 136export { streamIdentity } from './stream-identity' ; 137 138// MCP utilities 139export { 140detectMcpTransportFromUrl , 141parseMcpServerSettings , 142getMcpLogLevelIcon , 143getMcpLogLevelClass , 144isImageMimeType , 145parseResourcePath , 146getDisplayName , 147getResourceDisplayName , 148isCodeResource , 149isImageResource , 150getResourceIcon , 151getResourceTextContent , 152getResourceBlobContent , 153downloadResourceContent , 154getMcpIconUrl , 155getMcpServerFaviconFallback , 156getMcpServerLabel 157} from './mcp' ; 158 159// URI Template utilities 160export { 161extractTemplateVariables , 162expandTemplate , 163isTemplateComplete , 164normalizeResourceUri , 165type UriTemplateVariable 166} from './uri-template' ; 167 168// Data URL utilities 169export { createBase64DataUrl } from './data-url' ; 170 171// Header utilities 172export { parseHeadersToArray , serializeHeaders } from './headers' ; 173 174// Working-directory display helpers (HOME-style tilde abbreviation) 175export { 176abbreviateWorkingDir , 177abbreviateHome , 178lastPathSegment , 179formatCwdMessage , 180parseCwdMessage , 181CWD_CHANGED_PREFIX , 182CWD_CLEARED_TEXT , 183type CwdMessageInfo 184} from './path-display' ; 185 186// Working-directory picker search helpers 187export { 188splitPathQuery , 189buildCaseInsensitiveGlob , 190buildGlobSearchArgs , 191rankEntries , 192joinPath , 193highlightMatch , 194type PathQuery 195} from './working-directory' ; 196 197// Shared `file_glob_search` runner with a short-lived result cache 198export { runGlobSearch , runGlobSearchWithChildren } from './glob-search' ; 199 200// Mention-token detection (for the `@`-triggered file/folder mention picker) 201export { 202findMentionToken , 203takeMentionDismissSnapshot , 204type MentionDismissSnapshot 205} from './mention-token' ; 206 207// Slash-command token detection (for the `/`-triggered command picker) 208export { 209findCommandToken , 210takeCommandDismissSnapshot , 211type CommandDismissSnapshot 212} from './command-token' ; 213 214// Tokenization for the ChatFormInputRich (mention links + code spans <-> chip DOM) 215export { 216tokenizeContent , 217containsCodeSpan , 218isOffsetInCodeBlock , 219domMatchesTokens , 220syncCodeBlockHatches , 221stripBlockBoundaryLineBreaks , 222serializeContent , 223buildFragment , 224rangeToTextOffset , 225textOffsetToRange , 226badgeAwareWordJump , 227leadingBadgeEdgeOffset 228} from './chat-form-input-rich-tokenizer' ; 229 230// Source-space undo/redo history for the ChatFormInputRich 231export { SourceHistory , type SourceHistoryEntry } from './source-history' ; 232 233// Mention-badge visual contract (used by the ChatFormInputRich / rehype 234// DOM paths that build the same chip without a Svelte mount) 235export { 236containsFileMentionLink , 237fileMentionLinkRe , 238encodeFileLinkPath , 239decodeFileLinkPath , 240MENTION_BADGE_CLASSNAME , 241MENTION_BADGE_ICON_CLASSNAME , 242MENTION_BADGE_SVG_ATTRIBUTES , 243MENTION_BADGE_FILE_ICON_PATHS , 244MENTION_BADGE_FOLDER_ICON_PATHS , 245getMentionBadgeIconPaths , 246getMentionBadgeLabel , 247splitMentionSegments , 248buildMentionInsertion 249} from './mention-badge' ; 250 251// Chat template utilities 252export { 253detectThinkingSupport , 254detectThinkingSupportWithReason 255} from './chat-template-thinking-detector' ; 256 257// Agentic content utilities (structured section derivation) 258export { 259deriveAgenticSections , 260buildAssistantRawOutput , 261parseToolResultWithMedia , 262splitSearchSummaryList , 263hasAgenticContent , 264classifyToolResult , 265classifyContinueIntent 266} from './agentic' ; 267 268// Line-level unified diff for tool result rendering (`edit_file` block) 269export { computeLineDiff , prefixFor , renderUnifiedDiff , type DiffLine } from './compute-line-diff' ; 270 271// Partial-incremental JSON parser for streaming tool arguments 272export { parsePartialJsonArgs } from './parse-partial-json-args' ; 273 274// `exec_shell_command` result parsing 275export { parseExecShellCommandError } from './parse-exec-shell-error' ; 276export { 277parseExecShellCommandExitStatus , 278isExitCodeSummaryLine , 279type ExecShellExitStatus 280} from './parse-exec-shell-status' ; 281 282// Search-result parsing (web-search / fetch MCP tools) 283export { 284SUPPORTED_WEB_SEARCH_TOOL_NAMES , 285extractSearchResults , 286extractSearchQuery , 287faviconForUrl , 288isWebSearchToolName , 289looksLikeSearchResult 290} from './search-results' ; 291 292// Cache utilities 293export { TTLCache , ReactiveTTLMap } from './cache-ttl' ; 294 295// Redaction utilities 296export { redactValue } from './redact' ; 297 298// Request inspection utilities 299export { 300getRequestUrl , 301getRequestMethod , 302getRequestBody , 303summarizeRequestBody , 304formatDiagnosticErrorMessage , 305extractJsonRpcMethods , 306type RequestBodySummary 307} from './request-helpers' ; 308 309// Abort signal utilities 310export { 311throwIfAborted , 312isAbortError , 313createLinkedController , 314createTimeoutSignal , 315withAbortSignal 316} from './abort' ; 317 318// Tool-call meta utilities. Parsers for each server tool live next to 319// their renderer family under 320// `src/lib/components/app/chat/ChatMessages/ChatMessage/ChatMessageToolCall/parsers/`. 321// This module only carries the helpers that genuinely cross tool 322// boundaries (currently: parsing the tool-result blob into a JSON 323// object). 324export { tryParseToolResultObject } from './tool-call-meta' ; 325 326// Per-tool UI metadata (label + icon) used by the tool-call chrome. 327// Re-exported through $lib/utils so renderer components can read the 328// label without depending on $lib/constants directly. 329export { getToolUi } from './tool-ui' ; 330 331// Chat command picker 332 333export { getChatCommands } from './chat-commands' ; 334 335// Sandbox tool definition 336// SANDBOX_TOOL_DEFINITION is deprecated; kept for backward compatibility. 337export { buildSandboxToolDefinition , SANDBOX_TOOL_DEFINITION } from './sandbox-tool' ; 338 339// Browser `get_datetime` executor (the browser clock, not the server's) 340export { executeGetDatetimeTool } from './get-datetime' ; 341 342// Browser fallback for the server's get_info tool 343export { executeBrowserInfoTool } from './browser-info' ; 344 345// Cryptography utilities 346 347export { uuid } from './uuid' ; 348 349// CSS utilities 350export { remToPx } from './css' ; 351 352// Audio format helper (used by agentic store and chat service) 353export { getAudioInputFormat } from './audio-format' ;