ai 5.0.290 → 5.0.291
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/CHANGELOG.md +9 -0
- package/dist/index.js +113 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +113 -43
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -758,7 +758,7 @@ import {
|
|
|
758
758
|
} from "@ai-sdk/provider-utils";
|
|
759
759
|
|
|
760
760
|
// src/version.ts
|
|
761
|
-
var VERSION = true ? "5.0.
|
|
761
|
+
var VERSION = true ? "5.0.291" : "0.0.0-test";
|
|
762
762
|
|
|
763
763
|
// src/util/download/download.ts
|
|
764
764
|
var download = async ({
|
|
@@ -10816,57 +10816,127 @@ import {
|
|
|
10816
10816
|
zodSchema as zodSchema2
|
|
10817
10817
|
} from "@ai-sdk/provider-utils";
|
|
10818
10818
|
import { z as z8 } from "zod/v4";
|
|
10819
|
-
|
|
10819
|
+
|
|
10820
|
+
// src/util/normalize-json-value.ts
|
|
10821
|
+
var invalid = Symbol("invalid");
|
|
10822
|
+
function normalizeJsonValue(value) {
|
|
10823
|
+
const path = [];
|
|
10824
|
+
const normalized = normalize(value, path, /* @__PURE__ */ new Set());
|
|
10825
|
+
return normalized === invalid ? { success: false, path } : { success: true, value: normalized };
|
|
10826
|
+
}
|
|
10827
|
+
function normalize(value, path, ancestors) {
|
|
10820
10828
|
switch (typeof value) {
|
|
10829
|
+
case "string":
|
|
10830
|
+
case "boolean":
|
|
10831
|
+
return value;
|
|
10821
10832
|
case "number":
|
|
10822
|
-
return Number.isFinite(value) ?
|
|
10823
|
-
case "bigint":
|
|
10824
|
-
case "symbol":
|
|
10825
|
-
case "function":
|
|
10826
|
-
return [...path];
|
|
10833
|
+
return Number.isFinite(value) ? value : invalid;
|
|
10827
10834
|
case "object": {
|
|
10828
|
-
if (value === null
|
|
10829
|
-
return
|
|
10830
|
-
|
|
10831
|
-
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
|
|
10835
|
-
|
|
10836
|
-
path.push(key);
|
|
10837
|
-
const invalidPath = findInvalidJsonValuePath(
|
|
10838
|
-
value[key],
|
|
10839
|
-
path,
|
|
10840
|
-
visited
|
|
10841
|
-
);
|
|
10842
|
-
if (invalidPath != null)
|
|
10843
|
-
return invalidPath;
|
|
10844
|
-
path.pop();
|
|
10845
|
-
}
|
|
10846
|
-
return void 0;
|
|
10835
|
+
if (value === null)
|
|
10836
|
+
return value;
|
|
10837
|
+
if (ancestors.has(value))
|
|
10838
|
+
return invalid;
|
|
10839
|
+
ancestors.add(value);
|
|
10840
|
+
const normalized = Array.isArray(value) ? normalizeArray(value, path, ancestors) : normalizeObject(value, path, ancestors);
|
|
10841
|
+
ancestors.delete(value);
|
|
10842
|
+
return normalized;
|
|
10847
10843
|
}
|
|
10848
10844
|
default:
|
|
10849
|
-
return
|
|
10845
|
+
return invalid;
|
|
10846
|
+
}
|
|
10847
|
+
}
|
|
10848
|
+
function normalizeArray(array, path, ancestors) {
|
|
10849
|
+
let copy;
|
|
10850
|
+
for (let index = 0; index < array.length; index++) {
|
|
10851
|
+
const element = array[index];
|
|
10852
|
+
path.push(index);
|
|
10853
|
+
const normalized = normalize(element, path, ancestors);
|
|
10854
|
+
if (normalized === invalid)
|
|
10855
|
+
return invalid;
|
|
10856
|
+
path.pop();
|
|
10857
|
+
if (copy != null) {
|
|
10858
|
+
copy.push(normalized);
|
|
10859
|
+
} else if (normalized !== element) {
|
|
10860
|
+
copy = array.slice(0, index);
|
|
10861
|
+
copy.push(normalized);
|
|
10862
|
+
}
|
|
10863
|
+
}
|
|
10864
|
+
return copy != null ? copy : array;
|
|
10865
|
+
}
|
|
10866
|
+
function normalizeObject(object2, path, ancestors) {
|
|
10867
|
+
if (!isPlainObject(object2) || hasEnumerableSymbolKey(object2))
|
|
10868
|
+
return invalid;
|
|
10869
|
+
const keys = Object.keys(object2);
|
|
10870
|
+
let copy;
|
|
10871
|
+
for (let index = 0; index < keys.length; index++) {
|
|
10872
|
+
const key = keys[index];
|
|
10873
|
+
if (key === "__proto__") {
|
|
10874
|
+
copy != null ? copy : copy = copyProperties(object2, keys, index);
|
|
10875
|
+
continue;
|
|
10876
|
+
}
|
|
10877
|
+
const property = object2[key];
|
|
10878
|
+
let normalized = property;
|
|
10879
|
+
if (property !== void 0) {
|
|
10880
|
+
path.push(key);
|
|
10881
|
+
normalized = normalize(property, path, ancestors);
|
|
10882
|
+
if (normalized === invalid)
|
|
10883
|
+
return invalid;
|
|
10884
|
+
path.pop();
|
|
10885
|
+
}
|
|
10886
|
+
if (copy != null) {
|
|
10887
|
+
copy[key] = normalized;
|
|
10888
|
+
} else if (normalized !== property) {
|
|
10889
|
+
copy = copyProperties(object2, keys, index);
|
|
10890
|
+
copy[key] = normalized;
|
|
10891
|
+
}
|
|
10850
10892
|
}
|
|
10893
|
+
return copy != null ? copy : object2;
|
|
10851
10894
|
}
|
|
10852
|
-
function
|
|
10853
|
-
|
|
10854
|
-
|
|
10855
|
-
|
|
10856
|
-
|
|
10857
|
-
|
|
10858
|
-
|
|
10859
|
-
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10864
|
-
|
|
10865
|
-
|
|
10895
|
+
function copyProperties(object2, keys, count) {
|
|
10896
|
+
const copy = {};
|
|
10897
|
+
for (let index = 0; index < count; index++) {
|
|
10898
|
+
copy[keys[index]] = object2[keys[index]];
|
|
10899
|
+
}
|
|
10900
|
+
return copy;
|
|
10901
|
+
}
|
|
10902
|
+
function isPlainObject(object2) {
|
|
10903
|
+
const constructor = object2.constructor;
|
|
10904
|
+
if (typeof constructor !== "function")
|
|
10905
|
+
return true;
|
|
10906
|
+
const prototype = constructor.prototype;
|
|
10907
|
+
return prototype !== null && typeof prototype === "object" && Object.prototype.hasOwnProperty.call(prototype, "isPrototypeOf");
|
|
10908
|
+
}
|
|
10909
|
+
function hasEnumerableSymbolKey(object2) {
|
|
10910
|
+
const symbols = Object.getOwnPropertySymbols(object2);
|
|
10911
|
+
for (let index = 0; index < symbols.length; index++) {
|
|
10912
|
+
if (Object.prototype.propertyIsEnumerable.call(object2, symbols[index])) {
|
|
10913
|
+
return true;
|
|
10866
10914
|
}
|
|
10867
|
-
}
|
|
10915
|
+
}
|
|
10916
|
+
return false;
|
|
10868
10917
|
}
|
|
10869
|
-
|
|
10918
|
+
|
|
10919
|
+
// src/ui/validate-ui-messages.ts
|
|
10920
|
+
var jsonValueSchema2 = z8.unknown().transform((value, context) => {
|
|
10921
|
+
const result = normalizeJsonValue(value);
|
|
10922
|
+
if (!result.success) {
|
|
10923
|
+
context.issues.push({
|
|
10924
|
+
code: "custom",
|
|
10925
|
+
message: "Invalid JSON value. Expected null, a string, a finite number, a boolean, an array, or an object.",
|
|
10926
|
+
input: value,
|
|
10927
|
+
path: result.path
|
|
10928
|
+
});
|
|
10929
|
+
return z8.NEVER;
|
|
10930
|
+
}
|
|
10931
|
+
return result.value;
|
|
10932
|
+
});
|
|
10933
|
+
var validatedJsonValueSchema = z8.custom(
|
|
10934
|
+
(value) => value !== void 0,
|
|
10935
|
+
{ message: "Invalid JSON value. Expected a defined value." }
|
|
10936
|
+
);
|
|
10937
|
+
var providerMetadataSchema2 = jsonValueSchema2.pipe(
|
|
10938
|
+
z8.record(z8.string(), z8.record(z8.string(), validatedJsonValueSchema))
|
|
10939
|
+
);
|
|
10870
10940
|
function isEmptyObject(value) {
|
|
10871
10941
|
return value != null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0;
|
|
10872
10942
|
}
|