@mastra/server 0.20.2 → 0.21.0-alpha.1
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 +27 -0
- package/dist/{chunk-XVPBGW6Y.cjs → chunk-3LGGSMCC.cjs} +9 -9
- package/dist/{chunk-XVPBGW6Y.cjs.map → chunk-3LGGSMCC.cjs.map} +1 -1
- package/dist/{chunk-YJU744I4.cjs → chunk-3LTO44EP.cjs} +5 -3
- package/dist/chunk-3LTO44EP.cjs.map +1 -0
- package/dist/{chunk-OYL5TBJW.cjs → chunk-6BMOC6SA.cjs} +4 -4
- package/dist/{chunk-OYL5TBJW.cjs.map → chunk-6BMOC6SA.cjs.map} +1 -1
- package/dist/{chunk-3Q7FKRVX.cjs → chunk-BZLZFHAT.cjs} +2 -2
- package/dist/{chunk-3Q7FKRVX.cjs.map → chunk-BZLZFHAT.cjs.map} +1 -1
- package/dist/{chunk-HKW2536J.js → chunk-DTBJ3D22.js} +2509 -506
- package/dist/{chunk-HKW2536J.js.map → chunk-DTBJ3D22.js.map} +1 -1
- package/dist/{chunk-FZNS32WJ.js → chunk-H2CO44WB.js} +4 -4
- package/dist/{chunk-FZNS32WJ.js.map → chunk-H2CO44WB.js.map} +1 -1
- package/dist/{chunk-LV66LYKV.js → chunk-JSLAYFEW.js} +2 -2
- package/dist/{chunk-LV66LYKV.js.map → chunk-JSLAYFEW.js.map} +1 -1
- package/dist/{chunk-SIW6CYO3.js → chunk-KQZPT7AO.js} +7 -7
- package/dist/{chunk-SIW6CYO3.js.map → chunk-KQZPT7AO.js.map} +1 -1
- package/dist/{chunk-WHABYJRY.js → chunk-OEOGYAQC.js} +5 -3
- package/dist/chunk-OEOGYAQC.js.map +1 -0
- package/dist/{chunk-KJJA7GPJ.cjs → chunk-SBWOUCO3.cjs} +2957 -954
- package/dist/chunk-SBWOUCO3.cjs.map +1 -0
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.d.ts.map +1 -1
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/agents.cjs +19 -19
- package/dist/server/handlers/agents.d.ts +2 -2
- package/dist/server/handlers/agents.d.ts.map +1 -1
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/memory.cjs +16 -16
- package/dist/server/handlers/memory.d.ts +3 -2
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers.cjs +6 -6
- package/dist/server/handlers.js +3 -3
- package/dist/{token-WAEKDUVY.js → token-352SFL4N.js} +8 -8
- package/dist/{token-WAEKDUVY.js.map → token-352SFL4N.js.map} +1 -1
- package/dist/{token-53CFGXUO.cjs → token-JT637FZG.cjs} +10 -10
- package/dist/{token-53CFGXUO.cjs.map → token-JT637FZG.cjs.map} +1 -1
- package/dist/token-util-75OQWZ4W.js +7 -0
- package/dist/{token-util-LY37VCIN.js.map → token-util-75OQWZ4W.js.map} +1 -1
- package/dist/token-util-WGALAXWM.cjs +9 -0
- package/dist/{token-util-S4A355II.cjs.map → token-util-WGALAXWM.cjs.map} +1 -1
- package/package.json +6 -6
- package/dist/chunk-KJJA7GPJ.cjs.map +0 -1
- package/dist/chunk-WHABYJRY.js.map +0 -1
- package/dist/chunk-YJU744I4.cjs.map +0 -1
- package/dist/token-util-LY37VCIN.js +0 -7
- package/dist/token-util-S4A355II.cjs +0 -9
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { getWorkflowByIdHandler, getWorkflowRunByIdHandler, getWorkflowRunExecutionResultHandler, createWorkflowRunHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler, streamWorkflowHandler, streamVNextWorkflowHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, getWorkflowRunsHandler, cancelWorkflowRunHandler, sendWorkflowRunEventHandler } from './chunk-DB63UMTV.js';
|
|
2
|
-
import { require_token_error } from './chunk-
|
|
2
|
+
import { require_token_error } from './chunk-H2CO44WB.js';
|
|
3
3
|
import { openai } from './chunk-ZULZ2752.js';
|
|
4
4
|
import { createIdGenerator, AISDKError, isAbortError, getErrorMessage, APICallError, delay, safeParseJSON, safeValidateTypes, convertAsyncIteratorToReadableStream, validatorSymbol } from './chunk-RQK4FQUD.js';
|
|
5
5
|
import { WorkflowRegistry, getWorkflowInfo } from './chunk-YWOK4F5A.js';
|
|
6
6
|
import { handleError } from './chunk-CY4TP3FK.js';
|
|
7
7
|
import { HTTPException } from './chunk-MMROOK5J.js';
|
|
8
8
|
import { __commonJS, __export, __toESM } from './chunk-PR4QN5HX.js';
|
|
9
|
-
import { Agent, MessageList } from '@mastra/core/agent';
|
|
9
|
+
import { Agent, tryGenerateWithJsonFallback, tryStreamWithJsonFallback, MessageList } from '@mastra/core/agent';
|
|
10
10
|
import { MastraMemory, MemoryProcessor } from '@mastra/core/memory';
|
|
11
11
|
import { generateEmptyFromSchema } from '@mastra/core/utils';
|
|
12
12
|
import { z, ZodObject, ZodFirstPartyTypeKind } from 'zod';
|
|
13
|
-
import * as
|
|
13
|
+
import * as z104 from 'zod/v4';
|
|
14
14
|
import { z as z$1 } from 'zod/v4';
|
|
15
15
|
import { ZodFirstPartyTypeKind as ZodFirstPartyTypeKind$1 } from 'zod/v3';
|
|
16
16
|
import { createTool } from '@mastra/core/tools';
|
|
@@ -24,28 +24,28 @@ import { ModelRouterLanguageModel } from '@mastra/core/llm';
|
|
|
24
24
|
import { tmpdir } from 'os';
|
|
25
25
|
import { createStep, createWorkflow } from '@mastra/core/workflows';
|
|
26
26
|
|
|
27
|
-
// ../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
27
|
+
// ../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/get-context.js
|
|
28
28
|
var require_get_context = __commonJS({
|
|
29
|
-
"../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
30
|
-
var
|
|
29
|
+
"../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/get-context.js"(exports, module) {
|
|
30
|
+
var __defProp5 = Object.defineProperty;
|
|
31
31
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
32
32
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
33
33
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
34
|
-
var
|
|
35
|
-
for (var
|
|
36
|
-
|
|
34
|
+
var __export5 = (target, all) => {
|
|
35
|
+
for (var name21 in all)
|
|
36
|
+
__defProp5(target, name21, { get: all[name21], enumerable: true });
|
|
37
37
|
};
|
|
38
38
|
var __copyProps = (to, from, except, desc) => {
|
|
39
39
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
40
40
|
for (let key of __getOwnPropNames(from))
|
|
41
41
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
42
|
-
|
|
42
|
+
__defProp5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
43
43
|
}
|
|
44
44
|
return to;
|
|
45
45
|
};
|
|
46
|
-
var __toCommonJS = (mod) => __copyProps(
|
|
46
|
+
var __toCommonJS = (mod) => __copyProps(__defProp5({}, "__esModule", { value: true }), mod);
|
|
47
47
|
var get_context_exports = {};
|
|
48
|
-
|
|
48
|
+
__export5(get_context_exports, {
|
|
49
49
|
SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
|
|
50
50
|
getContext: () => getContext3
|
|
51
51
|
});
|
|
@@ -58,28 +58,28 @@ var require_get_context = __commonJS({
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
// ../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
61
|
+
// ../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js
|
|
62
62
|
var require_get_vercel_oidc_token = __commonJS({
|
|
63
|
-
"../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
64
|
-
var
|
|
63
|
+
"../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports, module) {
|
|
64
|
+
var __defProp5 = Object.defineProperty;
|
|
65
65
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
66
66
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
67
67
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
68
|
-
var
|
|
69
|
-
for (var
|
|
70
|
-
|
|
68
|
+
var __export5 = (target, all) => {
|
|
69
|
+
for (var name21 in all)
|
|
70
|
+
__defProp5(target, name21, { get: all[name21], enumerable: true });
|
|
71
71
|
};
|
|
72
72
|
var __copyProps = (to, from, except, desc) => {
|
|
73
73
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
74
74
|
for (let key of __getOwnPropNames(from))
|
|
75
75
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
76
|
-
|
|
76
|
+
__defProp5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
77
77
|
}
|
|
78
78
|
return to;
|
|
79
79
|
};
|
|
80
|
-
var __toCommonJS = (mod) => __copyProps(
|
|
80
|
+
var __toCommonJS = (mod) => __copyProps(__defProp5({}, "__esModule", { value: true }), mod);
|
|
81
81
|
var get_vercel_oidc_token_exports = {};
|
|
82
|
-
|
|
82
|
+
__export5(get_vercel_oidc_token_exports, {
|
|
83
83
|
getVercelOidcToken: () => getVercelOidcToken3,
|
|
84
84
|
getVercelOidcTokenSync: () => getVercelOidcTokenSync2
|
|
85
85
|
});
|
|
@@ -96,8 +96,8 @@ var require_get_vercel_oidc_token = __commonJS({
|
|
|
96
96
|
}
|
|
97
97
|
try {
|
|
98
98
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
99
|
-
await import('./token-util-
|
|
100
|
-
await import('./token-
|
|
99
|
+
await import('./token-util-75OQWZ4W.js'),
|
|
100
|
+
await import('./token-352SFL4N.js')
|
|
101
101
|
]);
|
|
102
102
|
if (!token || isExpired(getTokenPayload(token))) {
|
|
103
103
|
await refreshToken();
|
|
@@ -124,28 +124,28 @@ ${error.message}`;
|
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
126
|
|
|
127
|
-
// ../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
127
|
+
// ../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/index.js
|
|
128
128
|
var require_dist = __commonJS({
|
|
129
|
-
"../../node_modules/.pnpm/@vercel+oidc@3.0.
|
|
130
|
-
var
|
|
129
|
+
"../../node_modules/.pnpm/@vercel+oidc@3.0.2/node_modules/@vercel/oidc/dist/index.js"(exports, module) {
|
|
130
|
+
var __defProp5 = Object.defineProperty;
|
|
131
131
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
132
132
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
133
133
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
134
|
-
var
|
|
135
|
-
for (var
|
|
136
|
-
|
|
134
|
+
var __export5 = (target, all) => {
|
|
135
|
+
for (var name21 in all)
|
|
136
|
+
__defProp5(target, name21, { get: all[name21], enumerable: true });
|
|
137
137
|
};
|
|
138
138
|
var __copyProps = (to, from, except, desc) => {
|
|
139
139
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
140
140
|
for (let key of __getOwnPropNames(from))
|
|
141
141
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
142
|
-
|
|
142
|
+
__defProp5(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
143
143
|
}
|
|
144
144
|
return to;
|
|
145
145
|
};
|
|
146
|
-
var __toCommonJS = (mod) => __copyProps(
|
|
146
|
+
var __toCommonJS = (mod) => __copyProps(__defProp5({}, "__esModule", { value: true }), mod);
|
|
147
147
|
var src_exports = {};
|
|
148
|
-
|
|
148
|
+
__export5(src_exports, {
|
|
149
149
|
getContext: () => import_get_context.getContext,
|
|
150
150
|
getVercelOidcToken: () => import_get_vercel_oidc_token.getVercelOidcToken,
|
|
151
151
|
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync
|
|
@@ -279,8 +279,8 @@ var require_ignore = __commonJS({
|
|
|
279
279
|
TMP_KEY_IGNORE = Symbol.for("node-ignore");
|
|
280
280
|
}
|
|
281
281
|
var KEY_IGNORE = TMP_KEY_IGNORE;
|
|
282
|
-
var define = (
|
|
283
|
-
Object.defineProperty(
|
|
282
|
+
var define = (object8, key, value) => {
|
|
283
|
+
Object.defineProperty(object8, key, { value });
|
|
284
284
|
return value;
|
|
285
285
|
};
|
|
286
286
|
var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
|
|
@@ -776,11 +776,11 @@ var getRefs = (options) => {
|
|
|
776
776
|
flags: { hasReferencedOpenAiAnyType: false },
|
|
777
777
|
currentPath,
|
|
778
778
|
propertyPath: void 0,
|
|
779
|
-
seen: new Map(Object.entries(_options.definitions).map(([
|
|
779
|
+
seen: new Map(Object.entries(_options.definitions).map(([name21, def]) => [
|
|
780
780
|
def._def,
|
|
781
781
|
{
|
|
782
782
|
def: def._def,
|
|
783
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
783
|
+
path: [..._options.basePath, _options.definitionPath, name21],
|
|
784
784
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
785
785
|
jsonSchema: void 0
|
|
786
786
|
}
|
|
@@ -1229,8 +1229,8 @@ function parseStringDef(def, refs) {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
return res;
|
|
1231
1231
|
}
|
|
1232
|
-
function escapeLiteralCheckValue(
|
|
1233
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(
|
|
1232
|
+
function escapeLiteralCheckValue(literal7, refs) {
|
|
1233
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal7) : literal7;
|
|
1234
1234
|
}
|
|
1235
1235
|
var ALPHA_NUMERIC = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
1236
1236
|
function escapeNonAlphaNumeric(source) {
|
|
@@ -1448,11 +1448,11 @@ function parseMapDef(def, refs) {
|
|
|
1448
1448
|
|
|
1449
1449
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
|
|
1450
1450
|
function parseNativeEnumDef(def) {
|
|
1451
|
-
const
|
|
1451
|
+
const object8 = def.values;
|
|
1452
1452
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
1453
|
-
return typeof
|
|
1453
|
+
return typeof object8[object8[key]] !== "number";
|
|
1454
1454
|
});
|
|
1455
|
-
const actualValues = actualKeys.map((key) =>
|
|
1455
|
+
const actualValues = actualKeys.map((key) => object8[key]);
|
|
1456
1456
|
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
1457
1457
|
return {
|
|
1458
1458
|
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
@@ -1902,17 +1902,17 @@ function parseDef(def, refs, forceResolution = false) {
|
|
|
1902
1902
|
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
1903
1903
|
refs.seen.set(def, newItem);
|
|
1904
1904
|
const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
|
|
1905
|
-
const
|
|
1906
|
-
if (
|
|
1907
|
-
addMeta(def, refs,
|
|
1905
|
+
const jsonSchema4 = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
1906
|
+
if (jsonSchema4) {
|
|
1907
|
+
addMeta(def, refs, jsonSchema4);
|
|
1908
1908
|
}
|
|
1909
1909
|
if (refs.postProcess) {
|
|
1910
|
-
const postProcessResult = refs.postProcess(
|
|
1911
|
-
newItem.jsonSchema =
|
|
1910
|
+
const postProcessResult = refs.postProcess(jsonSchema4, def, refs);
|
|
1911
|
+
newItem.jsonSchema = jsonSchema4;
|
|
1912
1912
|
return postProcessResult;
|
|
1913
1913
|
}
|
|
1914
|
-
newItem.jsonSchema =
|
|
1915
|
-
return
|
|
1914
|
+
newItem.jsonSchema = jsonSchema4;
|
|
1915
|
+
return jsonSchema4;
|
|
1916
1916
|
}
|
|
1917
1917
|
var get$ref = (item, refs) => {
|
|
1918
1918
|
switch (refs.$refStrategy) {
|
|
@@ -1930,30 +1930,30 @@ var get$ref = (item, refs) => {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
}
|
|
1932
1932
|
};
|
|
1933
|
-
var addMeta = (def, refs,
|
|
1933
|
+
var addMeta = (def, refs, jsonSchema4) => {
|
|
1934
1934
|
if (def.description) {
|
|
1935
|
-
|
|
1935
|
+
jsonSchema4.description = def.description;
|
|
1936
1936
|
if (refs.markdownDescription) {
|
|
1937
|
-
|
|
1937
|
+
jsonSchema4.markdownDescription = def.description;
|
|
1938
1938
|
}
|
|
1939
1939
|
}
|
|
1940
|
-
return
|
|
1940
|
+
return jsonSchema4;
|
|
1941
1941
|
};
|
|
1942
1942
|
|
|
1943
1943
|
// ../../node_modules/.pnpm/zod-to-json-schema@3.24.6_zod@3.25.76/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
|
|
1944
1944
|
var zodToJsonSchema = (schema, options) => {
|
|
1945
1945
|
const refs = getRefs(options);
|
|
1946
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [
|
|
1946
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name26, schema2]) => ({
|
|
1947
1947
|
...acc,
|
|
1948
|
-
[
|
|
1948
|
+
[name26]: parseDef(schema2._def, {
|
|
1949
1949
|
...refs,
|
|
1950
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1950
|
+
currentPath: [...refs.basePath, refs.definitionPath, name26]
|
|
1951
1951
|
}, true) ?? parseAnyDef(refs)
|
|
1952
1952
|
}), {}) : void 0;
|
|
1953
|
-
const
|
|
1954
|
-
const main = parseDef(schema._def,
|
|
1953
|
+
const name21 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
1954
|
+
const main = parseDef(schema._def, name21 === void 0 ? refs : {
|
|
1955
1955
|
...refs,
|
|
1956
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1956
|
+
currentPath: [...refs.basePath, refs.definitionPath, name21]
|
|
1957
1957
|
}, false) ?? parseAnyDef(refs);
|
|
1958
1958
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1959
1959
|
if (title !== void 0) {
|
|
@@ -1977,18 +1977,18 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
1977
1977
|
};
|
|
1978
1978
|
}
|
|
1979
1979
|
}
|
|
1980
|
-
const combined =
|
|
1980
|
+
const combined = name21 === void 0 ? definitions ? {
|
|
1981
1981
|
...main,
|
|
1982
1982
|
[refs.definitionPath]: definitions
|
|
1983
1983
|
} : main : {
|
|
1984
1984
|
$ref: [
|
|
1985
1985
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1986
1986
|
refs.definitionPath,
|
|
1987
|
-
|
|
1987
|
+
name21
|
|
1988
1988
|
].join("/"),
|
|
1989
1989
|
[refs.definitionPath]: {
|
|
1990
1990
|
...definitions,
|
|
1991
|
-
[
|
|
1991
|
+
[name21]: main
|
|
1992
1992
|
}
|
|
1993
1993
|
};
|
|
1994
1994
|
if (refs.target === "jsonSchema7") {
|
|
@@ -2006,10 +2006,10 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
2006
2006
|
var esm_default = zodToJsonSchema;
|
|
2007
2007
|
|
|
2008
2008
|
// ../schema-compat/dist/chunk-GWTUXMDD.js
|
|
2009
|
-
function zodToJsonSchema2(
|
|
2009
|
+
function zodToJsonSchema2(zodSchema4, target = "jsonSchema7", strategy = "relative") {
|
|
2010
2010
|
const fn = "toJSONSchema";
|
|
2011
2011
|
if (fn in z) {
|
|
2012
|
-
return z[fn](
|
|
2012
|
+
return z[fn](zodSchema4, {
|
|
2013
2013
|
unrepresentable: "any",
|
|
2014
2014
|
override: (ctx) => {
|
|
2015
2015
|
const def = ctx.zodSchema?._zod?.def;
|
|
@@ -2020,7 +2020,7 @@ function zodToJsonSchema2(zodSchema3, target = "jsonSchema7", strategy = "relati
|
|
|
2020
2020
|
}
|
|
2021
2021
|
});
|
|
2022
2022
|
} else {
|
|
2023
|
-
return esm_default(
|
|
2023
|
+
return esm_default(zodSchema4, {
|
|
2024
2024
|
$refStrategy: strategy,
|
|
2025
2025
|
target
|
|
2026
2026
|
});
|
|
@@ -2620,8 +2620,8 @@ function formatDataStreamPart(type, value) {
|
|
|
2620
2620
|
`;
|
|
2621
2621
|
}
|
|
2622
2622
|
function zodSchema(zodSchema22, options) {
|
|
2623
|
-
var
|
|
2624
|
-
const useReferences = (
|
|
2623
|
+
var _a21;
|
|
2624
|
+
const useReferences = (_a21 = void 0 ) != null ? _a21 : false;
|
|
2625
2625
|
return jsonSchema(
|
|
2626
2626
|
esm_default(zodSchema22, {
|
|
2627
2627
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -2734,11 +2734,11 @@ var major = VERSION.split(".")[0];
|
|
|
2734
2734
|
var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
|
|
2735
2735
|
var _global = _globalThis;
|
|
2736
2736
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
2737
|
-
var
|
|
2737
|
+
var _a21;
|
|
2738
2738
|
if (allowOverride === void 0) {
|
|
2739
2739
|
allowOverride = false;
|
|
2740
2740
|
}
|
|
2741
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
2741
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a21 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a21 !== void 0 ? _a21 : {
|
|
2742
2742
|
version: VERSION
|
|
2743
2743
|
};
|
|
2744
2744
|
if (!allowOverride && api[type]) {
|
|
@@ -2756,8 +2756,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
2756
2756
|
return true;
|
|
2757
2757
|
}
|
|
2758
2758
|
function getGlobal(type) {
|
|
2759
|
-
var
|
|
2760
|
-
var globalVersion = (
|
|
2759
|
+
var _a21, _b8;
|
|
2760
|
+
var globalVersion = (_a21 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
2761
2761
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
2762
2762
|
return;
|
|
2763
2763
|
}
|
|
@@ -2934,13 +2934,13 @@ var DiagAPI = (
|
|
|
2934
2934
|
}
|
|
2935
2935
|
var self = this;
|
|
2936
2936
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
2937
|
-
var
|
|
2937
|
+
var _a21, _b8, _c;
|
|
2938
2938
|
if (optionsOrLogLevel === void 0) {
|
|
2939
2939
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
2940
2940
|
}
|
|
2941
2941
|
if (logger === self) {
|
|
2942
2942
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
2943
|
-
self.error((
|
|
2943
|
+
self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
|
|
2944
2944
|
return false;
|
|
2945
2945
|
}
|
|
2946
2946
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -3111,12 +3111,12 @@ var ContextAPI = (
|
|
|
3111
3111
|
return this._getContextManager().active();
|
|
3112
3112
|
};
|
|
3113
3113
|
ContextAPI2.prototype.with = function(context, fn, thisArg) {
|
|
3114
|
-
var
|
|
3114
|
+
var _a21;
|
|
3115
3115
|
var args = [];
|
|
3116
3116
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
3117
3117
|
args[_i - 3] = arguments[_i];
|
|
3118
3118
|
}
|
|
3119
|
-
return (
|
|
3119
|
+
return (_a21 = this._getContextManager()).with.apply(_a21, __spreadArray4([context, fn, thisArg], __read4(args), false));
|
|
3120
3120
|
};
|
|
3121
3121
|
ContextAPI2.prototype.bind = function(context, target) {
|
|
3122
3122
|
return this._getContextManager().bind(context, target);
|
|
@@ -3211,8 +3211,8 @@ function setSpanContext(context, spanContext) {
|
|
|
3211
3211
|
return setSpan(context, new NonRecordingSpan(spanContext));
|
|
3212
3212
|
}
|
|
3213
3213
|
function getSpanContext(context) {
|
|
3214
|
-
var
|
|
3215
|
-
return (
|
|
3214
|
+
var _a21;
|
|
3215
|
+
return (_a21 = getSpan(context)) === null || _a21 === void 0 ? void 0 : _a21.spanContext();
|
|
3216
3216
|
}
|
|
3217
3217
|
|
|
3218
3218
|
// ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
|
|
@@ -3238,7 +3238,7 @@ var NoopTracer = (
|
|
|
3238
3238
|
(function() {
|
|
3239
3239
|
function NoopTracer2() {
|
|
3240
3240
|
}
|
|
3241
|
-
NoopTracer2.prototype.startSpan = function(
|
|
3241
|
+
NoopTracer2.prototype.startSpan = function(name21, options, context) {
|
|
3242
3242
|
if (context === void 0) {
|
|
3243
3243
|
context = contextApi.active();
|
|
3244
3244
|
}
|
|
@@ -3253,7 +3253,7 @@ var NoopTracer = (
|
|
|
3253
3253
|
return new NonRecordingSpan();
|
|
3254
3254
|
}
|
|
3255
3255
|
};
|
|
3256
|
-
NoopTracer2.prototype.startActiveSpan = function(
|
|
3256
|
+
NoopTracer2.prototype.startActiveSpan = function(name21, arg2, arg3, arg4) {
|
|
3257
3257
|
var opts;
|
|
3258
3258
|
var ctx;
|
|
3259
3259
|
var fn;
|
|
@@ -3270,7 +3270,7 @@ var NoopTracer = (
|
|
|
3270
3270
|
fn = arg4;
|
|
3271
3271
|
}
|
|
3272
3272
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
3273
|
-
var span = this.startSpan(
|
|
3273
|
+
var span = this.startSpan(name21, opts, parentContext);
|
|
3274
3274
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
3275
3275
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
3276
3276
|
};
|
|
@@ -3286,14 +3286,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
3286
3286
|
var ProxyTracer = (
|
|
3287
3287
|
/** @class */
|
|
3288
3288
|
(function() {
|
|
3289
|
-
function ProxyTracer2(_provider,
|
|
3289
|
+
function ProxyTracer2(_provider, name21, version, options) {
|
|
3290
3290
|
this._provider = _provider;
|
|
3291
|
-
this.name =
|
|
3291
|
+
this.name = name21;
|
|
3292
3292
|
this.version = version;
|
|
3293
3293
|
this.options = options;
|
|
3294
3294
|
}
|
|
3295
|
-
ProxyTracer2.prototype.startSpan = function(
|
|
3296
|
-
return this._getTracer().startSpan(
|
|
3295
|
+
ProxyTracer2.prototype.startSpan = function(name21, options, context) {
|
|
3296
|
+
return this._getTracer().startSpan(name21, options, context);
|
|
3297
3297
|
};
|
|
3298
3298
|
ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
3299
3299
|
var tracer = this._getTracer();
|
|
@@ -3334,20 +3334,20 @@ var ProxyTracerProvider = (
|
|
|
3334
3334
|
(function() {
|
|
3335
3335
|
function ProxyTracerProvider2() {
|
|
3336
3336
|
}
|
|
3337
|
-
ProxyTracerProvider2.prototype.getTracer = function(
|
|
3338
|
-
var
|
|
3339
|
-
return (
|
|
3337
|
+
ProxyTracerProvider2.prototype.getTracer = function(name21, version, options) {
|
|
3338
|
+
var _a21;
|
|
3339
|
+
return (_a21 = this.getDelegateTracer(name21, version, options)) !== null && _a21 !== void 0 ? _a21 : new ProxyTracer(this, name21, version, options);
|
|
3340
3340
|
};
|
|
3341
3341
|
ProxyTracerProvider2.prototype.getDelegate = function() {
|
|
3342
|
-
var
|
|
3343
|
-
return (
|
|
3342
|
+
var _a21;
|
|
3343
|
+
return (_a21 = this._delegate) !== null && _a21 !== void 0 ? _a21 : NOOP_TRACER_PROVIDER;
|
|
3344
3344
|
};
|
|
3345
3345
|
ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
|
|
3346
3346
|
this._delegate = delegate;
|
|
3347
3347
|
};
|
|
3348
|
-
ProxyTracerProvider2.prototype.getDelegateTracer = function(
|
|
3349
|
-
var
|
|
3350
|
-
return (
|
|
3348
|
+
ProxyTracerProvider2.prototype.getDelegateTracer = function(name21, version, options) {
|
|
3349
|
+
var _a21;
|
|
3350
|
+
return (_a21 = this._delegate) === null || _a21 === void 0 ? void 0 : _a21.getTracer(name21, version, options);
|
|
3351
3351
|
};
|
|
3352
3352
|
return ProxyTracerProvider2;
|
|
3353
3353
|
})()
|
|
@@ -3393,8 +3393,8 @@ var TraceAPI = (
|
|
|
3393
3393
|
TraceAPI2.prototype.getTracerProvider = function() {
|
|
3394
3394
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
3395
3395
|
};
|
|
3396
|
-
TraceAPI2.prototype.getTracer = function(
|
|
3397
|
-
return this.getTracerProvider().getTracer(
|
|
3396
|
+
TraceAPI2.prototype.getTracer = function(name21, version) {
|
|
3397
|
+
return this.getTracerProvider().getTracer(name21, version);
|
|
3398
3398
|
};
|
|
3399
3399
|
TraceAPI2.prototype.disable = function() {
|
|
3400
3400
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -3732,13 +3732,13 @@ function selectTelemetryAttributes({
|
|
|
3732
3732
|
return { ...attributes2, [key]: value };
|
|
3733
3733
|
}, {});
|
|
3734
3734
|
}
|
|
3735
|
-
function splitArray(
|
|
3735
|
+
function splitArray(array7, chunkSize) {
|
|
3736
3736
|
if (chunkSize <= 0) {
|
|
3737
3737
|
throw new Error("chunkSize must be greater than 0");
|
|
3738
3738
|
}
|
|
3739
3739
|
const result = [];
|
|
3740
|
-
for (let i = 0; i <
|
|
3741
|
-
result.push(
|
|
3740
|
+
for (let i = 0; i < array7.length; i += chunkSize) {
|
|
3741
|
+
result.push(array7.slice(i, i + chunkSize));
|
|
3742
3742
|
}
|
|
3743
3743
|
return result;
|
|
3744
3744
|
}
|
|
@@ -4565,13 +4565,13 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
4565
4565
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
4566
4566
|
*/
|
|
4567
4567
|
constructor({
|
|
4568
|
-
name:
|
|
4568
|
+
name: name144,
|
|
4569
4569
|
message,
|
|
4570
4570
|
cause
|
|
4571
4571
|
}) {
|
|
4572
4572
|
super(message);
|
|
4573
4573
|
this[_a17] = true;
|
|
4574
|
-
this.name =
|
|
4574
|
+
this.name = name144;
|
|
4575
4575
|
this.cause = cause;
|
|
4576
4576
|
}
|
|
4577
4577
|
/**
|
|
@@ -4582,8 +4582,8 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
4582
4582
|
static isInstance(error) {
|
|
4583
4583
|
return _AISDKError2.hasMarker(error, marker17);
|
|
4584
4584
|
}
|
|
4585
|
-
static hasMarker(error,
|
|
4586
|
-
const markerSymbol = Symbol.for(
|
|
4585
|
+
static hasMarker(error, marker154) {
|
|
4586
|
+
const markerSymbol = Symbol.for(marker154);
|
|
4587
4587
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
4588
4588
|
}
|
|
4589
4589
|
};
|
|
@@ -4675,15 +4675,15 @@ var marker72 = `vercel.ai.error.${name62}`;
|
|
|
4675
4675
|
var symbol72 = Symbol.for(marker72);
|
|
4676
4676
|
var _a72;
|
|
4677
4677
|
var JSONParseError = class extends AISDKError2 {
|
|
4678
|
-
constructor({ text:
|
|
4678
|
+
constructor({ text: text4, cause }) {
|
|
4679
4679
|
super({
|
|
4680
4680
|
name: name62,
|
|
4681
|
-
message: `JSON parsing failed: Text: ${
|
|
4681
|
+
message: `JSON parsing failed: Text: ${text4}.
|
|
4682
4682
|
Error message: ${getErrorMessage2(cause)}`,
|
|
4683
4683
|
cause
|
|
4684
4684
|
});
|
|
4685
4685
|
this[_a72] = true;
|
|
4686
|
-
this.text =
|
|
4686
|
+
this.text = text4;
|
|
4687
4687
|
}
|
|
4688
4688
|
static isInstance(error) {
|
|
4689
4689
|
return AISDKError2.hasMarker(error, marker72);
|
|
@@ -4916,11 +4916,11 @@ function extractResponseHeaders(response) {
|
|
|
4916
4916
|
return Object.fromEntries([...response.headers]);
|
|
4917
4917
|
}
|
|
4918
4918
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
4919
|
-
var
|
|
4919
|
+
var _a21, _b8, _c;
|
|
4920
4920
|
if (globalThisAny.window) {
|
|
4921
4921
|
return `runtime/browser`;
|
|
4922
4922
|
}
|
|
4923
|
-
if ((
|
|
4923
|
+
if ((_a21 = globalThisAny.navigator) == null ? void 0 : _a21.userAgent) {
|
|
4924
4924
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
4925
4925
|
}
|
|
4926
4926
|
if ((_c = (_b8 = globalThisAny.process) == null ? void 0 : _b8.versions) == null ? void 0 : _c.node) {
|
|
@@ -4931,9 +4931,9 @@ function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
|
4931
4931
|
}
|
|
4932
4932
|
return "runtime/unknown";
|
|
4933
4933
|
}
|
|
4934
|
-
function removeUndefinedEntries(
|
|
4934
|
+
function removeUndefinedEntries(record3) {
|
|
4935
4935
|
return Object.fromEntries(
|
|
4936
|
-
Object.entries(
|
|
4936
|
+
Object.entries(record3).filter(([_key, value]) => value != null)
|
|
4937
4937
|
);
|
|
4938
4938
|
}
|
|
4939
4939
|
function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
@@ -5101,12 +5101,12 @@ function loadOptionalSetting({
|
|
|
5101
5101
|
}
|
|
5102
5102
|
var suspectProtoRx = /"__proto__"\s*:/;
|
|
5103
5103
|
var suspectConstructorRx = /"constructor"\s*:/;
|
|
5104
|
-
function _parse(
|
|
5105
|
-
const obj = JSON.parse(
|
|
5104
|
+
function _parse(text4) {
|
|
5105
|
+
const obj = JSON.parse(text4);
|
|
5106
5106
|
if (obj === null || typeof obj !== "object") {
|
|
5107
5107
|
return obj;
|
|
5108
5108
|
}
|
|
5109
|
-
if (suspectProtoRx.test(
|
|
5109
|
+
if (suspectProtoRx.test(text4) === false && suspectConstructorRx.test(text4) === false) {
|
|
5110
5110
|
return obj;
|
|
5111
5111
|
}
|
|
5112
5112
|
return filter(obj);
|
|
@@ -5133,11 +5133,11 @@ function filter(obj) {
|
|
|
5133
5133
|
}
|
|
5134
5134
|
return obj;
|
|
5135
5135
|
}
|
|
5136
|
-
function secureJsonParse(
|
|
5136
|
+
function secureJsonParse(text4) {
|
|
5137
5137
|
const { stackTraceLimit } = Error;
|
|
5138
5138
|
Error.stackTraceLimit = 0;
|
|
5139
5139
|
try {
|
|
5140
|
-
return _parse(
|
|
5140
|
+
return _parse(text4);
|
|
5141
5141
|
} finally {
|
|
5142
5142
|
Error.stackTraceLimit = stackTraceLimit;
|
|
5143
5143
|
}
|
|
@@ -5178,12 +5178,12 @@ async function safeValidateTypes2({
|
|
|
5178
5178
|
value,
|
|
5179
5179
|
schema
|
|
5180
5180
|
}) {
|
|
5181
|
-
const
|
|
5181
|
+
const validator22 = asValidator(schema);
|
|
5182
5182
|
try {
|
|
5183
|
-
if (
|
|
5183
|
+
if (validator22.validate == null) {
|
|
5184
5184
|
return { success: true, value, rawValue: value };
|
|
5185
5185
|
}
|
|
5186
|
-
const result = await
|
|
5186
|
+
const result = await validator22.validate(value);
|
|
5187
5187
|
if (result.success) {
|
|
5188
5188
|
return { success: true, value: result.value, rawValue: value };
|
|
5189
5189
|
}
|
|
@@ -5201,11 +5201,11 @@ async function safeValidateTypes2({
|
|
|
5201
5201
|
}
|
|
5202
5202
|
}
|
|
5203
5203
|
async function parseJSON({
|
|
5204
|
-
text:
|
|
5204
|
+
text: text4,
|
|
5205
5205
|
schema
|
|
5206
5206
|
}) {
|
|
5207
5207
|
try {
|
|
5208
|
-
const value = secureJsonParse(
|
|
5208
|
+
const value = secureJsonParse(text4);
|
|
5209
5209
|
if (schema == null) {
|
|
5210
5210
|
return value;
|
|
5211
5211
|
}
|
|
@@ -5214,15 +5214,15 @@ async function parseJSON({
|
|
|
5214
5214
|
if (JSONParseError.isInstance(error) || TypeValidationError.isInstance(error)) {
|
|
5215
5215
|
throw error;
|
|
5216
5216
|
}
|
|
5217
|
-
throw new JSONParseError({ text:
|
|
5217
|
+
throw new JSONParseError({ text: text4, cause: error });
|
|
5218
5218
|
}
|
|
5219
5219
|
}
|
|
5220
5220
|
async function safeParseJSON2({
|
|
5221
|
-
text:
|
|
5221
|
+
text: text4,
|
|
5222
5222
|
schema
|
|
5223
5223
|
}) {
|
|
5224
5224
|
try {
|
|
5225
|
-
const value = secureJsonParse(
|
|
5225
|
+
const value = secureJsonParse(text4);
|
|
5226
5226
|
if (schema == null) {
|
|
5227
5227
|
return { success: true, value, rawValue: value };
|
|
5228
5228
|
}
|
|
@@ -5230,7 +5230,7 @@ async function safeParseJSON2({
|
|
|
5230
5230
|
} catch (error) {
|
|
5231
5231
|
return {
|
|
5232
5232
|
success: false,
|
|
5233
|
-
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text:
|
|
5233
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
|
|
5234
5234
|
rawValue: void 0
|
|
5235
5235
|
};
|
|
5236
5236
|
}
|
|
@@ -5483,11 +5483,11 @@ function parseAnyDef2() {
|
|
|
5483
5483
|
return {};
|
|
5484
5484
|
}
|
|
5485
5485
|
function parseArrayDef2(def, refs) {
|
|
5486
|
-
var
|
|
5486
|
+
var _a21, _b8, _c;
|
|
5487
5487
|
const res = {
|
|
5488
5488
|
type: "array"
|
|
5489
5489
|
};
|
|
5490
|
-
if (((
|
|
5490
|
+
if (((_a21 = def.type) == null ? void 0 : _a21._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind$1.ZodAny) {
|
|
5491
5491
|
res.items = parseDef2(def.type._def, {
|
|
5492
5492
|
...refs,
|
|
5493
5493
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -5831,8 +5831,8 @@ function parseStringDef2(def, refs) {
|
|
|
5831
5831
|
}
|
|
5832
5832
|
return res;
|
|
5833
5833
|
}
|
|
5834
|
-
function escapeLiteralCheckValue2(
|
|
5835
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(
|
|
5834
|
+
function escapeLiteralCheckValue2(literal7, refs) {
|
|
5835
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal7) : literal7;
|
|
5836
5836
|
}
|
|
5837
5837
|
var ALPHA_NUMERIC2 = new Set(
|
|
5838
5838
|
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
@@ -5848,8 +5848,8 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
5848
5848
|
return result;
|
|
5849
5849
|
}
|
|
5850
5850
|
function addFormat2(schema, value, message, refs) {
|
|
5851
|
-
var
|
|
5852
|
-
if (schema.format || ((
|
|
5851
|
+
var _a21;
|
|
5852
|
+
if (schema.format || ((_a21 = schema.anyOf) == null ? void 0 : _a21.some((x) => x.format))) {
|
|
5853
5853
|
if (!schema.anyOf) {
|
|
5854
5854
|
schema.anyOf = [];
|
|
5855
5855
|
}
|
|
@@ -5868,8 +5868,8 @@ function addFormat2(schema, value, message, refs) {
|
|
|
5868
5868
|
}
|
|
5869
5869
|
}
|
|
5870
5870
|
function addPattern2(schema, regex, message, refs) {
|
|
5871
|
-
var
|
|
5872
|
-
if (schema.pattern || ((
|
|
5871
|
+
var _a21;
|
|
5872
|
+
if (schema.pattern || ((_a21 = schema.allOf) == null ? void 0 : _a21.some((x) => x.pattern))) {
|
|
5873
5873
|
if (!schema.allOf) {
|
|
5874
5874
|
schema.allOf = [];
|
|
5875
5875
|
}
|
|
@@ -5888,7 +5888,7 @@ function addPattern2(schema, regex, message, refs) {
|
|
|
5888
5888
|
}
|
|
5889
5889
|
}
|
|
5890
5890
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
5891
|
-
var
|
|
5891
|
+
var _a21;
|
|
5892
5892
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
5893
5893
|
return regex.source;
|
|
5894
5894
|
}
|
|
@@ -5918,7 +5918,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5918
5918
|
pattern += source[i];
|
|
5919
5919
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
5920
5920
|
inCharRange = false;
|
|
5921
|
-
} else if (source[i + 1] === "-" && ((
|
|
5921
|
+
} else if (source[i + 1] === "-" && ((_a21 = source[i + 2]) == null ? void 0 : _a21.match(/[a-z]/))) {
|
|
5922
5922
|
pattern += source[i];
|
|
5923
5923
|
inCharRange = true;
|
|
5924
5924
|
} else {
|
|
@@ -5960,13 +5960,13 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5960
5960
|
return pattern;
|
|
5961
5961
|
}
|
|
5962
5962
|
function parseRecordDef2(def, refs) {
|
|
5963
|
-
var
|
|
5963
|
+
var _a21, _b8, _c, _d, _e, _f;
|
|
5964
5964
|
const schema = {
|
|
5965
5965
|
type: "object",
|
|
5966
|
-
additionalProperties: (
|
|
5966
|
+
additionalProperties: (_a21 = parseDef2(def.valueType._def, {
|
|
5967
5967
|
...refs,
|
|
5968
5968
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
5969
|
-
})) != null ?
|
|
5969
|
+
})) != null ? _a21 : refs.allowedAdditionalProperties
|
|
5970
5970
|
};
|
|
5971
5971
|
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind$1.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
5972
5972
|
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
@@ -6017,11 +6017,11 @@ function parseMapDef2(def, refs) {
|
|
|
6017
6017
|
};
|
|
6018
6018
|
}
|
|
6019
6019
|
function parseNativeEnumDef2(def) {
|
|
6020
|
-
const
|
|
6020
|
+
const object8 = def.values;
|
|
6021
6021
|
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
6022
|
-
return typeof
|
|
6022
|
+
return typeof object8[object8[key]] !== "number";
|
|
6023
6023
|
});
|
|
6024
|
-
const actualValues = actualKeys.map((key) =>
|
|
6024
|
+
const actualValues = actualKeys.map((key) => object8[key]);
|
|
6025
6025
|
const parsedTypes = Array.from(
|
|
6026
6026
|
new Set(actualValues.map((values) => typeof values))
|
|
6027
6027
|
);
|
|
@@ -6225,8 +6225,8 @@ function safeIsOptional2(schema) {
|
|
|
6225
6225
|
}
|
|
6226
6226
|
}
|
|
6227
6227
|
var parseOptionalDef2 = (def, refs) => {
|
|
6228
|
-
var
|
|
6229
|
-
if (refs.currentPath.toString() === ((
|
|
6228
|
+
var _a21;
|
|
6229
|
+
if (refs.currentPath.toString() === ((_a21 = refs.propertyPath) == null ? void 0 : _a21.toString())) {
|
|
6230
6230
|
return parseDef2(def.innerType._def, refs);
|
|
6231
6231
|
}
|
|
6232
6232
|
const innerSchema = parseDef2(def.innerType._def, {
|
|
@@ -6396,10 +6396,10 @@ var selectParser2 = (def, typeName, refs) => {
|
|
|
6396
6396
|
}
|
|
6397
6397
|
};
|
|
6398
6398
|
function parseDef2(def, refs, forceResolution = false) {
|
|
6399
|
-
var
|
|
6399
|
+
var _a21;
|
|
6400
6400
|
const seenItem = refs.seen.get(def);
|
|
6401
6401
|
if (refs.override) {
|
|
6402
|
-
const overrideResult = (
|
|
6402
|
+
const overrideResult = (_a21 = refs.override) == null ? void 0 : _a21.call(
|
|
6403
6403
|
refs,
|
|
6404
6404
|
def,
|
|
6405
6405
|
refs,
|
|
@@ -6465,11 +6465,11 @@ var getRefs2 = (options) => {
|
|
|
6465
6465
|
currentPath,
|
|
6466
6466
|
propertyPath: void 0,
|
|
6467
6467
|
seen: new Map(
|
|
6468
|
-
Object.entries(_options.definitions).map(([
|
|
6468
|
+
Object.entries(_options.definitions).map(([name21, def]) => [
|
|
6469
6469
|
def._def,
|
|
6470
6470
|
{
|
|
6471
6471
|
def: def._def,
|
|
6472
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
6472
|
+
path: [..._options.basePath, _options.definitionPath, name21],
|
|
6473
6473
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
6474
6474
|
jsonSchema: void 0
|
|
6475
6475
|
}
|
|
@@ -6478,50 +6478,50 @@ var getRefs2 = (options) => {
|
|
|
6478
6478
|
};
|
|
6479
6479
|
};
|
|
6480
6480
|
var zodToJsonSchema3 = (schema, options) => {
|
|
6481
|
-
var
|
|
6481
|
+
var _a21;
|
|
6482
6482
|
const refs = getRefs2(options);
|
|
6483
6483
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
6484
|
-
(acc, [
|
|
6485
|
-
var
|
|
6484
|
+
(acc, [name26, schema2]) => {
|
|
6485
|
+
var _a26;
|
|
6486
6486
|
return {
|
|
6487
6487
|
...acc,
|
|
6488
|
-
[
|
|
6488
|
+
[name26]: (_a26 = parseDef2(
|
|
6489
6489
|
schema2._def,
|
|
6490
6490
|
{
|
|
6491
6491
|
...refs,
|
|
6492
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
6492
|
+
currentPath: [...refs.basePath, refs.definitionPath, name26]
|
|
6493
6493
|
},
|
|
6494
6494
|
true
|
|
6495
|
-
)) != null ?
|
|
6495
|
+
)) != null ? _a26 : parseAnyDef2()
|
|
6496
6496
|
};
|
|
6497
6497
|
},
|
|
6498
6498
|
{}
|
|
6499
6499
|
) : void 0;
|
|
6500
|
-
const
|
|
6501
|
-
const main = (
|
|
6500
|
+
const name21 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
6501
|
+
const main = (_a21 = parseDef2(
|
|
6502
6502
|
schema._def,
|
|
6503
|
-
|
|
6503
|
+
name21 === void 0 ? refs : {
|
|
6504
6504
|
...refs,
|
|
6505
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
6505
|
+
currentPath: [...refs.basePath, refs.definitionPath, name21]
|
|
6506
6506
|
},
|
|
6507
6507
|
false
|
|
6508
|
-
)) != null ?
|
|
6508
|
+
)) != null ? _a21 : parseAnyDef2();
|
|
6509
6509
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
6510
6510
|
if (title !== void 0) {
|
|
6511
6511
|
main.title = title;
|
|
6512
6512
|
}
|
|
6513
|
-
const combined =
|
|
6513
|
+
const combined = name21 === void 0 ? definitions ? {
|
|
6514
6514
|
...main,
|
|
6515
6515
|
[refs.definitionPath]: definitions
|
|
6516
6516
|
} : main : {
|
|
6517
6517
|
$ref: [
|
|
6518
6518
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
6519
6519
|
refs.definitionPath,
|
|
6520
|
-
|
|
6520
|
+
name21
|
|
6521
6521
|
].join("/"),
|
|
6522
6522
|
[refs.definitionPath]: {
|
|
6523
6523
|
...definitions,
|
|
6524
|
-
[
|
|
6524
|
+
[name21]: main
|
|
6525
6525
|
}
|
|
6526
6526
|
};
|
|
6527
6527
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -6529,8 +6529,8 @@ var zodToJsonSchema3 = (schema, options) => {
|
|
|
6529
6529
|
};
|
|
6530
6530
|
var zod_to_json_schema_default = zodToJsonSchema3;
|
|
6531
6531
|
function zod3Schema(zodSchema22, options) {
|
|
6532
|
-
var
|
|
6533
|
-
const useReferences = (
|
|
6532
|
+
var _a21;
|
|
6533
|
+
const useReferences = (_a21 = void 0 ) != null ? _a21 : false;
|
|
6534
6534
|
return jsonSchema2(
|
|
6535
6535
|
zod_to_json_schema_default(zodSchema22, {
|
|
6536
6536
|
$refStrategy: useReferences ? "root" : "none"
|
|
@@ -6544,16 +6544,16 @@ function zod3Schema(zodSchema22, options) {
|
|
|
6544
6544
|
);
|
|
6545
6545
|
}
|
|
6546
6546
|
function zod4Schema(zodSchema22, options) {
|
|
6547
|
-
var
|
|
6548
|
-
const useReferences = (
|
|
6549
|
-
const z4JSONSchema =
|
|
6547
|
+
var _a21;
|
|
6548
|
+
const useReferences = (_a21 = void 0 ) != null ? _a21 : false;
|
|
6549
|
+
const z4JSONSchema = z104.toJSONSchema(zodSchema22, {
|
|
6550
6550
|
target: "draft-7",
|
|
6551
6551
|
io: "output",
|
|
6552
6552
|
reused: useReferences ? "ref" : "inline"
|
|
6553
6553
|
});
|
|
6554
6554
|
return jsonSchema2(z4JSONSchema, {
|
|
6555
6555
|
validate: async (value) => {
|
|
6556
|
-
const result = await
|
|
6556
|
+
const result = await z104.safeParseAsync(zodSchema22, value);
|
|
6557
6557
|
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
6558
6558
|
}
|
|
6559
6559
|
});
|
|
@@ -6857,14 +6857,14 @@ var gatewayErrorResponseSchema = z$1.object({
|
|
|
6857
6857
|
})
|
|
6858
6858
|
});
|
|
6859
6859
|
function asGatewayError(error, authMethod) {
|
|
6860
|
-
var
|
|
6860
|
+
var _a85;
|
|
6861
6861
|
if (GatewayError.isInstance(error)) {
|
|
6862
6862
|
return error;
|
|
6863
6863
|
}
|
|
6864
6864
|
if (APICallError2.isInstance(error)) {
|
|
6865
6865
|
return createGatewayErrorFromResponse({
|
|
6866
6866
|
response: extractApiCallResponse(error),
|
|
6867
|
-
statusCode: (
|
|
6867
|
+
statusCode: (_a85 = error.statusCode) != null ? _a85 : 500,
|
|
6868
6868
|
defaultMessage: "Gateway request failed",
|
|
6869
6869
|
cause: error,
|
|
6870
6870
|
authMethod
|
|
@@ -7140,7 +7140,7 @@ var GatewayEmbeddingModel = class {
|
|
|
7140
7140
|
abortSignal,
|
|
7141
7141
|
providerOptions
|
|
7142
7142
|
}) {
|
|
7143
|
-
var
|
|
7143
|
+
var _a85;
|
|
7144
7144
|
const resolvedHeaders = await resolve(this.config.headers());
|
|
7145
7145
|
try {
|
|
7146
7146
|
const {
|
|
@@ -7171,7 +7171,7 @@ var GatewayEmbeddingModel = class {
|
|
|
7171
7171
|
});
|
|
7172
7172
|
return {
|
|
7173
7173
|
embeddings: responseBody.embeddings,
|
|
7174
|
-
usage: (
|
|
7174
|
+
usage: (_a85 = responseBody.usage) != null ? _a85 : void 0,
|
|
7175
7175
|
providerMetadata: responseBody.providerMetadata,
|
|
7176
7176
|
response: { headers: responseHeaders, body: rawValue }
|
|
7177
7177
|
};
|
|
@@ -7195,16 +7195,16 @@ var gatewayEmbeddingResponseSchema = z$1.object({
|
|
|
7195
7195
|
providerMetadata: z$1.record(z$1.string(), z$1.record(z$1.string(), z$1.unknown())).optional()
|
|
7196
7196
|
});
|
|
7197
7197
|
async function getVercelRequestId() {
|
|
7198
|
-
var
|
|
7199
|
-
return (
|
|
7198
|
+
var _a85;
|
|
7199
|
+
return (_a85 = (0, import_oidc.getContext)().headers) == null ? void 0 : _a85["x-vercel-id"];
|
|
7200
7200
|
}
|
|
7201
7201
|
var VERSION3 = "1.0.33" ;
|
|
7202
7202
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7203
7203
|
function createGatewayProvider(options = {}) {
|
|
7204
|
-
var
|
|
7204
|
+
var _a85, _b8;
|
|
7205
7205
|
let pendingMetadata = null;
|
|
7206
7206
|
let metadataCache = null;
|
|
7207
|
-
const cacheRefreshMillis = (
|
|
7207
|
+
const cacheRefreshMillis = (_a85 = options.metadataCacheRefreshMillis) != null ? _a85 : 1e3 * 60 * 5;
|
|
7208
7208
|
let lastFetchTime = 0;
|
|
7209
7209
|
const baseURL = (_b8 = withoutTrailingSlash(options.baseURL)) != null ? _b8 : "https://ai-gateway.vercel.sh/v1/ai";
|
|
7210
7210
|
const getHeaders = async () => {
|
|
@@ -7259,8 +7259,8 @@ function createGatewayProvider(options = {}) {
|
|
|
7259
7259
|
});
|
|
7260
7260
|
};
|
|
7261
7261
|
const getAvailableModels = async () => {
|
|
7262
|
-
var
|
|
7263
|
-
const now = (_c = (_b9 = (
|
|
7262
|
+
var _a95, _b9, _c;
|
|
7263
|
+
const now = (_c = (_b9 = (_a95 = options._internal) == null ? void 0 : _a95.currentDate) == null ? void 0 : _b9.call(_a95).getTime()) != null ? _c : Date.now();
|
|
7264
7264
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
7265
7265
|
lastFetchTime = now;
|
|
7266
7266
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -7881,9 +7881,6 @@ function prepareRetries2({
|
|
|
7881
7881
|
})
|
|
7882
7882
|
};
|
|
7883
7883
|
}
|
|
7884
|
-
function stepCountIs(stepCount) {
|
|
7885
|
-
return ({ steps }) => steps.length === stepCount;
|
|
7886
|
-
}
|
|
7887
7884
|
createIdGenerator2({
|
|
7888
7885
|
prefix: "aitxt",
|
|
7889
7886
|
size: 24
|
|
@@ -8358,13 +8355,13 @@ createIdGenerator2({
|
|
|
8358
8355
|
prefix: "aitxt",
|
|
8359
8356
|
size: 24
|
|
8360
8357
|
});
|
|
8361
|
-
function splitArray2(
|
|
8358
|
+
function splitArray2(array7, chunkSize) {
|
|
8362
8359
|
if (chunkSize <= 0) {
|
|
8363
8360
|
throw new Error("chunkSize must be greater than 0");
|
|
8364
8361
|
}
|
|
8365
8362
|
const result = [];
|
|
8366
|
-
for (let i = 0; i <
|
|
8367
|
-
result.push(
|
|
8363
|
+
for (let i = 0; i < array7.length; i += chunkSize) {
|
|
8364
|
+
result.push(array7.slice(i, i + chunkSize));
|
|
8368
8365
|
}
|
|
8369
8366
|
return result;
|
|
8370
8367
|
}
|
|
@@ -9595,50 +9592,50 @@ function isValidWithSchema(schema, value) {
|
|
|
9595
9592
|
return schema.safeParse(value).success;
|
|
9596
9593
|
}
|
|
9597
9594
|
var NotHandler = class {
|
|
9598
|
-
apply(
|
|
9599
|
-
if (!schema.not) return
|
|
9595
|
+
apply(zodSchema4, schema) {
|
|
9596
|
+
if (!schema.not) return zodSchema4;
|
|
9600
9597
|
const notSchema = convertJsonSchemaToZod(schema.not);
|
|
9601
|
-
return
|
|
9598
|
+
return zodSchema4.refine(
|
|
9602
9599
|
(value) => !isValidWithSchema(notSchema, value),
|
|
9603
9600
|
{ message: "Value must not match the 'not' schema" }
|
|
9604
9601
|
);
|
|
9605
9602
|
}
|
|
9606
9603
|
};
|
|
9607
9604
|
var UniqueItemsHandler = class {
|
|
9608
|
-
apply(
|
|
9605
|
+
apply(zodSchema4, schema) {
|
|
9609
9606
|
const arraySchema = schema;
|
|
9610
|
-
if (arraySchema.uniqueItems !== true) return
|
|
9611
|
-
return
|
|
9607
|
+
if (arraySchema.uniqueItems !== true) return zodSchema4;
|
|
9608
|
+
return zodSchema4.refine(createUniqueItemsValidator(), {
|
|
9612
9609
|
message: "Array items must be unique"
|
|
9613
9610
|
});
|
|
9614
9611
|
}
|
|
9615
9612
|
};
|
|
9616
9613
|
var AllOfHandler = class {
|
|
9617
|
-
apply(
|
|
9618
|
-
if (!schema.allOf || schema.allOf.length === 0) return
|
|
9614
|
+
apply(zodSchema4, schema) {
|
|
9615
|
+
if (!schema.allOf || schema.allOf.length === 0) return zodSchema4;
|
|
9619
9616
|
const allOfSchemas = schema.allOf.map((s) => convertJsonSchemaToZod(s));
|
|
9620
9617
|
return allOfSchemas.reduce(
|
|
9621
9618
|
(acc, s) => z$1.intersection(acc, s),
|
|
9622
|
-
|
|
9619
|
+
zodSchema4
|
|
9623
9620
|
);
|
|
9624
9621
|
}
|
|
9625
9622
|
};
|
|
9626
9623
|
var AnyOfHandler = class {
|
|
9627
|
-
apply(
|
|
9628
|
-
if (!schema.anyOf || schema.anyOf.length === 0) return
|
|
9624
|
+
apply(zodSchema4, schema) {
|
|
9625
|
+
if (!schema.anyOf || schema.anyOf.length === 0) return zodSchema4;
|
|
9629
9626
|
const anyOfSchema = schema.anyOf.length === 1 ? convertJsonSchemaToZod(schema.anyOf[0]) : z$1.union([
|
|
9630
9627
|
convertJsonSchemaToZod(schema.anyOf[0]),
|
|
9631
9628
|
convertJsonSchemaToZod(schema.anyOf[1]),
|
|
9632
9629
|
...schema.anyOf.slice(2).map((s) => convertJsonSchemaToZod(s))
|
|
9633
9630
|
]);
|
|
9634
|
-
return z$1.intersection(
|
|
9631
|
+
return z$1.intersection(zodSchema4, anyOfSchema);
|
|
9635
9632
|
}
|
|
9636
9633
|
};
|
|
9637
9634
|
var OneOfHandler = class {
|
|
9638
|
-
apply(
|
|
9639
|
-
if (!schema.oneOf || schema.oneOf.length === 0) return
|
|
9635
|
+
apply(zodSchema4, schema) {
|
|
9636
|
+
if (!schema.oneOf || schema.oneOf.length === 0) return zodSchema4;
|
|
9640
9637
|
const oneOfSchemas = schema.oneOf.map((s) => convertJsonSchemaToZod(s));
|
|
9641
|
-
return
|
|
9638
|
+
return zodSchema4.refine(
|
|
9642
9639
|
(value) => {
|
|
9643
9640
|
let validCount = 0;
|
|
9644
9641
|
for (const oneOfSchema of oneOfSchemas) {
|
|
@@ -9655,12 +9652,12 @@ var OneOfHandler = class {
|
|
|
9655
9652
|
}
|
|
9656
9653
|
};
|
|
9657
9654
|
var PrefixItemsHandler = class {
|
|
9658
|
-
apply(
|
|
9655
|
+
apply(zodSchema4, schema) {
|
|
9659
9656
|
const arraySchema = schema;
|
|
9660
9657
|
if (arraySchema.prefixItems && Array.isArray(arraySchema.prefixItems)) {
|
|
9661
9658
|
const prefixItems = arraySchema.prefixItems;
|
|
9662
9659
|
const prefixSchemas = prefixItems.map((itemSchema) => convertJsonSchemaToZod(itemSchema));
|
|
9663
|
-
return
|
|
9660
|
+
return zodSchema4.refine(
|
|
9664
9661
|
(value) => {
|
|
9665
9662
|
if (!Array.isArray(value)) return true;
|
|
9666
9663
|
for (let i = 0; i < Math.min(value.length, prefixSchemas.length); i++) {
|
|
@@ -9685,16 +9682,16 @@ var PrefixItemsHandler = class {
|
|
|
9685
9682
|
{ message: "Array does not match prefixItems schema" }
|
|
9686
9683
|
);
|
|
9687
9684
|
}
|
|
9688
|
-
return
|
|
9685
|
+
return zodSchema4;
|
|
9689
9686
|
}
|
|
9690
9687
|
};
|
|
9691
9688
|
var ObjectPropertiesHandler = class {
|
|
9692
|
-
apply(
|
|
9689
|
+
apply(zodSchema4, schema) {
|
|
9693
9690
|
const objectSchema = schema;
|
|
9694
9691
|
if (!objectSchema.properties && !objectSchema.required && objectSchema.additionalProperties !== false) {
|
|
9695
|
-
return
|
|
9692
|
+
return zodSchema4;
|
|
9696
9693
|
}
|
|
9697
|
-
if (
|
|
9694
|
+
if (zodSchema4 instanceof z$1.ZodObject || zodSchema4 instanceof z$1.ZodRecord) {
|
|
9698
9695
|
const shape = {};
|
|
9699
9696
|
if (objectSchema.properties) {
|
|
9700
9697
|
for (const [key, propSchema] of Object.entries(objectSchema.properties)) {
|
|
@@ -9721,7 +9718,7 @@ var ObjectPropertiesHandler = class {
|
|
|
9721
9718
|
return z$1.object(shape).passthrough();
|
|
9722
9719
|
}
|
|
9723
9720
|
}
|
|
9724
|
-
return
|
|
9721
|
+
return zodSchema4.refine(
|
|
9725
9722
|
(value) => {
|
|
9726
9723
|
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
9727
9724
|
return true;
|
|
@@ -9763,13 +9760,13 @@ var ObjectPropertiesHandler = class {
|
|
|
9763
9760
|
}
|
|
9764
9761
|
};
|
|
9765
9762
|
var EnumComplexHandler = class {
|
|
9766
|
-
apply(
|
|
9767
|
-
if (!schema.enum || schema.enum.length === 0) return
|
|
9763
|
+
apply(zodSchema4, schema) {
|
|
9764
|
+
if (!schema.enum || schema.enum.length === 0) return zodSchema4;
|
|
9768
9765
|
const complexValues = schema.enum.filter(
|
|
9769
9766
|
(v) => Array.isArray(v) || typeof v === "object" && v !== null
|
|
9770
9767
|
);
|
|
9771
|
-
if (complexValues.length === 0) return
|
|
9772
|
-
return
|
|
9768
|
+
if (complexValues.length === 0) return zodSchema4;
|
|
9769
|
+
return zodSchema4.refine(
|
|
9773
9770
|
(value) => {
|
|
9774
9771
|
if (typeof value !== "object" || value === null) return true;
|
|
9775
9772
|
return complexValues.some(
|
|
@@ -9781,32 +9778,32 @@ var EnumComplexHandler = class {
|
|
|
9781
9778
|
}
|
|
9782
9779
|
};
|
|
9783
9780
|
var ConstComplexHandler = class {
|
|
9784
|
-
apply(
|
|
9785
|
-
if (schema.const === void 0) return
|
|
9781
|
+
apply(zodSchema4, schema) {
|
|
9782
|
+
if (schema.const === void 0) return zodSchema4;
|
|
9786
9783
|
const constValue = schema.const;
|
|
9787
9784
|
if (typeof constValue !== "object" || constValue === null) {
|
|
9788
|
-
return
|
|
9785
|
+
return zodSchema4;
|
|
9789
9786
|
}
|
|
9790
|
-
return
|
|
9787
|
+
return zodSchema4.refine(
|
|
9791
9788
|
(value) => deepEqual(value, constValue),
|
|
9792
9789
|
{ message: "Value must equal the const value" }
|
|
9793
9790
|
);
|
|
9794
9791
|
}
|
|
9795
9792
|
};
|
|
9796
9793
|
var MetadataHandler = class {
|
|
9797
|
-
apply(
|
|
9794
|
+
apply(zodSchema4, schema) {
|
|
9798
9795
|
if (schema.description) {
|
|
9799
|
-
|
|
9796
|
+
zodSchema4 = zodSchema4.describe(schema.description);
|
|
9800
9797
|
}
|
|
9801
|
-
return
|
|
9798
|
+
return zodSchema4;
|
|
9802
9799
|
}
|
|
9803
9800
|
};
|
|
9804
9801
|
var ProtoRequiredHandler = class {
|
|
9805
|
-
apply(
|
|
9806
|
-
var
|
|
9802
|
+
apply(zodSchema4, schema) {
|
|
9803
|
+
var _a21;
|
|
9807
9804
|
const objectSchema = schema;
|
|
9808
|
-
if (!((
|
|
9809
|
-
return
|
|
9805
|
+
if (!((_a21 = objectSchema.required) == null ? void 0 : _a21.includes("__proto__")) || schema.type !== void 0) {
|
|
9806
|
+
return zodSchema4;
|
|
9810
9807
|
}
|
|
9811
9808
|
return z$1.any().refine(
|
|
9812
9809
|
(value) => this.validateRequired(value, objectSchema.required),
|
|
@@ -9823,14 +9820,14 @@ var ProtoRequiredHandler = class {
|
|
|
9823
9820
|
}
|
|
9824
9821
|
};
|
|
9825
9822
|
var ContainsHandler = class {
|
|
9826
|
-
apply(
|
|
9827
|
-
var
|
|
9823
|
+
apply(zodSchema4, schema) {
|
|
9824
|
+
var _a21;
|
|
9828
9825
|
const arraySchema = schema;
|
|
9829
|
-
if (arraySchema.contains === void 0) return
|
|
9826
|
+
if (arraySchema.contains === void 0) return zodSchema4;
|
|
9830
9827
|
const containsSchema = convertJsonSchemaToZod(arraySchema.contains);
|
|
9831
|
-
const minContains = (
|
|
9828
|
+
const minContains = (_a21 = arraySchema.minContains) != null ? _a21 : 1;
|
|
9832
9829
|
const maxContains = arraySchema.maxContains;
|
|
9833
|
-
return
|
|
9830
|
+
return zodSchema4.refine(
|
|
9834
9831
|
(value) => {
|
|
9835
9832
|
if (!Array.isArray(value)) {
|
|
9836
9833
|
return true;
|
|
@@ -9939,32 +9936,32 @@ function convertJsonSchemaToZod(schema) {
|
|
|
9939
9936
|
allowedSchemas.push(objectSchema);
|
|
9940
9937
|
}
|
|
9941
9938
|
}
|
|
9942
|
-
let
|
|
9939
|
+
let zodSchema4;
|
|
9943
9940
|
if (allowedSchemas.length === 0) {
|
|
9944
|
-
|
|
9941
|
+
zodSchema4 = z$1.never();
|
|
9945
9942
|
} else if (allowedSchemas.length === 1) {
|
|
9946
|
-
|
|
9943
|
+
zodSchema4 = allowedSchemas[0];
|
|
9947
9944
|
} else {
|
|
9948
9945
|
const hasConstraints = Object.keys(schema).some(
|
|
9949
9946
|
(key) => key !== "$schema" && key !== "title" && key !== "description"
|
|
9950
9947
|
);
|
|
9951
9948
|
if (!hasConstraints) {
|
|
9952
|
-
|
|
9949
|
+
zodSchema4 = z$1.any();
|
|
9953
9950
|
} else {
|
|
9954
|
-
|
|
9951
|
+
zodSchema4 = z$1.union(allowedSchemas);
|
|
9955
9952
|
}
|
|
9956
9953
|
}
|
|
9957
9954
|
for (const handler of refinementHandlers) {
|
|
9958
|
-
|
|
9955
|
+
zodSchema4 = handler.apply(zodSchema4, schema);
|
|
9959
9956
|
}
|
|
9960
|
-
return
|
|
9957
|
+
return zodSchema4;
|
|
9961
9958
|
}
|
|
9962
9959
|
function convertJsonSchemaToZod2(schema) {
|
|
9963
|
-
function addMetadata(
|
|
9964
|
-
if (
|
|
9965
|
-
|
|
9960
|
+
function addMetadata(zodSchema4, jsonSchema4) {
|
|
9961
|
+
if (jsonSchema4.description) {
|
|
9962
|
+
zodSchema4 = zodSchema4.describe(jsonSchema4.description);
|
|
9966
9963
|
}
|
|
9967
|
-
return
|
|
9964
|
+
return zodSchema4;
|
|
9968
9965
|
}
|
|
9969
9966
|
if (schema.const !== void 0) {
|
|
9970
9967
|
if (typeof schema.const === "string") {
|
|
@@ -10070,13 +10067,13 @@ function convertJsonSchemaToZod2(schema) {
|
|
|
10070
10067
|
shape[key] = shape[key].optional();
|
|
10071
10068
|
}
|
|
10072
10069
|
}
|
|
10073
|
-
let
|
|
10070
|
+
let zodSchema4;
|
|
10074
10071
|
if (schema.additionalProperties !== false) {
|
|
10075
|
-
|
|
10072
|
+
zodSchema4 = z.object(shape).passthrough();
|
|
10076
10073
|
} else {
|
|
10077
|
-
|
|
10074
|
+
zodSchema4 = z.object(shape);
|
|
10078
10075
|
}
|
|
10079
|
-
return addMetadata(
|
|
10076
|
+
return addMetadata(zodSchema4, schema);
|
|
10080
10077
|
}
|
|
10081
10078
|
return addMetadata(z.object({}), schema);
|
|
10082
10079
|
case "array": {
|
|
@@ -10653,11 +10650,11 @@ ${workingMemory}`;
|
|
|
10653
10650
|
release();
|
|
10654
10651
|
}
|
|
10655
10652
|
}
|
|
10656
|
-
chunkText(
|
|
10653
|
+
chunkText(text4, tokenSize = 4096) {
|
|
10657
10654
|
const charSize = tokenSize * CHARS_PER_TOKEN;
|
|
10658
10655
|
const chunks = [];
|
|
10659
10656
|
let currentChunk = "";
|
|
10660
|
-
const words =
|
|
10657
|
+
const words = text4.split(/\s+/);
|
|
10661
10658
|
for (const word of words) {
|
|
10662
10659
|
const wordWithSpace = currentChunk ? " " + word : word;
|
|
10663
10660
|
if (currentChunk.length + wordWithSpace.length > charSize) {
|
|
@@ -10819,10 +10816,10 @@ ${workingMemory}`;
|
|
|
10819
10816
|
}
|
|
10820
10817
|
return newMessage;
|
|
10821
10818
|
}
|
|
10822
|
-
parseWorkingMemory(
|
|
10819
|
+
parseWorkingMemory(text4) {
|
|
10823
10820
|
if (!this.threadConfig.workingMemory?.enabled) return null;
|
|
10824
10821
|
const workingMemoryRegex = /<working_memory>([^]*?)<\/working_memory>/g;
|
|
10825
|
-
const matches =
|
|
10822
|
+
const matches = text4.match(workingMemoryRegex);
|
|
10826
10823
|
const match = matches?.[0];
|
|
10827
10824
|
if (match) {
|
|
10828
10825
|
return match.replace(/<\/?working_memory>/g, "").trim();
|
|
@@ -11122,12 +11119,12 @@ var _Tiktoken = class {
|
|
|
11122
11119
|
this.textMap.set(rank, bytes);
|
|
11123
11120
|
}
|
|
11124
11121
|
this.specialTokens = { ...ranks.special_tokens, ...extendedSpecialTokens };
|
|
11125
|
-
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [
|
|
11126
|
-
memo[rank] = this.textEncoder.encode(
|
|
11122
|
+
this.inverseSpecialTokens = Object.entries(this.specialTokens).reduce((memo, [text4, rank]) => {
|
|
11123
|
+
memo[rank] = this.textEncoder.encode(text4);
|
|
11127
11124
|
return memo;
|
|
11128
11125
|
}, {});
|
|
11129
11126
|
}
|
|
11130
|
-
encode(
|
|
11127
|
+
encode(text4, allowedSpecial = [], disallowedSpecial = "all") {
|
|
11131
11128
|
const regexes = new RegExp(this.patStr, "ug");
|
|
11132
11129
|
const specialRegex = _Tiktoken.specialTokenRegex(
|
|
11133
11130
|
Object.keys(this.specialTokens)
|
|
@@ -11145,7 +11142,7 @@ var _Tiktoken = class {
|
|
|
11145
11142
|
const disallowedSpecialRegex = _Tiktoken.specialTokenRegex([
|
|
11146
11143
|
...disallowedSpecialSet
|
|
11147
11144
|
]);
|
|
11148
|
-
const specialMatch =
|
|
11145
|
+
const specialMatch = text4.match(disallowedSpecialRegex);
|
|
11149
11146
|
if (specialMatch != null) {
|
|
11150
11147
|
throw new Error(
|
|
11151
11148
|
`The text contains a special token that is not allowed: ${specialMatch[0]}`
|
|
@@ -11158,13 +11155,13 @@ var _Tiktoken = class {
|
|
|
11158
11155
|
let startFind = start;
|
|
11159
11156
|
while (true) {
|
|
11160
11157
|
specialRegex.lastIndex = startFind;
|
|
11161
|
-
nextSpecial = specialRegex.exec(
|
|
11158
|
+
nextSpecial = specialRegex.exec(text4);
|
|
11162
11159
|
if (nextSpecial == null || allowedSpecialSet.has(nextSpecial[0]))
|
|
11163
11160
|
break;
|
|
11164
11161
|
startFind = nextSpecial.index + 1;
|
|
11165
11162
|
}
|
|
11166
|
-
const end = nextSpecial?.index ??
|
|
11167
|
-
for (const match of
|
|
11163
|
+
const end = nextSpecial?.index ?? text4.length;
|
|
11164
|
+
for (const match of text4.substring(start, end).matchAll(regexes)) {
|
|
11168
11165
|
const piece = this.textEncoder.encode(match[0]);
|
|
11169
11166
|
const token2 = this.rankMap.get(piece.join(","));
|
|
11170
11167
|
if (token2 != null) {
|
|
@@ -11312,242 +11309,2244 @@ var TokenLimiter = class extends MemoryProcessor {
|
|
|
11312
11309
|
|
|
11313
11310
|
// ../agent-builder/dist/index.js
|
|
11314
11311
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
11315
|
-
var
|
|
11316
|
-
|
|
11317
|
-
|
|
11318
|
-
|
|
11319
|
-
|
|
11320
|
-
})
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
11324
|
-
|
|
11325
|
-
|
|
11326
|
-
});
|
|
11327
|
-
var AgentBuilderInputSchema = z.object({
|
|
11328
|
-
repo: z.string().describe("Git URL or local path of the template repo"),
|
|
11329
|
-
ref: z.string().optional().describe("Tag/branch/commit to checkout (defaults to main/master)"),
|
|
11330
|
-
slug: z.string().optional().describe("Slug for branch/scripts; defaults to inferred from repo"),
|
|
11331
|
-
targetPath: z.string().optional().describe("Project path to merge into; defaults to current directory"),
|
|
11332
|
-
variables: z.record(z.string()).optional().describe("Environment variables to set in .env file")
|
|
11333
|
-
});
|
|
11334
|
-
z.object({
|
|
11335
|
-
slug: z.string(),
|
|
11336
|
-
commitSha: z.string(),
|
|
11337
|
-
templateDir: z.string(),
|
|
11338
|
-
units: z.array(TemplateUnitSchema)
|
|
11339
|
-
});
|
|
11340
|
-
var CopiedFileSchema = z.object({
|
|
11341
|
-
source: z.string(),
|
|
11342
|
-
destination: z.string(),
|
|
11343
|
-
unit: z.object({
|
|
11344
|
-
kind: z.enum(UNIT_KINDS),
|
|
11345
|
-
id: z.string()
|
|
11346
|
-
})
|
|
11347
|
-
});
|
|
11348
|
-
var ConflictSchema = z.object({
|
|
11349
|
-
unit: z.object({
|
|
11350
|
-
kind: z.enum(UNIT_KINDS),
|
|
11351
|
-
id: z.string()
|
|
11352
|
-
}),
|
|
11353
|
-
issue: z.string(),
|
|
11354
|
-
sourceFile: z.string(),
|
|
11355
|
-
targetFile: z.string()
|
|
11356
|
-
});
|
|
11357
|
-
var FileCopyInputSchema = z.object({
|
|
11358
|
-
orderedUnits: z.array(TemplateUnitSchema),
|
|
11359
|
-
templateDir: z.string(),
|
|
11360
|
-
commitSha: z.string(),
|
|
11361
|
-
slug: z.string(),
|
|
11362
|
-
targetPath: z.string().optional(),
|
|
11363
|
-
variables: z.record(z.string()).optional()
|
|
11364
|
-
});
|
|
11365
|
-
var FileCopyResultSchema = z.object({
|
|
11366
|
-
success: z.boolean(),
|
|
11367
|
-
copiedFiles: z.array(CopiedFileSchema),
|
|
11368
|
-
conflicts: z.array(ConflictSchema),
|
|
11369
|
-
message: z.string(),
|
|
11370
|
-
error: z.string().optional()
|
|
11371
|
-
});
|
|
11372
|
-
var ConflictResolutionSchema = z.object({
|
|
11373
|
-
unit: z.object({
|
|
11374
|
-
kind: z.enum(UNIT_KINDS),
|
|
11375
|
-
id: z.string()
|
|
11376
|
-
}),
|
|
11377
|
-
issue: z.string(),
|
|
11378
|
-
resolution: z.string()
|
|
11379
|
-
});
|
|
11380
|
-
var IntelligentMergeInputSchema = z.object({
|
|
11381
|
-
conflicts: z.array(ConflictSchema),
|
|
11382
|
-
copiedFiles: z.array(CopiedFileSchema),
|
|
11383
|
-
templateDir: z.string(),
|
|
11384
|
-
commitSha: z.string(),
|
|
11385
|
-
slug: z.string(),
|
|
11386
|
-
targetPath: z.string().optional(),
|
|
11387
|
-
branchName: z.string().optional()
|
|
11388
|
-
});
|
|
11389
|
-
var IntelligentMergeResultSchema = z.object({
|
|
11390
|
-
success: z.boolean(),
|
|
11391
|
-
applied: z.boolean(),
|
|
11392
|
-
message: z.string(),
|
|
11393
|
-
conflictsResolved: z.array(ConflictResolutionSchema),
|
|
11394
|
-
error: z.string().optional()
|
|
11395
|
-
});
|
|
11396
|
-
var ValidationResultsSchema = z.object({
|
|
11397
|
-
valid: z.boolean(),
|
|
11398
|
-
errorsFixed: z.number(),
|
|
11399
|
-
remainingErrors: z.number(),
|
|
11400
|
-
errors: z.array(z.any()).optional()
|
|
11401
|
-
// Include specific validation errors
|
|
11402
|
-
});
|
|
11403
|
-
var ValidationFixInputSchema = z.object({
|
|
11404
|
-
commitSha: z.string(),
|
|
11405
|
-
slug: z.string(),
|
|
11406
|
-
targetPath: z.string().optional(),
|
|
11407
|
-
templateDir: z.string(),
|
|
11408
|
-
orderedUnits: z.array(TemplateUnitSchema),
|
|
11409
|
-
copiedFiles: z.array(CopiedFileSchema),
|
|
11410
|
-
conflictsResolved: z.array(ConflictResolutionSchema).optional(),
|
|
11411
|
-
maxIterations: z.number().optional().default(5)
|
|
11412
|
-
});
|
|
11413
|
-
var ValidationFixResultSchema = z.object({
|
|
11414
|
-
success: z.boolean(),
|
|
11415
|
-
applied: z.boolean(),
|
|
11416
|
-
message: z.string(),
|
|
11417
|
-
validationResults: ValidationResultsSchema,
|
|
11418
|
-
error: z.string().optional()
|
|
11419
|
-
});
|
|
11420
|
-
var ApplyResultSchema = z.object({
|
|
11421
|
-
success: z.boolean(),
|
|
11422
|
-
applied: z.boolean(),
|
|
11423
|
-
branchName: z.string().optional(),
|
|
11424
|
-
message: z.string(),
|
|
11425
|
-
validationResults: ValidationResultsSchema.optional(),
|
|
11426
|
-
error: z.string().optional(),
|
|
11427
|
-
errors: z.array(z.string()).optional(),
|
|
11428
|
-
stepResults: z.object({
|
|
11429
|
-
cloneSuccess: z.boolean().optional(),
|
|
11430
|
-
analyzeSuccess: z.boolean().optional(),
|
|
11431
|
-
discoverSuccess: z.boolean().optional(),
|
|
11432
|
-
orderSuccess: z.boolean().optional(),
|
|
11433
|
-
prepareBranchSuccess: z.boolean().optional(),
|
|
11434
|
-
packageMergeSuccess: z.boolean().optional(),
|
|
11435
|
-
installSuccess: z.boolean().optional(),
|
|
11436
|
-
copySuccess: z.boolean().optional(),
|
|
11437
|
-
mergeSuccess: z.boolean().optional(),
|
|
11438
|
-
validationSuccess: z.boolean().optional(),
|
|
11439
|
-
filesCopied: z.number(),
|
|
11440
|
-
conflictsSkipped: z.number(),
|
|
11441
|
-
conflictsResolved: z.number()
|
|
11442
|
-
}).optional()
|
|
11443
|
-
});
|
|
11444
|
-
var CloneTemplateResultSchema = z.object({
|
|
11445
|
-
templateDir: z.string(),
|
|
11446
|
-
commitSha: z.string(),
|
|
11447
|
-
slug: z.string(),
|
|
11448
|
-
success: z.boolean().optional(),
|
|
11449
|
-
error: z.string().optional(),
|
|
11450
|
-
targetPath: z.string().optional()
|
|
11451
|
-
});
|
|
11452
|
-
var PackageAnalysisSchema = z.object({
|
|
11453
|
-
name: z.string().optional(),
|
|
11454
|
-
version: z.string().optional(),
|
|
11455
|
-
description: z.string().optional(),
|
|
11456
|
-
dependencies: z.record(z.string()).optional(),
|
|
11457
|
-
devDependencies: z.record(z.string()).optional(),
|
|
11458
|
-
peerDependencies: z.record(z.string()).optional(),
|
|
11459
|
-
scripts: z.record(z.string()).optional(),
|
|
11460
|
-
success: z.boolean().optional(),
|
|
11461
|
-
error: z.string().optional()
|
|
11462
|
-
});
|
|
11463
|
-
var DiscoveryResultSchema = z.object({
|
|
11464
|
-
units: z.array(TemplateUnitSchema),
|
|
11465
|
-
success: z.boolean().optional(),
|
|
11466
|
-
error: z.string().optional()
|
|
11467
|
-
});
|
|
11468
|
-
var OrderedUnitsSchema = z.object({
|
|
11469
|
-
orderedUnits: z.array(TemplateUnitSchema),
|
|
11470
|
-
success: z.boolean().optional(),
|
|
11471
|
-
error: z.string().optional()
|
|
11472
|
-
});
|
|
11473
|
-
var PackageMergeInputSchema = z.object({
|
|
11474
|
-
commitSha: z.string(),
|
|
11475
|
-
slug: z.string(),
|
|
11476
|
-
targetPath: z.string().optional(),
|
|
11477
|
-
packageInfo: PackageAnalysisSchema
|
|
11478
|
-
});
|
|
11479
|
-
var PackageMergeResultSchema = z.object({
|
|
11480
|
-
success: z.boolean(),
|
|
11481
|
-
applied: z.boolean(),
|
|
11482
|
-
message: z.string(),
|
|
11483
|
-
error: z.string().optional()
|
|
11484
|
-
});
|
|
11485
|
-
var InstallInputSchema = z.object({
|
|
11486
|
-
targetPath: z.string().describe("Path to the project to install packages in")
|
|
11487
|
-
});
|
|
11488
|
-
var InstallResultSchema = z.object({
|
|
11489
|
-
success: z.boolean(),
|
|
11490
|
-
error: z.string().optional()
|
|
11491
|
-
});
|
|
11492
|
-
var PrepareBranchInputSchema = z.object({
|
|
11493
|
-
slug: z.string(),
|
|
11494
|
-
commitSha: z.string().optional(),
|
|
11495
|
-
// from clone-template if relevant
|
|
11496
|
-
targetPath: z.string().optional()
|
|
11497
|
-
});
|
|
11498
|
-
var PrepareBranchResultSchema = z.object({
|
|
11499
|
-
branchName: z.string(),
|
|
11500
|
-
success: z.boolean().optional(),
|
|
11501
|
-
error: z.string().optional()
|
|
11502
|
-
});
|
|
11503
|
-
var exec = promisify(exec$1);
|
|
11504
|
-
var execFile = promisify(execFile$1);
|
|
11505
|
-
function isInWorkspaceSubfolder(cwd) {
|
|
11506
|
-
try {
|
|
11507
|
-
const currentPackageJson = resolve$1(cwd, "package.json");
|
|
11508
|
-
if (!existsSync(currentPackageJson)) {
|
|
11509
|
-
return false;
|
|
11510
|
-
}
|
|
11511
|
-
let currentDir = cwd;
|
|
11512
|
-
let previousDir = "";
|
|
11513
|
-
while (currentDir !== previousDir && currentDir !== "/") {
|
|
11514
|
-
previousDir = currentDir;
|
|
11515
|
-
currentDir = dirname(currentDir);
|
|
11516
|
-
if (currentDir === cwd) {
|
|
11517
|
-
continue;
|
|
11518
|
-
}
|
|
11519
|
-
console.info(`Checking for workspace indicators in: ${currentDir}`);
|
|
11520
|
-
if (existsSync(resolve$1(currentDir, "pnpm-workspace.yaml"))) {
|
|
11521
|
-
return true;
|
|
11522
|
-
}
|
|
11523
|
-
const parentPackageJson = resolve$1(currentDir, "package.json");
|
|
11524
|
-
if (existsSync(parentPackageJson)) {
|
|
11525
|
-
try {
|
|
11526
|
-
const parentPkg = JSON.parse(readFileSync(parentPackageJson, "utf-8"));
|
|
11527
|
-
if (parentPkg.workspaces) {
|
|
11528
|
-
return true;
|
|
11529
|
-
}
|
|
11530
|
-
} catch {
|
|
11531
|
-
}
|
|
11532
|
-
}
|
|
11533
|
-
if (existsSync(resolve$1(currentDir, "lerna.json"))) {
|
|
11534
|
-
return true;
|
|
11535
|
-
}
|
|
11312
|
+
var createIdGenerator3 = ({
|
|
11313
|
+
prefix,
|
|
11314
|
+
size = 16,
|
|
11315
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
11316
|
+
separator = "-"
|
|
11317
|
+
} = {}) => {
|
|
11318
|
+
const generator = () => {
|
|
11319
|
+
const alphabetLength = alphabet.length;
|
|
11320
|
+
const chars = new Array(size);
|
|
11321
|
+
for (let i = 0; i < size; i++) {
|
|
11322
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
11536
11323
|
}
|
|
11537
|
-
return
|
|
11538
|
-
}
|
|
11539
|
-
|
|
11540
|
-
return
|
|
11324
|
+
return chars.join("");
|
|
11325
|
+
};
|
|
11326
|
+
if (prefix == null) {
|
|
11327
|
+
return generator;
|
|
11541
11328
|
}
|
|
11542
|
-
|
|
11543
|
-
|
|
11544
|
-
|
|
11545
|
-
|
|
11546
|
-
stdio: "inherit",
|
|
11547
|
-
// Enable proper stdio handling
|
|
11548
|
-
...options
|
|
11329
|
+
if (alphabet.includes(separator)) {
|
|
11330
|
+
throw new InvalidArgumentError2({
|
|
11331
|
+
argument: "separator",
|
|
11332
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
11549
11333
|
});
|
|
11550
|
-
|
|
11334
|
+
}
|
|
11335
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
11336
|
+
};
|
|
11337
|
+
createIdGenerator3();
|
|
11338
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
11339
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
11340
|
+
function _parse2(text4) {
|
|
11341
|
+
const obj = JSON.parse(text4);
|
|
11342
|
+
if (obj === null || typeof obj !== "object") {
|
|
11343
|
+
return obj;
|
|
11344
|
+
}
|
|
11345
|
+
if (suspectProtoRx2.test(text4) === false && suspectConstructorRx2.test(text4) === false) {
|
|
11346
|
+
return obj;
|
|
11347
|
+
}
|
|
11348
|
+
return filter2(obj);
|
|
11349
|
+
}
|
|
11350
|
+
function filter2(obj) {
|
|
11351
|
+
let next = [obj];
|
|
11352
|
+
while (next.length) {
|
|
11353
|
+
const nodes = next;
|
|
11354
|
+
next = [];
|
|
11355
|
+
for (const node of nodes) {
|
|
11356
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
11357
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
11358
|
+
}
|
|
11359
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
11360
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
11361
|
+
}
|
|
11362
|
+
for (const key in node) {
|
|
11363
|
+
const value = node[key];
|
|
11364
|
+
if (value && typeof value === "object") {
|
|
11365
|
+
next.push(value);
|
|
11366
|
+
}
|
|
11367
|
+
}
|
|
11368
|
+
}
|
|
11369
|
+
}
|
|
11370
|
+
return obj;
|
|
11371
|
+
}
|
|
11372
|
+
function secureJsonParse2(text4) {
|
|
11373
|
+
const { stackTraceLimit } = Error;
|
|
11374
|
+
Error.stackTraceLimit = 0;
|
|
11375
|
+
try {
|
|
11376
|
+
return _parse2(text4);
|
|
11377
|
+
} finally {
|
|
11378
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
11379
|
+
}
|
|
11380
|
+
}
|
|
11381
|
+
var validatorSymbol3 = Symbol.for("vercel.ai.validator");
|
|
11382
|
+
function validator2(validate) {
|
|
11383
|
+
return { [validatorSymbol3]: true, validate };
|
|
11384
|
+
}
|
|
11385
|
+
function isValidator2(value) {
|
|
11386
|
+
return typeof value === "object" && value !== null && validatorSymbol3 in value && value[validatorSymbol3] === true && "validate" in value;
|
|
11387
|
+
}
|
|
11388
|
+
function asValidator2(value) {
|
|
11389
|
+
return isValidator2(value) ? value : typeof value === "function" ? value() : standardSchemaValidator2(value);
|
|
11390
|
+
}
|
|
11391
|
+
function standardSchemaValidator2(standardSchema) {
|
|
11392
|
+
return validator2(async (value) => {
|
|
11393
|
+
const result = await standardSchema["~standard"].validate(value);
|
|
11394
|
+
return result.issues == null ? { success: true, value: result.value } : {
|
|
11395
|
+
success: false,
|
|
11396
|
+
error: new TypeValidationError({
|
|
11397
|
+
value,
|
|
11398
|
+
cause: result.issues
|
|
11399
|
+
})
|
|
11400
|
+
};
|
|
11401
|
+
});
|
|
11402
|
+
}
|
|
11403
|
+
async function safeValidateTypes3({
|
|
11404
|
+
value,
|
|
11405
|
+
schema
|
|
11406
|
+
}) {
|
|
11407
|
+
const validator22 = asValidator2(schema);
|
|
11408
|
+
try {
|
|
11409
|
+
if (validator22.validate == null) {
|
|
11410
|
+
return { success: true, value, rawValue: value };
|
|
11411
|
+
}
|
|
11412
|
+
const result = await validator22.validate(value);
|
|
11413
|
+
if (result.success) {
|
|
11414
|
+
return { success: true, value: result.value, rawValue: value };
|
|
11415
|
+
}
|
|
11416
|
+
return {
|
|
11417
|
+
success: false,
|
|
11418
|
+
error: TypeValidationError.wrap({ value, cause: result.error }),
|
|
11419
|
+
rawValue: value
|
|
11420
|
+
};
|
|
11421
|
+
} catch (error) {
|
|
11422
|
+
return {
|
|
11423
|
+
success: false,
|
|
11424
|
+
error: TypeValidationError.wrap({ value, cause: error }),
|
|
11425
|
+
rawValue: value
|
|
11426
|
+
};
|
|
11427
|
+
}
|
|
11428
|
+
}
|
|
11429
|
+
async function safeParseJSON3({
|
|
11430
|
+
text: text4,
|
|
11431
|
+
schema
|
|
11432
|
+
}) {
|
|
11433
|
+
try {
|
|
11434
|
+
const value = secureJsonParse2(text4);
|
|
11435
|
+
if (schema == null) {
|
|
11436
|
+
return { success: true, value, rawValue: value };
|
|
11437
|
+
}
|
|
11438
|
+
return await safeValidateTypes3({ value, schema });
|
|
11439
|
+
} catch (error) {
|
|
11440
|
+
return {
|
|
11441
|
+
success: false,
|
|
11442
|
+
error: JSONParseError.isInstance(error) ? error : new JSONParseError({ text: text4, cause: error }),
|
|
11443
|
+
rawValue: void 0
|
|
11444
|
+
};
|
|
11445
|
+
}
|
|
11446
|
+
}
|
|
11447
|
+
var getRelativePath3 = (pathA, pathB) => {
|
|
11448
|
+
let i = 0;
|
|
11449
|
+
for (; i < pathA.length && i < pathB.length; i++) {
|
|
11450
|
+
if (pathA[i] !== pathB[i]) break;
|
|
11451
|
+
}
|
|
11452
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
11453
|
+
};
|
|
11454
|
+
var ignoreOverride3 = Symbol(
|
|
11455
|
+
"Let zodToJsonSchema decide on which parser to use"
|
|
11456
|
+
);
|
|
11457
|
+
var defaultOptions3 = {
|
|
11458
|
+
name: void 0,
|
|
11459
|
+
$refStrategy: "root",
|
|
11460
|
+
basePath: ["#"],
|
|
11461
|
+
effectStrategy: "input",
|
|
11462
|
+
pipeStrategy: "all",
|
|
11463
|
+
dateStrategy: "format:date-time",
|
|
11464
|
+
mapStrategy: "entries",
|
|
11465
|
+
removeAdditionalStrategy: "passthrough",
|
|
11466
|
+
allowedAdditionalProperties: true,
|
|
11467
|
+
rejectedAdditionalProperties: false,
|
|
11468
|
+
definitionPath: "definitions",
|
|
11469
|
+
strictUnions: false,
|
|
11470
|
+
definitions: {},
|
|
11471
|
+
errorMessages: false,
|
|
11472
|
+
patternStrategy: "escape",
|
|
11473
|
+
applyRegexFlags: false,
|
|
11474
|
+
emailStrategy: "format:email",
|
|
11475
|
+
base64Strategy: "contentEncoding:base64",
|
|
11476
|
+
nameStrategy: "ref"
|
|
11477
|
+
};
|
|
11478
|
+
var getDefaultOptions3 = (options) => typeof options === "string" ? {
|
|
11479
|
+
...defaultOptions3,
|
|
11480
|
+
name: options
|
|
11481
|
+
} : {
|
|
11482
|
+
...defaultOptions3,
|
|
11483
|
+
...options
|
|
11484
|
+
};
|
|
11485
|
+
function parseAnyDef3() {
|
|
11486
|
+
return {};
|
|
11487
|
+
}
|
|
11488
|
+
function parseArrayDef3(def, refs) {
|
|
11489
|
+
var _a21, _b8, _c;
|
|
11490
|
+
const res = {
|
|
11491
|
+
type: "array"
|
|
11492
|
+
};
|
|
11493
|
+
if (((_a21 = def.type) == null ? void 0 : _a21._def) && ((_c = (_b8 = def.type) == null ? void 0 : _b8._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind$1.ZodAny) {
|
|
11494
|
+
res.items = parseDef3(def.type._def, {
|
|
11495
|
+
...refs,
|
|
11496
|
+
currentPath: [...refs.currentPath, "items"]
|
|
11497
|
+
});
|
|
11498
|
+
}
|
|
11499
|
+
if (def.minLength) {
|
|
11500
|
+
res.minItems = def.minLength.value;
|
|
11501
|
+
}
|
|
11502
|
+
if (def.maxLength) {
|
|
11503
|
+
res.maxItems = def.maxLength.value;
|
|
11504
|
+
}
|
|
11505
|
+
if (def.exactLength) {
|
|
11506
|
+
res.minItems = def.exactLength.value;
|
|
11507
|
+
res.maxItems = def.exactLength.value;
|
|
11508
|
+
}
|
|
11509
|
+
return res;
|
|
11510
|
+
}
|
|
11511
|
+
function parseBigintDef3(def) {
|
|
11512
|
+
const res = {
|
|
11513
|
+
type: "integer",
|
|
11514
|
+
format: "int64"
|
|
11515
|
+
};
|
|
11516
|
+
if (!def.checks) return res;
|
|
11517
|
+
for (const check of def.checks) {
|
|
11518
|
+
switch (check.kind) {
|
|
11519
|
+
case "min":
|
|
11520
|
+
if (check.inclusive) {
|
|
11521
|
+
res.minimum = check.value;
|
|
11522
|
+
} else {
|
|
11523
|
+
res.exclusiveMinimum = check.value;
|
|
11524
|
+
}
|
|
11525
|
+
break;
|
|
11526
|
+
case "max":
|
|
11527
|
+
if (check.inclusive) {
|
|
11528
|
+
res.maximum = check.value;
|
|
11529
|
+
} else {
|
|
11530
|
+
res.exclusiveMaximum = check.value;
|
|
11531
|
+
}
|
|
11532
|
+
break;
|
|
11533
|
+
case "multipleOf":
|
|
11534
|
+
res.multipleOf = check.value;
|
|
11535
|
+
break;
|
|
11536
|
+
}
|
|
11537
|
+
}
|
|
11538
|
+
return res;
|
|
11539
|
+
}
|
|
11540
|
+
function parseBooleanDef3() {
|
|
11541
|
+
return { type: "boolean" };
|
|
11542
|
+
}
|
|
11543
|
+
function parseBrandedDef3(_def, refs) {
|
|
11544
|
+
return parseDef3(_def.type._def, refs);
|
|
11545
|
+
}
|
|
11546
|
+
var parseCatchDef3 = (def, refs) => {
|
|
11547
|
+
return parseDef3(def.innerType._def, refs);
|
|
11548
|
+
};
|
|
11549
|
+
function parseDateDef3(def, refs, overrideDateStrategy) {
|
|
11550
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
11551
|
+
if (Array.isArray(strategy)) {
|
|
11552
|
+
return {
|
|
11553
|
+
anyOf: strategy.map((item, i) => parseDateDef3(def, refs, item))
|
|
11554
|
+
};
|
|
11555
|
+
}
|
|
11556
|
+
switch (strategy) {
|
|
11557
|
+
case "string":
|
|
11558
|
+
case "format:date-time":
|
|
11559
|
+
return {
|
|
11560
|
+
type: "string",
|
|
11561
|
+
format: "date-time"
|
|
11562
|
+
};
|
|
11563
|
+
case "format:date":
|
|
11564
|
+
return {
|
|
11565
|
+
type: "string",
|
|
11566
|
+
format: "date"
|
|
11567
|
+
};
|
|
11568
|
+
case "integer":
|
|
11569
|
+
return integerDateParser3(def);
|
|
11570
|
+
}
|
|
11571
|
+
}
|
|
11572
|
+
var integerDateParser3 = (def) => {
|
|
11573
|
+
const res = {
|
|
11574
|
+
type: "integer",
|
|
11575
|
+
format: "unix-time"
|
|
11576
|
+
};
|
|
11577
|
+
for (const check of def.checks) {
|
|
11578
|
+
switch (check.kind) {
|
|
11579
|
+
case "min":
|
|
11580
|
+
res.minimum = check.value;
|
|
11581
|
+
break;
|
|
11582
|
+
case "max":
|
|
11583
|
+
res.maximum = check.value;
|
|
11584
|
+
break;
|
|
11585
|
+
}
|
|
11586
|
+
}
|
|
11587
|
+
return res;
|
|
11588
|
+
};
|
|
11589
|
+
function parseDefaultDef3(_def, refs) {
|
|
11590
|
+
return {
|
|
11591
|
+
...parseDef3(_def.innerType._def, refs),
|
|
11592
|
+
default: _def.defaultValue()
|
|
11593
|
+
};
|
|
11594
|
+
}
|
|
11595
|
+
function parseEffectsDef3(_def, refs) {
|
|
11596
|
+
return refs.effectStrategy === "input" ? parseDef3(_def.schema._def, refs) : parseAnyDef3();
|
|
11597
|
+
}
|
|
11598
|
+
function parseEnumDef3(def) {
|
|
11599
|
+
return {
|
|
11600
|
+
type: "string",
|
|
11601
|
+
enum: Array.from(def.values)
|
|
11602
|
+
};
|
|
11603
|
+
}
|
|
11604
|
+
var isJsonSchema7AllOfType3 = (type) => {
|
|
11605
|
+
if ("type" in type && type.type === "string") return false;
|
|
11606
|
+
return "allOf" in type;
|
|
11607
|
+
};
|
|
11608
|
+
function parseIntersectionDef3(def, refs) {
|
|
11609
|
+
const allOf = [
|
|
11610
|
+
parseDef3(def.left._def, {
|
|
11611
|
+
...refs,
|
|
11612
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
11613
|
+
}),
|
|
11614
|
+
parseDef3(def.right._def, {
|
|
11615
|
+
...refs,
|
|
11616
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
11617
|
+
})
|
|
11618
|
+
].filter((x) => !!x);
|
|
11619
|
+
const mergedAllOf = [];
|
|
11620
|
+
allOf.forEach((schema) => {
|
|
11621
|
+
if (isJsonSchema7AllOfType3(schema)) {
|
|
11622
|
+
mergedAllOf.push(...schema.allOf);
|
|
11623
|
+
} else {
|
|
11624
|
+
let nestedSchema = schema;
|
|
11625
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
11626
|
+
const { additionalProperties, ...rest } = schema;
|
|
11627
|
+
nestedSchema = rest;
|
|
11628
|
+
}
|
|
11629
|
+
mergedAllOf.push(nestedSchema);
|
|
11630
|
+
}
|
|
11631
|
+
});
|
|
11632
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : void 0;
|
|
11633
|
+
}
|
|
11634
|
+
function parseLiteralDef3(def) {
|
|
11635
|
+
const parsedType = typeof def.value;
|
|
11636
|
+
if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") {
|
|
11637
|
+
return {
|
|
11638
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
11639
|
+
};
|
|
11640
|
+
}
|
|
11641
|
+
return {
|
|
11642
|
+
type: parsedType === "bigint" ? "integer" : parsedType,
|
|
11643
|
+
const: def.value
|
|
11644
|
+
};
|
|
11645
|
+
}
|
|
11646
|
+
var emojiRegex3 = void 0;
|
|
11647
|
+
var zodPatterns3 = {
|
|
11648
|
+
/**
|
|
11649
|
+
* `c` was changed to `[cC]` to replicate /i flag
|
|
11650
|
+
*/
|
|
11651
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
11652
|
+
cuid2: /^[0-9a-z]+$/,
|
|
11653
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
11654
|
+
/**
|
|
11655
|
+
* `a-z` was added to replicate /i flag
|
|
11656
|
+
*/
|
|
11657
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
11658
|
+
/**
|
|
11659
|
+
* Constructed a valid Unicode RegExp
|
|
11660
|
+
*
|
|
11661
|
+
* Lazily instantiate since this type of regex isn't supported
|
|
11662
|
+
* in all envs (e.g. React Native).
|
|
11663
|
+
*
|
|
11664
|
+
* See:
|
|
11665
|
+
* https://github.com/colinhacks/zod/issues/2433
|
|
11666
|
+
* Fix in Zod:
|
|
11667
|
+
* https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
|
|
11668
|
+
*/
|
|
11669
|
+
emoji: () => {
|
|
11670
|
+
if (emojiRegex3 === void 0) {
|
|
11671
|
+
emojiRegex3 = RegExp(
|
|
11672
|
+
"^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",
|
|
11673
|
+
"u"
|
|
11674
|
+
);
|
|
11675
|
+
}
|
|
11676
|
+
return emojiRegex3;
|
|
11677
|
+
},
|
|
11678
|
+
/**
|
|
11679
|
+
* Unused
|
|
11680
|
+
*/
|
|
11681
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
11682
|
+
/**
|
|
11683
|
+
* Unused
|
|
11684
|
+
*/
|
|
11685
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
11686
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
11687
|
+
/**
|
|
11688
|
+
* Unused
|
|
11689
|
+
*/
|
|
11690
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
11691
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
11692
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
11693
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
11694
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
11695
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
11696
|
+
};
|
|
11697
|
+
function parseStringDef3(def, refs) {
|
|
11698
|
+
const res = {
|
|
11699
|
+
type: "string"
|
|
11700
|
+
};
|
|
11701
|
+
if (def.checks) {
|
|
11702
|
+
for (const check of def.checks) {
|
|
11703
|
+
switch (check.kind) {
|
|
11704
|
+
case "min":
|
|
11705
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
11706
|
+
break;
|
|
11707
|
+
case "max":
|
|
11708
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
11709
|
+
break;
|
|
11710
|
+
case "email":
|
|
11711
|
+
switch (refs.emailStrategy) {
|
|
11712
|
+
case "format:email":
|
|
11713
|
+
addFormat3(res, "email", check.message, refs);
|
|
11714
|
+
break;
|
|
11715
|
+
case "format:idn-email":
|
|
11716
|
+
addFormat3(res, "idn-email", check.message, refs);
|
|
11717
|
+
break;
|
|
11718
|
+
case "pattern:zod":
|
|
11719
|
+
addPattern3(res, zodPatterns3.email, check.message, refs);
|
|
11720
|
+
break;
|
|
11721
|
+
}
|
|
11722
|
+
break;
|
|
11723
|
+
case "url":
|
|
11724
|
+
addFormat3(res, "uri", check.message, refs);
|
|
11725
|
+
break;
|
|
11726
|
+
case "uuid":
|
|
11727
|
+
addFormat3(res, "uuid", check.message, refs);
|
|
11728
|
+
break;
|
|
11729
|
+
case "regex":
|
|
11730
|
+
addPattern3(res, check.regex, check.message, refs);
|
|
11731
|
+
break;
|
|
11732
|
+
case "cuid":
|
|
11733
|
+
addPattern3(res, zodPatterns3.cuid, check.message, refs);
|
|
11734
|
+
break;
|
|
11735
|
+
case "cuid2":
|
|
11736
|
+
addPattern3(res, zodPatterns3.cuid2, check.message, refs);
|
|
11737
|
+
break;
|
|
11738
|
+
case "startsWith":
|
|
11739
|
+
addPattern3(
|
|
11740
|
+
res,
|
|
11741
|
+
RegExp(`^${escapeLiteralCheckValue3(check.value, refs)}`),
|
|
11742
|
+
check.message,
|
|
11743
|
+
refs
|
|
11744
|
+
);
|
|
11745
|
+
break;
|
|
11746
|
+
case "endsWith":
|
|
11747
|
+
addPattern3(
|
|
11748
|
+
res,
|
|
11749
|
+
RegExp(`${escapeLiteralCheckValue3(check.value, refs)}$`),
|
|
11750
|
+
check.message,
|
|
11751
|
+
refs
|
|
11752
|
+
);
|
|
11753
|
+
break;
|
|
11754
|
+
case "datetime":
|
|
11755
|
+
addFormat3(res, "date-time", check.message, refs);
|
|
11756
|
+
break;
|
|
11757
|
+
case "date":
|
|
11758
|
+
addFormat3(res, "date", check.message, refs);
|
|
11759
|
+
break;
|
|
11760
|
+
case "time":
|
|
11761
|
+
addFormat3(res, "time", check.message, refs);
|
|
11762
|
+
break;
|
|
11763
|
+
case "duration":
|
|
11764
|
+
addFormat3(res, "duration", check.message, refs);
|
|
11765
|
+
break;
|
|
11766
|
+
case "length":
|
|
11767
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value;
|
|
11768
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value;
|
|
11769
|
+
break;
|
|
11770
|
+
case "includes": {
|
|
11771
|
+
addPattern3(
|
|
11772
|
+
res,
|
|
11773
|
+
RegExp(escapeLiteralCheckValue3(check.value, refs)),
|
|
11774
|
+
check.message,
|
|
11775
|
+
refs
|
|
11776
|
+
);
|
|
11777
|
+
break;
|
|
11778
|
+
}
|
|
11779
|
+
case "ip": {
|
|
11780
|
+
if (check.version !== "v6") {
|
|
11781
|
+
addFormat3(res, "ipv4", check.message, refs);
|
|
11782
|
+
}
|
|
11783
|
+
if (check.version !== "v4") {
|
|
11784
|
+
addFormat3(res, "ipv6", check.message, refs);
|
|
11785
|
+
}
|
|
11786
|
+
break;
|
|
11787
|
+
}
|
|
11788
|
+
case "base64url":
|
|
11789
|
+
addPattern3(res, zodPatterns3.base64url, check.message, refs);
|
|
11790
|
+
break;
|
|
11791
|
+
case "jwt":
|
|
11792
|
+
addPattern3(res, zodPatterns3.jwt, check.message, refs);
|
|
11793
|
+
break;
|
|
11794
|
+
case "cidr": {
|
|
11795
|
+
if (check.version !== "v6") {
|
|
11796
|
+
addPattern3(res, zodPatterns3.ipv4Cidr, check.message, refs);
|
|
11797
|
+
}
|
|
11798
|
+
if (check.version !== "v4") {
|
|
11799
|
+
addPattern3(res, zodPatterns3.ipv6Cidr, check.message, refs);
|
|
11800
|
+
}
|
|
11801
|
+
break;
|
|
11802
|
+
}
|
|
11803
|
+
case "emoji":
|
|
11804
|
+
addPattern3(res, zodPatterns3.emoji(), check.message, refs);
|
|
11805
|
+
break;
|
|
11806
|
+
case "ulid": {
|
|
11807
|
+
addPattern3(res, zodPatterns3.ulid, check.message, refs);
|
|
11808
|
+
break;
|
|
11809
|
+
}
|
|
11810
|
+
case "base64": {
|
|
11811
|
+
switch (refs.base64Strategy) {
|
|
11812
|
+
case "format:binary": {
|
|
11813
|
+
addFormat3(res, "binary", check.message, refs);
|
|
11814
|
+
break;
|
|
11815
|
+
}
|
|
11816
|
+
case "contentEncoding:base64": {
|
|
11817
|
+
res.contentEncoding = "base64";
|
|
11818
|
+
break;
|
|
11819
|
+
}
|
|
11820
|
+
case "pattern:zod": {
|
|
11821
|
+
addPattern3(res, zodPatterns3.base64, check.message, refs);
|
|
11822
|
+
break;
|
|
11823
|
+
}
|
|
11824
|
+
}
|
|
11825
|
+
break;
|
|
11826
|
+
}
|
|
11827
|
+
case "nanoid": {
|
|
11828
|
+
addPattern3(res, zodPatterns3.nanoid, check.message, refs);
|
|
11829
|
+
}
|
|
11830
|
+
}
|
|
11831
|
+
}
|
|
11832
|
+
}
|
|
11833
|
+
return res;
|
|
11834
|
+
}
|
|
11835
|
+
function escapeLiteralCheckValue3(literal7, refs) {
|
|
11836
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric3(literal7) : literal7;
|
|
11837
|
+
}
|
|
11838
|
+
var ALPHA_NUMERIC3 = new Set(
|
|
11839
|
+
"ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789"
|
|
11840
|
+
);
|
|
11841
|
+
function escapeNonAlphaNumeric3(source) {
|
|
11842
|
+
let result = "";
|
|
11843
|
+
for (let i = 0; i < source.length; i++) {
|
|
11844
|
+
if (!ALPHA_NUMERIC3.has(source[i])) {
|
|
11845
|
+
result += "\\";
|
|
11846
|
+
}
|
|
11847
|
+
result += source[i];
|
|
11848
|
+
}
|
|
11849
|
+
return result;
|
|
11850
|
+
}
|
|
11851
|
+
function addFormat3(schema, value, message, refs) {
|
|
11852
|
+
var _a21;
|
|
11853
|
+
if (schema.format || ((_a21 = schema.anyOf) == null ? void 0 : _a21.some((x) => x.format))) {
|
|
11854
|
+
if (!schema.anyOf) {
|
|
11855
|
+
schema.anyOf = [];
|
|
11856
|
+
}
|
|
11857
|
+
if (schema.format) {
|
|
11858
|
+
schema.anyOf.push({
|
|
11859
|
+
format: schema.format
|
|
11860
|
+
});
|
|
11861
|
+
delete schema.format;
|
|
11862
|
+
}
|
|
11863
|
+
schema.anyOf.push({
|
|
11864
|
+
format: value,
|
|
11865
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
11866
|
+
});
|
|
11867
|
+
} else {
|
|
11868
|
+
schema.format = value;
|
|
11869
|
+
}
|
|
11870
|
+
}
|
|
11871
|
+
function addPattern3(schema, regex, message, refs) {
|
|
11872
|
+
var _a21;
|
|
11873
|
+
if (schema.pattern || ((_a21 = schema.allOf) == null ? void 0 : _a21.some((x) => x.pattern))) {
|
|
11874
|
+
if (!schema.allOf) {
|
|
11875
|
+
schema.allOf = [];
|
|
11876
|
+
}
|
|
11877
|
+
if (schema.pattern) {
|
|
11878
|
+
schema.allOf.push({
|
|
11879
|
+
pattern: schema.pattern
|
|
11880
|
+
});
|
|
11881
|
+
delete schema.pattern;
|
|
11882
|
+
}
|
|
11883
|
+
schema.allOf.push({
|
|
11884
|
+
pattern: stringifyRegExpWithFlags3(regex, refs),
|
|
11885
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
11886
|
+
});
|
|
11887
|
+
} else {
|
|
11888
|
+
schema.pattern = stringifyRegExpWithFlags3(regex, refs);
|
|
11889
|
+
}
|
|
11890
|
+
}
|
|
11891
|
+
function stringifyRegExpWithFlags3(regex, refs) {
|
|
11892
|
+
var _a21;
|
|
11893
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
11894
|
+
return regex.source;
|
|
11895
|
+
}
|
|
11896
|
+
const flags = {
|
|
11897
|
+
i: regex.flags.includes("i"),
|
|
11898
|
+
// Case-insensitive
|
|
11899
|
+
m: regex.flags.includes("m"),
|
|
11900
|
+
// `^` and `$` matches adjacent to newline characters
|
|
11901
|
+
s: regex.flags.includes("s")
|
|
11902
|
+
// `.` matches newlines
|
|
11903
|
+
};
|
|
11904
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
11905
|
+
let pattern = "";
|
|
11906
|
+
let isEscaped = false;
|
|
11907
|
+
let inCharGroup = false;
|
|
11908
|
+
let inCharRange = false;
|
|
11909
|
+
for (let i = 0; i < source.length; i++) {
|
|
11910
|
+
if (isEscaped) {
|
|
11911
|
+
pattern += source[i];
|
|
11912
|
+
isEscaped = false;
|
|
11913
|
+
continue;
|
|
11914
|
+
}
|
|
11915
|
+
if (flags.i) {
|
|
11916
|
+
if (inCharGroup) {
|
|
11917
|
+
if (source[i].match(/[a-z]/)) {
|
|
11918
|
+
if (inCharRange) {
|
|
11919
|
+
pattern += source[i];
|
|
11920
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
11921
|
+
inCharRange = false;
|
|
11922
|
+
} else if (source[i + 1] === "-" && ((_a21 = source[i + 2]) == null ? void 0 : _a21.match(/[a-z]/))) {
|
|
11923
|
+
pattern += source[i];
|
|
11924
|
+
inCharRange = true;
|
|
11925
|
+
} else {
|
|
11926
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
11927
|
+
}
|
|
11928
|
+
continue;
|
|
11929
|
+
}
|
|
11930
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
11931
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
11932
|
+
continue;
|
|
11933
|
+
}
|
|
11934
|
+
}
|
|
11935
|
+
if (flags.m) {
|
|
11936
|
+
if (source[i] === "^") {
|
|
11937
|
+
pattern += `(^|(?<=[\r
|
|
11938
|
+
]))`;
|
|
11939
|
+
continue;
|
|
11940
|
+
} else if (source[i] === "$") {
|
|
11941
|
+
pattern += `($|(?=[\r
|
|
11942
|
+
]))`;
|
|
11943
|
+
continue;
|
|
11944
|
+
}
|
|
11945
|
+
}
|
|
11946
|
+
if (flags.s && source[i] === ".") {
|
|
11947
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
11948
|
+
` : `[${source[i]}\r
|
|
11949
|
+
]`;
|
|
11950
|
+
continue;
|
|
11951
|
+
}
|
|
11952
|
+
pattern += source[i];
|
|
11953
|
+
if (source[i] === "\\") {
|
|
11954
|
+
isEscaped = true;
|
|
11955
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
11956
|
+
inCharGroup = false;
|
|
11957
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
11958
|
+
inCharGroup = true;
|
|
11959
|
+
}
|
|
11960
|
+
}
|
|
11961
|
+
return pattern;
|
|
11962
|
+
}
|
|
11963
|
+
function parseRecordDef3(def, refs) {
|
|
11964
|
+
var _a21, _b8, _c, _d, _e, _f;
|
|
11965
|
+
const schema = {
|
|
11966
|
+
type: "object",
|
|
11967
|
+
additionalProperties: (_a21 = parseDef3(def.valueType._def, {
|
|
11968
|
+
...refs,
|
|
11969
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
11970
|
+
})) != null ? _a21 : refs.allowedAdditionalProperties
|
|
11971
|
+
};
|
|
11972
|
+
if (((_b8 = def.keyType) == null ? void 0 : _b8._def.typeName) === ZodFirstPartyTypeKind$1.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
11973
|
+
const { type, ...keyType } = parseStringDef3(def.keyType._def, refs);
|
|
11974
|
+
return {
|
|
11975
|
+
...schema,
|
|
11976
|
+
propertyNames: keyType
|
|
11977
|
+
};
|
|
11978
|
+
} else if (((_d = def.keyType) == null ? void 0 : _d._def.typeName) === ZodFirstPartyTypeKind$1.ZodEnum) {
|
|
11979
|
+
return {
|
|
11980
|
+
...schema,
|
|
11981
|
+
propertyNames: {
|
|
11982
|
+
enum: def.keyType._def.values
|
|
11983
|
+
}
|
|
11984
|
+
};
|
|
11985
|
+
} else if (((_e = def.keyType) == null ? void 0 : _e._def.typeName) === ZodFirstPartyTypeKind$1.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind$1.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? void 0 : _f.length)) {
|
|
11986
|
+
const { type, ...keyType } = parseBrandedDef3(
|
|
11987
|
+
def.keyType._def,
|
|
11988
|
+
refs
|
|
11989
|
+
);
|
|
11990
|
+
return {
|
|
11991
|
+
...schema,
|
|
11992
|
+
propertyNames: keyType
|
|
11993
|
+
};
|
|
11994
|
+
}
|
|
11995
|
+
return schema;
|
|
11996
|
+
}
|
|
11997
|
+
function parseMapDef3(def, refs) {
|
|
11998
|
+
if (refs.mapStrategy === "record") {
|
|
11999
|
+
return parseRecordDef3(def, refs);
|
|
12000
|
+
}
|
|
12001
|
+
const keys = parseDef3(def.keyType._def, {
|
|
12002
|
+
...refs,
|
|
12003
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
12004
|
+
}) || parseAnyDef3();
|
|
12005
|
+
const values = parseDef3(def.valueType._def, {
|
|
12006
|
+
...refs,
|
|
12007
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
12008
|
+
}) || parseAnyDef3();
|
|
12009
|
+
return {
|
|
12010
|
+
type: "array",
|
|
12011
|
+
maxItems: 125,
|
|
12012
|
+
items: {
|
|
12013
|
+
type: "array",
|
|
12014
|
+
items: [keys, values],
|
|
12015
|
+
minItems: 2,
|
|
12016
|
+
maxItems: 2
|
|
12017
|
+
}
|
|
12018
|
+
};
|
|
12019
|
+
}
|
|
12020
|
+
function parseNativeEnumDef3(def) {
|
|
12021
|
+
const object8 = def.values;
|
|
12022
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
12023
|
+
return typeof object8[object8[key]] !== "number";
|
|
12024
|
+
});
|
|
12025
|
+
const actualValues = actualKeys.map((key) => object8[key]);
|
|
12026
|
+
const parsedTypes = Array.from(
|
|
12027
|
+
new Set(actualValues.map((values) => typeof values))
|
|
12028
|
+
);
|
|
12029
|
+
return {
|
|
12030
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
12031
|
+
enum: actualValues
|
|
12032
|
+
};
|
|
12033
|
+
}
|
|
12034
|
+
function parseNeverDef3() {
|
|
12035
|
+
return { not: parseAnyDef3() };
|
|
12036
|
+
}
|
|
12037
|
+
function parseNullDef3() {
|
|
12038
|
+
return {
|
|
12039
|
+
type: "null"
|
|
12040
|
+
};
|
|
12041
|
+
}
|
|
12042
|
+
var primitiveMappings3 = {
|
|
12043
|
+
ZodString: "string",
|
|
12044
|
+
ZodNumber: "number",
|
|
12045
|
+
ZodBigInt: "integer",
|
|
12046
|
+
ZodBoolean: "boolean",
|
|
12047
|
+
ZodNull: "null"
|
|
12048
|
+
};
|
|
12049
|
+
function parseUnionDef3(def, refs) {
|
|
12050
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
12051
|
+
if (options.every(
|
|
12052
|
+
(x) => x._def.typeName in primitiveMappings3 && (!x._def.checks || !x._def.checks.length)
|
|
12053
|
+
)) {
|
|
12054
|
+
const types = options.reduce((types2, x) => {
|
|
12055
|
+
const type = primitiveMappings3[x._def.typeName];
|
|
12056
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
12057
|
+
}, []);
|
|
12058
|
+
return {
|
|
12059
|
+
type: types.length > 1 ? types : types[0]
|
|
12060
|
+
};
|
|
12061
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
12062
|
+
const types = options.reduce(
|
|
12063
|
+
(acc, x) => {
|
|
12064
|
+
const type = typeof x._def.value;
|
|
12065
|
+
switch (type) {
|
|
12066
|
+
case "string":
|
|
12067
|
+
case "number":
|
|
12068
|
+
case "boolean":
|
|
12069
|
+
return [...acc, type];
|
|
12070
|
+
case "bigint":
|
|
12071
|
+
return [...acc, "integer"];
|
|
12072
|
+
case "object":
|
|
12073
|
+
if (x._def.value === null) return [...acc, "null"];
|
|
12074
|
+
case "symbol":
|
|
12075
|
+
case "undefined":
|
|
12076
|
+
case "function":
|
|
12077
|
+
default:
|
|
12078
|
+
return acc;
|
|
12079
|
+
}
|
|
12080
|
+
},
|
|
12081
|
+
[]
|
|
12082
|
+
);
|
|
12083
|
+
if (types.length === options.length) {
|
|
12084
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
12085
|
+
return {
|
|
12086
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
12087
|
+
enum: options.reduce(
|
|
12088
|
+
(acc, x) => {
|
|
12089
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
12090
|
+
},
|
|
12091
|
+
[]
|
|
12092
|
+
)
|
|
12093
|
+
};
|
|
12094
|
+
}
|
|
12095
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
12096
|
+
return {
|
|
12097
|
+
type: "string",
|
|
12098
|
+
enum: options.reduce(
|
|
12099
|
+
(acc, x) => [
|
|
12100
|
+
...acc,
|
|
12101
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
12102
|
+
],
|
|
12103
|
+
[]
|
|
12104
|
+
)
|
|
12105
|
+
};
|
|
12106
|
+
}
|
|
12107
|
+
return asAnyOf3(def, refs);
|
|
12108
|
+
}
|
|
12109
|
+
var asAnyOf3 = (def, refs) => {
|
|
12110
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map(
|
|
12111
|
+
(x, i) => parseDef3(x._def, {
|
|
12112
|
+
...refs,
|
|
12113
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
12114
|
+
})
|
|
12115
|
+
).filter(
|
|
12116
|
+
(x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0)
|
|
12117
|
+
);
|
|
12118
|
+
return anyOf.length ? { anyOf } : void 0;
|
|
12119
|
+
};
|
|
12120
|
+
function parseNullableDef3(def, refs) {
|
|
12121
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(
|
|
12122
|
+
def.innerType._def.typeName
|
|
12123
|
+
) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
12124
|
+
return {
|
|
12125
|
+
type: [
|
|
12126
|
+
primitiveMappings3[def.innerType._def.typeName],
|
|
12127
|
+
"null"
|
|
12128
|
+
]
|
|
12129
|
+
};
|
|
12130
|
+
}
|
|
12131
|
+
const base = parseDef3(def.innerType._def, {
|
|
12132
|
+
...refs,
|
|
12133
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
12134
|
+
});
|
|
12135
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
12136
|
+
}
|
|
12137
|
+
function parseNumberDef3(def) {
|
|
12138
|
+
const res = {
|
|
12139
|
+
type: "number"
|
|
12140
|
+
};
|
|
12141
|
+
if (!def.checks) return res;
|
|
12142
|
+
for (const check of def.checks) {
|
|
12143
|
+
switch (check.kind) {
|
|
12144
|
+
case "int":
|
|
12145
|
+
res.type = "integer";
|
|
12146
|
+
break;
|
|
12147
|
+
case "min":
|
|
12148
|
+
if (check.inclusive) {
|
|
12149
|
+
res.minimum = check.value;
|
|
12150
|
+
} else {
|
|
12151
|
+
res.exclusiveMinimum = check.value;
|
|
12152
|
+
}
|
|
12153
|
+
break;
|
|
12154
|
+
case "max":
|
|
12155
|
+
if (check.inclusive) {
|
|
12156
|
+
res.maximum = check.value;
|
|
12157
|
+
} else {
|
|
12158
|
+
res.exclusiveMaximum = check.value;
|
|
12159
|
+
}
|
|
12160
|
+
break;
|
|
12161
|
+
case "multipleOf":
|
|
12162
|
+
res.multipleOf = check.value;
|
|
12163
|
+
break;
|
|
12164
|
+
}
|
|
12165
|
+
}
|
|
12166
|
+
return res;
|
|
12167
|
+
}
|
|
12168
|
+
function parseObjectDef3(def, refs) {
|
|
12169
|
+
const result = {
|
|
12170
|
+
type: "object",
|
|
12171
|
+
properties: {}
|
|
12172
|
+
};
|
|
12173
|
+
const required = [];
|
|
12174
|
+
const shape = def.shape();
|
|
12175
|
+
for (const propName in shape) {
|
|
12176
|
+
let propDef = shape[propName];
|
|
12177
|
+
if (propDef === void 0 || propDef._def === void 0) {
|
|
12178
|
+
continue;
|
|
12179
|
+
}
|
|
12180
|
+
const propOptional = safeIsOptional3(propDef);
|
|
12181
|
+
const parsedDef = parseDef3(propDef._def, {
|
|
12182
|
+
...refs,
|
|
12183
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
12184
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
12185
|
+
});
|
|
12186
|
+
if (parsedDef === void 0) {
|
|
12187
|
+
continue;
|
|
12188
|
+
}
|
|
12189
|
+
result.properties[propName] = parsedDef;
|
|
12190
|
+
if (!propOptional) {
|
|
12191
|
+
required.push(propName);
|
|
12192
|
+
}
|
|
12193
|
+
}
|
|
12194
|
+
if (required.length) {
|
|
12195
|
+
result.required = required;
|
|
12196
|
+
}
|
|
12197
|
+
const additionalProperties = decideAdditionalProperties3(def, refs);
|
|
12198
|
+
if (additionalProperties !== void 0) {
|
|
12199
|
+
result.additionalProperties = additionalProperties;
|
|
12200
|
+
}
|
|
12201
|
+
return result;
|
|
12202
|
+
}
|
|
12203
|
+
function decideAdditionalProperties3(def, refs) {
|
|
12204
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
12205
|
+
return parseDef3(def.catchall._def, {
|
|
12206
|
+
...refs,
|
|
12207
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
12208
|
+
});
|
|
12209
|
+
}
|
|
12210
|
+
switch (def.unknownKeys) {
|
|
12211
|
+
case "passthrough":
|
|
12212
|
+
return refs.allowedAdditionalProperties;
|
|
12213
|
+
case "strict":
|
|
12214
|
+
return refs.rejectedAdditionalProperties;
|
|
12215
|
+
case "strip":
|
|
12216
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
12217
|
+
}
|
|
12218
|
+
}
|
|
12219
|
+
function safeIsOptional3(schema) {
|
|
12220
|
+
try {
|
|
12221
|
+
return schema.isOptional();
|
|
12222
|
+
} catch (e2) {
|
|
12223
|
+
return true;
|
|
12224
|
+
}
|
|
12225
|
+
}
|
|
12226
|
+
var parseOptionalDef3 = (def, refs) => {
|
|
12227
|
+
var _a21;
|
|
12228
|
+
if (refs.currentPath.toString() === ((_a21 = refs.propertyPath) == null ? void 0 : _a21.toString())) {
|
|
12229
|
+
return parseDef3(def.innerType._def, refs);
|
|
12230
|
+
}
|
|
12231
|
+
const innerSchema = parseDef3(def.innerType._def, {
|
|
12232
|
+
...refs,
|
|
12233
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
12234
|
+
});
|
|
12235
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef3() }, innerSchema] } : parseAnyDef3();
|
|
12236
|
+
};
|
|
12237
|
+
var parsePipelineDef3 = (def, refs) => {
|
|
12238
|
+
if (refs.pipeStrategy === "input") {
|
|
12239
|
+
return parseDef3(def.in._def, refs);
|
|
12240
|
+
} else if (refs.pipeStrategy === "output") {
|
|
12241
|
+
return parseDef3(def.out._def, refs);
|
|
12242
|
+
}
|
|
12243
|
+
const a = parseDef3(def.in._def, {
|
|
12244
|
+
...refs,
|
|
12245
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
12246
|
+
});
|
|
12247
|
+
const b = parseDef3(def.out._def, {
|
|
12248
|
+
...refs,
|
|
12249
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
12250
|
+
});
|
|
12251
|
+
return {
|
|
12252
|
+
allOf: [a, b].filter((x) => x !== void 0)
|
|
12253
|
+
};
|
|
12254
|
+
};
|
|
12255
|
+
function parsePromiseDef3(def, refs) {
|
|
12256
|
+
return parseDef3(def.type._def, refs);
|
|
12257
|
+
}
|
|
12258
|
+
function parseSetDef3(def, refs) {
|
|
12259
|
+
const items = parseDef3(def.valueType._def, {
|
|
12260
|
+
...refs,
|
|
12261
|
+
currentPath: [...refs.currentPath, "items"]
|
|
12262
|
+
});
|
|
12263
|
+
const schema = {
|
|
12264
|
+
type: "array",
|
|
12265
|
+
uniqueItems: true,
|
|
12266
|
+
items
|
|
12267
|
+
};
|
|
12268
|
+
if (def.minSize) {
|
|
12269
|
+
schema.minItems = def.minSize.value;
|
|
12270
|
+
}
|
|
12271
|
+
if (def.maxSize) {
|
|
12272
|
+
schema.maxItems = def.maxSize.value;
|
|
12273
|
+
}
|
|
12274
|
+
return schema;
|
|
12275
|
+
}
|
|
12276
|
+
function parseTupleDef3(def, refs) {
|
|
12277
|
+
if (def.rest) {
|
|
12278
|
+
return {
|
|
12279
|
+
type: "array",
|
|
12280
|
+
minItems: def.items.length,
|
|
12281
|
+
items: def.items.map(
|
|
12282
|
+
(x, i) => parseDef3(x._def, {
|
|
12283
|
+
...refs,
|
|
12284
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
12285
|
+
})
|
|
12286
|
+
).reduce(
|
|
12287
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
12288
|
+
[]
|
|
12289
|
+
),
|
|
12290
|
+
additionalItems: parseDef3(def.rest._def, {
|
|
12291
|
+
...refs,
|
|
12292
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
12293
|
+
})
|
|
12294
|
+
};
|
|
12295
|
+
} else {
|
|
12296
|
+
return {
|
|
12297
|
+
type: "array",
|
|
12298
|
+
minItems: def.items.length,
|
|
12299
|
+
maxItems: def.items.length,
|
|
12300
|
+
items: def.items.map(
|
|
12301
|
+
(x, i) => parseDef3(x._def, {
|
|
12302
|
+
...refs,
|
|
12303
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
12304
|
+
})
|
|
12305
|
+
).reduce(
|
|
12306
|
+
(acc, x) => x === void 0 ? acc : [...acc, x],
|
|
12307
|
+
[]
|
|
12308
|
+
)
|
|
12309
|
+
};
|
|
12310
|
+
}
|
|
12311
|
+
}
|
|
12312
|
+
function parseUndefinedDef3() {
|
|
12313
|
+
return {
|
|
12314
|
+
not: parseAnyDef3()
|
|
12315
|
+
};
|
|
12316
|
+
}
|
|
12317
|
+
function parseUnknownDef3() {
|
|
12318
|
+
return parseAnyDef3();
|
|
12319
|
+
}
|
|
12320
|
+
var parseReadonlyDef3 = (def, refs) => {
|
|
12321
|
+
return parseDef3(def.innerType._def, refs);
|
|
12322
|
+
};
|
|
12323
|
+
var selectParser3 = (def, typeName, refs) => {
|
|
12324
|
+
switch (typeName) {
|
|
12325
|
+
case ZodFirstPartyTypeKind$1.ZodString:
|
|
12326
|
+
return parseStringDef3(def, refs);
|
|
12327
|
+
case ZodFirstPartyTypeKind$1.ZodNumber:
|
|
12328
|
+
return parseNumberDef3(def);
|
|
12329
|
+
case ZodFirstPartyTypeKind$1.ZodObject:
|
|
12330
|
+
return parseObjectDef3(def, refs);
|
|
12331
|
+
case ZodFirstPartyTypeKind$1.ZodBigInt:
|
|
12332
|
+
return parseBigintDef3(def);
|
|
12333
|
+
case ZodFirstPartyTypeKind$1.ZodBoolean:
|
|
12334
|
+
return parseBooleanDef3();
|
|
12335
|
+
case ZodFirstPartyTypeKind$1.ZodDate:
|
|
12336
|
+
return parseDateDef3(def, refs);
|
|
12337
|
+
case ZodFirstPartyTypeKind$1.ZodUndefined:
|
|
12338
|
+
return parseUndefinedDef3();
|
|
12339
|
+
case ZodFirstPartyTypeKind$1.ZodNull:
|
|
12340
|
+
return parseNullDef3();
|
|
12341
|
+
case ZodFirstPartyTypeKind$1.ZodArray:
|
|
12342
|
+
return parseArrayDef3(def, refs);
|
|
12343
|
+
case ZodFirstPartyTypeKind$1.ZodUnion:
|
|
12344
|
+
case ZodFirstPartyTypeKind$1.ZodDiscriminatedUnion:
|
|
12345
|
+
return parseUnionDef3(def, refs);
|
|
12346
|
+
case ZodFirstPartyTypeKind$1.ZodIntersection:
|
|
12347
|
+
return parseIntersectionDef3(def, refs);
|
|
12348
|
+
case ZodFirstPartyTypeKind$1.ZodTuple:
|
|
12349
|
+
return parseTupleDef3(def, refs);
|
|
12350
|
+
case ZodFirstPartyTypeKind$1.ZodRecord:
|
|
12351
|
+
return parseRecordDef3(def, refs);
|
|
12352
|
+
case ZodFirstPartyTypeKind$1.ZodLiteral:
|
|
12353
|
+
return parseLiteralDef3(def);
|
|
12354
|
+
case ZodFirstPartyTypeKind$1.ZodEnum:
|
|
12355
|
+
return parseEnumDef3(def);
|
|
12356
|
+
case ZodFirstPartyTypeKind$1.ZodNativeEnum:
|
|
12357
|
+
return parseNativeEnumDef3(def);
|
|
12358
|
+
case ZodFirstPartyTypeKind$1.ZodNullable:
|
|
12359
|
+
return parseNullableDef3(def, refs);
|
|
12360
|
+
case ZodFirstPartyTypeKind$1.ZodOptional:
|
|
12361
|
+
return parseOptionalDef3(def, refs);
|
|
12362
|
+
case ZodFirstPartyTypeKind$1.ZodMap:
|
|
12363
|
+
return parseMapDef3(def, refs);
|
|
12364
|
+
case ZodFirstPartyTypeKind$1.ZodSet:
|
|
12365
|
+
return parseSetDef3(def, refs);
|
|
12366
|
+
case ZodFirstPartyTypeKind$1.ZodLazy:
|
|
12367
|
+
return () => def.getter()._def;
|
|
12368
|
+
case ZodFirstPartyTypeKind$1.ZodPromise:
|
|
12369
|
+
return parsePromiseDef3(def, refs);
|
|
12370
|
+
case ZodFirstPartyTypeKind$1.ZodNaN:
|
|
12371
|
+
case ZodFirstPartyTypeKind$1.ZodNever:
|
|
12372
|
+
return parseNeverDef3();
|
|
12373
|
+
case ZodFirstPartyTypeKind$1.ZodEffects:
|
|
12374
|
+
return parseEffectsDef3(def, refs);
|
|
12375
|
+
case ZodFirstPartyTypeKind$1.ZodAny:
|
|
12376
|
+
return parseAnyDef3();
|
|
12377
|
+
case ZodFirstPartyTypeKind$1.ZodUnknown:
|
|
12378
|
+
return parseUnknownDef3();
|
|
12379
|
+
case ZodFirstPartyTypeKind$1.ZodDefault:
|
|
12380
|
+
return parseDefaultDef3(def, refs);
|
|
12381
|
+
case ZodFirstPartyTypeKind$1.ZodBranded:
|
|
12382
|
+
return parseBrandedDef3(def, refs);
|
|
12383
|
+
case ZodFirstPartyTypeKind$1.ZodReadonly:
|
|
12384
|
+
return parseReadonlyDef3(def, refs);
|
|
12385
|
+
case ZodFirstPartyTypeKind$1.ZodCatch:
|
|
12386
|
+
return parseCatchDef3(def, refs);
|
|
12387
|
+
case ZodFirstPartyTypeKind$1.ZodPipeline:
|
|
12388
|
+
return parsePipelineDef3(def, refs);
|
|
12389
|
+
case ZodFirstPartyTypeKind$1.ZodFunction:
|
|
12390
|
+
case ZodFirstPartyTypeKind$1.ZodVoid:
|
|
12391
|
+
case ZodFirstPartyTypeKind$1.ZodSymbol:
|
|
12392
|
+
return void 0;
|
|
12393
|
+
default:
|
|
12394
|
+
return /* @__PURE__ */ ((_) => void 0)();
|
|
12395
|
+
}
|
|
12396
|
+
};
|
|
12397
|
+
function parseDef3(def, refs, forceResolution = false) {
|
|
12398
|
+
var _a21;
|
|
12399
|
+
const seenItem = refs.seen.get(def);
|
|
12400
|
+
if (refs.override) {
|
|
12401
|
+
const overrideResult = (_a21 = refs.override) == null ? void 0 : _a21.call(
|
|
12402
|
+
refs,
|
|
12403
|
+
def,
|
|
12404
|
+
refs,
|
|
12405
|
+
seenItem,
|
|
12406
|
+
forceResolution
|
|
12407
|
+
);
|
|
12408
|
+
if (overrideResult !== ignoreOverride3) {
|
|
12409
|
+
return overrideResult;
|
|
12410
|
+
}
|
|
12411
|
+
}
|
|
12412
|
+
if (seenItem && !forceResolution) {
|
|
12413
|
+
const seenSchema = get$ref3(seenItem, refs);
|
|
12414
|
+
if (seenSchema !== void 0) {
|
|
12415
|
+
return seenSchema;
|
|
12416
|
+
}
|
|
12417
|
+
}
|
|
12418
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: void 0 };
|
|
12419
|
+
refs.seen.set(def, newItem);
|
|
12420
|
+
const jsonSchemaOrGetter = selectParser3(def, def.typeName, refs);
|
|
12421
|
+
const jsonSchema22 = typeof jsonSchemaOrGetter === "function" ? parseDef3(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
12422
|
+
if (jsonSchema22) {
|
|
12423
|
+
addMeta3(def, refs, jsonSchema22);
|
|
12424
|
+
}
|
|
12425
|
+
if (refs.postProcess) {
|
|
12426
|
+
const postProcessResult = refs.postProcess(jsonSchema22, def, refs);
|
|
12427
|
+
newItem.jsonSchema = jsonSchema22;
|
|
12428
|
+
return postProcessResult;
|
|
12429
|
+
}
|
|
12430
|
+
newItem.jsonSchema = jsonSchema22;
|
|
12431
|
+
return jsonSchema22;
|
|
12432
|
+
}
|
|
12433
|
+
var get$ref3 = (item, refs) => {
|
|
12434
|
+
switch (refs.$refStrategy) {
|
|
12435
|
+
case "root":
|
|
12436
|
+
return { $ref: item.path.join("/") };
|
|
12437
|
+
case "relative":
|
|
12438
|
+
return { $ref: getRelativePath3(refs.currentPath, item.path) };
|
|
12439
|
+
case "none":
|
|
12440
|
+
case "seen": {
|
|
12441
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
12442
|
+
console.warn(
|
|
12443
|
+
`Recursive reference detected at ${refs.currentPath.join(
|
|
12444
|
+
"/"
|
|
12445
|
+
)}! Defaulting to any`
|
|
12446
|
+
);
|
|
12447
|
+
return parseAnyDef3();
|
|
12448
|
+
}
|
|
12449
|
+
return refs.$refStrategy === "seen" ? parseAnyDef3() : void 0;
|
|
12450
|
+
}
|
|
12451
|
+
}
|
|
12452
|
+
};
|
|
12453
|
+
var addMeta3 = (def, refs, jsonSchema22) => {
|
|
12454
|
+
if (def.description) {
|
|
12455
|
+
jsonSchema22.description = def.description;
|
|
12456
|
+
}
|
|
12457
|
+
return jsonSchema22;
|
|
12458
|
+
};
|
|
12459
|
+
var getRefs3 = (options) => {
|
|
12460
|
+
const _options = getDefaultOptions3(options);
|
|
12461
|
+
const currentPath = _options.name !== void 0 ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
12462
|
+
return {
|
|
12463
|
+
..._options,
|
|
12464
|
+
currentPath,
|
|
12465
|
+
propertyPath: void 0,
|
|
12466
|
+
seen: new Map(
|
|
12467
|
+
Object.entries(_options.definitions).map(([name21, def]) => [
|
|
12468
|
+
def._def,
|
|
12469
|
+
{
|
|
12470
|
+
def: def._def,
|
|
12471
|
+
path: [..._options.basePath, _options.definitionPath, name21],
|
|
12472
|
+
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
12473
|
+
jsonSchema: void 0
|
|
12474
|
+
}
|
|
12475
|
+
])
|
|
12476
|
+
)
|
|
12477
|
+
};
|
|
12478
|
+
};
|
|
12479
|
+
var zodToJsonSchema4 = (schema, options) => {
|
|
12480
|
+
var _a21;
|
|
12481
|
+
const refs = getRefs3(options);
|
|
12482
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
12483
|
+
(acc, [name26, schema2]) => {
|
|
12484
|
+
var _a26;
|
|
12485
|
+
return {
|
|
12486
|
+
...acc,
|
|
12487
|
+
[name26]: (_a26 = parseDef3(
|
|
12488
|
+
schema2._def,
|
|
12489
|
+
{
|
|
12490
|
+
...refs,
|
|
12491
|
+
currentPath: [...refs.basePath, refs.definitionPath, name26]
|
|
12492
|
+
},
|
|
12493
|
+
true
|
|
12494
|
+
)) != null ? _a26 : parseAnyDef3()
|
|
12495
|
+
};
|
|
12496
|
+
},
|
|
12497
|
+
{}
|
|
12498
|
+
) : void 0;
|
|
12499
|
+
const name21 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
12500
|
+
const main = (_a21 = parseDef3(
|
|
12501
|
+
schema._def,
|
|
12502
|
+
name21 === void 0 ? refs : {
|
|
12503
|
+
...refs,
|
|
12504
|
+
currentPath: [...refs.basePath, refs.definitionPath, name21]
|
|
12505
|
+
},
|
|
12506
|
+
false
|
|
12507
|
+
)) != null ? _a21 : parseAnyDef3();
|
|
12508
|
+
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
12509
|
+
if (title !== void 0) {
|
|
12510
|
+
main.title = title;
|
|
12511
|
+
}
|
|
12512
|
+
const combined = name21 === void 0 ? definitions ? {
|
|
12513
|
+
...main,
|
|
12514
|
+
[refs.definitionPath]: definitions
|
|
12515
|
+
} : main : {
|
|
12516
|
+
$ref: [
|
|
12517
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
12518
|
+
refs.definitionPath,
|
|
12519
|
+
name21
|
|
12520
|
+
].join("/"),
|
|
12521
|
+
[refs.definitionPath]: {
|
|
12522
|
+
...definitions,
|
|
12523
|
+
[name21]: main
|
|
12524
|
+
}
|
|
12525
|
+
};
|
|
12526
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
12527
|
+
return combined;
|
|
12528
|
+
};
|
|
12529
|
+
var zod_to_json_schema_default2 = zodToJsonSchema4;
|
|
12530
|
+
function zod3Schema2(zodSchema22, options) {
|
|
12531
|
+
var _a21;
|
|
12532
|
+
const useReferences = (_a21 = void 0 ) != null ? _a21 : false;
|
|
12533
|
+
return jsonSchema3(
|
|
12534
|
+
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
12535
|
+
() => zod_to_json_schema_default2(zodSchema22, {
|
|
12536
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
12537
|
+
}),
|
|
12538
|
+
{
|
|
12539
|
+
validate: async (value) => {
|
|
12540
|
+
const result = await zodSchema22.safeParseAsync(value);
|
|
12541
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
12542
|
+
}
|
|
12543
|
+
}
|
|
12544
|
+
);
|
|
12545
|
+
}
|
|
12546
|
+
function zod4Schema2(zodSchema22, options) {
|
|
12547
|
+
var _a21;
|
|
12548
|
+
const useReferences = (_a21 = void 0 ) != null ? _a21 : false;
|
|
12549
|
+
return jsonSchema3(
|
|
12550
|
+
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
12551
|
+
() => z104.toJSONSchema(zodSchema22, {
|
|
12552
|
+
target: "draft-7",
|
|
12553
|
+
io: "output",
|
|
12554
|
+
reused: useReferences ? "ref" : "inline"
|
|
12555
|
+
}),
|
|
12556
|
+
{
|
|
12557
|
+
validate: async (value) => {
|
|
12558
|
+
const result = await z104.safeParseAsync(zodSchema22, value);
|
|
12559
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
12560
|
+
}
|
|
12561
|
+
}
|
|
12562
|
+
);
|
|
12563
|
+
}
|
|
12564
|
+
function isZod4Schema2(zodSchema22) {
|
|
12565
|
+
return "_zod" in zodSchema22;
|
|
12566
|
+
}
|
|
12567
|
+
function zodSchema3(zodSchema22, options) {
|
|
12568
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
12569
|
+
return zod4Schema2(zodSchema22);
|
|
12570
|
+
} else {
|
|
12571
|
+
return zod3Schema2(zodSchema22);
|
|
12572
|
+
}
|
|
12573
|
+
}
|
|
12574
|
+
var schemaSymbol3 = Symbol.for("vercel.ai.schema");
|
|
12575
|
+
function jsonSchema3(jsonSchema22, {
|
|
12576
|
+
validate
|
|
12577
|
+
} = {}) {
|
|
12578
|
+
return {
|
|
12579
|
+
[schemaSymbol3]: true,
|
|
12580
|
+
_type: void 0,
|
|
12581
|
+
// should never be used directly
|
|
12582
|
+
[validatorSymbol3]: true,
|
|
12583
|
+
get jsonSchema() {
|
|
12584
|
+
if (typeof jsonSchema22 === "function") {
|
|
12585
|
+
jsonSchema22 = jsonSchema22();
|
|
12586
|
+
}
|
|
12587
|
+
return jsonSchema22;
|
|
12588
|
+
},
|
|
12589
|
+
validate
|
|
12590
|
+
};
|
|
12591
|
+
}
|
|
12592
|
+
function isSchema3(value) {
|
|
12593
|
+
return typeof value === "object" && value !== null && schemaSymbol3 in value && value[schemaSymbol3] === true && "jsonSchema" in value && "validate" in value;
|
|
12594
|
+
}
|
|
12595
|
+
function asSchema3(schema) {
|
|
12596
|
+
return schema == null ? jsonSchema3({
|
|
12597
|
+
properties: {},
|
|
12598
|
+
additionalProperties: false
|
|
12599
|
+
}) : isSchema3(schema) ? schema : typeof schema === "function" ? schema() : zodSchema3(schema);
|
|
12600
|
+
}
|
|
12601
|
+
var __defProp4 = Object.defineProperty;
|
|
12602
|
+
var __export4 = (target, all) => {
|
|
12603
|
+
for (var name172 in all)
|
|
12604
|
+
__defProp4(target, name172, { get: all[name172], enumerable: true });
|
|
12605
|
+
};
|
|
12606
|
+
var name74 = "AI_NoObjectGeneratedError";
|
|
12607
|
+
var marker75 = `vercel.ai.error.${name74}`;
|
|
12608
|
+
var symbol75 = Symbol.for(marker75);
|
|
12609
|
+
var _a75;
|
|
12610
|
+
var NoObjectGeneratedError3 = class extends AISDKError2 {
|
|
12611
|
+
constructor({
|
|
12612
|
+
message = "No object generated.",
|
|
12613
|
+
cause,
|
|
12614
|
+
text: text22,
|
|
12615
|
+
response,
|
|
12616
|
+
usage,
|
|
12617
|
+
finishReason
|
|
12618
|
+
}) {
|
|
12619
|
+
super({ name: name74, message, cause });
|
|
12620
|
+
this[_a75] = true;
|
|
12621
|
+
this.text = text22;
|
|
12622
|
+
this.response = response;
|
|
12623
|
+
this.usage = usage;
|
|
12624
|
+
this.finishReason = finishReason;
|
|
12625
|
+
}
|
|
12626
|
+
static isInstance(error) {
|
|
12627
|
+
return AISDKError2.hasMarker(error, marker75);
|
|
12628
|
+
}
|
|
12629
|
+
};
|
|
12630
|
+
_a75 = symbol75;
|
|
12631
|
+
var dataContentSchema3 = z104.union([
|
|
12632
|
+
z104.string(),
|
|
12633
|
+
z104.instanceof(Uint8Array),
|
|
12634
|
+
z104.instanceof(ArrayBuffer),
|
|
12635
|
+
z104.custom(
|
|
12636
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
12637
|
+
(value) => {
|
|
12638
|
+
var _a172, _b8;
|
|
12639
|
+
return (_b8 = (_a172 = globalThis.Buffer) == null ? void 0 : _a172.isBuffer(value)) != null ? _b8 : false;
|
|
12640
|
+
},
|
|
12641
|
+
{ message: "Must be a Buffer" }
|
|
12642
|
+
)
|
|
12643
|
+
]);
|
|
12644
|
+
var jsonValueSchema3 = z104.lazy(
|
|
12645
|
+
() => z104.union([
|
|
12646
|
+
z104.null(),
|
|
12647
|
+
z104.string(),
|
|
12648
|
+
z104.number(),
|
|
12649
|
+
z104.boolean(),
|
|
12650
|
+
z104.record(z104.string(), jsonValueSchema3),
|
|
12651
|
+
z104.array(jsonValueSchema3)
|
|
12652
|
+
])
|
|
12653
|
+
);
|
|
12654
|
+
var providerMetadataSchema3 = z104.record(
|
|
12655
|
+
z104.string(),
|
|
12656
|
+
z104.record(z104.string(), jsonValueSchema3)
|
|
12657
|
+
);
|
|
12658
|
+
var textPartSchema3 = z104.object({
|
|
12659
|
+
type: z104.literal("text"),
|
|
12660
|
+
text: z104.string(),
|
|
12661
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12662
|
+
});
|
|
12663
|
+
var imagePartSchema3 = z104.object({
|
|
12664
|
+
type: z104.literal("image"),
|
|
12665
|
+
image: z104.union([dataContentSchema3, z104.instanceof(URL)]),
|
|
12666
|
+
mediaType: z104.string().optional(),
|
|
12667
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12668
|
+
});
|
|
12669
|
+
var filePartSchema3 = z104.object({
|
|
12670
|
+
type: z104.literal("file"),
|
|
12671
|
+
data: z104.union([dataContentSchema3, z104.instanceof(URL)]),
|
|
12672
|
+
filename: z104.string().optional(),
|
|
12673
|
+
mediaType: z104.string(),
|
|
12674
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12675
|
+
});
|
|
12676
|
+
var reasoningPartSchema3 = z104.object({
|
|
12677
|
+
type: z104.literal("reasoning"),
|
|
12678
|
+
text: z104.string(),
|
|
12679
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12680
|
+
});
|
|
12681
|
+
var toolCallPartSchema3 = z104.object({
|
|
12682
|
+
type: z104.literal("tool-call"),
|
|
12683
|
+
toolCallId: z104.string(),
|
|
12684
|
+
toolName: z104.string(),
|
|
12685
|
+
input: z104.unknown(),
|
|
12686
|
+
providerOptions: providerMetadataSchema3.optional(),
|
|
12687
|
+
providerExecuted: z104.boolean().optional()
|
|
12688
|
+
});
|
|
12689
|
+
var outputSchema2 = z104.discriminatedUnion("type", [
|
|
12690
|
+
z104.object({
|
|
12691
|
+
type: z104.literal("text"),
|
|
12692
|
+
value: z104.string()
|
|
12693
|
+
}),
|
|
12694
|
+
z104.object({
|
|
12695
|
+
type: z104.literal("json"),
|
|
12696
|
+
value: jsonValueSchema3
|
|
12697
|
+
}),
|
|
12698
|
+
z104.object({
|
|
12699
|
+
type: z104.literal("error-text"),
|
|
12700
|
+
value: z104.string()
|
|
12701
|
+
}),
|
|
12702
|
+
z104.object({
|
|
12703
|
+
type: z104.literal("error-json"),
|
|
12704
|
+
value: jsonValueSchema3
|
|
12705
|
+
}),
|
|
12706
|
+
z104.object({
|
|
12707
|
+
type: z104.literal("content"),
|
|
12708
|
+
value: z104.array(
|
|
12709
|
+
z104.union([
|
|
12710
|
+
z104.object({
|
|
12711
|
+
type: z104.literal("text"),
|
|
12712
|
+
text: z104.string()
|
|
12713
|
+
}),
|
|
12714
|
+
z104.object({
|
|
12715
|
+
type: z104.literal("media"),
|
|
12716
|
+
data: z104.string(),
|
|
12717
|
+
mediaType: z104.string()
|
|
12718
|
+
})
|
|
12719
|
+
])
|
|
12720
|
+
)
|
|
12721
|
+
})
|
|
12722
|
+
]);
|
|
12723
|
+
var toolResultPartSchema3 = z104.object({
|
|
12724
|
+
type: z104.literal("tool-result"),
|
|
12725
|
+
toolCallId: z104.string(),
|
|
12726
|
+
toolName: z104.string(),
|
|
12727
|
+
output: outputSchema2,
|
|
12728
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12729
|
+
});
|
|
12730
|
+
var systemModelMessageSchema2 = z104.object(
|
|
12731
|
+
{
|
|
12732
|
+
role: z104.literal("system"),
|
|
12733
|
+
content: z104.string(),
|
|
12734
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12735
|
+
}
|
|
12736
|
+
);
|
|
12737
|
+
var userModelMessageSchema2 = z104.object({
|
|
12738
|
+
role: z104.literal("user"),
|
|
12739
|
+
content: z104.union([
|
|
12740
|
+
z104.string(),
|
|
12741
|
+
z104.array(z104.union([textPartSchema3, imagePartSchema3, filePartSchema3]))
|
|
12742
|
+
]),
|
|
12743
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12744
|
+
});
|
|
12745
|
+
var assistantModelMessageSchema2 = z104.object({
|
|
12746
|
+
role: z104.literal("assistant"),
|
|
12747
|
+
content: z104.union([
|
|
12748
|
+
z104.string(),
|
|
12749
|
+
z104.array(
|
|
12750
|
+
z104.union([
|
|
12751
|
+
textPartSchema3,
|
|
12752
|
+
filePartSchema3,
|
|
12753
|
+
reasoningPartSchema3,
|
|
12754
|
+
toolCallPartSchema3,
|
|
12755
|
+
toolResultPartSchema3
|
|
12756
|
+
])
|
|
12757
|
+
)
|
|
12758
|
+
]),
|
|
12759
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12760
|
+
});
|
|
12761
|
+
var toolModelMessageSchema2 = z104.object({
|
|
12762
|
+
role: z104.literal("tool"),
|
|
12763
|
+
content: z104.array(toolResultPartSchema3),
|
|
12764
|
+
providerOptions: providerMetadataSchema3.optional()
|
|
12765
|
+
});
|
|
12766
|
+
z104.union([
|
|
12767
|
+
systemModelMessageSchema2,
|
|
12768
|
+
userModelMessageSchema2,
|
|
12769
|
+
assistantModelMessageSchema2,
|
|
12770
|
+
toolModelMessageSchema2
|
|
12771
|
+
]);
|
|
12772
|
+
function stepCountIs(stepCount) {
|
|
12773
|
+
return ({ steps }) => steps.length === stepCount;
|
|
12774
|
+
}
|
|
12775
|
+
createIdGenerator3({
|
|
12776
|
+
prefix: "aitxt",
|
|
12777
|
+
size: 24
|
|
12778
|
+
});
|
|
12779
|
+
function fixJson3(input) {
|
|
12780
|
+
const stack = ["ROOT"];
|
|
12781
|
+
let lastValidIndex = -1;
|
|
12782
|
+
let literalStart = null;
|
|
12783
|
+
function processValueStart(char, i, swapState) {
|
|
12784
|
+
{
|
|
12785
|
+
switch (char) {
|
|
12786
|
+
case '"': {
|
|
12787
|
+
lastValidIndex = i;
|
|
12788
|
+
stack.pop();
|
|
12789
|
+
stack.push(swapState);
|
|
12790
|
+
stack.push("INSIDE_STRING");
|
|
12791
|
+
break;
|
|
12792
|
+
}
|
|
12793
|
+
case "f":
|
|
12794
|
+
case "t":
|
|
12795
|
+
case "n": {
|
|
12796
|
+
lastValidIndex = i;
|
|
12797
|
+
literalStart = i;
|
|
12798
|
+
stack.pop();
|
|
12799
|
+
stack.push(swapState);
|
|
12800
|
+
stack.push("INSIDE_LITERAL");
|
|
12801
|
+
break;
|
|
12802
|
+
}
|
|
12803
|
+
case "-": {
|
|
12804
|
+
stack.pop();
|
|
12805
|
+
stack.push(swapState);
|
|
12806
|
+
stack.push("INSIDE_NUMBER");
|
|
12807
|
+
break;
|
|
12808
|
+
}
|
|
12809
|
+
case "0":
|
|
12810
|
+
case "1":
|
|
12811
|
+
case "2":
|
|
12812
|
+
case "3":
|
|
12813
|
+
case "4":
|
|
12814
|
+
case "5":
|
|
12815
|
+
case "6":
|
|
12816
|
+
case "7":
|
|
12817
|
+
case "8":
|
|
12818
|
+
case "9": {
|
|
12819
|
+
lastValidIndex = i;
|
|
12820
|
+
stack.pop();
|
|
12821
|
+
stack.push(swapState);
|
|
12822
|
+
stack.push("INSIDE_NUMBER");
|
|
12823
|
+
break;
|
|
12824
|
+
}
|
|
12825
|
+
case "{": {
|
|
12826
|
+
lastValidIndex = i;
|
|
12827
|
+
stack.pop();
|
|
12828
|
+
stack.push(swapState);
|
|
12829
|
+
stack.push("INSIDE_OBJECT_START");
|
|
12830
|
+
break;
|
|
12831
|
+
}
|
|
12832
|
+
case "[": {
|
|
12833
|
+
lastValidIndex = i;
|
|
12834
|
+
stack.pop();
|
|
12835
|
+
stack.push(swapState);
|
|
12836
|
+
stack.push("INSIDE_ARRAY_START");
|
|
12837
|
+
break;
|
|
12838
|
+
}
|
|
12839
|
+
}
|
|
12840
|
+
}
|
|
12841
|
+
}
|
|
12842
|
+
function processAfterObjectValue(char, i) {
|
|
12843
|
+
switch (char) {
|
|
12844
|
+
case ",": {
|
|
12845
|
+
stack.pop();
|
|
12846
|
+
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
|
12847
|
+
break;
|
|
12848
|
+
}
|
|
12849
|
+
case "}": {
|
|
12850
|
+
lastValidIndex = i;
|
|
12851
|
+
stack.pop();
|
|
12852
|
+
break;
|
|
12853
|
+
}
|
|
12854
|
+
}
|
|
12855
|
+
}
|
|
12856
|
+
function processAfterArrayValue(char, i) {
|
|
12857
|
+
switch (char) {
|
|
12858
|
+
case ",": {
|
|
12859
|
+
stack.pop();
|
|
12860
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
12861
|
+
break;
|
|
12862
|
+
}
|
|
12863
|
+
case "]": {
|
|
12864
|
+
lastValidIndex = i;
|
|
12865
|
+
stack.pop();
|
|
12866
|
+
break;
|
|
12867
|
+
}
|
|
12868
|
+
}
|
|
12869
|
+
}
|
|
12870
|
+
for (let i = 0; i < input.length; i++) {
|
|
12871
|
+
const char = input[i];
|
|
12872
|
+
const currentState = stack[stack.length - 1];
|
|
12873
|
+
switch (currentState) {
|
|
12874
|
+
case "ROOT":
|
|
12875
|
+
processValueStart(char, i, "FINISH");
|
|
12876
|
+
break;
|
|
12877
|
+
case "INSIDE_OBJECT_START": {
|
|
12878
|
+
switch (char) {
|
|
12879
|
+
case '"': {
|
|
12880
|
+
stack.pop();
|
|
12881
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
12882
|
+
break;
|
|
12883
|
+
}
|
|
12884
|
+
case "}": {
|
|
12885
|
+
lastValidIndex = i;
|
|
12886
|
+
stack.pop();
|
|
12887
|
+
break;
|
|
12888
|
+
}
|
|
12889
|
+
}
|
|
12890
|
+
break;
|
|
12891
|
+
}
|
|
12892
|
+
case "INSIDE_OBJECT_AFTER_COMMA": {
|
|
12893
|
+
switch (char) {
|
|
12894
|
+
case '"': {
|
|
12895
|
+
stack.pop();
|
|
12896
|
+
stack.push("INSIDE_OBJECT_KEY");
|
|
12897
|
+
break;
|
|
12898
|
+
}
|
|
12899
|
+
}
|
|
12900
|
+
break;
|
|
12901
|
+
}
|
|
12902
|
+
case "INSIDE_OBJECT_KEY": {
|
|
12903
|
+
switch (char) {
|
|
12904
|
+
case '"': {
|
|
12905
|
+
stack.pop();
|
|
12906
|
+
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
|
12907
|
+
break;
|
|
12908
|
+
}
|
|
12909
|
+
}
|
|
12910
|
+
break;
|
|
12911
|
+
}
|
|
12912
|
+
case "INSIDE_OBJECT_AFTER_KEY": {
|
|
12913
|
+
switch (char) {
|
|
12914
|
+
case ":": {
|
|
12915
|
+
stack.pop();
|
|
12916
|
+
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
|
12917
|
+
break;
|
|
12918
|
+
}
|
|
12919
|
+
}
|
|
12920
|
+
break;
|
|
12921
|
+
}
|
|
12922
|
+
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
|
12923
|
+
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
|
12924
|
+
break;
|
|
12925
|
+
}
|
|
12926
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
12927
|
+
processAfterObjectValue(char, i);
|
|
12928
|
+
break;
|
|
12929
|
+
}
|
|
12930
|
+
case "INSIDE_STRING": {
|
|
12931
|
+
switch (char) {
|
|
12932
|
+
case '"': {
|
|
12933
|
+
stack.pop();
|
|
12934
|
+
lastValidIndex = i;
|
|
12935
|
+
break;
|
|
12936
|
+
}
|
|
12937
|
+
case "\\": {
|
|
12938
|
+
stack.push("INSIDE_STRING_ESCAPE");
|
|
12939
|
+
break;
|
|
12940
|
+
}
|
|
12941
|
+
default: {
|
|
12942
|
+
lastValidIndex = i;
|
|
12943
|
+
}
|
|
12944
|
+
}
|
|
12945
|
+
break;
|
|
12946
|
+
}
|
|
12947
|
+
case "INSIDE_ARRAY_START": {
|
|
12948
|
+
switch (char) {
|
|
12949
|
+
case "]": {
|
|
12950
|
+
lastValidIndex = i;
|
|
12951
|
+
stack.pop();
|
|
12952
|
+
break;
|
|
12953
|
+
}
|
|
12954
|
+
default: {
|
|
12955
|
+
lastValidIndex = i;
|
|
12956
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
12957
|
+
break;
|
|
12958
|
+
}
|
|
12959
|
+
}
|
|
12960
|
+
break;
|
|
12961
|
+
}
|
|
12962
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
12963
|
+
switch (char) {
|
|
12964
|
+
case ",": {
|
|
12965
|
+
stack.pop();
|
|
12966
|
+
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
|
12967
|
+
break;
|
|
12968
|
+
}
|
|
12969
|
+
case "]": {
|
|
12970
|
+
lastValidIndex = i;
|
|
12971
|
+
stack.pop();
|
|
12972
|
+
break;
|
|
12973
|
+
}
|
|
12974
|
+
default: {
|
|
12975
|
+
lastValidIndex = i;
|
|
12976
|
+
break;
|
|
12977
|
+
}
|
|
12978
|
+
}
|
|
12979
|
+
break;
|
|
12980
|
+
}
|
|
12981
|
+
case "INSIDE_ARRAY_AFTER_COMMA": {
|
|
12982
|
+
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
|
12983
|
+
break;
|
|
12984
|
+
}
|
|
12985
|
+
case "INSIDE_STRING_ESCAPE": {
|
|
12986
|
+
stack.pop();
|
|
12987
|
+
lastValidIndex = i;
|
|
12988
|
+
break;
|
|
12989
|
+
}
|
|
12990
|
+
case "INSIDE_NUMBER": {
|
|
12991
|
+
switch (char) {
|
|
12992
|
+
case "0":
|
|
12993
|
+
case "1":
|
|
12994
|
+
case "2":
|
|
12995
|
+
case "3":
|
|
12996
|
+
case "4":
|
|
12997
|
+
case "5":
|
|
12998
|
+
case "6":
|
|
12999
|
+
case "7":
|
|
13000
|
+
case "8":
|
|
13001
|
+
case "9": {
|
|
13002
|
+
lastValidIndex = i;
|
|
13003
|
+
break;
|
|
13004
|
+
}
|
|
13005
|
+
case "e":
|
|
13006
|
+
case "E":
|
|
13007
|
+
case "-":
|
|
13008
|
+
case ".": {
|
|
13009
|
+
break;
|
|
13010
|
+
}
|
|
13011
|
+
case ",": {
|
|
13012
|
+
stack.pop();
|
|
13013
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
13014
|
+
processAfterArrayValue(char, i);
|
|
13015
|
+
}
|
|
13016
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
13017
|
+
processAfterObjectValue(char, i);
|
|
13018
|
+
}
|
|
13019
|
+
break;
|
|
13020
|
+
}
|
|
13021
|
+
case "}": {
|
|
13022
|
+
stack.pop();
|
|
13023
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
13024
|
+
processAfterObjectValue(char, i);
|
|
13025
|
+
}
|
|
13026
|
+
break;
|
|
13027
|
+
}
|
|
13028
|
+
case "]": {
|
|
13029
|
+
stack.pop();
|
|
13030
|
+
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
13031
|
+
processAfterArrayValue(char, i);
|
|
13032
|
+
}
|
|
13033
|
+
break;
|
|
13034
|
+
}
|
|
13035
|
+
default: {
|
|
13036
|
+
stack.pop();
|
|
13037
|
+
break;
|
|
13038
|
+
}
|
|
13039
|
+
}
|
|
13040
|
+
break;
|
|
13041
|
+
}
|
|
13042
|
+
case "INSIDE_LITERAL": {
|
|
13043
|
+
const partialLiteral = input.substring(literalStart, i + 1);
|
|
13044
|
+
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
|
13045
|
+
stack.pop();
|
|
13046
|
+
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
|
13047
|
+
processAfterObjectValue(char, i);
|
|
13048
|
+
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
|
13049
|
+
processAfterArrayValue(char, i);
|
|
13050
|
+
}
|
|
13051
|
+
} else {
|
|
13052
|
+
lastValidIndex = i;
|
|
13053
|
+
}
|
|
13054
|
+
break;
|
|
13055
|
+
}
|
|
13056
|
+
}
|
|
13057
|
+
}
|
|
13058
|
+
let result = input.slice(0, lastValidIndex + 1);
|
|
13059
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
13060
|
+
const state = stack[i];
|
|
13061
|
+
switch (state) {
|
|
13062
|
+
case "INSIDE_STRING": {
|
|
13063
|
+
result += '"';
|
|
13064
|
+
break;
|
|
13065
|
+
}
|
|
13066
|
+
case "INSIDE_OBJECT_KEY":
|
|
13067
|
+
case "INSIDE_OBJECT_AFTER_KEY":
|
|
13068
|
+
case "INSIDE_OBJECT_AFTER_COMMA":
|
|
13069
|
+
case "INSIDE_OBJECT_START":
|
|
13070
|
+
case "INSIDE_OBJECT_BEFORE_VALUE":
|
|
13071
|
+
case "INSIDE_OBJECT_AFTER_VALUE": {
|
|
13072
|
+
result += "}";
|
|
13073
|
+
break;
|
|
13074
|
+
}
|
|
13075
|
+
case "INSIDE_ARRAY_START":
|
|
13076
|
+
case "INSIDE_ARRAY_AFTER_COMMA":
|
|
13077
|
+
case "INSIDE_ARRAY_AFTER_VALUE": {
|
|
13078
|
+
result += "]";
|
|
13079
|
+
break;
|
|
13080
|
+
}
|
|
13081
|
+
case "INSIDE_LITERAL": {
|
|
13082
|
+
const partialLiteral = input.substring(literalStart, input.length);
|
|
13083
|
+
if ("true".startsWith(partialLiteral)) {
|
|
13084
|
+
result += "true".slice(partialLiteral.length);
|
|
13085
|
+
} else if ("false".startsWith(partialLiteral)) {
|
|
13086
|
+
result += "false".slice(partialLiteral.length);
|
|
13087
|
+
} else if ("null".startsWith(partialLiteral)) {
|
|
13088
|
+
result += "null".slice(partialLiteral.length);
|
|
13089
|
+
}
|
|
13090
|
+
}
|
|
13091
|
+
}
|
|
13092
|
+
}
|
|
13093
|
+
return result;
|
|
13094
|
+
}
|
|
13095
|
+
async function parsePartialJson3(jsonText) {
|
|
13096
|
+
if (jsonText === void 0) {
|
|
13097
|
+
return { value: void 0, state: "undefined-input" };
|
|
13098
|
+
}
|
|
13099
|
+
let result = await safeParseJSON3({ text: jsonText });
|
|
13100
|
+
if (result.success) {
|
|
13101
|
+
return { value: result.value, state: "successful-parse" };
|
|
13102
|
+
}
|
|
13103
|
+
result = await safeParseJSON3({ text: fixJson3(jsonText) });
|
|
13104
|
+
if (result.success) {
|
|
13105
|
+
return { value: result.value, state: "repaired-parse" };
|
|
13106
|
+
}
|
|
13107
|
+
return { value: void 0, state: "failed-parse" };
|
|
13108
|
+
}
|
|
13109
|
+
createIdGenerator3({
|
|
13110
|
+
prefix: "aitxt",
|
|
13111
|
+
size: 24
|
|
13112
|
+
});
|
|
13113
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
13114
|
+
createIdGenerator3({ prefix: "aiobj", size: 24 });
|
|
13115
|
+
var output_exports3 = {};
|
|
13116
|
+
__export4(output_exports3, {
|
|
13117
|
+
object: () => object32,
|
|
13118
|
+
text: () => text3
|
|
13119
|
+
});
|
|
13120
|
+
var text3 = () => ({
|
|
13121
|
+
type: "text",
|
|
13122
|
+
responseFormat: { type: "text" },
|
|
13123
|
+
async parsePartial({ text: text22 }) {
|
|
13124
|
+
return { partial: text22 };
|
|
13125
|
+
},
|
|
13126
|
+
async parseOutput({ text: text22 }) {
|
|
13127
|
+
return text22;
|
|
13128
|
+
}
|
|
13129
|
+
});
|
|
13130
|
+
var object32 = ({
|
|
13131
|
+
schema: inputSchema
|
|
13132
|
+
}) => {
|
|
13133
|
+
const schema = asSchema3(inputSchema);
|
|
13134
|
+
return {
|
|
13135
|
+
type: "object",
|
|
13136
|
+
responseFormat: {
|
|
13137
|
+
type: "json",
|
|
13138
|
+
schema: schema.jsonSchema
|
|
13139
|
+
},
|
|
13140
|
+
async parsePartial({ text: text22 }) {
|
|
13141
|
+
const result = await parsePartialJson3(text22);
|
|
13142
|
+
switch (result.state) {
|
|
13143
|
+
case "failed-parse":
|
|
13144
|
+
case "undefined-input":
|
|
13145
|
+
return void 0;
|
|
13146
|
+
case "repaired-parse":
|
|
13147
|
+
case "successful-parse":
|
|
13148
|
+
return {
|
|
13149
|
+
// Note: currently no validation of partial results:
|
|
13150
|
+
partial: result.value
|
|
13151
|
+
};
|
|
13152
|
+
default: {
|
|
13153
|
+
const _exhaustiveCheck = result.state;
|
|
13154
|
+
throw new Error(`Unsupported parse state: ${_exhaustiveCheck}`);
|
|
13155
|
+
}
|
|
13156
|
+
}
|
|
13157
|
+
},
|
|
13158
|
+
async parseOutput({ text: text22 }, context) {
|
|
13159
|
+
const parseResult = await safeParseJSON3({ text: text22 });
|
|
13160
|
+
if (!parseResult.success) {
|
|
13161
|
+
throw new NoObjectGeneratedError3({
|
|
13162
|
+
message: "No object generated: could not parse the response.",
|
|
13163
|
+
cause: parseResult.error,
|
|
13164
|
+
text: text22,
|
|
13165
|
+
response: context.response,
|
|
13166
|
+
usage: context.usage,
|
|
13167
|
+
finishReason: context.finishReason
|
|
13168
|
+
});
|
|
13169
|
+
}
|
|
13170
|
+
const validationResult = await safeValidateTypes3({
|
|
13171
|
+
value: parseResult.value,
|
|
13172
|
+
schema
|
|
13173
|
+
});
|
|
13174
|
+
if (!validationResult.success) {
|
|
13175
|
+
throw new NoObjectGeneratedError3({
|
|
13176
|
+
message: "No object generated: response did not match schema.",
|
|
13177
|
+
cause: validationResult.error,
|
|
13178
|
+
text: text22,
|
|
13179
|
+
response: context.response,
|
|
13180
|
+
usage: context.usage,
|
|
13181
|
+
finishReason: context.finishReason
|
|
13182
|
+
});
|
|
13183
|
+
}
|
|
13184
|
+
return validationResult.value;
|
|
13185
|
+
}
|
|
13186
|
+
};
|
|
13187
|
+
};
|
|
13188
|
+
var ClientOrServerImplementationSchema3 = z104.looseObject({
|
|
13189
|
+
name: z104.string(),
|
|
13190
|
+
version: z104.string()
|
|
13191
|
+
});
|
|
13192
|
+
var BaseParamsSchema3 = z104.looseObject({
|
|
13193
|
+
_meta: z104.optional(z104.object({}).loose())
|
|
13194
|
+
});
|
|
13195
|
+
var ResultSchema3 = BaseParamsSchema3;
|
|
13196
|
+
var RequestSchema3 = z104.object({
|
|
13197
|
+
method: z104.string(),
|
|
13198
|
+
params: z104.optional(BaseParamsSchema3)
|
|
13199
|
+
});
|
|
13200
|
+
var ServerCapabilitiesSchema3 = z104.looseObject({
|
|
13201
|
+
experimental: z104.optional(z104.object({}).loose()),
|
|
13202
|
+
logging: z104.optional(z104.object({}).loose()),
|
|
13203
|
+
prompts: z104.optional(
|
|
13204
|
+
z104.looseObject({
|
|
13205
|
+
listChanged: z104.optional(z104.boolean())
|
|
13206
|
+
})
|
|
13207
|
+
),
|
|
13208
|
+
resources: z104.optional(
|
|
13209
|
+
z104.looseObject({
|
|
13210
|
+
subscribe: z104.optional(z104.boolean()),
|
|
13211
|
+
listChanged: z104.optional(z104.boolean())
|
|
13212
|
+
})
|
|
13213
|
+
),
|
|
13214
|
+
tools: z104.optional(
|
|
13215
|
+
z104.looseObject({
|
|
13216
|
+
listChanged: z104.optional(z104.boolean())
|
|
13217
|
+
})
|
|
13218
|
+
)
|
|
13219
|
+
});
|
|
13220
|
+
ResultSchema3.extend({
|
|
13221
|
+
protocolVersion: z104.string(),
|
|
13222
|
+
capabilities: ServerCapabilitiesSchema3,
|
|
13223
|
+
serverInfo: ClientOrServerImplementationSchema3,
|
|
13224
|
+
instructions: z104.optional(z104.string())
|
|
13225
|
+
});
|
|
13226
|
+
var PaginatedResultSchema3 = ResultSchema3.extend({
|
|
13227
|
+
nextCursor: z104.optional(z104.string())
|
|
13228
|
+
});
|
|
13229
|
+
var ToolSchema3 = z104.object({
|
|
13230
|
+
name: z104.string(),
|
|
13231
|
+
description: z104.optional(z104.string()),
|
|
13232
|
+
inputSchema: z104.object({
|
|
13233
|
+
type: z104.literal("object"),
|
|
13234
|
+
properties: z104.optional(z104.object({}).loose())
|
|
13235
|
+
}).loose()
|
|
13236
|
+
}).loose();
|
|
13237
|
+
PaginatedResultSchema3.extend({
|
|
13238
|
+
tools: z104.array(ToolSchema3)
|
|
13239
|
+
});
|
|
13240
|
+
var TextContentSchema3 = z104.object({
|
|
13241
|
+
type: z104.literal("text"),
|
|
13242
|
+
text: z104.string()
|
|
13243
|
+
}).loose();
|
|
13244
|
+
var ImageContentSchema3 = z104.object({
|
|
13245
|
+
type: z104.literal("image"),
|
|
13246
|
+
data: z104.base64(),
|
|
13247
|
+
mimeType: z104.string()
|
|
13248
|
+
}).loose();
|
|
13249
|
+
var ResourceContentsSchema3 = z104.object({
|
|
13250
|
+
/**
|
|
13251
|
+
* The URI of this resource.
|
|
13252
|
+
*/
|
|
13253
|
+
uri: z104.string(),
|
|
13254
|
+
/**
|
|
13255
|
+
* The MIME type of this resource, if known.
|
|
13256
|
+
*/
|
|
13257
|
+
mimeType: z104.optional(z104.string())
|
|
13258
|
+
}).loose();
|
|
13259
|
+
var TextResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
13260
|
+
text: z104.string()
|
|
13261
|
+
});
|
|
13262
|
+
var BlobResourceContentsSchema3 = ResourceContentsSchema3.extend({
|
|
13263
|
+
blob: z104.base64()
|
|
13264
|
+
});
|
|
13265
|
+
var EmbeddedResourceSchema3 = z104.object({
|
|
13266
|
+
type: z104.literal("resource"),
|
|
13267
|
+
resource: z104.union([TextResourceContentsSchema3, BlobResourceContentsSchema3])
|
|
13268
|
+
}).loose();
|
|
13269
|
+
ResultSchema3.extend({
|
|
13270
|
+
content: z104.array(
|
|
13271
|
+
z104.union([TextContentSchema3, ImageContentSchema3, EmbeddedResourceSchema3])
|
|
13272
|
+
),
|
|
13273
|
+
isError: z104.boolean().default(false).optional()
|
|
13274
|
+
}).or(
|
|
13275
|
+
ResultSchema3.extend({
|
|
13276
|
+
toolResult: z104.unknown()
|
|
13277
|
+
})
|
|
13278
|
+
);
|
|
13279
|
+
var JSONRPC_VERSION3 = "2.0";
|
|
13280
|
+
var JSONRPCRequestSchema3 = z104.object({
|
|
13281
|
+
jsonrpc: z104.literal(JSONRPC_VERSION3),
|
|
13282
|
+
id: z104.union([z104.string(), z104.number().int()])
|
|
13283
|
+
}).merge(RequestSchema3).strict();
|
|
13284
|
+
var JSONRPCResponseSchema3 = z104.object({
|
|
13285
|
+
jsonrpc: z104.literal(JSONRPC_VERSION3),
|
|
13286
|
+
id: z104.union([z104.string(), z104.number().int()]),
|
|
13287
|
+
result: ResultSchema3
|
|
13288
|
+
}).strict();
|
|
13289
|
+
var JSONRPCErrorSchema3 = z104.object({
|
|
13290
|
+
jsonrpc: z104.literal(JSONRPC_VERSION3),
|
|
13291
|
+
id: z104.union([z104.string(), z104.number().int()]),
|
|
13292
|
+
error: z104.object({
|
|
13293
|
+
code: z104.number().int(),
|
|
13294
|
+
message: z104.string(),
|
|
13295
|
+
data: z104.optional(z104.unknown())
|
|
13296
|
+
})
|
|
13297
|
+
}).strict();
|
|
13298
|
+
var JSONRPCNotificationSchema3 = z104.object({
|
|
13299
|
+
jsonrpc: z104.literal(JSONRPC_VERSION3)
|
|
13300
|
+
}).merge(
|
|
13301
|
+
z104.object({
|
|
13302
|
+
method: z104.string(),
|
|
13303
|
+
params: z104.optional(BaseParamsSchema3)
|
|
13304
|
+
})
|
|
13305
|
+
).strict();
|
|
13306
|
+
z104.union([
|
|
13307
|
+
JSONRPCRequestSchema3,
|
|
13308
|
+
JSONRPCNotificationSchema3,
|
|
13309
|
+
JSONRPCResponseSchema3,
|
|
13310
|
+
JSONRPCErrorSchema3
|
|
13311
|
+
]);
|
|
13312
|
+
|
|
13313
|
+
// ../agent-builder/dist/index.js
|
|
13314
|
+
var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
|
|
13315
|
+
var TemplateUnitSchema = z.object({
|
|
13316
|
+
kind: z.enum(UNIT_KINDS),
|
|
13317
|
+
id: z.string(),
|
|
13318
|
+
file: z.string()
|
|
13319
|
+
});
|
|
13320
|
+
z.object({
|
|
13321
|
+
slug: z.string(),
|
|
13322
|
+
ref: z.string().optional(),
|
|
13323
|
+
description: z.string().optional(),
|
|
13324
|
+
units: z.array(TemplateUnitSchema)
|
|
13325
|
+
});
|
|
13326
|
+
var AgentBuilderInputSchema = z.object({
|
|
13327
|
+
repo: z.string().describe("Git URL or local path of the template repo"),
|
|
13328
|
+
ref: z.string().optional().describe("Tag/branch/commit to checkout (defaults to main/master)"),
|
|
13329
|
+
slug: z.string().optional().describe("Slug for branch/scripts; defaults to inferred from repo"),
|
|
13330
|
+
targetPath: z.string().optional().describe("Project path to merge into; defaults to current directory"),
|
|
13331
|
+
variables: z.record(z.string()).optional().describe("Environment variables to set in .env file")
|
|
13332
|
+
});
|
|
13333
|
+
z.object({
|
|
13334
|
+
slug: z.string(),
|
|
13335
|
+
commitSha: z.string(),
|
|
13336
|
+
templateDir: z.string(),
|
|
13337
|
+
units: z.array(TemplateUnitSchema)
|
|
13338
|
+
});
|
|
13339
|
+
var CopiedFileSchema = z.object({
|
|
13340
|
+
source: z.string(),
|
|
13341
|
+
destination: z.string(),
|
|
13342
|
+
unit: z.object({
|
|
13343
|
+
kind: z.enum(UNIT_KINDS),
|
|
13344
|
+
id: z.string()
|
|
13345
|
+
})
|
|
13346
|
+
});
|
|
13347
|
+
var ConflictSchema = z.object({
|
|
13348
|
+
unit: z.object({
|
|
13349
|
+
kind: z.enum(UNIT_KINDS),
|
|
13350
|
+
id: z.string()
|
|
13351
|
+
}),
|
|
13352
|
+
issue: z.string(),
|
|
13353
|
+
sourceFile: z.string(),
|
|
13354
|
+
targetFile: z.string()
|
|
13355
|
+
});
|
|
13356
|
+
var FileCopyInputSchema = z.object({
|
|
13357
|
+
orderedUnits: z.array(TemplateUnitSchema),
|
|
13358
|
+
templateDir: z.string(),
|
|
13359
|
+
commitSha: z.string(),
|
|
13360
|
+
slug: z.string(),
|
|
13361
|
+
targetPath: z.string().optional(),
|
|
13362
|
+
variables: z.record(z.string()).optional()
|
|
13363
|
+
});
|
|
13364
|
+
var FileCopyResultSchema = z.object({
|
|
13365
|
+
success: z.boolean(),
|
|
13366
|
+
copiedFiles: z.array(CopiedFileSchema),
|
|
13367
|
+
conflicts: z.array(ConflictSchema),
|
|
13368
|
+
message: z.string(),
|
|
13369
|
+
error: z.string().optional()
|
|
13370
|
+
});
|
|
13371
|
+
var ConflictResolutionSchema = z.object({
|
|
13372
|
+
unit: z.object({
|
|
13373
|
+
kind: z.enum(UNIT_KINDS),
|
|
13374
|
+
id: z.string()
|
|
13375
|
+
}),
|
|
13376
|
+
issue: z.string(),
|
|
13377
|
+
resolution: z.string()
|
|
13378
|
+
});
|
|
13379
|
+
var IntelligentMergeInputSchema = z.object({
|
|
13380
|
+
conflicts: z.array(ConflictSchema),
|
|
13381
|
+
copiedFiles: z.array(CopiedFileSchema),
|
|
13382
|
+
templateDir: z.string(),
|
|
13383
|
+
commitSha: z.string(),
|
|
13384
|
+
slug: z.string(),
|
|
13385
|
+
targetPath: z.string().optional(),
|
|
13386
|
+
branchName: z.string().optional()
|
|
13387
|
+
});
|
|
13388
|
+
var IntelligentMergeResultSchema = z.object({
|
|
13389
|
+
success: z.boolean(),
|
|
13390
|
+
applied: z.boolean(),
|
|
13391
|
+
message: z.string(),
|
|
13392
|
+
conflictsResolved: z.array(ConflictResolutionSchema),
|
|
13393
|
+
error: z.string().optional()
|
|
13394
|
+
});
|
|
13395
|
+
var ValidationResultsSchema = z.object({
|
|
13396
|
+
valid: z.boolean(),
|
|
13397
|
+
errorsFixed: z.number(),
|
|
13398
|
+
remainingErrors: z.number(),
|
|
13399
|
+
errors: z.array(z.any()).optional()
|
|
13400
|
+
// Include specific validation errors
|
|
13401
|
+
});
|
|
13402
|
+
var ValidationFixInputSchema = z.object({
|
|
13403
|
+
commitSha: z.string(),
|
|
13404
|
+
slug: z.string(),
|
|
13405
|
+
targetPath: z.string().optional(),
|
|
13406
|
+
templateDir: z.string(),
|
|
13407
|
+
orderedUnits: z.array(TemplateUnitSchema),
|
|
13408
|
+
copiedFiles: z.array(CopiedFileSchema),
|
|
13409
|
+
conflictsResolved: z.array(ConflictResolutionSchema).optional(),
|
|
13410
|
+
maxIterations: z.number().optional().default(5)
|
|
13411
|
+
});
|
|
13412
|
+
var ValidationFixResultSchema = z.object({
|
|
13413
|
+
success: z.boolean(),
|
|
13414
|
+
applied: z.boolean(),
|
|
13415
|
+
message: z.string(),
|
|
13416
|
+
validationResults: ValidationResultsSchema,
|
|
13417
|
+
error: z.string().optional()
|
|
13418
|
+
});
|
|
13419
|
+
var ApplyResultSchema = z.object({
|
|
13420
|
+
success: z.boolean(),
|
|
13421
|
+
applied: z.boolean(),
|
|
13422
|
+
branchName: z.string().optional(),
|
|
13423
|
+
message: z.string(),
|
|
13424
|
+
validationResults: ValidationResultsSchema.optional(),
|
|
13425
|
+
error: z.string().optional(),
|
|
13426
|
+
errors: z.array(z.string()).optional(),
|
|
13427
|
+
stepResults: z.object({
|
|
13428
|
+
cloneSuccess: z.boolean().optional(),
|
|
13429
|
+
analyzeSuccess: z.boolean().optional(),
|
|
13430
|
+
discoverSuccess: z.boolean().optional(),
|
|
13431
|
+
orderSuccess: z.boolean().optional(),
|
|
13432
|
+
prepareBranchSuccess: z.boolean().optional(),
|
|
13433
|
+
packageMergeSuccess: z.boolean().optional(),
|
|
13434
|
+
installSuccess: z.boolean().optional(),
|
|
13435
|
+
copySuccess: z.boolean().optional(),
|
|
13436
|
+
mergeSuccess: z.boolean().optional(),
|
|
13437
|
+
validationSuccess: z.boolean().optional(),
|
|
13438
|
+
filesCopied: z.number(),
|
|
13439
|
+
conflictsSkipped: z.number(),
|
|
13440
|
+
conflictsResolved: z.number()
|
|
13441
|
+
}).optional()
|
|
13442
|
+
});
|
|
13443
|
+
var CloneTemplateResultSchema = z.object({
|
|
13444
|
+
templateDir: z.string(),
|
|
13445
|
+
commitSha: z.string(),
|
|
13446
|
+
slug: z.string(),
|
|
13447
|
+
success: z.boolean().optional(),
|
|
13448
|
+
error: z.string().optional(),
|
|
13449
|
+
targetPath: z.string().optional()
|
|
13450
|
+
});
|
|
13451
|
+
var PackageAnalysisSchema = z.object({
|
|
13452
|
+
name: z.string().optional(),
|
|
13453
|
+
version: z.string().optional(),
|
|
13454
|
+
description: z.string().optional(),
|
|
13455
|
+
dependencies: z.record(z.string()).optional(),
|
|
13456
|
+
devDependencies: z.record(z.string()).optional(),
|
|
13457
|
+
peerDependencies: z.record(z.string()).optional(),
|
|
13458
|
+
scripts: z.record(z.string()).optional(),
|
|
13459
|
+
success: z.boolean().optional(),
|
|
13460
|
+
error: z.string().optional()
|
|
13461
|
+
});
|
|
13462
|
+
var DiscoveryResultSchema = z.object({
|
|
13463
|
+
units: z.array(TemplateUnitSchema),
|
|
13464
|
+
success: z.boolean().optional(),
|
|
13465
|
+
error: z.string().optional()
|
|
13466
|
+
});
|
|
13467
|
+
var OrderedUnitsSchema = z.object({
|
|
13468
|
+
orderedUnits: z.array(TemplateUnitSchema),
|
|
13469
|
+
success: z.boolean().optional(),
|
|
13470
|
+
error: z.string().optional()
|
|
13471
|
+
});
|
|
13472
|
+
var PackageMergeInputSchema = z.object({
|
|
13473
|
+
commitSha: z.string(),
|
|
13474
|
+
slug: z.string(),
|
|
13475
|
+
targetPath: z.string().optional(),
|
|
13476
|
+
packageInfo: PackageAnalysisSchema
|
|
13477
|
+
});
|
|
13478
|
+
var PackageMergeResultSchema = z.object({
|
|
13479
|
+
success: z.boolean(),
|
|
13480
|
+
applied: z.boolean(),
|
|
13481
|
+
message: z.string(),
|
|
13482
|
+
error: z.string().optional()
|
|
13483
|
+
});
|
|
13484
|
+
var InstallInputSchema = z.object({
|
|
13485
|
+
targetPath: z.string().describe("Path to the project to install packages in")
|
|
13486
|
+
});
|
|
13487
|
+
var InstallResultSchema = z.object({
|
|
13488
|
+
success: z.boolean(),
|
|
13489
|
+
error: z.string().optional()
|
|
13490
|
+
});
|
|
13491
|
+
var PrepareBranchInputSchema = z.object({
|
|
13492
|
+
slug: z.string(),
|
|
13493
|
+
commitSha: z.string().optional(),
|
|
13494
|
+
// from clone-template if relevant
|
|
13495
|
+
targetPath: z.string().optional()
|
|
13496
|
+
});
|
|
13497
|
+
var PrepareBranchResultSchema = z.object({
|
|
13498
|
+
branchName: z.string(),
|
|
13499
|
+
success: z.boolean().optional(),
|
|
13500
|
+
error: z.string().optional()
|
|
13501
|
+
});
|
|
13502
|
+
var exec = promisify(exec$1);
|
|
13503
|
+
var execFile = promisify(execFile$1);
|
|
13504
|
+
function isInWorkspaceSubfolder(cwd) {
|
|
13505
|
+
try {
|
|
13506
|
+
const currentPackageJson = resolve$1(cwd, "package.json");
|
|
13507
|
+
if (!existsSync(currentPackageJson)) {
|
|
13508
|
+
return false;
|
|
13509
|
+
}
|
|
13510
|
+
let currentDir = cwd;
|
|
13511
|
+
let previousDir = "";
|
|
13512
|
+
while (currentDir !== previousDir && currentDir !== "/") {
|
|
13513
|
+
previousDir = currentDir;
|
|
13514
|
+
currentDir = dirname(currentDir);
|
|
13515
|
+
if (currentDir === cwd) {
|
|
13516
|
+
continue;
|
|
13517
|
+
}
|
|
13518
|
+
console.info(`Checking for workspace indicators in: ${currentDir}`);
|
|
13519
|
+
if (existsSync(resolve$1(currentDir, "pnpm-workspace.yaml"))) {
|
|
13520
|
+
return true;
|
|
13521
|
+
}
|
|
13522
|
+
const parentPackageJson = resolve$1(currentDir, "package.json");
|
|
13523
|
+
if (existsSync(parentPackageJson)) {
|
|
13524
|
+
try {
|
|
13525
|
+
const parentPkg = JSON.parse(readFileSync(parentPackageJson, "utf-8"));
|
|
13526
|
+
if (parentPkg.workspaces) {
|
|
13527
|
+
return true;
|
|
13528
|
+
}
|
|
13529
|
+
} catch {
|
|
13530
|
+
}
|
|
13531
|
+
}
|
|
13532
|
+
if (existsSync(resolve$1(currentDir, "lerna.json"))) {
|
|
13533
|
+
return true;
|
|
13534
|
+
}
|
|
13535
|
+
}
|
|
13536
|
+
return false;
|
|
13537
|
+
} catch (error) {
|
|
13538
|
+
console.warn(`Error in workspace detection: ${error}`);
|
|
13539
|
+
return false;
|
|
13540
|
+
}
|
|
13541
|
+
}
|
|
13542
|
+
function spawn(command, args, options) {
|
|
13543
|
+
return new Promise((resolve4, reject) => {
|
|
13544
|
+
const childProcess = spawn$1(command, args, {
|
|
13545
|
+
stdio: "inherit",
|
|
13546
|
+
// Enable proper stdio handling
|
|
13547
|
+
...options
|
|
13548
|
+
});
|
|
13549
|
+
childProcess.on("error", (error) => {
|
|
11551
13550
|
reject(error);
|
|
11552
13551
|
});
|
|
11553
13552
|
childProcess.on("close", (code) => {
|
|
@@ -13484,14 +15483,14 @@ export const mastra = new Mastra({
|
|
|
13484
15483
|
noEmit: true
|
|
13485
15484
|
};
|
|
13486
15485
|
const host = {
|
|
13487
|
-
getSourceFile: (
|
|
15486
|
+
getSourceFile: (name21) => name21 === fileName ? sourceFile : void 0,
|
|
13488
15487
|
writeFile: () => {
|
|
13489
15488
|
},
|
|
13490
15489
|
getCurrentDirectory: () => "",
|
|
13491
15490
|
getDirectories: () => [],
|
|
13492
|
-
fileExists: (
|
|
13493
|
-
readFile: (
|
|
13494
|
-
getCanonicalFileName: (
|
|
15491
|
+
fileExists: (name21) => name21 === fileName,
|
|
15492
|
+
readFile: (name21) => name21 === fileName ? fileContent : void 0,
|
|
15493
|
+
getCanonicalFileName: (name21) => name21,
|
|
13495
15494
|
useCaseSensitiveFileNames: () => true,
|
|
13496
15495
|
getNewLine: () => "\n",
|
|
13497
15496
|
getDefaultLibFileName: () => "lib.d.ts"
|
|
@@ -14740,8 +16739,10 @@ Return the actual exported names of the units, as well as the file names.`,
|
|
|
14740
16739
|
networks: z.array(z.object({ name: z.string(), file: z.string() })).optional(),
|
|
14741
16740
|
other: z.array(z.object({ name: z.string(), file: z.string() })).optional()
|
|
14742
16741
|
});
|
|
14743
|
-
const result = isV2 ? await agent
|
|
14744
|
-
|
|
16742
|
+
const result = isV2 ? await tryGenerateWithJsonFallback(agent, prompt, {
|
|
16743
|
+
structuredOutput: {
|
|
16744
|
+
schema: output
|
|
16745
|
+
},
|
|
14745
16746
|
maxSteps: 100
|
|
14746
16747
|
}) : await agent.generateLegacy(prompt, {
|
|
14747
16748
|
experimental_output: output,
|
|
@@ -14871,25 +16872,25 @@ var packageMergeStep = createStep({
|
|
|
14871
16872
|
const tplDevDeps = ensureObj(packageInfo.devDependencies);
|
|
14872
16873
|
const tplPeerDeps = ensureObj(packageInfo.peerDependencies);
|
|
14873
16874
|
const tplScripts = ensureObj(packageInfo.scripts);
|
|
14874
|
-
const existsAnywhere = (
|
|
14875
|
-
for (const [
|
|
14876
|
-
if (!existsAnywhere(
|
|
14877
|
-
targetPkg.dependencies[
|
|
16875
|
+
const existsAnywhere = (name21) => name21 in targetPkg.dependencies || name21 in targetPkg.devDependencies || name21 in targetPkg.peerDependencies;
|
|
16876
|
+
for (const [name21, ver] of Object.entries(tplDeps)) {
|
|
16877
|
+
if (!existsAnywhere(name21)) {
|
|
16878
|
+
targetPkg.dependencies[name21] = String(ver);
|
|
14878
16879
|
}
|
|
14879
16880
|
}
|
|
14880
|
-
for (const [
|
|
14881
|
-
if (!existsAnywhere(
|
|
14882
|
-
targetPkg.devDependencies[
|
|
16881
|
+
for (const [name21, ver] of Object.entries(tplDevDeps)) {
|
|
16882
|
+
if (!existsAnywhere(name21)) {
|
|
16883
|
+
targetPkg.devDependencies[name21] = String(ver);
|
|
14883
16884
|
}
|
|
14884
16885
|
}
|
|
14885
|
-
for (const [
|
|
14886
|
-
if (!(
|
|
14887
|
-
targetPkg.peerDependencies[
|
|
16886
|
+
for (const [name21, ver] of Object.entries(tplPeerDeps)) {
|
|
16887
|
+
if (!(name21 in targetPkg.peerDependencies)) {
|
|
16888
|
+
targetPkg.peerDependencies[name21] = String(ver);
|
|
14888
16889
|
}
|
|
14889
16890
|
}
|
|
14890
16891
|
const prefix = `template:${slug}:`;
|
|
14891
|
-
for (const [
|
|
14892
|
-
const newKey = `${prefix}${
|
|
16892
|
+
for (const [name21, cmd] of Object.entries(tplScripts)) {
|
|
16893
|
+
const newKey = `${prefix}${name21}`;
|
|
14893
16894
|
if (!(newKey in targetPkg.scripts)) {
|
|
14894
16895
|
targetPkg.scripts[newKey] = String(cmd);
|
|
14895
16896
|
}
|
|
@@ -14974,9 +16975,9 @@ var programmaticFileCopyStep = createStep({
|
|
|
14974
16975
|
return "unknown";
|
|
14975
16976
|
}
|
|
14976
16977
|
};
|
|
14977
|
-
const convertNaming = (
|
|
14978
|
-
const baseName = basename(
|
|
14979
|
-
const ext = extname(
|
|
16978
|
+
const convertNaming = (name21, convention) => {
|
|
16979
|
+
const baseName = basename(name21, extname(name21));
|
|
16980
|
+
const ext = extname(name21);
|
|
14980
16981
|
switch (convention) {
|
|
14981
16982
|
case "camelCase":
|
|
14982
16983
|
return baseName.replace(/[-_]/g, "").replace(/([A-Z])/g, (match, p1, offset) => offset === 0 ? p1.toLowerCase() : p1) + ext;
|
|
@@ -14987,7 +16988,7 @@ var programmaticFileCopyStep = createStep({
|
|
|
14987
16988
|
case "PascalCase":
|
|
14988
16989
|
return baseName.replace(/[-_]/g, "").replace(/^[a-z]/, (match) => match.toUpperCase()) + ext;
|
|
14989
16990
|
default:
|
|
14990
|
-
return
|
|
16991
|
+
return name21;
|
|
14991
16992
|
}
|
|
14992
16993
|
};
|
|
14993
16994
|
for (const unit of orderedUnits) {
|
|
@@ -15731,8 +17732,10 @@ Start by running validateCode with all validation types to get a complete pictur
|
|
|
15731
17732
|
Previous iterations may have fixed some issues, so start by re-running validateCode to see the current state, then fix any remaining issues.`;
|
|
15732
17733
|
const isV2 = model.specificationVersion === "v2";
|
|
15733
17734
|
const output = z.object({ success: z.boolean() });
|
|
15734
|
-
const result = isV2 ? await validationAgent
|
|
15735
|
-
|
|
17735
|
+
const result = isV2 ? await tryStreamWithJsonFallback(validationAgent, iterationPrompt, {
|
|
17736
|
+
structuredOutput: {
|
|
17737
|
+
schema: output
|
|
17738
|
+
}
|
|
15736
17739
|
}) : await validationAgent.streamLegacy(iterationPrompt, {
|
|
15737
17740
|
experimental_output: output
|
|
15738
17741
|
});
|
|
@@ -17473,5 +19476,5 @@ var sendAgentBuilderActionRunEventHandler = createAgentBuilderWorkflowHandler(
|
|
|
17473
19476
|
);
|
|
17474
19477
|
|
|
17475
19478
|
export { agent_builder_exports, cancelAgentBuilderActionRunHandler, createAgentBuilderActionRunHandler, getAgentBuilderActionByIdHandler, getAgentBuilderActionRunByIdHandler, getAgentBuilderActionRunExecutionResultHandler, getAgentBuilderActionRunsHandler, getAgentBuilderActionsHandler, resumeAgentBuilderActionHandler, resumeAsyncAgentBuilderActionHandler, sendAgentBuilderActionRunEventHandler, startAgentBuilderActionRunHandler, startAsyncAgentBuilderActionHandler, streamAgentBuilderActionHandler, streamVNextAgentBuilderActionHandler, watchAgentBuilderActionHandler };
|
|
17476
|
-
//# sourceMappingURL=chunk-
|
|
17477
|
-
//# sourceMappingURL=chunk-
|
|
19479
|
+
//# sourceMappingURL=chunk-DTBJ3D22.js.map
|
|
19480
|
+
//# sourceMappingURL=chunk-DTBJ3D22.js.map
|