@agent-assistant/core 0.2.20 → 0.2.21
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 +11 -3
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -236,6 +236,14 @@ export function createAssistant(definition, adapters) {
|
|
|
236
236
|
void executeDispatch(nextDispatch);
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
|
+
function reportError(error, message) {
|
|
240
|
+
const userHandler = frozenDefinition.hooks?.onError;
|
|
241
|
+
if (typeof userHandler === 'function') {
|
|
242
|
+
userHandler(error, message);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
console.error(`[${frozenDefinition.id ?? 'agent'}] unhandled capability handler error (capability=${message.capability}, id=${message.id}):`, error);
|
|
246
|
+
}
|
|
239
247
|
async function executeDispatch(dispatchJob) {
|
|
240
248
|
const { message, resolve, reject } = dispatchJob;
|
|
241
249
|
try {
|
|
@@ -246,7 +254,7 @@ export function createAssistant(definition, adapters) {
|
|
|
246
254
|
}
|
|
247
255
|
const handler = capabilityMap.get(message.capability);
|
|
248
256
|
if (!handler) {
|
|
249
|
-
|
|
257
|
+
reportError(new Error(`No capability registered for '${message.capability}'`), message);
|
|
250
258
|
resolve();
|
|
251
259
|
return;
|
|
252
260
|
}
|
|
@@ -262,13 +270,13 @@ export function createAssistant(definition, adapters) {
|
|
|
262
270
|
await withTimeout(handler, message, context, constraints.handlerTimeoutMs);
|
|
263
271
|
}
|
|
264
272
|
catch (error) {
|
|
265
|
-
|
|
273
|
+
reportError(error instanceof Error ? error : new Error(String(error)), message);
|
|
266
274
|
}
|
|
267
275
|
resolve();
|
|
268
276
|
}
|
|
269
277
|
catch (error) {
|
|
270
278
|
const wrappedError = error instanceof Error ? error : new Error(String(error));
|
|
271
|
-
|
|
279
|
+
reportError(wrappedError, message);
|
|
272
280
|
reject(wrappedError);
|
|
273
281
|
}
|
|
274
282
|
finally {
|