MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / process

Method process

ai/ai.ts:2395–2418  ·  view source on GitHub ↗
(
    input: T,
    next: (input: T, token?: AbortToken) => Promise<any>,
    token?: AbortToken,
  )

Source from the content-addressed store, hash-verified

2393
2394 async process<T>(
2395 input: T,
2396 next: (input: T, token?: AbortToken) => Promise<any>,
2397 token?: AbortToken,
2398 ): Promise<any> {
2399 const config = (await this.configManagerPromise).getConfig();
2400 const timeoutMs = config.timeout * 1000;
2401
2402 const timeoutController = new AbortController();
2403 const timeoutId = setTimeout(
2404 () => timeoutController.abort(`请求超时: ${timeoutMs}ms`),
2405 timeoutMs,
2406 );
2407
2408 try {
2409 const combined = this.combine(timeoutController, token);
2410 combined.signal.addEventListener("abort", () => clearTimeout(timeoutId), {
2411 once: true,
2412 });
2413 return await next(input, combined);
2414 } finally {
2415 clearTimeout(timeoutId);
2416 }
2417 }
2418
2419 private combine(
2420 timeoutController: AbortController,
2421 externalToken?: AbortToken,

Callers

nothing calls this directly

Calls 3

combineMethod · 0.95
abortMethod · 0.65
getConfigMethod · 0.45

Tested by

no test coverage detected