@copilotkit/core 1.59.5 → 1.60.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/dist/index.cjs CHANGED
@@ -691,9 +691,11 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
691
691
  if (this.transport === "single") {
692
692
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
693
693
  const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", { agentId: routedId });
694
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
694
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
695
695
  }
696
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(`${this.runtimeUrl}/agent/${routedId}/connect`, this.requestInit(input))));
696
+ const connectUrl = `${this.runtimeUrl}/agent/${routedId}/connect`;
697
+ const connectRequestInit = this.requestInit(input);
698
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(connectUrl, connectRequestInit))));
697
699
  }
698
700
  #runViaDelegate(input) {
699
701
  return (0, rxjs.defer)(() => (0, rxjs.from)(this.resolveDelegate())).pipe((0, rxjs_operators.switchMap)((delegate) => withAbortErrorHandling(delegate.run(input))));
@@ -702,7 +704,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
702
704
  if (this.transport === "single") {
703
705
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
704
706
  const requestInit = this.createSingleRouteRequestInit(input, "agent/run", { agentId: this.routedAgentId() });
705
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
707
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
706
708
  }
707
709
  return withAbortErrorHandling(super.run(input));
708
710
  }
@@ -875,6 +877,7 @@ var AgentRegistry = class {
875
877
  _runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
876
878
  _intelligence;
877
879
  _a2uiEnabled = false;
880
+ _a2uiAgents;
878
881
  _openGenerativeUIEnabled = false;
879
882
  _licenseStatus;
880
883
  _telemetryDisabled = false;
@@ -911,6 +914,13 @@ var AgentRegistry = class {
911
914
  get a2uiEnabled() {
912
915
  return this._a2uiEnabled;
913
916
  }
917
+ /**
918
+ * Agent ids the runtime applies A2UI to (#5369). `undefined` means A2UI
919
+ * applies to every agent — or is disabled entirely; check `a2uiEnabled`.
920
+ */
921
+ get a2uiAgents() {
922
+ return this._a2uiAgents;
923
+ }
914
924
  get openGenerativeUIEnabled() {
915
925
  return this._openGenerativeUIEnabled;
916
926
  }
@@ -1079,6 +1089,7 @@ var AgentRegistry = class {
1079
1089
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1080
1090
  this._intelligence = void 0;
1081
1091
  this._a2uiEnabled = false;
1092
+ this._a2uiAgents = void 0;
1082
1093
  this._openGenerativeUIEnabled = false;
1083
1094
  this.remoteAgents = {};
1084
1095
  this._agents = this.localAgents;
@@ -1117,7 +1128,9 @@ var AgentRegistry = class {
1117
1128
  this._audioFileTranscriptionEnabled = runtimeInfoResponse.audioFileTranscriptionEnabled ?? false;
1118
1129
  this._runtimeMode = runtimeInfoResponse.mode ?? _copilotkit_shared.RUNTIME_MODE_SSE;
1119
1130
  this._intelligence = runtimeInfoResponse.intelligence;
1120
- this._a2uiEnabled = runtimeInfoResponse.a2uiEnabled ?? false;
1131
+ const a2uiInfo = runtimeInfoResponse.a2ui;
1132
+ this._a2uiEnabled = a2uiInfo?.enabled ?? runtimeInfoResponse.a2uiEnabled ?? false;
1133
+ this._a2uiAgents = a2uiInfo?.enabled ? a2uiInfo.agents : void 0;
1121
1134
  this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
1122
1135
  this._licenseStatus = runtimeInfoResponse.licenseStatus;
1123
1136
  this._telemetryDisabled = runtimeInfoResponse.telemetryDisabled ?? false;
@@ -1130,6 +1143,7 @@ var AgentRegistry = class {
1130
1143
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1131
1144
  this._intelligence = void 0;
1132
1145
  this._a2uiEnabled = false;
1146
+ this._a2uiAgents = void 0;
1133
1147
  this._openGenerativeUIEnabled = false;
1134
1148
  this.remoteAgents = {};
1135
1149
  this._agents = this.localAgents;
@@ -1243,19 +1257,32 @@ var ContextStore = class {
1243
1257
  return this._context;
1244
1258
  }
1245
1259
  /**
1246
- * Add a new context entry
1260
+ * Add a new context entry. Pass `agentIds` to restrict the entry to runs of
1261
+ * specific agents (#5369); omit it for context every agent should receive.
1247
1262
  * @returns The ID of the created context entry
1248
1263
  */
1249
- addContext({ description, value }) {
1264
+ addContext({ description, value, agentIds }) {
1250
1265
  const id = (0, _copilotkit_shared.randomUUID)();
1251
1266
  this._context[id] = {
1252
1267
  description,
1253
- value
1268
+ value,
1269
+ ...agentIds ? { agentIds } : {}
1254
1270
  };
1255
1271
  this.notifySubscribers();
1256
1272
  return id;
1257
1273
  }
1258
1274
  /**
1275
+ * Build the context array for a run of the given agent: entries scoped to
1276
+ * other agents are dropped, and the scoping metadata is stripped so only
1277
+ * protocol-shaped `{ description, value }` entries go over the wire.
1278
+ */
1279
+ getContextForAgent(agentId) {
1280
+ return Object.values(this._context).filter((entry) => !entry.agentIds || agentId !== void 0 && entry.agentIds.includes(agentId)).map(({ description, value }) => ({
1281
+ description,
1282
+ value
1283
+ }));
1284
+ }
1285
+ /**
1259
1286
  * Remove a context entry by ID
1260
1287
  */
1261
1288
  removeContext(id) {
@@ -1383,7 +1410,7 @@ var SuggestionEngine = class {
1383
1410
  ].join("\n")
1384
1411
  });
1385
1412
  await agent.runAgent({
1386
- context: Object.values(this.core.context),
1413
+ context: this.core.getContextForAgent(consumerAgentId),
1387
1414
  forwardedProps: {
1388
1415
  ...this.core.properties,
1389
1416
  toolChoice: {
@@ -1693,7 +1720,7 @@ var RunHandler = class {
1693
1720
  const runAgentResult = await agent.connectAgent({
1694
1721
  forwardedProps: this._internal.properties,
1695
1722
  tools: this.buildFrontendTools(agent.agentId),
1696
- context: Object.values(this._internal.context)
1723
+ context: this._internal.getContextForAgent(agent.agentId)
1697
1724
  }, this.createAgentErrorSubscriber(agent));
1698
1725
  return this.processAgentResult({
1699
1726
  runAgentResult,
@@ -1739,7 +1766,7 @@ var RunHandler = class {
1739
1766
  ...forwardedProps
1740
1767
  },
1741
1768
  tools: this.buildFrontendTools(agent.agentId),
1742
- context: Object.values(this._internal.context)
1769
+ context: this._internal.getContextForAgent(agent.agentId)
1743
1770
  }, this.createAgentErrorSubscriber(agent));
1744
1771
  return await this.processAgentResult({
1745
1772
  runAgentResult,
@@ -2676,6 +2703,13 @@ var CopilotKitCore = class {
2676
2703
  get a2uiEnabled() {
2677
2704
  return this.agentRegistry.a2uiEnabled;
2678
2705
  }
2706
+ /**
2707
+ * Agent ids the runtime applies A2UI to. `undefined` means A2UI applies to
2708
+ * every agent (or is disabled — check `a2uiEnabled`).
2709
+ */
2710
+ get a2uiAgents() {
2711
+ return this.agentRegistry.a2uiAgents;
2712
+ }
2679
2713
  get openGenerativeUIEnabled() {
2680
2714
  return this.agentRegistry.openGenerativeUIEnabled;
2681
2715
  }
@@ -2745,7 +2779,9 @@ var CopilotKitCore = class {
2745
2779
  return this.agentRegistry.getAgent(id);
2746
2780
  }
2747
2781
  /**
2748
- * Context management (delegated to ContextStore)
2782
+ * Context management (delegated to ContextStore).
2783
+ * Pass `agentIds` to restrict the entry to runs of specific agents;
2784
+ * omit it for context every agent should receive.
2749
2785
  */
2750
2786
  addContext(context) {
2751
2787
  return this.contextStore.addContext(context);
@@ -2754,6 +2790,13 @@ var CopilotKitCore = class {
2754
2790
  this.contextStore.removeContext(id);
2755
2791
  }
2756
2792
  /**
2793
+ * Build the context array for a run of the given agent, dropping entries
2794
+ * scoped to other agents and stripping the scoping metadata.
2795
+ */
2796
+ getContextForAgent(agentId) {
2797
+ return this.contextStore.getContextForAgent(agentId);
2798
+ }
2799
+ /**
2757
2800
  * Thread store registry (delegated to ThreadStoreRegistry)
2758
2801
  */
2759
2802
  registerThreadStore(agentId, store) {