@tpmjs/types 0.1.1 → 0.1.2
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 +21 -0
- package/dist/registry.d.ts +7 -21
- package/dist/tool.d.ts +4 -50
- package/dist/tool.js +1 -1
- package/dist/tpmjs.d.ts +411 -0
- package/dist/tpmjs.js +169 -0
- package/package.json +22 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 TPMJS
|
|
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/registry.d.ts
CHANGED
|
@@ -3,32 +3,18 @@ import { z } from 'zod';
|
|
|
3
3
|
declare const RegistrySearchResultSchema: z.ZodObject<{
|
|
4
4
|
toolId: z.ZodString;
|
|
5
5
|
score: z.ZodNumber;
|
|
6
|
-
matchType: z.ZodEnum<
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
toolId: string;
|
|
13
|
-
score: number;
|
|
14
|
-
matchType: "exact" | "fuzzy" | "semantic";
|
|
15
|
-
}>;
|
|
6
|
+
matchType: z.ZodEnum<{
|
|
7
|
+
exact: "exact";
|
|
8
|
+
fuzzy: "fuzzy";
|
|
9
|
+
semantic: "semantic";
|
|
10
|
+
}>;
|
|
11
|
+
}, z.core.$strip>;
|
|
16
12
|
declare const RegistrySearchOptionsSchema: z.ZodObject<{
|
|
17
13
|
query: z.ZodString;
|
|
18
14
|
category: z.ZodOptional<z.ZodString>;
|
|
19
15
|
limit: z.ZodDefault<z.ZodNumber>;
|
|
20
16
|
offset: z.ZodDefault<z.ZodNumber>;
|
|
21
|
-
},
|
|
22
|
-
query: string;
|
|
23
|
-
limit: number;
|
|
24
|
-
offset: number;
|
|
25
|
-
category?: string | undefined;
|
|
26
|
-
}, {
|
|
27
|
-
query: string;
|
|
28
|
-
category?: string | undefined;
|
|
29
|
-
limit?: number | undefined;
|
|
30
|
-
offset?: number | undefined;
|
|
31
|
-
}>;
|
|
17
|
+
}, z.core.$strip>;
|
|
32
18
|
type RegistrySearchResult = z.infer<typeof RegistrySearchResultSchema>;
|
|
33
19
|
type RegistrySearchOptions = z.infer<typeof RegistrySearchOptionsSchema>;
|
|
34
20
|
|
package/dist/tool.d.ts
CHANGED
|
@@ -5,17 +5,7 @@ declare const ToolParameterSchema: z.ZodObject<{
|
|
|
5
5
|
description: z.ZodString;
|
|
6
6
|
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
7
7
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
-
},
|
|
9
|
-
name: string;
|
|
10
|
-
description: string;
|
|
11
|
-
schema: Record<string, unknown>;
|
|
12
|
-
required: boolean;
|
|
13
|
-
}, {
|
|
14
|
-
name: string;
|
|
15
|
-
description: string;
|
|
16
|
-
schema: Record<string, unknown>;
|
|
17
|
-
required?: boolean | undefined;
|
|
18
|
-
}>;
|
|
8
|
+
}, z.core.$strip>;
|
|
19
9
|
declare const ToolSchema: z.ZodObject<{
|
|
20
10
|
id: z.ZodString;
|
|
21
11
|
name: z.ZodString;
|
|
@@ -27,45 +17,9 @@ declare const ToolSchema: z.ZodObject<{
|
|
|
27
17
|
description: z.ZodString;
|
|
28
18
|
schema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
29
19
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
schema: Record<string, unknown>;
|
|
34
|
-
required: boolean;
|
|
35
|
-
}, {
|
|
36
|
-
name: string;
|
|
37
|
-
description: string;
|
|
38
|
-
schema: Record<string, unknown>;
|
|
39
|
-
required?: boolean | undefined;
|
|
40
|
-
}>, "many">;
|
|
41
|
-
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
42
|
-
}, "strip", z.ZodTypeAny, {
|
|
43
|
-
name: string;
|
|
44
|
-
description: string;
|
|
45
|
-
id: string;
|
|
46
|
-
category: string;
|
|
47
|
-
version: string;
|
|
48
|
-
parameters: {
|
|
49
|
-
name: string;
|
|
50
|
-
description: string;
|
|
51
|
-
schema: Record<string, unknown>;
|
|
52
|
-
required: boolean;
|
|
53
|
-
}[];
|
|
54
|
-
tags: string[];
|
|
55
|
-
}, {
|
|
56
|
-
name: string;
|
|
57
|
-
description: string;
|
|
58
|
-
id: string;
|
|
59
|
-
category: string;
|
|
60
|
-
version: string;
|
|
61
|
-
parameters: {
|
|
62
|
-
name: string;
|
|
63
|
-
description: string;
|
|
64
|
-
schema: Record<string, unknown>;
|
|
65
|
-
required?: boolean | undefined;
|
|
66
|
-
}[];
|
|
67
|
-
tags?: string[] | undefined;
|
|
68
|
-
}>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
22
|
+
}, z.core.$strip>;
|
|
69
23
|
type Tool = z.infer<typeof ToolSchema>;
|
|
70
24
|
type ToolParameter = z.infer<typeof ToolParameterSchema>;
|
|
71
25
|
|
package/dist/tool.js
CHANGED
package/dist/tpmjs.d.ts
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Valid tool categories for TPMJS registry
|
|
5
|
+
*/
|
|
6
|
+
declare const TPMJS_CATEGORIES: readonly ["web-scraping", "data-processing", "file-operations", "communication", "database", "api-integration", "image-processing", "text-analysis", "automation", "ai-ml", "security", "monitoring", "research"];
|
|
7
|
+
type TpmjsCategory = (typeof TPMJS_CATEGORIES)[number];
|
|
8
|
+
/**
|
|
9
|
+
* Tool parameter schema
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Parameters are now auto-extracted from the tool's inputSchema at runtime.
|
|
12
|
+
* You no longer need to manually specify parameters in your package.json.
|
|
13
|
+
* This schema is kept for backward compatibility as a fallback if auto-extraction fails.
|
|
14
|
+
*/
|
|
15
|
+
declare const TpmjsParameterSchema: z.ZodObject<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
type: z.ZodString;
|
|
18
|
+
description: z.ZodString;
|
|
19
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
20
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
type TpmjsParameter = z.infer<typeof TpmjsParameterSchema>;
|
|
23
|
+
/**
|
|
24
|
+
* Return value schema
|
|
25
|
+
*
|
|
26
|
+
* @deprecated Return type information is now auto-extracted from the tool at runtime.
|
|
27
|
+
* You no longer need to manually specify returns in your package.json.
|
|
28
|
+
*/
|
|
29
|
+
declare const TpmjsReturnsSchema: z.ZodObject<{
|
|
30
|
+
type: z.ZodString;
|
|
31
|
+
description: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
type TpmjsReturns = z.infer<typeof TpmjsReturnsSchema>;
|
|
34
|
+
/**
|
|
35
|
+
* Environment variable schema
|
|
36
|
+
*/
|
|
37
|
+
declare const TpmjsEnvSchema: z.ZodObject<{
|
|
38
|
+
name: z.ZodString;
|
|
39
|
+
description: z.ZodString;
|
|
40
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
41
|
+
default: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
type TpmjsEnv = z.infer<typeof TpmjsEnvSchema>;
|
|
44
|
+
/**
|
|
45
|
+
* AI Agent guidance schema
|
|
46
|
+
*
|
|
47
|
+
* @deprecated AI agent guidance is now auto-extracted from the tool at runtime.
|
|
48
|
+
* You no longer need to manually specify aiAgent in your package.json.
|
|
49
|
+
*/
|
|
50
|
+
declare const TpmjsAiAgentSchema: z.ZodObject<{
|
|
51
|
+
useCase: z.ZodString;
|
|
52
|
+
limitations: z.ZodOptional<z.ZodString>;
|
|
53
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
type TpmjsAiAgent = z.infer<typeof TpmjsAiAgentSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Individual tool definition within a multi-tool package
|
|
58
|
+
*
|
|
59
|
+
* Required fields:
|
|
60
|
+
* - name: The export name of the tool from the package
|
|
61
|
+
*
|
|
62
|
+
* Optional fields (auto-extracted if not provided):
|
|
63
|
+
* - description: A description of what the tool does (20-500 chars) - auto-extracted from tool
|
|
64
|
+
*
|
|
65
|
+
* @deprecated fields (now auto-extracted, kept for backward compatibility):
|
|
66
|
+
* - parameters: Tool input parameters - auto-extracted from inputSchema
|
|
67
|
+
* - returns: Tool return type - auto-extracted from tool
|
|
68
|
+
* - aiAgent: AI agent guidance - auto-extracted from tool
|
|
69
|
+
* - exportName: Renamed to 'name' - kept for backward compatibility with published packages
|
|
70
|
+
*/
|
|
71
|
+
declare const TpmjsToolDefinitionSchema: z.ZodPipe<z.ZodObject<{
|
|
72
|
+
name: z.ZodOptional<z.ZodString>;
|
|
73
|
+
exportName: z.ZodOptional<z.ZodString>;
|
|
74
|
+
description: z.ZodOptional<z.ZodString>;
|
|
75
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
type: z.ZodString;
|
|
78
|
+
description: z.ZodString;
|
|
79
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
80
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
81
|
+
}, z.core.$strip>>>;
|
|
82
|
+
returns: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
type: z.ZodString;
|
|
84
|
+
description: z.ZodString;
|
|
85
|
+
}, z.core.$strip>>;
|
|
86
|
+
aiAgent: z.ZodOptional<z.ZodObject<{
|
|
87
|
+
useCase: z.ZodString;
|
|
88
|
+
limitations: z.ZodOptional<z.ZodString>;
|
|
89
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
|
+
}, z.core.$strip>>;
|
|
91
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
92
|
+
name: string;
|
|
93
|
+
description: string | undefined;
|
|
94
|
+
parameters: {
|
|
95
|
+
name: string;
|
|
96
|
+
type: string;
|
|
97
|
+
description: string;
|
|
98
|
+
required: boolean;
|
|
99
|
+
default?: unknown;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
returns: {
|
|
102
|
+
type: string;
|
|
103
|
+
description: string;
|
|
104
|
+
} | undefined;
|
|
105
|
+
aiAgent: {
|
|
106
|
+
useCase: string;
|
|
107
|
+
limitations?: string | undefined;
|
|
108
|
+
examples?: string[] | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
name?: string | undefined;
|
|
112
|
+
exportName?: string | undefined;
|
|
113
|
+
description?: string | undefined;
|
|
114
|
+
parameters?: {
|
|
115
|
+
name: string;
|
|
116
|
+
type: string;
|
|
117
|
+
description: string;
|
|
118
|
+
required: boolean;
|
|
119
|
+
default?: unknown;
|
|
120
|
+
}[] | undefined;
|
|
121
|
+
returns?: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
} | undefined;
|
|
125
|
+
aiAgent?: {
|
|
126
|
+
useCase: string;
|
|
127
|
+
limitations?: string | undefined;
|
|
128
|
+
examples?: string[] | undefined;
|
|
129
|
+
} | undefined;
|
|
130
|
+
}>>;
|
|
131
|
+
type TpmjsToolDefinition = z.infer<typeof TpmjsToolDefinitionSchema>;
|
|
132
|
+
/**
|
|
133
|
+
* Multi-tool format - NEW SCHEMA
|
|
134
|
+
* Package-level metadata with optional array of tools
|
|
135
|
+
*
|
|
136
|
+
* If tools is not provided, TPMJS will auto-discover exports from the package.
|
|
137
|
+
* Authors can override auto-discovery by providing explicit tool definitions.
|
|
138
|
+
*/
|
|
139
|
+
declare const TpmjsMultiToolSchema: z.ZodObject<{
|
|
140
|
+
category: z.ZodEnum<{
|
|
141
|
+
"web-scraping": "web-scraping";
|
|
142
|
+
"data-processing": "data-processing";
|
|
143
|
+
"file-operations": "file-operations";
|
|
144
|
+
communication: "communication";
|
|
145
|
+
database: "database";
|
|
146
|
+
"api-integration": "api-integration";
|
|
147
|
+
"image-processing": "image-processing";
|
|
148
|
+
"text-analysis": "text-analysis";
|
|
149
|
+
automation: "automation";
|
|
150
|
+
"ai-ml": "ai-ml";
|
|
151
|
+
security: "security";
|
|
152
|
+
monitoring: "monitoring";
|
|
153
|
+
research: "research";
|
|
154
|
+
}>;
|
|
155
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
156
|
+
name: z.ZodOptional<z.ZodString>;
|
|
157
|
+
exportName: z.ZodOptional<z.ZodString>;
|
|
158
|
+
description: z.ZodOptional<z.ZodString>;
|
|
159
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
160
|
+
name: z.ZodString;
|
|
161
|
+
type: z.ZodString;
|
|
162
|
+
description: z.ZodString;
|
|
163
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
164
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
165
|
+
}, z.core.$strip>>>;
|
|
166
|
+
returns: z.ZodOptional<z.ZodObject<{
|
|
167
|
+
type: z.ZodString;
|
|
168
|
+
description: z.ZodString;
|
|
169
|
+
}, z.core.$strip>>;
|
|
170
|
+
aiAgent: z.ZodOptional<z.ZodObject<{
|
|
171
|
+
useCase: z.ZodString;
|
|
172
|
+
limitations: z.ZodOptional<z.ZodString>;
|
|
173
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
176
|
+
name: string;
|
|
177
|
+
description: string | undefined;
|
|
178
|
+
parameters: {
|
|
179
|
+
name: string;
|
|
180
|
+
type: string;
|
|
181
|
+
description: string;
|
|
182
|
+
required: boolean;
|
|
183
|
+
default?: unknown;
|
|
184
|
+
}[] | undefined;
|
|
185
|
+
returns: {
|
|
186
|
+
type: string;
|
|
187
|
+
description: string;
|
|
188
|
+
} | undefined;
|
|
189
|
+
aiAgent: {
|
|
190
|
+
useCase: string;
|
|
191
|
+
limitations?: string | undefined;
|
|
192
|
+
examples?: string[] | undefined;
|
|
193
|
+
} | undefined;
|
|
194
|
+
}, {
|
|
195
|
+
name?: string | undefined;
|
|
196
|
+
exportName?: string | undefined;
|
|
197
|
+
description?: string | undefined;
|
|
198
|
+
parameters?: {
|
|
199
|
+
name: string;
|
|
200
|
+
type: string;
|
|
201
|
+
description: string;
|
|
202
|
+
required: boolean;
|
|
203
|
+
default?: unknown;
|
|
204
|
+
}[] | undefined;
|
|
205
|
+
returns?: {
|
|
206
|
+
type: string;
|
|
207
|
+
description: string;
|
|
208
|
+
} | undefined;
|
|
209
|
+
aiAgent?: {
|
|
210
|
+
useCase: string;
|
|
211
|
+
limitations?: string | undefined;
|
|
212
|
+
examples?: string[] | undefined;
|
|
213
|
+
} | undefined;
|
|
214
|
+
}>>>>;
|
|
215
|
+
env: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
216
|
+
name: z.ZodString;
|
|
217
|
+
description: z.ZodString;
|
|
218
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
219
|
+
default: z.ZodOptional<z.ZodString>;
|
|
220
|
+
}, z.core.$strip>>>;
|
|
221
|
+
frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
222
|
+
"vercel-ai": "vercel-ai";
|
|
223
|
+
langchain: "langchain";
|
|
224
|
+
llamaindex: "llamaindex";
|
|
225
|
+
haystack: "haystack";
|
|
226
|
+
"semantic-kernel": "semantic-kernel";
|
|
227
|
+
}>>>;
|
|
228
|
+
}, z.core.$strip>;
|
|
229
|
+
type TpmjsMultiTool = z.infer<typeof TpmjsMultiToolSchema>;
|
|
230
|
+
/**
|
|
231
|
+
* Legacy minimal tier schema - DEPRECATED
|
|
232
|
+
* Kept for backward compatibility with auto-migration
|
|
233
|
+
*/
|
|
234
|
+
declare const TpmjsLegacyMinimalSchema: z.ZodObject<{
|
|
235
|
+
category: z.ZodEnum<{
|
|
236
|
+
"web-scraping": "web-scraping";
|
|
237
|
+
"data-processing": "data-processing";
|
|
238
|
+
"file-operations": "file-operations";
|
|
239
|
+
communication: "communication";
|
|
240
|
+
database: "database";
|
|
241
|
+
"api-integration": "api-integration";
|
|
242
|
+
"image-processing": "image-processing";
|
|
243
|
+
"text-analysis": "text-analysis";
|
|
244
|
+
automation: "automation";
|
|
245
|
+
"ai-ml": "ai-ml";
|
|
246
|
+
security: "security";
|
|
247
|
+
monitoring: "monitoring";
|
|
248
|
+
research: "research";
|
|
249
|
+
}>;
|
|
250
|
+
description: z.ZodString;
|
|
251
|
+
}, z.core.$strip>;
|
|
252
|
+
type TpmjsLegacyMinimal = z.infer<typeof TpmjsLegacyMinimalSchema>;
|
|
253
|
+
/**
|
|
254
|
+
* Legacy rich tier schema - DEPRECATED
|
|
255
|
+
* Kept for backward compatibility with auto-migration
|
|
256
|
+
*/
|
|
257
|
+
declare const TpmjsLegacyRichSchema: z.ZodObject<{
|
|
258
|
+
category: z.ZodEnum<{
|
|
259
|
+
"web-scraping": "web-scraping";
|
|
260
|
+
"data-processing": "data-processing";
|
|
261
|
+
"file-operations": "file-operations";
|
|
262
|
+
communication: "communication";
|
|
263
|
+
database: "database";
|
|
264
|
+
"api-integration": "api-integration";
|
|
265
|
+
"image-processing": "image-processing";
|
|
266
|
+
"text-analysis": "text-analysis";
|
|
267
|
+
automation: "automation";
|
|
268
|
+
"ai-ml": "ai-ml";
|
|
269
|
+
security: "security";
|
|
270
|
+
monitoring: "monitoring";
|
|
271
|
+
research: "research";
|
|
272
|
+
}>;
|
|
273
|
+
description: z.ZodString;
|
|
274
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
275
|
+
name: z.ZodString;
|
|
276
|
+
type: z.ZodString;
|
|
277
|
+
description: z.ZodString;
|
|
278
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
279
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
280
|
+
}, z.core.$strip>>>;
|
|
281
|
+
returns: z.ZodOptional<z.ZodObject<{
|
|
282
|
+
type: z.ZodString;
|
|
283
|
+
description: z.ZodString;
|
|
284
|
+
}, z.core.$strip>>;
|
|
285
|
+
env: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
286
|
+
name: z.ZodString;
|
|
287
|
+
description: z.ZodString;
|
|
288
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
289
|
+
default: z.ZodOptional<z.ZodString>;
|
|
290
|
+
}, z.core.$strip>>>;
|
|
291
|
+
frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
292
|
+
"vercel-ai": "vercel-ai";
|
|
293
|
+
langchain: "langchain";
|
|
294
|
+
llamaindex: "llamaindex";
|
|
295
|
+
haystack: "haystack";
|
|
296
|
+
"semantic-kernel": "semantic-kernel";
|
|
297
|
+
}>>>;
|
|
298
|
+
aiAgent: z.ZodOptional<z.ZodObject<{
|
|
299
|
+
useCase: z.ZodString;
|
|
300
|
+
limitations: z.ZodOptional<z.ZodString>;
|
|
301
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
302
|
+
}, z.core.$strip>>;
|
|
303
|
+
}, z.core.$strip>;
|
|
304
|
+
type TpmjsLegacyRich = z.infer<typeof TpmjsLegacyRichSchema>;
|
|
305
|
+
/**
|
|
306
|
+
* Union type for legacy formats
|
|
307
|
+
*/
|
|
308
|
+
type TpmjsLegacy = TpmjsLegacyMinimal | TpmjsLegacyRich;
|
|
309
|
+
/**
|
|
310
|
+
* Union type for all formats (new multi-tool + legacy)
|
|
311
|
+
*/
|
|
312
|
+
type TpmjsField = TpmjsMultiTool | TpmjsLegacy;
|
|
313
|
+
type TpmjsMinimal = TpmjsLegacyMinimal;
|
|
314
|
+
type TpmjsRich = TpmjsLegacyRich;
|
|
315
|
+
declare const TpmjsMinimalSchema: z.ZodObject<{
|
|
316
|
+
category: z.ZodEnum<{
|
|
317
|
+
"web-scraping": "web-scraping";
|
|
318
|
+
"data-processing": "data-processing";
|
|
319
|
+
"file-operations": "file-operations";
|
|
320
|
+
communication: "communication";
|
|
321
|
+
database: "database";
|
|
322
|
+
"api-integration": "api-integration";
|
|
323
|
+
"image-processing": "image-processing";
|
|
324
|
+
"text-analysis": "text-analysis";
|
|
325
|
+
automation: "automation";
|
|
326
|
+
"ai-ml": "ai-ml";
|
|
327
|
+
security: "security";
|
|
328
|
+
monitoring: "monitoring";
|
|
329
|
+
research: "research";
|
|
330
|
+
}>;
|
|
331
|
+
description: z.ZodString;
|
|
332
|
+
}, z.core.$strip>;
|
|
333
|
+
declare const TpmjsRichSchema: z.ZodObject<{
|
|
334
|
+
category: z.ZodEnum<{
|
|
335
|
+
"web-scraping": "web-scraping";
|
|
336
|
+
"data-processing": "data-processing";
|
|
337
|
+
"file-operations": "file-operations";
|
|
338
|
+
communication: "communication";
|
|
339
|
+
database: "database";
|
|
340
|
+
"api-integration": "api-integration";
|
|
341
|
+
"image-processing": "image-processing";
|
|
342
|
+
"text-analysis": "text-analysis";
|
|
343
|
+
automation: "automation";
|
|
344
|
+
"ai-ml": "ai-ml";
|
|
345
|
+
security: "security";
|
|
346
|
+
monitoring: "monitoring";
|
|
347
|
+
research: "research";
|
|
348
|
+
}>;
|
|
349
|
+
description: z.ZodString;
|
|
350
|
+
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
351
|
+
name: z.ZodString;
|
|
352
|
+
type: z.ZodString;
|
|
353
|
+
description: z.ZodString;
|
|
354
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
355
|
+
default: z.ZodOptional<z.ZodUnknown>;
|
|
356
|
+
}, z.core.$strip>>>;
|
|
357
|
+
returns: z.ZodOptional<z.ZodObject<{
|
|
358
|
+
type: z.ZodString;
|
|
359
|
+
description: z.ZodString;
|
|
360
|
+
}, z.core.$strip>>;
|
|
361
|
+
env: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
362
|
+
name: z.ZodString;
|
|
363
|
+
description: z.ZodString;
|
|
364
|
+
required: z.ZodDefault<z.ZodBoolean>;
|
|
365
|
+
default: z.ZodOptional<z.ZodString>;
|
|
366
|
+
}, z.core.$strip>>>;
|
|
367
|
+
frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
368
|
+
"vercel-ai": "vercel-ai";
|
|
369
|
+
langchain: "langchain";
|
|
370
|
+
llamaindex: "llamaindex";
|
|
371
|
+
haystack: "haystack";
|
|
372
|
+
"semantic-kernel": "semantic-kernel";
|
|
373
|
+
}>>>;
|
|
374
|
+
aiAgent: z.ZodOptional<z.ZodObject<{
|
|
375
|
+
useCase: z.ZodString;
|
|
376
|
+
limitations: z.ZodOptional<z.ZodString>;
|
|
377
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
378
|
+
}, z.core.$strip>>;
|
|
379
|
+
}, z.core.$strip>;
|
|
380
|
+
/**
|
|
381
|
+
* Extended validation result type for multi-tool support
|
|
382
|
+
*/
|
|
383
|
+
interface ValidationResult {
|
|
384
|
+
valid: boolean;
|
|
385
|
+
tier: 'minimal' | 'rich' | null;
|
|
386
|
+
data?: TpmjsField;
|
|
387
|
+
errors?: z.ZodError;
|
|
388
|
+
packageData?: {
|
|
389
|
+
category: TpmjsCategory;
|
|
390
|
+
env?: TpmjsEnv[];
|
|
391
|
+
frameworks?: string[];
|
|
392
|
+
};
|
|
393
|
+
tools?: TpmjsToolDefinition[];
|
|
394
|
+
wasLegacyFormat?: boolean;
|
|
395
|
+
needsAutoDiscovery?: boolean;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Validates a tpmjs field and determines its tier
|
|
399
|
+
* Supports both new multi-tool format and legacy single-tool format with auto-migration
|
|
400
|
+
*/
|
|
401
|
+
declare function validateTpmjsField(tpmjs: unknown): ValidationResult;
|
|
402
|
+
/**
|
|
403
|
+
* Type guard for minimal tier
|
|
404
|
+
*/
|
|
405
|
+
declare function isTpmjsMinimal(tpmjs: unknown): tpmjs is TpmjsMinimal;
|
|
406
|
+
/**
|
|
407
|
+
* Type guard for rich tier
|
|
408
|
+
*/
|
|
409
|
+
declare function isTpmjsRich(tpmjs: unknown): tpmjs is TpmjsRich;
|
|
410
|
+
|
|
411
|
+
export { TPMJS_CATEGORIES, type TpmjsAiAgent, TpmjsAiAgentSchema, type TpmjsCategory, type TpmjsEnv, TpmjsEnvSchema, type TpmjsField, type TpmjsLegacy, type TpmjsLegacyMinimal, TpmjsLegacyMinimalSchema, type TpmjsLegacyRich, TpmjsLegacyRichSchema, type TpmjsMinimal, TpmjsMinimalSchema, type TpmjsMultiTool, TpmjsMultiToolSchema, type TpmjsParameter, TpmjsParameterSchema, type TpmjsReturns, TpmjsReturnsSchema, type TpmjsRich, TpmjsRichSchema, type TpmjsToolDefinition, TpmjsToolDefinitionSchema, type ValidationResult, isTpmjsMinimal, isTpmjsRich, validateTpmjsField };
|
package/dist/tpmjs.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/tpmjs.ts
|
|
4
|
+
var TPMJS_CATEGORIES = [
|
|
5
|
+
"web-scraping",
|
|
6
|
+
"data-processing",
|
|
7
|
+
"file-operations",
|
|
8
|
+
"communication",
|
|
9
|
+
"database",
|
|
10
|
+
"api-integration",
|
|
11
|
+
"image-processing",
|
|
12
|
+
"text-analysis",
|
|
13
|
+
"automation",
|
|
14
|
+
"ai-ml",
|
|
15
|
+
"security",
|
|
16
|
+
"monitoring",
|
|
17
|
+
"research"
|
|
18
|
+
];
|
|
19
|
+
var TpmjsParameterSchema = z.object({
|
|
20
|
+
name: z.string().min(1),
|
|
21
|
+
type: z.string().min(1),
|
|
22
|
+
description: z.string().min(1),
|
|
23
|
+
required: z.boolean().default(false),
|
|
24
|
+
default: z.unknown().optional()
|
|
25
|
+
});
|
|
26
|
+
var TpmjsReturnsSchema = z.object({
|
|
27
|
+
type: z.string().min(1),
|
|
28
|
+
description: z.string().min(1)
|
|
29
|
+
});
|
|
30
|
+
var TpmjsEnvSchema = z.object({
|
|
31
|
+
name: z.string().min(1),
|
|
32
|
+
description: z.string().min(1),
|
|
33
|
+
required: z.boolean().default(true),
|
|
34
|
+
default: z.string().optional()
|
|
35
|
+
});
|
|
36
|
+
var TpmjsAiAgentSchema = z.object({
|
|
37
|
+
useCase: z.string().min(10),
|
|
38
|
+
limitations: z.string().optional(),
|
|
39
|
+
examples: z.array(z.string()).optional()
|
|
40
|
+
});
|
|
41
|
+
var TpmjsToolDefinitionSchema = z.object({
|
|
42
|
+
// Required: The export name of the tool from the package
|
|
43
|
+
// Accepts both 'name' and legacy 'exportName' field
|
|
44
|
+
name: z.string().min(1).optional(),
|
|
45
|
+
// @deprecated - renamed to 'name', kept for backward compatibility
|
|
46
|
+
exportName: z.string().min(1).optional(),
|
|
47
|
+
// Optional - auto-extracted from tool if not provided
|
|
48
|
+
description: z.string().min(20, "Description must be at least 20 characters").max(500).optional(),
|
|
49
|
+
// @deprecated - now auto-extracted from tool's inputSchema
|
|
50
|
+
parameters: z.array(TpmjsParameterSchema).optional(),
|
|
51
|
+
// @deprecated - now auto-extracted from tool
|
|
52
|
+
returns: TpmjsReturnsSchema.optional(),
|
|
53
|
+
// @deprecated - now auto-extracted from tool
|
|
54
|
+
aiAgent: TpmjsAiAgentSchema.optional()
|
|
55
|
+
}).transform((data) => ({
|
|
56
|
+
// Transform exportName to name for backward compatibility
|
|
57
|
+
name: data.name || data.exportName || "",
|
|
58
|
+
description: data.description,
|
|
59
|
+
parameters: data.parameters,
|
|
60
|
+
returns: data.returns,
|
|
61
|
+
aiAgent: data.aiAgent
|
|
62
|
+
})).refine((data) => data.name.length > 0, {
|
|
63
|
+
message: "Either name or exportName is required",
|
|
64
|
+
path: ["name"]
|
|
65
|
+
});
|
|
66
|
+
var TpmjsMultiToolSchema = z.object({
|
|
67
|
+
category: z.enum(TPMJS_CATEGORIES, {
|
|
68
|
+
message: `Category must be one of: ${TPMJS_CATEGORIES.join(", ")}`
|
|
69
|
+
}),
|
|
70
|
+
// Optional - if not provided, tools are auto-discovered from package exports
|
|
71
|
+
tools: z.array(TpmjsToolDefinitionSchema).optional(),
|
|
72
|
+
env: z.array(TpmjsEnvSchema).optional(),
|
|
73
|
+
frameworks: z.array(z.enum(["vercel-ai", "langchain", "llamaindex", "haystack", "semantic-kernel"])).optional()
|
|
74
|
+
});
|
|
75
|
+
var TpmjsLegacyMinimalSchema = z.object({
|
|
76
|
+
category: z.enum(TPMJS_CATEGORIES, {
|
|
77
|
+
message: `Category must be one of: ${TPMJS_CATEGORIES.join(", ")}`
|
|
78
|
+
}),
|
|
79
|
+
description: z.string().min(20, "Description must be at least 20 characters").max(500)
|
|
80
|
+
});
|
|
81
|
+
var TpmjsLegacyRichSchema = TpmjsLegacyMinimalSchema.extend({
|
|
82
|
+
parameters: z.array(TpmjsParameterSchema).optional(),
|
|
83
|
+
returns: TpmjsReturnsSchema.optional(),
|
|
84
|
+
env: z.array(TpmjsEnvSchema).optional(),
|
|
85
|
+
frameworks: z.array(z.enum(["vercel-ai", "langchain", "llamaindex", "haystack", "semantic-kernel"])).optional(),
|
|
86
|
+
aiAgent: TpmjsAiAgentSchema.optional()
|
|
87
|
+
});
|
|
88
|
+
var TpmjsMinimalSchema = TpmjsLegacyMinimalSchema;
|
|
89
|
+
var TpmjsRichSchema = TpmjsLegacyRichSchema;
|
|
90
|
+
function validateTpmjsField(tpmjs) {
|
|
91
|
+
const multiResult = TpmjsMultiToolSchema.safeParse(tpmjs);
|
|
92
|
+
if (multiResult.success) {
|
|
93
|
+
const data = multiResult.data;
|
|
94
|
+
const needsAutoDiscovery = !data.tools || data.tools.length === 0;
|
|
95
|
+
const hasRichFields = (data.tools?.some((tool) => tool.parameters || tool.returns || tool.aiAgent) ?? false) || data.env || data.frameworks;
|
|
96
|
+
return {
|
|
97
|
+
valid: true,
|
|
98
|
+
tier: hasRichFields ? "rich" : "minimal",
|
|
99
|
+
data,
|
|
100
|
+
packageData: {
|
|
101
|
+
category: data.category,
|
|
102
|
+
env: data.env,
|
|
103
|
+
frameworks: data.frameworks
|
|
104
|
+
},
|
|
105
|
+
tools: data.tools,
|
|
106
|
+
wasLegacyFormat: false,
|
|
107
|
+
needsAutoDiscovery
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
const richResult = TpmjsLegacyRichSchema.safeParse(tpmjs);
|
|
111
|
+
if (richResult.success) {
|
|
112
|
+
const legacyData = richResult.data;
|
|
113
|
+
const tool = {
|
|
114
|
+
name: "default",
|
|
115
|
+
description: legacyData.description,
|
|
116
|
+
parameters: legacyData.parameters,
|
|
117
|
+
returns: legacyData.returns,
|
|
118
|
+
aiAgent: legacyData.aiAgent
|
|
119
|
+
};
|
|
120
|
+
const hasRichFields = legacyData.parameters || legacyData.returns || legacyData.env || legacyData.frameworks || legacyData.aiAgent;
|
|
121
|
+
return {
|
|
122
|
+
valid: true,
|
|
123
|
+
tier: hasRichFields ? "rich" : "minimal",
|
|
124
|
+
data: legacyData,
|
|
125
|
+
packageData: {
|
|
126
|
+
category: legacyData.category,
|
|
127
|
+
env: legacyData.env,
|
|
128
|
+
frameworks: legacyData.frameworks
|
|
129
|
+
},
|
|
130
|
+
tools: [tool],
|
|
131
|
+
wasLegacyFormat: true,
|
|
132
|
+
needsAutoDiscovery: false
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
const minimalResult = TpmjsLegacyMinimalSchema.safeParse(tpmjs);
|
|
136
|
+
if (minimalResult.success) {
|
|
137
|
+
const tool = {
|
|
138
|
+
name: "default",
|
|
139
|
+
description: minimalResult.data.description,
|
|
140
|
+
parameters: void 0,
|
|
141
|
+
returns: void 0,
|
|
142
|
+
aiAgent: void 0
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
valid: true,
|
|
146
|
+
tier: "minimal",
|
|
147
|
+
data: minimalResult.data,
|
|
148
|
+
packageData: {
|
|
149
|
+
category: minimalResult.data.category
|
|
150
|
+
},
|
|
151
|
+
tools: [tool],
|
|
152
|
+
wasLegacyFormat: true,
|
|
153
|
+
needsAutoDiscovery: false
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
valid: false,
|
|
158
|
+
tier: null,
|
|
159
|
+
errors: multiResult.error
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function isTpmjsMinimal(tpmjs) {
|
|
163
|
+
return TpmjsMinimalSchema.safeParse(tpmjs).success;
|
|
164
|
+
}
|
|
165
|
+
function isTpmjsRich(tpmjs) {
|
|
166
|
+
return TpmjsRichSchema.safeParse(tpmjs).success;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export { TPMJS_CATEGORIES, TpmjsAiAgentSchema, TpmjsEnvSchema, TpmjsLegacyMinimalSchema, TpmjsLegacyRichSchema, TpmjsMinimalSchema, TpmjsMultiToolSchema, TpmjsParameterSchema, TpmjsReturnsSchema, TpmjsRichSchema, TpmjsToolDefinitionSchema, isTpmjsMinimal, isTpmjsRich, validateTpmjsField };
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpmjs/types",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Shared TypeScript types and Zod schemas for TPMJS",
|
|
5
|
+
"author": "TPMJS",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/tpmjs/tpmjs.git",
|
|
10
|
+
"directory": "packages/types"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://tpmjs.com",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"tpmjs",
|
|
15
|
+
"typescript",
|
|
16
|
+
"types",
|
|
17
|
+
"zod",
|
|
18
|
+
"schemas"
|
|
19
|
+
],
|
|
4
20
|
"type": "module",
|
|
5
21
|
"exports": {
|
|
6
22
|
"./tool": {
|
|
@@ -10,13 +26,17 @@
|
|
|
10
26
|
"./registry": {
|
|
11
27
|
"types": "./dist/registry.d.ts",
|
|
12
28
|
"default": "./dist/registry.js"
|
|
29
|
+
},
|
|
30
|
+
"./tpmjs": {
|
|
31
|
+
"types": "./dist/tpmjs.d.ts",
|
|
32
|
+
"default": "./dist/tpmjs.js"
|
|
13
33
|
}
|
|
14
34
|
},
|
|
15
35
|
"files": [
|
|
16
36
|
"dist"
|
|
17
37
|
],
|
|
18
38
|
"dependencies": {
|
|
19
|
-
"zod": "^
|
|
39
|
+
"zod": "^4.1.13"
|
|
20
40
|
},
|
|
21
41
|
"devDependencies": {
|
|
22
42
|
"tsup": "^8.3.5",
|