refactor(shared): hide parser helper internals

This commit is contained in:
Vincent Koc
2026-06-17 15:59:58 +08:00
parent 3b4808100d
commit d1923085e3
4 changed files with 10 additions and 10 deletions
+5 -5
View File
@@ -30,15 +30,15 @@ const AVATAR_MIME_BY_EXT: Record<string, string> = {
};
/** Detects data URLs before image-specific avatar validation. */
export const AVATAR_DATA_RE = /^data:/i;
const AVATAR_DATA_RE = /^data:/i;
/** Detects inline image data URLs that can be used as avatar sources. */
export const AVATAR_IMAGE_DATA_RE = /^data:image\//i;
const AVATAR_IMAGE_DATA_RE = /^data:image\//i;
/** Detects remote avatar URLs served over HTTP(S). */
export const AVATAR_HTTP_RE = /^https?:\/\//i;
const AVATAR_HTTP_RE = /^https?:\/\//i;
/** Detects URI schemes so non-path avatar values can be rejected or routed. */
export const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
const AVATAR_SCHEME_RE = /^[a-z][a-z0-9+.-]*:/i;
/** Detects Windows absolute paths before URI-scheme classification. */
export const WINDOWS_ABS_RE = /^[a-zA-Z]:[\\/]/;
const WINDOWS_ABS_RE = /^[a-zA-Z]:[\\/]/;
const AVATAR_PATH_EXT_RE = /\.(png|jpe?g|gif|webp|svg|ico)$/i;
+2 -2
View File
@@ -1,8 +1,8 @@
/** JSON opening delimiters supported by the balanced-fragment scanner. */
export type JsonOpeningDelimiter = "{" | "[";
type JsonOpeningDelimiter = "{" | "[";
/** One balanced JSON object/array fragment found inside arbitrary text. */
export type BalancedJsonFragment = {
type BalancedJsonFragment = {
json: string;
startIndex: number;
endIndex: number;
+2 -2
View File
@@ -1,5 +1,5 @@
// Final tag helpers detect final-answer tag regions in assistant text.
export type FinalTagMatch = {
type FinalTagMatch = {
index: number;
text: string;
isClose: boolean;
@@ -78,7 +78,7 @@ function parseAttributeList(text: string): boolean {
}
/** Parses a candidate `<final>` tag while rejecting lookalike names and malformed attributes. */
export function parseFinalTag(text: string): Omit<FinalTagMatch, "index" | "text"> | null {
function parseFinalTag(text: string): Omit<FinalTagMatch, "index" | "text"> | null {
if (!text.startsWith("<") || !text.endsWith(">")) {
return null;
}
+1 -1
View File
@@ -2,7 +2,7 @@
import { asOptionalRecord } from "@openclaw/normalization-core/record-coerce";
import { normalizeOptionalString as readTrimmedString } from "@openclaw/normalization-core/string-coerce";
export type ToolCallShapedTextDetection = {
type ToolCallShapedTextDetection = {
kind: "json_tool_call" | "xml_tool_call" | "bracketed_tool_call" | "react_action";
toolName?: string;
};