@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.cjs CHANGED
@@ -152,12 +152,6 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
152
152
  activeChannel = null;
153
153
  canonicalRunId = null;
154
154
  sharedState;
155
- /**
156
- * Resolves when the active run's pipeline finalizes; `undefined` between runs.
157
- * Set/cleared inside {@link connectAgent}'s observable lifecycle. Declared
158
- * here so {@link RunCompletionAware} consumers can read it without a cast.
159
- */
160
- activeRunCompletionPromise;
161
155
  constructor(config, sharedState = { lastSeenEventIds: /* @__PURE__ */ new Map() }) {
162
156
  super();
163
157
  this.config = config;
@@ -203,7 +197,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
203
197
  const previousMessageIds = new Set(this.messages.map((m) => m.id));
204
198
  const subscribers = [
205
199
  { onRunFinishedEvent: (event) => {
206
- result = event.result;
200
+ if (event.outcome === "success") result = event.result;
207
201
  } },
208
202
  ...this.subscribers,
209
203
  subscriber ?? {}
@@ -211,10 +205,10 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
211
205
  await this.onInitialize(input, subscribers);
212
206
  self.activeRunDetach$ = new rxjs.Subject();
213
207
  let resolveCompletion;
214
- this.activeRunCompletionPromise = new Promise((resolve) => {
208
+ self.activeRunCompletionPromise = new Promise((resolve) => {
215
209
  resolveCompletion = resolve;
216
210
  });
217
- const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debug), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
211
+ const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debugLogger), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
218
212
  const applied$ = this.apply(input, source$, subscribers);
219
213
  await (0, rxjs.lastValueFrom)(this.processApplyEvents(input, applied$, subscribers).pipe((0, rxjs_operators.catchError)((error) => {
220
214
  this.isRunning = false;
@@ -224,7 +218,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
224
218
  this.onFinalize(input, subscribers);
225
219
  resolveCompletion?.();
226
220
  resolveCompletion = void 0;
227
- this.activeRunCompletionPromise = void 0;
221
+ self.activeRunCompletionPromise = void 0;
228
222
  self.activeRunDetach$ = void 0;
229
223
  })), { defaultValue: void 0 });
230
224
  const newMessages = (0, _ag_ui_client.structuredClone_)(this.messages).filter((m) => !previousMessageIds.has(m.id));
@@ -726,8 +720,9 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
726
720
  cloned.setState(this.state);
727
721
  cloned.setMessages(this.messages);
728
722
  if (this.delegate) {
729
- cloned.delegate = this.delegate.clone();
730
- cloned.syncDelegate(cloned.delegate);
723
+ const clonedDelegate = this.delegate.clone();
724
+ cloned.delegate = clonedDelegate;
725
+ cloned.syncDelegate(clonedDelegate);
731
726
  }
732
727
  return cloned;
733
728
  }
@@ -876,11 +871,23 @@ var AgentRegistry = class {
876
871
  _audioFileTranscriptionEnabled = false;
877
872
  _runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
878
873
  _intelligence;
874
+ _threadEndpoints;
879
875
  _a2uiEnabled = false;
880
876
  _a2uiAgents;
881
877
  _openGenerativeUIEnabled = false;
882
878
  _licenseStatus;
883
879
  _telemetryDisabled = false;
880
+ /**
881
+ * The headers each HttpAgent was constructed with, captured on the first
882
+ * `applyHeadersToAgent` call for that agent (which, for agents the registry
883
+ * owns, happens at registration before any core headers are applied). Core
884
+ * headers are merged ON TOP of this baseline so that headers configured
885
+ * directly on an agent (e.g. an `Authorization` for a self-hosted backend)
886
+ * survive registration instead of being silently replaced. The baseline is
887
+ * captured once and never re-captured, so a later direct mutation of
888
+ * `agent.headers` is not folded into it. See #5635.
889
+ */
890
+ agentOwnHeaders = /* @__PURE__ */ new WeakMap();
884
891
  constructor(core) {
885
892
  this.core = core;
886
893
  }
@@ -911,6 +918,9 @@ var AgentRegistry = class {
911
918
  get intelligence() {
912
919
  return this._intelligence;
913
920
  }
921
+ get threadEndpoints() {
922
+ return this._threadEndpoints;
923
+ }
914
924
  get a2uiEnabled() {
915
925
  return this._a2uiEnabled;
916
926
  }
@@ -1050,10 +1060,19 @@ var AgentRegistry = class {
1050
1060
  console.warn(`Agent ${id} not found`);
1051
1061
  }
1052
1062
  /**
1053
- * Apply current headers to an agent
1063
+ * Apply current core headers to an agent, merged ON TOP of the agent's own
1064
+ * construction-time headers (the per-agent baseline in `agentOwnHeaders`).
1065
+ * Core wins on a key conflict. Non-`HttpAgent` agents are left untouched
1066
+ * because only `HttpAgent` carries a `headers` field. See #5635.
1054
1067
  */
1055
1068
  applyHeadersToAgent(agent) {
1056
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this.core.headers };
1069
+ if (agent instanceof _ag_ui_client.HttpAgent) {
1070
+ if (!this.agentOwnHeaders.has(agent)) this.agentOwnHeaders.set(agent, { ...agent.headers });
1071
+ agent.headers = {
1072
+ ...this.agentOwnHeaders.get(agent),
1073
+ ...this.core.headers
1074
+ };
1075
+ }
1057
1076
  }
1058
1077
  /**
1059
1078
  * Apply current headers to all agents
@@ -1088,6 +1107,7 @@ var AgentRegistry = class {
1088
1107
  this._audioFileTranscriptionEnabled = false;
1089
1108
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1090
1109
  this._intelligence = void 0;
1110
+ this._threadEndpoints = void 0;
1091
1111
  this._a2uiEnabled = false;
1092
1112
  this._a2uiAgents = void 0;
1093
1113
  this._openGenerativeUIEnabled = false;
@@ -1105,6 +1125,12 @@ var AgentRegistry = class {
1105
1125
  const credentials = this.core.credentials;
1106
1126
  const rawDebug = this.core.debug;
1107
1127
  this.remoteAgents = Object.fromEntries(Object.entries(runtimeInfo.agents).map(([id, { description, capabilities }]) => {
1128
+ const existing = Object.prototype.hasOwnProperty.call(this.remoteAgents, id) ? this.remoteAgents[id] : void 0;
1129
+ if (existing instanceof ProxiedCopilotRuntimeAgent) {
1130
+ this.applyHeadersToAgent(existing);
1131
+ this.applyCredentialsToAgent(existing);
1132
+ return [id, existing];
1133
+ }
1108
1134
  const agent = new ProxiedCopilotRuntimeAgent({
1109
1135
  runtimeUrl: this.runtimeUrl,
1110
1136
  agentId: id,
@@ -1128,6 +1154,7 @@ var AgentRegistry = class {
1128
1154
  this._audioFileTranscriptionEnabled = runtimeInfoResponse.audioFileTranscriptionEnabled ?? false;
1129
1155
  this._runtimeMode = runtimeInfoResponse.mode ?? _copilotkit_shared.RUNTIME_MODE_SSE;
1130
1156
  this._intelligence = runtimeInfoResponse.intelligence;
1157
+ this._threadEndpoints = runtimeInfoResponse.threadEndpoints;
1131
1158
  const a2uiInfo = runtimeInfoResponse.a2ui;
1132
1159
  this._a2uiEnabled = a2uiInfo?.enabled ?? runtimeInfoResponse.a2uiEnabled ?? false;
1133
1160
  this._a2uiAgents = a2uiInfo?.enabled ? a2uiInfo.agents : void 0;
@@ -1142,6 +1169,7 @@ var AgentRegistry = class {
1142
1169
  this._audioFileTranscriptionEnabled = false;
1143
1170
  this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
1144
1171
  this._intelligence = void 0;
1172
+ this._threadEndpoints = void 0;
1145
1173
  this._a2uiEnabled = false;
1146
1174
  this._a2uiAgents = void 0;
1147
1175
  this._openGenerativeUIEnabled = false;
@@ -1716,7 +1744,7 @@ var RunHandler = class {
1716
1744
  const proxied = agent;
1717
1745
  if (incomingThreadId && typeof proxied.clearReplayCursor === "function") proxied.clearReplayCursor(incomingThreadId);
1718
1746
  }
1719
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
1747
+ this._internal.applyHeadersToAgent(agent);
1720
1748
  const runAgentResult = await agent.connectAgent({
1721
1749
  forwardedProps: this._internal.properties,
1722
1750
  tools: this.buildFrontendTools(agent.agentId),
@@ -1737,15 +1765,18 @@ var RunHandler = class {
1737
1765
  context
1738
1766
  });
1739
1767
  }
1740
- return { newMessages: [] };
1768
+ return {
1769
+ result: void 0,
1770
+ newMessages: []
1771
+ };
1741
1772
  }
1742
1773
  }
1743
1774
  /**
1744
1775
  * Run an agent
1745
1776
  */
1746
- async runAgent({ agent, forwardedProps }) {
1777
+ async runAgent({ agent, forwardedProps, resume }) {
1747
1778
  if (agent.agentId) this._internal.suggestionEngine.clearSuggestions(agent.agentId);
1748
- if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
1779
+ this._internal.applyHeadersToAgent(agent);
1749
1780
  if (agent.detachActiveRun) await agent.detachActiveRun();
1750
1781
  const isTopLevel = this._runDepth === 0;
1751
1782
  let originalAbortRun;
@@ -1765,6 +1796,7 @@ var RunHandler = class {
1765
1796
  ...this._internal.properties,
1766
1797
  ...forwardedProps
1767
1798
  },
1799
+ ...resume !== void 0 ? { resume } : {},
1768
1800
  tools: this.buildFrontendTools(agent.agentId),
1769
1801
  context: this._internal.getContextForAgent(agent.agentId)
1770
1802
  }, this.createAgentErrorSubscriber(agent));
@@ -1781,7 +1813,10 @@ var RunHandler = class {
1781
1813
  code: CopilotKitCoreErrorCode.AGENT_RUN_FAILED,
1782
1814
  context
1783
1815
  });
1784
- return { newMessages: [] };
1816
+ return {
1817
+ result: void 0,
1818
+ newMessages: []
1819
+ };
1785
1820
  } finally {
1786
1821
  this._runDepth--;
1787
1822
  if (isTopLevel && originalAbortRun) agent.abortRun = originalAbortRun;
@@ -2053,18 +2088,19 @@ var RunHandler = class {
2053
2088
  throw error;
2054
2089
  }
2055
2090
  const toolCallId = (0, _copilotkit_shared.randomUUID)();
2091
+ const assistantToolCall = {
2092
+ id: toolCallId,
2093
+ type: "function",
2094
+ function: {
2095
+ name,
2096
+ arguments: JSON.stringify(parameters)
2097
+ }
2098
+ };
2056
2099
  const assistantMessage = {
2057
2100
  id: (0, _copilotkit_shared.randomUUID)(),
2058
2101
  role: "assistant",
2059
2102
  content: "",
2060
- toolCalls: [{
2061
- id: toolCallId,
2062
- type: "function",
2063
- function: {
2064
- name,
2065
- arguments: JSON.stringify(parameters)
2066
- }
2067
- }]
2103
+ toolCalls: [assistantToolCall]
2068
2104
  };
2069
2105
  agent.messages.push(assistantMessage);
2070
2106
  let handlerResult = {
@@ -2074,7 +2110,7 @@ var RunHandler = class {
2074
2110
  };
2075
2111
  if (tool.handler) handlerResult = await this.executeToolHandler({
2076
2112
  tool,
2077
- toolCall: assistantMessage.toolCalls[0],
2113
+ toolCall: assistantToolCall,
2078
2114
  agent,
2079
2115
  agentId: resolvedAgentId,
2080
2116
  handlerArgs: parameters,
@@ -2160,9 +2196,9 @@ const EMPTY_TOOL_SCHEMA = {
2160
2196
  */
2161
2197
  function createToolSchema(tool) {
2162
2198
  if (!tool.parameters) return { ...EMPTY_TOOL_SCHEMA };
2163
- const rawSchema = (0, _copilotkit_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: zod_to_json_schema.zodToJsonSchema });
2199
+ const rawSchema = (0, _copilotkit_shared.schemaToJsonSchema)(tool.parameters, { zodToJsonSchema: (schema, options) => (0, zod_to_json_schema.zodToJsonSchema)(schema, options) });
2164
2200
  if (!rawSchema || typeof rawSchema !== "object") return { ...EMPTY_TOOL_SCHEMA };
2165
- const { $schema, ...schema } = rawSchema;
2201
+ const { $schema: _$schema, ...schema } = rawSchema;
2166
2202
  if (typeof schema.type !== "string") schema.type = "object";
2167
2203
  if (typeof schema.properties !== "object" || schema.properties === null) schema.properties = {};
2168
2204
  stripAdditionalProperties(schema);
@@ -2528,6 +2564,15 @@ let CopilotKitCoreRuntimeConnectionStatus = /* @__PURE__ */ function(CopilotKitC
2528
2564
  CopilotKitCoreRuntimeConnectionStatus["Error"] = "error";
2529
2565
  return CopilotKitCoreRuntimeConnectionStatus;
2530
2566
  }({});
2567
+ /**
2568
+ * Normalize a header map to the internal invariant: a `Record<string, string>`
2569
+ * with no `null`/`undefined` values. Entries whose value is `null`/`undefined`
2570
+ * are dropped (this is how a header is cleared). Shared by the constructor and
2571
+ * `setHeaders` so both write paths into `_headers` enforce the same invariant.
2572
+ */
2573
+ function normalizeHeaders(headers) {
2574
+ return Object.fromEntries(Object.entries(headers).filter((entry) => entry[1] != null));
2575
+ }
2531
2576
  var CopilotKitCore = class {
2532
2577
  _headers;
2533
2578
  _credentials;
@@ -2549,7 +2594,7 @@ var CopilotKitCore = class {
2549
2594
  */
2550
2595
  previousAgentIds = /* @__PURE__ */ new Set();
2551
2596
  constructor({ runtimeUrl, runtimeTransport = "auto", headers = {}, credentials, properties = {}, agents__unsafe_dev_only = {}, tools = [], suggestionsConfig = [], debug }) {
2552
- this._headers = headers;
2597
+ this._headers = normalizeHeaders(headers);
2553
2598
  this._credentials = credentials;
2554
2599
  this._properties = properties;
2555
2600
  this._debug = debug;
@@ -2700,6 +2745,9 @@ var CopilotKitCore = class {
2700
2745
  get intelligence() {
2701
2746
  return this.agentRegistry.intelligence;
2702
2747
  }
2748
+ get threadEndpoints() {
2749
+ return this.agentRegistry.threadEndpoints;
2750
+ }
2703
2751
  get a2uiEnabled() {
2704
2752
  return this.agentRegistry.a2uiEnabled;
2705
2753
  }
@@ -2722,8 +2770,37 @@ var CopilotKitCore = class {
2722
2770
  /**
2723
2771
  * Configuration updates
2724
2772
  */
2773
+ /**
2774
+ * Replace the headers sent with every runtime request.
2775
+ *
2776
+ * This is an overwrite, not a merge — the supplied object becomes the
2777
+ * complete header set. Entries whose value is `null` or `undefined` are
2778
+ * dropped, which is how you clear a header (e.g. removing `Authorization`
2779
+ * on logout) without leaving an empty-string value behind:
2780
+ *
2781
+ * ```ts
2782
+ * copilotkit.setHeaders({
2783
+ * ...copilotkit.headers,
2784
+ * Authorization: token ? `Bearer ${token}` : null,
2785
+ * });
2786
+ * ```
2787
+ *
2788
+ * The resulting header set is also re-applied to every agent in the registry
2789
+ * and `onHeadersChanged` subscribers are notified. These headers are merged
2790
+ * ON TOP of the headers each `HttpAgent` was constructed with, so per-agent
2791
+ * headers (e.g. an `Authorization` for a self-hosted backend) are preserved;
2792
+ * on a key conflict the core-level value wins.
2793
+ *
2794
+ * Because the agent's construction-time headers form the merge baseline, this
2795
+ * method can override a per-agent header but cannot REMOVE one: clearing a
2796
+ * core key here only drops the core-level override, after which the agent's
2797
+ * own value (if any) re-surfaces. To change a header an agent was constructed
2798
+ * with, set it at the provider/core level instead of on the agent, or update
2799
+ * it on the agent directly. The clear-on-logout pattern above is for
2800
+ * core-level headers.
2801
+ */
2725
2802
  setHeaders(headers) {
2726
- this._headers = headers;
2803
+ this._headers = normalizeHeaders(headers);
2727
2804
  this.agentRegistry.applyHeadersToAgents(this.agentRegistry.agents);
2728
2805
  this.notifySubscribers((subscriber) => subscriber.onHeadersChanged?.({
2729
2806
  copilotkit: this,
@@ -2779,6 +2856,23 @@ var CopilotKitCore = class {
2779
2856
  return this.agentRegistry.getAgent(id);
2780
2857
  }
2781
2858
  /**
2859
+ * Re-apply the current headers to a single agent (delegated to
2860
+ * AgentRegistry). Core headers are merged on top of the agent's own
2861
+ * construction-time headers rather than replacing them, so headers
2862
+ * configured directly on an `HttpAgent` (e.g. an `Authorization` for a
2863
+ * self-hosted backend) survive header updates instead of being silently
2864
+ * dropped (see #5635). On a key conflict the core-level value wins.
2865
+ *
2866
+ * The merge baseline is the agent's headers as captured the first time the
2867
+ * agent is applied (at registration), so the way to change headers
2868
+ * afterwards is `setHeaders` (which re-applies to every agent), not mutating
2869
+ * `agent.headers` directly — a direct mutation is overwritten on the next
2870
+ * re-apply.
2871
+ */
2872
+ applyHeadersToAgent(agent) {
2873
+ this.agentRegistry.applyHeadersToAgent(agent);
2874
+ }
2875
+ /**
2782
2876
  * Context management (delegated to ContextStore).
2783
2877
  * Pass `agentIds` to restrict the entry to runs of specific agents;
2784
2878
  * omit it for context every agent should receive.
@@ -3504,6 +3598,7 @@ const threadAdapterEvents = createActionGroup("Thread Adapter", {
3504
3598
  fetchNextPageRequested: empty(),
3505
3599
  renameRequested: props(),
3506
3600
  archiveRequested: props(),
3601
+ unarchiveRequested: props(),
3507
3602
  deleteRequested: props()
3508
3603
  });
3509
3604
  const threadRestEvents = createActionGroup("Thread REST", {
@@ -3646,13 +3741,16 @@ function createThreadRequestId() {
3646
3741
  threadRequestId += 1;
3647
3742
  return `thread-request-${threadRequestId}`;
3648
3743
  }
3744
+ function threadFromFetch(input, init) {
3745
+ return (0, rxjs_fetch.fromFetch)(input, init);
3746
+ }
3649
3747
  function createThreadFetchObservable(environment, context, sessionId) {
3650
3748
  return (0, rxjs.defer)(() => {
3651
3749
  const params = { agentId: context.agentId };
3652
3750
  if (context.includeArchived) params.includeArchived = "true";
3653
3751
  if (context.limit != null) params.limit = String(context.limit);
3654
3752
  const qs = new URLSearchParams(params);
3655
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${qs.toString()}`, {
3753
+ return threadFromFetch(`${context.runtimeUrl}/threads?${qs.toString()}`, {
3656
3754
  selector: (response) => {
3657
3755
  if (!response.ok) throw new Error(`Failed to fetch threads: ${response.status}`);
3658
3756
  return response.json();
@@ -3680,7 +3778,7 @@ function createThreadFetchObservable(environment, context, sessionId) {
3680
3778
  }
3681
3779
  function createThreadMetadataCredentialsObservable(environment, context, sessionId) {
3682
3780
  return (0, rxjs.defer)(() => {
3683
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}${THREAD_SUBSCRIBE_PATH}`, {
3781
+ return threadFromFetch(`${context.runtimeUrl}${THREAD_SUBSCRIBE_PATH}`, {
3684
3782
  selector: async (response) => {
3685
3783
  if (!response.ok) throw new Error(`Failed to fetch thread metadata credentials: ${response.status}`);
3686
3784
  return response.json();
@@ -3713,7 +3811,7 @@ function createThreadMetadataCredentialsObservable(environment, context, session
3713
3811
  }
3714
3812
  function createThreadMutationObservable(environment, context, request) {
3715
3813
  return (0, rxjs.defer)(() => {
3716
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}${request.path}`, {
3814
+ return threadFromFetch(`${context.runtimeUrl}${request.path}`, {
3717
3815
  selector: async (response) => {
3718
3816
  if (!response.ok) throw new Error(`Request failed: ${response.status}`);
3719
3817
  return null;
@@ -3812,7 +3910,7 @@ function createThreadStore(environment) {
3812
3910
  };
3813
3911
  if (context.includeArchived) params.includeArchived = "true";
3814
3912
  if (context.limit != null) params.limit = String(context.limit);
3815
- return (0, rxjs_fetch.fromFetch)(`${context.runtimeUrl}/threads?${new URLSearchParams(params).toString()}`, {
3913
+ return threadFromFetch(`${context.runtimeUrl}/threads?${new URLSearchParams(params).toString()}`, {
3816
3914
  selector: (response) => {
3817
3915
  if (!response.ok) throw new Error(`Failed to fetch next page: ${response.status}`);
3818
3916
  return response.json();
@@ -3834,7 +3932,7 @@ function createThreadStore(environment) {
3834
3932
  error: error instanceof Error ? error : new Error(String(error))
3835
3933
  }))), (0, rxjs_operators.takeUntil)(actions$.pipe(ofType(threadAdapterEvents.contextChanged, threadAdapterEvents.stopped))));
3836
3934
  }))),
3837
- createEffect((actions$, state$) => actions$.pipe(ofType(threadAdapterEvents.renameRequested, threadAdapterEvents.archiveRequested, threadAdapterEvents.deleteRequested), (0, rxjs_operators.withLatestFrom)(state$), (0, rxjs_operators.mergeMap)(([action, state]) => {
3935
+ 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]) => {
3838
3936
  const context = state.context;
3839
3937
  if (!context?.runtimeUrl) {
3840
3938
  const requestId = action.requestId;
@@ -3860,6 +3958,15 @@ function createThreadStore(environment) {
3860
3958
  path: `/threads/${encodeURIComponent(action.threadId)}/archive`,
3861
3959
  body: commonBody
3862
3960
  });
3961
+ if (threadAdapterEvents.unarchiveRequested.match(action)) return createThreadMutationObservable(environment, context, {
3962
+ requestId: action.requestId,
3963
+ method: "PATCH",
3964
+ path: `/threads/${encodeURIComponent(action.threadId)}`,
3965
+ body: {
3966
+ ...commonBody,
3967
+ archived: false
3968
+ }
3969
+ });
3863
3970
  return createThreadMutationObservable(environment, context, {
3864
3971
  requestId: action.requestId,
3865
3972
  method: "DELETE",
@@ -3914,6 +4021,12 @@ function createThreadStore(environment) {
3914
4021
  threadId
3915
4022
  }));
3916
4023
  },
4024
+ unarchiveThread(threadId) {
4025
+ return trackMutation(threadAdapterEvents.unarchiveRequested({
4026
+ requestId: createThreadRequestId(),
4027
+ threadId
4028
+ }));
4029
+ },
3917
4030
  deleteThread(threadId) {
3918
4031
  return trackMutation(threadAdapterEvents.deleteRequested({
3919
4032
  requestId: createThreadRequestId(),