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>
89 lines
2.7 KiB
JavaScript
89 lines
2.7 KiB
JavaScript
'use strict';
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = timeout;
|
|
|
|
var _initialParams = require('./internal/initialParams.js');
|
|
|
|
var _initialParams2 = _interopRequireDefault(_initialParams);
|
|
|
|
var _wrapAsync = require('./internal/wrapAsync.js');
|
|
|
|
var _wrapAsync2 = _interopRequireDefault(_wrapAsync);
|
|
|
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
|
|
/**
|
|
* Sets a time limit on an asynchronous function. If the function does not call
|
|
* its callback within the specified milliseconds, it will be called with a
|
|
* timeout error. The code property for the error object will be `'ETIMEDOUT'`.
|
|
*
|
|
* @name timeout
|
|
* @static
|
|
* @memberOf module:Utils
|
|
* @method
|
|
* @category Util
|
|
* @param {AsyncFunction} asyncFn - The async function to limit in time.
|
|
* @param {number} milliseconds - The specified time limit.
|
|
* @param {*} [info] - Any variable you want attached (`string`, `object`, etc)
|
|
* to timeout Error for more information..
|
|
* @returns {AsyncFunction} Returns a wrapped function that can be used with any
|
|
* of the control flow functions.
|
|
* Invoke this function with the same parameters as you would `asyncFunc`.
|
|
* @example
|
|
*
|
|
* function myFunction(foo, callback) {
|
|
* doAsyncTask(foo, function(err, data) {
|
|
* // handle errors
|
|
* if (err) return callback(err);
|
|
*
|
|
* // do some stuff ...
|
|
*
|
|
* // return processed data
|
|
* return callback(null, data);
|
|
* });
|
|
* }
|
|
*
|
|
* var wrapped = async.timeout(myFunction, 1000);
|
|
*
|
|
* // call `wrapped` as you would `myFunction`
|
|
* wrapped({ bar: 'bar' }, function(err, data) {
|
|
* // if `myFunction` takes < 1000 ms to execute, `err`
|
|
* // and `data` will have their expected values
|
|
*
|
|
* // else `err` will be an Error with the code 'ETIMEDOUT'
|
|
* });
|
|
*/
|
|
function timeout(asyncFn, milliseconds, info) {
|
|
var fn = (0, _wrapAsync2.default)(asyncFn);
|
|
|
|
return (0, _initialParams2.default)((args, callback) => {
|
|
var timedOut = false;
|
|
var timer;
|
|
|
|
function timeoutCallback() {
|
|
var name = asyncFn.name || 'anonymous';
|
|
var error = new Error('Callback function "' + name + '" timed out.');
|
|
error.code = 'ETIMEDOUT';
|
|
if (info) {
|
|
error.info = info;
|
|
}
|
|
timedOut = true;
|
|
callback(error);
|
|
}
|
|
|
|
args.push((...cbArgs) => {
|
|
if (!timedOut) {
|
|
callback(...cbArgs);
|
|
clearTimeout(timer);
|
|
}
|
|
});
|
|
|
|
// setup timer and call original function
|
|
timer = setTimeout(timeoutCallback, milliseconds);
|
|
fn(...args);
|
|
});
|
|
}
|
|
module.exports = exports.default; |