@yourgpt/copilot-sdk 2.1.0 → 2.1.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.
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMUZ2RYS2_cjs = require('../chunk-MUZ2RYS2.cjs');
3
+ var chunk5UMM5VYB_cjs = require('../chunk-5UMM5VYB.cjs');
4
4
  var chunk33JSFVGH_cjs = require('../chunk-33JSFVGH.cjs');
5
5
  require('../chunk-JGPDQDY4.cjs');
6
6
  require('../chunk-O33I4HBL.cjs');
@@ -20,167 +20,167 @@ require('../chunk-JEQ2X3Z6.cjs');
20
20
 
21
21
  Object.defineProperty(exports, "AbstractAgentLoop", {
22
22
  enumerable: true,
23
- get: function () { return chunkMUZ2RYS2_cjs.AbstractAgentLoop; }
23
+ get: function () { return chunk5UMM5VYB_cjs.AbstractAgentLoop; }
24
24
  });
25
25
  Object.defineProperty(exports, "AbstractChat", {
26
26
  enumerable: true,
27
- get: function () { return chunkMUZ2RYS2_cjs.AbstractChat; }
27
+ get: function () { return chunk5UMM5VYB_cjs.AbstractChat; }
28
28
  });
29
29
  Object.defineProperty(exports, "CopilotProvider", {
30
30
  enumerable: true,
31
- get: function () { return chunkMUZ2RYS2_cjs.CopilotProvider; }
31
+ get: function () { return chunk5UMM5VYB_cjs.CopilotProvider; }
32
32
  });
33
33
  Object.defineProperty(exports, "ReactChat", {
34
34
  enumerable: true,
35
- get: function () { return chunkMUZ2RYS2_cjs.ReactChat; }
35
+ get: function () { return chunk5UMM5VYB_cjs.ReactChat; }
36
36
  });
37
37
  Object.defineProperty(exports, "ReactChatState", {
38
38
  enumerable: true,
39
- get: function () { return chunkMUZ2RYS2_cjs.ReactChatState; }
39
+ get: function () { return chunk5UMM5VYB_cjs.ReactChatState; }
40
40
  });
41
41
  Object.defineProperty(exports, "ReactThreadManager", {
42
42
  enumerable: true,
43
- get: function () { return chunkMUZ2RYS2_cjs.ReactThreadManager; }
43
+ get: function () { return chunk5UMM5VYB_cjs.ReactThreadManager; }
44
44
  });
45
45
  Object.defineProperty(exports, "ReactThreadManagerState", {
46
46
  enumerable: true,
47
- get: function () { return chunkMUZ2RYS2_cjs.ReactThreadManagerState; }
47
+ get: function () { return chunk5UMM5VYB_cjs.ReactThreadManagerState; }
48
48
  });
49
49
  Object.defineProperty(exports, "createMessageIntentHandler", {
50
50
  enumerable: true,
51
- get: function () { return chunkMUZ2RYS2_cjs.createMessageIntentHandler; }
51
+ get: function () { return chunk5UMM5VYB_cjs.createMessageIntentHandler; }
52
52
  });
53
53
  Object.defineProperty(exports, "createPermissionStorage", {
54
54
  enumerable: true,
55
- get: function () { return chunkMUZ2RYS2_cjs.createPermissionStorage; }
55
+ get: function () { return chunk5UMM5VYB_cjs.createPermissionStorage; }
56
56
  });
57
57
  Object.defineProperty(exports, "createReactChat", {
58
58
  enumerable: true,
59
- get: function () { return chunkMUZ2RYS2_cjs.createReactChat; }
59
+ get: function () { return chunk5UMM5VYB_cjs.createReactChat; }
60
60
  });
61
61
  Object.defineProperty(exports, "createReactChatState", {
62
62
  enumerable: true,
63
- get: function () { return chunkMUZ2RYS2_cjs.createReactChatState; }
63
+ get: function () { return chunk5UMM5VYB_cjs.createReactChatState; }
64
64
  });
65
65
  Object.defineProperty(exports, "createReactThreadManager", {
66
66
  enumerable: true,
67
- get: function () { return chunkMUZ2RYS2_cjs.createReactThreadManager; }
67
+ get: function () { return chunk5UMM5VYB_cjs.createReactThreadManager; }
68
68
  });
69
69
  Object.defineProperty(exports, "createReactThreadManagerState", {
70
70
  enumerable: true,
71
- get: function () { return chunkMUZ2RYS2_cjs.createReactThreadManagerState; }
71
+ get: function () { return chunk5UMM5VYB_cjs.createReactThreadManagerState; }
72
72
  });
73
73
  Object.defineProperty(exports, "createSessionPermissionCache", {
74
74
  enumerable: true,
75
- get: function () { return chunkMUZ2RYS2_cjs.createSessionPermissionCache; }
75
+ get: function () { return chunk5UMM5VYB_cjs.createSessionPermissionCache; }
76
76
  });
77
77
  Object.defineProperty(exports, "createToolIntentHandler", {
78
78
  enumerable: true,
79
- get: function () { return chunkMUZ2RYS2_cjs.createToolIntentHandler; }
79
+ get: function () { return chunk5UMM5VYB_cjs.createToolIntentHandler; }
80
80
  });
81
81
  Object.defineProperty(exports, "formatKnowledgeResultsForAI", {
82
82
  enumerable: true,
83
- get: function () { return chunkMUZ2RYS2_cjs.formatKnowledgeResultsForAI; }
83
+ get: function () { return chunk5UMM5VYB_cjs.formatKnowledgeResultsForAI; }
84
84
  });
85
85
  Object.defineProperty(exports, "initialAgentLoopState", {
86
86
  enumerable: true,
87
- get: function () { return chunkMUZ2RYS2_cjs.initialAgentLoopState; }
87
+ get: function () { return chunk5UMM5VYB_cjs.initialAgentLoopState; }
88
88
  });
89
89
  Object.defineProperty(exports, "searchKnowledgeBase", {
90
90
  enumerable: true,
91
- get: function () { return chunkMUZ2RYS2_cjs.searchKnowledgeBase; }
91
+ get: function () { return chunk5UMM5VYB_cjs.searchKnowledgeBase; }
92
92
  });
93
93
  Object.defineProperty(exports, "useAIAction", {
94
94
  enumerable: true,
95
- get: function () { return chunkMUZ2RYS2_cjs.useAIAction; }
95
+ get: function () { return chunk5UMM5VYB_cjs.useAIAction; }
96
96
  });
97
97
  Object.defineProperty(exports, "useAIActions", {
98
98
  enumerable: true,
99
- get: function () { return chunkMUZ2RYS2_cjs.useAIActions; }
99
+ get: function () { return chunk5UMM5VYB_cjs.useAIActions; }
100
100
  });
101
101
  Object.defineProperty(exports, "useAIContext", {
102
102
  enumerable: true,
103
- get: function () { return chunkMUZ2RYS2_cjs.useAIContext; }
103
+ get: function () { return chunk5UMM5VYB_cjs.useAIContext; }
104
104
  });
105
105
  Object.defineProperty(exports, "useAIContexts", {
106
106
  enumerable: true,
107
- get: function () { return chunkMUZ2RYS2_cjs.useAIContexts; }
107
+ get: function () { return chunk5UMM5VYB_cjs.useAIContexts; }
108
108
  });
109
109
  Object.defineProperty(exports, "useAITools", {
110
110
  enumerable: true,
111
- get: function () { return chunkMUZ2RYS2_cjs.useAITools; }
111
+ get: function () { return chunk5UMM5VYB_cjs.useAITools; }
112
112
  });
113
113
  Object.defineProperty(exports, "useAgent", {
114
114
  enumerable: true,
115
- get: function () { return chunkMUZ2RYS2_cjs.useAgent; }
115
+ get: function () { return chunk5UMM5VYB_cjs.useAgent; }
116
116
  });
117
117
  Object.defineProperty(exports, "useCapabilities", {
118
118
  enumerable: true,
119
- get: function () { return chunkMUZ2RYS2_cjs.useCapabilities; }
119
+ get: function () { return chunk5UMM5VYB_cjs.useCapabilities; }
120
120
  });
121
121
  Object.defineProperty(exports, "useChat", {
122
122
  enumerable: true,
123
- get: function () { return chunkMUZ2RYS2_cjs.useChat; }
123
+ get: function () { return chunk5UMM5VYB_cjs.useChat; }
124
124
  });
125
125
  Object.defineProperty(exports, "useCopilot", {
126
126
  enumerable: true,
127
- get: function () { return chunkMUZ2RYS2_cjs.useCopilot; }
127
+ get: function () { return chunk5UMM5VYB_cjs.useCopilot; }
128
128
  });
129
129
  Object.defineProperty(exports, "useDevLogger", {
130
130
  enumerable: true,
131
- get: function () { return chunkMUZ2RYS2_cjs.useDevLogger; }
131
+ get: function () { return chunk5UMM5VYB_cjs.useDevLogger; }
132
132
  });
133
133
  Object.defineProperty(exports, "useFeatureSupport", {
134
134
  enumerable: true,
135
- get: function () { return chunkMUZ2RYS2_cjs.useFeatureSupport; }
135
+ get: function () { return chunk5UMM5VYB_cjs.useFeatureSupport; }
136
136
  });
137
137
  Object.defineProperty(exports, "useKnowledgeBase", {
138
138
  enumerable: true,
139
- get: function () { return chunkMUZ2RYS2_cjs.useKnowledgeBase; }
139
+ get: function () { return chunk5UMM5VYB_cjs.useKnowledgeBase; }
140
140
  });
141
141
  Object.defineProperty(exports, "useMCPClient", {
142
142
  enumerable: true,
143
- get: function () { return chunkMUZ2RYS2_cjs.useMCPClient; }
143
+ get: function () { return chunk5UMM5VYB_cjs.useMCPClient; }
144
144
  });
145
145
  Object.defineProperty(exports, "useMCPTools", {
146
146
  enumerable: true,
147
- get: function () { return chunkMUZ2RYS2_cjs.useMCPTools; }
147
+ get: function () { return chunk5UMM5VYB_cjs.useMCPTools; }
148
148
  });
149
149
  Object.defineProperty(exports, "useMCPUIIntents", {
150
150
  enumerable: true,
151
- get: function () { return chunkMUZ2RYS2_cjs.useMCPUIIntents; }
151
+ get: function () { return chunk5UMM5VYB_cjs.useMCPUIIntents; }
152
152
  });
153
153
  Object.defineProperty(exports, "useSuggestions", {
154
154
  enumerable: true,
155
- get: function () { return chunkMUZ2RYS2_cjs.useSuggestions; }
155
+ get: function () { return chunk5UMM5VYB_cjs.useSuggestions; }
156
156
  });
157
157
  Object.defineProperty(exports, "useSupportedMediaTypes", {
158
158
  enumerable: true,
159
- get: function () { return chunkMUZ2RYS2_cjs.useSupportedMediaTypes; }
159
+ get: function () { return chunk5UMM5VYB_cjs.useSupportedMediaTypes; }
160
160
  });
161
161
  Object.defineProperty(exports, "useThreadManager", {
162
162
  enumerable: true,
163
- get: function () { return chunkMUZ2RYS2_cjs.useThreadManager; }
163
+ get: function () { return chunk5UMM5VYB_cjs.useThreadManager; }
164
164
  });
165
165
  Object.defineProperty(exports, "useTool", {
166
166
  enumerable: true,
167
- get: function () { return chunkMUZ2RYS2_cjs.useTool; }
167
+ get: function () { return chunk5UMM5VYB_cjs.useTool; }
168
168
  });
169
169
  Object.defineProperty(exports, "useToolExecutor", {
170
170
  enumerable: true,
171
- get: function () { return chunkMUZ2RYS2_cjs.useToolExecutor; }
171
+ get: function () { return chunk5UMM5VYB_cjs.useToolExecutor; }
172
172
  });
173
173
  Object.defineProperty(exports, "useToolWithSchema", {
174
174
  enumerable: true,
175
- get: function () { return chunkMUZ2RYS2_cjs.useToolWithSchema; }
175
+ get: function () { return chunk5UMM5VYB_cjs.useToolWithSchema; }
176
176
  });
177
177
  Object.defineProperty(exports, "useTools", {
178
178
  enumerable: true,
179
- get: function () { return chunkMUZ2RYS2_cjs.useTools; }
179
+ get: function () { return chunk5UMM5VYB_cjs.useTools; }
180
180
  });
181
181
  Object.defineProperty(exports, "useToolsWithSchema", {
182
182
  enumerable: true,
183
- get: function () { return chunkMUZ2RYS2_cjs.useToolsWithSchema; }
183
+ get: function () { return chunk5UMM5VYB_cjs.useToolsWithSchema; }
184
184
  });
185
185
  Object.defineProperty(exports, "createLocalStorageAdapter", {
186
186
  enumerable: true,
@@ -10,6 +10,36 @@ import { G as MCPServerConfig, U as UseMCPClientConfig, D as UseMCPClientReturn,
10
10
  export { b as MCPClientState } from '../types-DM6M_pv_.cjs';
11
11
  import { U as UseMCPUIIntentsConfig, m as UseMCPUIIntentsReturn } from '../types-B20VCJXL.cjs';
12
12
 
13
+ /**
14
+ * Resolvable - Type utility for values that can be static or dynamic
15
+ *
16
+ * This pattern allows SDK consumers to pass either:
17
+ * - Static value: `headers: { "x-api-key": "abc123" }`
18
+ * - Getter function: `headers: () => ({ "x-api-key": getToken() })`
19
+ *
20
+ * Values are resolved at request time, ensuring fresh data on every API call.
21
+ * This is the modern pattern used by tanstack-query, tRPC, and axios interceptors.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * // Static (for values that never change)
26
+ * <CopilotProvider headers={{ "x-api-key": "static-key" }} />
27
+ *
28
+ * // Dynamic (for values that change at runtime)
29
+ * <CopilotProvider
30
+ * headers={() => ({
31
+ * Authorization: `Bearer ${getToken()}`,
32
+ * ...getCustomHeaders(),
33
+ * })}
34
+ * />
35
+ * ```
36
+ */
37
+ /**
38
+ * A value that can be either static or a getter function
39
+ * Getter can be sync or async for flexibility
40
+ */
41
+ type Resolvable<T> = T | (() => T) | (() => Promise<T>);
42
+
13
43
  /**
14
44
  * Server Thread Storage Adapter
15
45
  *
@@ -59,6 +89,7 @@ declare function createServerAdapter(config: ServerAdapterConfig): AsyncThreadSt
59
89
  * Contract for different transport implementations.
60
90
  * HTTP, WebSocket, or mock for testing.
61
91
  */
92
+
62
93
  /**
63
94
  * Chat request to send
64
95
  */
@@ -220,6 +251,21 @@ interface ChatTransport {
220
251
  * Check if currently streaming
221
252
  */
222
253
  isStreaming(): boolean;
254
+ /**
255
+ * Update headers configuration (optional)
256
+ * Can be static headers or a getter function for dynamic resolution
257
+ */
258
+ setHeaders?(headers: Resolvable<Record<string, string>>): void;
259
+ /**
260
+ * Update URL configuration (optional)
261
+ * Can be static URL or a getter function for dynamic resolution
262
+ */
263
+ setUrl?(url: Resolvable<string>): void;
264
+ /**
265
+ * Update body configuration (optional)
266
+ * Additional properties merged into every request body
267
+ */
268
+ setBody?(body: Resolvable<Record<string, unknown>>): void;
223
269
  }
224
270
 
225
271
  /**
@@ -369,18 +415,37 @@ interface ChatState$1<T extends UIMessage = UIMessage> {
369
415
  type ChatStatus$1 = "ready" | "submitted" | "streaming" | "error";
370
416
  /**
371
417
  * Chat configuration
418
+ *
419
+ * Supports both static values and getter functions for dynamic configuration.
420
+ * Using getter functions ensures fresh values on every request.
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * const config: ChatConfig = {
425
+ * // Static URL
426
+ * runtimeUrl: "/api/chat",
427
+ *
428
+ * // Dynamic headers - resolved fresh on every request
429
+ * headers: () => ({
430
+ * Authorization: `Bearer ${getToken()}`,
431
+ * ...getCustomHeaders(),
432
+ * }),
433
+ * };
434
+ * ```
372
435
  */
373
436
  interface ChatConfig {
374
- /** Runtime API endpoint */
375
- runtimeUrl: string;
437
+ /** Runtime API endpoint - can be static or getter function */
438
+ runtimeUrl: Resolvable<string>;
376
439
  /** LLM configuration */
377
440
  llm?: Partial<LLMConfig>;
378
441
  /** System prompt */
379
442
  systemPrompt?: string;
380
443
  /** Enable streaming (default: true) */
381
444
  streaming?: boolean;
382
- /** Request headers */
383
- headers?: Record<string, string>;
445
+ /** Request headers - can be static or getter function */
446
+ headers?: Resolvable<Record<string, string>>;
447
+ /** Additional body properties - can be static or getter function */
448
+ body?: Resolvable<Record<string, unknown>>;
384
449
  /** Thread ID for conversation persistence */
385
450
  threadId?: string;
386
451
  /** Debug mode */
@@ -659,6 +724,21 @@ declare class AbstractChat<T extends UIMessage = UIMessage> {
659
724
  * This allows updating the system prompt after initialization
660
725
  */
661
726
  setSystemPrompt(prompt: string): void;
727
+ /**
728
+ * Set headers configuration
729
+ * Can be static headers or a getter function for dynamic resolution
730
+ */
731
+ setHeaders(headers: ChatConfig["headers"]): void;
732
+ /**
733
+ * Set URL configuration
734
+ * Can be static URL or a getter function for dynamic resolution
735
+ */
736
+ setUrl(url: ChatConfig["runtimeUrl"]): void;
737
+ /**
738
+ * Set body configuration
739
+ * Additional properties merged into every request body
740
+ */
741
+ setBody(body: ChatConfig["body"]): void;
662
742
  /**
663
743
  * Build the request payload
664
744
  */
@@ -870,8 +950,11 @@ declare class AbstractAgentLoop implements AgentLoopActions {
870
950
 
871
951
  interface CopilotProviderProps {
872
952
  children: React__default.ReactNode;
873
- /** Runtime API endpoint URL */
874
- runtimeUrl: string;
953
+ /**
954
+ * Runtime API endpoint URL
955
+ * Can be static string or getter function for dynamic resolution.
956
+ */
957
+ runtimeUrl: Resolvable<string>;
875
958
  /** System prompt sent with each request */
876
959
  systemPrompt?: string;
877
960
  /** @deprecated Use useTools() hook instead */
@@ -886,8 +969,16 @@ interface CopilotProviderProps {
886
969
  onError?: (error: Error) => void;
887
970
  /** Enable/disable streaming (default: true) */
888
971
  streaming?: boolean;
889
- /** Custom headers to send with each request */
890
- headers?: Record<string, string>;
972
+ /**
973
+ * Custom headers to send with each request
974
+ * Can be static object or getter function for dynamic resolution.
975
+ */
976
+ headers?: Resolvable<Record<string, string>>;
977
+ /**
978
+ * Additional body properties to include in each request
979
+ * Can be static object or getter function for dynamic resolution.
980
+ */
981
+ body?: Resolvable<Record<string, unknown>>;
891
982
  /** Enable debug logging */
892
983
  debug?: boolean;
893
984
  /** Max tool execution iterations (default: 20) */
@@ -921,11 +1012,15 @@ interface CopilotContextValue {
921
1012
  removeContext: (id: string) => void;
922
1013
  setSystemPrompt: (prompt: string) => void;
923
1014
  threadId?: string;
924
- runtimeUrl: string;
1015
+ /**
1016
+ * Runtime URL configuration.
1017
+ * Can be a static string or getter function (matches what was passed to provider).
1018
+ */
1019
+ runtimeUrl: Resolvable<string>;
925
1020
  toolsConfig?: ToolsConfig;
926
1021
  }
927
1022
  declare function useCopilot(): CopilotContextValue;
928
- declare function CopilotProvider({ children, runtimeUrl, systemPrompt, tools: toolsConfig, threadId, initialMessages, onMessagesChange, onError, streaming, headers, debug, maxIterations, maxIterationsMessage, mcpServers, }: CopilotProviderProps): react_jsx_runtime.JSX.Element;
1023
+ declare function CopilotProvider({ children, runtimeUrl, systemPrompt, tools: toolsConfig, threadId, initialMessages, onMessagesChange, onError, streaming, headers, body, debug, maxIterations, maxIterationsMessage, mcpServers, }: CopilotProviderProps): react_jsx_runtime.JSX.Element;
929
1024
 
930
1025
  /**
931
1026
  * Chat UI state interface (UI-only state, not message data)
@@ -10,6 +10,36 @@ import { G as MCPServerConfig, U as UseMCPClientConfig, D as UseMCPClientReturn,
10
10
  export { b as MCPClientState } from '../types-wudOhedT.js';
11
11
  import { U as UseMCPUIIntentsConfig, m as UseMCPUIIntentsReturn } from '../types-B20VCJXL.js';
12
12
 
13
+ /**
14
+ * Resolvable - Type utility for values that can be static or dynamic
15
+ *
16
+ * This pattern allows SDK consumers to pass either:
17
+ * - Static value: `headers: { "x-api-key": "abc123" }`
18
+ * - Getter function: `headers: () => ({ "x-api-key": getToken() })`
19
+ *
20
+ * Values are resolved at request time, ensuring fresh data on every API call.
21
+ * This is the modern pattern used by tanstack-query, tRPC, and axios interceptors.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * // Static (for values that never change)
26
+ * <CopilotProvider headers={{ "x-api-key": "static-key" }} />
27
+ *
28
+ * // Dynamic (for values that change at runtime)
29
+ * <CopilotProvider
30
+ * headers={() => ({
31
+ * Authorization: `Bearer ${getToken()}`,
32
+ * ...getCustomHeaders(),
33
+ * })}
34
+ * />
35
+ * ```
36
+ */
37
+ /**
38
+ * A value that can be either static or a getter function
39
+ * Getter can be sync or async for flexibility
40
+ */
41
+ type Resolvable<T> = T | (() => T) | (() => Promise<T>);
42
+
13
43
  /**
14
44
  * Server Thread Storage Adapter
15
45
  *
@@ -59,6 +89,7 @@ declare function createServerAdapter(config: ServerAdapterConfig): AsyncThreadSt
59
89
  * Contract for different transport implementations.
60
90
  * HTTP, WebSocket, or mock for testing.
61
91
  */
92
+
62
93
  /**
63
94
  * Chat request to send
64
95
  */
@@ -220,6 +251,21 @@ interface ChatTransport {
220
251
  * Check if currently streaming
221
252
  */
222
253
  isStreaming(): boolean;
254
+ /**
255
+ * Update headers configuration (optional)
256
+ * Can be static headers or a getter function for dynamic resolution
257
+ */
258
+ setHeaders?(headers: Resolvable<Record<string, string>>): void;
259
+ /**
260
+ * Update URL configuration (optional)
261
+ * Can be static URL or a getter function for dynamic resolution
262
+ */
263
+ setUrl?(url: Resolvable<string>): void;
264
+ /**
265
+ * Update body configuration (optional)
266
+ * Additional properties merged into every request body
267
+ */
268
+ setBody?(body: Resolvable<Record<string, unknown>>): void;
223
269
  }
224
270
 
225
271
  /**
@@ -369,18 +415,37 @@ interface ChatState$1<T extends UIMessage = UIMessage> {
369
415
  type ChatStatus$1 = "ready" | "submitted" | "streaming" | "error";
370
416
  /**
371
417
  * Chat configuration
418
+ *
419
+ * Supports both static values and getter functions for dynamic configuration.
420
+ * Using getter functions ensures fresh values on every request.
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * const config: ChatConfig = {
425
+ * // Static URL
426
+ * runtimeUrl: "/api/chat",
427
+ *
428
+ * // Dynamic headers - resolved fresh on every request
429
+ * headers: () => ({
430
+ * Authorization: `Bearer ${getToken()}`,
431
+ * ...getCustomHeaders(),
432
+ * }),
433
+ * };
434
+ * ```
372
435
  */
373
436
  interface ChatConfig {
374
- /** Runtime API endpoint */
375
- runtimeUrl: string;
437
+ /** Runtime API endpoint - can be static or getter function */
438
+ runtimeUrl: Resolvable<string>;
376
439
  /** LLM configuration */
377
440
  llm?: Partial<LLMConfig>;
378
441
  /** System prompt */
379
442
  systemPrompt?: string;
380
443
  /** Enable streaming (default: true) */
381
444
  streaming?: boolean;
382
- /** Request headers */
383
- headers?: Record<string, string>;
445
+ /** Request headers - can be static or getter function */
446
+ headers?: Resolvable<Record<string, string>>;
447
+ /** Additional body properties - can be static or getter function */
448
+ body?: Resolvable<Record<string, unknown>>;
384
449
  /** Thread ID for conversation persistence */
385
450
  threadId?: string;
386
451
  /** Debug mode */
@@ -659,6 +724,21 @@ declare class AbstractChat<T extends UIMessage = UIMessage> {
659
724
  * This allows updating the system prompt after initialization
660
725
  */
661
726
  setSystemPrompt(prompt: string): void;
727
+ /**
728
+ * Set headers configuration
729
+ * Can be static headers or a getter function for dynamic resolution
730
+ */
731
+ setHeaders(headers: ChatConfig["headers"]): void;
732
+ /**
733
+ * Set URL configuration
734
+ * Can be static URL or a getter function for dynamic resolution
735
+ */
736
+ setUrl(url: ChatConfig["runtimeUrl"]): void;
737
+ /**
738
+ * Set body configuration
739
+ * Additional properties merged into every request body
740
+ */
741
+ setBody(body: ChatConfig["body"]): void;
662
742
  /**
663
743
  * Build the request payload
664
744
  */
@@ -870,8 +950,11 @@ declare class AbstractAgentLoop implements AgentLoopActions {
870
950
 
871
951
  interface CopilotProviderProps {
872
952
  children: React__default.ReactNode;
873
- /** Runtime API endpoint URL */
874
- runtimeUrl: string;
953
+ /**
954
+ * Runtime API endpoint URL
955
+ * Can be static string or getter function for dynamic resolution.
956
+ */
957
+ runtimeUrl: Resolvable<string>;
875
958
  /** System prompt sent with each request */
876
959
  systemPrompt?: string;
877
960
  /** @deprecated Use useTools() hook instead */
@@ -886,8 +969,16 @@ interface CopilotProviderProps {
886
969
  onError?: (error: Error) => void;
887
970
  /** Enable/disable streaming (default: true) */
888
971
  streaming?: boolean;
889
- /** Custom headers to send with each request */
890
- headers?: Record<string, string>;
972
+ /**
973
+ * Custom headers to send with each request
974
+ * Can be static object or getter function for dynamic resolution.
975
+ */
976
+ headers?: Resolvable<Record<string, string>>;
977
+ /**
978
+ * Additional body properties to include in each request
979
+ * Can be static object or getter function for dynamic resolution.
980
+ */
981
+ body?: Resolvable<Record<string, unknown>>;
891
982
  /** Enable debug logging */
892
983
  debug?: boolean;
893
984
  /** Max tool execution iterations (default: 20) */
@@ -921,11 +1012,15 @@ interface CopilotContextValue {
921
1012
  removeContext: (id: string) => void;
922
1013
  setSystemPrompt: (prompt: string) => void;
923
1014
  threadId?: string;
924
- runtimeUrl: string;
1015
+ /**
1016
+ * Runtime URL configuration.
1017
+ * Can be a static string or getter function (matches what was passed to provider).
1018
+ */
1019
+ runtimeUrl: Resolvable<string>;
925
1020
  toolsConfig?: ToolsConfig;
926
1021
  }
927
1022
  declare function useCopilot(): CopilotContextValue;
928
- declare function CopilotProvider({ children, runtimeUrl, systemPrompt, tools: toolsConfig, threadId, initialMessages, onMessagesChange, onError, streaming, headers, debug, maxIterations, maxIterationsMessage, mcpServers, }: CopilotProviderProps): react_jsx_runtime.JSX.Element;
1023
+ declare function CopilotProvider({ children, runtimeUrl, systemPrompt, tools: toolsConfig, threadId, initialMessages, onMessagesChange, onError, streaming, headers, body, debug, maxIterations, maxIterationsMessage, mcpServers, }: CopilotProviderProps): react_jsx_runtime.JSX.Element;
929
1024
 
930
1025
  /**
931
1026
  * Chat UI state interface (UI-only state, not message data)
@@ -1,4 +1,4 @@
1
- export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-3SP6V22Y.js';
1
+ export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-SNI7VN2U.js';
2
2
  export { createLocalStorageAdapter, createMemoryAdapter, createServerAdapter, generateSuggestionReason } from '../chunk-7PJ4GAJR.js';
3
3
  import '../chunk-EWVQWTNV.js';
4
4
  import '../chunk-7YZVSG62.js';
package/dist/ui/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var chunkMUZ2RYS2_cjs = require('../chunk-MUZ2RYS2.cjs');
3
+ var chunk5UMM5VYB_cjs = require('../chunk-5UMM5VYB.cjs');
4
4
  var chunk33JSFVGH_cjs = require('../chunk-33JSFVGH.cjs');
5
5
  var chunkJO4BHPAD_cjs = require('../chunk-JO4BHPAD.cjs');
6
6
  require('../chunk-JGPDQDY4.cjs');
@@ -5944,7 +5944,7 @@ function useInternalThreadManager(config = {}) {
5944
5944
  saveDebounce,
5945
5945
  autoRestoreLastThread
5946
5946
  };
5947
- const threadManager = chunkMUZ2RYS2_cjs.useThreadManager(threadManagerConfig);
5947
+ const threadManager = chunk5UMM5VYB_cjs.useThreadManager(threadManagerConfig);
5948
5948
  const {
5949
5949
  currentThread,
5950
5950
  currentThreadId,
@@ -5954,7 +5954,7 @@ function useInternalThreadManager(config = {}) {
5954
5954
  clearCurrentThread,
5955
5955
  refreshThreads
5956
5956
  } = threadManager;
5957
- const { messages, setMessages, status, isLoading } = chunkMUZ2RYS2_cjs.useCopilot();
5957
+ const { messages, setMessages, status, isLoading } = chunk5UMM5VYB_cjs.useCopilot();
5958
5958
  const isLoadingMessagesRef = React20.useRef(false);
5959
5959
  const savingToThreadRef = React20.useRef(null);
5960
5960
  const lastSavedSnapshotRef = React20.useRef("");
@@ -6171,7 +6171,7 @@ function CopilotChatBase(props) {
6171
6171
  approveToolExecution,
6172
6172
  rejectToolExecution,
6173
6173
  registeredTools
6174
- } = chunkMUZ2RYS2_cjs.useCopilot();
6174
+ } = chunk5UMM5VYB_cjs.useCopilot();
6175
6175
  const toolExecutions = rawToolExecutions.map(
6176
6176
  (exec) => ({
6177
6177
  id: exec.id,
package/dist/ui/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { useCopilot, useThreadManager } from '../chunk-3SP6V22Y.js';
1
+ import { useCopilot, useThreadManager } from '../chunk-SNI7VN2U.js';
2
2
  import { createServerAdapter } from '../chunk-7PJ4GAJR.js';
3
3
  import { DEFAULT_MCP_UI_SANDBOX, parseMCPUIMessage } from '../chunk-G4SF2PNQ.js';
4
4
  import '../chunk-EWVQWTNV.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yourgpt/copilot-sdk",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Copilot SDK for building Production-ready AI Copilots for any product. Connect any LLM, deploy on your infrastructure, own your data.",
5
5
  "type": "module",
6
6
  "types": "./dist/core/index.d.ts",