@agent-assistant/core 0.2.18 → 0.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.js +19 -10
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const DEFAULT_HANDLER_TIMEOUT_MS =
|
|
1
|
+
const DEFAULT_HANDLER_TIMEOUT_MS = 5 * 60_000;
|
|
2
2
|
const DEFAULT_MAX_CONCURRENT_HANDLERS = 10;
|
|
3
|
-
const
|
|
3
|
+
const DRAIN_MARGIN_MS = 5_000;
|
|
4
4
|
export class AssistantDefinitionError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -206,14 +206,23 @@ export function createAssistant(definition, adapters) {
|
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
drainWaiter ??= createDeferred();
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
209
|
+
const drainTimeoutMs = constraints.handlerTimeoutMs + DRAIN_MARGIN_MS;
|
|
210
|
+
let timeoutHandle;
|
|
211
|
+
try {
|
|
212
|
+
await Promise.race([
|
|
213
|
+
drainWaiter.promise,
|
|
214
|
+
new Promise((_, reject) => {
|
|
215
|
+
timeoutHandle = setTimeout(() => {
|
|
216
|
+
reject(new Error(`Timed out waiting ${drainTimeoutMs}ms for in-flight handlers to drain`));
|
|
217
|
+
}, drainTimeoutMs);
|
|
218
|
+
}),
|
|
219
|
+
]);
|
|
220
|
+
}
|
|
221
|
+
finally {
|
|
222
|
+
if (timeoutHandle) {
|
|
223
|
+
clearTimeout(timeoutHandle);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
217
226
|
}
|
|
218
227
|
function runNext() {
|
|
219
228
|
while (lifecycleState === 'started' &&
|