@402md/skillmd 0.1.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.
@@ -0,0 +1,331 @@
1
+ interface SkillManifest {
2
+ name: string;
3
+ displayName?: string;
4
+ description: string;
5
+ version?: string;
6
+ author?: string;
7
+ base_url: string;
8
+ type: SkillType;
9
+ payment: PaymentConfig;
10
+ endpoints: EndpointSpec[];
11
+ tags?: string[];
12
+ category?: string;
13
+ sla?: string;
14
+ rateLimit?: string;
15
+ sandbox?: string;
16
+ body: string;
17
+ }
18
+ interface PaymentConfig {
19
+ networks: PaymentNetwork[];
20
+ asset: string;
21
+ payTo: string;
22
+ payToEvm?: string;
23
+ facilitator?: string;
24
+ }
25
+ interface EndpointSpec {
26
+ path: string;
27
+ method: HttpMethod;
28
+ description: string;
29
+ priceUsdc: string;
30
+ inputSchema?: JSONSchema;
31
+ outputSchema?: JSONSchema;
32
+ }
33
+ type SkillType = 'API' | 'SAAS' | 'PRODUCT' | 'SERVICE' | 'SUBSCRIPTION' | 'CONTENT';
34
+ type PaymentNetwork = 'stellar' | 'base' | 'base-sepolia' | 'stellar-testnet';
35
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
36
+ type JSONSchema = Record<string, unknown>;
37
+ interface ValidationResult {
38
+ valid: boolean;
39
+ errors: ValidationError[];
40
+ warnings: ValidationWarning[];
41
+ }
42
+ interface ValidationError {
43
+ field: string;
44
+ message: string;
45
+ code: string;
46
+ }
47
+ interface ValidationWarning {
48
+ field: string;
49
+ message: string;
50
+ code: string;
51
+ }
52
+ interface SkillConfig {
53
+ name: string;
54
+ displayName?: string;
55
+ description: string;
56
+ version?: string;
57
+ author?: string;
58
+ base_url: string;
59
+ type?: SkillType;
60
+ payment: PaymentConfig;
61
+ endpoints: EndpointSpec[];
62
+ tags?: string[];
63
+ category?: string;
64
+ sla?: string;
65
+ rateLimit?: string;
66
+ sandbox?: string;
67
+ body?: string;
68
+ }
69
+ interface OpenAPISpec {
70
+ openapi: string;
71
+ info: {
72
+ title: string;
73
+ description?: string;
74
+ version: string;
75
+ };
76
+ servers?: {
77
+ url: string;
78
+ }[];
79
+ paths: Record<string, OpenAPIPathItem>;
80
+ }
81
+ interface OpenAPIPathItem {
82
+ get?: OpenAPIOperation;
83
+ post?: OpenAPIOperation;
84
+ put?: OpenAPIOperation;
85
+ delete?: OpenAPIOperation;
86
+ patch?: OpenAPIOperation;
87
+ }
88
+ interface OpenAPIOperation {
89
+ summary?: string;
90
+ description?: string;
91
+ operationId?: string;
92
+ requestBody?: {
93
+ content?: Record<string, {
94
+ schema?: JSONSchema;
95
+ }>;
96
+ };
97
+ responses?: Record<string, {
98
+ description?: string;
99
+ content?: Record<string, {
100
+ schema?: JSONSchema;
101
+ }>;
102
+ }>;
103
+ }
104
+ interface LegacyFrontmatter {
105
+ name: string;
106
+ base_url?: string;
107
+ type?: string;
108
+ description?: string;
109
+ endpoints?: {
110
+ path: string;
111
+ method: string;
112
+ price?: string;
113
+ description?: string;
114
+ }[];
115
+ [key: string]: unknown;
116
+ }
117
+
118
+ /**
119
+ * Parse a SKILL.md string into a SkillManifest.
120
+ * Supports both v2 (with payment block) and v1 (legacy) formats.
121
+ */
122
+ declare function parseSkillMd(content: string): SkillManifest;
123
+ /**
124
+ * Extract raw frontmatter data and body from a SKILL.md string.
125
+ * Lower-level than parseSkillMd — returns unprocessed YAML data.
126
+ */
127
+ declare function parseFrontmatter(md: string): {
128
+ data: LegacyFrontmatter;
129
+ body: string;
130
+ };
131
+
132
+ /**
133
+ * Validate a SkillManifest (already parsed).
134
+ */
135
+ declare function validateSkill(manifest: SkillManifest): ValidationResult;
136
+ /**
137
+ * Validate a raw SKILL.md string (parse + validate).
138
+ */
139
+ declare function validateSkillMd(content: string): ValidationResult;
140
+
141
+ /**
142
+ * Generate a SKILL.md string from a SkillConfig.
143
+ */
144
+ declare function generateSkillMd(config: SkillConfig): string;
145
+ /**
146
+ * Convert an OpenAPI spec into a SkillManifest.
147
+ * Each path+method becomes an endpoint in the manifest.
148
+ */
149
+ declare function generateFromOpenAPI(spec: OpenAPISpec, payment: PaymentConfig, options?: {
150
+ defaultPrice?: string;
151
+ baseUrlOverride?: string;
152
+ /** Per-endpoint pricing. Keys: 'METHOD /path' or '*' for fallback. */
153
+ pricing?: Record<string, string>;
154
+ }): SkillManifest;
155
+ /**
156
+ * Convert a SkillManifest into an OpenAPI 3.0 spec.
157
+ * Reverse of generateFromOpenAPI.
158
+ */
159
+ declare function toOpenAPI(manifest: SkillManifest): OpenAPISpec;
160
+
161
+ /**
162
+ * MCP tool definition shape.
163
+ * Defined inline to avoid depending on @modelcontextprotocol/sdk.
164
+ */
165
+ interface McpToolDefinition {
166
+ name: string;
167
+ description: string;
168
+ inputSchema: Record<string, unknown>;
169
+ }
170
+ /**
171
+ * Convert a SkillManifest into MCP tool definitions.
172
+ * Each endpoint becomes one tool.
173
+ */
174
+ declare function toMcpToolDefinitions(manifest: SkillManifest): McpToolDefinition[];
175
+
176
+ /**
177
+ * JSON Schema for SKILL.md v2 frontmatter validation.
178
+ * Can be used with any JSON Schema validator (ajv, zod, etc).
179
+ *
180
+ * Enums are derived from the shared constants in constants.ts
181
+ * so they stay in sync with the parser and validator.
182
+ */
183
+ declare const SKILLMD_JSON_SCHEMA: {
184
+ readonly $schema: "https://json-schema.org/draft/2020-12/schema";
185
+ readonly title: "SKILL.md Frontmatter";
186
+ readonly description: "Schema for the YAML frontmatter in a SKILL.md file";
187
+ readonly type: "object";
188
+ readonly required: readonly ["name", "description", "base_url", "payment", "endpoints"];
189
+ readonly properties: {
190
+ readonly name: {
191
+ readonly type: "string";
192
+ readonly pattern: "^[a-z0-9][a-z0-9_-]*$";
193
+ readonly minLength: 1;
194
+ readonly maxLength: 100;
195
+ readonly description: "Unique skill identifier (kebab-case)";
196
+ };
197
+ readonly displayName: {
198
+ readonly type: "string";
199
+ readonly maxLength: 200;
200
+ readonly description: "Human-readable name";
201
+ };
202
+ readonly description: {
203
+ readonly type: "string";
204
+ readonly minLength: 1;
205
+ readonly maxLength: 2000;
206
+ readonly description: "What this skill does";
207
+ };
208
+ readonly version: {
209
+ readonly type: "string";
210
+ readonly pattern: "^\\d+\\.\\d+\\.\\d+";
211
+ readonly description: "Semantic version";
212
+ };
213
+ readonly author: {
214
+ readonly type: "string";
215
+ readonly maxLength: 100;
216
+ };
217
+ readonly base_url: {
218
+ readonly type: "string";
219
+ readonly format: "uri";
220
+ readonly description: "Base URL of the API";
221
+ };
222
+ readonly type: {
223
+ readonly type: "string";
224
+ readonly enum: readonly SkillType[];
225
+ readonly default: "API";
226
+ };
227
+ readonly payment: {
228
+ readonly type: "object";
229
+ readonly required: readonly ["networks", "payTo"];
230
+ readonly properties: {
231
+ readonly networks: {
232
+ readonly type: "array";
233
+ readonly items: {
234
+ readonly type: "string";
235
+ readonly enum: readonly PaymentNetwork[];
236
+ };
237
+ readonly minItems: 1;
238
+ readonly description: "Supported payment networks";
239
+ };
240
+ readonly asset: {
241
+ readonly type: "string";
242
+ readonly default: "USDC";
243
+ readonly description: "Payment asset";
244
+ };
245
+ readonly payTo: {
246
+ readonly type: "string";
247
+ readonly minLength: 1;
248
+ readonly description: "Recipient address (Stellar or EVM)";
249
+ };
250
+ readonly payToEvm: {
251
+ readonly type: "string";
252
+ readonly pattern: "^0x[a-fA-F0-9]{40}$";
253
+ readonly description: "EVM address (fallback)";
254
+ };
255
+ readonly facilitator: {
256
+ readonly type: "string";
257
+ readonly format: "uri";
258
+ readonly description: "Facilitator URL";
259
+ };
260
+ };
261
+ readonly additionalProperties: false;
262
+ };
263
+ readonly endpoints: {
264
+ readonly type: "array";
265
+ readonly items: {
266
+ readonly type: "object";
267
+ readonly required: readonly ["path", "method", "description", "priceUsdc"];
268
+ readonly properties: {
269
+ readonly path: {
270
+ readonly type: "string";
271
+ readonly pattern: "^/";
272
+ readonly description: "Endpoint path (must start with /)";
273
+ };
274
+ readonly method: {
275
+ readonly type: "string";
276
+ readonly enum: readonly HttpMethod[];
277
+ };
278
+ readonly description: {
279
+ readonly type: "string";
280
+ readonly minLength: 1;
281
+ };
282
+ readonly priceUsdc: {
283
+ readonly type: "string";
284
+ readonly pattern: "^\\d+(\\.\\d+)?$";
285
+ readonly description: "Price in USDC (e.g. \"0.001\")";
286
+ };
287
+ readonly inputSchema: {
288
+ readonly type: "object";
289
+ readonly description: "JSON Schema for request body";
290
+ };
291
+ readonly outputSchema: {
292
+ readonly type: "object";
293
+ readonly description: "JSON Schema for response body";
294
+ };
295
+ };
296
+ readonly additionalProperties: false;
297
+ };
298
+ readonly minItems: 1;
299
+ };
300
+ readonly tags: {
301
+ readonly type: "array";
302
+ readonly items: {
303
+ readonly type: "string";
304
+ };
305
+ readonly maxItems: 20;
306
+ };
307
+ readonly category: {
308
+ readonly type: "string";
309
+ };
310
+ readonly sla: {
311
+ readonly type: "string";
312
+ readonly description: "Uptime guarantee (e.g. \"99.9%\")";
313
+ };
314
+ readonly rateLimit: {
315
+ readonly type: "string";
316
+ readonly description: "Rate limit (e.g. \"1000/hour\")";
317
+ };
318
+ readonly sandbox: {
319
+ readonly type: "string";
320
+ readonly format: "uri";
321
+ readonly description: "Free test endpoint URL";
322
+ };
323
+ };
324
+ readonly additionalProperties: true;
325
+ };
326
+
327
+ declare const SKILL_TYPES: readonly SkillType[];
328
+ declare const HTTP_METHODS: readonly HttpMethod[];
329
+ declare const PAYMENT_NETWORKS: readonly PaymentNetwork[];
330
+
331
+ export { type EndpointSpec, HTTP_METHODS, type HttpMethod, type JSONSchema, type LegacyFrontmatter, type McpToolDefinition, type OpenAPIOperation, type OpenAPIPathItem, type OpenAPISpec, PAYMENT_NETWORKS, type PaymentConfig, type PaymentNetwork, SKILLMD_JSON_SCHEMA, SKILL_TYPES, type SkillConfig, type SkillManifest, type SkillType, type ValidationError, type ValidationResult, type ValidationWarning, generateFromOpenAPI, generateSkillMd, parseFrontmatter, parseSkillMd, toMcpToolDefinitions, toOpenAPI, validateSkill, validateSkillMd };