digital-tools 2.0.2 → 2.1.3
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/.turbo/turbo-build.log +4 -5
- package/CHANGELOG.md +25 -0
- package/LICENSE +21 -0
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +1 -9
- package/dist/define.js.map +1 -1
- package/package.json +14 -15
- package/src/define.js +259 -0
- package/src/define.ts +1 -13
- package/src/entities/advertising.js +999 -0
- package/src/entities/ai.js +756 -0
- package/src/entities/analytics.js +1588 -0
- package/src/entities/automation.js +601 -0
- package/src/entities/communication.js +1150 -0
- package/src/entities/crm.js +1386 -0
- package/src/entities/design.js +546 -0
- package/src/entities/development.js +2212 -0
- package/src/entities/document.js +874 -0
- package/src/entities/ecommerce.js +1429 -0
- package/src/entities/experiment.js +1039 -0
- package/src/entities/finance.js +3478 -0
- package/src/entities/forms.js +1892 -0
- package/src/entities/hr.js +661 -0
- package/src/entities/identity.js +997 -0
- package/src/entities/index.js +282 -0
- package/src/entities/infrastructure.js +1153 -0
- package/src/entities/knowledge.js +1438 -0
- package/src/entities/marketing.js +1610 -0
- package/src/entities/media.js +1634 -0
- package/src/entities/notification.js +1199 -0
- package/src/entities/presentation.js +1274 -0
- package/src/entities/productivity.js +1317 -0
- package/src/entities/project-management.js +1136 -0
- package/src/entities/recruiting.js +736 -0
- package/src/entities/shipping.js +509 -0
- package/src/entities/signature.js +1102 -0
- package/src/entities/site.js +222 -0
- package/src/entities/spreadsheet.js +1341 -0
- package/src/entities/storage.js +1198 -0
- package/src/entities/support.js +1166 -0
- package/src/entities/video-conferencing.js +1750 -0
- package/src/entities/video.js +950 -0
- package/src/entities.js +1663 -0
- package/src/index.js +74 -0
- package/src/providers/analytics/index.js +17 -0
- package/src/providers/analytics/mixpanel.js +255 -0
- package/src/providers/calendar/cal-com.js +303 -0
- package/src/providers/calendar/google-calendar.js +335 -0
- package/src/providers/calendar/index.js +20 -0
- package/src/providers/crm/hubspot.js +566 -0
- package/src/providers/crm/index.js +17 -0
- package/src/providers/development/github.js +472 -0
- package/src/providers/development/index.js +17 -0
- package/src/providers/ecommerce/index.js +17 -0
- package/src/providers/ecommerce/shopify.js +378 -0
- package/src/providers/email/index.js +20 -0
- package/src/providers/email/resend.js +258 -0
- package/src/providers/email/sendgrid.js +161 -0
- package/src/providers/finance/index.js +17 -0
- package/src/providers/finance/stripe.js +549 -0
- package/src/providers/forms/index.js +17 -0
- package/src/providers/forms/typeform.js +500 -0
- package/src/providers/index.js +123 -0
- package/src/providers/knowledge/index.js +17 -0
- package/src/providers/knowledge/notion.js +389 -0
- package/src/providers/marketing/index.js +17 -0
- package/src/providers/marketing/mailchimp.js +443 -0
- package/src/providers/media/cloudinary.js +318 -0
- package/src/providers/media/index.js +17 -0
- package/src/providers/messaging/index.js +20 -0
- package/src/providers/messaging/slack.js +393 -0
- package/src/providers/messaging/twilio-sms.js +249 -0
- package/src/providers/project-management/index.js +17 -0
- package/src/providers/project-management/linear.js +575 -0
- package/src/providers/registry.js +86 -0
- package/src/providers/spreadsheet/google-sheets.js +375 -0
- package/src/providers/spreadsheet/index.js +20 -0
- package/src/providers/spreadsheet/xlsx.js +423 -0
- package/src/providers/storage/index.js +24 -0
- package/src/providers/storage/s3.js +419 -0
- package/src/providers/support/index.js +17 -0
- package/src/providers/support/zendesk.js +373 -0
- package/src/providers/tasks/index.js +17 -0
- package/src/providers/tasks/todoist.js +286 -0
- package/src/providers/types.js +9 -0
- package/src/providers/video-conferencing/google-meet.js +286 -0
- package/src/providers/video-conferencing/index.js +31 -0
- package/src/providers/video-conferencing/jitsi.js +254 -0
- package/src/providers/video-conferencing/teams.js +270 -0
- package/src/providers/video-conferencing/zoom.js +332 -0
- package/src/registry.js +128 -0
- package/src/tools/communication.js +184 -0
- package/src/tools/data.js +205 -0
- package/src/tools/index.js +11 -0
- package/src/tools/web.js +137 -0
- package/src/types.js +10 -0
- package/test/define.test.js +306 -0
- package/test/registry.test.js +357 -0
- package/test/tools.test.js +363 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
|
|
2
|
+
> digital-tools@2.1.3 build /Users/nathanclevenger/projects/primitives.org.ai/packages/digital-tools
|
|
3
|
+
> tsc
|
|
4
|
+
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# digital-tools
|
|
2
2
|
|
|
3
|
+
## 2.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- ai-functions@2.1.3
|
|
9
|
+
- ai-database@2.1.3
|
|
10
|
+
|
|
11
|
+
## 2.1.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [6beb531]
|
|
16
|
+
- ai-functions@2.1.1
|
|
17
|
+
- ai-database@2.1.1
|
|
18
|
+
|
|
19
|
+
## 2.0.3
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- rpc.do@0.2.0
|
|
25
|
+
- ai-database@2.0.3
|
|
26
|
+
- ai-functions@2.0.3
|
|
27
|
+
|
|
3
28
|
## 2.0.2
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 .org.ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/define.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EAEJ,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,MAAM,EACP,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EAEJ,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,MAAM,EACP,MAAM,YAAY,CAAA;AAgDnB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,EACxC,OAAO,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,GAC1C,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAmBvB;AAED;;GAEG;AACH,wBAAg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|
*/
|
|
9
|
+
import { isZodSchema } from 'ai-functions';
|
|
9
10
|
import { registry } from './registry.js';
|
|
10
|
-
/**
|
|
11
|
-
* Check if a schema is a Zod schema
|
|
12
|
-
*/
|
|
13
|
-
function isZodSchema(schema) {
|
|
14
|
-
return (typeof schema === 'object' &&
|
|
15
|
-
schema !== null &&
|
|
16
|
-
'_def' in schema &&
|
|
17
|
-
'parse' in schema);
|
|
18
|
-
}
|
|
19
11
|
/**
|
|
20
12
|
* Convert a schema to JSON Schema format
|
|
21
13
|
*/
|
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,WAAW,EAAmB,MAAM,cAAc,CAAA;AAU3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC;;GAEG;AACH,SAAS,YAAY,CAAC,MAAc;IAClC,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,6DAA6D;QAC7D,yCAAyC;QACzC,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,8CAA8C;SAC5D,CAAA;IACH,CAAC;IACD,OAAO,MAAoB,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,SAAS,kBAAkB,CAAC,MAAc;IACxC,MAAM,UAAU,GAAG,YAAY,CAAC,MAAM,CAAC,CAAA;IAEvC,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC;QAC3D,mBAAmB;QACnB,OAAO;YACL;gBACE,IAAI,EAAE,OAAO;gBACb,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,aAAa;gBACpD,MAAM,EAAE,UAAU;gBAClB,QAAQ,EAAE,IA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A;QACb,CAAC;QAED,OAAO,CAAkB,EAAiD;YACxE,MAAM,CAAC,OAAO,GAAG,EAAoD,CAAA;YACrE,OAAO,IAIN,CAAA;QACH,CAAC;QAED,OAAO,CAAC,IAAsB;YAC5B,MAAM,CAAC,OAAO,GAAG,IAAsD,CAAA;YACvE,OAAO,IAAI,CAAA;QACb,CAAC;QAED,KAAK;YACH,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBAChG,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;YACtF,CAAC;YACD,OAAO,UAAU,CAAC,MAA4C,CAAC,CAAA;QACjE,CAAC;QAED,QAAQ;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAmB,CAAA;YAC1C,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;YACvB,OAAO,IAAI,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "digital-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Tools that can be used by both humans and AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -19,19 +19,10 @@
|
|
|
19
19
|
"types": "./dist/registry.d.ts"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsc",
|
|
24
|
-
"dev": "tsc --watch",
|
|
25
|
-
"test": "vitest",
|
|
26
|
-
"typecheck": "tsc --noEmit",
|
|
27
|
-
"lint": "eslint .",
|
|
28
|
-
"clean": "rm -rf dist"
|
|
29
|
-
},
|
|
30
22
|
"dependencies": {
|
|
31
|
-
"
|
|
32
|
-
"ai-
|
|
33
|
-
"
|
|
34
|
-
"zod": "^3.23.0"
|
|
23
|
+
"zod": "^3.23.0",
|
|
24
|
+
"ai-database": "2.1.3",
|
|
25
|
+
"ai-functions": "2.1.3"
|
|
35
26
|
},
|
|
36
27
|
"keywords": [
|
|
37
28
|
"ai",
|
|
@@ -41,5 +32,13 @@
|
|
|
41
32
|
"primitives",
|
|
42
33
|
"mcp"
|
|
43
34
|
],
|
|
44
|
-
"license": "MIT"
|
|
45
|
-
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc",
|
|
38
|
+
"dev": "tsc --watch",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"lint": "eslint .",
|
|
42
|
+
"clean": "rm -rf dist"
|
|
43
|
+
}
|
|
44
|
+
}
|
package/src/define.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Definition Utilities
|
|
3
|
+
*
|
|
4
|
+
* Provides helpers for defining tools with type safety
|
|
5
|
+
* and automatic schema conversion.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { isZodSchema } from 'ai-functions';
|
|
10
|
+
import { registry } from './registry.js';
|
|
11
|
+
/**
|
|
12
|
+
* Convert a schema to JSON Schema format
|
|
13
|
+
*/
|
|
14
|
+
function toJSONSchema(schema) {
|
|
15
|
+
if (isZodSchema(schema)) {
|
|
16
|
+
// For Zod schemas, we'd use zod-to-json-schema in production
|
|
17
|
+
// For now, return a basic representation
|
|
18
|
+
return {
|
|
19
|
+
type: 'object',
|
|
20
|
+
description: 'Zod schema (convert with zod-to-json-schema)',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return schema;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Convert a schema definition to tool parameters
|
|
27
|
+
*/
|
|
28
|
+
function schemaToParameters(schema) {
|
|
29
|
+
const jsonSchema = toJSONSchema(schema);
|
|
30
|
+
if (jsonSchema.type !== 'object' || !jsonSchema.properties) {
|
|
31
|
+
// Single parameter
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
name: 'input',
|
|
35
|
+
description: jsonSchema.description || 'Input value',
|
|
36
|
+
schema: jsonSchema,
|
|
37
|
+
required: true,
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
const required = jsonSchema.required || [];
|
|
42
|
+
return Object.entries(jsonSchema.properties).map(([name, propSchema]) => ({
|
|
43
|
+
name,
|
|
44
|
+
description: propSchema.description || `Parameter: ${name}`,
|
|
45
|
+
schema: propSchema,
|
|
46
|
+
required: required.includes(name),
|
|
47
|
+
default: propSchema.default,
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Define a new tool with type safety
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const sendEmail = defineTool({
|
|
56
|
+
* id: 'communication.email.send',
|
|
57
|
+
* name: 'Send Email',
|
|
58
|
+
* description: 'Send an email to one or more recipients',
|
|
59
|
+
* category: 'communication',
|
|
60
|
+
* subcategory: 'email',
|
|
61
|
+
* input: {
|
|
62
|
+
* type: 'object',
|
|
63
|
+
* properties: {
|
|
64
|
+
* to: { type: 'array', items: { type: 'string' }, description: 'Recipients' },
|
|
65
|
+
* subject: { type: 'string', description: 'Email subject' },
|
|
66
|
+
* body: { type: 'string', description: 'Email body' },
|
|
67
|
+
* },
|
|
68
|
+
* required: ['to', 'subject', 'body'],
|
|
69
|
+
* },
|
|
70
|
+
* handler: async (input) => {
|
|
71
|
+
* // Send email logic
|
|
72
|
+
* return { success: true, messageId: 'msg_123' }
|
|
73
|
+
* },
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
export function defineTool(options) {
|
|
78
|
+
const tool = {
|
|
79
|
+
id: options.id,
|
|
80
|
+
name: options.name,
|
|
81
|
+
description: options.description,
|
|
82
|
+
category: options.category,
|
|
83
|
+
subcategory: options.subcategory,
|
|
84
|
+
parameters: schemaToParameters(options.input),
|
|
85
|
+
output: options.output
|
|
86
|
+
? {
|
|
87
|
+
description: 'Tool output',
|
|
88
|
+
schema: options.output,
|
|
89
|
+
}
|
|
90
|
+
: undefined,
|
|
91
|
+
handler: options.handler,
|
|
92
|
+
...options.options,
|
|
93
|
+
};
|
|
94
|
+
return tool;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Define and register a tool in one step
|
|
98
|
+
*/
|
|
99
|
+
export function defineAndRegister(options) {
|
|
100
|
+
const tool = defineTool(options);
|
|
101
|
+
registry.register(tool);
|
|
102
|
+
return tool;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create a tool executor with context
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* const executor = createToolExecutor({
|
|
110
|
+
* executor: { type: 'agent', id: 'agent_123', name: 'Research Agent' },
|
|
111
|
+
* environment: 'production',
|
|
112
|
+
* })
|
|
113
|
+
*
|
|
114
|
+
* const result = await executor.execute('communication.email.send', {
|
|
115
|
+
* to: ['user@example.com'],
|
|
116
|
+
* subject: 'Hello',
|
|
117
|
+
* body: 'World',
|
|
118
|
+
* })
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export function createToolExecutor(context) {
|
|
122
|
+
return {
|
|
123
|
+
/**
|
|
124
|
+
* Execute a tool by ID with context tracking
|
|
125
|
+
*/
|
|
126
|
+
async execute(toolId, input) {
|
|
127
|
+
const tool = registry.get(toolId);
|
|
128
|
+
if (!tool) {
|
|
129
|
+
return {
|
|
130
|
+
success: false,
|
|
131
|
+
error: {
|
|
132
|
+
code: 'TOOL_NOT_FOUND',
|
|
133
|
+
message: `Tool "${toolId}" not found`,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Check audience restrictions
|
|
138
|
+
if (tool.audience &&
|
|
139
|
+
tool.audience !== 'both' &&
|
|
140
|
+
tool.audience !== context.executor.type) {
|
|
141
|
+
return {
|
|
142
|
+
success: false,
|
|
143
|
+
error: {
|
|
144
|
+
code: 'ACCESS_DENIED',
|
|
145
|
+
message: `Tool "${toolId}" is not available for ${context.executor.type}`,
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
const startTime = Date.now();
|
|
150
|
+
try {
|
|
151
|
+
const data = (await tool.handler(input));
|
|
152
|
+
const duration = Date.now() - startTime;
|
|
153
|
+
return {
|
|
154
|
+
success: true,
|
|
155
|
+
data,
|
|
156
|
+
metadata: {
|
|
157
|
+
duration,
|
|
158
|
+
requestId: context.requestId,
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
const duration = Date.now() - startTime;
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
error: {
|
|
167
|
+
code: 'EXECUTION_ERROR',
|
|
168
|
+
message: error instanceof Error ? error.message : String(error),
|
|
169
|
+
details: error,
|
|
170
|
+
},
|
|
171
|
+
metadata: {
|
|
172
|
+
duration,
|
|
173
|
+
requestId: context.requestId,
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
/**
|
|
179
|
+
* List available tools for this executor
|
|
180
|
+
*/
|
|
181
|
+
listAvailable() {
|
|
182
|
+
return registry.query({
|
|
183
|
+
audience: context.executor.type,
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Tool builder for fluent API
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```ts
|
|
193
|
+
* const tool = toolBuilder('web.fetch')
|
|
194
|
+
* .name('Fetch URL')
|
|
195
|
+
* .description('Fetch content from a URL')
|
|
196
|
+
* .category('web')
|
|
197
|
+
* .subcategory('fetch')
|
|
198
|
+
* .input({
|
|
199
|
+
* type: 'object',
|
|
200
|
+
* properties: {
|
|
201
|
+
* url: { type: 'string', description: 'URL to fetch' },
|
|
202
|
+
* },
|
|
203
|
+
* required: ['url'],
|
|
204
|
+
* })
|
|
205
|
+
* .handler(async ({ url }) => {
|
|
206
|
+
* const response = await fetch(url)
|
|
207
|
+
* return response.text()
|
|
208
|
+
* })
|
|
209
|
+
* .build()
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
export function toolBuilder(id) {
|
|
213
|
+
const config = { id };
|
|
214
|
+
return {
|
|
215
|
+
name(name) {
|
|
216
|
+
config.name = name;
|
|
217
|
+
return this;
|
|
218
|
+
},
|
|
219
|
+
description(description) {
|
|
220
|
+
config.description = description;
|
|
221
|
+
return this;
|
|
222
|
+
},
|
|
223
|
+
category(category) {
|
|
224
|
+
config.category = category;
|
|
225
|
+
return this;
|
|
226
|
+
},
|
|
227
|
+
subcategory(subcategory) {
|
|
228
|
+
config.subcategory = subcategory;
|
|
229
|
+
return this;
|
|
230
|
+
},
|
|
231
|
+
input(schema) {
|
|
232
|
+
config.input = schema;
|
|
233
|
+
return this;
|
|
234
|
+
},
|
|
235
|
+
output(schema) {
|
|
236
|
+
config.output = schema;
|
|
237
|
+
return this;
|
|
238
|
+
},
|
|
239
|
+
handler(fn) {
|
|
240
|
+
config.handler = fn;
|
|
241
|
+
return this;
|
|
242
|
+
},
|
|
243
|
+
options(opts) {
|
|
244
|
+
config.options = opts;
|
|
245
|
+
return this;
|
|
246
|
+
},
|
|
247
|
+
build() {
|
|
248
|
+
if (!config.name || !config.description || !config.category || !config.input || !config.handler) {
|
|
249
|
+
throw new Error('Tool requires id, name, description, category, input, and handler');
|
|
250
|
+
}
|
|
251
|
+
return defineTool(config);
|
|
252
|
+
},
|
|
253
|
+
register() {
|
|
254
|
+
const tool = this.build();
|
|
255
|
+
registry.register(tool);
|
|
256
|
+
return tool;
|
|
257
|
+
},
|
|
258
|
+
};
|
|
259
|
+
}
|
package/src/define.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type
|
|
10
|
+
import { isZodSchema, type JSONSchema } from 'ai-functions'
|
|
11
11
|
import type {
|
|
12
12
|
AnyTool,
|
|
13
13
|
Tool,
|
|
@@ -19,18 +19,6 @@ import type {
|
|
|
19
19
|
} from './types.js'
|
|
20
20
|
import { registry } from './registry.js'
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Check if a schema is a Zod schema
|
|
24
|
-
*/
|
|
25
|
-
function isZodSchema(schema: Schema): schema is { _def: unknown; parse: unknown } {
|
|
26
|
-
return (
|
|
27
|
-
typeof schema === 'object' &&
|
|
28
|
-
schema !== null &&
|
|
29
|
-
'_def' in schema &&
|
|
30
|
-
'parse' in schema
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
22
|
/**
|
|
35
23
|
* Convert a schema to JSON Schema format
|
|
36
24
|
*/
|