Implements Phases 1-8 of the TFTSR implementation plan. Rust backend (Tauri 2.x, src-tauri/): - Multi-provider AI: OpenAI-compatible, Anthropic, Gemini, Mistral, Ollama - PII detection engine: 11 regex patterns with overlap resolution - SQLCipher AES-256 encrypted database with 10 versioned migrations - 28 Tauri IPC commands for triage, analysis, document, and system ops - Ollama: hardware probe, model recommendations, pull/delete with events - RCA and blameless post-mortem Markdown document generators - PDF export via printpdf - Audit log: SHA-256 hash of every external data send - Integration stubs for Confluence, ServiceNow, Azure DevOps (v0.2) Frontend (React 18 + TypeScript + Vite, src/): - 9 pages: full triage workflow NewIssue→LogUpload→Triage→Resolution→RCA→Postmortem→History+Settings - 7 components: ChatWindow, TriageProgress, PiiDiffViewer, DocEditor, HardwareReport, ModelSelector, UI primitives - 3 Zustand stores: session, settings (persisted), history - Type-safe tauriCommands.ts matching Rust backend types exactly - 8 IT domain system prompts (Linux, Windows, Network, K8s, DB, Virt, HW, Obs) DevOps: - .woodpecker/test.yml: rustfmt, clippy, cargo test, tsc, vitest on every push - .woodpecker/release.yml: linux/amd64 + linux/arm64 builds, Gogs release upload Verified: - cargo check: zero errors - tsc --noEmit: zero errors - vitest run: 13/13 unit tests passing Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
126 lines
4.5 KiB
TypeScript
126 lines
4.5 KiB
TypeScript
export declare enum QuoteType {
|
|
NoValue = 0,
|
|
Unquoted = 1,
|
|
Single = 2,
|
|
Double = 3
|
|
}
|
|
export interface Callbacks {
|
|
onattribdata(start: number, endIndex: number): void;
|
|
onattribentity(codepoint: number): void;
|
|
onattribend(quote: QuoteType, endIndex: number): void;
|
|
onattribname(start: number, endIndex: number): void;
|
|
oncdata(start: number, endIndex: number, endOffset: number): void;
|
|
onclosetag(start: number, endIndex: number): void;
|
|
oncomment(start: number, endIndex: number, endOffset: number): void;
|
|
ondeclaration(start: number, endIndex: number): void;
|
|
onend(): void;
|
|
onopentagend(endIndex: number): void;
|
|
onopentagname(start: number, endIndex: number): void;
|
|
onprocessinginstruction(start: number, endIndex: number): void;
|
|
onselfclosingtag(endIndex: number): void;
|
|
ontext(start: number, endIndex: number): void;
|
|
ontextentity(codepoint: number, endIndex: number): void;
|
|
}
|
|
export default class Tokenizer {
|
|
private readonly cbs;
|
|
/** The current state the tokenizer is in. */
|
|
private state;
|
|
/** The read buffer. */
|
|
private buffer;
|
|
/** The beginning of the section that is currently being read. */
|
|
private sectionStart;
|
|
/** The index within the buffer that we are currently looking at. */
|
|
private index;
|
|
/** The start of the last entity. */
|
|
private entityStart;
|
|
/** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
|
|
private baseState;
|
|
/** For special parsing behavior inside of script and style tags. */
|
|
private isSpecial;
|
|
/** Indicates whether the tokenizer has been paused. */
|
|
running: boolean;
|
|
/** The offset of the current buffer. */
|
|
private offset;
|
|
private readonly xmlMode;
|
|
private readonly decodeEntities;
|
|
private readonly entityDecoder;
|
|
constructor({ xmlMode, decodeEntities, }: {
|
|
xmlMode?: boolean;
|
|
decodeEntities?: boolean;
|
|
}, cbs: Callbacks);
|
|
reset(): void;
|
|
write(chunk: string): void;
|
|
end(): void;
|
|
pause(): void;
|
|
resume(): void;
|
|
private stateText;
|
|
private currentSequence;
|
|
private sequenceIndex;
|
|
private stateSpecialStartSequence;
|
|
/** Look for an end tag. For <title> tags, also decode entities. */
|
|
private stateInSpecialTag;
|
|
private stateCDATASequence;
|
|
/**
|
|
* When we wait for one specific character, we can speed things up
|
|
* by skipping through the buffer until we find it.
|
|
*
|
|
* @returns Whether the character was found.
|
|
*/
|
|
private fastForwardTo;
|
|
/**
|
|
* Comments and CDATA end with `-->` and `]]>`.
|
|
*
|
|
* Their common qualities are:
|
|
* - Their end sequences have a distinct character they start with.
|
|
* - That character is then repeated, so we have to check multiple repeats.
|
|
* - All characters but the start character of the sequence can be skipped.
|
|
*/
|
|
private stateInCommentLike;
|
|
/**
|
|
* HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
|
|
*
|
|
* XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
|
|
* We allow anything that wouldn't end the tag.
|
|
*/
|
|
private isTagStartChar;
|
|
private startSpecial;
|
|
private stateBeforeTagName;
|
|
private stateInTagName;
|
|
private stateBeforeClosingTagName;
|
|
private stateInClosingTagName;
|
|
private stateAfterClosingTagName;
|
|
private stateBeforeAttributeName;
|
|
private stateInSelfClosingTag;
|
|
private stateInAttributeName;
|
|
private stateAfterAttributeName;
|
|
private stateBeforeAttributeValue;
|
|
private handleInAttributeValue;
|
|
private stateInAttributeValueDoubleQuotes;
|
|
private stateInAttributeValueSingleQuotes;
|
|
private stateInAttributeValueNoQuotes;
|
|
private stateBeforeDeclaration;
|
|
private stateInDeclaration;
|
|
private stateInProcessingInstruction;
|
|
private stateBeforeComment;
|
|
private stateInSpecialComment;
|
|
private stateBeforeSpecialS;
|
|
private stateBeforeSpecialT;
|
|
private startEntity;
|
|
private stateInEntity;
|
|
/**
|
|
* Remove data that has already been consumed from the buffer.
|
|
*/
|
|
private cleanup;
|
|
private shouldContinue;
|
|
/**
|
|
* Iterates through the buffer, calling the function corresponding to the current state.
|
|
*
|
|
* States that are more likely to be hit are higher up, as a performance improvement.
|
|
*/
|
|
private parse;
|
|
private finish;
|
|
/** Handle any trailing data. */
|
|
private handleTrailingData;
|
|
private emitCodePoint;
|
|
}
|
|
//# sourceMappingURL=Tokenizer.d.ts.map
|