@copilotkit/core 1.79.1-canary.1792091124 → 1.79.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
@@ -26,15 +26,6 @@ function ɵisHttpAgent(agent) {
26
26
 
27
27
  //#endregion
28
28
  //#region src/utils/connect-replay.ts
29
- const connectRunErrorPhases = /* @__PURE__ */ new WeakMap();
30
- /**
31
- * The phase in which a connection received `event`, as recorded when it
32
- * arrived. Events that did not come through a connection with replay
33
- * boundaries report `unknown`.
34
- */
35
- function ɵgetConnectRunErrorPhase(event) {
36
- return connectRunErrorPhases.get(event) ?? "unknown";
37
- }
38
29
  /**
39
30
  * Runs an agent's `connect()` stream through the AbstractAgent apply pipeline
40
31
  * with the `verifyEvents` step omitted.
@@ -89,7 +80,6 @@ async function ɵconnectWithoutEventVerification(agent, parameters, subscriber,
89
80
  let result;
90
81
  const previousMessageIds = new Set(agent.messages.map((m) => m.id));
91
82
  let isReplaying = true;
92
- let reportsReplayPhase = false;
93
83
  const liveErrors = /* @__PURE__ */ new WeakSet();
94
84
  const subscribers = [
95
85
  {
@@ -137,19 +127,15 @@ async function ɵconnectWithoutEventVerification(agent, parameters, subscriber,
137
127
  };
138
128
  const lifecycle = {
139
129
  onReplayStarted: () => {
140
- reportsReplayPhase = true;
141
130
  isReplaying = true;
142
131
  agent.isRunning = true;
143
132
  },
144
133
  onReplayFinished: () => {
145
- reportsReplayPhase = true;
146
134
  isReplaying = false;
147
135
  }
148
136
  };
149
137
  const source$ = (0, rxjs.defer)(() => new _ag_ui_client.CompatibilityBoundary().run(input, { run: () => connect ? connect(input, lifecycle) : self.connect(input) })).pipe((0, rxjs_operators.tap)((event) => {
150
- if (event.type !== _ag_ui_client.EventType.RUN_ERROR) return;
151
- if (!isReplaying) liveErrors.add(event);
152
- if (reportsReplayPhase) connectRunErrorPhases.set(event, isReplaying ? "replay" : "live");
138
+ if (!isReplaying && event.type === _ag_ui_client.EventType.RUN_ERROR) liveErrors.add(event);
153
139
  }), (0, _ag_ui_client.transformChunks)(self.debugLogger), (0, rxjs_operators.takeUntil)(activeRunDetach$));
154
140
  const applied$ = self.apply(input, source$, subscribers);
155
141
  await (0, rxjs.lastValueFrom)(self.processApplyEvents(input, applied$, subscribers).pipe((0, rxjs_operators.catchError)((error) => {
@@ -316,20 +302,6 @@ var AgentThreadLockedError = class extends Error {
316
302
  }
317
303
  };
318
304
  /**
319
- * The gateway could not replay a live run's events, so the client cannot
320
- * verify the run it is following. The run itself may still be going on the
321
- * server; reconnecting to the thread shows its real state.
322
- */
323
- var IntelligenceReplayFailedError = class extends Error {
324
- code = "INTELLIGENCE_REPLAY_FAILED";
325
- constructor(threadId, runId) {
326
- super("The run's events could not be replayed. Reconnect to the thread to check the run's status.");
327
- this.threadId = threadId;
328
- this.runId = runId;
329
- this.name = "IntelligenceReplayFailedError";
330
- }
331
- };
332
- /**
333
305
  * Type guard for {@link RunCompletionAware}. Returns true when `agent` exposes
334
306
  * an `activeRunCompletionPromise` property, so callers can await an in-flight
335
307
  * run without an `as unknown as` cast. Returns false for agents that don't
@@ -655,7 +627,6 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
655
627
  };
656
628
  const replayFailed$ = channel$.pipe((0, rxjs_operators.switchMap)(({ channel }) => this.observeChannelEvent$(channel, REPLAY_FAILED_EVENT)), (0, rxjs_operators.tap)(() => {
657
629
  controlCursor.replayFailed = true;
658
- if (options.streamMode === "run") throw new IntelligenceReplayFailedError(credentials.threadId, credentials.runId);
659
630
  }));
660
631
  const replayComplete$ = this.observeControlEvent$(input.threadId, channel$, REPLAY_COMPLETE_EVENT, controlCursor).pipe((0, rxjs_operators.tap)(() => {
661
632
  replayFinished = true;
@@ -3816,7 +3787,7 @@ var RunHandler = class {
3816
3787
  forwardedProps: this._internal.properties,
3817
3788
  tools: this.buildFrontendTools(agent.agentId),
3818
3789
  context: this._internal.getContextForAgent(agent.agentId)
3819
- }, this.createAgentErrorSubscriber(agent, "connect"));
3790
+ }, this.createAgentErrorSubscriber(agent));
3820
3791
  if (this._connectionGenerations.get(agent) !== connection || (agent.threadId ?? null) !== incomingThreadId) return runAgentResult;
3821
3792
  const controller = new AbortController();
3822
3793
  const replay = this._interactionAbortControllers.get(agent) ?? {
@@ -3907,7 +3878,7 @@ var RunHandler = class {
3907
3878
  this._runDepth++;
3908
3879
  try {
3909
3880
  let logicalRunId = resumedRunId ?? runId;
3910
- const agentSubscriber = this.createAgentErrorSubscriber(agent, "run");
3881
+ const agentSubscriber = this.createAgentErrorSubscriber(agent);
3911
3882
  let started = false;
3912
3883
  const onRunStartedEvent = agentSubscriber.onRunStartedEvent;
3913
3884
  const onRunInitialized = agentSubscriber.onRunInitialized;
@@ -4412,7 +4383,7 @@ var RunHandler = class {
4412
4383
  /**
4413
4384
  * Create an agent error subscriber
4414
4385
  */
4415
- createAgentErrorSubscriber(agent, stream) {
4386
+ createAgentErrorSubscriber(agent) {
4416
4387
  const emitAgentError = async (error, code, extraContext = {}) => {
4417
4388
  const context = { ...extraContext };
4418
4389
  if (agent.agentId) context.agentId = agent.agentId;
@@ -4435,8 +4406,7 @@ var RunHandler = class {
4435
4406
  await emitAgentError(rawError, CopilotKitCoreErrorCode.AGENT_RUN_ERROR_EVENT, {
4436
4407
  source: "onRunErrorEvent",
4437
4408
  event,
4438
- runtimeErrorCode: event?.code,
4439
- phase: stream === "run" ? "live" : ɵgetConnectRunErrorPhase(event)
4409
+ runtimeErrorCode: event?.code
4440
4410
  });
4441
4411
  }
4442
4412
  };
@@ -6801,12 +6771,6 @@ let CopilotKitCoreErrorCode = /* @__PURE__ */ function(CopilotKitCoreErrorCode)
6801
6771
  CopilotKitCoreErrorCode["AGENT_CONNECT_FAILED"] = "agent_connect_failed";
6802
6772
  CopilotKitCoreErrorCode["AGENT_RUN_FAILED"] = "agent_run_failed";
6803
6773
  CopilotKitCoreErrorCode["AGENT_RUN_FAILED_EVENT"] = "agent_run_failed_event";
6804
- /**
6805
- * An agent emitted RUN_ERROR. `context.phase` (`RunErrorPhase`) is
6806
- * `"replay"` when the error belongs to stored thread history replayed on
6807
- * connect, `"live"` when the run is happening now, and `"unknown"` when the
6808
- * transport cannot tell. Show a live-failure notice only for `"live"`.
6809
- */
6810
6774
  CopilotKitCoreErrorCode["AGENT_RUN_ERROR_EVENT"] = "agent_run_error_event";
6811
6775
  CopilotKitCoreErrorCode["TOOL_ARGUMENT_PARSE_FAILED"] = "tool_argument_parse_failed";
6812
6776
  CopilotKitCoreErrorCode["TOOL_HANDLER_FAILED"] = "tool_handler_failed";
@@ -8877,7 +8841,6 @@ exports.CopilotKitCoreRuntimeConnectionStatus = CopilotKitCoreRuntimeConnectionS
8877
8841
  exports.CopilotKitHeaderResolutionError = CopilotKitHeaderResolutionError;
8878
8842
  exports.INSPECTOR_THREAD_BRIDGE_PLUGIN_ID = INSPECTOR_THREAD_BRIDGE_PLUGIN_ID;
8879
8843
  exports.IntelligenceAgent = IntelligenceAgent;
8880
- exports.IntelligenceReplayFailedError = IntelligenceReplayFailedError;
8881
8844
  exports.MEMORY_ERROR_REGISTRY = MEMORY_ERROR_REGISTRY;
8882
8845
  exports.MemoryError = MemoryError;
8883
8846
  exports.ProxiedCopilotRuntimeAgent = ProxiedCopilotRuntimeAgent;