@supyagent/sdk 0.2.0 → 0.3.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/index.cjs +528 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +219 -1
- package/dist/index.d.ts +219 -1
- package/dist/index.js +522 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ interface ToolMetadata {
|
|
|
10
10
|
bodyDefaults?: Record<string, string>;
|
|
11
11
|
category?: string;
|
|
12
12
|
tags?: string[];
|
|
13
|
+
/** Whether the user has the required integration connected. Present on all tool discovery endpoints. */
|
|
14
|
+
connected?: boolean;
|
|
13
15
|
}
|
|
14
16
|
/** A single tool as returned by the /api/v1/tools endpoint */
|
|
15
17
|
interface OpenAITool {
|
|
@@ -96,6 +98,20 @@ interface SkillsResult {
|
|
|
96
98
|
/** Tool objects: loadSkill and apiCall */
|
|
97
99
|
tools: Record<string, ai.Tool>;
|
|
98
100
|
}
|
|
101
|
+
/** A tool with a relevance score, returned by search endpoints */
|
|
102
|
+
interface ScoredTool extends OpenAITool {
|
|
103
|
+
score: number;
|
|
104
|
+
}
|
|
105
|
+
/** Response from search endpoints (/tools/search, /tools/names) */
|
|
106
|
+
interface ToolSearchResponse {
|
|
107
|
+
tools: ScoredTool[];
|
|
108
|
+
total: number;
|
|
109
|
+
}
|
|
110
|
+
/** Response from filter endpoints (/tools/provider, /tools/service) */
|
|
111
|
+
interface ToolListResponse {
|
|
112
|
+
tools: OpenAITool[];
|
|
113
|
+
total: number;
|
|
114
|
+
}
|
|
99
115
|
/** A connected account (end-user of the partner) */
|
|
100
116
|
interface ConnectedAccount {
|
|
101
117
|
id: string;
|
|
@@ -190,12 +206,24 @@ interface ScopedClient {
|
|
|
190
206
|
tools(options?: ToolFilterOptions): Promise<Record<string, ai.Tool>>;
|
|
191
207
|
skills(options?: SkillsOptions): Promise<SkillsResult>;
|
|
192
208
|
me(options?: MeOptions): Promise<MeResponse>;
|
|
209
|
+
/** Fuzzy search across tool names and descriptions. Returns scored results. */
|
|
210
|
+
searchTools(query: string): Promise<ToolSearchResponse>;
|
|
211
|
+
/** Get all tools for a specific provider (e.g. "google", "slack"). */
|
|
212
|
+
toolsByProvider(provider: string): Promise<ToolListResponse>;
|
|
213
|
+
/** Get all tools for a specific service (e.g. "gmail", "calendar"). */
|
|
214
|
+
toolsByService(service: string): Promise<ToolListResponse>;
|
|
193
215
|
}
|
|
194
216
|
/** The supyagent client interface */
|
|
195
217
|
interface SupyagentClient {
|
|
196
218
|
tools(options?: ToolFilterOptions): Promise<Record<string, ai.Tool>>;
|
|
197
219
|
skills(options?: SkillsOptions): Promise<SkillsResult>;
|
|
198
220
|
me(options?: MeOptions): Promise<MeResponse>;
|
|
221
|
+
/** Fuzzy search across tool names and descriptions. Returns scored results. */
|
|
222
|
+
searchTools(query: string): Promise<ToolSearchResponse>;
|
|
223
|
+
/** Get all tools for a specific provider (e.g. "google", "slack"). */
|
|
224
|
+
toolsByProvider(provider: string): Promise<ToolListResponse>;
|
|
225
|
+
/** Get all tools for a specific service (e.g. "gmail", "calendar"). */
|
|
226
|
+
toolsByService(service: string): Promise<ToolListResponse>;
|
|
199
227
|
accounts: AccountsClient;
|
|
200
228
|
/** Returns a client scoped to a connected account. All requests include X-Account-Id. */
|
|
201
229
|
asAccount(externalId: string): ScopedClient;
|
|
@@ -328,4 +356,194 @@ declare function createLoadSkillTool(skills: ParsedSkill[]): ai.Tool<unknown, {
|
|
|
328
356
|
*/
|
|
329
357
|
declare function createApiCallTool(baseUrl: string, apiKey: string, accountId?: string): ai.Tool<unknown, any>;
|
|
330
358
|
|
|
331
|
-
|
|
359
|
+
interface EditFileToolOptions {
|
|
360
|
+
/** Base directory for resolving relative paths. Defaults to `process.cwd()`. */
|
|
361
|
+
cwd?: string;
|
|
362
|
+
/** Maximum file size in bytes that can be edited. Defaults to 1MB. */
|
|
363
|
+
maxFileSize?: number;
|
|
364
|
+
}
|
|
365
|
+
interface EditFileToolResult {
|
|
366
|
+
path: string;
|
|
367
|
+
replacements: number;
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* Create an editFile tool that patches files using search-and-replace.
|
|
371
|
+
*
|
|
372
|
+
* Unlike a full-file write, this lets the LLM send only the changed sections,
|
|
373
|
+
* saving tokens and reducing the risk of accidentally dropping content.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```ts
|
|
377
|
+
* import { createEditFileTool } from '@supyagent/sdk';
|
|
378
|
+
*
|
|
379
|
+
* const tools = {
|
|
380
|
+
* editFile: createEditFileTool({ cwd: '/path/to/project' }),
|
|
381
|
+
* };
|
|
382
|
+
* ```
|
|
383
|
+
*/
|
|
384
|
+
declare function createEditFileTool(options?: EditFileToolOptions): ai.Tool<unknown, EditFileToolResult | {
|
|
385
|
+
error: string;
|
|
386
|
+
currentContent?: string;
|
|
387
|
+
}>;
|
|
388
|
+
|
|
389
|
+
interface GrepToolOptions {
|
|
390
|
+
/** Base directory for searching. Defaults to `process.cwd()`. */
|
|
391
|
+
cwd?: string;
|
|
392
|
+
/** Timeout in milliseconds. Defaults to 15000 (15s). */
|
|
393
|
+
timeout?: number;
|
|
394
|
+
/** Maximum output length in characters. Defaults to 30000. */
|
|
395
|
+
maxOutput?: number;
|
|
396
|
+
}
|
|
397
|
+
interface GrepToolResult {
|
|
398
|
+
matches: string;
|
|
399
|
+
matchCount: number;
|
|
400
|
+
truncated: boolean;
|
|
401
|
+
}
|
|
402
|
+
/**
|
|
403
|
+
* Create a grep tool for searching file contents by pattern.
|
|
404
|
+
*
|
|
405
|
+
* Uses `grep -rn` (or `rg` if available) under the hood.
|
|
406
|
+
* Returns matching lines with file paths and line numbers.
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```ts
|
|
410
|
+
* import { createGrepTool } from '@supyagent/sdk';
|
|
411
|
+
*
|
|
412
|
+
* const tools = {
|
|
413
|
+
* grep: createGrepTool({ cwd: '/path/to/project' }),
|
|
414
|
+
* };
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
declare function createGrepTool(options?: GrepToolOptions): ai.Tool<unknown, GrepToolResult | {
|
|
418
|
+
error: string;
|
|
419
|
+
}>;
|
|
420
|
+
|
|
421
|
+
interface FindToolOptions {
|
|
422
|
+
/** Base directory for searching. Defaults to `process.cwd()`. */
|
|
423
|
+
cwd?: string;
|
|
424
|
+
/** Timeout in milliseconds. Defaults to 15000 (15s). */
|
|
425
|
+
timeout?: number;
|
|
426
|
+
/** Maximum output length in characters. Defaults to 30000. */
|
|
427
|
+
maxOutput?: number;
|
|
428
|
+
}
|
|
429
|
+
interface FindToolResult {
|
|
430
|
+
files: string[];
|
|
431
|
+
count: number;
|
|
432
|
+
truncated: boolean;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Create a find tool for discovering files by name or glob pattern.
|
|
436
|
+
*
|
|
437
|
+
* Uses `find` under the hood with common ignore patterns
|
|
438
|
+
* (node_modules, .git, dist, etc.) pre-configured.
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* import { createFindTool } from '@supyagent/sdk';
|
|
443
|
+
*
|
|
444
|
+
* const tools = {
|
|
445
|
+
* find: createFindTool({ cwd: '/path/to/project' }),
|
|
446
|
+
* };
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
declare function createFindTool(options?: FindToolOptions): ai.Tool<unknown, FindToolResult | {
|
|
450
|
+
error: string;
|
|
451
|
+
}>;
|
|
452
|
+
|
|
453
|
+
interface ReadFileRangeToolOptions {
|
|
454
|
+
/** Base directory for resolving relative paths. Defaults to `process.cwd()`. */
|
|
455
|
+
cwd?: string;
|
|
456
|
+
/** Maximum number of lines that can be requested at once. Defaults to 200. */
|
|
457
|
+
maxLines?: number;
|
|
458
|
+
}
|
|
459
|
+
interface ReadFileRangeToolResult {
|
|
460
|
+
path: string;
|
|
461
|
+
content: string;
|
|
462
|
+
startLine: number;
|
|
463
|
+
endLine: number;
|
|
464
|
+
totalLines: number;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Create a readFileRange tool that reads specific line ranges from files.
|
|
468
|
+
*
|
|
469
|
+
* More token-efficient than reading entire files — especially useful
|
|
470
|
+
* after a grep to read context around a match.
|
|
471
|
+
*
|
|
472
|
+
* @example
|
|
473
|
+
* ```ts
|
|
474
|
+
* import { createReadFileRangeTool } from '@supyagent/sdk';
|
|
475
|
+
*
|
|
476
|
+
* const tools = {
|
|
477
|
+
* readFileRange: createReadFileRangeTool({ cwd: '/path/to/project' }),
|
|
478
|
+
* };
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
declare function createReadFileRangeTool(options?: ReadFileRangeToolOptions): ai.Tool<unknown, ReadFileRangeToolResult | {
|
|
482
|
+
error: string;
|
|
483
|
+
}>;
|
|
484
|
+
|
|
485
|
+
interface AppendFileToolOptions {
|
|
486
|
+
/** Base directory for resolving relative paths. Defaults to `process.cwd()`. */
|
|
487
|
+
cwd?: string;
|
|
488
|
+
}
|
|
489
|
+
interface AppendFileToolResult {
|
|
490
|
+
path: string;
|
|
491
|
+
bytesAppended: number;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Create an appendFile tool that appends content to existing files.
|
|
495
|
+
*
|
|
496
|
+
* More token-efficient than read-concat-write for incremental file building
|
|
497
|
+
* (logs, CSVs, reports). Creates the file if it doesn't exist.
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```ts
|
|
501
|
+
* import { createAppendFileTool } from '@supyagent/sdk';
|
|
502
|
+
*
|
|
503
|
+
* const tools = {
|
|
504
|
+
* appendFile: createAppendFileTool({ cwd: '/path/to/project' }),
|
|
505
|
+
* };
|
|
506
|
+
* ```
|
|
507
|
+
*/
|
|
508
|
+
declare function createAppendFileTool(options?: AppendFileToolOptions): ai.Tool<unknown, AppendFileToolResult | {
|
|
509
|
+
error: string;
|
|
510
|
+
}>;
|
|
511
|
+
|
|
512
|
+
interface HttpRequestToolOptions {
|
|
513
|
+
/** Default timeout in milliseconds. Defaults to 30000 (30s). */
|
|
514
|
+
timeout?: number;
|
|
515
|
+
/** Maximum response body size in characters. Defaults to 100000. */
|
|
516
|
+
maxResponseSize?: number;
|
|
517
|
+
/** Default headers to include in every request. */
|
|
518
|
+
defaultHeaders?: Record<string, string>;
|
|
519
|
+
}
|
|
520
|
+
interface HttpRequestToolResult {
|
|
521
|
+
status: number;
|
|
522
|
+
statusText: string;
|
|
523
|
+
headers: Record<string, string>;
|
|
524
|
+
body: string;
|
|
525
|
+
durationMs: number;
|
|
526
|
+
truncated: boolean;
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Create an httpRequest tool for making HTTP requests.
|
|
530
|
+
*
|
|
531
|
+
* Supports GET, POST, PUT, PATCH, DELETE with headers, body, and
|
|
532
|
+
* parsed JSON responses. Cleaner than composing curl commands via bash.
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```ts
|
|
536
|
+
* import { createHttpRequestTool } from '@supyagent/sdk';
|
|
537
|
+
*
|
|
538
|
+
* const tools = {
|
|
539
|
+
* httpRequest: createHttpRequestTool({
|
|
540
|
+
* defaultHeaders: { 'Authorization': 'Bearer ...' },
|
|
541
|
+
* }),
|
|
542
|
+
* };
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
declare function createHttpRequestTool(options?: HttpRequestToolOptions): ai.Tool<unknown, HttpRequestToolResult | {
|
|
546
|
+
error: string;
|
|
547
|
+
}>;
|
|
548
|
+
|
|
549
|
+
export { type AccountIntegration, type AccountIntegrationDetail, type AccountsClient, type AppendFileToolOptions, type AppendFileToolResult, type BashToolOptions, type BashToolResult, type ConnectOptions, type ConnectSession, type ConnectSessionStatus, type ConnectedAccount, type ConnectedAccountWithIntegrations, type CreateAccountOptions, type EditFileToolOptions, type EditFileToolResult, type FindToolOptions, type FindToolResult, type GrepToolOptions, type GrepToolResult, type HttpRequestToolOptions, type HttpRequestToolResult, type ListAccountsOptions, type ListAccountsResponse, type MeOptions, type MeResponse, type OpenAITool, type ParsedSkill, type ParsedSkillsDocument, type ReadFileRangeToolOptions, type ReadFileRangeToolResult, type ScopedClient, type ScoredTool, type SkillsOptions, type SkillsResult, type SupyagentClient, type SupyagentOptions, type ToolFilterOptions, type ToolListResponse, type ToolMetadata, type ToolSearchResponse, type ToolsResponse, type UpdateAccountOptions, type ViewImageToolOptions, type ViewImageToolResult, buildSkillsSystemPrompt, createApiCallTool, createAppendFileTool, createBashTool, createEditFileTool, createFindTool, createGrepTool, createHttpRequestTool, createLoadSkillTool, createReadFileRangeTool, createViewImageTool, findSkill, parseSkillsMarkdown, supyagent };
|