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>
146 lines
4.7 KiB
TypeScript
146 lines
4.7 KiB
TypeScript
declare global {
|
|
interface Window {
|
|
__TAURI_EVENT_PLUGIN_INTERNALS__: {
|
|
unregisterListener: (event: string, eventId: number) => void;
|
|
};
|
|
}
|
|
}
|
|
type EventTarget = {
|
|
kind: 'Any';
|
|
} | {
|
|
kind: 'AnyLabel';
|
|
label: string;
|
|
} | {
|
|
kind: 'App';
|
|
} | {
|
|
kind: 'Window';
|
|
label: string;
|
|
} | {
|
|
kind: 'Webview';
|
|
label: string;
|
|
} | {
|
|
kind: 'WebviewWindow';
|
|
label: string;
|
|
};
|
|
interface Event<T> {
|
|
/** Event name */
|
|
event: EventName;
|
|
/** Event identifier used to unlisten */
|
|
id: number;
|
|
/** Event payload */
|
|
payload: T;
|
|
}
|
|
type EventCallback<T> = (event: Event<T>) => void;
|
|
type UnlistenFn = () => void;
|
|
type EventName = `${TauriEvent}` | (string & Record<never, never>);
|
|
interface Options {
|
|
/**
|
|
* The event target to listen to, defaults to `{ kind: 'Any' }`, see {@link EventTarget}.
|
|
*
|
|
* If a string is provided, {@link EventTarget.AnyLabel} is used.
|
|
*/
|
|
target?: string | EventTarget;
|
|
}
|
|
/**
|
|
* @since 1.1.0
|
|
*/
|
|
declare enum TauriEvent {
|
|
WINDOW_RESIZED = "tauri://resize",
|
|
WINDOW_MOVED = "tauri://move",
|
|
WINDOW_CLOSE_REQUESTED = "tauri://close-requested",
|
|
WINDOW_DESTROYED = "tauri://destroyed",
|
|
WINDOW_FOCUS = "tauri://focus",
|
|
WINDOW_BLUR = "tauri://blur",
|
|
WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change",
|
|
WINDOW_THEME_CHANGED = "tauri://theme-changed",
|
|
WINDOW_CREATED = "tauri://window-created",
|
|
WEBVIEW_CREATED = "tauri://webview-created",
|
|
DRAG_ENTER = "tauri://drag-enter",
|
|
DRAG_OVER = "tauri://drag-over",
|
|
DRAG_DROP = "tauri://drag-drop",
|
|
DRAG_LEAVE = "tauri://drag-leave"
|
|
}
|
|
/**
|
|
* Listen to an emitted event to any {@link EventTarget|target}.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { listen } from '@tauri-apps/api/event';
|
|
* const unlisten = await listen<string>('error', (event) => {
|
|
* console.log(`Got error, payload: ${event.payload}`);
|
|
* });
|
|
*
|
|
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
* unlisten();
|
|
* ```
|
|
*
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
* @param handler Event handler callback.
|
|
* @param options Event listening options.
|
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
declare function listen<T>(event: EventName, handler: EventCallback<T>, options?: Options): Promise<UnlistenFn>;
|
|
/**
|
|
* Listens once to an emitted event to any {@link EventTarget|target}.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { once } from '@tauri-apps/api/event';
|
|
* interface LoadedPayload {
|
|
* loggedIn: boolean,
|
|
* token: string
|
|
* }
|
|
* const unlisten = await once<LoadedPayload>('loaded', (event) => {
|
|
* console.log(`App is loaded, loggedIn: ${event.payload.loggedIn}, token: ${event.payload.token}`);
|
|
* });
|
|
*
|
|
* // you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
|
|
* unlisten();
|
|
* ```
|
|
*
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
* @param handler Event handler callback.
|
|
* @param options Event listening options.
|
|
* @returns A promise resolving to a function to unlisten to the event.
|
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
declare function once<T>(event: EventName, handler: EventCallback<T>, options?: Options): Promise<UnlistenFn>;
|
|
/**
|
|
* Emits an event to all {@link EventTarget|targets}.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { emit } from '@tauri-apps/api/event';
|
|
* await emit('frontend-loaded', { loggedIn: true, token: 'authToken' });
|
|
* ```
|
|
*
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
* @param payload Event payload.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
declare function emit<T>(event: string, payload?: T): Promise<void>;
|
|
/**
|
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* import { emitTo } from '@tauri-apps/api/event';
|
|
* await emitTo('main', 'frontend-loaded', { loggedIn: true, token: 'authToken' });
|
|
* ```
|
|
*
|
|
* @param target Label of the target Window/Webview/WebviewWindow or raw {@link EventTarget} object.
|
|
* @param event Event name. Must include only alphanumeric characters, `-`, `/`, `:` and `_`.
|
|
* @param payload Event payload.
|
|
*
|
|
* @since 2.0.0
|
|
*/
|
|
declare function emitTo<T>(target: EventTarget | string, event: string, payload?: T): Promise<void>;
|
|
export type { Event, EventTarget, EventCallback, UnlistenFn, EventName, Options };
|
|
export { listen, once, emit, emitTo, TauriEvent };
|