tftsr-devops_investigation/node_modules/@wdio/repl/build/index.js
Shaun Arman 8839075805 feat: initial implementation of TFTSR IT Triage & RCA application
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>
2026-03-14 22:36:25 -05:00

109 lines
2.8 KiB
JavaScript

// src/index.ts
import vm from "node:vm";
import repl from "node:repl";
// src/constants.ts
var STATIC_RETURNS = {
driver: "[WebdriverIO REPL client]",
browser: "[WebdriverIO REPL client]",
$: "[Function: findElement]",
$$: "[Function: findElements]"
};
var INTRO_MESSAGE = `
The execution has stopped!
You can now go into the browser or use the command line as REPL
(To exit, press ^C again or type .exit)
`;
var DEFAULT_CONFIG = {
commandTimeout: 5e3,
prompt: "\u203A ",
useGlobal: true,
useColor: true
};
// src/index.ts
var WDIORepl = class {
static introMessage = INTRO_MESSAGE;
_config;
_isCommandRunning = false;
_replServer;
constructor(config) {
this._config = Object.assign(
DEFAULT_CONFIG,
{ eval: this.eval.bind(this) },
config
);
}
eval(cmd, context, filename, callback) {
if (this._isCommandRunning) {
return;
}
if (cmd && STATIC_RETURNS[cmd.trim()]) {
return callback(null, STATIC_RETURNS[cmd.trim()]);
}
vm.createContext(context);
this._isCommandRunning = true;
return this._runCmd(cmd, context, callback);
}
_runCmd(cmd, context, callback) {
try {
const result = vm.runInContext(cmd, context);
return this._handleResult(result, callback);
} catch (e) {
this._isCommandRunning = false;
return callback(e, void 0);
}
}
_handleResult(result, callback) {
if (!result || typeof result.then !== "function") {
this._isCommandRunning = false;
return callback(null, result);
}
let timeoutCalled = false;
const timeout = setTimeout(
() => {
callback(new Error("Command execution timed out"), void 0);
this._isCommandRunning = false;
timeoutCalled = true;
},
this._config.commandTimeout
);
result.then((res) => {
if (timeoutCalled) {
return;
}
this._isCommandRunning = false;
clearTimeout(timeout);
return callback(null, res);
}, (e) => {
if (timeoutCalled) {
return;
}
this._isCommandRunning = false;
clearTimeout(timeout);
const errorMessage = e ? e.message : "Command execution timed out";
const commandError = new Error(errorMessage);
delete commandError.stack;
return callback(commandError, void 0);
});
}
start(context) {
if (this._replServer) {
throw new Error("a repl was already initialized");
}
if (context) {
const evalFn = this._config.eval;
this._config.eval = function(cmd, _, filename, callback) {
return evalFn.call(this, cmd, context, filename, callback);
};
}
this._replServer = repl.start(this._config);
return new Promise((resolve) => {
return this._replServer.on("exit", resolve);
});
}
};
export {
WDIORepl as default
};