@copilotkitnext/core 1.53.1-next.2 → 1.54.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +11 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +15 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -5
package/dist/index.cjs
CHANGED
|
@@ -898,7 +898,7 @@ var RunHandler = class {
|
|
|
898
898
|
if (tool?.handler) {
|
|
899
899
|
let parsedArgs;
|
|
900
900
|
try {
|
|
901
|
-
parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
901
|
+
parsedArgs = ensureObjectArgs(JSON.parse(toolCall.function.arguments), toolCall.function.name);
|
|
902
902
|
} catch (error) {
|
|
903
903
|
const parseError = error instanceof Error ? error : new Error(String(error));
|
|
904
904
|
errorMessage = parseError.message;
|
|
@@ -980,7 +980,7 @@ var RunHandler = class {
|
|
|
980
980
|
if (wildcardTool?.handler) {
|
|
981
981
|
let parsedArgs;
|
|
982
982
|
try {
|
|
983
|
-
parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
983
|
+
parsedArgs = ensureObjectArgs(JSON.parse(toolCall.function.arguments), toolCall.function.name);
|
|
984
984
|
} catch (error) {
|
|
985
985
|
const parseError = error instanceof Error ? error : new Error(String(error));
|
|
986
986
|
errorMessage = parseError.message;
|
|
@@ -1109,7 +1109,7 @@ const EMPTY_TOOL_SCHEMA = {
|
|
|
1109
1109
|
*/
|
|
1110
1110
|
function createToolSchema(tool) {
|
|
1111
1111
|
if (!tool.parameters) return { ...EMPTY_TOOL_SCHEMA };
|
|
1112
|
-
const rawSchema = (0,
|
|
1112
|
+
const rawSchema = (0, _copilotkitnext_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: zod_to_json_schema.zodToJsonSchema });
|
|
1113
1113
|
if (!rawSchema || typeof rawSchema !== "object") return { ...EMPTY_TOOL_SCHEMA };
|
|
1114
1114
|
const { $schema, ...schema } = rawSchema;
|
|
1115
1115
|
if (typeof schema.type !== "string") schema.type = "object";
|
|
@@ -1127,6 +1127,17 @@ function stripAdditionalProperties(schema) {
|
|
|
1127
1127
|
if (record.additionalProperties !== void 0) delete record.additionalProperties;
|
|
1128
1128
|
for (const value of Object.values(record)) stripAdditionalProperties(value);
|
|
1129
1129
|
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Ensures parsed tool arguments are a plain object.
|
|
1132
|
+
* Throws for non-object values so the caller's catch block can emit
|
|
1133
|
+
* a structured TOOL_ARGUMENT_PARSE_FAILED error.
|
|
1134
|
+
*
|
|
1135
|
+
* @internal Exported for testing only.
|
|
1136
|
+
*/
|
|
1137
|
+
function ensureObjectArgs(parsed, toolName) {
|
|
1138
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) return parsed;
|
|
1139
|
+
throw new Error(`Tool arguments for ${toolName} parsed to non-object (${typeof parsed})`);
|
|
1140
|
+
}
|
|
1130
1141
|
|
|
1131
1142
|
//#endregion
|
|
1132
1143
|
//#region src/core/state-manager.ts
|
|
@@ -1910,4 +1921,5 @@ exports.StateManager = StateManager;
|
|
|
1910
1921
|
exports.SuggestionEngine = SuggestionEngine;
|
|
1911
1922
|
exports.ToolCallStatus = ToolCallStatus;
|
|
1912
1923
|
exports.completePartialMarkdown = completePartialMarkdown;
|
|
1924
|
+
exports.ensureObjectArgs = ensureObjectArgs;
|
|
1913
1925
|
//# sourceMappingURL=index.cjs.map
|