@copilotkit/core 1.61.0 → 1.61.2

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
@@ -193,16 +193,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
193
193
  _defineProperty(this, "activeChannel", null);
194
194
  _defineProperty(this, "canonicalRunId", null);
195
195
  _defineProperty(this, "sharedState", void 0);
196
- _defineProperty(
197
- this,
198
- /**
199
- * Resolves when the active run's pipeline finalizes; `undefined` between runs.
200
- * Set/cleared inside {@link connectAgent}'s observable lifecycle. Declared
201
- * here so {@link RunCompletionAware} consumers can read it without a cast.
202
- */
203
- "activeRunCompletionPromise",
204
- void 0
205
- );
206
196
  this.config = config;
207
197
  this.sharedState = sharedState;
208
198
  }
@@ -247,7 +237,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
247
237
  const previousMessageIds = new Set(this.messages.map((m) => m.id));
248
238
  const subscribers = [
249
239
  { onRunFinishedEvent: (event) => {
250
- result = event.result;
240
+ if (event.outcome === "success") result = event.result;
251
241
  } },
252
242
  ...this.subscribers,
253
243
  subscriber !== null && subscriber !== void 0 ? subscriber : {}
@@ -255,10 +245,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
255
245
  await this.onInitialize(input, subscribers);
256
246
  self.activeRunDetach$ = new rxjs.Subject();
257
247
  let resolveCompletion;
258
- this.activeRunCompletionPromise = new Promise((resolve) => {
248
+ self.activeRunCompletionPromise = new Promise((resolve) => {
259
249
  resolveCompletion = resolve;
260
250
  });
261
- const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debug), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
251
+ const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debugLogger), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
262
252
  const applied$ = this.apply(input, source$, subscribers);
263
253
  await (0, rxjs.lastValueFrom)(this.processApplyEvents(input, applied$, subscribers).pipe((0, rxjs_operators.catchError)((error) => {
264
254
  this.isRunning = false;
@@ -268,7 +258,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
268
258
  this.onFinalize(input, subscribers);
269
259
  resolveCompletion === null || resolveCompletion === void 0 || resolveCompletion();
270
260
  resolveCompletion = void 0;
271
- this.activeRunCompletionPromise = void 0;
261
+ self.activeRunCompletionPromise = void 0;
272
262
  self.activeRunDetach$ = void 0;
273
263
  })), { defaultValue: void 0 });
274
264
  const newMessages = (0, _ag_ui_client.structuredClone_)(this.messages).filter((m) => !previousMessageIds.has(m.id));
@@ -810,8 +800,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
810
800
  cloned.setState(this.state);
811
801
  cloned.setMessages(this.messages);
812
802
  if (this.delegate) {
813
- cloned.delegate = this.delegate.clone();
814
- cloned.syncDelegate(cloned.delegate);
803
+ const clonedDelegate = this.delegate.clone();
804
+ cloned.delegate = clonedDelegate;
805
+ cloned.syncDelegate(clonedDelegate);
815
806
  }
816
807
  return cloned;
817
808
  }
@@ -994,11 +985,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
994
985
  _defineProperty(this, "_audioFileTranscriptionEnabled", false);
995
986
  _defineProperty(this, "_runtimeMode", _copilotkit_shared.RUNTIME_MODE_SSE);
996
987
  _defineProperty(this, "_intelligence", void 0);
988
+ _defineProperty(this, "_threadEndpoints", void 0);
997
989
  _defineProperty(this, "_a2uiEnabled", false);
998
990
  _defineProperty(this, "_a2uiAgents", void 0);
999
991
  _defineProperty(this, "_openGenerativeUIEnabled", false);
1000
992
  _defineProperty(this, "_licenseStatus", void 0);
1001
993
  _defineProperty(this, "_telemetryDisabled", false);
994
+ _defineProperty(this, "agentOwnHeaders", /* @__PURE__ */ new WeakMap());
1002
995
  }
1003
996
  /**
1004
997
  * Get all agents as a readonly record
@@ -1027,6 +1020,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1027
1020
  get intelligence() {
1028
1021
  return this._intelligence;
1029
1022
  }
1023
+ get threadEndpoints() {
1024
+ return this._threadEndpoints;
1025
+ }
1030
1026
  get a2uiEnabled() {
1031
1027
  return this._a2uiEnabled;
1032
1028
  }
@@ -1166,10 +1162,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1166
1162
  console.warn(`Agent ${id} not found`);
1167
1163
  }
1168
1164
  /**
1169
- * Apply current headers to an agent
1165
+ * Apply current core headers to an agent, merged ON TOP of the agent's own
1166
+ * construction-time headers (the per-agent baseline in `agentOwnHeaders`).
1167
+ * Core wins on a key conflict. Non-`HttpAgent` agents are left untouched
1168
+ * because only `HttpAgent` carries a `headers` field. See #5635.
1170
1169
  */
1171
1170
  applyHeadersToAgent(agent) {
1172
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this.core.headers };
1171
+ if (agent instanceof _ag_ui_client.HttpAgent) {
1172
+ if (!this.agentOwnHeaders.has(agent)) this.agentOwnHeaders.set(agent, { ...agent.headers });
1173
+ agent.headers = {
1174
+ ...this.agentOwnHeaders.get(agent),
1175
+ ...this.core.headers
1176
+ };
1177
+ }
1173
1178
  }
1174
1179
  /**
1175
1180
  * Apply current headers to all agents
@@ -1204,6 +1209,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1204
1209
  this._audioFileTranscriptionEnabled = false;
1205
1210
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1206
1211
  this._intelligence = void 0;
1212
+ this._threadEndpoints = void 0;
1207
1213
  this._a2uiEnabled = false;
1208
1214
  this._a2uiAgents = void 0;
1209
1215
  this._openGenerativeUIEnabled = false;
@@ -1223,6 +1229,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1223
1229
  const rawDebug = this.core.debug;
1224
1230
  this.remoteAgents = Object.fromEntries(Object.entries(runtimeInfo.agents).map(([id, { description, capabilities }]) => {
1225
1231
  var _runtimeInfoResponse$;
1232
+ const existing = Object.prototype.hasOwnProperty.call(this.remoteAgents, id) ? this.remoteAgents[id] : void 0;
1233
+ if (existing instanceof ProxiedCopilotRuntimeAgent) {
1234
+ this.applyHeadersToAgent(existing);
1235
+ this.applyCredentialsToAgent(existing);
1236
+ return [id, existing];
1237
+ }
1226
1238
  const agent = new ProxiedCopilotRuntimeAgent({
1227
1239
  runtimeUrl: this.runtimeUrl,
1228
1240
  agentId: id,
@@ -1246,6 +1258,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1246
1258
  this._audioFileTranscriptionEnabled = (_runtimeInfoResponse$2 = runtimeInfoResponse.audioFileTranscriptionEnabled) !== null && _runtimeInfoResponse$2 !== void 0 ? _runtimeInfoResponse$2 : false;
1247
1259
  this._runtimeMode = (_runtimeInfoResponse$3 = runtimeInfoResponse.mode) !== null && _runtimeInfoResponse$3 !== void 0 ? _runtimeInfoResponse$3 : _copilotkit_shared.RUNTIME_MODE_SSE;
1248
1260
  this._intelligence = runtimeInfoResponse.intelligence;
1261
+ this._threadEndpoints = runtimeInfoResponse.threadEndpoints;
1249
1262
  const a2uiInfo = runtimeInfoResponse.a2ui;
1250
1263
  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
1264
  this._a2uiAgents = (a2uiInfo === null || a2uiInfo === void 0 ? void 0 : a2uiInfo.enabled) ? a2uiInfo.agents : void 0;
@@ -1260,6 +1273,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1260
1273
  this._audioFileTranscriptionEnabled = false;
1261
1274
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1262
1275
  this._intelligence = void 0;
1276
+ this._threadEndpoints = void 0;
1263
1277
  this._a2uiEnabled = false;
1264
1278
  this._a2uiAgents = void 0;
1265
1279
  this._openGenerativeUIEnabled = false;
@@ -1839,7 +1853,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1839
1853
  const proxied = agent;
1840
1854
  if (incomingThreadId && typeof proxied.clearReplayCursor === "function") proxied.clearReplayCursor(incomingThreadId);
1841
1855
  }
1842
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
1856
+ this._internal.applyHeadersToAgent(agent);
1843
1857
  const runAgentResult = await agent.connectAgent({
1844
1858
  forwardedProps: this._internal.properties,
1845
1859
  tools: this.buildFrontendTools(agent.agentId),
@@ -1860,15 +1874,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1860
1874
  context
1861
1875
  });
1862
1876
  }
1863
- return { newMessages: [] };
1877
+ return {
1878
+ result: void 0,
1879
+ newMessages: []
1880
+ };
1864
1881
  }
1865
1882
  }
1866
1883
  /**
1867
1884
  * Run an agent
1868
1885
  */
1869
- async runAgent({ agent, forwardedProps }) {
1886
+ async runAgent({ agent, forwardedProps, resume }) {
1870
1887
  if (agent.agentId) this._internal.suggestionEngine.clearSuggestions(agent.agentId);
1871
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
1888
+ this._internal.applyHeadersToAgent(agent);
1872
1889
  if (agent.detachActiveRun) await agent.detachActiveRun();
1873
1890
  const isTopLevel = this._runDepth === 0;
1874
1891
  let originalAbortRun;
@@ -1888,6 +1905,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1888
1905
  ...this._internal.properties,
1889
1906
  ...forwardedProps
1890
1907
  },
1908
+ ...resume !== void 0 ? { resume } : {},
1891
1909
  tools: this.buildFrontendTools(agent.agentId),
1892
1910
  context: this._internal.getContextForAgent(agent.agentId)
1893
1911
  }, this.createAgentErrorSubscriber(agent));
@@ -1904,7 +1922,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1904
1922
  code: CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
1905
1923
  context
1906
1924
  });
1907
- return { newMessages: [] };
1925
+ return {
1926
+ result: void 0,
1927
+ newMessages: []
1928
+ };
1908
1929
  } finally {
1909
1930
  this._runDepth--;
1910
1931
  if (isTopLevel && originalAbortRun) agent.abortRun = originalAbortRun;
@@ -2190,18 +2211,19 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2190
2211
  throw error;
2191
2212
  }
2192
2213
  const toolCallId = (0, _copilotkit_shared.randomUUID)();
2214
+ const assistantToolCall = {
2215
+ id: toolCallId,
2216
+ type: "function",
2217
+ function: {
2218
+ name,
2219
+ arguments: JSON.stringify(parameters)
2220
+ }
2221
+ };
2193
2222
  const assistantMessage = {
2194
2223
  id: (0, _copilotkit_shared.randomUUID)(),
2195
2224
  role: "assistant",
2196
2225
  content: "",
2197
- toolCalls: [{
2198
- id: toolCallId,
2199
- type: "function",
2200
- function: {
2201
- name,
2202
- arguments: JSON.stringify(parameters)
2203
- }
2204
- }]
2226
+ toolCalls: [assistantToolCall]
2205
2227
  };
2206
2228
  agent.messages.push(assistantMessage);
2207
2229
  let handlerResult = {
@@ -2211,7 +2233,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2211
2233
  };
2212
2234
  if (tool.handler) handlerResult = await this.executeToolHandler({
2213
2235
  tool,
2214
- toolCall: assistantMessage.toolCalls[0],
2236
+ toolCall: assistantToolCall,
2215
2237
  agent,
2216
2238
  agentId: resolvedAgentId,
2217
2239
  handlerArgs: parameters,
@@ -2301,9 +2323,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2301
2323
  */
2302
2324
  function createToolSchema(tool) {
2303
2325
  if (!tool.parameters) return { ...EMPTY_TOOL_SCHEMA };
2304
- const rawSchema = (0, _copilotkit_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: zod_to_json_schema.zodToJsonSchema });
2326
+ const rawSchema = (0, _copilotkit_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: (schema, options) => (0, zod_to_json_schema.zodToJsonSchema)(schema, options) });
2305
2327
  if (!rawSchema || typeof rawSchema !== "object") return { ...EMPTY_TOOL_SCHEMA };
2306
- const { $schema, ...schema } = rawSchema;
2328
+ const { $schema: _$schema, ...schema } = rawSchema;
2307
2329
  if (typeof schema.type !== "string") schema.type = "object";
2308
2330
  if (typeof schema.properties !== "object" || schema.properties === null) schema.properties = {};
2309
2331
  stripAdditionalProperties(schema);
@@ -2684,6 +2706,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2684
2706
  CopilotKitCoreRuntimeConnectionStatus["Error"] = "error";
2685
2707
  return CopilotKitCoreRuntimeConnectionStatus;
2686
2708
  }({});
2709
+ /**
2710
+ * Normalize a header map to the internal invariant: a `Record<string, string>`
2711
+ * with no `null`/`undefined` values. Entries whose value is `null`/`undefined`
2712
+ * are dropped (this is how a header is cleared). Shared by the constructor and
2713
+ * `setHeaders` so both write paths into `_headers` enforce the same invariant.
2714
+ */
2715
+ function normalizeHeaders(headers) {
2716
+ return Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] != null));
2717
+ }
2687
2718
  var CopilotKitCore = class {
2688
2719
  constructor({ runtimeUrl, runtimeTransport = "auto", headers = {}, credentials, properties = {}, agents__unsafe_dev_only = {}, tools = [], suggestionsConfig = [], debug }) {
2689
2720
  _defineProperty(this, "_headers", void 0);
@@ -2699,7 +2730,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2699
2730
  _defineProperty(this, "stateManager", void 0);
2700
2731
  _defineProperty(this, "threadStoreRegistry", void 0);
2701
2732
  _defineProperty(this, "previousAgentIds", /* @__PURE__ */ new Set());
2702
- this._headers = headers;
2733
+ this._headers = normalizeHeaders(headers);
2703
2734
  this._credentials = credentials;
2704
2735
  this._properties = properties;
2705
2736
  this._debug = debug;
@@ -2853,6 +2884,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2853
2884
  get intelligence() {
2854
2885
  return this.agentRegistry.intelligence;
2855
2886
  }
2887
+ get threadEndpoints() {
2888
+ return this.agentRegistry.threadEndpoints;
2889
+ }
2856
2890
  get a2uiEnabled() {
2857
2891
  return this.agentRegistry.a2uiEnabled;
2858
2892
  }
@@ -2875,8 +2909,37 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2875
2909
  /**
2876
2910
  * Configuration updates
2877
2911
  */
2912
+ /**
2913
+ * Replace the headers sent with every runtime request.
2914
+ *
2915
+ * This is an overwrite, not a merge — the supplied object becomes the
2916
+ * complete header set. Entries whose value is `null` or `undefined` are
2917
+ * dropped, which is how you clear a header (e.g. removing `Authorization`
2918
+ * on logout) without leaving an empty-string value behind:
2919
+ *
2920
+ * ```ts
2921
+ * copilotkit.setHeaders({
2922
+ * ...copilotkit.headers,
2923
+ * Authorization: token ? `Bearer ${token}` : null,
2924
+ * });
2925
+ * ```
2926
+ *
2927
+ * The resulting header set is also re-applied to every agent in the registry
2928
+ * and `onHeadersChanged` subscribers are notified. These headers are merged
2929
+ * ON TOP of the headers each `HttpAgent` was constructed with, so per-agent
2930
+ * headers (e.g. an `Authorization` for a self-hosted backend) are preserved;
2931
+ * on a key conflict the core-level value wins.
2932
+ *
2933
+ * Because the agent's construction-time headers form the merge baseline, this
2934
+ * method can override a per-agent header but cannot REMOVE one: clearing a
2935
+ * core key here only drops the core-level override, after which the agent's
2936
+ * own value (if any) re-surfaces. To change a header an agent was constructed
2937
+ * with, set it at the provider/core level instead of on the agent, or update
2938
+ * it on the agent directly. The clear-on-logout pattern above is for
2939
+ * core-level headers.
2940
+ */
2878
2941
  setHeaders(headers) {
2879
- this._headers = headers;
2942
+ this._headers = normalizeHeaders(headers);
2880
2943
  this.agentRegistry.applyHeadersToAgents(this.agentRegistry.agents);
2881
2944
  this.notifySubscribers((subscriber) => {
2882
2945
  var _subscriber$onHeaders;
@@ -2938,6 +3001,23 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2938
3001
  return this.agentRegistry.getAgent(id);
2939
3002
  }
2940
3003
  /**
3004
+ * Re-apply the current headers to a single agent (delegated to
3005
+ * AgentRegistry). Core headers are merged on top of the agent's own
3006
+ * construction-time headers rather than replacing them, so headers
3007
+ * configured directly on an `HttpAgent` (e.g. an `Authorization` for a
3008
+ * self-hosted backend) survive header updates instead of being silently
3009
+ * dropped (see #5635). On a key conflict the core-level value wins.
3010
+ *
3011
+ * The merge baseline is the agent's headers as captured the first time the
3012
+ * agent is applied (at registration), so the way to change headers
3013
+ * afterwards is `setHeaders` (which re-applies to every agent), not mutating
3014
+ * `agent.headers` directly — a direct mutation is overwritten on the next
3015
+ * re-apply.
3016
+ */
3017
+ applyHeadersToAgent(agent) {
3018
+ this.agentRegistry.applyHeadersToAgent(agent);
3019
+ }
3020
+ /**
2941
3021
  * Context management (delegated to ContextStore).
2942
3022
  * Pass `agentIds` to restrict the entry to runs of specific agents;
2943
3023
  * omit it for context every agent should receive.
@@ -3666,6 +3746,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3666
3746
  fetchNextPageRequested: empty(),
3667
3747
  renameRequested: props(),
3668
3748
  archiveRequested: props(),
3749
+ unarchiveRequested: props(),
3669
3750
  deleteRequested: props()
3670
3751
  });
3671
3752
  const threadRestEvents = createActionGroup("Thread REST", {
@@ -3809,13 +3890,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3809
3890
  threadRequestId += 1;
3810
3891
  return `thread-request-${threadRequestId}`;
3811
3892
  }
3893
+ function threadFromFetch(input, init) {
3894
+ return (0, rxjs_fetch.fromFetch)(input, init);
3895
+ }
3812
3896
  function createThreadFetchObservable(environment, context, sessionId) {
3813
3897
  return (0, rxjs.defer)(() => {
3814
3898
  const params = { agentId: context.agentId };
3815
3899
  if (context.includeArchived) params.includeArchived = "true";
3816
3900
  if (context.limit != null) params.limit = String(context.limit);
3817
3901
  const qs = new URLSearchParams(params);
3818
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${qs.toString()}`, {
3902
+ return threadFromFetch(`${context.runtimeUrl}/threads?${qs.toString()}`, {
3819
3903
  selector: (response) => {
3820
3904
  if (!response.ok) throw new Error(`Failed to fetch threads: ${response.status}`);
3821
3905
  return response.json();
@@ -3846,7 +3930,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3846
3930
  }
3847
3931
  function createThreadMetadataCredentialsObservable(environment, context, sessionId) {
3848
3932
  return (0, rxjs.defer)(() => {
3849
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}${THREAD_SUBSCRIBE_PATH}`, {
3933
+ return threadFromFetch(`${context.runtimeUrl}${THREAD_SUBSCRIBE_PATH}`, {
3850
3934
  selector: async (response) => {
3851
3935
  if (!response.ok) throw new Error(`Failed to fetch thread metadata credentials: ${response.status}`);
3852
3936
  return response.json();
@@ -3879,7 +3963,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3879
3963
  }
3880
3964
  function createThreadMutationObservable(environment, context, request) {
3881
3965
  return (0, rxjs.defer)(() => {
3882
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}${request.path}`, {
3966
+ return threadFromFetch(`${context.runtimeUrl}${request.path}`, {
3883
3967
  selector: async (response) => {
3884
3968
  if (!response.ok) throw new Error(`Request failed: ${response.status}`);
3885
3969
  return null;
@@ -3981,7 +4065,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
3981
4065
  };
3982
4066
  if (context.includeArchived) params.includeArchived = "true";
3983
4067
  if (context.limit != null) params.limit = String(context.limit);
3984
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${new URLSearchParams(params).toString()}`, {
4068
+ return threadFromFetch(`${context.runtimeUrl}/threads?${new URLSearchParams(params).toString()}`, {
3985
4069
  selector: (response) => {
3986
4070
  if (!response.ok) throw new Error(`Failed to fetch next page: ${response.status}`);
3987
4071
  return response.json();
@@ -4006,7 +4090,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4006
4090
  error: error instanceof Error ? error : new Error(String(error))
4007
4091
  }))), (0, rxjs_operators.takeUntil)(actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped))));
4008
4092
  }))),
4009
- createEffect((actions$, state$) => actions$.pipe(ofType(threadAdapterEvents.renameRequested, threadAdapterEvents.archiveRequested, threadAdapterEvents.deleteRequested), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.mergeMap)(([action, state]) => {
4093
+ createEffect((actions$, state$) => actions$.pipe(ofType(threadAdapterEvents.renameRequested, threadAdapterEvents.archiveRequested, threadAdapterEvents.unarchiveRequested, threadAdapterEvents.deleteRequested), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.mergeMap)(([action, state]) => {
4010
4094
  const context = state.context;
4011
4095
  if (!(context === null || context === void 0 ? void 0 : context.runtimeUrl)) {
4012
4096
  const requestId = action.requestId;
@@ -4032,6 +4116,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4032
4116
  path: `/threads/${encodeURIComponent(action.threadId)}/archive`,
4033
4117
  body: commonBody
4034
4118
  });
4119
+ if (threadAdapterEvents.unarchiveRequested.match(action)) return createThreadMutationObservable(environment, context, {
4120
+ requestId: action.requestId,
4121
+ method: "PATCH",
4122
+ path: `/threads/${encodeURIComponent(action.threadId)}`,
4123
+ body: {
4124
+ ...commonBody,
4125
+ archived: false
4126
+ }
4127
+ });
4035
4128
  return createThreadMutationObservable(environment, context, {
4036
4129
  requestId: action.requestId,
4037
4130
  method: "DELETE",
@@ -4086,6 +4179,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4086
4179
  threadId
4087
4180
  }));
4088
4181
  },
4182
+ unarchiveThread(threadId) {
4183
+ return trackMutation(threadAdapterEvents.unarchiveRequested({
4184
+ requestId: createThreadRequestId(),
4185
+ threadId
4186
+ }));
4187
+ },
4089
4188
  deleteThread(threadId) {
4090
4189
  return trackMutation(threadAdapterEvents.deleteRequested({
4091
4190
  requestId: createThreadRequestId(),