@tpmjs/types 0.1.1 → 0.2.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/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.
@@ -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<["exact", "fuzzy", "semantic"]>;
7
- }, "strip", z.ZodTypeAny, {
8
- toolId: string;
9
- score: number;
10
- matchType: "exact" | "fuzzy" | "semantic";
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
- }, "strip", z.ZodTypeAny, {
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
- }, "strip", z.ZodTypeAny, {
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
- }, "strip", z.ZodTypeAny, {
31
- name: string;
32
- description: string;
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
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  var ToolParameterSchema = z.object({
5
5
  name: z.string(),
6
6
  description: z.string(),
7
- schema: z.record(z.unknown()),
7
+ schema: z.record(z.string(), z.unknown()),
8
8
  required: z.boolean().default(false)
9
9
  });
10
10
  var ToolSchema = z.object({
@@ -0,0 +1,471 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Valid tool categories for TPMJS registry
5
+ */
6
+ declare const TPMJS_CATEGORIES: readonly ["research", "web", "data", "documentation", "engineering", "security", "statistics", "ops", "agent", "utilities", "html", "compliance", "web-scraping", "data-processing", "file-operations", "communication", "database", "api-integration", "image-processing", "text-analysis", "automation", "ai-ml", "monitoring", "doc", "text"];
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
+ research: "research";
142
+ web: "web";
143
+ data: "data";
144
+ documentation: "documentation";
145
+ engineering: "engineering";
146
+ security: "security";
147
+ statistics: "statistics";
148
+ ops: "ops";
149
+ agent: "agent";
150
+ utilities: "utilities";
151
+ html: "html";
152
+ compliance: "compliance";
153
+ "web-scraping": "web-scraping";
154
+ "data-processing": "data-processing";
155
+ "file-operations": "file-operations";
156
+ communication: "communication";
157
+ database: "database";
158
+ "api-integration": "api-integration";
159
+ "image-processing": "image-processing";
160
+ "text-analysis": "text-analysis";
161
+ automation: "automation";
162
+ "ai-ml": "ai-ml";
163
+ monitoring: "monitoring";
164
+ doc: "doc";
165
+ text: "text";
166
+ }>;
167
+ tools: z.ZodOptional<z.ZodArray<z.ZodPipe<z.ZodObject<{
168
+ name: z.ZodOptional<z.ZodString>;
169
+ exportName: z.ZodOptional<z.ZodString>;
170
+ description: z.ZodOptional<z.ZodString>;
171
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
172
+ name: z.ZodString;
173
+ type: z.ZodString;
174
+ description: z.ZodString;
175
+ required: z.ZodDefault<z.ZodBoolean>;
176
+ default: z.ZodOptional<z.ZodUnknown>;
177
+ }, z.core.$strip>>>;
178
+ returns: z.ZodOptional<z.ZodObject<{
179
+ type: z.ZodString;
180
+ description: z.ZodString;
181
+ }, z.core.$strip>>;
182
+ aiAgent: z.ZodOptional<z.ZodObject<{
183
+ useCase: z.ZodString;
184
+ limitations: z.ZodOptional<z.ZodString>;
185
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
186
+ }, z.core.$strip>>;
187
+ }, z.core.$strip>, z.ZodTransform<{
188
+ name: string;
189
+ description: string | undefined;
190
+ parameters: {
191
+ name: string;
192
+ type: string;
193
+ description: string;
194
+ required: boolean;
195
+ default?: unknown;
196
+ }[] | undefined;
197
+ returns: {
198
+ type: string;
199
+ description: string;
200
+ } | undefined;
201
+ aiAgent: {
202
+ useCase: string;
203
+ limitations?: string | undefined;
204
+ examples?: string[] | undefined;
205
+ } | undefined;
206
+ }, {
207
+ name?: string | undefined;
208
+ exportName?: string | undefined;
209
+ description?: string | undefined;
210
+ parameters?: {
211
+ name: string;
212
+ type: string;
213
+ description: string;
214
+ required: boolean;
215
+ default?: unknown;
216
+ }[] | undefined;
217
+ returns?: {
218
+ type: string;
219
+ description: string;
220
+ } | undefined;
221
+ aiAgent?: {
222
+ useCase: string;
223
+ limitations?: string | undefined;
224
+ examples?: string[] | undefined;
225
+ } | undefined;
226
+ }>>>>;
227
+ env: z.ZodOptional<z.ZodArray<z.ZodObject<{
228
+ name: z.ZodString;
229
+ description: z.ZodString;
230
+ required: z.ZodDefault<z.ZodBoolean>;
231
+ default: z.ZodOptional<z.ZodString>;
232
+ }, z.core.$strip>>>;
233
+ frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
234
+ "vercel-ai": "vercel-ai";
235
+ langchain: "langchain";
236
+ llamaindex: "llamaindex";
237
+ haystack: "haystack";
238
+ "semantic-kernel": "semantic-kernel";
239
+ }>>>;
240
+ }, z.core.$strip>;
241
+ type TpmjsMultiTool = z.infer<typeof TpmjsMultiToolSchema>;
242
+ /**
243
+ * Legacy minimal tier schema - DEPRECATED
244
+ * Kept for backward compatibility with auto-migration
245
+ */
246
+ declare const TpmjsLegacyMinimalSchema: z.ZodObject<{
247
+ category: z.ZodEnum<{
248
+ research: "research";
249
+ web: "web";
250
+ data: "data";
251
+ documentation: "documentation";
252
+ engineering: "engineering";
253
+ security: "security";
254
+ statistics: "statistics";
255
+ ops: "ops";
256
+ agent: "agent";
257
+ utilities: "utilities";
258
+ html: "html";
259
+ compliance: "compliance";
260
+ "web-scraping": "web-scraping";
261
+ "data-processing": "data-processing";
262
+ "file-operations": "file-operations";
263
+ communication: "communication";
264
+ database: "database";
265
+ "api-integration": "api-integration";
266
+ "image-processing": "image-processing";
267
+ "text-analysis": "text-analysis";
268
+ automation: "automation";
269
+ "ai-ml": "ai-ml";
270
+ monitoring: "monitoring";
271
+ doc: "doc";
272
+ text: "text";
273
+ }>;
274
+ description: z.ZodString;
275
+ }, z.core.$strip>;
276
+ type TpmjsLegacyMinimal = z.infer<typeof TpmjsLegacyMinimalSchema>;
277
+ /**
278
+ * Legacy rich tier schema - DEPRECATED
279
+ * Kept for backward compatibility with auto-migration
280
+ */
281
+ declare const TpmjsLegacyRichSchema: z.ZodObject<{
282
+ category: z.ZodEnum<{
283
+ research: "research";
284
+ web: "web";
285
+ data: "data";
286
+ documentation: "documentation";
287
+ engineering: "engineering";
288
+ security: "security";
289
+ statistics: "statistics";
290
+ ops: "ops";
291
+ agent: "agent";
292
+ utilities: "utilities";
293
+ html: "html";
294
+ compliance: "compliance";
295
+ "web-scraping": "web-scraping";
296
+ "data-processing": "data-processing";
297
+ "file-operations": "file-operations";
298
+ communication: "communication";
299
+ database: "database";
300
+ "api-integration": "api-integration";
301
+ "image-processing": "image-processing";
302
+ "text-analysis": "text-analysis";
303
+ automation: "automation";
304
+ "ai-ml": "ai-ml";
305
+ monitoring: "monitoring";
306
+ doc: "doc";
307
+ text: "text";
308
+ }>;
309
+ description: z.ZodString;
310
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
311
+ name: z.ZodString;
312
+ type: z.ZodString;
313
+ description: z.ZodString;
314
+ required: z.ZodDefault<z.ZodBoolean>;
315
+ default: z.ZodOptional<z.ZodUnknown>;
316
+ }, z.core.$strip>>>;
317
+ returns: z.ZodOptional<z.ZodObject<{
318
+ type: z.ZodString;
319
+ description: z.ZodString;
320
+ }, z.core.$strip>>;
321
+ env: z.ZodOptional<z.ZodArray<z.ZodObject<{
322
+ name: z.ZodString;
323
+ description: z.ZodString;
324
+ required: z.ZodDefault<z.ZodBoolean>;
325
+ default: z.ZodOptional<z.ZodString>;
326
+ }, z.core.$strip>>>;
327
+ frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
328
+ "vercel-ai": "vercel-ai";
329
+ langchain: "langchain";
330
+ llamaindex: "llamaindex";
331
+ haystack: "haystack";
332
+ "semantic-kernel": "semantic-kernel";
333
+ }>>>;
334
+ aiAgent: z.ZodOptional<z.ZodObject<{
335
+ useCase: z.ZodString;
336
+ limitations: z.ZodOptional<z.ZodString>;
337
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
338
+ }, z.core.$strip>>;
339
+ }, z.core.$strip>;
340
+ type TpmjsLegacyRich = z.infer<typeof TpmjsLegacyRichSchema>;
341
+ /**
342
+ * Union type for legacy formats
343
+ */
344
+ type TpmjsLegacy = TpmjsLegacyMinimal | TpmjsLegacyRich;
345
+ /**
346
+ * Union type for all formats (new multi-tool + legacy)
347
+ */
348
+ type TpmjsField = TpmjsMultiTool | TpmjsLegacy;
349
+ type TpmjsMinimal = TpmjsLegacyMinimal;
350
+ type TpmjsRich = TpmjsLegacyRich;
351
+ declare const TpmjsMinimalSchema: z.ZodObject<{
352
+ category: z.ZodEnum<{
353
+ research: "research";
354
+ web: "web";
355
+ data: "data";
356
+ documentation: "documentation";
357
+ engineering: "engineering";
358
+ security: "security";
359
+ statistics: "statistics";
360
+ ops: "ops";
361
+ agent: "agent";
362
+ utilities: "utilities";
363
+ html: "html";
364
+ compliance: "compliance";
365
+ "web-scraping": "web-scraping";
366
+ "data-processing": "data-processing";
367
+ "file-operations": "file-operations";
368
+ communication: "communication";
369
+ database: "database";
370
+ "api-integration": "api-integration";
371
+ "image-processing": "image-processing";
372
+ "text-analysis": "text-analysis";
373
+ automation: "automation";
374
+ "ai-ml": "ai-ml";
375
+ monitoring: "monitoring";
376
+ doc: "doc";
377
+ text: "text";
378
+ }>;
379
+ description: z.ZodString;
380
+ }, z.core.$strip>;
381
+ declare const TpmjsRichSchema: z.ZodObject<{
382
+ category: z.ZodEnum<{
383
+ research: "research";
384
+ web: "web";
385
+ data: "data";
386
+ documentation: "documentation";
387
+ engineering: "engineering";
388
+ security: "security";
389
+ statistics: "statistics";
390
+ ops: "ops";
391
+ agent: "agent";
392
+ utilities: "utilities";
393
+ html: "html";
394
+ compliance: "compliance";
395
+ "web-scraping": "web-scraping";
396
+ "data-processing": "data-processing";
397
+ "file-operations": "file-operations";
398
+ communication: "communication";
399
+ database: "database";
400
+ "api-integration": "api-integration";
401
+ "image-processing": "image-processing";
402
+ "text-analysis": "text-analysis";
403
+ automation: "automation";
404
+ "ai-ml": "ai-ml";
405
+ monitoring: "monitoring";
406
+ doc: "doc";
407
+ text: "text";
408
+ }>;
409
+ description: z.ZodString;
410
+ parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
411
+ name: z.ZodString;
412
+ type: z.ZodString;
413
+ description: z.ZodString;
414
+ required: z.ZodDefault<z.ZodBoolean>;
415
+ default: z.ZodOptional<z.ZodUnknown>;
416
+ }, z.core.$strip>>>;
417
+ returns: z.ZodOptional<z.ZodObject<{
418
+ type: z.ZodString;
419
+ description: z.ZodString;
420
+ }, z.core.$strip>>;
421
+ env: z.ZodOptional<z.ZodArray<z.ZodObject<{
422
+ name: z.ZodString;
423
+ description: z.ZodString;
424
+ required: z.ZodDefault<z.ZodBoolean>;
425
+ default: z.ZodOptional<z.ZodString>;
426
+ }, z.core.$strip>>>;
427
+ frameworks: z.ZodOptional<z.ZodArray<z.ZodEnum<{
428
+ "vercel-ai": "vercel-ai";
429
+ langchain: "langchain";
430
+ llamaindex: "llamaindex";
431
+ haystack: "haystack";
432
+ "semantic-kernel": "semantic-kernel";
433
+ }>>>;
434
+ aiAgent: z.ZodOptional<z.ZodObject<{
435
+ useCase: z.ZodString;
436
+ limitations: z.ZodOptional<z.ZodString>;
437
+ examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
438
+ }, z.core.$strip>>;
439
+ }, z.core.$strip>;
440
+ /**
441
+ * Extended validation result type for multi-tool support
442
+ */
443
+ interface ValidationResult {
444
+ valid: boolean;
445
+ tier: 'minimal' | 'rich' | null;
446
+ data?: TpmjsField;
447
+ errors?: z.ZodError;
448
+ packageData?: {
449
+ category: TpmjsCategory;
450
+ env?: TpmjsEnv[];
451
+ frameworks?: string[];
452
+ };
453
+ tools?: TpmjsToolDefinition[];
454
+ wasLegacyFormat?: boolean;
455
+ needsAutoDiscovery?: boolean;
456
+ }
457
+ /**
458
+ * Validates a tpmjs field and determines its tier
459
+ * Supports both new multi-tool format and legacy single-tool format with auto-migration
460
+ */
461
+ declare function validateTpmjsField(tpmjs: unknown): ValidationResult;
462
+ /**
463
+ * Type guard for minimal tier
464
+ */
465
+ declare function isTpmjsMinimal(tpmjs: unknown): tpmjs is TpmjsMinimal;
466
+ /**
467
+ * Type guard for rich tier
468
+ */
469
+ declare function isTpmjsRich(tpmjs: unknown): tpmjs is TpmjsRich;
470
+
471
+ 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,184 @@
1
+ import { z } from 'zod';
2
+
3
+ // src/tpmjs.ts
4
+ var TPMJS_CATEGORIES = [
5
+ // Core categories
6
+ "research",
7
+ "web",
8
+ "data",
9
+ "documentation",
10
+ "engineering",
11
+ "security",
12
+ "statistics",
13
+ "ops",
14
+ "agent",
15
+ "utilities",
16
+ "html",
17
+ "compliance",
18
+ // Legacy categories (kept for backward compatibility)
19
+ "web-scraping",
20
+ "data-processing",
21
+ "file-operations",
22
+ "communication",
23
+ "database",
24
+ "api-integration",
25
+ "image-processing",
26
+ "text-analysis",
27
+ "automation",
28
+ "ai-ml",
29
+ "monitoring",
30
+ // Aliases
31
+ "doc",
32
+ "text"
33
+ ];
34
+ var TpmjsParameterSchema = z.object({
35
+ name: z.string().min(1),
36
+ type: z.string().min(1),
37
+ description: z.string().min(1),
38
+ required: z.boolean().default(false),
39
+ default: z.unknown().optional()
40
+ });
41
+ var TpmjsReturnsSchema = z.object({
42
+ type: z.string().min(1),
43
+ description: z.string().min(1)
44
+ });
45
+ var TpmjsEnvSchema = z.object({
46
+ name: z.string().min(1),
47
+ description: z.string().min(1),
48
+ required: z.boolean().default(true),
49
+ default: z.string().optional()
50
+ });
51
+ var TpmjsAiAgentSchema = z.object({
52
+ useCase: z.string().min(10),
53
+ limitations: z.string().optional(),
54
+ examples: z.array(z.string()).optional()
55
+ });
56
+ var TpmjsToolDefinitionSchema = z.object({
57
+ // Required: The export name of the tool from the package
58
+ // Accepts both 'name' and legacy 'exportName' field
59
+ name: z.string().min(1).optional(),
60
+ // @deprecated - renamed to 'name', kept for backward compatibility
61
+ exportName: z.string().min(1).optional(),
62
+ // Optional - auto-extracted from tool if not provided
63
+ description: z.string().min(20, "Description must be at least 20 characters").max(500).optional(),
64
+ // @deprecated - now auto-extracted from tool's inputSchema
65
+ parameters: z.array(TpmjsParameterSchema).optional(),
66
+ // @deprecated - now auto-extracted from tool
67
+ returns: TpmjsReturnsSchema.optional(),
68
+ // @deprecated - now auto-extracted from tool
69
+ aiAgent: TpmjsAiAgentSchema.optional()
70
+ }).transform((data) => ({
71
+ // Transform exportName to name for backward compatibility
72
+ name: data.name || data.exportName || "",
73
+ description: data.description,
74
+ parameters: data.parameters,
75
+ returns: data.returns,
76
+ aiAgent: data.aiAgent
77
+ })).refine((data) => data.name.length > 0, {
78
+ message: "Either name or exportName is required",
79
+ path: ["name"]
80
+ });
81
+ var TpmjsMultiToolSchema = z.object({
82
+ category: z.enum(TPMJS_CATEGORIES, {
83
+ message: `Category must be one of: ${TPMJS_CATEGORIES.join(", ")}`
84
+ }),
85
+ // Optional - if not provided, tools are auto-discovered from package exports
86
+ tools: z.array(TpmjsToolDefinitionSchema).optional(),
87
+ env: z.array(TpmjsEnvSchema).optional(),
88
+ frameworks: z.array(z.enum(["vercel-ai", "langchain", "llamaindex", "haystack", "semantic-kernel"])).optional()
89
+ });
90
+ var TpmjsLegacyMinimalSchema = z.object({
91
+ category: z.enum(TPMJS_CATEGORIES, {
92
+ message: `Category must be one of: ${TPMJS_CATEGORIES.join(", ")}`
93
+ }),
94
+ description: z.string().min(20, "Description must be at least 20 characters").max(500)
95
+ });
96
+ var TpmjsLegacyRichSchema = TpmjsLegacyMinimalSchema.extend({
97
+ parameters: z.array(TpmjsParameterSchema).optional(),
98
+ returns: TpmjsReturnsSchema.optional(),
99
+ env: z.array(TpmjsEnvSchema).optional(),
100
+ frameworks: z.array(z.enum(["vercel-ai", "langchain", "llamaindex", "haystack", "semantic-kernel"])).optional(),
101
+ aiAgent: TpmjsAiAgentSchema.optional()
102
+ });
103
+ var TpmjsMinimalSchema = TpmjsLegacyMinimalSchema;
104
+ var TpmjsRichSchema = TpmjsLegacyRichSchema;
105
+ function validateTpmjsField(tpmjs) {
106
+ const multiResult = TpmjsMultiToolSchema.safeParse(tpmjs);
107
+ if (multiResult.success) {
108
+ const data = multiResult.data;
109
+ const needsAutoDiscovery = !data.tools || data.tools.length === 0;
110
+ const hasRichFields = (data.tools?.some((tool) => tool.parameters || tool.returns || tool.aiAgent) ?? false) || data.env || data.frameworks;
111
+ return {
112
+ valid: true,
113
+ tier: hasRichFields ? "rich" : "minimal",
114
+ data,
115
+ packageData: {
116
+ category: data.category,
117
+ env: data.env,
118
+ frameworks: data.frameworks
119
+ },
120
+ tools: data.tools,
121
+ wasLegacyFormat: false,
122
+ needsAutoDiscovery
123
+ };
124
+ }
125
+ const richResult = TpmjsLegacyRichSchema.safeParse(tpmjs);
126
+ if (richResult.success) {
127
+ const legacyData = richResult.data;
128
+ const tool = {
129
+ name: "default",
130
+ description: legacyData.description,
131
+ parameters: legacyData.parameters,
132
+ returns: legacyData.returns,
133
+ aiAgent: legacyData.aiAgent
134
+ };
135
+ const hasRichFields = legacyData.parameters || legacyData.returns || legacyData.env || legacyData.frameworks || legacyData.aiAgent;
136
+ return {
137
+ valid: true,
138
+ tier: hasRichFields ? "rich" : "minimal",
139
+ data: legacyData,
140
+ packageData: {
141
+ category: legacyData.category,
142
+ env: legacyData.env,
143
+ frameworks: legacyData.frameworks
144
+ },
145
+ tools: [tool],
146
+ wasLegacyFormat: true,
147
+ needsAutoDiscovery: false
148
+ };
149
+ }
150
+ const minimalResult = TpmjsLegacyMinimalSchema.safeParse(tpmjs);
151
+ if (minimalResult.success) {
152
+ const tool = {
153
+ name: "default",
154
+ description: minimalResult.data.description,
155
+ parameters: void 0,
156
+ returns: void 0,
157
+ aiAgent: void 0
158
+ };
159
+ return {
160
+ valid: true,
161
+ tier: "minimal",
162
+ data: minimalResult.data,
163
+ packageData: {
164
+ category: minimalResult.data.category
165
+ },
166
+ tools: [tool],
167
+ wasLegacyFormat: true,
168
+ needsAutoDiscovery: false
169
+ };
170
+ }
171
+ return {
172
+ valid: false,
173
+ tier: null,
174
+ errors: multiResult.error
175
+ };
176
+ }
177
+ function isTpmjsMinimal(tpmjs) {
178
+ return TpmjsMinimalSchema.safeParse(tpmjs).success;
179
+ }
180
+ function isTpmjsRich(tpmjs) {
181
+ return TpmjsRichSchema.safeParse(tpmjs).success;
182
+ }
183
+
184
+ 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.1",
3
+ "version": "0.2.0",
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": "^3.24.1"
39
+ "zod": "^4.1.13"
20
40
  },
21
41
  "devDependencies": {
22
42
  "tsup": "^8.3.5",