@ax-llm/ax 11.0.17 → 11.0.18

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/index.cjs CHANGED
@@ -4537,8 +4537,6 @@ var validateValue = (field, value) => {
4537
4537
  switch (expectedType) {
4538
4538
  case "code":
4539
4539
  return typeof val === "string";
4540
- case "json":
4541
- return typeof val === "object";
4542
4540
  case "string":
4543
4541
  return typeof val === "string";
4544
4542
  case "number":
@@ -4672,7 +4670,9 @@ function mergeDeltas(base, delta) {
4672
4670
  for (const key of Object.keys(delta)) {
4673
4671
  const baseValue = base[key];
4674
4672
  const deltaValue = delta[key];
4675
- if ((baseValue === void 0 || Array.isArray(baseValue)) && Array.isArray(deltaValue)) {
4673
+ if (baseValue === void 0 && Array.isArray(deltaValue)) {
4674
+ base[key] = [...deltaValue];
4675
+ } else if (Array.isArray(baseValue) && Array.isArray(deltaValue)) {
4676
4676
  base[key] = [...baseValue ?? [], ...deltaValue];
4677
4677
  } else if ((baseValue === void 0 || typeof baseValue === "string") && typeof deltaValue === "string") {
4678
4678
  base[key] = (baseValue ?? "") + deltaValue;
@@ -5532,18 +5532,12 @@ function processStreamingDelta(content, xstate) {
5532
5532
  const { name: fieldName, type: fieldType } = xstate.currField ?? {};
5533
5533
  const { isArray: fieldIsArray, name: fieldTypeName } = fieldType ?? {};
5534
5534
  if (!xstate.streamedIndex) {
5535
- xstate.streamedIndex = {};
5535
+ xstate.streamedIndex = { [fieldName]: 0 };
5536
5536
  }
5537
5537
  if (fieldIsArray) {
5538
- if (xstate.streamedIndex[fieldName] === void 0) {
5539
- xstate.streamedIndex[fieldName] = 0;
5540
- }
5541
5538
  return null;
5542
5539
  }
5543
5540
  if (fieldTypeName !== "string" && fieldTypeName !== "code") {
5544
- if (xstate.streamedIndex[fieldName] === void 0) {
5545
- xstate.streamedIndex[fieldName] = 0;
5546
- }
5547
5541
  return null;
5548
5542
  }
5549
5543
  const pos = xstate.streamedIndex[fieldName] ?? 0;
@@ -5582,14 +5576,15 @@ function* streamValues(sig, values, xstate, delta) {
5582
5576
  for (const key of Object.keys(values)) {
5583
5577
  const value = values[key];
5584
5578
  if (Array.isArray(value)) {
5585
- if (xstate.streamedIndex?.[key] === void 0) {
5586
- throw new Error("Streamed index is not set for array field " + key);
5587
- }
5588
- const s = xstate.streamedIndex[key];
5579
+ const s = xstate.streamedIndex?.[key] ?? 0;
5589
5580
  const v = value.slice(s);
5590
5581
  if (v && v.length > 0) {
5591
5582
  yield { [key]: v };
5592
- xstate.streamedIndex[key] = s + 1;
5583
+ if (xstate.streamedIndex) {
5584
+ xstate.streamedIndex[key] = s + 1;
5585
+ } else {
5586
+ xstate.streamedIndex = { [key]: s + 1 };
5587
+ }
5593
5588
  }
5594
5589
  } else {
5595
5590
  yield { [key]: value };