@copilotkit/core 1.67.1 → 1.68.1

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
@@ -158,6 +158,45 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
158
158
  this.config = config;
159
159
  this.sharedState = sharedState;
160
160
  }
161
+ /**
162
+ * Headers sent with the REST join requests (`/connect`, `/run`).
163
+ *
164
+ * Deliberately a public accessor pair rather than a plain read of `config`.
165
+ * `ProxiedCopilotRuntimeAgent` builds its delegate once and caches it for the
166
+ * proxy's lifetime, so a header that changes later (a tenant switch, a
167
+ * rotated bearer) would otherwise never reach the gateway. The accessor is
168
+ * what closes that gap: `syncDelegate` refreshes the delegate before every
169
+ * join, and its `hasHeaders` probe is an `"headers" in agent` check — which a
170
+ * prototype accessor satisfies but a `private config` does not.
171
+ *
172
+ * The setter replaces the config object instead of mutating it because
173
+ * `clone()` hands the same config reference to the copy. An in-place write
174
+ * would therefore have a per-thread clone's headers land on the original's
175
+ * config too. The join path itself would survive that (`syncDelegate`
176
+ * rewrites the headers just before every join), but the re-acquisition inside
177
+ * an already-running pipeline does not go through `syncDelegate` — so a
178
+ * clone's tenant could ride out on the original's socket-error refresh. That
179
+ * is the same cross-tenant leak this accessor exists to prevent.
180
+ */
181
+ get headers() {
182
+ return this.config.headers;
183
+ }
184
+ set headers(headers) {
185
+ this.config = {
186
+ ...this.config,
187
+ headers
188
+ };
189
+ }
190
+ /** Credentials mode for the REST join requests. Live for the same reason as {@link headers}. */
191
+ get credentials() {
192
+ return this.config.credentials;
193
+ }
194
+ set credentials(credentials) {
195
+ this.config = {
196
+ ...this.config,
197
+ credentials
198
+ };
199
+ }
161
200
  clone() {
162
201
  return new IntelligenceAgent(this.config, this.sharedState);
163
202
  }
@@ -318,7 +357,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
318
357
  method: "POST",
319
358
  headers: {
320
359
  "Content-Type": "application/json",
321
- ...this.config.headers
360
+ ...this.headers
322
361
  },
323
362
  body: JSON.stringify({
324
363
  threadId: input.threadId,
@@ -330,7 +369,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
330
369
  forwardedProps: input.forwardedProps,
331
370
  ...mode === "connect" ? { lastSeenEventId: replayCursor === void 0 ? this.getReconnectCursor(input) : replayCursor } : {}
332
371
  }),
333
- ...this.config.credentials ? { credentials: this.config.credentials } : {}
372
+ ...this.credentials ? { credentials: this.credentials } : {}
334
373
  });
335
374
  if (response.status === 204 && mode === "connect") return null;
336
375
  if (response.status === 409 && mode === "run") throw new AgentThreadLockedError(input.threadId);
@@ -5838,7 +5877,7 @@ var ɵInterruptState = class {
5838
5877
  const mutableInterrupts = [...interrupts];
5839
5878
  const resume = (0, _ag_ui_client.buildResumeArray)(mutableInterrupts, this.#responses);
5840
5879
  const toolResults = mutableInterrupts.flatMap((interrupt) => {
5841
- if (!interrupt.toolCallId) return [];
5880
+ if (!interrupt.toolCallId || interrupt.reason !== "tool_call") return [];
5842
5881
  return [{
5843
5882
  toolCallId: interrupt.toolCallId,
5844
5883
  content: toolResultContent(this.#responses[interrupt.id])