@hiper2d/ai-agents 0.37.0 → 0.38.0

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/index.mjs CHANGED
@@ -2486,8 +2486,20 @@ var AbstractAgent = class {
2486
2486
  * invalidResponseRetries policy. Subclasses implement doAskWithZodSchema/doAskText and
2487
2487
  * must NOT override these.
2488
2488
  */
2489
- async askWithZodSchema(zodSchema, messages) {
2490
- return this.askWithRetries(() => this.doAskWithZodSchema(zodSchema, messages));
2489
+ /**
2490
+ * `reject` is the host's own check on a schema-valid answer: return why it is unusable
2491
+ * (a required field left as an empty string, say) and the answer is treated exactly like
2492
+ * a malformed one: a ModelInvalidResponseError, re-sent under invalidResponseRetries.
2493
+ * It exists because a check written into the zod schema would change the JSON schema
2494
+ * the provider sees.
2495
+ */
2496
+ async askWithZodSchema(zodSchema, messages, reject) {
2497
+ return this.askWithRetries(async () => {
2498
+ const result = await this.doAskWithZodSchema(zodSchema, messages);
2499
+ const reason = reject?.(result[0]);
2500
+ if (reason) throw new ModelInvalidResponseError(this.model, reason);
2501
+ return result;
2502
+ });
2491
2503
  }
2492
2504
  async askText(messages) {
2493
2505
  return this.askWithRetries(() => this.doAskText(messages));