@yourgpt/copilot-sdk 0.1.0 → 0.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.
- package/README.md +25 -23
- package/dist/{chunk-QUGTRQSS.js → chunk-FO75W5UI.js} +30 -23
- package/dist/chunk-FO75W5UI.js.map +1 -0
- package/dist/{chunk-2ZCWVAAK.cjs → chunk-IH7WXWX4.cjs} +2 -2
- package/dist/{chunk-2ZCWVAAK.cjs.map → chunk-IH7WXWX4.cjs.map} +1 -1
- package/dist/{chunk-N4OA2J32.js → chunk-QWQELTEB.js} +2 -2
- package/dist/{chunk-N4OA2J32.js.map → chunk-QWQELTEB.js.map} +1 -1
- package/dist/{chunk-W6KQT7YZ.cjs → chunk-R452HH3J.cjs} +53 -46
- package/dist/chunk-R452HH3J.cjs.map +1 -0
- package/dist/core/index.cjs +71 -71
- package/dist/core/index.d.cts +13 -4
- package/dist/core/index.d.ts +13 -4
- package/dist/core/index.js +1 -1
- package/dist/react/index.cjs +34 -34
- package/dist/react/index.d.cts +28 -6
- package/dist/react/index.d.ts +28 -6
- package/dist/react/index.js +2 -2
- package/dist/{thread-C2FjuGLb.d.cts → thread-CLmfwine.d.cts} +1 -516
- package/dist/{thread-C2FjuGLb.d.ts → thread-CLmfwine.d.ts} +1 -516
- package/dist/tools-eeJ5iEC4.d.cts +595 -0
- package/dist/tools-eeJ5iEC4.d.ts +595 -0
- package/dist/ui/index.cjs +136 -46
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +68 -6
- package/dist/ui/index.d.ts +68 -6
- package/dist/ui/index.js +135 -45
- package/dist/ui/index.js.map +1 -1
- package/package.json +9 -8
- package/dist/chunk-QUGTRQSS.js.map +0 -1
- package/dist/chunk-W6KQT7YZ.cjs.map +0 -1
|
@@ -207,521 +207,6 @@ interface CustomKeywords {
|
|
|
207
207
|
*/
|
|
208
208
|
declare function createCustomDetector(customKeywords: CustomKeywords): (message: string) => IntentDetectionResult;
|
|
209
209
|
|
|
210
|
-
/**
|
|
211
|
-
* Tool-related types for the agentic loop
|
|
212
|
-
*/
|
|
213
|
-
/**
|
|
214
|
-
* Supported AI providers for tool calling
|
|
215
|
-
*/
|
|
216
|
-
type AIProvider = "anthropic" | "openai" | "xai" | "grok" | "gemini" | "groq" | "ollama";
|
|
217
|
-
/**
|
|
218
|
-
* Where the tool executes
|
|
219
|
-
*/
|
|
220
|
-
type ToolLocation = "server" | "client";
|
|
221
|
-
/**
|
|
222
|
-
* JSON Schema property definition
|
|
223
|
-
*/
|
|
224
|
-
interface JSONSchemaProperty {
|
|
225
|
-
type: "string" | "number" | "boolean" | "object" | "array" | "integer" | "null";
|
|
226
|
-
description?: string;
|
|
227
|
-
enum?: (string | number | boolean)[];
|
|
228
|
-
items?: JSONSchemaProperty;
|
|
229
|
-
properties?: Record<string, JSONSchemaProperty>;
|
|
230
|
-
required?: string[];
|
|
231
|
-
default?: unknown;
|
|
232
|
-
minLength?: number;
|
|
233
|
-
maxLength?: number;
|
|
234
|
-
minimum?: number;
|
|
235
|
-
maximum?: number;
|
|
236
|
-
pattern?: string;
|
|
237
|
-
}
|
|
238
|
-
/**
|
|
239
|
-
* JSON Schema for tool input
|
|
240
|
-
*/
|
|
241
|
-
interface ToolInputSchema {
|
|
242
|
-
type: "object";
|
|
243
|
-
properties: Record<string, JSONSchemaProperty>;
|
|
244
|
-
required?: string[];
|
|
245
|
-
additionalProperties?: boolean;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Tool execution context
|
|
249
|
-
*
|
|
250
|
-
* Provides runtime information to tool handlers including cancellation signals,
|
|
251
|
-
* request metadata, and custom context data.
|
|
252
|
-
*/
|
|
253
|
-
interface ToolContext {
|
|
254
|
-
/** Abort signal for cancellation */
|
|
255
|
-
signal?: AbortSignal;
|
|
256
|
-
/** Thread ID if using threads */
|
|
257
|
-
threadId?: string;
|
|
258
|
-
/** Custom context data passed from runtime config */
|
|
259
|
-
data?: Record<string, unknown>;
|
|
260
|
-
/**
|
|
261
|
-
* Unique ID for this specific tool call.
|
|
262
|
-
* Useful for logging, tracing, and correlating tool executions.
|
|
263
|
-
*/
|
|
264
|
-
toolCallId?: string;
|
|
265
|
-
/**
|
|
266
|
-
* Request headers (for auth in server tools).
|
|
267
|
-
* Contains headers from the original HTTP request.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```typescript
|
|
271
|
-
* handler: async (params, context) => {
|
|
272
|
-
* const token = context?.headers?.authorization;
|
|
273
|
-
* if (!token) return failure('Authentication required');
|
|
274
|
-
* // ...
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
*/
|
|
278
|
-
headers?: Record<string, string>;
|
|
279
|
-
/**
|
|
280
|
-
* Full request metadata for server-side tools.
|
|
281
|
-
* Provides access to HTTP method, URL, and headers.
|
|
282
|
-
*
|
|
283
|
-
* @example
|
|
284
|
-
* ```typescript
|
|
285
|
-
* handler: async (params, context) => {
|
|
286
|
-
* console.log(`Tool called from: ${context?.request?.url}`);
|
|
287
|
-
* // Forward auth to internal service
|
|
288
|
-
* const authHeader = context?.request?.headers?.authorization;
|
|
289
|
-
* }
|
|
290
|
-
* ```
|
|
291
|
-
*/
|
|
292
|
-
request?: {
|
|
293
|
-
/** HTTP method (GET, POST, etc.) */
|
|
294
|
-
method?: string;
|
|
295
|
-
/** Request URL path */
|
|
296
|
-
url?: string;
|
|
297
|
-
/** Request headers */
|
|
298
|
-
headers?: Record<string, string>;
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
/**
|
|
302
|
-
* AI response behavior for tool results.
|
|
303
|
-
*
|
|
304
|
-
* Controls what the AI sees after a tool executes and renders UI.
|
|
305
|
-
*
|
|
306
|
-
* - `'none'`: AI generates minimal response, UI component handles display
|
|
307
|
-
* - `'brief'`: AI gets summary context (via aiContext), gives brief acknowledgment
|
|
308
|
-
* - `'full'`: AI receives full data and responds accordingly (default)
|
|
309
|
-
*/
|
|
310
|
-
type AIResponseMode = "none" | "brief" | "full";
|
|
311
|
-
/**
|
|
312
|
-
* Multimodal content for AI to analyze
|
|
313
|
-
*/
|
|
314
|
-
type AIContent = {
|
|
315
|
-
type: "image";
|
|
316
|
-
data: string;
|
|
317
|
-
mediaType: string;
|
|
318
|
-
} | {
|
|
319
|
-
type: "text";
|
|
320
|
-
text: string;
|
|
321
|
-
};
|
|
322
|
-
/**
|
|
323
|
-
* Tool response format
|
|
324
|
-
*/
|
|
325
|
-
interface ToolResponse<T = unknown> {
|
|
326
|
-
/** Whether the tool succeeded */
|
|
327
|
-
success: boolean;
|
|
328
|
-
/** Human-readable message */
|
|
329
|
-
message?: string;
|
|
330
|
-
/** Error message if failed */
|
|
331
|
-
error?: string;
|
|
332
|
-
/** Result data */
|
|
333
|
-
data?: T;
|
|
334
|
-
/**
|
|
335
|
-
* Override AI context for this specific result.
|
|
336
|
-
* Takes precedence over tool-level aiContext config.
|
|
337
|
-
* If set, this message is sent to AI instead of full result data.
|
|
338
|
-
*
|
|
339
|
-
* @example
|
|
340
|
-
* ```typescript
|
|
341
|
-
* return {
|
|
342
|
-
* success: true,
|
|
343
|
-
* data: sensitiveData,
|
|
344
|
-
* _aiContext: '[Data retrieved - contains sensitive info, displayed to user]'
|
|
345
|
-
* };
|
|
346
|
-
* ```
|
|
347
|
-
*/
|
|
348
|
-
_aiContext?: string;
|
|
349
|
-
/**
|
|
350
|
-
* Override AI response mode for this specific result.
|
|
351
|
-
* Takes precedence over tool-level aiResponseMode config.
|
|
352
|
-
*/
|
|
353
|
-
_aiResponseMode?: AIResponseMode;
|
|
354
|
-
/**
|
|
355
|
-
* Content for AI to analyze (images, documents, etc.).
|
|
356
|
-
* When present, these are included as multimodal content for AI analysis.
|
|
357
|
-
*
|
|
358
|
-
* @example
|
|
359
|
-
* ```typescript
|
|
360
|
-
* // Screenshot for AI to analyze
|
|
361
|
-
* return {
|
|
362
|
-
* success: true,
|
|
363
|
-
* message: 'Screenshot captured',
|
|
364
|
-
* _aiContent: [{ type: 'image', data: base64, mediaType: 'image/png' }]
|
|
365
|
-
* };
|
|
366
|
-
* ```
|
|
367
|
-
*/
|
|
368
|
-
_aiContent?: AIContent[];
|
|
369
|
-
}
|
|
370
|
-
/**
|
|
371
|
-
* Props passed to tool render function
|
|
372
|
-
*/
|
|
373
|
-
interface ToolRenderProps<TParams = Record<string, unknown>> {
|
|
374
|
-
/** Current execution status */
|
|
375
|
-
status: "pending" | "executing" | "completed" | "error";
|
|
376
|
-
/** Arguments passed to the tool */
|
|
377
|
-
args: TParams;
|
|
378
|
-
/** Result if completed */
|
|
379
|
-
result?: ToolResponse;
|
|
380
|
-
/** Error if failed */
|
|
381
|
-
error?: string;
|
|
382
|
-
}
|
|
383
|
-
/**
|
|
384
|
-
* Tool definition with JSON Schema
|
|
385
|
-
*/
|
|
386
|
-
interface ToolDefinition<TParams = Record<string, unknown>> {
|
|
387
|
-
/** Unique tool name */
|
|
388
|
-
name: string;
|
|
389
|
-
/** Tool description for LLM */
|
|
390
|
-
description: string;
|
|
391
|
-
/** Where the tool executes (server or client) */
|
|
392
|
-
location: ToolLocation;
|
|
393
|
-
/**
|
|
394
|
-
* Human-readable title for UI display.
|
|
395
|
-
* Can be a static string or a function that generates title from args.
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* ```typescript
|
|
399
|
-
* title: "Get order details"
|
|
400
|
-
* // or dynamic:
|
|
401
|
-
* title: (args) => `Order #${args.orderId}`
|
|
402
|
-
* ```
|
|
403
|
-
*/
|
|
404
|
-
title?: string | ((args: TParams) => string);
|
|
405
|
-
/**
|
|
406
|
-
* Title shown while executing (present tense with "...").
|
|
407
|
-
* If not provided, uses `title` with "..." appended.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* ```typescript
|
|
411
|
-
* executingTitle: (args) => `Fetching order #${args.orderId}...`
|
|
412
|
-
* ```
|
|
413
|
-
*/
|
|
414
|
-
executingTitle?: string | ((args: TParams) => string);
|
|
415
|
-
/**
|
|
416
|
-
* Title shown after completion.
|
|
417
|
-
* If not provided, defaults to `title`.
|
|
418
|
-
*
|
|
419
|
-
* @example
|
|
420
|
-
* ```typescript
|
|
421
|
-
* completedTitle: (args) => `Retrieved order #${args.orderId}`
|
|
422
|
-
* ```
|
|
423
|
-
*/
|
|
424
|
-
completedTitle?: string | ((args: TParams) => string);
|
|
425
|
-
/** JSON Schema for input parameters */
|
|
426
|
-
inputSchema: ToolInputSchema;
|
|
427
|
-
/** Handler function (optional for client tools registered on server) */
|
|
428
|
-
handler?: (params: TParams, context?: ToolContext) => Promise<ToolResponse> | ToolResponse;
|
|
429
|
-
/** Optional render function for UI */
|
|
430
|
-
render?: (props: ToolRenderProps<TParams>) => unknown;
|
|
431
|
-
/** Whether the tool is available (for conditional registration) */
|
|
432
|
-
available?: boolean;
|
|
433
|
-
/**
|
|
434
|
-
* Require user approval before execution.
|
|
435
|
-
* Can be:
|
|
436
|
-
* - `true`: Always require approval
|
|
437
|
-
* - `false` or `undefined`: No approval needed (default)
|
|
438
|
-
* - `(params) => boolean`: Conditional approval based on input
|
|
439
|
-
*
|
|
440
|
-
* Similar to Vercel AI SDK v6's needsApproval pattern.
|
|
441
|
-
*/
|
|
442
|
-
needsApproval?: boolean | ((params: TParams) => boolean | Promise<boolean>);
|
|
443
|
-
/**
|
|
444
|
-
* Custom message shown in the approval UI.
|
|
445
|
-
* Can be a string or a function that generates a message from params.
|
|
446
|
-
* If not provided, a default message with the tool name is shown.
|
|
447
|
-
*/
|
|
448
|
-
approvalMessage?: string | ((params: TParams) => string);
|
|
449
|
-
/**
|
|
450
|
-
* How the AI should respond when this tool's result is rendered as UI.
|
|
451
|
-
*
|
|
452
|
-
* - `'none'`: AI generates minimal response ("[Result displayed to user]").
|
|
453
|
-
* Use for tools where UI component fully handles the display (stats cards, etc.)
|
|
454
|
-
*
|
|
455
|
-
* - `'brief'`: AI receives summary context (from aiContext) and gives brief acknowledgment.
|
|
456
|
-
* Use for charts/visualizations where AI should acknowledge but not repeat data.
|
|
457
|
-
*
|
|
458
|
-
* - `'full'`: AI receives complete data and responds accordingly (default).
|
|
459
|
-
* Use for tools where AI should analyze and elaborate on results.
|
|
460
|
-
*
|
|
461
|
-
* @default 'full'
|
|
462
|
-
*
|
|
463
|
-
* @example
|
|
464
|
-
* ```typescript
|
|
465
|
-
* // Chart tool - AI acknowledges without repeating data
|
|
466
|
-
* const chartTool: ToolDefinition = {
|
|
467
|
-
* name: 'get_chart',
|
|
468
|
-
* aiResponseMode: 'brief',
|
|
469
|
-
* aiContext: (result) => `[Chart displayed: ${result.data.title}]`,
|
|
470
|
-
* handler: async () => ({ success: true, data: chartData })
|
|
471
|
-
* };
|
|
472
|
-
* ```
|
|
473
|
-
*/
|
|
474
|
-
aiResponseMode?: AIResponseMode;
|
|
475
|
-
/**
|
|
476
|
-
* Context/summary sent to AI instead of (or along with) full result.
|
|
477
|
-
*
|
|
478
|
-
* Used when:
|
|
479
|
-
* - `aiResponseMode: 'brief'` - This becomes the only thing AI sees
|
|
480
|
-
* - `aiResponseMode: 'full'` - This is prepended to full data for context
|
|
481
|
-
*
|
|
482
|
-
* Can be:
|
|
483
|
-
* - `string`: Static message (e.g., "[Weather data displayed]")
|
|
484
|
-
* - `function`: Dynamic based on result (e.g., (result) => `[Chart: ${result.data.title}]`)
|
|
485
|
-
*
|
|
486
|
-
* @example
|
|
487
|
-
* ```typescript
|
|
488
|
-
* // Static context
|
|
489
|
-
* aiContext: '[Analytics chart displayed to user]'
|
|
490
|
-
*
|
|
491
|
-
* // Dynamic context based on result
|
|
492
|
-
* aiContext: (result, args) => {
|
|
493
|
-
* const { title, currentValue } = result.data;
|
|
494
|
-
* return `[Chart displayed: ${title}, showing ${currentValue}]`;
|
|
495
|
-
* }
|
|
496
|
-
* ```
|
|
497
|
-
*/
|
|
498
|
-
aiContext?: string | ((result: ToolResponse, args: Record<string, unknown>) => string);
|
|
499
|
-
}
|
|
500
|
-
/**
|
|
501
|
-
* Unified tool call format (internal representation)
|
|
502
|
-
*/
|
|
503
|
-
interface UnifiedToolCall {
|
|
504
|
-
/** Unique tool call ID */
|
|
505
|
-
id: string;
|
|
506
|
-
/** Tool name */
|
|
507
|
-
name: string;
|
|
508
|
-
/** Tool input arguments */
|
|
509
|
-
input: Record<string, unknown>;
|
|
510
|
-
}
|
|
511
|
-
/**
|
|
512
|
-
* Unified tool result format
|
|
513
|
-
*/
|
|
514
|
-
interface UnifiedToolResult {
|
|
515
|
-
/** Tool call ID this result is for */
|
|
516
|
-
toolCallId: string;
|
|
517
|
-
/** Serialized result content (JSON string) */
|
|
518
|
-
content: string;
|
|
519
|
-
/** Whether the tool succeeded */
|
|
520
|
-
success: boolean;
|
|
521
|
-
/** Error message if failed */
|
|
522
|
-
error?: string;
|
|
523
|
-
}
|
|
524
|
-
/**
|
|
525
|
-
* Tool execution status
|
|
526
|
-
*/
|
|
527
|
-
type ToolExecutionStatus = "pending" | "executing" | "completed" | "error";
|
|
528
|
-
/**
|
|
529
|
-
* Tool approval status (for human-in-the-loop)
|
|
530
|
-
*
|
|
531
|
-
* Similar to Vercel AI SDK v6's tool approval pattern.
|
|
532
|
-
*/
|
|
533
|
-
type ToolApprovalStatus = "none" | "required" | "approved" | "rejected";
|
|
534
|
-
/**
|
|
535
|
-
* Permission level for tool execution
|
|
536
|
-
*
|
|
537
|
-
* Controls whether approval is needed and how the choice is remembered:
|
|
538
|
-
* - "ask" - Always prompt user (default)
|
|
539
|
-
* - "allow_always" - Auto-approve, persisted to storage
|
|
540
|
-
* - "deny_always" - Auto-reject, persisted to storage
|
|
541
|
-
* - "session" - Auto-approve for current session only
|
|
542
|
-
*/
|
|
543
|
-
type PermissionLevel = "ask" | "allow_always" | "deny_always" | "session";
|
|
544
|
-
/**
|
|
545
|
-
* Stored tool permission record
|
|
546
|
-
*/
|
|
547
|
-
interface ToolPermission {
|
|
548
|
-
/** Tool name (unique identifier) */
|
|
549
|
-
toolName: string;
|
|
550
|
-
/** Permission level */
|
|
551
|
-
level: PermissionLevel;
|
|
552
|
-
/** When permission was set */
|
|
553
|
-
createdAt: number;
|
|
554
|
-
/** Last time this permission was used */
|
|
555
|
-
lastUsedAt?: number;
|
|
556
|
-
}
|
|
557
|
-
/**
|
|
558
|
-
* Permission storage configuration
|
|
559
|
-
*/
|
|
560
|
-
interface PermissionStorageConfig {
|
|
561
|
-
/**
|
|
562
|
-
* Storage type:
|
|
563
|
-
* - "localStorage" - Persists across browser sessions
|
|
564
|
-
* - "sessionStorage" - Clears when tab closes
|
|
565
|
-
* - "memory" - In-memory only (for SSR or testing)
|
|
566
|
-
*/
|
|
567
|
-
type: "localStorage" | "sessionStorage" | "memory";
|
|
568
|
-
/** Storage key prefix (default: "yourgpt-permissions") */
|
|
569
|
-
keyPrefix?: string;
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Permission storage adapter interface (for custom implementations)
|
|
573
|
-
*/
|
|
574
|
-
interface PermissionStorageAdapter {
|
|
575
|
-
/** Get permission for a tool */
|
|
576
|
-
get(toolName: string): Promise<ToolPermission | null>;
|
|
577
|
-
/** Set permission for a tool */
|
|
578
|
-
set(permission: ToolPermission): Promise<void>;
|
|
579
|
-
/** Remove permission for a tool */
|
|
580
|
-
remove(toolName: string): Promise<void>;
|
|
581
|
-
/** Get all permissions */
|
|
582
|
-
getAll(): Promise<ToolPermission[]>;
|
|
583
|
-
/** Clear all permissions */
|
|
584
|
-
clear(): Promise<void>;
|
|
585
|
-
}
|
|
586
|
-
/**
|
|
587
|
-
* Tool execution record (for UI tracking)
|
|
588
|
-
*/
|
|
589
|
-
interface ToolExecution {
|
|
590
|
-
/** Tool call ID */
|
|
591
|
-
id: string;
|
|
592
|
-
/** Tool name */
|
|
593
|
-
name: string;
|
|
594
|
-
/** Tool arguments */
|
|
595
|
-
args: Record<string, unknown>;
|
|
596
|
-
/** Execution status */
|
|
597
|
-
status: ToolExecutionStatus;
|
|
598
|
-
/** Result if completed */
|
|
599
|
-
result?: ToolResponse;
|
|
600
|
-
/** Error message if failed */
|
|
601
|
-
error?: string;
|
|
602
|
-
/** Timestamp when execution started */
|
|
603
|
-
timestamp: number;
|
|
604
|
-
/** Duration in ms (set when completed) */
|
|
605
|
-
duration?: number;
|
|
606
|
-
/** Approval status for this execution */
|
|
607
|
-
approvalStatus: ToolApprovalStatus;
|
|
608
|
-
/** Message shown in approval UI (from tool's approvalMessage) */
|
|
609
|
-
approvalMessage?: string;
|
|
610
|
-
/** Timestamp when user responded to approval request */
|
|
611
|
-
approvalTimestamp?: number;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Agentic loop configuration
|
|
615
|
-
*/
|
|
616
|
-
interface AgentLoopConfig {
|
|
617
|
-
/** Maximum iterations before stopping (default: 20) */
|
|
618
|
-
maxIterations?: number;
|
|
619
|
-
/** Enable debug logging */
|
|
620
|
-
debug?: boolean;
|
|
621
|
-
/** Whether to enable the agentic loop (default: true) */
|
|
622
|
-
enabled?: boolean;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Agent loop state (for tracking)
|
|
626
|
-
*/
|
|
627
|
-
interface AgentLoopState {
|
|
628
|
-
/** Current iteration number */
|
|
629
|
-
iteration: number;
|
|
630
|
-
/** Maximum iterations allowed */
|
|
631
|
-
maxIterations: number;
|
|
632
|
-
/** Whether the loop is currently running */
|
|
633
|
-
running: boolean;
|
|
634
|
-
/** Whether max iterations was reached */
|
|
635
|
-
maxIterationsReached: boolean;
|
|
636
|
-
/** Whether the loop was aborted */
|
|
637
|
-
aborted: boolean;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* A set of tools, keyed by tool name
|
|
641
|
-
*
|
|
642
|
-
* @example
|
|
643
|
-
* ```typescript
|
|
644
|
-
* const myTools: ToolSet = {
|
|
645
|
-
* capture_screenshot: screenshotTool,
|
|
646
|
-
* get_weather: weatherTool,
|
|
647
|
-
* };
|
|
648
|
-
* ```
|
|
649
|
-
*/
|
|
650
|
-
type ToolSet = Record<string, ToolDefinition>;
|
|
651
|
-
/**
|
|
652
|
-
* Configuration for creating a tool
|
|
653
|
-
*/
|
|
654
|
-
interface ToolConfig<TParams = Record<string, unknown>> {
|
|
655
|
-
/** Tool description for LLM */
|
|
656
|
-
description: string;
|
|
657
|
-
/** Where the tool executes (default: 'client') */
|
|
658
|
-
location?: ToolLocation;
|
|
659
|
-
/** Human-readable title for UI display */
|
|
660
|
-
title?: string | ((args: TParams) => string);
|
|
661
|
-
/** Title shown while executing */
|
|
662
|
-
executingTitle?: string | ((args: TParams) => string);
|
|
663
|
-
/** Title shown after completion */
|
|
664
|
-
completedTitle?: string | ((args: TParams) => string);
|
|
665
|
-
/** JSON Schema for input parameters */
|
|
666
|
-
inputSchema?: ToolInputSchema;
|
|
667
|
-
/** Handler function */
|
|
668
|
-
handler?: (params: TParams, context?: ToolContext) => Promise<ToolResponse> | ToolResponse;
|
|
669
|
-
/** Optional render function for UI */
|
|
670
|
-
render?: (props: ToolRenderProps<TParams>) => unknown;
|
|
671
|
-
/** Whether the tool is available */
|
|
672
|
-
available?: boolean;
|
|
673
|
-
/** Require user approval before execution */
|
|
674
|
-
needsApproval?: boolean | ((params: TParams) => boolean | Promise<boolean>);
|
|
675
|
-
/** Custom message shown in the approval UI */
|
|
676
|
-
approvalMessage?: string | ((params: TParams) => string);
|
|
677
|
-
/** AI response mode for this tool (default: 'full') */
|
|
678
|
-
aiResponseMode?: AIResponseMode;
|
|
679
|
-
/** Context/summary sent to AI instead of full result */
|
|
680
|
-
aiContext?: string | ((result: ToolResponse, args: Record<string, unknown>) => string);
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* Create a tool definition (similar to Vercel AI SDK's tool())
|
|
684
|
-
*
|
|
685
|
-
* @example
|
|
686
|
-
* ```typescript
|
|
687
|
-
* const weatherTool = tool({
|
|
688
|
-
* description: 'Get weather for a location',
|
|
689
|
-
* inputSchema: {
|
|
690
|
-
* type: 'object',
|
|
691
|
-
* properties: {
|
|
692
|
-
* location: { type: 'string', description: 'City name' },
|
|
693
|
-
* },
|
|
694
|
-
* required: ['location'],
|
|
695
|
-
* },
|
|
696
|
-
* handler: async ({ location }) => {
|
|
697
|
-
* const weather = await fetchWeather(location);
|
|
698
|
-
* return success(weather);
|
|
699
|
-
* },
|
|
700
|
-
* });
|
|
701
|
-
* ```
|
|
702
|
-
*/
|
|
703
|
-
declare function tool<TParams = Record<string, unknown>>(config: ToolConfig<TParams>): Omit<ToolDefinition<TParams>, "name">;
|
|
704
|
-
/**
|
|
705
|
-
* Convert ToolDefinition to OpenAI tool format
|
|
706
|
-
*/
|
|
707
|
-
declare function toolToOpenAIFormat(tool: ToolDefinition): object;
|
|
708
|
-
/**
|
|
709
|
-
* Convert ToolDefinition to Anthropic tool format
|
|
710
|
-
*/
|
|
711
|
-
declare function toolToAnthropicFormat(tool: ToolDefinition): object;
|
|
712
|
-
/**
|
|
713
|
-
* Create a tool result response
|
|
714
|
-
*/
|
|
715
|
-
declare function createToolResult(toolCallId: string, response: ToolResponse): UnifiedToolResult;
|
|
716
|
-
/**
|
|
717
|
-
* Create a successful tool response
|
|
718
|
-
*/
|
|
719
|
-
declare function success<T = unknown>(data?: T, message?: string): ToolResponse<T>;
|
|
720
|
-
/**
|
|
721
|
-
* Create a failed tool response
|
|
722
|
-
*/
|
|
723
|
-
declare function failure(error: string): ToolResponse;
|
|
724
|
-
|
|
725
210
|
/**
|
|
726
211
|
* Message roles in a conversation (OpenAI format)
|
|
727
212
|
*/
|
|
@@ -1222,4 +707,4 @@ interface PersistenceConfig {
|
|
|
1222
707
|
*/
|
|
1223
708
|
declare function generateThreadTitle(content: string): string;
|
|
1224
709
|
|
|
1225
|
-
export {
|
|
710
|
+
export { createAssistantMessage as $, type ActionParameter as A, type ActionRenderProps as B, type ConsoleLogOptions as C, type KnowledgeBaseConfig as D, type Extension as E, type KnowledgeBaseResult as F, type KnowledgeBaseSearchRequest as G, type HttpMethod as H, type IntentDetectionResult as I, type KnowledgeBaseSearchResponse as J, type KnowledgeBaseProvider as K, type LLMProvider as L, type MessageAttachment as M, type NetworkRequestOptions as N, type InternalKnowledgeBaseConfig as O, type ParameterType as P, type InternalKnowledgeBaseResult as Q, type InternalKnowledgeBaseSearchResponse as R, type ScreenshotOptions as S, type ToolType as T, type Thread as U, type ThreadData as V, type PersistenceConfig as W, type ThreadStorageAdapter as X, generateThreadTitle as Y, createMessage as Z, createUserMessage as _, type ScreenshotResult as a, createToolMessage as a0, createToolCall as a1, parseToolCallArgs as a2, hasToolCalls as a3, isToolResult as a4, actionToTool as a5, getDefaultModel as a6, DEFAULT_MODELS as a7, type ConsoleLogResult as b, type ConsoleLogEntry as c, type NetworkRequestResult as d, type NetworkRequestEntry as e, type Source as f, detectIntent as g, hasToolSuggestions as h, getPrimaryTool as i, generateSuggestionReason as j, createCustomDetector as k, type ConsoleLogType as l, type ToolsConfig as m, type ToolConsentRequest as n, type ToolConsentResponse as o, type CapturedContext as p, type CustomKeywords as q, type MessageRole as r, type Message as s, type MessageMetadata as t, type ToolCall as u, type TokenUsage as v, type LLMConfig as w, type CloudConfig as x, type CopilotConfig as y, type ActionDefinition as z };
|