@yourgpt/copilot-sdk 2.1.4 → 2.1.5-alpha.0
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/MessageTree-CoIt_4nB.d.cts +161 -0
- package/dist/MessageTree-CzaN9Eul.d.ts +161 -0
- package/dist/{ThreadManager-Dkp_eLty.d.ts → ThreadManager-BEAECB7Y.d.ts} +1 -1
- package/dist/{ThreadManager-LfFRhr4e.d.cts → ThreadManager-Cw5fwyCN.d.cts} +1 -1
- package/dist/{chunk-POZNNKNJ.cjs → chunk-246B6X5D.cjs} +8 -2
- package/dist/chunk-246B6X5D.cjs.map +1 -0
- package/dist/{chunk-QLH6TSCC.js → chunk-4QXY2PBG.js} +8 -2
- package/dist/chunk-4QXY2PBG.js.map +1 -0
- package/dist/{chunk-7PKGRYHY.js → chunk-6BMQZIS3.js} +3094 -355
- package/dist/chunk-6BMQZIS3.js.map +1 -0
- package/dist/{chunk-N6VZ7FOW.cjs → chunk-76RE7AJE.cjs} +3277 -520
- package/dist/chunk-76RE7AJE.cjs.map +1 -0
- package/dist/chunk-BJYA5NDL.cjs +96 -0
- package/dist/chunk-BJYA5NDL.cjs.map +1 -0
- package/dist/{chunk-LZMBBGWH.js → chunk-ENFWM3EY.js} +4 -4
- package/dist/{chunk-LZMBBGWH.js.map → chunk-ENFWM3EY.js.map} +1 -1
- package/dist/{chunk-OQPRIB73.cjs → chunk-I3SQUNTT.cjs} +71 -25
- package/dist/chunk-I3SQUNTT.cjs.map +1 -0
- package/dist/{chunk-WAPGTQDR.cjs → chunk-JKGFQUHJ.cjs} +10 -10
- package/dist/{chunk-WAPGTQDR.cjs.map → chunk-JKGFQUHJ.cjs.map} +1 -1
- package/dist/{chunk-XGITAEXU.js → chunk-LLM7AHMO.js} +2 -2
- package/dist/{chunk-XGITAEXU.js.map → chunk-LLM7AHMO.js.map} +1 -1
- package/dist/{chunk-ASV6JLYG.cjs → chunk-NUXLAZOE.cjs} +2 -2
- package/dist/{chunk-ASV6JLYG.cjs.map → chunk-NUXLAZOE.cjs.map} +1 -1
- package/dist/{chunk-37KEHUCE.js → chunk-UXJ6LIZB.js} +51 -7
- package/dist/chunk-UXJ6LIZB.js.map +1 -0
- package/dist/chunk-VNLLW3ZI.js +94 -0
- package/dist/chunk-VNLLW3ZI.js.map +1 -0
- package/dist/core/index.cjs +99 -91
- package/dist/core/index.d.cts +7 -7
- package/dist/core/index.d.ts +7 -7
- package/dist/core/index.js +5 -5
- package/dist/{index-BHkRA0mM.d.cts → index-CiExk87c.d.cts} +1 -1
- package/dist/{index-tB0qI8my.d.ts → index-Dwrcf-CP.d.ts} +1 -1
- package/dist/mcp/index.d.cts +3 -3
- package/dist/mcp/index.d.ts +3 -3
- package/dist/react/index.cjs +113 -52
- package/dist/react/index.d.cts +673 -77
- package/dist/react/index.d.ts +673 -77
- package/dist/react/index.js +7 -6
- package/dist/server/index.cjs +339 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +171 -0
- package/dist/server/index.d.ts +171 -0
- package/dist/server/index.js +332 -0
- package/dist/server/index.js.map +1 -0
- package/dist/tools/anthropic/index.cjs +3 -3
- package/dist/tools/anthropic/index.d.cts +1 -1
- package/dist/tools/anthropic/index.d.ts +1 -1
- package/dist/tools/anthropic/index.js +3 -3
- package/dist/tools/brave/index.cjs +6 -6
- package/dist/tools/brave/index.d.cts +1 -1
- package/dist/tools/brave/index.d.ts +1 -1
- package/dist/tools/brave/index.js +3 -3
- package/dist/tools/exa/index.cjs +6 -6
- package/dist/tools/exa/index.d.cts +1 -1
- package/dist/tools/exa/index.d.ts +1 -1
- package/dist/tools/exa/index.js +3 -3
- package/dist/tools/google/index.cjs +6 -6
- package/dist/tools/google/index.d.cts +1 -1
- package/dist/tools/google/index.d.ts +1 -1
- package/dist/tools/google/index.js +3 -3
- package/dist/tools/openai/index.cjs +6 -6
- package/dist/tools/openai/index.d.cts +1 -1
- package/dist/tools/openai/index.d.ts +1 -1
- package/dist/tools/openai/index.js +3 -3
- package/dist/tools/searxng/index.cjs +6 -6
- package/dist/tools/searxng/index.d.cts +1 -1
- package/dist/tools/searxng/index.d.ts +1 -1
- package/dist/tools/searxng/index.js +3 -3
- package/dist/tools/serper/index.cjs +6 -6
- package/dist/tools/serper/index.d.cts +1 -1
- package/dist/tools/serper/index.d.ts +1 -1
- package/dist/tools/serper/index.js +3 -3
- package/dist/tools/tavily/index.cjs +6 -6
- package/dist/tools/tavily/index.d.cts +1 -1
- package/dist/tools/tavily/index.d.ts +1 -1
- package/dist/tools/tavily/index.js +3 -3
- package/dist/tools/web-search/index.cjs +7 -7
- package/dist/tools/web-search/index.d.cts +2 -2
- package/dist/tools/web-search/index.d.ts +2 -2
- package/dist/tools/web-search/index.js +4 -4
- package/dist/{tools-coIcskZ4.d.ts → tools-DHZhF5km.d.cts} +161 -1
- package/dist/{tools-coIcskZ4.d.cts → tools-DHZhF5km.d.ts} +161 -1
- package/dist/{types-rjaSVmEF.d.ts → types-BTyJu0WD.d.ts} +1 -1
- package/dist/types-BckL3hiw.d.cts +93 -0
- package/dist/types-BckL3hiw.d.ts +93 -0
- package/dist/{types-C8t4Ut8f.d.cts → types-BdX7uPj0.d.cts} +1 -1
- package/dist/{types-DG2ya08y.d.ts → types-BeFBBZ5i.d.cts} +64 -1
- package/dist/{types-DG2ya08y.d.cts → types-BeFBBZ5i.d.ts} +64 -1
- package/dist/ui/index.cjs +468 -163
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +81 -4
- package/dist/ui/index.d.ts +81 -4
- package/dist/ui/index.js +416 -112
- package/dist/ui/index.js.map +1 -1
- package/package.json +6 -1
- package/dist/chunk-37KEHUCE.js.map +0 -1
- package/dist/chunk-7PKGRYHY.js.map +0 -1
- package/dist/chunk-N6VZ7FOW.cjs.map +0 -1
- package/dist/chunk-OQPRIB73.cjs.map +0 -1
- package/dist/chunk-POZNNKNJ.cjs.map +0 -1
- package/dist/chunk-QLH6TSCC.js.map +0 -1
|
@@ -134,6 +134,140 @@ type AIContent = {
|
|
|
134
134
|
type: "text";
|
|
135
135
|
text: string;
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* How large tool results should be trimmed before they are sent back to the AI.
|
|
139
|
+
*/
|
|
140
|
+
type ToolTruncationStrategy = "head" | "head-tail" | "smart";
|
|
141
|
+
/**
|
|
142
|
+
* Truncation controls for tool results.
|
|
143
|
+
*/
|
|
144
|
+
interface ToolResultTruncationConfig {
|
|
145
|
+
enabled?: boolean;
|
|
146
|
+
maxContextShare?: number;
|
|
147
|
+
hardMaxChars?: number;
|
|
148
|
+
minKeepChars?: number;
|
|
149
|
+
strategy?: ToolTruncationStrategy;
|
|
150
|
+
preserveErrors?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Global or per-tool controls for how tool results are represented in prompts.
|
|
154
|
+
*/
|
|
155
|
+
interface ToolResultConfig {
|
|
156
|
+
truncation?: ToolResultTruncationConfig;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Named tool profile for selective loading.
|
|
160
|
+
*/
|
|
161
|
+
interface ToolProfile {
|
|
162
|
+
name: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
include?: string[];
|
|
165
|
+
exclude?: string[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Tool profile configuration.
|
|
169
|
+
*/
|
|
170
|
+
interface ToolProfileConfig {
|
|
171
|
+
enabled?: boolean;
|
|
172
|
+
defaultProfile?: string;
|
|
173
|
+
profiles?: Record<string, ToolProfile>;
|
|
174
|
+
/** When false, active profiles exclude tools that do not declare profile membership. */
|
|
175
|
+
includeUnprofiled?: boolean;
|
|
176
|
+
dynamicSelection?: {
|
|
177
|
+
enabled?: boolean;
|
|
178
|
+
maxTools?: number;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* History compaction behavior for long-running sessions.
|
|
183
|
+
*/
|
|
184
|
+
interface ContextHistoryConfig {
|
|
185
|
+
maxMessages?: number;
|
|
186
|
+
maxTokens?: number;
|
|
187
|
+
maxContextShare?: number;
|
|
188
|
+
pruneStrategy?: "oldest" | "least-relevant" | "summarize";
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Optional summarization controls used during history compaction.
|
|
192
|
+
*/
|
|
193
|
+
interface ContextSummarizationConfig {
|
|
194
|
+
enabled?: boolean;
|
|
195
|
+
triggerAt?: number;
|
|
196
|
+
chunkSize?: number;
|
|
197
|
+
preserveRecent?: number;
|
|
198
|
+
fallbackBehavior?: "truncate" | "statistical" | "error";
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Token estimation controls.
|
|
202
|
+
*/
|
|
203
|
+
interface TokenEstimationConfig {
|
|
204
|
+
safetyMargin?: number;
|
|
205
|
+
charsPerToken?: number;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Conversation context management.
|
|
209
|
+
*/
|
|
210
|
+
interface ContextManagementConfig {
|
|
211
|
+
enabled?: boolean;
|
|
212
|
+
history?: ContextHistoryConfig;
|
|
213
|
+
summarization?: ContextSummarizationConfig;
|
|
214
|
+
tokenEstimation?: TokenEstimationConfig;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One budget bucket in the prompt context.
|
|
218
|
+
*/
|
|
219
|
+
interface ContextUsagePart {
|
|
220
|
+
tokens: number;
|
|
221
|
+
percent: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Prompt context usage snapshot.
|
|
225
|
+
*/
|
|
226
|
+
interface ContextUsage {
|
|
227
|
+
total: ContextUsagePart;
|
|
228
|
+
breakdown: {
|
|
229
|
+
systemPrompt: ContextUsagePart;
|
|
230
|
+
history: ContextUsagePart;
|
|
231
|
+
toolResults: ContextUsagePart;
|
|
232
|
+
tools: ContextUsagePart;
|
|
233
|
+
};
|
|
234
|
+
budget: {
|
|
235
|
+
available: number;
|
|
236
|
+
remaining: number;
|
|
237
|
+
};
|
|
238
|
+
warnings: string[];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Real-time context budget configuration.
|
|
242
|
+
*/
|
|
243
|
+
interface ContextBudgetConfig {
|
|
244
|
+
enabled?: boolean;
|
|
245
|
+
budget?: {
|
|
246
|
+
contextWindowTokens?: number;
|
|
247
|
+
inputHeadroomRatio?: number;
|
|
248
|
+
systemPromptShare?: number;
|
|
249
|
+
historyShare?: number;
|
|
250
|
+
toolResultsShare?: number;
|
|
251
|
+
toolDefinitionsShare?: number;
|
|
252
|
+
};
|
|
253
|
+
enforcement?: {
|
|
254
|
+
mode?: "warn" | "truncate" | "error";
|
|
255
|
+
onBudgetExceeded?: (info: ContextUsage) => void;
|
|
256
|
+
};
|
|
257
|
+
monitoring?: {
|
|
258
|
+
enabled?: boolean;
|
|
259
|
+
onUsageUpdate?: (usage: ContextUsage) => void;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Framework-agnostic optimization controls for tool-heavy chat sessions.
|
|
264
|
+
*/
|
|
265
|
+
interface ToolOptimizationConfig {
|
|
266
|
+
toolProfiles?: ToolProfileConfig;
|
|
267
|
+
toolResultConfig?: ToolResultConfig;
|
|
268
|
+
contextManagement?: ContextManagementConfig;
|
|
269
|
+
contextBudget?: ContextBudgetConfig;
|
|
270
|
+
}
|
|
137
271
|
/**
|
|
138
272
|
* Tool response format
|
|
139
273
|
*/
|
|
@@ -306,6 +440,18 @@ interface ToolDefinition<TParams = Record<string, unknown>> {
|
|
|
306
440
|
* @default "custom"
|
|
307
441
|
*/
|
|
308
442
|
source?: ToolSource;
|
|
443
|
+
/** Optional category for search, filtering, and budgets */
|
|
444
|
+
category?: string;
|
|
445
|
+
/** Optional group for profile-based tool selection */
|
|
446
|
+
group?: string;
|
|
447
|
+
/** Deferred tools are discoverable but need not be sent on every request */
|
|
448
|
+
deferLoading?: boolean;
|
|
449
|
+
/** Profile memberships for selective tool loading */
|
|
450
|
+
profiles?: string[];
|
|
451
|
+
/** Extra keywords for dynamic tool selection */
|
|
452
|
+
searchKeywords?: string[];
|
|
453
|
+
/** Per-tool prompt/result shaping controls */
|
|
454
|
+
resultConfig?: ToolResultConfig;
|
|
309
455
|
/**
|
|
310
456
|
* Human-readable title for UI display.
|
|
311
457
|
* Can be a static string or a function that generates title from args.
|
|
@@ -548,6 +694,8 @@ interface AgentLoopConfig {
|
|
|
548
694
|
debug?: boolean;
|
|
549
695
|
/** Whether to enable the agentic loop (default: true) */
|
|
550
696
|
enabled?: boolean;
|
|
697
|
+
/** Optional prompt/tool optimization controls */
|
|
698
|
+
optimization?: ToolOptimizationConfig;
|
|
551
699
|
}
|
|
552
700
|
/**
|
|
553
701
|
* Agent loop state (for tracking)
|
|
@@ -598,6 +746,18 @@ interface ToolConfig<TParams = Record<string, unknown>> {
|
|
|
598
746
|
description: string;
|
|
599
747
|
/** Where the tool executes (default: 'client') */
|
|
600
748
|
location?: ToolLocation;
|
|
749
|
+
/** Optional category for search, filtering, and budgets */
|
|
750
|
+
category?: string;
|
|
751
|
+
/** Optional group for profile-based tool selection */
|
|
752
|
+
group?: string;
|
|
753
|
+
/** Deferred tools are discoverable but omitted from the default prompt */
|
|
754
|
+
deferLoading?: boolean;
|
|
755
|
+
/** Profile memberships for selective tool loading */
|
|
756
|
+
profiles?: string[];
|
|
757
|
+
/** Extra keywords for dynamic tool selection */
|
|
758
|
+
searchKeywords?: string[];
|
|
759
|
+
/** Per-tool prompt/result shaping controls */
|
|
760
|
+
resultConfig?: ToolResultConfig;
|
|
601
761
|
/** Human-readable title for UI display */
|
|
602
762
|
title?: string | ((args: TParams) => string);
|
|
603
763
|
/** Title shown while executing */
|
|
@@ -666,4 +826,4 @@ declare function success<T = unknown>(data?: T, message?: string): ToolResponse<
|
|
|
666
826
|
*/
|
|
667
827
|
declare function failure(error: string): ToolResponse;
|
|
668
828
|
|
|
669
|
-
export { type AIProvider as A, type JSONSchemaProperty as J, type PermissionLevel as P, type ToolDefinition as T, type UnifiedToolCall as U, type ToolExecutionStatus as a, type ToolResponse as b, type ToolInputSchema as c, type ToolLocation as d, type ToolContext as e, type ToolSource as f, type ToolRenderProps as g, type ToolConfig as h, type
|
|
829
|
+
export { type AIProvider as A, type AgentLoopState as B, type ContextHistoryConfig as C, type AIResponseMode as D, type AIContent as E, type ToolPermission as F, type PermissionStorageConfig as G, type PermissionStorageAdapter as H, tool as I, type JSONSchemaProperty as J, toolToOpenAIFormat as K, toolToAnthropicFormat as L, createToolResult as M, success as N, failure as O, type PermissionLevel as P, type ToolDefinition as T, type UnifiedToolCall as U, type ToolExecutionStatus as a, type ToolResponse as b, type ToolInputSchema as c, type ToolLocation as d, type ToolContext as e, type ToolSource as f, type ToolRenderProps as g, type ToolConfig as h, type ToolResultConfig as i, type ToolResultTruncationConfig as j, type ToolTruncationStrategy as k, type ToolProfile as l, type ToolProfileConfig as m, type ContextSummarizationConfig as n, type TokenEstimationConfig as o, type ContextManagementConfig as p, type ContextUsagePart as q, type ContextUsage as r, type ContextBudgetConfig as s, type ToolOptimizationConfig as t, type ToolSet as u, type ToolSetEntry as v, type UnifiedToolResult as w, type ToolApprovalStatus as x, type ToolExecution as y, type AgentLoopConfig as z };
|
|
@@ -134,6 +134,140 @@ type AIContent = {
|
|
|
134
134
|
type: "text";
|
|
135
135
|
text: string;
|
|
136
136
|
};
|
|
137
|
+
/**
|
|
138
|
+
* How large tool results should be trimmed before they are sent back to the AI.
|
|
139
|
+
*/
|
|
140
|
+
type ToolTruncationStrategy = "head" | "head-tail" | "smart";
|
|
141
|
+
/**
|
|
142
|
+
* Truncation controls for tool results.
|
|
143
|
+
*/
|
|
144
|
+
interface ToolResultTruncationConfig {
|
|
145
|
+
enabled?: boolean;
|
|
146
|
+
maxContextShare?: number;
|
|
147
|
+
hardMaxChars?: number;
|
|
148
|
+
minKeepChars?: number;
|
|
149
|
+
strategy?: ToolTruncationStrategy;
|
|
150
|
+
preserveErrors?: boolean;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Global or per-tool controls for how tool results are represented in prompts.
|
|
154
|
+
*/
|
|
155
|
+
interface ToolResultConfig {
|
|
156
|
+
truncation?: ToolResultTruncationConfig;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Named tool profile for selective loading.
|
|
160
|
+
*/
|
|
161
|
+
interface ToolProfile {
|
|
162
|
+
name: string;
|
|
163
|
+
description?: string;
|
|
164
|
+
include?: string[];
|
|
165
|
+
exclude?: string[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Tool profile configuration.
|
|
169
|
+
*/
|
|
170
|
+
interface ToolProfileConfig {
|
|
171
|
+
enabled?: boolean;
|
|
172
|
+
defaultProfile?: string;
|
|
173
|
+
profiles?: Record<string, ToolProfile>;
|
|
174
|
+
/** When false, active profiles exclude tools that do not declare profile membership. */
|
|
175
|
+
includeUnprofiled?: boolean;
|
|
176
|
+
dynamicSelection?: {
|
|
177
|
+
enabled?: boolean;
|
|
178
|
+
maxTools?: number;
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* History compaction behavior for long-running sessions.
|
|
183
|
+
*/
|
|
184
|
+
interface ContextHistoryConfig {
|
|
185
|
+
maxMessages?: number;
|
|
186
|
+
maxTokens?: number;
|
|
187
|
+
maxContextShare?: number;
|
|
188
|
+
pruneStrategy?: "oldest" | "least-relevant" | "summarize";
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Optional summarization controls used during history compaction.
|
|
192
|
+
*/
|
|
193
|
+
interface ContextSummarizationConfig {
|
|
194
|
+
enabled?: boolean;
|
|
195
|
+
triggerAt?: number;
|
|
196
|
+
chunkSize?: number;
|
|
197
|
+
preserveRecent?: number;
|
|
198
|
+
fallbackBehavior?: "truncate" | "statistical" | "error";
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Token estimation controls.
|
|
202
|
+
*/
|
|
203
|
+
interface TokenEstimationConfig {
|
|
204
|
+
safetyMargin?: number;
|
|
205
|
+
charsPerToken?: number;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Conversation context management.
|
|
209
|
+
*/
|
|
210
|
+
interface ContextManagementConfig {
|
|
211
|
+
enabled?: boolean;
|
|
212
|
+
history?: ContextHistoryConfig;
|
|
213
|
+
summarization?: ContextSummarizationConfig;
|
|
214
|
+
tokenEstimation?: TokenEstimationConfig;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One budget bucket in the prompt context.
|
|
218
|
+
*/
|
|
219
|
+
interface ContextUsagePart {
|
|
220
|
+
tokens: number;
|
|
221
|
+
percent: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Prompt context usage snapshot.
|
|
225
|
+
*/
|
|
226
|
+
interface ContextUsage {
|
|
227
|
+
total: ContextUsagePart;
|
|
228
|
+
breakdown: {
|
|
229
|
+
systemPrompt: ContextUsagePart;
|
|
230
|
+
history: ContextUsagePart;
|
|
231
|
+
toolResults: ContextUsagePart;
|
|
232
|
+
tools: ContextUsagePart;
|
|
233
|
+
};
|
|
234
|
+
budget: {
|
|
235
|
+
available: number;
|
|
236
|
+
remaining: number;
|
|
237
|
+
};
|
|
238
|
+
warnings: string[];
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Real-time context budget configuration.
|
|
242
|
+
*/
|
|
243
|
+
interface ContextBudgetConfig {
|
|
244
|
+
enabled?: boolean;
|
|
245
|
+
budget?: {
|
|
246
|
+
contextWindowTokens?: number;
|
|
247
|
+
inputHeadroomRatio?: number;
|
|
248
|
+
systemPromptShare?: number;
|
|
249
|
+
historyShare?: number;
|
|
250
|
+
toolResultsShare?: number;
|
|
251
|
+
toolDefinitionsShare?: number;
|
|
252
|
+
};
|
|
253
|
+
enforcement?: {
|
|
254
|
+
mode?: "warn" | "truncate" | "error";
|
|
255
|
+
onBudgetExceeded?: (info: ContextUsage) => void;
|
|
256
|
+
};
|
|
257
|
+
monitoring?: {
|
|
258
|
+
enabled?: boolean;
|
|
259
|
+
onUsageUpdate?: (usage: ContextUsage) => void;
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Framework-agnostic optimization controls for tool-heavy chat sessions.
|
|
264
|
+
*/
|
|
265
|
+
interface ToolOptimizationConfig {
|
|
266
|
+
toolProfiles?: ToolProfileConfig;
|
|
267
|
+
toolResultConfig?: ToolResultConfig;
|
|
268
|
+
contextManagement?: ContextManagementConfig;
|
|
269
|
+
contextBudget?: ContextBudgetConfig;
|
|
270
|
+
}
|
|
137
271
|
/**
|
|
138
272
|
* Tool response format
|
|
139
273
|
*/
|
|
@@ -306,6 +440,18 @@ interface ToolDefinition<TParams = Record<string, unknown>> {
|
|
|
306
440
|
* @default "custom"
|
|
307
441
|
*/
|
|
308
442
|
source?: ToolSource;
|
|
443
|
+
/** Optional category for search, filtering, and budgets */
|
|
444
|
+
category?: string;
|
|
445
|
+
/** Optional group for profile-based tool selection */
|
|
446
|
+
group?: string;
|
|
447
|
+
/** Deferred tools are discoverable but need not be sent on every request */
|
|
448
|
+
deferLoading?: boolean;
|
|
449
|
+
/** Profile memberships for selective tool loading */
|
|
450
|
+
profiles?: string[];
|
|
451
|
+
/** Extra keywords for dynamic tool selection */
|
|
452
|
+
searchKeywords?: string[];
|
|
453
|
+
/** Per-tool prompt/result shaping controls */
|
|
454
|
+
resultConfig?: ToolResultConfig;
|
|
309
455
|
/**
|
|
310
456
|
* Human-readable title for UI display.
|
|
311
457
|
* Can be a static string or a function that generates title from args.
|
|
@@ -548,6 +694,8 @@ interface AgentLoopConfig {
|
|
|
548
694
|
debug?: boolean;
|
|
549
695
|
/** Whether to enable the agentic loop (default: true) */
|
|
550
696
|
enabled?: boolean;
|
|
697
|
+
/** Optional prompt/tool optimization controls */
|
|
698
|
+
optimization?: ToolOptimizationConfig;
|
|
551
699
|
}
|
|
552
700
|
/**
|
|
553
701
|
* Agent loop state (for tracking)
|
|
@@ -598,6 +746,18 @@ interface ToolConfig<TParams = Record<string, unknown>> {
|
|
|
598
746
|
description: string;
|
|
599
747
|
/** Where the tool executes (default: 'client') */
|
|
600
748
|
location?: ToolLocation;
|
|
749
|
+
/** Optional category for search, filtering, and budgets */
|
|
750
|
+
category?: string;
|
|
751
|
+
/** Optional group for profile-based tool selection */
|
|
752
|
+
group?: string;
|
|
753
|
+
/** Deferred tools are discoverable but omitted from the default prompt */
|
|
754
|
+
deferLoading?: boolean;
|
|
755
|
+
/** Profile memberships for selective tool loading */
|
|
756
|
+
profiles?: string[];
|
|
757
|
+
/** Extra keywords for dynamic tool selection */
|
|
758
|
+
searchKeywords?: string[];
|
|
759
|
+
/** Per-tool prompt/result shaping controls */
|
|
760
|
+
resultConfig?: ToolResultConfig;
|
|
601
761
|
/** Human-readable title for UI display */
|
|
602
762
|
title?: string | ((args: TParams) => string);
|
|
603
763
|
/** Title shown while executing */
|
|
@@ -666,4 +826,4 @@ declare function success<T = unknown>(data?: T, message?: string): ToolResponse<
|
|
|
666
826
|
*/
|
|
667
827
|
declare function failure(error: string): ToolResponse;
|
|
668
828
|
|
|
669
|
-
export { type AIProvider as A, type JSONSchemaProperty as J, type PermissionLevel as P, type ToolDefinition as T, type UnifiedToolCall as U, type ToolExecutionStatus as a, type ToolResponse as b, type ToolInputSchema as c, type ToolLocation as d, type ToolContext as e, type ToolSource as f, type ToolRenderProps as g, type ToolConfig as h, type
|
|
829
|
+
export { type AIProvider as A, type AgentLoopState as B, type ContextHistoryConfig as C, type AIResponseMode as D, type AIContent as E, type ToolPermission as F, type PermissionStorageConfig as G, type PermissionStorageAdapter as H, tool as I, type JSONSchemaProperty as J, toolToOpenAIFormat as K, toolToAnthropicFormat as L, createToolResult as M, success as N, failure as O, type PermissionLevel as P, type ToolDefinition as T, type UnifiedToolCall as U, type ToolExecutionStatus as a, type ToolResponse as b, type ToolInputSchema as c, type ToolLocation as d, type ToolContext as e, type ToolSource as f, type ToolRenderProps as g, type ToolConfig as h, type ToolResultConfig as i, type ToolResultTruncationConfig as j, type ToolTruncationStrategy as k, type ToolProfile as l, type ToolProfileConfig as m, type ContextSummarizationConfig as n, type TokenEstimationConfig as o, type ContextManagementConfig as p, type ContextUsagePart as q, type ContextUsage as r, type ContextBudgetConfig as s, type ToolOptimizationConfig as t, type ToolSet as u, type ToolSetEntry as v, type UnifiedToolResult as w, type ToolApprovalStatus as x, type ToolExecution as y, type AgentLoopConfig as z };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills System — Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Skills are instruction playbooks the AI loads on demand.
|
|
5
|
+
* Separate from Tools (execution layer) — skills shape behavior, tools do work.
|
|
6
|
+
*/
|
|
7
|
+
type SkillStrategy = "eager" | "auto" | "manual";
|
|
8
|
+
type SkillSource = {
|
|
9
|
+
type: "inline";
|
|
10
|
+
content: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "url";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "file";
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
interface SkillDefinition {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
source: SkillSource;
|
|
22
|
+
/** @default "auto" */
|
|
23
|
+
strategy?: SkillStrategy;
|
|
24
|
+
version?: string;
|
|
25
|
+
}
|
|
26
|
+
interface ResolvedSkill extends SkillDefinition {
|
|
27
|
+
/** Fully resolved content string */
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
type SkillDiagnosticWinner = "server-dir" | "remote-url" | "client-inline";
|
|
31
|
+
interface SkillDiagnostic {
|
|
32
|
+
type: "collision";
|
|
33
|
+
name: string;
|
|
34
|
+
winner: SkillDiagnosticWinner;
|
|
35
|
+
loser: SkillDiagnosticWinner;
|
|
36
|
+
}
|
|
37
|
+
interface ClientInlineSkill {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
content: string;
|
|
41
|
+
strategy?: SkillStrategy;
|
|
42
|
+
}
|
|
43
|
+
interface LoadSkillsOptions {
|
|
44
|
+
/** Path to /skills directory (server-only) */
|
|
45
|
+
dir?: string;
|
|
46
|
+
/** Remote .md URLs to fetch */
|
|
47
|
+
remoteUrls?: string[];
|
|
48
|
+
/** Inline skills from useSkill() hooks */
|
|
49
|
+
clientSkills?: ClientInlineSkill[];
|
|
50
|
+
}
|
|
51
|
+
interface LoadSkillsResult {
|
|
52
|
+
skills: ResolvedSkill[];
|
|
53
|
+
diagnostics: SkillDiagnostic[];
|
|
54
|
+
/**
|
|
55
|
+
* Build a complete system prompt incorporating eager + auto skill catalog.
|
|
56
|
+
* Prepends eager skill content, appends auto catalog.
|
|
57
|
+
*/
|
|
58
|
+
buildSystemPrompt(basePrompt?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* The load_skill tool definition ready to register with your AI framework.
|
|
61
|
+
* Returns structured result: { name, description, strategy, content, source }
|
|
62
|
+
*/
|
|
63
|
+
tools: {
|
|
64
|
+
load_skill: {
|
|
65
|
+
description: string;
|
|
66
|
+
parameters: {
|
|
67
|
+
type: "object";
|
|
68
|
+
properties: {
|
|
69
|
+
name: {
|
|
70
|
+
type: "string";
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
required: ["name"];
|
|
75
|
+
};
|
|
76
|
+
execute: (args: {
|
|
77
|
+
name: string;
|
|
78
|
+
}) => Promise<LoadSkillResult | LoadSkillError>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
interface LoadSkillResult {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
strategy: SkillStrategy;
|
|
86
|
+
content: string;
|
|
87
|
+
source: "server-dir" | "remote-url" | "client-inline";
|
|
88
|
+
}
|
|
89
|
+
interface LoadSkillError {
|
|
90
|
+
error: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type { ClientInlineSkill as C, LoadSkillsOptions as L, ResolvedSkill as R, SkillDefinition as S, LoadSkillsResult as a, SkillSource as b, SkillStrategy as c, SkillDiagnostic as d, SkillDiagnosticWinner as e, LoadSkillResult as f, LoadSkillError as g };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills System — Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Skills are instruction playbooks the AI loads on demand.
|
|
5
|
+
* Separate from Tools (execution layer) — skills shape behavior, tools do work.
|
|
6
|
+
*/
|
|
7
|
+
type SkillStrategy = "eager" | "auto" | "manual";
|
|
8
|
+
type SkillSource = {
|
|
9
|
+
type: "inline";
|
|
10
|
+
content: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "url";
|
|
13
|
+
url: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "file";
|
|
16
|
+
path: string;
|
|
17
|
+
};
|
|
18
|
+
interface SkillDefinition {
|
|
19
|
+
name: string;
|
|
20
|
+
description: string;
|
|
21
|
+
source: SkillSource;
|
|
22
|
+
/** @default "auto" */
|
|
23
|
+
strategy?: SkillStrategy;
|
|
24
|
+
version?: string;
|
|
25
|
+
}
|
|
26
|
+
interface ResolvedSkill extends SkillDefinition {
|
|
27
|
+
/** Fully resolved content string */
|
|
28
|
+
content: string;
|
|
29
|
+
}
|
|
30
|
+
type SkillDiagnosticWinner = "server-dir" | "remote-url" | "client-inline";
|
|
31
|
+
interface SkillDiagnostic {
|
|
32
|
+
type: "collision";
|
|
33
|
+
name: string;
|
|
34
|
+
winner: SkillDiagnosticWinner;
|
|
35
|
+
loser: SkillDiagnosticWinner;
|
|
36
|
+
}
|
|
37
|
+
interface ClientInlineSkill {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
content: string;
|
|
41
|
+
strategy?: SkillStrategy;
|
|
42
|
+
}
|
|
43
|
+
interface LoadSkillsOptions {
|
|
44
|
+
/** Path to /skills directory (server-only) */
|
|
45
|
+
dir?: string;
|
|
46
|
+
/** Remote .md URLs to fetch */
|
|
47
|
+
remoteUrls?: string[];
|
|
48
|
+
/** Inline skills from useSkill() hooks */
|
|
49
|
+
clientSkills?: ClientInlineSkill[];
|
|
50
|
+
}
|
|
51
|
+
interface LoadSkillsResult {
|
|
52
|
+
skills: ResolvedSkill[];
|
|
53
|
+
diagnostics: SkillDiagnostic[];
|
|
54
|
+
/**
|
|
55
|
+
* Build a complete system prompt incorporating eager + auto skill catalog.
|
|
56
|
+
* Prepends eager skill content, appends auto catalog.
|
|
57
|
+
*/
|
|
58
|
+
buildSystemPrompt(basePrompt?: string): string;
|
|
59
|
+
/**
|
|
60
|
+
* The load_skill tool definition ready to register with your AI framework.
|
|
61
|
+
* Returns structured result: { name, description, strategy, content, source }
|
|
62
|
+
*/
|
|
63
|
+
tools: {
|
|
64
|
+
load_skill: {
|
|
65
|
+
description: string;
|
|
66
|
+
parameters: {
|
|
67
|
+
type: "object";
|
|
68
|
+
properties: {
|
|
69
|
+
name: {
|
|
70
|
+
type: "string";
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
required: ["name"];
|
|
75
|
+
};
|
|
76
|
+
execute: (args: {
|
|
77
|
+
name: string;
|
|
78
|
+
}) => Promise<LoadSkillResult | LoadSkillError>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
interface LoadSkillResult {
|
|
83
|
+
name: string;
|
|
84
|
+
description: string;
|
|
85
|
+
strategy: SkillStrategy;
|
|
86
|
+
content: string;
|
|
87
|
+
source: "server-dir" | "remote-url" | "client-inline";
|
|
88
|
+
}
|
|
89
|
+
interface LoadSkillError {
|
|
90
|
+
error: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type { ClientInlineSkill as C, LoadSkillsOptions as L, ResolvedSkill as R, SkillDefinition as S, LoadSkillsResult as a, SkillSource as b, SkillStrategy as c, SkillDiagnostic as d, SkillDiagnosticWinner as e, LoadSkillResult as f, LoadSkillError as g };
|
|
@@ -1,3 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copilot SDK Logger
|
|
3
|
+
*
|
|
4
|
+
* Simple debug logger with console grouping support.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* debug={true} → enable all logs
|
|
8
|
+
* debug={false} → silent (default)
|
|
9
|
+
*
|
|
10
|
+
* Runtime toggle from browser console (no rebuild needed):
|
|
11
|
+
* window.__COPILOT_DEBUG = true
|
|
12
|
+
* window.__COPILOT_DEBUG = false
|
|
13
|
+
*/
|
|
14
|
+
/** Well-known log scopes — used internally as labels, not exposed to the user. */
|
|
15
|
+
type LogScope = "streaming" | "tools" | "provider" | string;
|
|
16
|
+
/** Debug config accepted by CopilotProvider. true = on, false = off. */
|
|
17
|
+
type DebugConfig = boolean;
|
|
18
|
+
declare global {
|
|
19
|
+
interface Window {
|
|
20
|
+
__COPILOT_DEBUG?: boolean;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
interface ScopedLogger {
|
|
24
|
+
/** Log a message with optional data */
|
|
25
|
+
(action: string, data?: unknown): void;
|
|
26
|
+
/** Open a collapsible group — all subsequent logs nest inside until groupEnd() */
|
|
27
|
+
group(label: string): void;
|
|
28
|
+
/** Open a collapsed group (hidden by default in DevTools) */
|
|
29
|
+
groupCollapsed(label: string): void;
|
|
30
|
+
/** Close the most recently opened group */
|
|
31
|
+
groupEnd(): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a scoped logger bound to a specific namespace.
|
|
35
|
+
*
|
|
36
|
+
* @param scope - Label shown in brackets, e.g. "streaming", "tools"
|
|
37
|
+
* @param getEnabled - Returns whether debug logging is currently on
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* const log = createLogger("streaming", () => this.config.debug ?? false);
|
|
41
|
+
* log("sendMessage", { content });
|
|
42
|
+
* // → [streaming] sendMessage { content: '...' }
|
|
43
|
+
*
|
|
44
|
+
* log.groupCollapsed("Stream #1");
|
|
45
|
+
* log("chunk", { type: "message:start" }); // nested inside group
|
|
46
|
+
* log.groupEnd();
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* One-shot log — for cases where you don't keep a persistent logger.
|
|
50
|
+
*/
|
|
51
|
+
declare function logOnce(scope: LogScope, enabled: boolean, action: string, data?: unknown): void;
|
|
52
|
+
declare function createLogger(scope: LogScope, getEnabled: () => boolean): ScopedLogger;
|
|
53
|
+
|
|
1
54
|
/**
|
|
2
55
|
* Message roles in a conversation (OpenAI format)
|
|
3
56
|
*/
|
|
@@ -131,6 +184,15 @@ interface Message {
|
|
|
131
184
|
metadata?: MessageMetadata;
|
|
132
185
|
/** When the message was created */
|
|
133
186
|
created_at: Date;
|
|
187
|
+
/**
|
|
188
|
+
* Parent message ID for branching support.
|
|
189
|
+
* - null = root message (no parent)
|
|
190
|
+
* - undefined = legacy linear message (no branch awareness)
|
|
191
|
+
* - string = ID of parent message
|
|
192
|
+
*/
|
|
193
|
+
parent_id?: string | null;
|
|
194
|
+
/** Direct children IDs for O(1) sibling lookup */
|
|
195
|
+
children_ids?: string[];
|
|
134
196
|
}
|
|
135
197
|
/**
|
|
136
198
|
* Helper to parse tool call arguments
|
|
@@ -153,6 +215,7 @@ declare function createUserMessage(content: string, options?: {
|
|
|
153
215
|
id?: string;
|
|
154
216
|
thread_id?: string;
|
|
155
217
|
attachments?: MessageAttachment[];
|
|
218
|
+
parent_id?: string | null;
|
|
156
219
|
}): Message;
|
|
157
220
|
/**
|
|
158
221
|
* Create an assistant message
|
|
@@ -364,4 +427,4 @@ interface AsyncThreadStorageAdapter extends ThreadStorageAdapter {
|
|
|
364
427
|
listThreads?: (options?: ListThreadsOptions) => Promise<ListThreadsResult>;
|
|
365
428
|
}
|
|
366
429
|
|
|
367
|
-
export { type AsyncThreadStorageAdapter as A, type ListThreadsOptions as L, type
|
|
430
|
+
export { type AsyncThreadStorageAdapter as A, type DebugConfig as D, type ListThreadsOptions as L, type MessageAttachment as M, type PersistenceConfig as P, type Source as S, type ToolCall as T, type Thread as a, type ThreadData as b, type ThreadStorageAdapter as c, type Message as d, createLogger as e, type ScopedLogger as f, type MessageRole as g, type MessageMetadata as h, type TokenUsage as i, type ThreadStorageAdapter$1 as j, generateThreadTitle as k, logOnce as l, createMessage as m, createUserMessage as n, createAssistantMessage as o, createToolMessage as p, createToolCall as q, parseToolCallArgs as r, hasToolCalls as s, isToolResult as t, type ListThreadsResult as u };
|