@tpmjs/types 0.2.0 → 0.2.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/dist/agent.d.ts +300 -0
- package/dist/agent.js +206 -0
- package/dist/collection.d.ts +125 -0
- package/dist/collection.js +131 -0
- package/dist/executor.d.ts +127 -0
- package/dist/executor.js +43 -0
- package/dist/tpmjs.d.ts +13 -89
- package/dist/tpmjs.js +2 -14
- package/dist/user.d.ts +54 -0
- package/dist/user.js +81 -0
- package/package.json +19 -3
package/dist/agent.d.ts
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const AIProviderSchema: z.ZodEnum<{
|
|
4
|
+
OPENAI: "OPENAI";
|
|
5
|
+
ANTHROPIC: "ANTHROPIC";
|
|
6
|
+
GOOGLE: "GOOGLE";
|
|
7
|
+
GROQ: "GROQ";
|
|
8
|
+
MISTRAL: "MISTRAL";
|
|
9
|
+
}>;
|
|
10
|
+
declare const MessageRoleSchema: z.ZodEnum<{
|
|
11
|
+
USER: "USER";
|
|
12
|
+
ASSISTANT: "ASSISTANT";
|
|
13
|
+
TOOL: "TOOL";
|
|
14
|
+
SYSTEM: "SYSTEM";
|
|
15
|
+
}>;
|
|
16
|
+
type AIProvider = z.infer<typeof AIProviderSchema>;
|
|
17
|
+
type MessageRole = z.infer<typeof MessageRoleSchema>;
|
|
18
|
+
declare const CreateAgentSchema: z.ZodObject<{
|
|
19
|
+
name: z.ZodString;
|
|
20
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
21
|
+
description: z.ZodOptional<z.ZodString>;
|
|
22
|
+
provider: z.ZodEnum<{
|
|
23
|
+
OPENAI: "OPENAI";
|
|
24
|
+
ANTHROPIC: "ANTHROPIC";
|
|
25
|
+
GOOGLE: "GOOGLE";
|
|
26
|
+
GROQ: "GROQ";
|
|
27
|
+
MISTRAL: "MISTRAL";
|
|
28
|
+
}>;
|
|
29
|
+
modelId: z.ZodString;
|
|
30
|
+
systemPrompt: z.ZodOptional<z.ZodString>;
|
|
31
|
+
temperature: z.ZodDefault<z.ZodNumber>;
|
|
32
|
+
maxToolCallsPerTurn: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
maxMessagesInContext: z.ZodDefault<z.ZodNumber>;
|
|
34
|
+
isPublic: z.ZodDefault<z.ZodBoolean>;
|
|
35
|
+
collectionIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
36
|
+
toolIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
declare const UpdateAgentSchema: z.ZodObject<{
|
|
39
|
+
name: z.ZodOptional<z.ZodString>;
|
|
40
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
41
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
provider: z.ZodOptional<z.ZodEnum<{
|
|
43
|
+
OPENAI: "OPENAI";
|
|
44
|
+
ANTHROPIC: "ANTHROPIC";
|
|
45
|
+
GOOGLE: "GOOGLE";
|
|
46
|
+
GROQ: "GROQ";
|
|
47
|
+
MISTRAL: "MISTRAL";
|
|
48
|
+
}>>;
|
|
49
|
+
modelId: z.ZodOptional<z.ZodString>;
|
|
50
|
+
systemPrompt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
maxToolCallsPerTurn: z.ZodOptional<z.ZodNumber>;
|
|
53
|
+
maxMessagesInContext: z.ZodOptional<z.ZodNumber>;
|
|
54
|
+
isPublic: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
executorType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
56
|
+
default: "default";
|
|
57
|
+
custom_url: "custom_url";
|
|
58
|
+
}>>>;
|
|
59
|
+
executorConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
60
|
+
url: z.ZodString;
|
|
61
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, z.core.$strip>>>;
|
|
63
|
+
envVars: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
declare const AddCollectionToAgentSchema: z.ZodObject<{
|
|
66
|
+
collectionId: z.ZodString;
|
|
67
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
declare const AddToolToAgentSchema: z.ZodObject<{
|
|
70
|
+
toolId: z.ZodString;
|
|
71
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
declare const CloneAgentSchema: z.ZodObject<{
|
|
74
|
+
name: z.ZodOptional<z.ZodString>;
|
|
75
|
+
uid: z.ZodOptional<z.ZodString>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const SUPPORTED_PROVIDERS: readonly ["OPENAI", "ANTHROPIC", "GOOGLE", "GROQ", "MISTRAL"];
|
|
78
|
+
declare const AddApiKeySchema: z.ZodObject<{
|
|
79
|
+
provider: z.ZodEnum<{
|
|
80
|
+
OPENAI: "OPENAI";
|
|
81
|
+
ANTHROPIC: "ANTHROPIC";
|
|
82
|
+
GOOGLE: "GOOGLE";
|
|
83
|
+
GROQ: "GROQ";
|
|
84
|
+
MISTRAL: "MISTRAL";
|
|
85
|
+
}>;
|
|
86
|
+
apiKey: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
declare const ApiKeyInfoSchema: z.ZodObject<{
|
|
89
|
+
provider: z.ZodEnum<{
|
|
90
|
+
OPENAI: "OPENAI";
|
|
91
|
+
ANTHROPIC: "ANTHROPIC";
|
|
92
|
+
GOOGLE: "GOOGLE";
|
|
93
|
+
GROQ: "GROQ";
|
|
94
|
+
MISTRAL: "MISTRAL";
|
|
95
|
+
}>;
|
|
96
|
+
keyHint: z.ZodNullable<z.ZodString>;
|
|
97
|
+
createdAt: z.ZodDate;
|
|
98
|
+
updatedAt: z.ZodDate;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
declare const CreateConversationSchema: z.ZodObject<{
|
|
101
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
102
|
+
title: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
declare const SendMessageSchema: z.ZodObject<{
|
|
105
|
+
message: z.ZodString;
|
|
106
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
107
|
+
}, z.core.$strip>;
|
|
108
|
+
declare const ToolCallSchema: z.ZodObject<{
|
|
109
|
+
id: z.ZodString;
|
|
110
|
+
name: z.ZodString;
|
|
111
|
+
arguments: z.ZodString;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
declare const MessageSchema: z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
role: z.ZodEnum<{
|
|
116
|
+
USER: "USER";
|
|
117
|
+
ASSISTANT: "ASSISTANT";
|
|
118
|
+
TOOL: "TOOL";
|
|
119
|
+
SYSTEM: "SYSTEM";
|
|
120
|
+
}>;
|
|
121
|
+
content: z.ZodString;
|
|
122
|
+
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
123
|
+
id: z.ZodString;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
arguments: z.ZodString;
|
|
126
|
+
}, z.core.$strip>>>;
|
|
127
|
+
toolCallId: z.ZodNullable<z.ZodString>;
|
|
128
|
+
toolName: z.ZodNullable<z.ZodString>;
|
|
129
|
+
toolResult: z.ZodNullable<z.ZodAny>;
|
|
130
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
131
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
132
|
+
createdAt: z.ZodDate;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
declare const AgentSchema: z.ZodObject<{
|
|
135
|
+
id: z.ZodString;
|
|
136
|
+
uid: z.ZodString;
|
|
137
|
+
name: z.ZodString;
|
|
138
|
+
description: z.ZodNullable<z.ZodString>;
|
|
139
|
+
provider: z.ZodEnum<{
|
|
140
|
+
OPENAI: "OPENAI";
|
|
141
|
+
ANTHROPIC: "ANTHROPIC";
|
|
142
|
+
GOOGLE: "GOOGLE";
|
|
143
|
+
GROQ: "GROQ";
|
|
144
|
+
MISTRAL: "MISTRAL";
|
|
145
|
+
}>;
|
|
146
|
+
modelId: z.ZodString;
|
|
147
|
+
systemPrompt: z.ZodNullable<z.ZodString>;
|
|
148
|
+
temperature: z.ZodNumber;
|
|
149
|
+
maxToolCallsPerTurn: z.ZodNumber;
|
|
150
|
+
maxMessagesInContext: z.ZodNumber;
|
|
151
|
+
isPublic: z.ZodBoolean;
|
|
152
|
+
toolCount: z.ZodNumber;
|
|
153
|
+
collectionCount: z.ZodNumber;
|
|
154
|
+
forkCount: z.ZodDefault<z.ZodNumber>;
|
|
155
|
+
forkedFromId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
156
|
+
createdAt: z.ZodDate;
|
|
157
|
+
updatedAt: z.ZodDate;
|
|
158
|
+
}, z.core.$strip>;
|
|
159
|
+
declare const ConversationSchema: z.ZodObject<{
|
|
160
|
+
id: z.ZodString;
|
|
161
|
+
agentId: z.ZodString;
|
|
162
|
+
slug: z.ZodString;
|
|
163
|
+
title: z.ZodNullable<z.ZodString>;
|
|
164
|
+
createdAt: z.ZodDate;
|
|
165
|
+
updatedAt: z.ZodDate;
|
|
166
|
+
messageCount: z.ZodOptional<z.ZodNumber>;
|
|
167
|
+
}, z.core.$strip>;
|
|
168
|
+
declare const ConversationWithMessagesSchema: z.ZodObject<{
|
|
169
|
+
id: z.ZodString;
|
|
170
|
+
agentId: z.ZodString;
|
|
171
|
+
slug: z.ZodString;
|
|
172
|
+
title: z.ZodNullable<z.ZodString>;
|
|
173
|
+
createdAt: z.ZodDate;
|
|
174
|
+
updatedAt: z.ZodDate;
|
|
175
|
+
messageCount: z.ZodOptional<z.ZodNumber>;
|
|
176
|
+
messages: z.ZodArray<z.ZodObject<{
|
|
177
|
+
id: z.ZodString;
|
|
178
|
+
role: z.ZodEnum<{
|
|
179
|
+
USER: "USER";
|
|
180
|
+
ASSISTANT: "ASSISTANT";
|
|
181
|
+
TOOL: "TOOL";
|
|
182
|
+
SYSTEM: "SYSTEM";
|
|
183
|
+
}>;
|
|
184
|
+
content: z.ZodString;
|
|
185
|
+
toolCalls: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
186
|
+
id: z.ZodString;
|
|
187
|
+
name: z.ZodString;
|
|
188
|
+
arguments: z.ZodString;
|
|
189
|
+
}, z.core.$strip>>>;
|
|
190
|
+
toolCallId: z.ZodNullable<z.ZodString>;
|
|
191
|
+
toolName: z.ZodNullable<z.ZodString>;
|
|
192
|
+
toolResult: z.ZodNullable<z.ZodAny>;
|
|
193
|
+
inputTokens: z.ZodNullable<z.ZodNumber>;
|
|
194
|
+
outputTokens: z.ZodNullable<z.ZodNumber>;
|
|
195
|
+
createdAt: z.ZodDate;
|
|
196
|
+
}, z.core.$strip>>;
|
|
197
|
+
}, z.core.$strip>;
|
|
198
|
+
type CreateAgentInput = z.infer<typeof CreateAgentSchema>;
|
|
199
|
+
type UpdateAgentInput = z.infer<typeof UpdateAgentSchema>;
|
|
200
|
+
type AddCollectionToAgentInput = z.infer<typeof AddCollectionToAgentSchema>;
|
|
201
|
+
type AddToolToAgentInput = z.infer<typeof AddToolToAgentSchema>;
|
|
202
|
+
type CloneAgentInput = z.infer<typeof CloneAgentSchema>;
|
|
203
|
+
type AddApiKeyInput = z.infer<typeof AddApiKeySchema>;
|
|
204
|
+
type ApiKeyInfo = z.infer<typeof ApiKeyInfoSchema>;
|
|
205
|
+
type CreateConversationInput = z.infer<typeof CreateConversationSchema>;
|
|
206
|
+
type SendMessageInput = z.infer<typeof SendMessageSchema>;
|
|
207
|
+
type ToolCall = z.infer<typeof ToolCallSchema>;
|
|
208
|
+
type Message = z.infer<typeof MessageSchema>;
|
|
209
|
+
type Agent = z.infer<typeof AgentSchema>;
|
|
210
|
+
type Conversation = z.infer<typeof ConversationSchema>;
|
|
211
|
+
type ConversationWithMessages = z.infer<typeof ConversationWithMessagesSchema>;
|
|
212
|
+
declare const AGENT_LIMITS: {
|
|
213
|
+
readonly MAX_AGENTS_PER_USER: 20;
|
|
214
|
+
readonly MAX_COLLECTIONS_PER_AGENT: 10;
|
|
215
|
+
readonly MAX_TOOLS_PER_AGENT: 50;
|
|
216
|
+
readonly MAX_SYSTEM_PROMPT_LENGTH: 10000;
|
|
217
|
+
readonly MAX_NAME_LENGTH: 100;
|
|
218
|
+
readonly MAX_DESCRIPTION_LENGTH: 500;
|
|
219
|
+
readonly MAX_UID_LENGTH: 50;
|
|
220
|
+
};
|
|
221
|
+
declare const CONVERSATION_LIMITS: {
|
|
222
|
+
readonly MAX_CONVERSATIONS_PER_AGENT: 100;
|
|
223
|
+
readonly MAX_MESSAGE_LENGTH: 50000;
|
|
224
|
+
readonly MAX_TITLE_LENGTH: 200;
|
|
225
|
+
readonly MAX_SLUG_LENGTH: 100;
|
|
226
|
+
};
|
|
227
|
+
declare const PROVIDER_MODELS: {
|
|
228
|
+
readonly OPENAI: readonly [{
|
|
229
|
+
readonly id: "gpt-4o";
|
|
230
|
+
readonly name: "GPT-4o";
|
|
231
|
+
readonly contextWindow: 128000;
|
|
232
|
+
}, {
|
|
233
|
+
readonly id: "gpt-4o-mini";
|
|
234
|
+
readonly name: "GPT-4o Mini";
|
|
235
|
+
readonly contextWindow: 128000;
|
|
236
|
+
}, {
|
|
237
|
+
readonly id: "gpt-4-turbo";
|
|
238
|
+
readonly name: "GPT-4 Turbo";
|
|
239
|
+
readonly contextWindow: 128000;
|
|
240
|
+
}, {
|
|
241
|
+
readonly id: "gpt-3.5-turbo";
|
|
242
|
+
readonly name: "GPT-3.5 Turbo";
|
|
243
|
+
readonly contextWindow: 16385;
|
|
244
|
+
}];
|
|
245
|
+
readonly ANTHROPIC: readonly [{
|
|
246
|
+
readonly id: "claude-3-5-sonnet-20241022";
|
|
247
|
+
readonly name: "Claude 3.5 Sonnet";
|
|
248
|
+
readonly contextWindow: 200000;
|
|
249
|
+
}, {
|
|
250
|
+
readonly id: "claude-3-5-haiku-20241022";
|
|
251
|
+
readonly name: "Claude 3.5 Haiku";
|
|
252
|
+
readonly contextWindow: 200000;
|
|
253
|
+
}, {
|
|
254
|
+
readonly id: "claude-3-opus-20240229";
|
|
255
|
+
readonly name: "Claude 3 Opus";
|
|
256
|
+
readonly contextWindow: 200000;
|
|
257
|
+
}];
|
|
258
|
+
readonly GOOGLE: readonly [{
|
|
259
|
+
readonly id: "gemini-2.0-flash-exp";
|
|
260
|
+
readonly name: "Gemini 2.0 Flash";
|
|
261
|
+
readonly contextWindow: 1000000;
|
|
262
|
+
}, {
|
|
263
|
+
readonly id: "gemini-1.5-pro";
|
|
264
|
+
readonly name: "Gemini 1.5 Pro";
|
|
265
|
+
readonly contextWindow: 1000000;
|
|
266
|
+
}, {
|
|
267
|
+
readonly id: "gemini-1.5-flash";
|
|
268
|
+
readonly name: "Gemini 1.5 Flash";
|
|
269
|
+
readonly contextWindow: 1000000;
|
|
270
|
+
}];
|
|
271
|
+
readonly GROQ: readonly [{
|
|
272
|
+
readonly id: "llama-3.3-70b-versatile";
|
|
273
|
+
readonly name: "Llama 3.3 70B";
|
|
274
|
+
readonly contextWindow: 131072;
|
|
275
|
+
}, {
|
|
276
|
+
readonly id: "llama-3.1-8b-instant";
|
|
277
|
+
readonly name: "Llama 3.1 8B";
|
|
278
|
+
readonly contextWindow: 131072;
|
|
279
|
+
}, {
|
|
280
|
+
readonly id: "mixtral-8x7b-32768";
|
|
281
|
+
readonly name: "Mixtral 8x7B";
|
|
282
|
+
readonly contextWindow: 32768;
|
|
283
|
+
}];
|
|
284
|
+
readonly MISTRAL: readonly [{
|
|
285
|
+
readonly id: "mistral-large-latest";
|
|
286
|
+
readonly name: "Mistral Large";
|
|
287
|
+
readonly contextWindow: 128000;
|
|
288
|
+
}, {
|
|
289
|
+
readonly id: "mistral-small-latest";
|
|
290
|
+
readonly name: "Mistral Small";
|
|
291
|
+
readonly contextWindow: 128000;
|
|
292
|
+
}];
|
|
293
|
+
};
|
|
294
|
+
type ProviderModel = {
|
|
295
|
+
id: string;
|
|
296
|
+
name: string;
|
|
297
|
+
contextWindow: number;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export { AGENT_LIMITS, type AIProvider, AIProviderSchema, type AddApiKeyInput, AddApiKeySchema, type AddCollectionToAgentInput, AddCollectionToAgentSchema, type AddToolToAgentInput, AddToolToAgentSchema, type Agent, AgentSchema, type ApiKeyInfo, ApiKeyInfoSchema, CONVERSATION_LIMITS, type CloneAgentInput, CloneAgentSchema, type Conversation, ConversationSchema, type ConversationWithMessages, ConversationWithMessagesSchema, type CreateAgentInput, CreateAgentSchema, type CreateConversationInput, CreateConversationSchema, type Message, type MessageRole, MessageRoleSchema, MessageSchema, PROVIDER_MODELS, type ProviderModel, SUPPORTED_PROVIDERS, type SendMessageInput, SendMessageSchema, type ToolCall, ToolCallSchema, type UpdateAgentInput, UpdateAgentSchema };
|
package/dist/agent.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/agent.ts
|
|
4
|
+
var ExecutorTypeSchema = z.enum(["default", "custom_url"]);
|
|
5
|
+
var DefaultExecutorConfigSchema = z.object({
|
|
6
|
+
type: z.literal("default")
|
|
7
|
+
});
|
|
8
|
+
var CustomUrlExecutorConfigSchema = z.object({
|
|
9
|
+
type: z.literal("custom_url"),
|
|
10
|
+
/** URL of the custom executor (must be HTTPS in production) */
|
|
11
|
+
url: z.string().url(),
|
|
12
|
+
/** Optional API key for Bearer token authentication */
|
|
13
|
+
apiKey: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
z.discriminatedUnion("type", [
|
|
16
|
+
DefaultExecutorConfigSchema,
|
|
17
|
+
CustomUrlExecutorConfigSchema
|
|
18
|
+
]);
|
|
19
|
+
z.object({
|
|
20
|
+
packageName: z.string().min(1),
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
version: z.string().optional(),
|
|
23
|
+
importUrl: z.string().url().optional(),
|
|
24
|
+
params: z.record(z.string(), z.unknown()),
|
|
25
|
+
env: z.record(z.string(), z.string()).optional()
|
|
26
|
+
});
|
|
27
|
+
z.object({
|
|
28
|
+
success: z.boolean(),
|
|
29
|
+
output: z.unknown().optional(),
|
|
30
|
+
error: z.string().optional(),
|
|
31
|
+
executionTimeMs: z.number()
|
|
32
|
+
});
|
|
33
|
+
z.object({
|
|
34
|
+
status: z.enum(["ok", "degraded", "error"]),
|
|
35
|
+
version: z.string().optional(),
|
|
36
|
+
info: z.record(z.string(), z.unknown()).optional()
|
|
37
|
+
});
|
|
38
|
+
z.object({
|
|
39
|
+
url: z.string().url(),
|
|
40
|
+
apiKey: z.string().optional()
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/agent.ts
|
|
44
|
+
var UID_REGEX = /^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/;
|
|
45
|
+
var ExecutorConfigUpdateSchema = z.object({
|
|
46
|
+
url: z.string().url(),
|
|
47
|
+
apiKey: z.string().optional()
|
|
48
|
+
}).nullable().optional();
|
|
49
|
+
var AIProviderSchema = z.enum(["OPENAI", "ANTHROPIC", "GOOGLE", "GROQ", "MISTRAL"]);
|
|
50
|
+
var MessageRoleSchema = z.enum(["USER", "ASSISTANT", "TOOL", "SYSTEM"]);
|
|
51
|
+
var CreateAgentSchema = z.object({
|
|
52
|
+
name: z.string().min(1, "Name is required").max(100, "Name must be 100 characters or less"),
|
|
53
|
+
uid: z.string().min(1, "UID is required").max(50, "UID must be 50 characters or less").regex(UID_REGEX, "UID must be lowercase alphanumeric with hyphens").optional(),
|
|
54
|
+
description: z.string().max(500, "Description must be 500 characters or less").optional(),
|
|
55
|
+
provider: AIProviderSchema,
|
|
56
|
+
modelId: z.string().min(1, "Model ID is required").max(100),
|
|
57
|
+
systemPrompt: z.string().max(1e4, "System prompt must be 10,000 characters or less").optional(),
|
|
58
|
+
temperature: z.number().min(0).max(2).default(0.7),
|
|
59
|
+
maxToolCallsPerTurn: z.number().int().min(1).max(100).default(20),
|
|
60
|
+
maxMessagesInContext: z.number().int().min(1).max(100).default(10),
|
|
61
|
+
isPublic: z.boolean().default(true),
|
|
62
|
+
collectionIds: z.array(z.string()).optional(),
|
|
63
|
+
toolIds: z.array(z.string()).optional()
|
|
64
|
+
});
|
|
65
|
+
var UpdateAgentSchema = z.object({
|
|
66
|
+
name: z.string().min(1).max(100).optional(),
|
|
67
|
+
uid: z.string().min(1).max(50).regex(UID_REGEX).optional(),
|
|
68
|
+
description: z.string().max(500).nullable().optional(),
|
|
69
|
+
provider: AIProviderSchema.optional(),
|
|
70
|
+
modelId: z.string().min(1).max(100).optional(),
|
|
71
|
+
systemPrompt: z.string().max(1e4).nullable().optional(),
|
|
72
|
+
temperature: z.number().min(0).max(2).optional(),
|
|
73
|
+
maxToolCallsPerTurn: z.number().int().min(1).max(100).optional(),
|
|
74
|
+
maxMessagesInContext: z.number().int().min(1).max(100).optional(),
|
|
75
|
+
isPublic: z.boolean().optional(),
|
|
76
|
+
// Executor configuration
|
|
77
|
+
executorType: ExecutorTypeSchema.nullable().optional(),
|
|
78
|
+
executorConfig: ExecutorConfigUpdateSchema,
|
|
79
|
+
// Tool environment variables
|
|
80
|
+
envVars: z.record(z.string(), z.string()).nullable().optional()
|
|
81
|
+
});
|
|
82
|
+
var AddCollectionToAgentSchema = z.object({
|
|
83
|
+
collectionId: z.string().min(1, "Collection ID is required"),
|
|
84
|
+
position: z.number().int().min(0).optional()
|
|
85
|
+
});
|
|
86
|
+
var AddToolToAgentSchema = z.object({
|
|
87
|
+
toolId: z.string().min(1, "Tool ID is required"),
|
|
88
|
+
position: z.number().int().min(0).optional()
|
|
89
|
+
});
|
|
90
|
+
var CloneAgentSchema = z.object({
|
|
91
|
+
name: z.string().min(1).max(100).optional(),
|
|
92
|
+
// If not provided, will append "(copy)"
|
|
93
|
+
uid: z.string().min(1).max(50).regex(UID_REGEX, "UID must be lowercase alphanumeric with hyphens").optional()
|
|
94
|
+
// If not provided, will generate from name
|
|
95
|
+
});
|
|
96
|
+
var SUPPORTED_PROVIDERS = ["OPENAI", "ANTHROPIC", "GOOGLE", "GROQ", "MISTRAL"];
|
|
97
|
+
var AddApiKeySchema = z.object({
|
|
98
|
+
provider: AIProviderSchema,
|
|
99
|
+
apiKey: z.string().min(10, "API key is required")
|
|
100
|
+
});
|
|
101
|
+
var ApiKeyInfoSchema = z.object({
|
|
102
|
+
provider: AIProviderSchema,
|
|
103
|
+
keyHint: z.string().nullable(),
|
|
104
|
+
createdAt: z.date(),
|
|
105
|
+
updatedAt: z.date()
|
|
106
|
+
});
|
|
107
|
+
var CreateConversationSchema = z.object({
|
|
108
|
+
slug: z.string().min(1).max(100).regex(/^[a-z0-9-]+$/, "Slug must be lowercase alphanumeric with hyphens").optional(),
|
|
109
|
+
title: z.string().max(200).optional()
|
|
110
|
+
});
|
|
111
|
+
var SendMessageSchema = z.object({
|
|
112
|
+
message: z.string().min(1, "Message is required").max(5e4, "Message too long"),
|
|
113
|
+
env: z.record(z.string(), z.string()).optional()
|
|
114
|
+
});
|
|
115
|
+
var ToolCallSchema = z.object({
|
|
116
|
+
id: z.string(),
|
|
117
|
+
name: z.string(),
|
|
118
|
+
arguments: z.string()
|
|
119
|
+
});
|
|
120
|
+
var MessageSchema = z.object({
|
|
121
|
+
id: z.string(),
|
|
122
|
+
role: MessageRoleSchema,
|
|
123
|
+
content: z.string(),
|
|
124
|
+
toolCalls: z.array(ToolCallSchema).nullable(),
|
|
125
|
+
toolCallId: z.string().nullable(),
|
|
126
|
+
toolName: z.string().nullable(),
|
|
127
|
+
toolResult: z.any().nullable(),
|
|
128
|
+
inputTokens: z.number().nullable(),
|
|
129
|
+
outputTokens: z.number().nullable(),
|
|
130
|
+
createdAt: z.date()
|
|
131
|
+
});
|
|
132
|
+
var AgentSchema = z.object({
|
|
133
|
+
id: z.string(),
|
|
134
|
+
uid: z.string(),
|
|
135
|
+
name: z.string(),
|
|
136
|
+
description: z.string().nullable(),
|
|
137
|
+
provider: AIProviderSchema,
|
|
138
|
+
modelId: z.string(),
|
|
139
|
+
systemPrompt: z.string().nullable(),
|
|
140
|
+
temperature: z.number(),
|
|
141
|
+
maxToolCallsPerTurn: z.number(),
|
|
142
|
+
maxMessagesInContext: z.number(),
|
|
143
|
+
isPublic: z.boolean(),
|
|
144
|
+
toolCount: z.number(),
|
|
145
|
+
collectionCount: z.number(),
|
|
146
|
+
forkCount: z.number().default(0),
|
|
147
|
+
forkedFromId: z.string().nullable().optional(),
|
|
148
|
+
createdAt: z.date(),
|
|
149
|
+
updatedAt: z.date()
|
|
150
|
+
});
|
|
151
|
+
var ConversationSchema = z.object({
|
|
152
|
+
id: z.string(),
|
|
153
|
+
agentId: z.string(),
|
|
154
|
+
slug: z.string(),
|
|
155
|
+
title: z.string().nullable(),
|
|
156
|
+
createdAt: z.date(),
|
|
157
|
+
updatedAt: z.date(),
|
|
158
|
+
messageCount: z.number().optional()
|
|
159
|
+
});
|
|
160
|
+
var ConversationWithMessagesSchema = ConversationSchema.extend({
|
|
161
|
+
messages: z.array(MessageSchema)
|
|
162
|
+
});
|
|
163
|
+
var AGENT_LIMITS = {
|
|
164
|
+
MAX_AGENTS_PER_USER: 20,
|
|
165
|
+
MAX_COLLECTIONS_PER_AGENT: 10,
|
|
166
|
+
MAX_TOOLS_PER_AGENT: 50,
|
|
167
|
+
MAX_SYSTEM_PROMPT_LENGTH: 1e4,
|
|
168
|
+
MAX_NAME_LENGTH: 100,
|
|
169
|
+
MAX_DESCRIPTION_LENGTH: 500,
|
|
170
|
+
MAX_UID_LENGTH: 50
|
|
171
|
+
};
|
|
172
|
+
var CONVERSATION_LIMITS = {
|
|
173
|
+
MAX_CONVERSATIONS_PER_AGENT: 100,
|
|
174
|
+
MAX_MESSAGE_LENGTH: 5e4,
|
|
175
|
+
MAX_TITLE_LENGTH: 200,
|
|
176
|
+
MAX_SLUG_LENGTH: 100
|
|
177
|
+
};
|
|
178
|
+
var PROVIDER_MODELS = {
|
|
179
|
+
OPENAI: [
|
|
180
|
+
{ id: "gpt-4o", name: "GPT-4o", contextWindow: 128e3 },
|
|
181
|
+
{ id: "gpt-4o-mini", name: "GPT-4o Mini", contextWindow: 128e3 },
|
|
182
|
+
{ id: "gpt-4-turbo", name: "GPT-4 Turbo", contextWindow: 128e3 },
|
|
183
|
+
{ id: "gpt-3.5-turbo", name: "GPT-3.5 Turbo", contextWindow: 16385 }
|
|
184
|
+
],
|
|
185
|
+
ANTHROPIC: [
|
|
186
|
+
{ id: "claude-3-5-sonnet-20241022", name: "Claude 3.5 Sonnet", contextWindow: 2e5 },
|
|
187
|
+
{ id: "claude-3-5-haiku-20241022", name: "Claude 3.5 Haiku", contextWindow: 2e5 },
|
|
188
|
+
{ id: "claude-3-opus-20240229", name: "Claude 3 Opus", contextWindow: 2e5 }
|
|
189
|
+
],
|
|
190
|
+
GOOGLE: [
|
|
191
|
+
{ id: "gemini-2.0-flash-exp", name: "Gemini 2.0 Flash", contextWindow: 1e6 },
|
|
192
|
+
{ id: "gemini-1.5-pro", name: "Gemini 1.5 Pro", contextWindow: 1e6 },
|
|
193
|
+
{ id: "gemini-1.5-flash", name: "Gemini 1.5 Flash", contextWindow: 1e6 }
|
|
194
|
+
],
|
|
195
|
+
GROQ: [
|
|
196
|
+
{ id: "llama-3.3-70b-versatile", name: "Llama 3.3 70B", contextWindow: 131072 },
|
|
197
|
+
{ id: "llama-3.1-8b-instant", name: "Llama 3.1 8B", contextWindow: 131072 },
|
|
198
|
+
{ id: "mixtral-8x7b-32768", name: "Mixtral 8x7B", contextWindow: 32768 }
|
|
199
|
+
],
|
|
200
|
+
MISTRAL: [
|
|
201
|
+
{ id: "mistral-large-latest", name: "Mistral Large", contextWindow: 128e3 },
|
|
202
|
+
{ id: "mistral-small-latest", name: "Mistral Small", contextWindow: 128e3 }
|
|
203
|
+
]
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export { AGENT_LIMITS, AIProviderSchema, AddApiKeySchema, AddCollectionToAgentSchema, AddToolToAgentSchema, AgentSchema, ApiKeyInfoSchema, CONVERSATION_LIMITS, CloneAgentSchema, ConversationSchema, ConversationWithMessagesSchema, CreateAgentSchema, CreateConversationSchema, MessageRoleSchema, MessageSchema, PROVIDER_MODELS, SUPPORTED_PROVIDERS, SendMessageSchema, ToolCallSchema, UpdateAgentSchema };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const CreateCollectionSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
description: z.ZodOptional<z.ZodString>;
|
|
6
|
+
isPublic: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
declare const UpdateCollectionSchema: z.ZodObject<{
|
|
9
|
+
name: z.ZodOptional<z.ZodString>;
|
|
10
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
11
|
+
isPublic: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
executorType: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
13
|
+
default: "default";
|
|
14
|
+
custom_url: "custom_url";
|
|
15
|
+
}>>>;
|
|
16
|
+
executorConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
17
|
+
url: z.ZodString;
|
|
18
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>>>;
|
|
20
|
+
envVars: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
declare const AddToolToCollectionSchema: z.ZodObject<{
|
|
23
|
+
toolId: z.ZodString;
|
|
24
|
+
note: z.ZodOptional<z.ZodString>;
|
|
25
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
declare const UpdateCollectionToolSchema: z.ZodObject<{
|
|
28
|
+
note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
29
|
+
position: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
declare const ReorderToolsSchema: z.ZodObject<{
|
|
32
|
+
toolIds: z.ZodArray<z.ZodString>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
declare const AddBridgeToolToCollectionSchema: z.ZodObject<{
|
|
35
|
+
serverId: z.ZodString;
|
|
36
|
+
toolName: z.ZodString;
|
|
37
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
38
|
+
note: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
declare const UpdateCollectionBridgeToolSchema: z.ZodObject<{
|
|
41
|
+
displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
note: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
declare const CloneCollectionSchema: z.ZodObject<{
|
|
45
|
+
name: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
declare const CollectionSchema: z.ZodObject<{
|
|
48
|
+
id: z.ZodString;
|
|
49
|
+
name: z.ZodString;
|
|
50
|
+
slug: z.ZodNullable<z.ZodString>;
|
|
51
|
+
description: z.ZodNullable<z.ZodString>;
|
|
52
|
+
isPublic: z.ZodBoolean;
|
|
53
|
+
toolCount: z.ZodNumber;
|
|
54
|
+
forkCount: z.ZodDefault<z.ZodNumber>;
|
|
55
|
+
forkedFromId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
56
|
+
createdAt: z.ZodDate;
|
|
57
|
+
updatedAt: z.ZodDate;
|
|
58
|
+
}, z.core.$strip>;
|
|
59
|
+
declare const CollectionToolSchema: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
toolId: z.ZodString;
|
|
62
|
+
position: z.ZodNumber;
|
|
63
|
+
note: z.ZodNullable<z.ZodString>;
|
|
64
|
+
addedAt: z.ZodDate;
|
|
65
|
+
tool: z.ZodObject<{
|
|
66
|
+
id: z.ZodString;
|
|
67
|
+
name: z.ZodString;
|
|
68
|
+
description: z.ZodString;
|
|
69
|
+
package: z.ZodObject<{
|
|
70
|
+
id: z.ZodString;
|
|
71
|
+
npmPackageName: z.ZodString;
|
|
72
|
+
category: z.ZodString;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
declare const CollectionWithToolsSchema: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
slug: z.ZodNullable<z.ZodString>;
|
|
80
|
+
description: z.ZodNullable<z.ZodString>;
|
|
81
|
+
isPublic: z.ZodBoolean;
|
|
82
|
+
toolCount: z.ZodNumber;
|
|
83
|
+
forkCount: z.ZodDefault<z.ZodNumber>;
|
|
84
|
+
forkedFromId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
85
|
+
createdAt: z.ZodDate;
|
|
86
|
+
updatedAt: z.ZodDate;
|
|
87
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
88
|
+
id: z.ZodString;
|
|
89
|
+
toolId: z.ZodString;
|
|
90
|
+
position: z.ZodNumber;
|
|
91
|
+
note: z.ZodNullable<z.ZodString>;
|
|
92
|
+
addedAt: z.ZodDate;
|
|
93
|
+
tool: z.ZodObject<{
|
|
94
|
+
id: z.ZodString;
|
|
95
|
+
name: z.ZodString;
|
|
96
|
+
description: z.ZodString;
|
|
97
|
+
package: z.ZodObject<{
|
|
98
|
+
id: z.ZodString;
|
|
99
|
+
npmPackageName: z.ZodString;
|
|
100
|
+
category: z.ZodString;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
}, z.core.$strip>>;
|
|
104
|
+
}, z.core.$strip>;
|
|
105
|
+
type CreateCollectionInput = z.infer<typeof CreateCollectionSchema>;
|
|
106
|
+
type UpdateCollectionInput = z.infer<typeof UpdateCollectionSchema>;
|
|
107
|
+
type AddToolToCollectionInput = z.infer<typeof AddToolToCollectionSchema>;
|
|
108
|
+
type UpdateCollectionToolInput = z.infer<typeof UpdateCollectionToolSchema>;
|
|
109
|
+
type ReorderToolsInput = z.infer<typeof ReorderToolsSchema>;
|
|
110
|
+
type CloneCollectionInput = z.infer<typeof CloneCollectionSchema>;
|
|
111
|
+
type AddBridgeToolToCollectionInput = z.infer<typeof AddBridgeToolToCollectionSchema>;
|
|
112
|
+
type UpdateCollectionBridgeToolInput = z.infer<typeof UpdateCollectionBridgeToolSchema>;
|
|
113
|
+
type Collection = z.infer<typeof CollectionSchema>;
|
|
114
|
+
type CollectionTool = z.infer<typeof CollectionToolSchema>;
|
|
115
|
+
type CollectionWithTools = z.infer<typeof CollectionWithToolsSchema>;
|
|
116
|
+
declare const COLLECTION_LIMITS: {
|
|
117
|
+
readonly MAX_COLLECTIONS_PER_USER: 50;
|
|
118
|
+
readonly MAX_TOOLS_PER_COLLECTION: 100;
|
|
119
|
+
readonly MAX_BRIDGE_TOOLS_PER_COLLECTION: 50;
|
|
120
|
+
readonly MAX_NAME_LENGTH: 100;
|
|
121
|
+
readonly MAX_DESCRIPTION_LENGTH: 500;
|
|
122
|
+
readonly MAX_NOTE_LENGTH: 500;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export { type AddBridgeToolToCollectionInput, AddBridgeToolToCollectionSchema, type AddToolToCollectionInput, AddToolToCollectionSchema, COLLECTION_LIMITS, type CloneCollectionInput, CloneCollectionSchema, type Collection, CollectionSchema, type CollectionTool, CollectionToolSchema, type CollectionWithTools, CollectionWithToolsSchema, type CreateCollectionInput, CreateCollectionSchema, type ReorderToolsInput, ReorderToolsSchema, type UpdateCollectionBridgeToolInput, UpdateCollectionBridgeToolSchema, type UpdateCollectionInput, UpdateCollectionSchema, type UpdateCollectionToolInput, UpdateCollectionToolSchema };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/collection.ts
|
|
4
|
+
var ExecutorTypeSchema = z.enum(["default", "custom_url"]);
|
|
5
|
+
var DefaultExecutorConfigSchema = z.object({
|
|
6
|
+
type: z.literal("default")
|
|
7
|
+
});
|
|
8
|
+
var CustomUrlExecutorConfigSchema = z.object({
|
|
9
|
+
type: z.literal("custom_url"),
|
|
10
|
+
/** URL of the custom executor (must be HTTPS in production) */
|
|
11
|
+
url: z.string().url(),
|
|
12
|
+
/** Optional API key for Bearer token authentication */
|
|
13
|
+
apiKey: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
z.discriminatedUnion("type", [
|
|
16
|
+
DefaultExecutorConfigSchema,
|
|
17
|
+
CustomUrlExecutorConfigSchema
|
|
18
|
+
]);
|
|
19
|
+
z.object({
|
|
20
|
+
packageName: z.string().min(1),
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
version: z.string().optional(),
|
|
23
|
+
importUrl: z.string().url().optional(),
|
|
24
|
+
params: z.record(z.string(), z.unknown()),
|
|
25
|
+
env: z.record(z.string(), z.string()).optional()
|
|
26
|
+
});
|
|
27
|
+
z.object({
|
|
28
|
+
success: z.boolean(),
|
|
29
|
+
output: z.unknown().optional(),
|
|
30
|
+
error: z.string().optional(),
|
|
31
|
+
executionTimeMs: z.number()
|
|
32
|
+
});
|
|
33
|
+
z.object({
|
|
34
|
+
status: z.enum(["ok", "degraded", "error"]),
|
|
35
|
+
version: z.string().optional(),
|
|
36
|
+
info: z.record(z.string(), z.unknown()).optional()
|
|
37
|
+
});
|
|
38
|
+
z.object({
|
|
39
|
+
url: z.string().url(),
|
|
40
|
+
apiKey: z.string().optional()
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// src/collection.ts
|
|
44
|
+
var NAME_REGEX = /^[a-zA-Z0-9\s\-_]+$/;
|
|
45
|
+
var ExecutorConfigUpdateSchema = z.object({
|
|
46
|
+
url: z.string().url(),
|
|
47
|
+
apiKey: z.string().optional()
|
|
48
|
+
}).nullable().optional();
|
|
49
|
+
var CreateCollectionSchema = z.object({
|
|
50
|
+
name: z.string().min(1, "Name is required").max(100, "Name must be 100 characters or less").regex(NAME_REGEX, "Name can only contain letters, numbers, spaces, hyphens, and underscores"),
|
|
51
|
+
description: z.string().max(500, "Description must be 500 characters or less").optional(),
|
|
52
|
+
isPublic: z.boolean().default(false)
|
|
53
|
+
});
|
|
54
|
+
var UpdateCollectionSchema = z.object({
|
|
55
|
+
name: z.string().min(1, "Name is required").max(100, "Name must be 100 characters or less").regex(NAME_REGEX, "Name can only contain letters, numbers, spaces, hyphens, and underscores").optional(),
|
|
56
|
+
description: z.string().max(500, "Description must be 500 characters or less").nullable().optional(),
|
|
57
|
+
isPublic: z.boolean().optional(),
|
|
58
|
+
// Executor configuration
|
|
59
|
+
executorType: ExecutorTypeSchema.nullable().optional(),
|
|
60
|
+
executorConfig: ExecutorConfigUpdateSchema,
|
|
61
|
+
// Tool environment variables
|
|
62
|
+
envVars: z.record(z.string(), z.string()).nullable().optional()
|
|
63
|
+
});
|
|
64
|
+
var AddToolToCollectionSchema = z.object({
|
|
65
|
+
toolId: z.string().min(1, "Tool ID is required"),
|
|
66
|
+
note: z.string().max(500, "Note must be 500 characters or less").optional(),
|
|
67
|
+
position: z.number().int().min(0).optional()
|
|
68
|
+
});
|
|
69
|
+
var UpdateCollectionToolSchema = z.object({
|
|
70
|
+
note: z.string().max(500, "Note must be 500 characters or less").nullable().optional(),
|
|
71
|
+
position: z.number().int().min(0).optional()
|
|
72
|
+
});
|
|
73
|
+
var ReorderToolsSchema = z.object({
|
|
74
|
+
toolIds: z.array(z.string().min(1))
|
|
75
|
+
});
|
|
76
|
+
var AddBridgeToolToCollectionSchema = z.object({
|
|
77
|
+
serverId: z.string().min(1, "Server ID is required").max(100),
|
|
78
|
+
toolName: z.string().min(1, "Tool name is required").max(100),
|
|
79
|
+
displayName: z.string().max(100).optional(),
|
|
80
|
+
note: z.string().max(500, "Note must be 500 characters or less").optional()
|
|
81
|
+
});
|
|
82
|
+
var UpdateCollectionBridgeToolSchema = z.object({
|
|
83
|
+
displayName: z.string().max(100).nullable().optional(),
|
|
84
|
+
note: z.string().max(500, "Note must be 500 characters or less").nullable().optional()
|
|
85
|
+
});
|
|
86
|
+
var CloneCollectionSchema = z.object({
|
|
87
|
+
name: z.string().min(1, "Name is required").max(100, "Name must be 100 characters or less").regex(NAME_REGEX, "Name can only contain letters, numbers, spaces, hyphens, and underscores").optional()
|
|
88
|
+
// If not provided, will use original name or append "(copy)"
|
|
89
|
+
});
|
|
90
|
+
var CollectionSchema = z.object({
|
|
91
|
+
id: z.string(),
|
|
92
|
+
name: z.string(),
|
|
93
|
+
slug: z.string().nullable(),
|
|
94
|
+
description: z.string().nullable(),
|
|
95
|
+
isPublic: z.boolean(),
|
|
96
|
+
toolCount: z.number(),
|
|
97
|
+
forkCount: z.number().default(0),
|
|
98
|
+
forkedFromId: z.string().nullable().optional(),
|
|
99
|
+
createdAt: z.date(),
|
|
100
|
+
updatedAt: z.date()
|
|
101
|
+
});
|
|
102
|
+
var CollectionToolSchema = z.object({
|
|
103
|
+
id: z.string(),
|
|
104
|
+
toolId: z.string(),
|
|
105
|
+
position: z.number(),
|
|
106
|
+
note: z.string().nullable(),
|
|
107
|
+
addedAt: z.date(),
|
|
108
|
+
tool: z.object({
|
|
109
|
+
id: z.string(),
|
|
110
|
+
name: z.string(),
|
|
111
|
+
description: z.string(),
|
|
112
|
+
package: z.object({
|
|
113
|
+
id: z.string(),
|
|
114
|
+
npmPackageName: z.string(),
|
|
115
|
+
category: z.string()
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
});
|
|
119
|
+
var CollectionWithToolsSchema = CollectionSchema.extend({
|
|
120
|
+
tools: z.array(CollectionToolSchema)
|
|
121
|
+
});
|
|
122
|
+
var COLLECTION_LIMITS = {
|
|
123
|
+
MAX_COLLECTIONS_PER_USER: 50,
|
|
124
|
+
MAX_TOOLS_PER_COLLECTION: 100,
|
|
125
|
+
MAX_BRIDGE_TOOLS_PER_COLLECTION: 50,
|
|
126
|
+
MAX_NAME_LENGTH: 100,
|
|
127
|
+
MAX_DESCRIPTION_LENGTH: 500,
|
|
128
|
+
MAX_NOTE_LENGTH: 500
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { AddBridgeToolToCollectionSchema, AddToolToCollectionSchema, COLLECTION_LIMITS, CloneCollectionSchema, CollectionSchema, CollectionToolSchema, CollectionWithToolsSchema, CreateCollectionSchema, ReorderToolsSchema, UpdateCollectionBridgeToolSchema, UpdateCollectionSchema, UpdateCollectionToolSchema };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Executor API Types
|
|
5
|
+
*
|
|
6
|
+
* These types define the contract between TPMJS and any executor service.
|
|
7
|
+
* Custom executors must implement the ExecuteToolRequest/Response interface.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Request payload for POST /execute-tool
|
|
12
|
+
*/
|
|
13
|
+
interface ExecuteToolRequest {
|
|
14
|
+
/** NPM package name, e.g., "@tpmjs/hello" */
|
|
15
|
+
packageName: string;
|
|
16
|
+
/** Tool name within the package, e.g., "helloWorld" */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Package version, e.g., "1.0.0" or "latest" */
|
|
19
|
+
version?: string;
|
|
20
|
+
/** Direct esm.sh URL override for the package */
|
|
21
|
+
importUrl?: string;
|
|
22
|
+
/** Tool parameters to pass to execute() */
|
|
23
|
+
params: Record<string, unknown>;
|
|
24
|
+
/** Environment variables to inject during execution */
|
|
25
|
+
env?: Record<string, string>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Response from POST /execute-tool
|
|
29
|
+
*/
|
|
30
|
+
interface ExecuteToolResponse {
|
|
31
|
+
/** Whether the execution succeeded */
|
|
32
|
+
success: boolean;
|
|
33
|
+
/** Tool output on success */
|
|
34
|
+
output?: unknown;
|
|
35
|
+
/** Error message on failure */
|
|
36
|
+
error?: string;
|
|
37
|
+
/** Execution duration in milliseconds */
|
|
38
|
+
executionTimeMs: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Response from GET /health (optional but recommended)
|
|
42
|
+
*/
|
|
43
|
+
interface ExecutorHealthResponse {
|
|
44
|
+
/** Executor status */
|
|
45
|
+
status: 'ok' | 'degraded' | 'error';
|
|
46
|
+
/** Executor version string */
|
|
47
|
+
version?: string;
|
|
48
|
+
/** Optional additional info */
|
|
49
|
+
info?: Record<string, unknown>;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Executor type enum
|
|
53
|
+
*/
|
|
54
|
+
declare const ExecutorTypeSchema: z.ZodEnum<{
|
|
55
|
+
default: "default";
|
|
56
|
+
custom_url: "custom_url";
|
|
57
|
+
}>;
|
|
58
|
+
type ExecutorType = z.infer<typeof ExecutorTypeSchema>;
|
|
59
|
+
/**
|
|
60
|
+
* Default executor config (uses TPMJS Railway executor)
|
|
61
|
+
*/
|
|
62
|
+
declare const DefaultExecutorConfigSchema: z.ZodObject<{
|
|
63
|
+
type: z.ZodLiteral<"default">;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom URL executor config
|
|
67
|
+
*/
|
|
68
|
+
declare const CustomUrlExecutorConfigSchema: z.ZodObject<{
|
|
69
|
+
type: z.ZodLiteral<"custom_url">;
|
|
70
|
+
url: z.ZodString;
|
|
71
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
/**
|
|
74
|
+
* Union of all executor config types
|
|
75
|
+
*/
|
|
76
|
+
declare const ExecutorConfigSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"default">;
|
|
78
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
79
|
+
type: z.ZodLiteral<"custom_url">;
|
|
80
|
+
url: z.ZodString;
|
|
81
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, z.core.$strip>], "type">;
|
|
83
|
+
type ExecutorConfig = z.infer<typeof ExecutorConfigSchema>;
|
|
84
|
+
type DefaultExecutorConfig = z.infer<typeof DefaultExecutorConfigSchema>;
|
|
85
|
+
type CustomUrlExecutorConfig = z.infer<typeof CustomUrlExecutorConfigSchema>;
|
|
86
|
+
declare const ExecuteToolRequestSchema: z.ZodObject<{
|
|
87
|
+
packageName: z.ZodString;
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
version: z.ZodOptional<z.ZodString>;
|
|
90
|
+
importUrl: z.ZodOptional<z.ZodString>;
|
|
91
|
+
params: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
92
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
94
|
+
declare const ExecuteToolResponseSchema: z.ZodObject<{
|
|
95
|
+
success: z.ZodBoolean;
|
|
96
|
+
output: z.ZodOptional<z.ZodUnknown>;
|
|
97
|
+
error: z.ZodOptional<z.ZodString>;
|
|
98
|
+
executionTimeMs: z.ZodNumber;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
declare const ExecutorHealthResponseSchema: z.ZodObject<{
|
|
101
|
+
status: z.ZodEnum<{
|
|
102
|
+
ok: "ok";
|
|
103
|
+
degraded: "degraded";
|
|
104
|
+
error: "error";
|
|
105
|
+
}>;
|
|
106
|
+
version: z.ZodOptional<z.ZodString>;
|
|
107
|
+
info: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
declare const VerifyExecutorRequestSchema: z.ZodObject<{
|
|
110
|
+
url: z.ZodString;
|
|
111
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
interface VerifyExecutorRequest {
|
|
114
|
+
url: string;
|
|
115
|
+
apiKey?: string;
|
|
116
|
+
}
|
|
117
|
+
interface VerifyExecutorResponse {
|
|
118
|
+
valid: boolean;
|
|
119
|
+
healthCheck?: ExecutorHealthResponse;
|
|
120
|
+
testExecution?: {
|
|
121
|
+
success: boolean;
|
|
122
|
+
executionTimeMs: number;
|
|
123
|
+
};
|
|
124
|
+
errors?: string[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export { type CustomUrlExecutorConfig, CustomUrlExecutorConfigSchema, type DefaultExecutorConfig, DefaultExecutorConfigSchema, type ExecuteToolRequest, ExecuteToolRequestSchema, type ExecuteToolResponse, ExecuteToolResponseSchema, type ExecutorConfig, ExecutorConfigSchema, type ExecutorHealthResponse, ExecutorHealthResponseSchema, type ExecutorType, ExecutorTypeSchema, type VerifyExecutorRequest, VerifyExecutorRequestSchema, type VerifyExecutorResponse };
|
package/dist/executor.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/executor.ts
|
|
4
|
+
var ExecutorTypeSchema = z.enum(["default", "custom_url"]);
|
|
5
|
+
var DefaultExecutorConfigSchema = z.object({
|
|
6
|
+
type: z.literal("default")
|
|
7
|
+
});
|
|
8
|
+
var CustomUrlExecutorConfigSchema = z.object({
|
|
9
|
+
type: z.literal("custom_url"),
|
|
10
|
+
/** URL of the custom executor (must be HTTPS in production) */
|
|
11
|
+
url: z.string().url(),
|
|
12
|
+
/** Optional API key for Bearer token authentication */
|
|
13
|
+
apiKey: z.string().optional()
|
|
14
|
+
});
|
|
15
|
+
var ExecutorConfigSchema = z.discriminatedUnion("type", [
|
|
16
|
+
DefaultExecutorConfigSchema,
|
|
17
|
+
CustomUrlExecutorConfigSchema
|
|
18
|
+
]);
|
|
19
|
+
var ExecuteToolRequestSchema = z.object({
|
|
20
|
+
packageName: z.string().min(1),
|
|
21
|
+
name: z.string().min(1),
|
|
22
|
+
version: z.string().optional(),
|
|
23
|
+
importUrl: z.string().url().optional(),
|
|
24
|
+
params: z.record(z.string(), z.unknown()),
|
|
25
|
+
env: z.record(z.string(), z.string()).optional()
|
|
26
|
+
});
|
|
27
|
+
var ExecuteToolResponseSchema = z.object({
|
|
28
|
+
success: z.boolean(),
|
|
29
|
+
output: z.unknown().optional(),
|
|
30
|
+
error: z.string().optional(),
|
|
31
|
+
executionTimeMs: z.number()
|
|
32
|
+
});
|
|
33
|
+
var ExecutorHealthResponseSchema = z.object({
|
|
34
|
+
status: z.enum(["ok", "degraded", "error"]),
|
|
35
|
+
version: z.string().optional(),
|
|
36
|
+
info: z.record(z.string(), z.unknown()).optional()
|
|
37
|
+
});
|
|
38
|
+
var VerifyExecutorRequestSchema = z.object({
|
|
39
|
+
url: z.string().url(),
|
|
40
|
+
apiKey: z.string().optional()
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
export { CustomUrlExecutorConfigSchema, DefaultExecutorConfigSchema, ExecuteToolRequestSchema, ExecuteToolResponseSchema, ExecutorConfigSchema, ExecutorHealthResponseSchema, ExecutorTypeSchema, VerifyExecutorRequestSchema };
|
package/dist/tpmjs.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { z } from 'zod';
|
|
|
3
3
|
/**
|
|
4
4
|
* Valid tool categories for TPMJS registry
|
|
5
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"];
|
|
6
|
+
declare const TPMJS_CATEGORIES: readonly ["research", "web", "data", "documentation", "engineering", "security", "statistics", "ops", "agent", "sandbox", "utilities", "html", "compliance", "web-scraping", "data-processing", "file-operations", "communication", "database", "api-integration", "image-processing", "text-analysis", "automation", "ai-ml", "monitoring", "doc", "text"];
|
|
7
7
|
type TpmjsCategory = (typeof TPMJS_CATEGORIES)[number];
|
|
8
8
|
/**
|
|
9
9
|
* Tool parameter schema
|
|
@@ -62,15 +62,13 @@ type TpmjsAiAgent = z.infer<typeof TpmjsAiAgentSchema>;
|
|
|
62
62
|
* Optional fields (auto-extracted if not provided):
|
|
63
63
|
* - description: A description of what the tool does (20-500 chars) - auto-extracted from tool
|
|
64
64
|
*
|
|
65
|
-
* @deprecated fields (now auto-extracted
|
|
65
|
+
* @deprecated fields (now auto-extracted):
|
|
66
66
|
* - parameters: Tool input parameters - auto-extracted from inputSchema
|
|
67
67
|
* - returns: Tool return type - auto-extracted from tool
|
|
68
68
|
* - aiAgent: AI agent guidance - auto-extracted from tool
|
|
69
|
-
* - exportName: Renamed to 'name' - kept for backward compatibility with published packages
|
|
70
69
|
*/
|
|
71
|
-
declare const TpmjsToolDefinitionSchema: z.
|
|
72
|
-
name: z.
|
|
73
|
-
exportName: z.ZodOptional<z.ZodString>;
|
|
70
|
+
declare const TpmjsToolDefinitionSchema: z.ZodObject<{
|
|
71
|
+
name: z.ZodString;
|
|
74
72
|
description: z.ZodOptional<z.ZodString>;
|
|
75
73
|
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
76
74
|
name: z.ZodString;
|
|
@@ -88,46 +86,7 @@ declare const TpmjsToolDefinitionSchema: z.ZodPipe<z.ZodObject<{
|
|
|
88
86
|
limitations: z.ZodOptional<z.ZodString>;
|
|
89
87
|
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
90
88
|
}, z.core.$strip>>;
|
|
91
|
-
}, z.core.$strip
|
|
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
|
-
}>>;
|
|
89
|
+
}, z.core.$strip>;
|
|
131
90
|
type TpmjsToolDefinition = z.infer<typeof TpmjsToolDefinitionSchema>;
|
|
132
91
|
/**
|
|
133
92
|
* Multi-tool format - NEW SCHEMA
|
|
@@ -147,6 +106,7 @@ declare const TpmjsMultiToolSchema: z.ZodObject<{
|
|
|
147
106
|
statistics: "statistics";
|
|
148
107
|
ops: "ops";
|
|
149
108
|
agent: "agent";
|
|
109
|
+
sandbox: "sandbox";
|
|
150
110
|
utilities: "utilities";
|
|
151
111
|
html: "html";
|
|
152
112
|
compliance: "compliance";
|
|
@@ -164,9 +124,8 @@ declare const TpmjsMultiToolSchema: z.ZodObject<{
|
|
|
164
124
|
doc: "doc";
|
|
165
125
|
text: "text";
|
|
166
126
|
}>;
|
|
167
|
-
tools: z.ZodOptional<z.ZodArray<z.
|
|
168
|
-
name: z.
|
|
169
|
-
exportName: z.ZodOptional<z.ZodString>;
|
|
127
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
128
|
+
name: z.ZodString;
|
|
170
129
|
description: z.ZodOptional<z.ZodString>;
|
|
171
130
|
parameters: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
172
131
|
name: z.ZodString;
|
|
@@ -184,46 +143,7 @@ declare const TpmjsMultiToolSchema: z.ZodObject<{
|
|
|
184
143
|
limitations: z.ZodOptional<z.ZodString>;
|
|
185
144
|
examples: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
186
145
|
}, z.core.$strip>>;
|
|
187
|
-
}, z.core.$strip
|
|
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
|
-
}>>>>;
|
|
146
|
+
}, z.core.$strip>>>;
|
|
227
147
|
env: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
228
148
|
name: z.ZodString;
|
|
229
149
|
description: z.ZodString;
|
|
@@ -254,6 +174,7 @@ declare const TpmjsLegacyMinimalSchema: z.ZodObject<{
|
|
|
254
174
|
statistics: "statistics";
|
|
255
175
|
ops: "ops";
|
|
256
176
|
agent: "agent";
|
|
177
|
+
sandbox: "sandbox";
|
|
257
178
|
utilities: "utilities";
|
|
258
179
|
html: "html";
|
|
259
180
|
compliance: "compliance";
|
|
@@ -289,6 +210,7 @@ declare const TpmjsLegacyRichSchema: z.ZodObject<{
|
|
|
289
210
|
statistics: "statistics";
|
|
290
211
|
ops: "ops";
|
|
291
212
|
agent: "agent";
|
|
213
|
+
sandbox: "sandbox";
|
|
292
214
|
utilities: "utilities";
|
|
293
215
|
html: "html";
|
|
294
216
|
compliance: "compliance";
|
|
@@ -359,6 +281,7 @@ declare const TpmjsMinimalSchema: z.ZodObject<{
|
|
|
359
281
|
statistics: "statistics";
|
|
360
282
|
ops: "ops";
|
|
361
283
|
agent: "agent";
|
|
284
|
+
sandbox: "sandbox";
|
|
362
285
|
utilities: "utilities";
|
|
363
286
|
html: "html";
|
|
364
287
|
compliance: "compliance";
|
|
@@ -389,6 +312,7 @@ declare const TpmjsRichSchema: z.ZodObject<{
|
|
|
389
312
|
statistics: "statistics";
|
|
390
313
|
ops: "ops";
|
|
391
314
|
agent: "agent";
|
|
315
|
+
sandbox: "sandbox";
|
|
392
316
|
utilities: "utilities";
|
|
393
317
|
html: "html";
|
|
394
318
|
compliance: "compliance";
|
package/dist/tpmjs.js
CHANGED
|
@@ -12,6 +12,7 @@ var TPMJS_CATEGORIES = [
|
|
|
12
12
|
"statistics",
|
|
13
13
|
"ops",
|
|
14
14
|
"agent",
|
|
15
|
+
"sandbox",
|
|
15
16
|
"utilities",
|
|
16
17
|
"html",
|
|
17
18
|
"compliance",
|
|
@@ -55,10 +56,7 @@ var TpmjsAiAgentSchema = z.object({
|
|
|
55
56
|
});
|
|
56
57
|
var TpmjsToolDefinitionSchema = z.object({
|
|
57
58
|
// Required: The export name of the tool from the package
|
|
58
|
-
|
|
59
|
-
name: z.string().min(1).optional(),
|
|
60
|
-
// @deprecated - renamed to 'name', kept for backward compatibility
|
|
61
|
-
exportName: z.string().min(1).optional(),
|
|
59
|
+
name: z.string().min(1, "Tool name is required"),
|
|
62
60
|
// Optional - auto-extracted from tool if not provided
|
|
63
61
|
description: z.string().min(20, "Description must be at least 20 characters").max(500).optional(),
|
|
64
62
|
// @deprecated - now auto-extracted from tool's inputSchema
|
|
@@ -67,16 +65,6 @@ var TpmjsToolDefinitionSchema = z.object({
|
|
|
67
65
|
returns: TpmjsReturnsSchema.optional(),
|
|
68
66
|
// @deprecated - now auto-extracted from tool
|
|
69
67
|
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
68
|
});
|
|
81
69
|
var TpmjsMultiToolSchema = z.object({
|
|
82
70
|
category: z.enum(TPMJS_CATEGORIES, {
|
package/dist/user.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
declare const RESERVED_USERNAMES: readonly ["admin", "api", "auth", "dashboard", "help", "support", "system", "www", "settings", "login", "logout", "register", "signup", "signin", "agents", "collections", "tools", "tool", "playground", "explore", "search", "about", "blog", "docs", "pricing", "terms", "privacy", "contact", "status", "tpmjs", "tpm", "official"];
|
|
4
|
+
/**
|
|
5
|
+
* Username requirements:
|
|
6
|
+
* - 3-30 characters
|
|
7
|
+
* - Lowercase alphanumeric and hyphens only
|
|
8
|
+
* - Must start and end with alphanumeric (unless 1-2 chars)
|
|
9
|
+
* - No consecutive hyphens
|
|
10
|
+
*/
|
|
11
|
+
declare const USERNAME_REGEX: RegExp;
|
|
12
|
+
declare const UsernameSchema: z.ZodString;
|
|
13
|
+
declare const UpdateUserProfileSchema: z.ZodObject<{
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
username: z.ZodOptional<z.ZodString>;
|
|
16
|
+
image: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
declare const CheckUsernameSchema: z.ZodObject<{
|
|
19
|
+
username: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
declare const UserProfileSchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
name: z.ZodString;
|
|
24
|
+
username: z.ZodNullable<z.ZodString>;
|
|
25
|
+
email: z.ZodString;
|
|
26
|
+
image: z.ZodNullable<z.ZodString>;
|
|
27
|
+
createdAt: z.ZodDate;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
declare const PublicUserSchema: z.ZodObject<{
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
username: z.ZodString;
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
image: z.ZodNullable<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
declare const UsernameAvailabilitySchema: z.ZodObject<{
|
|
36
|
+
username: z.ZodString;
|
|
37
|
+
available: z.ZodBoolean;
|
|
38
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
type UpdateUserProfileInput = z.infer<typeof UpdateUserProfileSchema>;
|
|
41
|
+
type CheckUsernameInput = z.infer<typeof CheckUsernameSchema>;
|
|
42
|
+
type UserProfile = z.infer<typeof UserProfileSchema>;
|
|
43
|
+
type PublicUser = z.infer<typeof PublicUserSchema>;
|
|
44
|
+
type UsernameAvailability = z.infer<typeof UsernameAvailabilitySchema>;
|
|
45
|
+
/**
|
|
46
|
+
* Convert a display name to a URL-friendly username suggestion.
|
|
47
|
+
*/
|
|
48
|
+
declare function suggestUsername(name: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* Check if a username is valid (without checking availability).
|
|
51
|
+
*/
|
|
52
|
+
declare function isValidUsername(username: string): boolean;
|
|
53
|
+
|
|
54
|
+
export { type CheckUsernameInput, CheckUsernameSchema, type PublicUser, PublicUserSchema, RESERVED_USERNAMES, USERNAME_REGEX, type UpdateUserProfileInput, UpdateUserProfileSchema, type UserProfile, UserProfileSchema, type UsernameAvailability, UsernameAvailabilitySchema, UsernameSchema, isValidUsername, suggestUsername };
|
package/dist/user.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/user.ts
|
|
4
|
+
var RESERVED_USERNAMES = [
|
|
5
|
+
// System routes
|
|
6
|
+
"admin",
|
|
7
|
+
"api",
|
|
8
|
+
"auth",
|
|
9
|
+
"dashboard",
|
|
10
|
+
"help",
|
|
11
|
+
"support",
|
|
12
|
+
"system",
|
|
13
|
+
"www",
|
|
14
|
+
"settings",
|
|
15
|
+
"login",
|
|
16
|
+
"logout",
|
|
17
|
+
"register",
|
|
18
|
+
"signup",
|
|
19
|
+
"signin",
|
|
20
|
+
// Content routes
|
|
21
|
+
"agents",
|
|
22
|
+
"collections",
|
|
23
|
+
"tools",
|
|
24
|
+
"tool",
|
|
25
|
+
"playground",
|
|
26
|
+
"explore",
|
|
27
|
+
"search",
|
|
28
|
+
// Reserved for future
|
|
29
|
+
"about",
|
|
30
|
+
"blog",
|
|
31
|
+
"docs",
|
|
32
|
+
"pricing",
|
|
33
|
+
"terms",
|
|
34
|
+
"privacy",
|
|
35
|
+
"contact",
|
|
36
|
+
"status",
|
|
37
|
+
// Brand/official
|
|
38
|
+
"tpmjs",
|
|
39
|
+
"tpm",
|
|
40
|
+
"official"
|
|
41
|
+
];
|
|
42
|
+
var USERNAME_REGEX = /^[a-z0-9](?:[a-z0-9]|(?:-(?!-))){1,28}[a-z0-9]$|^[a-z0-9]{1,2}$/;
|
|
43
|
+
var UsernameSchema = z.string().min(3, "Username must be at least 3 characters").max(30, "Username must be 30 characters or less").regex(USERNAME_REGEX, "Username must be lowercase, alphanumeric, with single hyphens only").refine(
|
|
44
|
+
(val) => !RESERVED_USERNAMES.includes(val),
|
|
45
|
+
"This username is reserved"
|
|
46
|
+
);
|
|
47
|
+
var UpdateUserProfileSchema = z.object({
|
|
48
|
+
name: z.string().min(1, "Name is required").max(100).optional(),
|
|
49
|
+
username: UsernameSchema.optional(),
|
|
50
|
+
image: z.string().url("Invalid image URL").nullable().optional()
|
|
51
|
+
});
|
|
52
|
+
var CheckUsernameSchema = z.object({
|
|
53
|
+
username: z.string().min(3, "Username must be at least 3 characters").max(30, "Username must be 30 characters or less").transform((val) => val.toLowerCase())
|
|
54
|
+
});
|
|
55
|
+
var UserProfileSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
name: z.string(),
|
|
58
|
+
username: z.string().nullable(),
|
|
59
|
+
email: z.string().email(),
|
|
60
|
+
image: z.string().nullable(),
|
|
61
|
+
createdAt: z.date()
|
|
62
|
+
});
|
|
63
|
+
var PublicUserSchema = z.object({
|
|
64
|
+
id: z.string(),
|
|
65
|
+
username: z.string(),
|
|
66
|
+
name: z.string(),
|
|
67
|
+
image: z.string().nullable()
|
|
68
|
+
});
|
|
69
|
+
var UsernameAvailabilitySchema = z.object({
|
|
70
|
+
username: z.string(),
|
|
71
|
+
available: z.boolean(),
|
|
72
|
+
reason: z.string().optional()
|
|
73
|
+
});
|
|
74
|
+
function suggestUsername(name) {
|
|
75
|
+
return name.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-+|-+$/g, "").slice(0, 30);
|
|
76
|
+
}
|
|
77
|
+
function isValidUsername(username) {
|
|
78
|
+
return UsernameSchema.safeParse(username).success;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { CheckUsernameSchema, PublicUserSchema, RESERVED_USERNAMES, USERNAME_REGEX, UpdateUserProfileSchema, UserProfileSchema, UsernameAvailabilitySchema, UsernameSchema, isValidUsername, suggestUsername };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tpmjs/types",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Shared TypeScript types and Zod schemas for TPMJS",
|
|
5
5
|
"author": "TPMJS",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,16 +30,32 @@
|
|
|
30
30
|
"./tpmjs": {
|
|
31
31
|
"types": "./dist/tpmjs.d.ts",
|
|
32
32
|
"default": "./dist/tpmjs.js"
|
|
33
|
+
},
|
|
34
|
+
"./collection": {
|
|
35
|
+
"types": "./dist/collection.d.ts",
|
|
36
|
+
"default": "./dist/collection.js"
|
|
37
|
+
},
|
|
38
|
+
"./agent": {
|
|
39
|
+
"types": "./dist/agent.d.ts",
|
|
40
|
+
"default": "./dist/agent.js"
|
|
41
|
+
},
|
|
42
|
+
"./user": {
|
|
43
|
+
"types": "./dist/user.d.ts",
|
|
44
|
+
"default": "./dist/user.js"
|
|
45
|
+
},
|
|
46
|
+
"./executor": {
|
|
47
|
+
"types": "./dist/executor.d.ts",
|
|
48
|
+
"default": "./dist/executor.js"
|
|
33
49
|
}
|
|
34
50
|
},
|
|
35
51
|
"files": [
|
|
36
52
|
"dist"
|
|
37
53
|
],
|
|
38
54
|
"dependencies": {
|
|
39
|
-
"zod": "^4.
|
|
55
|
+
"zod": "^4.3.5"
|
|
40
56
|
},
|
|
41
57
|
"devDependencies": {
|
|
42
|
-
"tsup": "^8.
|
|
58
|
+
"tsup": "^8.5.1",
|
|
43
59
|
"typescript": "^5.9.3",
|
|
44
60
|
"@tpmjs/tsconfig": "0.0.0"
|
|
45
61
|
},
|