@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
76 lines (75 loc) • 2.38 kB
TypeScript
/**
* Default citation identifier used for simplified citation markers without an explicit position.
*
* @private utility of `<Chat/>`
*/
export declare const DEFAULT_SIMPLIFIED_CITATION_ID = "0:0";
/**
* Parsed citation marker normalized to the full OpenAI-style notation.
*
* @private utility of `<Chat/>`
*/
export type CitationMarker = {
/**
* Citation identifier (for example `7:15`).
*/
id: string;
/**
* Citation source filename or label.
*/
source: string;
/**
* Original marker exactly as found in the content.
*/
raw: string;
/**
* Full normalized marker (`【id†source】`).
*/
normalized: string;
};
/**
* Creates a global regular expression that matches citation markers wrapped in `【...】`.
*
* @private utility of `<Chat/>`
*/
export declare function createCitationMarkerRegex(): RegExp;
/**
* Parses one citation marker and normalizes it to full notation.
*
* @param rawMarker - Marker including outer brackets.
* @returns Parsed marker or `null` when the marker is invalid.
*
* @private utility of `<Chat/>`
*/
export declare function parseCitationMarker(rawMarker: string): CitationMarker | null;
/**
* Parses all citation markers from content and normalizes each to full notation.
*
* @param content - Content that may contain citation markers.
* @returns Parsed citation markers in their original order.
*
* @private utility of `<Chat/>`
*/
export declare function parseCitationMarkersFromContent(content: string): CitationMarker[];
/**
* Replaces all citation markers in content using normalized marker metadata.
*
* @param content - Content that may contain citation markers.
* @param replacer - Replacement callback for each valid marker.
* @returns Content with citation markers replaced.
*
* @private utility of `<Chat/>`
*/
export declare function replaceCitationMarkers(content: string, replacer: (marker: CitationMarker) => string): string;
/**
* Normalizes simplified citation markers to full notation.
*
* Example:
* - `【document.pdf】` -> `【0:0†document.pdf】`
*
* @param content - Content that may contain simplified markers.
* @returns Content where every citation marker is in full notation.
*
* @private utility of `<Chat/>`
*/
export declare function normalizeCitationMarkersToFullNotation(content: string): string;