@copilotkitnext/core 1.53.1-next.1 → 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 +25 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -3
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +14 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +26 -5
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +26 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +8 -5
package/dist/index.cjs
CHANGED
|
@@ -148,6 +148,7 @@ var AgentRegistry = class {
|
|
|
148
148
|
_runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
149
149
|
_runtimeTransport = "rest";
|
|
150
150
|
_audioFileTranscriptionEnabled = false;
|
|
151
|
+
_a2uiEnabled = false;
|
|
151
152
|
constructor(core) {
|
|
152
153
|
this.core = core;
|
|
153
154
|
}
|
|
@@ -172,6 +173,9 @@ var AgentRegistry = class {
|
|
|
172
173
|
get audioFileTranscriptionEnabled() {
|
|
173
174
|
return this._audioFileTranscriptionEnabled;
|
|
174
175
|
}
|
|
176
|
+
get a2uiEnabled() {
|
|
177
|
+
return this._a2uiEnabled;
|
|
178
|
+
}
|
|
175
179
|
/**
|
|
176
180
|
* Initialize agents from configuration
|
|
177
181
|
*/
|
|
@@ -278,6 +282,7 @@ var AgentRegistry = class {
|
|
|
278
282
|
this._runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
279
283
|
this._runtimeVersion = void 0;
|
|
280
284
|
this._audioFileTranscriptionEnabled = false;
|
|
285
|
+
this._a2uiEnabled = false;
|
|
281
286
|
this.remoteAgents = {};
|
|
282
287
|
this._agents = this.localAgents;
|
|
283
288
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Disconnected);
|
|
@@ -308,12 +313,14 @@ var AgentRegistry = class {
|
|
|
308
313
|
this._runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Connected;
|
|
309
314
|
this._runtimeVersion = version;
|
|
310
315
|
this._audioFileTranscriptionEnabled = runtimeInfoResponse.audioFileTranscriptionEnabled ?? false;
|
|
316
|
+
this._a2uiEnabled = runtimeInfoResponse.a2uiEnabled ?? false;
|
|
311
317
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connected);
|
|
312
318
|
await this.notifyAgentsChanged();
|
|
313
319
|
} catch (error) {
|
|
314
320
|
this._runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Error;
|
|
315
321
|
this._runtimeVersion = void 0;
|
|
316
322
|
this._audioFileTranscriptionEnabled = false;
|
|
323
|
+
this._a2uiEnabled = false;
|
|
317
324
|
this.remoteAgents = {};
|
|
318
325
|
this._agents = this.localAgents;
|
|
319
326
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Error);
|
|
@@ -891,7 +898,7 @@ var RunHandler = class {
|
|
|
891
898
|
if (tool?.handler) {
|
|
892
899
|
let parsedArgs;
|
|
893
900
|
try {
|
|
894
|
-
parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
901
|
+
parsedArgs = ensureObjectArgs(JSON.parse(toolCall.function.arguments), toolCall.function.name);
|
|
895
902
|
} catch (error) {
|
|
896
903
|
const parseError = error instanceof Error ? error : new Error(String(error));
|
|
897
904
|
errorMessage = parseError.message;
|
|
@@ -973,7 +980,7 @@ var RunHandler = class {
|
|
|
973
980
|
if (wildcardTool?.handler) {
|
|
974
981
|
let parsedArgs;
|
|
975
982
|
try {
|
|
976
|
-
parsedArgs = JSON.parse(toolCall.function.arguments);
|
|
983
|
+
parsedArgs = ensureObjectArgs(JSON.parse(toolCall.function.arguments), toolCall.function.name);
|
|
977
984
|
} catch (error) {
|
|
978
985
|
const parseError = error instanceof Error ? error : new Error(String(error));
|
|
979
986
|
errorMessage = parseError.message;
|
|
@@ -1102,7 +1109,7 @@ const EMPTY_TOOL_SCHEMA = {
|
|
|
1102
1109
|
*/
|
|
1103
1110
|
function createToolSchema(tool) {
|
|
1104
1111
|
if (!tool.parameters) return { ...EMPTY_TOOL_SCHEMA };
|
|
1105
|
-
const rawSchema = (0,
|
|
1112
|
+
const rawSchema = (0, _copilotkitnext_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: zod_to_json_schema.zodToJsonSchema });
|
|
1106
1113
|
if (!rawSchema || typeof rawSchema !== "object") return { ...EMPTY_TOOL_SCHEMA };
|
|
1107
1114
|
const { $schema, ...schema } = rawSchema;
|
|
1108
1115
|
if (typeof schema.type !== "string") schema.type = "object";
|
|
@@ -1120,6 +1127,17 @@ function stripAdditionalProperties(schema) {
|
|
|
1120
1127
|
if (record.additionalProperties !== void 0) delete record.additionalProperties;
|
|
1121
1128
|
for (const value of Object.values(record)) stripAdditionalProperties(value);
|
|
1122
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
|
+
}
|
|
1123
1141
|
|
|
1124
1142
|
//#endregion
|
|
1125
1143
|
//#region src/core/state-manager.ts
|
|
@@ -1412,6 +1430,9 @@ var CopilotKitCore = class {
|
|
|
1412
1430
|
get audioFileTranscriptionEnabled() {
|
|
1413
1431
|
return this.agentRegistry.audioFileTranscriptionEnabled;
|
|
1414
1432
|
}
|
|
1433
|
+
get a2uiEnabled() {
|
|
1434
|
+
return this.agentRegistry.a2uiEnabled;
|
|
1435
|
+
}
|
|
1415
1436
|
/**
|
|
1416
1437
|
* Configuration updates
|
|
1417
1438
|
*/
|
|
@@ -1900,4 +1921,5 @@ exports.StateManager = StateManager;
|
|
|
1900
1921
|
exports.SuggestionEngine = SuggestionEngine;
|
|
1901
1922
|
exports.ToolCallStatus = ToolCallStatus;
|
|
1902
1923
|
exports.completePartialMarkdown = completePartialMarkdown;
|
|
1924
|
+
exports.ensureObjectArgs = ensureObjectArgs;
|
|
1903
1925
|
//# sourceMappingURL=index.cjs.map
|