@copilotkit/core 1.59.5-canary.1781104893 → 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.mjs CHANGED
@@ -876,6 +876,7 @@ var AgentRegistry = class {
876
876
  _runtimeMode = RUNTIME_MODE_SSE;
877
877
  _intelligence;
878
878
  _a2uiEnabled = false;
879
+ _a2uiAgents;
879
880
  _openGenerativeUIEnabled = false;
880
881
  _licenseStatus;
881
882
  _telemetryDisabled = false;
@@ -912,6 +913,13 @@ var AgentRegistry = class {
912
913
  get a2uiEnabled() {
913
914
  return this._a2uiEnabled;
914
915
  }
916
+ /**
917
+ * Agent ids the runtime applies A2UI to (#5369). `undefined` means A2UI
918
+ * applies to every agent — or is disabled entirely; check `a2uiEnabled`.
919
+ */
920
+ get a2uiAgents() {
921
+ return this._a2uiAgents;
922
+ }
915
923
  get openGenerativeUIEnabled() {
916
924
  return this._openGenerativeUIEnabled;
917
925
  }
@@ -1080,6 +1088,7 @@ var AgentRegistry = class {
1080
1088
  this._runtimeMode = RUNTIME_MODE_SSE;
1081
1089
  this._intelligence = void 0;
1082
1090
  this._a2uiEnabled = false;
1091
+ this._a2uiAgents = void 0;
1083
1092
  this._openGenerativeUIEnabled = false;
1084
1093
  this.remoteAgents = {};
1085
1094
  this._agents = this.localAgents;
@@ -1118,7 +1127,9 @@ var AgentRegistry = class {
1118
1127
  this._audioFileTranscriptionEnabled = runtimeInfoResponse.audioFileTranscriptionEnabled ?? false;
1119
1128
  this._runtimeMode = runtimeInfoResponse.mode ?? RUNTIME_MODE_SSE;
1120
1129
  this._intelligence = runtimeInfoResponse.intelligence;
1121
- this._a2uiEnabled = runtimeInfoResponse.a2uiEnabled ?? false;
1130
+ const a2uiInfo = runtimeInfoResponse.a2ui;
1131
+ this._a2uiEnabled = a2uiInfo?.enabled ?? runtimeInfoResponse.a2uiEnabled ?? false;
1132
+ this._a2uiAgents = a2uiInfo?.enabled ? a2uiInfo.agents : void 0;
1122
1133
  this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
1123
1134
  this._licenseStatus = runtimeInfoResponse.licenseStatus;
1124
1135
  this._telemetryDisabled = runtimeInfoResponse.telemetryDisabled ?? false;
@@ -1131,6 +1142,7 @@ var AgentRegistry = class {
1131
1142
  this._runtimeMode = RUNTIME_MODE_SSE;
1132
1143
  this._intelligence = void 0;
1133
1144
  this._a2uiEnabled = false;
1145
+ this._a2uiAgents = void 0;
1134
1146
  this._openGenerativeUIEnabled = false;
1135
1147
  this.remoteAgents = {};
1136
1148
  this._agents = this.localAgents;
@@ -1244,19 +1256,32 @@ var ContextStore = class {
1244
1256
  return this._context;
1245
1257
  }
1246
1258
  /**
1247
- * Add a new context entry
1259
+ * Add a new context entry. Pass `agentIds` to restrict the entry to runs of
1260
+ * specific agents (#5369); omit it for context every agent should receive.
1248
1261
  * @returns The ID of the created context entry
1249
1262
  */
1250
- addContext({ description, value }) {
1263
+ addContext({ description, value, agentIds }) {
1251
1264
  const id = randomUUID$1();
1252
1265
  this._context[id] = {
1253
1266
  description,
1254
- value
1267
+ value,
1268
+ ...agentIds ? { agentIds } : {}
1255
1269
  };
1256
1270
  this.notifySubscribers();
1257
1271
  return id;
1258
1272
  }
1259
1273
  /**
1274
+ * Build the context array for a run of the given agent: entries scoped to
1275
+ * other agents are dropped, and the scoping metadata is stripped so only
1276
+ * protocol-shaped `{ description, value }` entries go over the wire.
1277
+ */
1278
+ getContextForAgent(agentId) {
1279
+ return Object.values(this._context).filter((entry) => !entry.agentIds || agentId !== void 0 && entry.agentIds.includes(agentId)).map(({ description, value }) => ({
1280
+ description,
1281
+ value
1282
+ }));
1283
+ }
1284
+ /**
1260
1285
  * Remove a context entry by ID
1261
1286
  */
1262
1287
  removeContext(id) {
@@ -1384,7 +1409,7 @@ var SuggestionEngine = class {
1384
1409
  ].join("\n")
1385
1410
  });
1386
1411
  await agent.runAgent({
1387
- context: Object.values(this.core.context),
1412
+ context: this.core.getContextForAgent(consumerAgentId),
1388
1413
  forwardedProps: {
1389
1414
  ...this.core.properties,
1390
1415
  toolChoice: {
@@ -1694,7 +1719,7 @@ var RunHandler = class {
1694
1719
  const runAgentResult = await agent.connectAgent({
1695
1720
  forwardedProps: this._internal.properties,
1696
1721
  tools: this.buildFrontendTools(agent.agentId),
1697
- context: Object.values(this._internal.context)
1722
+ context: this._internal.getContextForAgent(agent.agentId)
1698
1723
  }, this.createAgentErrorSubscriber(agent));
1699
1724
  return this.processAgentResult({
1700
1725
  runAgentResult,
@@ -1740,7 +1765,7 @@ var RunHandler = class {
1740
1765
  ...forwardedProps
1741
1766
  },
1742
1767
  tools: this.buildFrontendTools(agent.agentId),
1743
- context: Object.values(this._internal.context)
1768
+ context: this._internal.getContextForAgent(agent.agentId)
1744
1769
  }, this.createAgentErrorSubscriber(agent));
1745
1770
  return await this.processAgentResult({
1746
1771
  runAgentResult,
@@ -2677,6 +2702,13 @@ var CopilotKitCore = class {
2677
2702
  get a2uiEnabled() {
2678
2703
  return this.agentRegistry.a2uiEnabled;
2679
2704
  }
2705
+ /**
2706
+ * Agent ids the runtime applies A2UI to. `undefined` means A2UI applies to
2707
+ * every agent (or is disabled — check `a2uiEnabled`).
2708
+ */
2709
+ get a2uiAgents() {
2710
+ return this.agentRegistry.a2uiAgents;
2711
+ }
2680
2712
  get openGenerativeUIEnabled() {
2681
2713
  return this.agentRegistry.openGenerativeUIEnabled;
2682
2714
  }
@@ -2746,7 +2778,9 @@ var CopilotKitCore = class {
2746
2778
  return this.agentRegistry.getAgent(id);
2747
2779
  }
2748
2780
  /**
2749
- * Context management (delegated to ContextStore)
2781
+ * Context management (delegated to ContextStore).
2782
+ * Pass `agentIds` to restrict the entry to runs of specific agents;
2783
+ * omit it for context every agent should receive.
2750
2784
  */
2751
2785
  addContext(context) {
2752
2786
  return this.contextStore.addContext(context);
@@ -2755,6 +2789,13 @@ var CopilotKitCore = class {
2755
2789
  this.contextStore.removeContext(id);
2756
2790
  }
2757
2791
  /**
2792
+ * Build the context array for a run of the given agent, dropping entries
2793
+ * scoped to other agents and stripping the scoping metadata.
2794
+ */
2795
+ getContextForAgent(agentId) {
2796
+ return this.contextStore.getContextForAgent(agentId);
2797
+ }
2798
+ /**
2758
2799
  * Thread store registry (delegated to ThreadStoreRegistry)
2759
2800
  */
2760
2801
  registerThreadStore(agentId, store) {