@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.umd.js CHANGED
@@ -956,9 +956,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
956
956
  if (this.transport === "single") {
957
957
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
958
958
  const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", { agentId: routedId });
959
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
959
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
960
960
  }
961
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(`${this.runtimeUrl}/agent/${routedId}/connect`, this.requestInit(input))));
961
+ const connectUrl = `${this.runtimeUrl}/agent/${routedId}/connect`;
962
+ const connectRequestInit = this.requestInit(input);
963
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(connectUrl, connectRequestInit))));
962
964
  }
963
965
  function _runViaDelegate(input) {
964
966
  return (0, rxjs.defer)(() => (0, rxjs.from)(this.resolveDelegate())).pipe((0, rxjs_operators.switchMap)((delegate) => withAbortErrorHandling(delegate.run(input))));
@@ -967,7 +969,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
967
969
  if (this.transport === "single") {
968
970
  if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
969
971
  const requestInit = this.createSingleRouteRequestInit(input, "agent/run", { agentId: this.routedAgentId() });
970
- return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
972
+ return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
971
973
  }
972
974
  return withAbortErrorHandling(_superPropGet(_ProxiedCopilotRuntimeAgent.prototype, "run", this, 2)([input]));
973
975
  }
@@ -993,6 +995,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
993
995
  _defineProperty(this, "_runtimeMode", _copilotkit_shared.RUNTIME_MODE_SSE);
994
996
  _defineProperty(this, "_intelligence", void 0);
995
997
  _defineProperty(this, "_a2uiEnabled", false);
998
+ _defineProperty(this, "_a2uiAgents", void 0);
996
999
  _defineProperty(this, "_openGenerativeUIEnabled", false);
997
1000
  _defineProperty(this, "_licenseStatus", void 0);
998
1001
  _defineProperty(this, "_telemetryDisabled", false);
@@ -1027,6 +1030,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1027
1030
  get a2uiEnabled() {
1028
1031
  return this._a2uiEnabled;
1029
1032
  }
1033
+ /**
1034
+ * Agent ids the runtime applies A2UI to (#5369). `undefined` means A2UI
1035
+ * applies to every agent — or is disabled entirely; check `a2uiEnabled`.
1036
+ */
1037
+ get a2uiAgents() {
1038
+ return this._a2uiAgents;
1039
+ }
1030
1040
  get openGenerativeUIEnabled() {
1031
1041
  return this._openGenerativeUIEnabled;
1032
1042
  }
@@ -1195,6 +1205,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1195
1205
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1196
1206
  this._intelligence = void 0;
1197
1207
  this._a2uiEnabled = false;
1208
+ this._a2uiAgents = void 0;
1198
1209
  this._openGenerativeUIEnabled = false;
1199
1210
  this.remoteAgents = {};
1200
1211
  this._agents = this.localAgents;
@@ -1205,7 +1216,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1205
1216
  this._runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Connecting;
1206
1217
  await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connecting);
1207
1218
  try {
1208
- var _runtimeInfoResponse$2, _runtimeInfoResponse$3, _runtimeInfoResponse$4, _runtimeInfoResponse$5, _runtimeInfoResponse$6;
1219
+ var _runtimeInfoResponse$2, _runtimeInfoResponse$3, _ref, _a2uiInfo$enabled, _runtimeInfoResponse$4, _runtimeInfoResponse$5;
1209
1220
  const runtimeInfoResponse = await this.fetchRuntimeInfo();
1210
1221
  const { version, ...runtimeInfo } = runtimeInfoResponse;
1211
1222
  const credentials = this.core.credentials;
@@ -1235,10 +1246,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1235
1246
  this._audioFileTranscriptionEnabled = (_runtimeInfoResponse$2 = runtimeInfoResponse.audioFileTranscriptionEnabled) !== null && _runtimeInfoResponse$2 !== void 0 ? _runtimeInfoResponse$2 : false;
1236
1247
  this._runtimeMode = (_runtimeInfoResponse$3 = runtimeInfoResponse.mode) !== null && _runtimeInfoResponse$3 !== void 0 ? _runtimeInfoResponse$3 : _copilotkit_shared.RUNTIME_MODE_SSE;
1237
1248
  this._intelligence = runtimeInfoResponse.intelligence;
1238
- this._a2uiEnabled = (_runtimeInfoResponse$4 = runtimeInfoResponse.a2uiEnabled) !== null && _runtimeInfoResponse$4 !== void 0 ? _runtimeInfoResponse$4 : false;
1239
- this._openGenerativeUIEnabled = (_runtimeInfoResponse$5 = runtimeInfoResponse.openGenerativeUIEnabled) !== null && _runtimeInfoResponse$5 !== void 0 ? _runtimeInfoResponse$5 : false;
1249
+ const a2uiInfo = runtimeInfoResponse.a2ui;
1250
+ this._a2uiEnabled = (_ref = (_a2uiInfo$enabled = a2uiInfo === null || a2uiInfo === void 0 ? void 0 : a2uiInfo.enabled) !== null && _a2uiInfo$enabled !== void 0 ? _a2uiInfo$enabled : runtimeInfoResponse.a2uiEnabled) !== null && _ref !== void 0 ? _ref : false;
1251
+ this._a2uiAgents = (a2uiInfo === null || a2uiInfo === void 0 ? void 0 : a2uiInfo.enabled) ? a2uiInfo.agents : void 0;
1252
+ this._openGenerativeUIEnabled = (_runtimeInfoResponse$4 = runtimeInfoResponse.openGenerativeUIEnabled) !== null && _runtimeInfoResponse$4 !== void 0 ? _runtimeInfoResponse$4 : false;
1240
1253
  this._licenseStatus = runtimeInfoResponse.licenseStatus;
1241
- this._telemetryDisabled = (_runtimeInfoResponse$6 = runtimeInfoResponse.telemetryDisabled) !== null && _runtimeInfoResponse$6 !== void 0 ? _runtimeInfoResponse$6 : false;
1254
+ this._telemetryDisabled = (_runtimeInfoResponse$5 = runtimeInfoResponse.telemetryDisabled) !== null && _runtimeInfoResponse$5 !== void 0 ? _runtimeInfoResponse$5 : false;
1242
1255
  await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connected);
1243
1256
  await this.notifyAgentsChanged();
1244
1257
  } catch (error) {
@@ -1248,6 +1261,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1248
1261
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1249
1262
  this._intelligence = void 0;
1250
1263
  this._a2uiEnabled = false;
1264
+ this._a2uiAgents = void 0;
1251
1265
  this._openGenerativeUIEnabled = false;
1252
1266
  this.remoteAgents = {};
1253
1267
  this._agents = this.localAgents;
@@ -1367,19 +1381,32 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1367
1381
  return this._context;
1368
1382
  }
1369
1383
  /**
1370
- * Add a new context entry
1384
+ * Add a new context entry. Pass `agentIds` to restrict the entry to runs of
1385
+ * specific agents (#5369); omit it for context every agent should receive.
1371
1386
  * @returns The ID of the created context entry
1372
1387
  */
1373
- addContext({ description, value }) {
1388
+ addContext({ description, value, agentIds }) {
1374
1389
  const id = (0, _copilotkit_shared.randomUUID)();
1375
1390
  this._context[id] = {
1376
1391
  description,
1377
- value
1392
+ value,
1393
+ ...agentIds ? { agentIds } : {}
1378
1394
  };
1379
1395
  this.notifySubscribers();
1380
1396
  return id;
1381
1397
  }
1382
1398
  /**
1399
+ * Build the context array for a run of the given agent: entries scoped to
1400
+ * other agents are dropped, and the scoping metadata is stripped so only
1401
+ * protocol-shaped `{ description, value }` entries go over the wire.
1402
+ */
1403
+ getContextForAgent(agentId) {
1404
+ return Object.values(this._context).filter((entry) => !entry.agentIds || agentId !== void 0 && entry.agentIds.includes(agentId)).map(({ description, value }) => ({
1405
+ description,
1406
+ value
1407
+ }));
1408
+ }
1409
+ /**
1383
1410
  * Remove a context entry by ID
1384
1411
  */
1385
1412
  removeContext(id) {
@@ -1513,7 +1540,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1513
1540
  ].join("\n")
1514
1541
  });
1515
1542
  await agent.runAgent({
1516
- context: Object.values(this.core.context),
1543
+ context: this.core.getContextForAgent(consumerAgentId),
1517
1544
  forwardedProps: {
1518
1545
  ...this.core.properties,
1519
1546
  toolChoice: {
@@ -1816,7 +1843,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1816
1843
  const runAgentResult = await agent.connectAgent({
1817
1844
  forwardedProps: this._internal.properties,
1818
1845
  tools: this.buildFrontendTools(agent.agentId),
1819
- context: Object.values(this._internal.context)
1846
+ context: this._internal.getContextForAgent(agent.agentId)
1820
1847
  }, this.createAgentErrorSubscriber(agent));
1821
1848
  return this.processAgentResult({
1822
1849
  runAgentResult,
@@ -1862,7 +1889,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1862
1889
  ...forwardedProps
1863
1890
  },
1864
1891
  tools: this.buildFrontendTools(agent.agentId),
1865
- context: Object.values(this._internal.context)
1892
+ context: this._internal.getContextForAgent(agent.agentId)
1866
1893
  }, this.createAgentErrorSubscriber(agent));
1867
1894
  return await this.processAgentResult({
1868
1895
  runAgentResult,
@@ -2829,6 +2856,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2829
2856
  get a2uiEnabled() {
2830
2857
  return this.agentRegistry.a2uiEnabled;
2831
2858
  }
2859
+ /**
2860
+ * Agent ids the runtime applies A2UI to. `undefined` means A2UI applies to
2861
+ * every agent (or is disabled — check `a2uiEnabled`).
2862
+ */
2863
+ get a2uiAgents() {
2864
+ return this.agentRegistry.a2uiAgents;
2865
+ }
2832
2866
  get openGenerativeUIEnabled() {
2833
2867
  return this.agentRegistry.openGenerativeUIEnabled;
2834
2868
  }
@@ -2904,7 +2938,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2904
2938
  return this.agentRegistry.getAgent(id);
2905
2939
  }
2906
2940
  /**
2907
- * Context management (delegated to ContextStore)
2941
+ * Context management (delegated to ContextStore).
2942
+ * Pass `agentIds` to restrict the entry to runs of specific agents;
2943
+ * omit it for context every agent should receive.
2908
2944
  */
2909
2945
  addContext(context) {
2910
2946
  return this.contextStore.addContext(context);
@@ -2913,6 +2949,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2913
2949
  this.contextStore.removeContext(id);
2914
2950
  }
2915
2951
  /**
2952
+ * Build the context array for a run of the given agent, dropping entries
2953
+ * scoped to other agents and stripping the scoping metadata.
2954
+ */
2955
+ getContextForAgent(agentId) {
2956
+ return this.contextStore.getContextForAgent(agentId);
2957
+ }
2958
+ /**
2916
2959
  * Thread store registry (delegated to ThreadStoreRegistry)
2917
2960
  */
2918
2961
  registerThreadStore(agentId, store) {