@agentforge/core 0.18.1 → 0.18.3

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.cjs CHANGED
@@ -317,81 +317,64 @@ var MissingDescriptionError = class extends Error {
317
317
  this.name = "MissingDescriptionError";
318
318
  }
319
319
  };
320
- function validateSchemaDescriptions(schema, fieldPath = []) {
320
+ function* findMissingDescriptions(schema, fieldPath = []) {
321
321
  const def = schema._def;
322
322
  const typeName = def.typeName;
323
323
  if (schema instanceof import_zod2.z.ZodObject) {
324
- const shape = schema.shape;
325
- Object.entries(shape).forEach(([key, fieldSchema]) => {
326
- validateSchemaDescriptions(fieldSchema, [...fieldPath, key]);
327
- });
328
- return;
329
- }
330
- if (schema instanceof import_zod2.z.ZodArray) {
331
- validateSchemaDescriptions(def.type, [...fieldPath, "[]"]);
332
- return;
333
- }
334
- if (schema instanceof import_zod2.z.ZodOptional) {
335
- const wrapperDescription = def.description;
336
- const innerDescription = def.innerType._def.description;
337
- if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
338
- throw new MissingDescriptionError(fieldPath, typeName);
339
- }
340
- if (!wrapperDescription) {
341
- validateSchemaDescriptions(def.innerType, fieldPath);
324
+ for (const [key, fieldSchema] of Object.entries(schema.shape)) {
325
+ yield* findMissingDescriptions(fieldSchema, [...fieldPath, key]);
342
326
  }
343
327
  return;
344
328
  }
345
- if (schema instanceof import_zod2.z.ZodNullable) {
346
- const wrapperDescription = def.description;
347
- const innerDescription = def.innerType._def.description;
348
- if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
349
- throw new MissingDescriptionError(fieldPath, typeName);
350
- }
351
- if (!wrapperDescription) {
352
- validateSchemaDescriptions(def.innerType, fieldPath);
353
- }
329
+ if (schema instanceof import_zod2.z.ZodArray) {
330
+ yield* findMissingDescriptions(def.type, [...fieldPath, "[]"]);
354
331
  return;
355
332
  }
356
- if (schema instanceof import_zod2.z.ZodDefault) {
333
+ if (schema instanceof import_zod2.z.ZodOptional || schema instanceof import_zod2.z.ZodNullable || schema instanceof import_zod2.z.ZodDefault) {
357
334
  const wrapperDescription = def.description;
358
335
  const innerDescription = def.innerType._def.description;
359
336
  if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
360
- throw new MissingDescriptionError(fieldPath, typeName);
337
+ yield { fieldPath, fieldType: typeName };
361
338
  }
362
339
  if (!wrapperDescription) {
363
- validateSchemaDescriptions(def.innerType, fieldPath);
340
+ yield* findMissingDescriptions(def.innerType, fieldPath);
364
341
  }
365
342
  return;
366
343
  }
367
344
  if (schema instanceof import_zod2.z.ZodUnion) {
368
- def.options.forEach((option, index) => {
369
- validateSchemaDescriptions(option, [...fieldPath, `option${index}`]);
370
- });
345
+ for (const [index, option] of def.options.entries()) {
346
+ yield* findMissingDescriptions(option, [...fieldPath, `option${index}`]);
347
+ }
371
348
  return;
372
349
  }
373
350
  if (schema instanceof import_zod2.z.ZodIntersection) {
374
- validateSchemaDescriptions(def.left, fieldPath);
375
- validateSchemaDescriptions(def.right, fieldPath);
351
+ yield* findMissingDescriptions(def.left, fieldPath);
352
+ yield* findMissingDescriptions(def.right, fieldPath);
376
353
  return;
377
354
  }
378
355
  if (schema instanceof import_zod2.z.ZodRecord) {
379
- validateSchemaDescriptions(def.valueType, [...fieldPath, "[key]"]);
356
+ yield* findMissingDescriptions(def.valueType, [...fieldPath, "[key]"]);
380
357
  return;
381
358
  }
382
359
  if (schema instanceof import_zod2.z.ZodTuple) {
383
- def.items.forEach((item, index) => {
384
- validateSchemaDescriptions(item, [...fieldPath, `[${index}]`]);
385
- });
360
+ for (const [index, item] of def.items.entries()) {
361
+ yield* findMissingDescriptions(item, [...fieldPath, `[${index}]`]);
362
+ }
386
363
  return;
387
364
  }
388
365
  if (fieldPath.length > 0) {
389
366
  const description = def.description;
390
367
  if (!description || description.trim() === "") {
391
- throw new MissingDescriptionError(fieldPath, typeName);
368
+ yield { fieldPath, fieldType: typeName };
392
369
  }
393
370
  }
394
371
  }
372
+ function validateSchemaDescriptions(schema, fieldPath = []) {
373
+ const firstFinding = findMissingDescriptions(schema, fieldPath).next();
374
+ if (!firstFinding.done) {
375
+ throw new MissingDescriptionError(firstFinding.value.fieldPath, firstFinding.value.fieldType);
376
+ }
377
+ }
395
378
  function safeValidateSchemaDescriptions(schema) {
396
379
  try {
397
380
  validateSchemaDescriptions(schema);
@@ -405,39 +388,14 @@ function safeValidateSchemaDescriptions(schema) {
405
388
  }
406
389
  function getMissingDescriptions(schema) {
407
390
  const missing = [];
408
- function check(s, path = []) {
409
- const def = s._def;
410
- const typeName = def.typeName;
411
- if (s instanceof import_zod2.z.ZodObject) {
412
- const shape = s.shape;
413
- Object.entries(shape).forEach(([key, fieldSchema]) => {
414
- check(fieldSchema, [...path, key]);
415
- });
416
- return;
417
- }
418
- if (s instanceof import_zod2.z.ZodOptional || s instanceof import_zod2.z.ZodNullable || s instanceof import_zod2.z.ZodDefault) {
419
- const wrapperDescription = def.description;
420
- const innerDescription = def.innerType._def.description;
421
- if (path.length > 0 && !wrapperDescription && !innerDescription) {
422
- missing.push(path.join("."));
423
- }
424
- if (!wrapperDescription) {
425
- check(def.innerType, path);
426
- }
427
- return;
428
- }
429
- if (s instanceof import_zod2.z.ZodArray) {
430
- check(def.type, [...path, "[]"]);
431
- return;
432
- }
433
- if (path.length > 0) {
434
- const description = def.description;
435
- if (!description || description.trim() === "") {
436
- missing.push(path.join("."));
437
- }
391
+ const seen = /* @__PURE__ */ new Set();
392
+ for (const finding of findMissingDescriptions(schema)) {
393
+ const path = finding.fieldPath.join(".");
394
+ if (!seen.has(path)) {
395
+ seen.add(path);
396
+ missing.push(path);
438
397
  }
439
398
  }
440
- check(schema);
441
399
  return missing;
442
400
  }
443
401
 
package/dist/index.js CHANGED
@@ -141,81 +141,64 @@ var MissingDescriptionError = class extends Error {
141
141
  this.name = "MissingDescriptionError";
142
142
  }
143
143
  };
144
- function validateSchemaDescriptions(schema, fieldPath = []) {
144
+ function* findMissingDescriptions(schema, fieldPath = []) {
145
145
  const def = schema._def;
146
146
  const typeName = def.typeName;
147
147
  if (schema instanceof z2.ZodObject) {
148
- const shape = schema.shape;
149
- Object.entries(shape).forEach(([key, fieldSchema]) => {
150
- validateSchemaDescriptions(fieldSchema, [...fieldPath, key]);
151
- });
152
- return;
153
- }
154
- if (schema instanceof z2.ZodArray) {
155
- validateSchemaDescriptions(def.type, [...fieldPath, "[]"]);
156
- return;
157
- }
158
- if (schema instanceof z2.ZodOptional) {
159
- const wrapperDescription = def.description;
160
- const innerDescription = def.innerType._def.description;
161
- if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
162
- throw new MissingDescriptionError(fieldPath, typeName);
163
- }
164
- if (!wrapperDescription) {
165
- validateSchemaDescriptions(def.innerType, fieldPath);
148
+ for (const [key, fieldSchema] of Object.entries(schema.shape)) {
149
+ yield* findMissingDescriptions(fieldSchema, [...fieldPath, key]);
166
150
  }
167
151
  return;
168
152
  }
169
- if (schema instanceof z2.ZodNullable) {
170
- const wrapperDescription = def.description;
171
- const innerDescription = def.innerType._def.description;
172
- if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
173
- throw new MissingDescriptionError(fieldPath, typeName);
174
- }
175
- if (!wrapperDescription) {
176
- validateSchemaDescriptions(def.innerType, fieldPath);
177
- }
153
+ if (schema instanceof z2.ZodArray) {
154
+ yield* findMissingDescriptions(def.type, [...fieldPath, "[]"]);
178
155
  return;
179
156
  }
180
- if (schema instanceof z2.ZodDefault) {
157
+ if (schema instanceof z2.ZodOptional || schema instanceof z2.ZodNullable || schema instanceof z2.ZodDefault) {
181
158
  const wrapperDescription = def.description;
182
159
  const innerDescription = def.innerType._def.description;
183
160
  if (fieldPath.length > 0 && !wrapperDescription && !innerDescription) {
184
- throw new MissingDescriptionError(fieldPath, typeName);
161
+ yield { fieldPath, fieldType: typeName };
185
162
  }
186
163
  if (!wrapperDescription) {
187
- validateSchemaDescriptions(def.innerType, fieldPath);
164
+ yield* findMissingDescriptions(def.innerType, fieldPath);
188
165
  }
189
166
  return;
190
167
  }
191
168
  if (schema instanceof z2.ZodUnion) {
192
- def.options.forEach((option, index) => {
193
- validateSchemaDescriptions(option, [...fieldPath, `option${index}`]);
194
- });
169
+ for (const [index, option] of def.options.entries()) {
170
+ yield* findMissingDescriptions(option, [...fieldPath, `option${index}`]);
171
+ }
195
172
  return;
196
173
  }
197
174
  if (schema instanceof z2.ZodIntersection) {
198
- validateSchemaDescriptions(def.left, fieldPath);
199
- validateSchemaDescriptions(def.right, fieldPath);
175
+ yield* findMissingDescriptions(def.left, fieldPath);
176
+ yield* findMissingDescriptions(def.right, fieldPath);
200
177
  return;
201
178
  }
202
179
  if (schema instanceof z2.ZodRecord) {
203
- validateSchemaDescriptions(def.valueType, [...fieldPath, "[key]"]);
180
+ yield* findMissingDescriptions(def.valueType, [...fieldPath, "[key]"]);
204
181
  return;
205
182
  }
206
183
  if (schema instanceof z2.ZodTuple) {
207
- def.items.forEach((item, index) => {
208
- validateSchemaDescriptions(item, [...fieldPath, `[${index}]`]);
209
- });
184
+ for (const [index, item] of def.items.entries()) {
185
+ yield* findMissingDescriptions(item, [...fieldPath, `[${index}]`]);
186
+ }
210
187
  return;
211
188
  }
212
189
  if (fieldPath.length > 0) {
213
190
  const description = def.description;
214
191
  if (!description || description.trim() === "") {
215
- throw new MissingDescriptionError(fieldPath, typeName);
192
+ yield { fieldPath, fieldType: typeName };
216
193
  }
217
194
  }
218
195
  }
196
+ function validateSchemaDescriptions(schema, fieldPath = []) {
197
+ const firstFinding = findMissingDescriptions(schema, fieldPath).next();
198
+ if (!firstFinding.done) {
199
+ throw new MissingDescriptionError(firstFinding.value.fieldPath, firstFinding.value.fieldType);
200
+ }
201
+ }
219
202
  function safeValidateSchemaDescriptions(schema) {
220
203
  try {
221
204
  validateSchemaDescriptions(schema);
@@ -229,39 +212,14 @@ function safeValidateSchemaDescriptions(schema) {
229
212
  }
230
213
  function getMissingDescriptions(schema) {
231
214
  const missing = [];
232
- function check(s, path = []) {
233
- const def = s._def;
234
- const typeName = def.typeName;
235
- if (s instanceof z2.ZodObject) {
236
- const shape = s.shape;
237
- Object.entries(shape).forEach(([key, fieldSchema]) => {
238
- check(fieldSchema, [...path, key]);
239
- });
240
- return;
241
- }
242
- if (s instanceof z2.ZodOptional || s instanceof z2.ZodNullable || s instanceof z2.ZodDefault) {
243
- const wrapperDescription = def.description;
244
- const innerDescription = def.innerType._def.description;
245
- if (path.length > 0 && !wrapperDescription && !innerDescription) {
246
- missing.push(path.join("."));
247
- }
248
- if (!wrapperDescription) {
249
- check(def.innerType, path);
250
- }
251
- return;
252
- }
253
- if (s instanceof z2.ZodArray) {
254
- check(def.type, [...path, "[]"]);
255
- return;
256
- }
257
- if (path.length > 0) {
258
- const description = def.description;
259
- if (!description || description.trim() === "") {
260
- missing.push(path.join("."));
261
- }
215
+ const seen = /* @__PURE__ */ new Set();
216
+ for (const finding of findMissingDescriptions(schema)) {
217
+ const path = finding.fieldPath.join(".");
218
+ if (!seen.has(path)) {
219
+ seen.add(path);
220
+ missing.push(path);
262
221
  }
263
222
  }
264
- check(schema);
265
223
  return missing;
266
224
  }
267
225
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/core",
3
- "version": "0.18.1",
3
+ "version": "0.18.3",
4
4
  "description": "Production-ready TypeScript agent framework built on LangGraph with orchestration, middleware, and typed abstractions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",