@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.umd.js CHANGED
@@ -23,17 +23,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
23
23
 
24
24
  //#endregion
25
25
  //#region src/utils/connect-replay.ts
26
- const connectRunErrorPhases = /* @__PURE__ */ new WeakMap();
27
- /**
28
- * The phase in which a connection received `event`, as recorded when it
29
- * arrived. Events that did not come through a connection with replay
30
- * boundaries report `unknown`.
31
- */
32
- function ɵgetConnectRunErrorPhase(event) {
33
- var _connectRunErrorPhase;
34
- return (_connectRunErrorPhase = connectRunErrorPhases.get(event)) !== null && _connectRunErrorPhase !== void 0 ? _connectRunErrorPhase : "unknown";
35
- }
36
- /**
26
+ /**
37
27
  * Runs an agent's `connect()` stream through the AbstractAgent apply pipeline
38
28
  * with the `verifyEvents` step omitted.
39
29
  *
@@ -88,7 +78,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
88
78
  let result;
89
79
  const previousMessageIds = new Set(agent.messages.map((m) => m.id));
90
80
  let isReplaying = true;
91
- let reportsReplayPhase = false;
92
81
  const liveErrors = /* @__PURE__ */ new WeakSet();
93
82
  const subscribers = [
94
83
  {
@@ -136,19 +125,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
136
125
  };
137
126
  const lifecycle = {
138
127
  onReplayStarted: () => {
139
- reportsReplayPhase = true;
140
128
  isReplaying = true;
141
129
  agent.isRunning = true;
142
130
  },
143
131
  onReplayFinished: () => {
144
- reportsReplayPhase = true;
145
132
  isReplaying = false;
146
133
  }
147
134
  };
148
135
  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) => {
149
- if (event.type !== _ag_ui_client.EventType.RUN_ERROR) return;
150
- if (!isReplaying) liveErrors.add(event);
151
- if (reportsReplayPhase) connectRunErrorPhases.set(event, isReplaying ? "replay" : "live");
136
+ if (!isReplaying && event.type === _ag_ui_client.EventType.RUN_ERROR) liveErrors.add(event);
152
137
  }), (0, _ag_ui_client.transformChunks)(self.debugLogger), (0, rxjs_operators.takeUntil)(activeRunDetach$));
153
138
  const applied$ = self.apply(input, source$, subscribers);
154
139
  await (0, rxjs.lastValueFrom)(self.processApplyEvents(input, applied$, subscribers).pipe((0, rxjs_operators.catchError)((error) => {
@@ -357,20 +342,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
357
342
  }
358
343
  };
359
344
  /**
360
- * The gateway could not replay a live run's events, so the client cannot
361
- * verify the run it is following. The run itself may still be going on the
362
- * server; reconnecting to the thread shows its real state.
363
- */
364
- var IntelligenceReplayFailedError = class extends Error {
365
- constructor(threadId, runId) {
366
- super("The run's events could not be replayed. Reconnect to the thread to check the run's status.");
367
- this.threadId = threadId;
368
- this.runId = runId;
369
- _defineProperty(this, "code", "INTELLIGENCE_REPLAY_FAILED");
370
- this.name = "IntelligenceReplayFailedError";
371
- }
372
- };
373
- /**
374
345
  * Type guard for {@link RunCompletionAware}. Returns true when `agent` exposes
375
346
  * an `activeRunCompletionPromise` property, so callers can await an in-flight
376
347
  * run without an `as unknown as` cast. Returns false for agents that don't
@@ -701,7 +672,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
701
672
  };
702
673
  const replayFailed$ = channel$.pipe((0, rxjs_operators.switchMap)(({ channel }) => this.observeChannelEvent$(channel, REPLAY_FAILED_EVENT)), (0, rxjs_operators.tap)(() => {
703
674
  controlCursor.replayFailed = true;
704
- if (options.streamMode === "run") throw new IntelligenceReplayFailedError(credentials.threadId, credentials.runId);
705
675
  }));
706
676
  const replayComplete$ = this.observeControlEvent$(input.threadId, channel$, REPLAY_COMPLETE_EVENT, controlCursor).pipe((0, rxjs_operators.tap)(() => {
707
677
  var _options$lifecycle2, _options$lifecycle2$o;
@@ -3903,7 +3873,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3903
3873
  forwardedProps: this._internal.properties,
3904
3874
  tools: this.buildFrontendTools(agent.agentId),
3905
3875
  context: this._internal.getContextForAgent(agent.agentId)
3906
- }, this.createAgentErrorSubscriber(agent, "connect"));
3876
+ }, this.createAgentErrorSubscriber(agent));
3907
3877
  if (this._connectionGenerations.get(agent) !== connection || ((_agent$threadId4 = agent.threadId) !== null && _agent$threadId4 !== void 0 ? _agent$threadId4 : null) !== incomingThreadId) return runAgentResult;
3908
3878
  const controller = new AbortController();
3909
3879
  const replay = (_this$_interactionAbo = this._interactionAbortControllers.get(agent)) !== null && _this$_interactionAbo !== void 0 ? _this$_interactionAbo : {
@@ -3997,7 +3967,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3997
3967
  this._runDepth++;
3998
3968
  try {
3999
3969
  let logicalRunId = resumedRunId !== null && resumedRunId !== void 0 ? resumedRunId : runId;
4000
- const agentSubscriber = this.createAgentErrorSubscriber(agent, "run");
3970
+ const agentSubscriber = this.createAgentErrorSubscriber(agent);
4001
3971
  let started = false;
4002
3972
  const onRunStartedEvent = agentSubscriber.onRunStartedEvent;
4003
3973
  const onRunInitialized = agentSubscriber.onRunInitialized;
@@ -4531,7 +4501,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4531
4501
  /**
4532
4502
  * Create an agent error subscriber
4533
4503
  */
4534
- createAgentErrorSubscriber(agent, stream) {
4504
+ createAgentErrorSubscriber(agent) {
4535
4505
  const emitAgentError = async (error, code, extraContext = {}) => {
4536
4506
  const context = { ...extraContext };
4537
4507
  if (agent.agentId) context.agentId = agent.agentId;
@@ -4555,8 +4525,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4555
4525
  await emitAgentError(rawError, CopilotKitCoreErrorCode.AGENT_RUN_ERROR_EVENT, {
4556
4526
  source: "onRunErrorEvent",
4557
4527
  event,
4558
- runtimeErrorCode: event === null || event === void 0 ? void 0 : event.code,
4559
- phase: stream === "run" ? "live" : ɵgetConnectRunErrorPhase(event)
4528
+ runtimeErrorCode: event === null || event === void 0 ? void 0 : event.code
4560
4529
  });
4561
4530
  }
4562
4531
  };
@@ -7000,12 +6969,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7000
6969
  CopilotKitCoreErrorCode["AGENT_CONNECT_FAILED"] = "agent_connect_failed";
7001
6970
  CopilotKitCoreErrorCode["AGENT_RUN_FAILED"] = "agent_run_failed";
7002
6971
  CopilotKitCoreErrorCode["AGENT_RUN_FAILED_EVENT"] = "agent_run_failed_event";
7003
- /**
7004
- * An agent emitted RUN_ERROR. `context.phase` (`RunErrorPhase`) is
7005
- * `"replay"` when the error belongs to stored thread history replayed on
7006
- * connect, `"live"` when the run is happening now, and `"unknown"` when the
7007
- * transport cannot tell. Show a live-failure notice only for `"live"`.
7008
- */
7009
6972
  CopilotKitCoreErrorCode["AGENT_RUN_ERROR_EVENT"] = "agent_run_error_event";
7010
6973
  CopilotKitCoreErrorCode["TOOL_ARGUMENT_PARSE_FAILED"] = "tool_argument_parse_failed";
7011
6974
  CopilotKitCoreErrorCode["TOOL_HANDLER_FAILED"] = "tool_handler_failed";
@@ -9130,7 +9093,6 @@ exports.CopilotKitCoreRuntimeConnectionStatus = CopilotKitCoreRuntimeConnectionS
9130
9093
  exports.CopilotKitHeaderResolutionError = CopilotKitHeaderResolutionError;
9131
9094
  exports.INSPECTOR_THREAD_BRIDGE_PLUGIN_ID = INSPECTOR_THREAD_BRIDGE_PLUGIN_ID;
9132
9095
  exports.IntelligenceAgent = IntelligenceAgent;
9133
- exports.IntelligenceReplayFailedError = IntelligenceReplayFailedError;
9134
9096
  exports.MEMORY_ERROR_REGISTRY = MEMORY_ERROR_REGISTRY;
9135
9097
  exports.MemoryError = MemoryError;
9136
9098
  exports.ProxiedCopilotRuntimeAgent = ProxiedCopilotRuntimeAgent;