@modelrelay/sdk 5.3.0 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +122 -0
- package/dist/{api-7TVb2cnl.d.cts → api-B7SmXjnr.d.cts} +599 -1
- package/dist/{api-7TVb2cnl.d.ts → api-B7SmXjnr.d.ts} +599 -1
- package/dist/api-CdHqjsU_.d.cts +6062 -0
- package/dist/api-CdHqjsU_.d.ts +6062 -0
- package/dist/api-CyuI9lx0.d.cts +6249 -0
- package/dist/api-CyuI9lx0.d.ts +6249 -0
- package/dist/api-DP9MoKHy.d.cts +5993 -0
- package/dist/api-DP9MoKHy.d.ts +5993 -0
- package/dist/api-R_gUMD1L.d.cts +6243 -0
- package/dist/api-R_gUMD1L.d.ts +6243 -0
- package/dist/{api-BRAJe_xm.d.cts → api-c1j5ycVR.d.cts} +0 -54
- package/dist/{api-BRAJe_xm.d.ts → api-c1j5ycVR.d.ts} +0 -54
- package/dist/billing/index.d.cts +1 -1
- package/dist/billing/index.d.ts +1 -1
- package/dist/chunk-27KGKJLT.js +1194 -0
- package/dist/{chunk-5O4NJXLJ.js → chunk-HHBAD7FF.js} +1 -1
- package/dist/{chunk-LZDGY24E.js → chunk-PKGWFDGU.js} +111 -59
- package/dist/{chunk-HLJAMT7F.js → chunk-RVHKBQ7X.js} +1 -1
- package/dist/chunk-SJC7Q4NK.js +1199 -0
- package/dist/chunk-URFLODQC.js +1199 -0
- package/dist/{chunk-JZRSCFQH.js → chunk-YQWOQ74P.js} +53 -20
- package/dist/index.cjs +3468 -1156
- package/dist/index.d.cts +916 -85
- package/dist/index.d.ts +916 -85
- package/dist/index.js +3106 -881
- package/dist/node.cjs +11 -7
- package/dist/node.d.cts +11 -11
- package/dist/node.d.ts +11 -11
- package/dist/node.js +6 -6
- package/dist/{tools-Db-F5rIL.d.cts → tools-Bxdv0Np2.d.cts} +101 -218
- package/dist/{tools-Db-F5rIL.d.ts → tools-Bxdv0Np2.d.ts} +101 -218
- package/dist/tools-DHCGz_lx.d.cts +1041 -0
- package/dist/tools-DHCGz_lx.d.ts +1041 -0
- package/dist/tools-ZpcYacSo.d.cts +1000 -0
- package/dist/tools-ZpcYacSo.d.ts +1000 -0
- package/package.json +6 -1
- package/dist/api-B9x3HA3Z.d.cts +0 -5292
- package/dist/api-B9x3HA3Z.d.ts +0 -5292
- package/dist/api-Bitsm1tl.d.cts +0 -5290
- package/dist/api-Bitsm1tl.d.ts +0 -5290
- package/dist/api-D0wnVpwn.d.cts +0 -5292
- package/dist/api-D0wnVpwn.d.ts +0 -5292
- package/dist/api-HVh8Lusf.d.cts +0 -5300
- package/dist/api-HVh8Lusf.d.ts +0 -5300
- package/dist/chunk-BL7GWXRZ.js +0 -1196
- package/dist/chunk-CV3DTA6P.js +0 -1196
- package/dist/chunk-G5H7EY4F.js +0 -1196
- package/dist/chunk-OJFVI3QJ.js +0 -1133
- package/dist/chunk-Z6R4G2TU.js +0 -1133
|
@@ -220,7 +220,7 @@ async function parseErrorResponse(response, retries) {
|
|
|
220
220
|
// package.json
|
|
221
221
|
var package_default = {
|
|
222
222
|
name: "@modelrelay/sdk",
|
|
223
|
-
version: "
|
|
223
|
+
version: "5.5.0",
|
|
224
224
|
description: "TypeScript SDK for the ModelRelay API",
|
|
225
225
|
type: "module",
|
|
226
226
|
main: "dist/index.cjs",
|
|
@@ -134,6 +134,15 @@ var PathEscapeError = class extends ModelRelayError {
|
|
|
134
134
|
this.resolvedPath = opts.resolvedPath;
|
|
135
135
|
}
|
|
136
136
|
};
|
|
137
|
+
var AgentMaxTurnsError = class extends ModelRelayError {
|
|
138
|
+
constructor(maxTurns) {
|
|
139
|
+
super(`agent exceeded maximum turns (${maxTurns}) without completing`, {
|
|
140
|
+
category: "config",
|
|
141
|
+
status: 400
|
|
142
|
+
});
|
|
143
|
+
this.maxTurns = maxTurns;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
137
146
|
async function parseErrorResponse(response, retries) {
|
|
138
147
|
const requestId = response.headers.get("X-ModelRelay-Request-Id") || response.headers.get("X-Request-Id") || void 0;
|
|
139
148
|
const fallbackMessage = response.statusText || "Request failed";
|
|
@@ -220,7 +229,7 @@ async function parseErrorResponse(response, retries) {
|
|
|
220
229
|
// package.json
|
|
221
230
|
var package_default = {
|
|
222
231
|
name: "@modelrelay/sdk",
|
|
223
|
-
version: "
|
|
232
|
+
version: "7.0.0",
|
|
224
233
|
description: "TypeScript SDK for the ModelRelay API",
|
|
225
234
|
type: "module",
|
|
226
235
|
main: "dist/index.cjs",
|
|
@@ -355,15 +364,9 @@ var OutputItemTypes = {
|
|
|
355
364
|
};
|
|
356
365
|
var ToolTypes = {
|
|
357
366
|
Function: "function",
|
|
358
|
-
Web: "web",
|
|
359
367
|
XSearch: "x_search",
|
|
360
368
|
CodeExecution: "code_execution"
|
|
361
369
|
};
|
|
362
|
-
var WebToolIntents = {
|
|
363
|
-
Auto: "auto",
|
|
364
|
-
SearchWeb: "search_web",
|
|
365
|
-
FetchURL: "fetch_url"
|
|
366
|
-
};
|
|
367
370
|
var ToolChoiceTypes = {
|
|
368
371
|
Auto: "auto",
|
|
369
372
|
Required: "required",
|
|
@@ -490,7 +493,10 @@ function convertZodType(schema) {
|
|
|
490
493
|
case "ZodNullable":
|
|
491
494
|
return convertZodNullable(def);
|
|
492
495
|
case "ZodDefault":
|
|
493
|
-
return {
|
|
496
|
+
return {
|
|
497
|
+
...convertZodType(def.innerType),
|
|
498
|
+
default: def.defaultValue()
|
|
499
|
+
};
|
|
494
500
|
case "ZodEffects":
|
|
495
501
|
return convertZodType(def.schema);
|
|
496
502
|
case "ZodRecord":
|
|
@@ -685,9 +691,14 @@ function convertZodTuple(def) {
|
|
|
685
691
|
}
|
|
686
692
|
return result;
|
|
687
693
|
}
|
|
688
|
-
function
|
|
689
|
-
const jsonSchema = zodToJsonSchema(
|
|
690
|
-
|
|
694
|
+
function createTypedTool(def) {
|
|
695
|
+
const jsonSchema = zodToJsonSchema(def.parameters, def.options);
|
|
696
|
+
const tool = createFunctionTool(def.name, def.description, jsonSchema);
|
|
697
|
+
Object.defineProperty(tool, "_schema", {
|
|
698
|
+
value: def.parameters,
|
|
699
|
+
enumerable: false
|
|
700
|
+
});
|
|
701
|
+
return tool;
|
|
691
702
|
}
|
|
692
703
|
function createFunctionTool(name, description, parameters) {
|
|
693
704
|
const fn = { name, description };
|
|
@@ -699,17 +710,6 @@ function createFunctionTool(name, description, parameters) {
|
|
|
699
710
|
function: fn
|
|
700
711
|
};
|
|
701
712
|
}
|
|
702
|
-
function createWebTool(options) {
|
|
703
|
-
return {
|
|
704
|
-
type: ToolTypes.Web,
|
|
705
|
-
web: options ? {
|
|
706
|
-
intent: options.intent,
|
|
707
|
-
allowedDomains: options.allowedDomains,
|
|
708
|
-
excludedDomains: options.excludedDomains,
|
|
709
|
-
maxUses: options.maxUses
|
|
710
|
-
} : void 0
|
|
711
|
-
};
|
|
712
|
-
}
|
|
713
713
|
function toolChoiceAuto() {
|
|
714
714
|
return { type: ToolChoiceTypes.Auto };
|
|
715
715
|
}
|
|
@@ -824,7 +824,7 @@ var ToolArgsError = class extends Error {
|
|
|
824
824
|
this.rawArguments = rawArguments;
|
|
825
825
|
}
|
|
826
826
|
};
|
|
827
|
-
function
|
|
827
|
+
function parseToolArgsWithSchema(call, schema) {
|
|
828
828
|
const toolName = call.function?.name ?? "unknown";
|
|
829
829
|
const rawArgs = call.function?.arguments ?? "";
|
|
830
830
|
let parsed;
|
|
@@ -865,41 +865,89 @@ function parseToolArgs(call, schema) {
|
|
|
865
865
|
);
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
|
-
function
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
const toolName = call.function?.name ?? "unknown";
|
|
877
|
-
const rawArgs = call.function?.arguments ?? "";
|
|
878
|
-
return {
|
|
879
|
-
success: false,
|
|
880
|
-
error: new ToolArgsError(
|
|
881
|
-
err instanceof Error ? err.message : String(err),
|
|
882
|
-
call.id,
|
|
883
|
-
toolName,
|
|
884
|
-
rawArgs
|
|
885
|
-
)
|
|
886
|
-
};
|
|
868
|
+
function parseTypedToolCall(call, tool) {
|
|
869
|
+
if (!call.function) {
|
|
870
|
+
throw new ToolArgsError(
|
|
871
|
+
"Tool call missing function",
|
|
872
|
+
call.id,
|
|
873
|
+
tool.function.name,
|
|
874
|
+
""
|
|
875
|
+
);
|
|
887
876
|
}
|
|
888
|
-
|
|
889
|
-
function parseToolArgsRaw(call) {
|
|
890
|
-
const toolName = call.function?.name ?? "unknown";
|
|
891
|
-
const rawArgs = call.function?.arguments ?? "";
|
|
892
|
-
try {
|
|
893
|
-
return rawArgs ? JSON.parse(rawArgs) : {};
|
|
894
|
-
} catch (err) {
|
|
895
|
-
const message = err instanceof Error ? err.message : "Invalid JSON in arguments";
|
|
877
|
+
if (call.function.name !== tool.function.name) {
|
|
896
878
|
throw new ToolArgsError(
|
|
897
|
-
`
|
|
879
|
+
`Expected tool '${tool.function.name}', got '${call.function.name}'`,
|
|
898
880
|
call.id,
|
|
899
|
-
|
|
900
|
-
|
|
881
|
+
tool.function.name,
|
|
882
|
+
call.function.arguments ?? ""
|
|
901
883
|
);
|
|
902
884
|
}
|
|
885
|
+
const parsed = parseToolArgsWithSchema(call, tool._schema);
|
|
886
|
+
return {
|
|
887
|
+
...call,
|
|
888
|
+
function: {
|
|
889
|
+
...call.function,
|
|
890
|
+
arguments: parsed
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
function getTypedToolCall(response, tool) {
|
|
895
|
+
for (const item of response.output || []) {
|
|
896
|
+
for (const call of item?.toolCalls || []) {
|
|
897
|
+
if (call.function?.name === tool.function.name) {
|
|
898
|
+
return parseTypedToolCall(call, tool);
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
return void 0;
|
|
903
|
+
}
|
|
904
|
+
function getTypedToolCalls(response, tool) {
|
|
905
|
+
const result = [];
|
|
906
|
+
for (const item of response.output || []) {
|
|
907
|
+
for (const call of item?.toolCalls || []) {
|
|
908
|
+
if (call.function?.name === tool.function.name) {
|
|
909
|
+
result.push(parseTypedToolCall(call, tool));
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
return result;
|
|
914
|
+
}
|
|
915
|
+
function getToolName(call) {
|
|
916
|
+
return call.function?.name ?? "";
|
|
917
|
+
}
|
|
918
|
+
function getToolArgsRaw(call) {
|
|
919
|
+
return call.function?.arguments ?? "";
|
|
920
|
+
}
|
|
921
|
+
function getToolArgs(call) {
|
|
922
|
+
const raw = call.function?.arguments ?? "";
|
|
923
|
+
if (!raw) return {};
|
|
924
|
+
try {
|
|
925
|
+
return JSON.parse(raw);
|
|
926
|
+
} catch {
|
|
927
|
+
return {};
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
function getAllToolCalls(response) {
|
|
931
|
+
const calls = [];
|
|
932
|
+
for (const item of response.output || []) {
|
|
933
|
+
if (item.toolCalls) {
|
|
934
|
+
calls.push(...item.toolCalls);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
return calls;
|
|
938
|
+
}
|
|
939
|
+
function getAssistantText(response) {
|
|
940
|
+
const texts = [];
|
|
941
|
+
for (const item of response.output || []) {
|
|
942
|
+
if (item.role === "assistant" && item.content) {
|
|
943
|
+
for (const part of item.content) {
|
|
944
|
+
if (part.type === "text" && part.text) {
|
|
945
|
+
texts.push(part.text);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
return texts.join("");
|
|
903
951
|
}
|
|
904
952
|
var ToolRegistry = class {
|
|
905
953
|
constructor() {
|
|
@@ -1075,6 +1123,7 @@ export {
|
|
|
1075
1123
|
WorkflowValidationError,
|
|
1076
1124
|
ToolArgumentError,
|
|
1077
1125
|
PathEscapeError,
|
|
1126
|
+
AgentMaxTurnsError,
|
|
1078
1127
|
parseErrorResponse,
|
|
1079
1128
|
SDK_VERSION,
|
|
1080
1129
|
DEFAULT_BASE_URL,
|
|
@@ -1093,7 +1142,6 @@ export {
|
|
|
1093
1142
|
InputItemTypes,
|
|
1094
1143
|
OutputItemTypes,
|
|
1095
1144
|
ToolTypes,
|
|
1096
|
-
WebToolIntents,
|
|
1097
1145
|
ToolChoiceTypes,
|
|
1098
1146
|
OutputFormatTypes,
|
|
1099
1147
|
mergeMetrics,
|
|
@@ -1108,9 +1156,8 @@ export {
|
|
|
1108
1156
|
createToolCall,
|
|
1109
1157
|
createFunctionCall,
|
|
1110
1158
|
zodToJsonSchema,
|
|
1111
|
-
|
|
1159
|
+
createTypedTool,
|
|
1112
1160
|
createFunctionTool,
|
|
1113
|
-
createWebTool,
|
|
1114
1161
|
toolChoiceAuto,
|
|
1115
1162
|
toolChoiceRequired,
|
|
1116
1163
|
toolChoiceNone,
|
|
@@ -1121,9 +1168,14 @@ export {
|
|
|
1121
1168
|
assistantMessageWithToolCalls,
|
|
1122
1169
|
ToolCallAccumulator,
|
|
1123
1170
|
ToolArgsError,
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1171
|
+
parseTypedToolCall,
|
|
1172
|
+
getTypedToolCall,
|
|
1173
|
+
getTypedToolCalls,
|
|
1174
|
+
getToolName,
|
|
1175
|
+
getToolArgsRaw,
|
|
1176
|
+
getToolArgs,
|
|
1177
|
+
getAllToolCalls,
|
|
1178
|
+
getAssistantText,
|
|
1127
1179
|
ToolRegistry,
|
|
1128
1180
|
formatToolErrorForModel,
|
|
1129
1181
|
hasRetryableErrors,
|
|
@@ -220,7 +220,7 @@ async function parseErrorResponse(response, retries) {
|
|
|
220
220
|
// package.json
|
|
221
221
|
var package_default = {
|
|
222
222
|
name: "@modelrelay/sdk",
|
|
223
|
-
version: "
|
|
223
|
+
version: "5.1.0",
|
|
224
224
|
description: "TypeScript SDK for the ModelRelay API",
|
|
225
225
|
type: "module",
|
|
226
226
|
main: "dist/index.cjs",
|