@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.mjs CHANGED
@@ -690,9 +690,11 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends HttpAg
690
690
  if (this.transport === "single") {
691
691
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
692
692
  const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", { agentId: routedId });
693
- return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(this.singleEndpointUrl, requestInit)));
693
+ return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(() => this.fetch(this.singleEndpointUrl, requestInit))));
694
694
  }
695
- return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(`${this.runtimeUrl}/agent/${routedId}/connect`, this.requestInit(input))));
695
+ const connectUrl = `${this.runtimeUrl}/agent/${routedId}/connect`;
696
+ const connectRequestInit = this.requestInit(input);
697
+ return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(() => this.fetch(connectUrl, connectRequestInit))));
696
698
  }
697
699
  #runViaDelegate(input) {
698
700
  return defer(() => from(this.resolveDelegate())).pipe(switchMap$1((delegate) => withAbortErrorHandling(delegate.run(input))));
@@ -701,7 +703,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends HttpAg
701
703
  if (this.transport === "single") {
702
704
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
703
705
  const requestInit = this.createSingleRouteRequestInit(input, "agent/run", { agentId: this.routedAgentId() });
704
- return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(this.singleEndpointUrl, requestInit)));
706
+ return withAbortErrorHandling(transformHttpEventStream(runHttpRequest(() => this.fetch(this.singleEndpointUrl, requestInit))));
705
707
  }
706
708
  return withAbortErrorHandling(super.run(input));
707
709
  }
@@ -874,6 +876,7 @@ var AgentRegistry = class {
874
876
  _runtimeMode = RUNTIME_MODE_SSE;
875
877
  _intelligence;
876
878
  _a2uiEnabled = false;
879
+ _a2uiAgents;
877
880
  _openGenerativeUIEnabled = false;
878
881
  _licenseStatus;
879
882
  _telemetryDisabled = false;
@@ -910,6 +913,13 @@ var AgentRegistry = class {
910
913
  get a2uiEnabled() {
911
914
  return this._a2uiEnabled;
912
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
+ }
913
923
  get openGenerativeUIEnabled() {
914
924
  return this._openGenerativeUIEnabled;
915
925
  }
@@ -1078,6 +1088,7 @@ var AgentRegistry = class {
1078
1088
  this._runtimeMode = RUNTIME_MODE_SSE;
1079
1089
  this._intelligence = void 0;
1080
1090
  this._a2uiEnabled = false;
1091
+ this._a2uiAgents = void 0;
1081
1092
  this._openGenerativeUIEnabled = false;
1082
1093
  this.remoteAgents = {};
1083
1094
  this._agents = this.localAgents;
@@ -1116,7 +1127,9 @@ var AgentRegistry = class {
1116
1127
  this._audioFileTranscriptionEnabled = runtimeInfoResponse.audioFileTranscriptionEnabled ?? false;
1117
1128
  this._runtimeMode = runtimeInfoResponse.mode ?? RUNTIME_MODE_SSE;
1118
1129
  this._intelligence = runtimeInfoResponse.intelligence;
1119
- 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;
1120
1133
  this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
1121
1134
  this._licenseStatus = runtimeInfoResponse.licenseStatus;
1122
1135
  this._telemetryDisabled = runtimeInfoResponse.telemetryDisabled ?? false;
@@ -1129,6 +1142,7 @@ var AgentRegistry = class {
1129
1142
  this._runtimeMode = RUNTIME_MODE_SSE;
1130
1143
  this._intelligence = void 0;
1131
1144
  this._a2uiEnabled = false;
1145
+ this._a2uiAgents = void 0;
1132
1146
  this._openGenerativeUIEnabled = false;
1133
1147
  this.remoteAgents = {};
1134
1148
  this._agents = this.localAgents;
@@ -1242,19 +1256,32 @@ var ContextStore = class {
1242
1256
  return this._context;
1243
1257
  }
1244
1258
  /**
1245
- * 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.
1246
1261
  * @returns The ID of the created context entry
1247
1262
  */
1248
- addContext({ description, value }) {
1263
+ addContext({ description, value, agentIds }) {
1249
1264
  const id = randomUUID$1();
1250
1265
  this._context[id] = {
1251
1266
  description,
1252
- value
1267
+ value,
1268
+ ...agentIds ? { agentIds } : {}
1253
1269
  };
1254
1270
  this.notifySubscribers();
1255
1271
  return id;
1256
1272
  }
1257
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
+ /**
1258
1285
  * Remove a context entry by ID
1259
1286
  */
1260
1287
  removeContext(id) {
@@ -1382,7 +1409,7 @@ var SuggestionEngine = class {
1382
1409
  ].join("\n")
1383
1410
  });
1384
1411
  await agent.runAgent({
1385
- context: Object.values(this.core.context),
1412
+ context: this.core.getContextForAgent(consumerAgentId),
1386
1413
  forwardedProps: {
1387
1414
  ...this.core.properties,
1388
1415
  toolChoice: {
@@ -1692,7 +1719,7 @@ var RunHandler = class {
1692
1719
  const runAgentResult = await agent.connectAgent({
1693
1720
  forwardedProps: this._internal.properties,
1694
1721
  tools: this.buildFrontendTools(agent.agentId),
1695
- context: Object.values(this._internal.context)
1722
+ context: this._internal.getContextForAgent(agent.agentId)
1696
1723
  }, this.createAgentErrorSubscriber(agent));
1697
1724
  return this.processAgentResult({
1698
1725
  runAgentResult,
@@ -1738,7 +1765,7 @@ var RunHandler = class {
1738
1765
  ...forwardedProps
1739
1766
  },
1740
1767
  tools: this.buildFrontendTools(agent.agentId),
1741
- context: Object.values(this._internal.context)
1768
+ context: this._internal.getContextForAgent(agent.agentId)
1742
1769
  }, this.createAgentErrorSubscriber(agent));
1743
1770
  return await this.processAgentResult({
1744
1771
  runAgentResult,
@@ -2675,6 +2702,13 @@ var CopilotKitCore = class {
2675
2702
  get a2uiEnabled() {
2676
2703
  return this.agentRegistry.a2uiEnabled;
2677
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
+ }
2678
2712
  get openGenerativeUIEnabled() {
2679
2713
  return this.agentRegistry.openGenerativeUIEnabled;
2680
2714
  }
@@ -2744,7 +2778,9 @@ var CopilotKitCore = class {
2744
2778
  return this.agentRegistry.getAgent(id);
2745
2779
  }
2746
2780
  /**
2747
- * 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.
2748
2784
  */
2749
2785
  addContext(context) {
2750
2786
  return this.contextStore.addContext(context);
@@ -2753,6 +2789,13 @@ var CopilotKitCore = class {
2753
2789
  this.contextStore.removeContext(id);
2754
2790
  }
2755
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
+ /**
2756
2799
  * Thread store registry (delegated to ThreadStoreRegistry)
2757
2800
  */
2758
2801
  registerThreadStore(agentId, store) {