@copilotkitnext/core 0.0.22-alpha.6 → 0.0.22-alpha.8

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.js CHANGED
@@ -1,46 +1,11 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
19
2
 
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- AgentRegistry: () => AgentRegistry,
24
- ContextStore: () => ContextStore,
25
- CopilotKitCore: () => CopilotKitCore,
26
- CopilotKitCoreErrorCode: () => CopilotKitCoreErrorCode,
27
- CopilotKitCoreRuntimeConnectionStatus: () => CopilotKitCoreRuntimeConnectionStatus,
28
- ProxiedCopilotRuntimeAgent: () => ProxiedCopilotRuntimeAgent,
29
- RunHandler: () => RunHandler,
30
- StateManager: () => StateManager,
31
- SuggestionEngine: () => SuggestionEngine,
32
- ToolCallStatus: () => ToolCallStatus,
33
- completePartialMarkdown: () => completePartialMarkdown
34
- });
35
- module.exports = __toCommonJS(index_exports);
3
+ var client = require('@ag-ui/client');
4
+ var shared = require('@copilotkitnext/shared');
5
+ var zodToJsonSchema = require('zod-to-json-schema');
36
6
 
37
7
  // src/core/agent-registry.ts
38
- var import_client2 = require("@ag-ui/client");
39
- var import_shared = require("@copilotkitnext/shared");
40
-
41
- // src/agent.ts
42
- var import_client = require("@ag-ui/client");
43
- var ProxiedCopilotRuntimeAgent = class extends import_client.HttpAgent {
8
+ var ProxiedCopilotRuntimeAgent = class extends client.HttpAgent {
44
9
  runtimeUrl;
45
10
  transport;
46
11
  singleEndpointUrl;
@@ -113,11 +78,11 @@ var ProxiedCopilotRuntimeAgent = class extends import_client.HttpAgent {
113
78
  const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", {
114
79
  agentId: this.agentId
115
80
  });
116
- const httpEvents2 = (0, import_client.runHttpRequest)(this.singleEndpointUrl, requestInit);
117
- return (0, import_client.transformHttpEventStream)(httpEvents2);
81
+ const httpEvents2 = client.runHttpRequest(this.singleEndpointUrl, requestInit);
82
+ return client.transformHttpEventStream(httpEvents2);
118
83
  }
119
- const httpEvents = (0, import_client.runHttpRequest)(`${this.runtimeUrl}/agent/${this.agentId}/connect`, this.requestInit(input));
120
- return (0, import_client.transformHttpEventStream)(httpEvents);
84
+ const httpEvents = client.runHttpRequest(`${this.runtimeUrl}/agent/${this.agentId}/connect`, this.requestInit(input));
85
+ return client.transformHttpEventStream(httpEvents);
121
86
  }
122
87
  run(input) {
123
88
  if (this.transport === "single") {
@@ -127,8 +92,8 @@ var ProxiedCopilotRuntimeAgent = class extends import_client.HttpAgent {
127
92
  const requestInit = this.createSingleRouteRequestInit(input, "agent/run", {
128
93
  agentId: this.agentId
129
94
  });
130
- const httpEvents = (0, import_client.runHttpRequest)(this.singleEndpointUrl, requestInit);
131
- return (0, import_client.transformHttpEventStream)(httpEvents);
95
+ const httpEvents = client.runHttpRequest(this.singleEndpointUrl, requestInit);
96
+ return client.transformHttpEventStream(httpEvents);
132
97
  }
133
98
  return super.run(input);
134
99
  }
@@ -271,7 +236,7 @@ var AgentRegistry = class {
271
236
  * Apply current headers to an agent
272
237
  */
273
238
  applyHeadersToAgent(agent) {
274
- if (agent instanceof import_client2.HttpAgent) {
239
+ if (agent instanceof client.HttpAgent) {
275
240
  agent.headers = { ...this.core.headers };
276
241
  }
277
242
  }
@@ -334,7 +299,7 @@ var AgentRegistry = class {
334
299
  await this.notifyRuntimeStatusChanged("error" /* Error */);
335
300
  await this.notifyAgentsChanged();
336
301
  const message = error instanceof Error ? error.message : JSON.stringify(error);
337
- import_shared.logger.warn(`Failed to load runtime info (${this.runtimeUrl}/info): ${message}`);
302
+ shared.logger.warn(`Failed to load runtime info (${this.runtimeUrl}/info): ${message}`);
338
303
  const runtimeError = error instanceof Error ? error : new Error(String(error));
339
304
  await this.core.emitError({
340
305
  error: runtimeError,
@@ -424,9 +389,6 @@ var AgentRegistry = class {
424
389
  );
425
390
  }
426
391
  };
427
-
428
- // src/core/context-store.ts
429
- var import_shared2 = require("@copilotkitnext/shared");
430
392
  var ContextStore = class {
431
393
  constructor(core) {
432
394
  this.core = core;
@@ -443,7 +405,7 @@ var ContextStore = class {
443
405
  * @returns The ID of the created context entry
444
406
  */
445
407
  addContext({ description, value }) {
446
- const id = (0, import_shared2.randomUUID)();
408
+ const id = shared.randomUUID();
447
409
  this._context[id] = { description, value };
448
410
  void this.notifySubscribers();
449
411
  return id;
@@ -468,9 +430,6 @@ var ContextStore = class {
468
430
  );
469
431
  }
470
432
  };
471
-
472
- // src/core/suggestion-engine.ts
473
- var import_shared3 = require("@copilotkitnext/shared");
474
433
  var SuggestionEngine = class {
475
434
  constructor(core) {
476
435
  this.core = core;
@@ -483,7 +442,7 @@ var SuggestionEngine = class {
483
442
  */
484
443
  initialize(suggestionsConfig) {
485
444
  for (const config of suggestionsConfig) {
486
- this._suggestionsConfig[(0, import_shared3.randomUUID)()] = config;
445
+ this._suggestionsConfig[shared.randomUUID()] = config;
487
446
  }
488
447
  }
489
448
  /**
@@ -491,7 +450,7 @@ var SuggestionEngine = class {
491
450
  * @returns The ID of the created config
492
451
  */
493
452
  addSuggestionsConfig(config) {
494
- const id = (0, import_shared3.randomUUID)();
453
+ const id = shared.randomUUID();
495
454
  this._suggestionsConfig[id] = config;
496
455
  void this.notifySuggestionsConfigChanged();
497
456
  return id;
@@ -522,7 +481,7 @@ var SuggestionEngine = class {
522
481
  if (!this.shouldShowSuggestions(config, messageCount)) {
523
482
  continue;
524
483
  }
525
- const suggestionId = (0, import_shared3.randomUUID)();
484
+ const suggestionId = shared.randomUUID();
526
485
  if (isDynamicSuggestionsConfig(config)) {
527
486
  if (!hasAnySuggestions) {
528
487
  hasAnySuggestions = true;
@@ -656,7 +615,7 @@ var SuggestionEngine = class {
656
615
  for (const toolCall of message.toolCalls) {
657
616
  if (toolCall.function.name === "copilotkitSuggest") {
658
617
  const fullArgs = Array.isArray(toolCall.function.arguments) ? toolCall.function.arguments.join("") : toolCall.function.arguments;
659
- const parsed = (0, import_shared3.partialJSONParse)(fullArgs);
618
+ const parsed = shared.partialJSONParse(fullArgs);
660
619
  if (parsed && typeof parsed === "object" && "suggestions" in parsed) {
661
620
  const parsedSuggestions = parsed.suggestions;
662
621
  if (Array.isArray(parsedSuggestions)) {
@@ -812,11 +771,6 @@ var SUGGEST_TOOL = {
812
771
  additionalProperties: false
813
772
  }
814
773
  };
815
-
816
- // src/core/run-handler.ts
817
- var import_client3 = require("@ag-ui/client");
818
- var import_shared4 = require("@copilotkitnext/shared");
819
- var import_zod_to_json_schema = require("zod-to-json-schema");
820
774
  var RunHandler = class {
821
775
  constructor(core) {
822
776
  this.core = core;
@@ -841,7 +795,7 @@ var RunHandler = class {
841
795
  addTool(tool) {
842
796
  const existingToolIndex = this._tools.findIndex((t) => t.name === tool.name && t.agentId === tool.agentId);
843
797
  if (existingToolIndex !== -1) {
844
- import_shared4.logger.warn(`Tool already exists: '${tool.name}' for agent '${tool.agentId || "global"}', skipping.`);
798
+ shared.logger.warn(`Tool already exists: '${tool.name}' for agent '${tool.agentId || "global"}', skipping.`);
845
799
  return;
846
800
  }
847
801
  this._tools.push(tool);
@@ -883,7 +837,7 @@ var RunHandler = class {
883
837
  */
884
838
  async connectAgent({ agent }) {
885
839
  try {
886
- if (agent instanceof import_client3.HttpAgent) {
840
+ if (agent instanceof client.HttpAgent) {
887
841
  agent.headers = { ...this.core.headers };
888
842
  }
889
843
  const runAgentResult = await agent.connectAgent(
@@ -915,7 +869,7 @@ var RunHandler = class {
915
869
  if (agent.agentId) {
916
870
  void this.core.suggestionEngine.clearSuggestions(agent.agentId);
917
871
  }
918
- if (agent instanceof import_client3.HttpAgent) {
872
+ if (agent instanceof client.HttpAgent) {
919
873
  agent.headers = { ...this.core.headers };
920
874
  }
921
875
  if (withMessages) {
@@ -1079,7 +1033,7 @@ var RunHandler = class {
1079
1033
  if (!errorMessage || !isArgumentError) {
1080
1034
  const messageIndex = agent.messages.findIndex((m) => m.id === message.id);
1081
1035
  const toolMessage = {
1082
- id: (0, import_shared4.randomUUID)(),
1036
+ id: shared.randomUUID(),
1083
1037
  role: "tool",
1084
1038
  toolCallId: toolCall.id,
1085
1039
  content: toolCallResult
@@ -1184,7 +1138,7 @@ var RunHandler = class {
1184
1138
  if (!errorMessage || !isArgumentError) {
1185
1139
  const messageIndex = agent.messages.findIndex((m) => m.id === message.id);
1186
1140
  const toolMessage = {
1187
- id: (0, import_shared4.randomUUID)(),
1141
+ id: shared.randomUUID(),
1188
1142
  role: "tool",
1189
1143
  toolCallId: toolCall.id,
1190
1144
  content: toolCallResult
@@ -1252,7 +1206,7 @@ function createToolSchema(tool) {
1252
1206
  if (!tool.parameters) {
1253
1207
  return EMPTY_TOOL_SCHEMA;
1254
1208
  }
1255
- const rawSchema = (0, import_zod_to_json_schema.zodToJsonSchema)(tool.parameters, {
1209
+ const rawSchema = zodToJsonSchema.zodToJsonSchema(tool.parameters, {
1256
1210
  $refStrategy: "none"
1257
1211
  });
1258
1212
  if (!rawSchema || typeof rawSchema !== "object") {
@@ -1927,18 +1881,17 @@ ${indent}${fence}`;
1927
1881
  }
1928
1882
  return result;
1929
1883
  }
1930
- // Annotate the CommonJS export names for ESM import in node:
1931
- 0 && (module.exports = {
1932
- AgentRegistry,
1933
- ContextStore,
1934
- CopilotKitCore,
1935
- CopilotKitCoreErrorCode,
1936
- CopilotKitCoreRuntimeConnectionStatus,
1937
- ProxiedCopilotRuntimeAgent,
1938
- RunHandler,
1939
- StateManager,
1940
- SuggestionEngine,
1941
- ToolCallStatus,
1942
- completePartialMarkdown
1943
- });
1884
+
1885
+ exports.AgentRegistry = AgentRegistry;
1886
+ exports.ContextStore = ContextStore;
1887
+ exports.CopilotKitCore = CopilotKitCore;
1888
+ exports.CopilotKitCoreErrorCode = CopilotKitCoreErrorCode;
1889
+ exports.CopilotKitCoreRuntimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus;
1890
+ exports.ProxiedCopilotRuntimeAgent = ProxiedCopilotRuntimeAgent;
1891
+ exports.RunHandler = RunHandler;
1892
+ exports.StateManager = StateManager;
1893
+ exports.SuggestionEngine = SuggestionEngine;
1894
+ exports.ToolCallStatus = ToolCallStatus;
1895
+ exports.completePartialMarkdown = completePartialMarkdown;
1896
+ //# sourceMappingURL=index.js.map
1944
1897
  //# sourceMappingURL=index.js.map