Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license

This commit is contained in:
2026-09-05 13:26:46 +03:00
commit 03634b1ca3
11340 changed files with 3442369 additions and 0 deletions
+67
View File
@@ -0,0 +1,67 @@
/** Shared budget for any renderer await that rides out a primary backend
* cold boot (initial getConnection(), the registry restore's descriptor
* wait). Matches the main-process spawn budget
* (DEFAULT_BACKEND_READY_TIMEOUT_MS in electron/backend-health.ts): a
* healthy cold boot publishes well within this; anything longer means the
* backend is not coming and the caller should fail instead of hanging.
* Reconnect-class awaits against an already-spawned backend use the shorter
* RECONNECT_ATTEMPT_TIMEOUT_MS below instead. */
export const BACKEND_BOOT_WAIT_TIMEOUT_MS = 45_000
// desktop.getConnection() / getConnectionFor() / revalidateConnection() /
// resolveGatewayWsUrl() are IPC round-trips into the main process with no
// timeout of their own (#93454). A wedged main-process round-trip (e.g. a
// stuck revalidation after a liveness-probe trip) otherwise hangs an awaiting
// caller forever. Every caller of these bounds them with this shared budget.
export const RECONNECT_ATTEMPT_TIMEOUT_MS = 20_000
/** Rejection raised by withTimeout. The bounded work is NOT cancelled — the
* caller decides what a straggler that settles later means. */
export class TimeoutError extends Error {
constructor(message: string) {
super(message)
this.name = 'TimeoutError'
}
}
export function isTimeoutError(error: unknown): error is TimeoutError {
return error instanceof TimeoutError
}
/** Settle with `promise`, or reject with a TimeoutError after `ms`.
* `onTimeout` runs synchronously before the rejection is published so callers
* can revoke ownership of work that would otherwise keep running unowned. If
* that callback throws, its error becomes this promise's rejection. */
export function withTimeout<T>(
promise: Promise<T>,
ms: number,
message: string,
onTimeout?: (error: TimeoutError) => void
): Promise<T> {
return new Promise<T>((resolve, reject) => {
const timer = setTimeout(() => {
const error = new TimeoutError(message)
try {
onTimeout?.(error)
} catch (onTimeoutError) {
reject(onTimeoutError)
return
}
reject(error)
}, ms)
Promise.resolve(promise).then(
value => {
clearTimeout(timer)
resolve(value)
},
err => {
clearTimeout(timer)
reject(err)
}
)
})
}