@anytio/pspm 0.13.0 → 0.14.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/CHANGELOG.md +20 -1
- package/CLI_GUIDE.md +7 -2
- package/README.md +3 -1
- package/dist/add-CcgUlOLa.js +753 -0
- package/dist/add-Cnn-OR9g.js +2 -0
- package/dist/api-client-CBTk37gh.js +2 -0
- package/dist/api-client-DBXUpGoX.js +450 -0
- package/dist/config-BQy_Rjip.js +468 -0
- package/dist/config-BZJ6_GsC.js +2 -0
- package/dist/index.js +2781 -7019
- package/dist/install-gcvbBeWi.js +2 -0
- package/dist/install-lNvqIk5c.js +477 -0
- package/dist/symlinks-BTw8X0GG.js +1832 -0
- package/package.json +14 -12
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
//#region src/sdk/fetcher.ts
|
|
2
|
+
let config = null;
|
|
3
|
+
/**
|
|
4
|
+
* Configure the SDK with base URL and API key.
|
|
5
|
+
* Must be called before making any API requests.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { configure } from "./sdk/fetcher";
|
|
10
|
+
*
|
|
11
|
+
* configure({
|
|
12
|
+
* baseUrl: "http://localhost:5600",
|
|
13
|
+
* apiKey: "your-api-key"
|
|
14
|
+
* });
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
function configure$1(options) {
|
|
18
|
+
config = options;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Get the current SDK configuration.
|
|
22
|
+
* @throws Error if not configured
|
|
23
|
+
*/
|
|
24
|
+
function getConfig() {
|
|
25
|
+
if (!config) throw new Error("SDK not configured. Call configure() first.");
|
|
26
|
+
return config;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Custom fetch function for Orval
|
|
30
|
+
*
|
|
31
|
+
* This is used by all generated API functions to make HTTP requests.
|
|
32
|
+
* It handles authentication, error handling, and response parsing.
|
|
33
|
+
*
|
|
34
|
+
* Returns { data, status, headers } structure expected by Orval v8.
|
|
35
|
+
*/
|
|
36
|
+
async function customFetch(url, options) {
|
|
37
|
+
const { baseUrl, apiKey } = getConfig();
|
|
38
|
+
const fullUrl = `${baseUrl}${url}`;
|
|
39
|
+
const headers = {
|
|
40
|
+
...options.headers ?? {},
|
|
41
|
+
"Content-Type": "application/json"
|
|
42
|
+
};
|
|
43
|
+
if (apiKey) headers.Authorization = `Bearer ${apiKey}`;
|
|
44
|
+
const response = await fetch(fullUrl, {
|
|
45
|
+
...options,
|
|
46
|
+
headers
|
|
47
|
+
});
|
|
48
|
+
const text = await response.text();
|
|
49
|
+
let data = null;
|
|
50
|
+
if (text) try {
|
|
51
|
+
data = JSON.parse(text);
|
|
52
|
+
} catch {
|
|
53
|
+
data = text;
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
data,
|
|
57
|
+
status: response.status,
|
|
58
|
+
headers: response.headers
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/sdk/generated/index.ts
|
|
63
|
+
/**
|
|
64
|
+
* Generated by orval v8.5.3 🍺
|
|
65
|
+
* Do not edit manually.
|
|
66
|
+
* PSPM API
|
|
67
|
+
* Backend API for PSPM - Performant Skill Package Manager for AI Agents
|
|
68
|
+
* OpenAPI spec version: 1.0.0
|
|
69
|
+
*/
|
|
70
|
+
const getMeUrl = () => {
|
|
71
|
+
return `/api/skills/-/me`;
|
|
72
|
+
};
|
|
73
|
+
const me = async (options) => {
|
|
74
|
+
return customFetch(getMeUrl(), {
|
|
75
|
+
...options,
|
|
76
|
+
method: "GET"
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
const getExplorePublicSkillsUrl = (params) => {
|
|
80
|
+
const normalizedParams = new URLSearchParams();
|
|
81
|
+
Object.entries(params || {}).forEach(([key, value]) => {
|
|
82
|
+
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : value.toString());
|
|
83
|
+
});
|
|
84
|
+
const stringifiedParams = normalizedParams.toString();
|
|
85
|
+
return stringifiedParams.length > 0 ? `/api/skills/-/explore?${stringifiedParams}` : `/api/skills/-/explore`;
|
|
86
|
+
};
|
|
87
|
+
const explorePublicSkills = async (params, options) => {
|
|
88
|
+
return customFetch(getExplorePublicSkillsUrl(params), {
|
|
89
|
+
...options,
|
|
90
|
+
method: "GET"
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const getDeleteSkillUrl = (username, name) => {
|
|
94
|
+
return `/api/skills/@user/${username}/${name}`;
|
|
95
|
+
};
|
|
96
|
+
const deleteSkill = async (username, name, options) => {
|
|
97
|
+
return customFetch(getDeleteSkillUrl(username, name), {
|
|
98
|
+
...options,
|
|
99
|
+
method: "DELETE"
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
const getListSkillVersionsUrl = (username, name) => {
|
|
103
|
+
return `/api/skills/@user/${username}/${name}/versions`;
|
|
104
|
+
};
|
|
105
|
+
const listSkillVersions = async (username, name, options) => {
|
|
106
|
+
return customFetch(getListSkillVersionsUrl(username, name), {
|
|
107
|
+
...options,
|
|
108
|
+
method: "GET"
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const getGetSkillVersionUrl = (username, name, version) => {
|
|
112
|
+
return `/api/skills/@user/${username}/${name}/versions/${version}`;
|
|
113
|
+
};
|
|
114
|
+
const getSkillVersion = async (username, name, version, options) => {
|
|
115
|
+
return customFetch(getGetSkillVersionUrl(username, name, version), {
|
|
116
|
+
...options,
|
|
117
|
+
method: "GET"
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
const getDeleteSkillVersionUrl = (username, name, version) => {
|
|
121
|
+
return `/api/skills/@user/${username}/${name}/versions/${version}`;
|
|
122
|
+
};
|
|
123
|
+
const deleteSkillVersion = async (username, name, version, options) => {
|
|
124
|
+
return customFetch(getDeleteSkillVersionUrl(username, name, version), {
|
|
125
|
+
...options,
|
|
126
|
+
method: "DELETE"
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const getPublishSkillUrl = () => {
|
|
130
|
+
return `/api/skills/-/publish`;
|
|
131
|
+
};
|
|
132
|
+
const publishSkill = async (publishSkillInput, options) => {
|
|
133
|
+
return customFetch(getPublishSkillUrl(), {
|
|
134
|
+
...options,
|
|
135
|
+
method: "POST",
|
|
136
|
+
headers: {
|
|
137
|
+
"Content-Type": "application/json",
|
|
138
|
+
...options?.headers
|
|
139
|
+
},
|
|
140
|
+
body: JSON.stringify(publishSkillInput)
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
const getDeleteOrgSkillUrl = (orgname, name) => {
|
|
144
|
+
return `/api/skills/@org/${orgname}/${name}`;
|
|
145
|
+
};
|
|
146
|
+
const deleteOrgSkill = async (orgname, name, options) => {
|
|
147
|
+
return customFetch(getDeleteOrgSkillUrl(orgname, name), {
|
|
148
|
+
...options,
|
|
149
|
+
method: "DELETE"
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
const getListOrgSkillVersionsUrl = (orgname, name) => {
|
|
153
|
+
return `/api/skills/@org/${orgname}/${name}/versions`;
|
|
154
|
+
};
|
|
155
|
+
const listOrgSkillVersions = async (orgname, name, options) => {
|
|
156
|
+
return customFetch(getListOrgSkillVersionsUrl(orgname, name), {
|
|
157
|
+
...options,
|
|
158
|
+
method: "GET"
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
const getGetOrgSkillVersionUrl = (orgname, name, version) => {
|
|
162
|
+
return `/api/skills/@org/${orgname}/${name}/versions/${version}`;
|
|
163
|
+
};
|
|
164
|
+
const getOrgSkillVersion = async (orgname, name, version, options) => {
|
|
165
|
+
return customFetch(getGetOrgSkillVersionUrl(orgname, name, version), {
|
|
166
|
+
...options,
|
|
167
|
+
method: "GET"
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
const getPublishOrgSkillUrl = (orgname) => {
|
|
171
|
+
return `/api/skills/@org/${orgname}/publish`;
|
|
172
|
+
};
|
|
173
|
+
const publishOrgSkill = async (orgname, publishSkillInput, options) => {
|
|
174
|
+
return customFetch(getPublishOrgSkillUrl(orgname), {
|
|
175
|
+
...options,
|
|
176
|
+
method: "POST",
|
|
177
|
+
headers: {
|
|
178
|
+
"Content-Type": "application/json",
|
|
179
|
+
...options?.headers
|
|
180
|
+
},
|
|
181
|
+
body: JSON.stringify(publishSkillInput)
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/api-client.ts
|
|
186
|
+
/**
|
|
187
|
+
* API Client for PSPM CLI
|
|
188
|
+
*
|
|
189
|
+
* This module re-exports the SDK functions and provides the
|
|
190
|
+
* initialization logic for the CLI.
|
|
191
|
+
*/
|
|
192
|
+
/**
|
|
193
|
+
* Convert a registry URL to the base server URL for the SDK.
|
|
194
|
+
*
|
|
195
|
+
* The CLI stores registry URLs like "https://pspm.dev". This function
|
|
196
|
+
* normalizes the URL by removing any trailing /api/skills path if present
|
|
197
|
+
* (for backwards compatibility with older configs).
|
|
198
|
+
*/
|
|
199
|
+
function registryUrlToBaseUrl(registryUrl) {
|
|
200
|
+
return registryUrl.replace(/\/api\/skills\/?$/, "");
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Configure the SDK with registry URL and API key.
|
|
204
|
+
*
|
|
205
|
+
* This wrapper handles converting the CLI's registry URL format to the
|
|
206
|
+
* base URL format expected by the SDK.
|
|
207
|
+
*/
|
|
208
|
+
function configure(options) {
|
|
209
|
+
configure$1({
|
|
210
|
+
baseUrl: registryUrlToBaseUrl(options.registryUrl),
|
|
211
|
+
apiKey: options.apiKey
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Get user info from the API using the /me endpoint.
|
|
216
|
+
* Returns null if not authenticated.
|
|
217
|
+
*/
|
|
218
|
+
async function whoamiRequest(registryUrl, apiKey) {
|
|
219
|
+
try {
|
|
220
|
+
configure({
|
|
221
|
+
registryUrl,
|
|
222
|
+
apiKey
|
|
223
|
+
});
|
|
224
|
+
const response = await me();
|
|
225
|
+
if (response.status !== 200 || !response.data) return null;
|
|
226
|
+
const user = response.data;
|
|
227
|
+
return {
|
|
228
|
+
username: user.username,
|
|
229
|
+
userId: user.userId
|
|
230
|
+
};
|
|
231
|
+
} catch {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Deprecate a skill version
|
|
237
|
+
*/
|
|
238
|
+
async function deprecateSkillVersion(username, skillName, version, message) {
|
|
239
|
+
const config = getConfig();
|
|
240
|
+
if (!config) return {
|
|
241
|
+
status: 401,
|
|
242
|
+
error: "SDK not configured"
|
|
243
|
+
};
|
|
244
|
+
try {
|
|
245
|
+
const response = await fetch(`${config.baseUrl}/api/skills/@user/${username}/${skillName}/versions/${version}/deprecate`, {
|
|
246
|
+
method: "POST",
|
|
247
|
+
headers: {
|
|
248
|
+
"Content-Type": "application/json",
|
|
249
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
250
|
+
},
|
|
251
|
+
body: JSON.stringify({ message })
|
|
252
|
+
});
|
|
253
|
+
if (!response.ok) {
|
|
254
|
+
const error = await response.text();
|
|
255
|
+
return {
|
|
256
|
+
status: response.status,
|
|
257
|
+
error
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
const data = await response.json();
|
|
261
|
+
return {
|
|
262
|
+
status: response.status,
|
|
263
|
+
data
|
|
264
|
+
};
|
|
265
|
+
} catch (error) {
|
|
266
|
+
return {
|
|
267
|
+
status: 500,
|
|
268
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Remove deprecation from a skill version
|
|
274
|
+
*/
|
|
275
|
+
async function undeprecateSkillVersion(username, skillName, version) {
|
|
276
|
+
const config = getConfig();
|
|
277
|
+
if (!config) return {
|
|
278
|
+
status: 401,
|
|
279
|
+
error: "SDK not configured"
|
|
280
|
+
};
|
|
281
|
+
try {
|
|
282
|
+
const response = await fetch(`${config.baseUrl}/api/skills/@user/${username}/${skillName}/versions/${version}/deprecate`, {
|
|
283
|
+
method: "DELETE",
|
|
284
|
+
headers: { Authorization: `Bearer ${config.apiKey}` }
|
|
285
|
+
});
|
|
286
|
+
if (!response.ok) {
|
|
287
|
+
const error = await response.text();
|
|
288
|
+
return {
|
|
289
|
+
status: response.status,
|
|
290
|
+
error
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const data = await response.json();
|
|
294
|
+
return {
|
|
295
|
+
status: response.status,
|
|
296
|
+
data
|
|
297
|
+
};
|
|
298
|
+
} catch (error) {
|
|
299
|
+
return {
|
|
300
|
+
status: 500,
|
|
301
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Fetch a public skill list by owner type and name.
|
|
307
|
+
* Calls GET /api/skill-lists/lists/@{ownerType}/{ownerName}/{listName}
|
|
308
|
+
*/
|
|
309
|
+
async function fetchSkillList(ownerType, ownerName, listName) {
|
|
310
|
+
const config = getConfig();
|
|
311
|
+
try {
|
|
312
|
+
const response = await fetch(`${config.baseUrl}/api/skill-lists/lists/@${ownerType}/${ownerName}/${listName}`, {
|
|
313
|
+
method: "GET",
|
|
314
|
+
headers: {
|
|
315
|
+
"Content-Type": "application/json",
|
|
316
|
+
...config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
if (!response.ok) {
|
|
320
|
+
const error = await response.text();
|
|
321
|
+
return {
|
|
322
|
+
status: response.status,
|
|
323
|
+
error
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
const data = await response.json();
|
|
327
|
+
return {
|
|
328
|
+
status: response.status,
|
|
329
|
+
data
|
|
330
|
+
};
|
|
331
|
+
} catch (error) {
|
|
332
|
+
return {
|
|
333
|
+
status: 500,
|
|
334
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* List versions for a @github skill.
|
|
340
|
+
* Calls GET /api/skills/@github/{owner}/{repo}/{name}/versions
|
|
341
|
+
*/
|
|
342
|
+
async function listGithubSkillVersions(owner, repo, name) {
|
|
343
|
+
const config = getConfig();
|
|
344
|
+
try {
|
|
345
|
+
const response = await fetch(`${config.baseUrl}/api/skills/@github/${owner}/${repo}/${name}/versions`, {
|
|
346
|
+
method: "GET",
|
|
347
|
+
headers: {
|
|
348
|
+
"Content-Type": "application/json",
|
|
349
|
+
...config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}
|
|
350
|
+
}
|
|
351
|
+
});
|
|
352
|
+
if (!response.ok) {
|
|
353
|
+
const error = await response.text();
|
|
354
|
+
return {
|
|
355
|
+
status: response.status,
|
|
356
|
+
error
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
const data = await response.json();
|
|
360
|
+
return {
|
|
361
|
+
status: response.status,
|
|
362
|
+
data
|
|
363
|
+
};
|
|
364
|
+
} catch (error) {
|
|
365
|
+
return {
|
|
366
|
+
status: 500,
|
|
367
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Get a specific version of a @github skill (with download URL).
|
|
373
|
+
* Calls GET /api/skills/@github/{owner}/{repo}/{name}/versions/{version}
|
|
374
|
+
*/
|
|
375
|
+
async function getGithubSkillVersion(owner, repo, name, version) {
|
|
376
|
+
const config = getConfig();
|
|
377
|
+
try {
|
|
378
|
+
const response = await fetch(`${config.baseUrl}/api/skills/@github/${owner}/${repo}/${name}/versions/${version}`, {
|
|
379
|
+
method: "GET",
|
|
380
|
+
headers: {
|
|
381
|
+
"Content-Type": "application/json",
|
|
382
|
+
...config.apiKey ? { Authorization: `Bearer ${config.apiKey}` } : {}
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
if (!response.ok) {
|
|
386
|
+
const error = await response.text();
|
|
387
|
+
return {
|
|
388
|
+
status: response.status,
|
|
389
|
+
error
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
const data = await response.json();
|
|
393
|
+
return {
|
|
394
|
+
status: response.status,
|
|
395
|
+
data
|
|
396
|
+
};
|
|
397
|
+
} catch (error) {
|
|
398
|
+
return {
|
|
399
|
+
status: 500,
|
|
400
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Change skill visibility (public/private)
|
|
406
|
+
*/
|
|
407
|
+
async function changeSkillAccess(username, skillName, input) {
|
|
408
|
+
const config = getConfig();
|
|
409
|
+
if (!config) return {
|
|
410
|
+
status: 401,
|
|
411
|
+
error: "SDK not configured"
|
|
412
|
+
};
|
|
413
|
+
try {
|
|
414
|
+
const response = await fetch(`${config.baseUrl}/api/skills/@user/${username}/${skillName}/access`, {
|
|
415
|
+
method: "POST",
|
|
416
|
+
headers: {
|
|
417
|
+
"Content-Type": "application/json",
|
|
418
|
+
Authorization: `Bearer ${config.apiKey}`
|
|
419
|
+
},
|
|
420
|
+
body: JSON.stringify(input)
|
|
421
|
+
});
|
|
422
|
+
if (!response.ok) {
|
|
423
|
+
const error = await response.text();
|
|
424
|
+
try {
|
|
425
|
+
const errorJson = JSON.parse(error);
|
|
426
|
+
return {
|
|
427
|
+
status: response.status,
|
|
428
|
+
error: errorJson.message || errorJson.error || error
|
|
429
|
+
};
|
|
430
|
+
} catch {
|
|
431
|
+
return {
|
|
432
|
+
status: response.status,
|
|
433
|
+
error
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
const data = await response.json();
|
|
438
|
+
return {
|
|
439
|
+
status: response.status,
|
|
440
|
+
data
|
|
441
|
+
};
|
|
442
|
+
} catch (error) {
|
|
443
|
+
return {
|
|
444
|
+
status: 500,
|
|
445
|
+
error: error instanceof Error ? error.message : "Unknown error"
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
//#endregion
|
|
450
|
+
export { me as _, getGithubSkillVersion as a, getConfig as b, whoamiRequest as c, deleteSkillVersion as d, explorePublicSkills as f, listSkillVersions as g, listOrgSkillVersions as h, fetchSkillList as i, deleteOrgSkill as l, getSkillVersion as m, configure as n, listGithubSkillVersions as o, getOrgSkillVersion as p, deprecateSkillVersion as r, undeprecateSkillVersion as s, changeSkillAccess as t, deleteSkill as u, publishOrgSkill as v, publishSkill as y };
|