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>
174 lines
5.0 KiB
JavaScript
174 lines
5.0 KiB
JavaScript
import { isFunction } from './util/isFunction';
|
|
import { isSubscription, Subscription } from './Subscription';
|
|
import { config } from './config';
|
|
import { reportUnhandledError } from './util/reportUnhandledError';
|
|
import { noop } from './util/noop';
|
|
import { nextNotification, errorNotification, COMPLETE_NOTIFICATION } from './NotificationFactories';
|
|
import { timeoutProvider } from './scheduler/timeoutProvider';
|
|
import { captureError } from './util/errorContext';
|
|
export class Subscriber extends Subscription {
|
|
constructor(destination) {
|
|
super();
|
|
this.isStopped = false;
|
|
if (destination) {
|
|
this.destination = destination;
|
|
if (isSubscription(destination)) {
|
|
destination.add(this);
|
|
}
|
|
}
|
|
else {
|
|
this.destination = EMPTY_OBSERVER;
|
|
}
|
|
}
|
|
static create(next, error, complete) {
|
|
return new SafeSubscriber(next, error, complete);
|
|
}
|
|
next(value) {
|
|
if (this.isStopped) {
|
|
handleStoppedNotification(nextNotification(value), this);
|
|
}
|
|
else {
|
|
this._next(value);
|
|
}
|
|
}
|
|
error(err) {
|
|
if (this.isStopped) {
|
|
handleStoppedNotification(errorNotification(err), this);
|
|
}
|
|
else {
|
|
this.isStopped = true;
|
|
this._error(err);
|
|
}
|
|
}
|
|
complete() {
|
|
if (this.isStopped) {
|
|
handleStoppedNotification(COMPLETE_NOTIFICATION, this);
|
|
}
|
|
else {
|
|
this.isStopped = true;
|
|
this._complete();
|
|
}
|
|
}
|
|
unsubscribe() {
|
|
if (!this.closed) {
|
|
this.isStopped = true;
|
|
super.unsubscribe();
|
|
this.destination = null;
|
|
}
|
|
}
|
|
_next(value) {
|
|
this.destination.next(value);
|
|
}
|
|
_error(err) {
|
|
try {
|
|
this.destination.error(err);
|
|
}
|
|
finally {
|
|
this.unsubscribe();
|
|
}
|
|
}
|
|
_complete() {
|
|
try {
|
|
this.destination.complete();
|
|
}
|
|
finally {
|
|
this.unsubscribe();
|
|
}
|
|
}
|
|
}
|
|
const _bind = Function.prototype.bind;
|
|
function bind(fn, thisArg) {
|
|
return _bind.call(fn, thisArg);
|
|
}
|
|
class ConsumerObserver {
|
|
constructor(partialObserver) {
|
|
this.partialObserver = partialObserver;
|
|
}
|
|
next(value) {
|
|
const { partialObserver } = this;
|
|
if (partialObserver.next) {
|
|
try {
|
|
partialObserver.next(value);
|
|
}
|
|
catch (error) {
|
|
handleUnhandledError(error);
|
|
}
|
|
}
|
|
}
|
|
error(err) {
|
|
const { partialObserver } = this;
|
|
if (partialObserver.error) {
|
|
try {
|
|
partialObserver.error(err);
|
|
}
|
|
catch (error) {
|
|
handleUnhandledError(error);
|
|
}
|
|
}
|
|
else {
|
|
handleUnhandledError(err);
|
|
}
|
|
}
|
|
complete() {
|
|
const { partialObserver } = this;
|
|
if (partialObserver.complete) {
|
|
try {
|
|
partialObserver.complete();
|
|
}
|
|
catch (error) {
|
|
handleUnhandledError(error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export class SafeSubscriber extends Subscriber {
|
|
constructor(observerOrNext, error, complete) {
|
|
super();
|
|
let partialObserver;
|
|
if (isFunction(observerOrNext) || !observerOrNext) {
|
|
partialObserver = {
|
|
next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
|
|
error: error !== null && error !== void 0 ? error : undefined,
|
|
complete: complete !== null && complete !== void 0 ? complete : undefined,
|
|
};
|
|
}
|
|
else {
|
|
let context;
|
|
if (this && config.useDeprecatedNextContext) {
|
|
context = Object.create(observerOrNext);
|
|
context.unsubscribe = () => this.unsubscribe();
|
|
partialObserver = {
|
|
next: observerOrNext.next && bind(observerOrNext.next, context),
|
|
error: observerOrNext.error && bind(observerOrNext.error, context),
|
|
complete: observerOrNext.complete && bind(observerOrNext.complete, context),
|
|
};
|
|
}
|
|
else {
|
|
partialObserver = observerOrNext;
|
|
}
|
|
}
|
|
this.destination = new ConsumerObserver(partialObserver);
|
|
}
|
|
}
|
|
function handleUnhandledError(error) {
|
|
if (config.useDeprecatedSynchronousErrorHandling) {
|
|
captureError(error);
|
|
}
|
|
else {
|
|
reportUnhandledError(error);
|
|
}
|
|
}
|
|
function defaultErrorHandler(err) {
|
|
throw err;
|
|
}
|
|
function handleStoppedNotification(notification, subscriber) {
|
|
const { onStoppedNotification } = config;
|
|
onStoppedNotification && timeoutProvider.setTimeout(() => onStoppedNotification(notification, subscriber));
|
|
}
|
|
export const EMPTY_OBSERVER = {
|
|
closed: true,
|
|
next: noop,
|
|
error: defaultErrorHandler,
|
|
complete: noop,
|
|
};
|
|
//# sourceMappingURL=Subscriber.js.map
|