@vertesia/tools-sdk 0.24.0-dev.202601221707
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/LICENSE +13 -0
- package/README.md +122 -0
- package/lib/cjs/InteractionCollection.js +164 -0
- package/lib/cjs/InteractionCollection.js.map +1 -0
- package/lib/cjs/SkillCollection.js +376 -0
- package/lib/cjs/SkillCollection.js.map +1 -0
- package/lib/cjs/ToolCollection.js +228 -0
- package/lib/cjs/ToolCollection.js.map +1 -0
- package/lib/cjs/ToolRegistry.js +111 -0
- package/lib/cjs/ToolRegistry.js.map +1 -0
- package/lib/cjs/auth.js +104 -0
- package/lib/cjs/auth.js.map +1 -0
- package/lib/cjs/build/validate.js +7 -0
- package/lib/cjs/build/validate.js.map +1 -0
- package/lib/cjs/copy-assets.js +84 -0
- package/lib/cjs/copy-assets.js.map +1 -0
- package/lib/cjs/index.js +31 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/server/interactions.js +66 -0
- package/lib/cjs/server/interactions.js.map +1 -0
- package/lib/cjs/server/mcp.js +45 -0
- package/lib/cjs/server/mcp.js.map +1 -0
- package/lib/cjs/server/site.js +30 -0
- package/lib/cjs/server/site.js.map +1 -0
- package/lib/cjs/server/skills.js +114 -0
- package/lib/cjs/server/skills.js.map +1 -0
- package/lib/cjs/server/tools.js +104 -0
- package/lib/cjs/server/tools.js.map +1 -0
- package/lib/cjs/server/types.js +3 -0
- package/lib/cjs/server/types.js.map +1 -0
- package/lib/cjs/server/widgets.js +27 -0
- package/lib/cjs/server/widgets.js.map +1 -0
- package/lib/cjs/server.js +132 -0
- package/lib/cjs/server.js.map +1 -0
- package/lib/cjs/site/styles.js +621 -0
- package/lib/cjs/site/styles.js.map +1 -0
- package/lib/cjs/site/templates.js +968 -0
- package/lib/cjs/site/templates.js.map +1 -0
- package/lib/cjs/types.js +3 -0
- package/lib/cjs/types.js.map +1 -0
- package/lib/cjs/utils.js +31 -0
- package/lib/cjs/utils.js.map +1 -0
- package/lib/esm/InteractionCollection.js +125 -0
- package/lib/esm/InteractionCollection.js.map +1 -0
- package/lib/esm/SkillCollection.js +369 -0
- package/lib/esm/SkillCollection.js.map +1 -0
- package/lib/esm/ToolCollection.js +190 -0
- package/lib/esm/ToolCollection.js.map +1 -0
- package/lib/esm/ToolRegistry.js +106 -0
- package/lib/esm/ToolRegistry.js.map +1 -0
- package/lib/esm/auth.js +97 -0
- package/lib/esm/auth.js.map +1 -0
- package/lib/esm/build/validate.js +4 -0
- package/lib/esm/build/validate.js.map +1 -0
- package/lib/esm/copy-assets.js +81 -0
- package/lib/esm/copy-assets.js.map +1 -0
- package/lib/esm/index.js +11 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/server/interactions.js +63 -0
- package/lib/esm/server/interactions.js.map +1 -0
- package/lib/esm/server/mcp.js +42 -0
- package/lib/esm/server/mcp.js.map +1 -0
- package/lib/esm/server/site.js +27 -0
- package/lib/esm/server/site.js.map +1 -0
- package/lib/esm/server/skills.js +111 -0
- package/lib/esm/server/skills.js.map +1 -0
- package/lib/esm/server/tools.js +101 -0
- package/lib/esm/server/tools.js.map +1 -0
- package/lib/esm/server/types.js +2 -0
- package/lib/esm/server/types.js.map +1 -0
- package/lib/esm/server/widgets.js +24 -0
- package/lib/esm/server/widgets.js.map +1 -0
- package/lib/esm/server.js +128 -0
- package/lib/esm/server.js.map +1 -0
- package/lib/esm/site/styles.js +618 -0
- package/lib/esm/site/styles.js.map +1 -0
- package/lib/esm/site/templates.js +956 -0
- package/lib/esm/site/templates.js.map +1 -0
- package/lib/esm/types.js +2 -0
- package/lib/esm/types.js.map +1 -0
- package/lib/esm/utils.js +26 -0
- package/lib/esm/utils.js.map +1 -0
- package/lib/types/InteractionCollection.d.ts +48 -0
- package/lib/types/InteractionCollection.d.ts.map +1 -0
- package/lib/types/SkillCollection.d.ts +118 -0
- package/lib/types/SkillCollection.d.ts.map +1 -0
- package/lib/types/ToolCollection.d.ts +72 -0
- package/lib/types/ToolCollection.d.ts.map +1 -0
- package/lib/types/ToolRegistry.d.ts +41 -0
- package/lib/types/ToolRegistry.d.ts.map +1 -0
- package/lib/types/auth.d.ts +32 -0
- package/lib/types/auth.d.ts.map +1 -0
- package/lib/types/build/validate.d.ts +2 -0
- package/lib/types/build/validate.d.ts.map +1 -0
- package/lib/types/copy-assets.d.ts +14 -0
- package/lib/types/copy-assets.d.ts.map +1 -0
- package/lib/types/index.d.ts +11 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/server/interactions.d.ts +4 -0
- package/lib/types/server/interactions.d.ts.map +1 -0
- package/lib/types/server/mcp.d.ts +4 -0
- package/lib/types/server/mcp.d.ts.map +1 -0
- package/lib/types/server/site.d.ts +4 -0
- package/lib/types/server/site.d.ts.map +1 -0
- package/lib/types/server/skills.d.ts +4 -0
- package/lib/types/server/skills.d.ts.map +1 -0
- package/lib/types/server/tools.d.ts +4 -0
- package/lib/types/server/tools.d.ts.map +1 -0
- package/lib/types/server/types.d.ts +62 -0
- package/lib/types/server/types.d.ts.map +1 -0
- package/lib/types/server/widgets.d.ts +9 -0
- package/lib/types/server/widgets.d.ts.map +1 -0
- package/lib/types/server.d.ts +27 -0
- package/lib/types/server.d.ts.map +1 -0
- package/lib/types/site/styles.d.ts +5 -0
- package/lib/types/site/styles.d.ts.map +1 -0
- package/lib/types/site/templates.d.ts +54 -0
- package/lib/types/site/templates.d.ts.map +1 -0
- package/lib/types/types.d.ts +280 -0
- package/lib/types/types.d.ts.map +1 -0
- package/lib/types/utils.d.ts +4 -0
- package/lib/types/utils.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/InteractionCollection.ts +143 -0
- package/src/SkillCollection.ts +461 -0
- package/src/ToolCollection.ts +223 -0
- package/src/ToolRegistry.ts +135 -0
- package/src/auth.ts +123 -0
- package/src/build/validate.ts +3 -0
- package/src/copy-assets.ts +104 -0
- package/src/index.ts +12 -0
- package/src/server/interactions.ts +79 -0
- package/src/server/mcp.ts +51 -0
- package/src/server/site.ts +46 -0
- package/src/server/skills.ts +133 -0
- package/src/server/tools.ts +128 -0
- package/src/server/types.ts +65 -0
- package/src/server/widgets.ts +38 -0
- package/src/server.ts +160 -0
- package/src/site/styles.ts +617 -0
- package/src/site/templates.ts +994 -0
- package/src/types.ts +303 -0
- package/src/utils.ts +23 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import type { ToolDefinition, ToolUse } from "@llumiverse/common";
|
|
2
|
+
import { VertesiaClient } from "@vertesia/client";
|
|
3
|
+
import { AuthTokenPayload, ToolExecutionMetadata, ToolResult, ToolResultContent } from "@vertesia/common";
|
|
4
|
+
|
|
5
|
+
export type { ToolExecutionMetadata };
|
|
6
|
+
|
|
7
|
+
export type ICollection<T = any> = CollectionProperties & Iterable<T>
|
|
8
|
+
|
|
9
|
+
export interface CollectionProperties {
|
|
10
|
+
/**
|
|
11
|
+
* A kebab case collection name. Must only contains alphanumeric and dash characters,
|
|
12
|
+
* The name can be used to generate the path where the collection is exposed.
|
|
13
|
+
* Example: my-collection
|
|
14
|
+
*/
|
|
15
|
+
name: string;
|
|
16
|
+
/**
|
|
17
|
+
* Optional title for UI display.
|
|
18
|
+
* If not provided the pascal case version of the name will be used
|
|
19
|
+
*/
|
|
20
|
+
title?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional icon for UI display
|
|
23
|
+
*/
|
|
24
|
+
icon?: string;
|
|
25
|
+
/**
|
|
26
|
+
* A short description
|
|
27
|
+
*/
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ToolExecutionContext {
|
|
32
|
+
/**
|
|
33
|
+
* The raw JWT token to the tool execution request
|
|
34
|
+
*/
|
|
35
|
+
token: string;
|
|
36
|
+
/**
|
|
37
|
+
* The decoded JWT token
|
|
38
|
+
*/
|
|
39
|
+
payload: AuthTokenPayload;
|
|
40
|
+
/**
|
|
41
|
+
* Vertesia client factory using the current auth token.
|
|
42
|
+
* @returns a vertesia client instance
|
|
43
|
+
*/
|
|
44
|
+
getClient: () => Promise<VertesiaClient>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ToolExecutionResult extends ToolResultContent {
|
|
48
|
+
/**
|
|
49
|
+
* Medata can be used to return more info on the tool execution like stats or user messages.
|
|
50
|
+
*/
|
|
51
|
+
meta?: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ToolExecutionResponse extends ToolExecutionResult, ToolResult {
|
|
55
|
+
/**
|
|
56
|
+
* The tool use id of the tool use request. For traceability.
|
|
57
|
+
*/
|
|
58
|
+
tool_use_id: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface ToolExecutionResponseError {
|
|
62
|
+
/**
|
|
63
|
+
* The tool use id of the tool use request. For traceability.
|
|
64
|
+
*/
|
|
65
|
+
tool_use_id: string;
|
|
66
|
+
/**
|
|
67
|
+
* The http status code
|
|
68
|
+
*/
|
|
69
|
+
status: number;
|
|
70
|
+
/**
|
|
71
|
+
* the error message
|
|
72
|
+
*/
|
|
73
|
+
error: string;
|
|
74
|
+
/**
|
|
75
|
+
* Additional context information
|
|
76
|
+
*/
|
|
77
|
+
data?: Record<string, any>;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface ToolExecutionPayload<ParamsT extends Record<string, any>> {
|
|
81
|
+
tool_use: ToolUse<ParamsT>,
|
|
82
|
+
/**
|
|
83
|
+
* Optional metadata related to the current execution request
|
|
84
|
+
*/
|
|
85
|
+
metadata?: ToolExecutionMetadata,
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export type ToolFn<ParamsT extends Record<string, any>> = (payload: ToolExecutionPayload<ParamsT>, context: ToolExecutionContext) => Promise<ToolExecutionResult>;
|
|
89
|
+
|
|
90
|
+
export interface Tool<ParamsT extends Record<string, any>> extends ToolDefinition {
|
|
91
|
+
run: ToolFn<ParamsT>;
|
|
92
|
+
/**
|
|
93
|
+
* Whether this tool is available by default.
|
|
94
|
+
* - true/undefined: Tool is always available to agents
|
|
95
|
+
* - false: Tool is only available when activated by a skill's related_tools
|
|
96
|
+
*/
|
|
97
|
+
default?: boolean;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Tool definition with optional activation control for agent exposure.
|
|
102
|
+
*/
|
|
103
|
+
export interface ToolDefinitionWithDefault extends ToolDefinition {
|
|
104
|
+
/**
|
|
105
|
+
* Whether this tool is available by default.
|
|
106
|
+
* - true/undefined: Tool is always available to agents
|
|
107
|
+
* - false: Tool is only available when activated by a skill's related_tools
|
|
108
|
+
*/
|
|
109
|
+
default?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* For skill tools (learn_*): list of related tool names that become available
|
|
112
|
+
* when this skill is called. Used for dynamic tool discovery.
|
|
113
|
+
*/
|
|
114
|
+
related_tools?: string[];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The interface that should be returned when requesting a collection endpoint using a GET
|
|
119
|
+
*/
|
|
120
|
+
export interface ToolCollectionDefinition {
|
|
121
|
+
title: string;
|
|
122
|
+
description: string;
|
|
123
|
+
src: string;
|
|
124
|
+
tools: ToolDefinitionWithDefault[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export type { ToolDefinition };
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The details of a connection to a MCP server - including the server URL and an authentication token
|
|
131
|
+
*/
|
|
132
|
+
export interface MCPConnectionDetails {
|
|
133
|
+
/**
|
|
134
|
+
* The mcp server name. It will be used to prefix tool names.
|
|
135
|
+
*/
|
|
136
|
+
name: string;
|
|
137
|
+
/**
|
|
138
|
+
* The target mcp server URL
|
|
139
|
+
*/
|
|
140
|
+
url: string;
|
|
141
|
+
/**
|
|
142
|
+
* The bearer authentication token to use when connecting to the mcp server.
|
|
143
|
+
* If an empty string no authentication will be done
|
|
144
|
+
*/
|
|
145
|
+
token: string;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ================== Skill Types ==================
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Content type for skill instructions
|
|
152
|
+
*/
|
|
153
|
+
export type SkillContentType = 'md' | 'jst';
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Context triggers for auto-injection of skills
|
|
157
|
+
*/
|
|
158
|
+
export interface SkillContextTriggers {
|
|
159
|
+
/**
|
|
160
|
+
* Keywords in user input that should trigger this skill
|
|
161
|
+
*/
|
|
162
|
+
keywords?: string[];
|
|
163
|
+
/**
|
|
164
|
+
* If these tools are being used, suggest this skill
|
|
165
|
+
*/
|
|
166
|
+
tool_names?: string[];
|
|
167
|
+
/**
|
|
168
|
+
* Regex patterns to match against input data
|
|
169
|
+
*/
|
|
170
|
+
data_patterns?: string[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Execution configuration for skills that need code execution
|
|
175
|
+
*/
|
|
176
|
+
export interface SkillExecution {
|
|
177
|
+
/**
|
|
178
|
+
* The programming language for execution
|
|
179
|
+
*/
|
|
180
|
+
language: string;
|
|
181
|
+
/**
|
|
182
|
+
* Required packages to install
|
|
183
|
+
*/
|
|
184
|
+
packages?: string[];
|
|
185
|
+
/**
|
|
186
|
+
* System-level packages to install (e.g., apt-get packages)
|
|
187
|
+
*/
|
|
188
|
+
system_packages?: string[];
|
|
189
|
+
/**
|
|
190
|
+
* Code template to execute
|
|
191
|
+
*/
|
|
192
|
+
template?: string;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Skill definition - parsed from SKILL.md or SKILL.jst
|
|
198
|
+
*/
|
|
199
|
+
export interface SkillDefinition {
|
|
200
|
+
/**
|
|
201
|
+
* Unique skill name (kebab-case)
|
|
202
|
+
*/
|
|
203
|
+
name: string;
|
|
204
|
+
/**
|
|
205
|
+
* Display title
|
|
206
|
+
*/
|
|
207
|
+
title?: string;
|
|
208
|
+
/**
|
|
209
|
+
* Short description for discovery
|
|
210
|
+
*/
|
|
211
|
+
description: string;
|
|
212
|
+
/**
|
|
213
|
+
* The skill instructions (markdown or JST template)
|
|
214
|
+
*/
|
|
215
|
+
instructions: string;
|
|
216
|
+
/**
|
|
217
|
+
* Content type: 'md' for static markdown, 'jst' for dynamic templates
|
|
218
|
+
*/
|
|
219
|
+
content_type: SkillContentType;
|
|
220
|
+
/**
|
|
221
|
+
* JSON Schema for skill input parameters.
|
|
222
|
+
* Used when skill is exposed as a tool.
|
|
223
|
+
*/
|
|
224
|
+
input_schema?: {
|
|
225
|
+
type: 'object';
|
|
226
|
+
properties?: Record<string, any>;
|
|
227
|
+
required?: string[];
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Context triggers for auto-injection
|
|
231
|
+
*/
|
|
232
|
+
context_triggers?: SkillContextTriggers;
|
|
233
|
+
/**
|
|
234
|
+
* Execution configuration for code-based skills
|
|
235
|
+
*/
|
|
236
|
+
execution?: SkillExecution;
|
|
237
|
+
/**
|
|
238
|
+
* Related tools that work well with this skill
|
|
239
|
+
*/
|
|
240
|
+
related_tools?: string[];
|
|
241
|
+
/**
|
|
242
|
+
* Scripts bundled with this skill (synced to sandbox when skill is used)
|
|
243
|
+
*/
|
|
244
|
+
scripts?: string[];
|
|
245
|
+
/**
|
|
246
|
+
* The name of the widgets provided by this skill (if any)
|
|
247
|
+
* The name will be used to load the widget dynamically from the agent chat
|
|
248
|
+
* and must match the code block language returned by the LLM (e.g., ```my-widget)
|
|
249
|
+
* which will be rendered using the widget.
|
|
250
|
+
* The widget file must be located in the skill directory under the name {{widget-name}}.tsx.
|
|
251
|
+
*/
|
|
252
|
+
widgets?: string[];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Skill execution payload
|
|
257
|
+
*/
|
|
258
|
+
export interface SkillExecutionPayload {
|
|
259
|
+
/**
|
|
260
|
+
* The skill name to execute
|
|
261
|
+
*/
|
|
262
|
+
skill_name: string;
|
|
263
|
+
/**
|
|
264
|
+
* Data context for JST template rendering
|
|
265
|
+
*/
|
|
266
|
+
data?: Record<string, any>;
|
|
267
|
+
/**
|
|
268
|
+
* Whether to execute the code template (if present)
|
|
269
|
+
*/
|
|
270
|
+
execute?: boolean;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Skill execution result
|
|
275
|
+
*/
|
|
276
|
+
export interface SkillExecutionResult {
|
|
277
|
+
/**
|
|
278
|
+
* The skill name
|
|
279
|
+
*/
|
|
280
|
+
name: string;
|
|
281
|
+
/**
|
|
282
|
+
* Rendered instructions
|
|
283
|
+
*/
|
|
284
|
+
instructions: string;
|
|
285
|
+
/**
|
|
286
|
+
* Execution output (if execute=true and skill has code template)
|
|
287
|
+
*/
|
|
288
|
+
execution_result?: {
|
|
289
|
+
output: string;
|
|
290
|
+
files?: string[];
|
|
291
|
+
is_error: boolean;
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Skill collection definition - returned by GET endpoint
|
|
297
|
+
*/
|
|
298
|
+
export interface SkillCollectionDefinition {
|
|
299
|
+
name: string;
|
|
300
|
+
title: string;
|
|
301
|
+
description: string;
|
|
302
|
+
skills: SkillDefinition[];
|
|
303
|
+
}
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function kebabCaseToTitle(name: string) {
|
|
2
|
+
return name.split('-').map(p => p[0].toUpperCase() + p.substring(1)).join(' ');
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function makeScriptUrl(origin: string, script: string) {
|
|
6
|
+
return join(origin, join("/scripts", script));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function join(left: string, right: string) {
|
|
10
|
+
if (left.endsWith('/')) {
|
|
11
|
+
if (right.startsWith('/')) {
|
|
12
|
+
return left + right.slice(1);
|
|
13
|
+
} else {
|
|
14
|
+
return left + right;
|
|
15
|
+
}
|
|
16
|
+
} else if (right.startsWith('/')) {
|
|
17
|
+
return left + right;
|
|
18
|
+
} else if (right.startsWith('./')) {
|
|
19
|
+
return left + '/' + right.slice(2);
|
|
20
|
+
} else {
|
|
21
|
+
return left + '/' + right;
|
|
22
|
+
}
|
|
23
|
+
}
|