digital-tools 2.0.1 → 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.
- package/CHANGELOG.md +25 -0
- package/package.json +3 -4
- package/src/define.js +267 -0
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# digital-tools
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [6beb531]
|
|
8
|
+
- ai-functions@2.1.1
|
|
9
|
+
- ai-database@2.1.1
|
|
10
|
+
|
|
11
|
+
## 2.0.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
- rpc.do@0.2.0
|
|
17
|
+
- ai-database@2.0.3
|
|
18
|
+
- ai-functions@2.0.3
|
|
19
|
+
|
|
20
|
+
## 2.0.2
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
- ai-functions@2.0.2
|
|
26
|
+
- ai-database@2.0.2
|
|
27
|
+
|
|
3
28
|
## 2.0.1
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "digital-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Tools that can be used by both humans and AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,9 +28,8 @@
|
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"ai-database": "
|
|
32
|
-
"ai-functions": "
|
|
33
|
-
"rpc.do": "^0.1.0",
|
|
31
|
+
"ai-database": "2.1.1",
|
|
32
|
+
"ai-functions": "2.1.1",
|
|
34
33
|
"zod": "^3.23.0"
|
|
35
34
|
},
|
|
36
35
|
"keywords": [
|
package/src/define.js
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
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 { 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
|
+
/**
|
|
20
|
+
* Convert a schema to JSON Schema format
|
|
21
|
+
*/
|
|
22
|
+
function toJSONSchema(schema) {
|
|
23
|
+
if (isZodSchema(schema)) {
|
|
24
|
+
// For Zod schemas, we'd use zod-to-json-schema in production
|
|
25
|
+
// For now, return a basic representation
|
|
26
|
+
return {
|
|
27
|
+
type: 'object',
|
|
28
|
+
description: 'Zod schema (convert with zod-to-json-schema)',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return schema;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert a schema definition to tool parameters
|
|
35
|
+
*/
|
|
36
|
+
function schemaToParameters(schema) {
|
|
37
|
+
const jsonSchema = toJSONSchema(schema);
|
|
38
|
+
if (jsonSchema.type !== 'object' || !jsonSchema.properties) {
|
|
39
|
+
// Single parameter
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
name: 'input',
|
|
43
|
+
description: jsonSchema.description || 'Input value',
|
|
44
|
+
schema: jsonSchema,
|
|
45
|
+
required: true,
|
|
46
|
+
},
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
const required = jsonSchema.required || [];
|
|
50
|
+
return Object.entries(jsonSchema.properties).map(([name, propSchema]) => ({
|
|
51
|
+
name,
|
|
52
|
+
description: propSchema.description || `Parameter: ${name}`,
|
|
53
|
+
schema: propSchema,
|
|
54
|
+
required: required.includes(name),
|
|
55
|
+
default: propSchema.default,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Define a new tool with type safety
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const sendEmail = defineTool({
|
|
64
|
+
* id: 'communication.email.send',
|
|
65
|
+
* name: 'Send Email',
|
|
66
|
+
* description: 'Send an email to one or more recipients',
|
|
67
|
+
* category: 'communication',
|
|
68
|
+
* subcategory: 'email',
|
|
69
|
+
* input: {
|
|
70
|
+
* type: 'object',
|
|
71
|
+
* properties: {
|
|
72
|
+
* to: { type: 'array', items: { type: 'string' }, description: 'Recipients' },
|
|
73
|
+
* subject: { type: 'string', description: 'Email subject' },
|
|
74
|
+
* body: { type: 'string', description: 'Email body' },
|
|
75
|
+
* },
|
|
76
|
+
* required: ['to', 'subject', 'body'],
|
|
77
|
+
* },
|
|
78
|
+
* handler: async (input) => {
|
|
79
|
+
* // Send email logic
|
|
80
|
+
* return { success: true, messageId: 'msg_123' }
|
|
81
|
+
* },
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
export function defineTool(options) {
|
|
86
|
+
const tool = {
|
|
87
|
+
id: options.id,
|
|
88
|
+
name: options.name,
|
|
89
|
+
description: options.description,
|
|
90
|
+
category: options.category,
|
|
91
|
+
subcategory: options.subcategory,
|
|
92
|
+
parameters: schemaToParameters(options.input),
|
|
93
|
+
output: options.output
|
|
94
|
+
? {
|
|
95
|
+
description: 'Tool output',
|
|
96
|
+
schema: options.output,
|
|
97
|
+
}
|
|
98
|
+
: undefined,
|
|
99
|
+
handler: options.handler,
|
|
100
|
+
...options.options,
|
|
101
|
+
};
|
|
102
|
+
return tool;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Define and register a tool in one step
|
|
106
|
+
*/
|
|
107
|
+
export function defineAndRegister(options) {
|
|
108
|
+
const tool = defineTool(options);
|
|
109
|
+
registry.register(tool);
|
|
110
|
+
return tool;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Create a tool executor with context
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* ```ts
|
|
117
|
+
* const executor = createToolExecutor({
|
|
118
|
+
* executor: { type: 'agent', id: 'agent_123', name: 'Research Agent' },
|
|
119
|
+
* environment: 'production',
|
|
120
|
+
* })
|
|
121
|
+
*
|
|
122
|
+
* const result = await executor.execute('communication.email.send', {
|
|
123
|
+
* to: ['user@example.com'],
|
|
124
|
+
* subject: 'Hello',
|
|
125
|
+
* body: 'World',
|
|
126
|
+
* })
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
export function createToolExecutor(context) {
|
|
130
|
+
return {
|
|
131
|
+
/**
|
|
132
|
+
* Execute a tool by ID with context tracking
|
|
133
|
+
*/
|
|
134
|
+
async execute(toolId, input) {
|
|
135
|
+
const tool = registry.get(toolId);
|
|
136
|
+
if (!tool) {
|
|
137
|
+
return {
|
|
138
|
+
success: false,
|
|
139
|
+
error: {
|
|
140
|
+
code: 'TOOL_NOT_FOUND',
|
|
141
|
+
message: `Tool "${toolId}" not found`,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
// Check audience restrictions
|
|
146
|
+
if (tool.audience &&
|
|
147
|
+
tool.audience !== 'both' &&
|
|
148
|
+
tool.audience !== context.executor.type) {
|
|
149
|
+
return {
|
|
150
|
+
success: false,
|
|
151
|
+
error: {
|
|
152
|
+
code: 'ACCESS_DENIED',
|
|
153
|
+
message: `Tool "${toolId}" is not available for ${context.executor.type}`,
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const startTime = Date.now();
|
|
158
|
+
try {
|
|
159
|
+
const data = (await tool.handler(input));
|
|
160
|
+
const duration = Date.now() - startTime;
|
|
161
|
+
return {
|
|
162
|
+
success: true,
|
|
163
|
+
data,
|
|
164
|
+
metadata: {
|
|
165
|
+
duration,
|
|
166
|
+
requestId: context.requestId,
|
|
167
|
+
},
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const duration = Date.now() - startTime;
|
|
172
|
+
return {
|
|
173
|
+
success: false,
|
|
174
|
+
error: {
|
|
175
|
+
code: 'EXECUTION_ERROR',
|
|
176
|
+
message: error instanceof Error ? error.message : String(error),
|
|
177
|
+
details: error,
|
|
178
|
+
},
|
|
179
|
+
metadata: {
|
|
180
|
+
duration,
|
|
181
|
+
requestId: context.requestId,
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* List available tools for this executor
|
|
188
|
+
*/
|
|
189
|
+
listAvailable() {
|
|
190
|
+
return registry.query({
|
|
191
|
+
audience: context.executor.type,
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Tool builder for fluent API
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const tool = toolBuilder('web.fetch')
|
|
202
|
+
* .name('Fetch URL')
|
|
203
|
+
* .description('Fetch content from a URL')
|
|
204
|
+
* .category('web')
|
|
205
|
+
* .subcategory('fetch')
|
|
206
|
+
* .input({
|
|
207
|
+
* type: 'object',
|
|
208
|
+
* properties: {
|
|
209
|
+
* url: { type: 'string', description: 'URL to fetch' },
|
|
210
|
+
* },
|
|
211
|
+
* required: ['url'],
|
|
212
|
+
* })
|
|
213
|
+
* .handler(async ({ url }) => {
|
|
214
|
+
* const response = await fetch(url)
|
|
215
|
+
* return response.text()
|
|
216
|
+
* })
|
|
217
|
+
* .build()
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export function toolBuilder(id) {
|
|
221
|
+
const config = { id };
|
|
222
|
+
return {
|
|
223
|
+
name(name) {
|
|
224
|
+
config.name = name;
|
|
225
|
+
return this;
|
|
226
|
+
},
|
|
227
|
+
description(description) {
|
|
228
|
+
config.description = description;
|
|
229
|
+
return this;
|
|
230
|
+
},
|
|
231
|
+
category(category) {
|
|
232
|
+
config.category = category;
|
|
233
|
+
return this;
|
|
234
|
+
},
|
|
235
|
+
subcategory(subcategory) {
|
|
236
|
+
config.subcategory = subcategory;
|
|
237
|
+
return this;
|
|
238
|
+
},
|
|
239
|
+
input(schema) {
|
|
240
|
+
config.input = schema;
|
|
241
|
+
return this;
|
|
242
|
+
},
|
|
243
|
+
output(schema) {
|
|
244
|
+
config.output = schema;
|
|
245
|
+
return this;
|
|
246
|
+
},
|
|
247
|
+
handler(fn) {
|
|
248
|
+
config.handler = fn;
|
|
249
|
+
return this;
|
|
250
|
+
},
|
|
251
|
+
options(opts) {
|
|
252
|
+
config.options = opts;
|
|
253
|
+
return this;
|
|
254
|
+
},
|
|
255
|
+
build() {
|
|
256
|
+
if (!config.name || !config.description || !config.category || !config.input || !config.handler) {
|
|
257
|
+
throw new Error('Tool requires id, name, description, category, input, and handler');
|
|
258
|
+
}
|
|
259
|
+
return defineTool(config);
|
|
260
|
+
},
|
|
261
|
+
register() {
|
|
262
|
+
const tool = this.build();
|
|
263
|
+
registry.register(tool);
|
|
264
|
+
return tool;
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|