MCPcopy Create free account
hub / github.com/braintrustdata/bash-agent-evals / withTimeout

Function withTimeout

src/agents/bash-agent.ts:64–80  ·  view source on GitHub ↗
(promise: Promise<T>, timeoutMs: number, command: string)

Source from the content-addressed store, hash-verified

62
63// Wrapper that adds timeout to bash commands
64function withTimeout<T>(promise: Promise<T>, timeoutMs: number, command: string): Promise<T> {
65 return new Promise((resolve, reject) => {
66 const timer = setTimeout(() => {
67 reject(new TimeoutError(command, timeoutMs));
68 }, timeoutMs);
69
70 promise
71 .then((result) => {
72 clearTimeout(timer);
73 resolve(result);
74 })
75 .catch((err) => {
76 clearTimeout(timer);
77 reject(err);
78 });
79 });
80}
81
82// Wrapper that adds timeout to just-bash exec calls
83function createTimeoutBash(bash: Bash, timeoutMs: number) {

Callers 1

execFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected