@lobehub/market-sdk 0.40.1 → 0.42.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/dist/index.d.mts +547 -312
- package/dist/index.mjs +925 -473
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// src/admin/MarketAdmin.ts
|
|
2
|
-
import
|
|
2
|
+
import debug14 from "debug";
|
|
3
3
|
|
|
4
4
|
// src/core/BaseSDK.ts
|
|
5
|
+
import { context, isSpanContextValid, trace } from "@opentelemetry/api";
|
|
5
6
|
import debug from "debug";
|
|
6
7
|
import { SignJWT } from "jose";
|
|
7
8
|
import urlJoin from "url-join";
|
|
@@ -27,7 +28,7 @@ var normalizeErrorDetails = (errorBody) => {
|
|
|
27
28
|
return void 0;
|
|
28
29
|
};
|
|
29
30
|
var MarketAPIError = class _MarketAPIError extends Error {
|
|
30
|
-
constructor(status, statusText, errorBody) {
|
|
31
|
+
constructor(status, statusText, errorBody, traceId) {
|
|
31
32
|
const errorDetails = normalizeErrorDetails(errorBody);
|
|
32
33
|
const errorCode = errorDetails == null ? void 0 : errorDetails.code;
|
|
33
34
|
const errorMessage = errorDetails == null ? void 0 : errorDetails.message;
|
|
@@ -37,6 +38,7 @@ var MarketAPIError = class _MarketAPIError extends Error {
|
|
|
37
38
|
this.status = status;
|
|
38
39
|
this.code = errorCode;
|
|
39
40
|
this.errorBody = errorBody;
|
|
41
|
+
this.traceId = traceId && /^[\da-f]{32}$/.test(traceId) && !/^0{32}$/.test(traceId) ? traceId : void 0;
|
|
40
42
|
if (Error.captureStackTrace) {
|
|
41
43
|
Error.captureStackTrace(this, _MarketAPIError);
|
|
42
44
|
}
|
|
@@ -62,7 +64,8 @@ var MarketAPIError = class _MarketAPIError extends Error {
|
|
|
62
64
|
errorBody: this.errorBody,
|
|
63
65
|
message: this.message,
|
|
64
66
|
name: this.name,
|
|
65
|
-
status: this.status
|
|
67
|
+
status: this.status,
|
|
68
|
+
traceId: this.traceId
|
|
66
69
|
};
|
|
67
70
|
}
|
|
68
71
|
};
|
|
@@ -100,7 +103,7 @@ var BaseSDK = class {
|
|
|
100
103
|
"Content-Type": "application/json",
|
|
101
104
|
"User-Agent": userAgent
|
|
102
105
|
};
|
|
103
|
-
log("Created new headers object
|
|
106
|
+
log("Created new headers object");
|
|
104
107
|
}
|
|
105
108
|
if (apiKey) {
|
|
106
109
|
this.headers.Authorization = `Bearer ${apiKey}`;
|
|
@@ -116,16 +119,7 @@ var BaseSDK = class {
|
|
|
116
119
|
this.headers["x-lobe-owner-account-id"] = String(options.ownerAccountId);
|
|
117
120
|
log("Owner account id configured: %d", options.ownerAccountId);
|
|
118
121
|
}
|
|
119
|
-
log("BaseSDK instance created
|
|
120
|
-
baseUrl: this.baseUrl,
|
|
121
|
-
defaultLocale: this.defaultLocale,
|
|
122
|
-
hasApiKey: !!apiKey,
|
|
123
|
-
hasInitialAccessToken: !!this.initialAccessToken,
|
|
124
|
-
hasM2MCredentials: !!this.clientId,
|
|
125
|
-
hasOwnerAccountId: options.ownerAccountId !== void 0,
|
|
126
|
-
hasSharedTokenState: !!this.sharedTokenState,
|
|
127
|
-
hasTrustedClientToken: !!options.trustedClientToken
|
|
128
|
-
});
|
|
122
|
+
log("BaseSDK instance created");
|
|
129
123
|
}
|
|
130
124
|
/**
|
|
131
125
|
* Sets the owner account id header for subsequent requests.
|
|
@@ -157,16 +151,32 @@ var BaseSDK = class {
|
|
|
157
151
|
*/
|
|
158
152
|
// eslint-disable-next-line no-undef
|
|
159
153
|
async request(url, options = {}) {
|
|
154
|
+
var _a, _b, _c, _d;
|
|
160
155
|
const requestUrl = urlJoin(this.apiBaseUrl, url);
|
|
161
|
-
|
|
156
|
+
const spanContext = trace.getSpanContext(context.active());
|
|
157
|
+
log("Sending request");
|
|
162
158
|
if (!this.initialAccessToken && this.clientId && this.clientSecret) {
|
|
163
159
|
await this.setM2MAuthToken();
|
|
164
160
|
}
|
|
165
161
|
const mergedHeaders = {
|
|
166
162
|
...this.headers,
|
|
167
|
-
...options.headers
|
|
163
|
+
...options.headers instanceof Headers || Array.isArray(options.headers) ? Object.fromEntries(new Headers(options.headers)) : options.headers
|
|
168
164
|
};
|
|
169
|
-
|
|
165
|
+
if (spanContext && isSpanContextValid(spanContext)) {
|
|
166
|
+
for (const key of Object.keys(mergedHeaders)) {
|
|
167
|
+
if (key.toLowerCase() === "traceparent" || key.toLowerCase() === "tracestate") {
|
|
168
|
+
delete mergedHeaders[key];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
mergedHeaders.traceparent = `00-${spanContext.traceId}-${spanContext.spanId}-${(spanContext.traceFlags & 1).toString(16).padStart(2, "0")}`;
|
|
172
|
+
const traceState = (_a = spanContext.traceState) == null ? void 0 : _a.serialize();
|
|
173
|
+
if (traceState) mergedHeaders.tracestate = traceState;
|
|
174
|
+
}
|
|
175
|
+
if (typeof FormData !== "undefined" && options.body instanceof FormData) {
|
|
176
|
+
for (const key of Object.keys(mergedHeaders)) {
|
|
177
|
+
if (key.toLowerCase() === "content-type") delete mergedHeaders[key];
|
|
178
|
+
}
|
|
179
|
+
}
|
|
170
180
|
const response = await fetch(requestUrl, {
|
|
171
181
|
...options,
|
|
172
182
|
headers: mergedHeaders
|
|
@@ -175,13 +185,19 @@ var BaseSDK = class {
|
|
|
175
185
|
let errorBody;
|
|
176
186
|
try {
|
|
177
187
|
errorBody = await response.json();
|
|
178
|
-
console.error("Request error: %s", JSON.stringify(errorBody));
|
|
179
188
|
} catch (e) {
|
|
180
189
|
errorBody = void 0;
|
|
181
190
|
}
|
|
182
|
-
|
|
191
|
+
const error = new MarketAPIError(
|
|
192
|
+
response.status,
|
|
193
|
+
response.statusText,
|
|
194
|
+
errorBody,
|
|
195
|
+
(_c = (_b = response.headers) == null ? void 0 : _b.get("x-market-trace-id")) != null ? _c : void 0
|
|
196
|
+
);
|
|
197
|
+
log("Request failed: status=%d traceId=%s", error.status, (_d = error.traceId) != null ? _d : "none");
|
|
198
|
+
throw error;
|
|
183
199
|
}
|
|
184
|
-
log("Request successful:
|
|
200
|
+
log("Request successful: status=%d", response.status);
|
|
185
201
|
if (response.status === 204) {
|
|
186
202
|
return void 0;
|
|
187
203
|
}
|
|
@@ -261,7 +277,7 @@ var BaseSDK = class {
|
|
|
261
277
|
}
|
|
262
278
|
async exchangeTokenForServer(clientAssertion) {
|
|
263
279
|
const tokenEndpoint = urlJoin(this.oauthBaseUrl, "token");
|
|
264
|
-
log("Exchanging token
|
|
280
|
+
log("Exchanging token");
|
|
265
281
|
const params = new URLSearchParams();
|
|
266
282
|
params.append("grant_type", "client_credentials");
|
|
267
283
|
params.append(
|
|
@@ -342,9 +358,21 @@ var BaseSDK = class {
|
|
|
342
358
|
import debug2 from "debug";
|
|
343
359
|
var log2 = debug2("lobe-market-sdk:admin:agents");
|
|
344
360
|
var AgentService = class extends BaseSDK {
|
|
361
|
+
/**
|
|
362
|
+
* Creates a cloud Agent and its current initial version, including required A2A metadata.
|
|
363
|
+
*/
|
|
364
|
+
async createAgent(data) {
|
|
365
|
+
log2("Creating Agent with initial version: %s", data.identifier);
|
|
366
|
+
return this.request("/admin/agents", {
|
|
367
|
+
body: JSON.stringify(data),
|
|
368
|
+
method: "POST"
|
|
369
|
+
});
|
|
370
|
+
}
|
|
345
371
|
/**
|
|
346
372
|
* Retrieves a list of agents with admin details
|
|
347
373
|
*
|
|
374
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
375
|
+
*
|
|
348
376
|
* Supports filtering, pagination, and sorting of results.
|
|
349
377
|
*
|
|
350
378
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -416,6 +444,46 @@ var AgentService = class extends BaseSDK {
|
|
|
416
444
|
log2("Agent updated successfully");
|
|
417
445
|
return result;
|
|
418
446
|
}
|
|
447
|
+
/**
|
|
448
|
+
* Updates a selected Agent version.
|
|
449
|
+
*
|
|
450
|
+
* @param id - Agent ID or identifier
|
|
451
|
+
* @param version - Agent or A2A implementation version string
|
|
452
|
+
* @param data - Mutable version fields
|
|
453
|
+
* @returns Promise resolving to the updated Agent version
|
|
454
|
+
*/
|
|
455
|
+
async updateAgentVersion(id, version, data) {
|
|
456
|
+
log2("Updating agent version: %s@%s, data: %O", id, version, data);
|
|
457
|
+
const result = await this.request(
|
|
458
|
+
`/admin/agents/${encodeURIComponent(String(id))}/versions/${encodeURIComponent(version)}`,
|
|
459
|
+
{
|
|
460
|
+
body: JSON.stringify(data),
|
|
461
|
+
method: "PUT"
|
|
462
|
+
}
|
|
463
|
+
);
|
|
464
|
+
log2("Agent version updated successfully: %s@%s", id, version);
|
|
465
|
+
return result;
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Creates a new version for an existing agent, inheriting A2A-level fields
|
|
469
|
+
* from the version the agent currently points to.
|
|
470
|
+
*
|
|
471
|
+
* @param id - Agent ID or identifier
|
|
472
|
+
* @param data - Version creation parameters (version string required)
|
|
473
|
+
* @returns Promise resolving to the created Agent version
|
|
474
|
+
*/
|
|
475
|
+
async createAgentVersion(id, data) {
|
|
476
|
+
log2("Creating agent version: %s@%s, data: %O", id, data.version);
|
|
477
|
+
const result = await this.request(
|
|
478
|
+
`/admin/agents/${encodeURIComponent(String(id))}/versions`,
|
|
479
|
+
{
|
|
480
|
+
body: JSON.stringify(data),
|
|
481
|
+
method: "POST"
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
log2("Agent version created successfully: %s@%s", id, result.version);
|
|
485
|
+
return result;
|
|
486
|
+
}
|
|
419
487
|
/**
|
|
420
488
|
* Updates agent publication status
|
|
421
489
|
*
|
|
@@ -844,18 +912,17 @@ var PluginService = class extends BaseSDK {
|
|
|
844
912
|
* This method is intended for use with scripts and bulk import operations.
|
|
845
913
|
*
|
|
846
914
|
* @param manifests - Array of plugin manifests to import
|
|
847
|
-
* @param
|
|
915
|
+
* @param _ownerId - Deprecated. Imports are attributed by the server authentication context.
|
|
848
916
|
* @returns Promise resolving to the import results with counts of success, skipped, failed, and a list of failed IDs
|
|
849
917
|
*/
|
|
850
|
-
async importPlugins(manifests,
|
|
918
|
+
async importPlugins(manifests, _ownerId) {
|
|
851
919
|
log5(`Starting batch plugin import of ${manifests.length} manifests`);
|
|
852
|
-
if (
|
|
853
|
-
log5(
|
|
920
|
+
if (_ownerId !== void 0) {
|
|
921
|
+
log5("Ignoring caller-supplied owner ID; imports use the server authentication context");
|
|
854
922
|
}
|
|
855
923
|
const response = await this.request("/admin/plugins/import", {
|
|
856
924
|
body: JSON.stringify({
|
|
857
|
-
manifests
|
|
858
|
-
ownerId
|
|
925
|
+
manifests
|
|
859
926
|
}),
|
|
860
927
|
method: "POST"
|
|
861
928
|
});
|
|
@@ -889,6 +956,8 @@ var PluginService = class extends BaseSDK {
|
|
|
889
956
|
/**
|
|
890
957
|
* Retrieves a list of plugins with admin details
|
|
891
958
|
*
|
|
959
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
960
|
+
*
|
|
892
961
|
* Supports filtering, pagination, and sorting of results.
|
|
893
962
|
*
|
|
894
963
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -1680,9 +1749,88 @@ var SkillCollectionService = class extends BaseSDK {
|
|
|
1680
1749
|
}
|
|
1681
1750
|
};
|
|
1682
1751
|
|
|
1683
|
-
// src/admin/services/
|
|
1752
|
+
// src/admin/services/SkillService.ts
|
|
1684
1753
|
import debug10 from "debug";
|
|
1685
|
-
var log10 = debug10("lobe-market-sdk:admin:
|
|
1754
|
+
var log10 = debug10("lobe-market-sdk:admin:skills");
|
|
1755
|
+
var SkillService = class extends BaseSDK {
|
|
1756
|
+
/** Create a manual Skill. Self-hosted category names resolve to directory identifiers. */
|
|
1757
|
+
async createSkill(data) {
|
|
1758
|
+
return this.request("/admin/skills", {
|
|
1759
|
+
body: JSON.stringify(data),
|
|
1760
|
+
method: "POST"
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
/** Import a GitHub Skill; omit icon to preserve it, or pass null to clear it. */
|
|
1764
|
+
async importFromGitHub(data) {
|
|
1765
|
+
return this.request("/admin/skills/import", {
|
|
1766
|
+
body: JSON.stringify(data),
|
|
1767
|
+
method: "POST"
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
/** Retrieve raw Admin detail and image metadata for editing. */
|
|
1771
|
+
async getSkill(id) {
|
|
1772
|
+
return this.request(`/admin/skills/${id}`);
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Update publication settings and the current version's category atomically.
|
|
1776
|
+
*
|
|
1777
|
+
* @param id - Skill database ID
|
|
1778
|
+
* @param data - Omit category to preserve it, or pass null to clear it
|
|
1779
|
+
* Self-hosted categories accept directory identifiers or unique names; unknown names return 400.
|
|
1780
|
+
* @returns Updated Skill metadata; read the category through the Skill detail endpoint
|
|
1781
|
+
* @throws If the Skill does not exist, or category is supplied without a current version
|
|
1782
|
+
*/
|
|
1783
|
+
async updateSkill(id, data) {
|
|
1784
|
+
log10("Updating skill: %d", id);
|
|
1785
|
+
const result = await this.request(`/admin/skills/${id}`, {
|
|
1786
|
+
body: JSON.stringify(data),
|
|
1787
|
+
method: "PUT"
|
|
1788
|
+
});
|
|
1789
|
+
log10("Updated skill: %d", id);
|
|
1790
|
+
return result;
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Retrieve Skills with Admin API status and visibility fields.
|
|
1794
|
+
*
|
|
1795
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
1796
|
+
*
|
|
1797
|
+
* @param params - Query parameters for filtering and pagination
|
|
1798
|
+
* @returns Paginated Skill list
|
|
1799
|
+
*/
|
|
1800
|
+
async getSkills(params = {}) {
|
|
1801
|
+
log10("Getting skills with params: %O", params);
|
|
1802
|
+
const queryString = this.buildQueryString(params);
|
|
1803
|
+
const result = await this.request(`/admin/skills${queryString}`);
|
|
1804
|
+
log10("Retrieved %d skills", result.items.length);
|
|
1805
|
+
return result;
|
|
1806
|
+
}
|
|
1807
|
+
/**
|
|
1808
|
+
* Import a skill from a .zip or .skill package.
|
|
1809
|
+
*
|
|
1810
|
+
* @param file - Skill package contents
|
|
1811
|
+
* @param options - Optional filename and identifier override
|
|
1812
|
+
* @returns Imported skill and version details
|
|
1813
|
+
*/
|
|
1814
|
+
async importPackage(file, options = {}) {
|
|
1815
|
+
const filename = options.filename || (typeof File !== "undefined" && file instanceof File ? file.name : "skill.zip");
|
|
1816
|
+
const formData = new FormData();
|
|
1817
|
+
formData.set("file", file, filename);
|
|
1818
|
+
if (options.icon !== void 0)
|
|
1819
|
+
formData.set("icon", options.icon === null ? "null" : options.icon);
|
|
1820
|
+
if (options.identifier) formData.set("identifier", options.identifier);
|
|
1821
|
+
log10("Importing skill package: %s", filename);
|
|
1822
|
+
const result = await this.request("/admin/skills/import/upload", {
|
|
1823
|
+
body: formData,
|
|
1824
|
+
method: "POST"
|
|
1825
|
+
});
|
|
1826
|
+
log10("Imported skill package %s with status %s", result.skill.identifier, result.status);
|
|
1827
|
+
return result;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1831
|
+
// src/admin/services/PluginEnvService.ts
|
|
1832
|
+
import debug11 from "debug";
|
|
1833
|
+
var log11 = debug11("lobe-market-sdk:admin:plugin-env");
|
|
1686
1834
|
var PluginEnvService = class extends BaseSDK {
|
|
1687
1835
|
/**
|
|
1688
1836
|
* Retrieves a paginated list of plugin environment variables
|
|
@@ -1691,11 +1839,11 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1691
1839
|
* @returns Promise resolving to the env list response
|
|
1692
1840
|
*/
|
|
1693
1841
|
async getPluginEnvs(params = {}) {
|
|
1694
|
-
|
|
1842
|
+
log11("Getting plugin envs with params: %O", params);
|
|
1695
1843
|
const queryString = this.buildQueryString(params);
|
|
1696
1844
|
const url = `/admin/plugins/env${queryString}`;
|
|
1697
1845
|
const result = await this.request(url);
|
|
1698
|
-
|
|
1846
|
+
log11("Retrieved %d plugin envs", result.data.length);
|
|
1699
1847
|
return result;
|
|
1700
1848
|
}
|
|
1701
1849
|
/**
|
|
@@ -1705,9 +1853,9 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1705
1853
|
* @returns Promise resolving to the env item
|
|
1706
1854
|
*/
|
|
1707
1855
|
async getPluginEnv(id) {
|
|
1708
|
-
|
|
1856
|
+
log11("Getting plugin env: %d", id);
|
|
1709
1857
|
const result = await this.request(`/admin/plugins/env/${id}`);
|
|
1710
|
-
|
|
1858
|
+
log11("Retrieved plugin env: %d", id);
|
|
1711
1859
|
return result;
|
|
1712
1860
|
}
|
|
1713
1861
|
/**
|
|
@@ -1717,12 +1865,12 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1717
1865
|
* @returns Promise resolving to the created env item
|
|
1718
1866
|
*/
|
|
1719
1867
|
async createPluginEnv(data) {
|
|
1720
|
-
|
|
1868
|
+
log11("Creating plugin env: %O", data);
|
|
1721
1869
|
const result = await this.request(`/admin/plugins/env`, {
|
|
1722
1870
|
body: JSON.stringify(data),
|
|
1723
1871
|
method: "POST"
|
|
1724
1872
|
});
|
|
1725
|
-
|
|
1873
|
+
log11("Plugin env created successfully");
|
|
1726
1874
|
return result;
|
|
1727
1875
|
}
|
|
1728
1876
|
/**
|
|
@@ -1733,12 +1881,12 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1733
1881
|
* @returns Promise resolving to the updated env item
|
|
1734
1882
|
*/
|
|
1735
1883
|
async updatePluginEnv(id, data) {
|
|
1736
|
-
|
|
1884
|
+
log11("Updating plugin env: %d, data: %O", id, data);
|
|
1737
1885
|
const result = await this.request(`/admin/plugins/env/${id}`, {
|
|
1738
1886
|
body: JSON.stringify(data),
|
|
1739
1887
|
method: "PUT"
|
|
1740
1888
|
});
|
|
1741
|
-
|
|
1889
|
+
log11("Plugin env updated successfully");
|
|
1742
1890
|
return result;
|
|
1743
1891
|
}
|
|
1744
1892
|
/**
|
|
@@ -1748,11 +1896,11 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1748
1896
|
* @returns Promise resolving to success response
|
|
1749
1897
|
*/
|
|
1750
1898
|
async deletePluginEnv(id) {
|
|
1751
|
-
|
|
1899
|
+
log11("Deleting plugin env: %d", id);
|
|
1752
1900
|
const result = await this.request(`/admin/plugins/env/${id}`, {
|
|
1753
1901
|
method: "DELETE"
|
|
1754
1902
|
});
|
|
1755
|
-
|
|
1903
|
+
log11("Plugin env deleted successfully");
|
|
1756
1904
|
return result;
|
|
1757
1905
|
}
|
|
1758
1906
|
/**
|
|
@@ -1762,19 +1910,19 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1762
1910
|
* @returns Promise resolving to import result
|
|
1763
1911
|
*/
|
|
1764
1912
|
async importPluginEnvs(data) {
|
|
1765
|
-
|
|
1913
|
+
log11("Batch importing plugin envs: %O", data);
|
|
1766
1914
|
const result = await this.request(`/admin/plugins/env/import`, {
|
|
1767
1915
|
body: JSON.stringify(data),
|
|
1768
1916
|
method: "POST"
|
|
1769
1917
|
});
|
|
1770
|
-
|
|
1918
|
+
log11("Batch import completed: %d envs imported", result.success);
|
|
1771
1919
|
return result;
|
|
1772
1920
|
}
|
|
1773
1921
|
};
|
|
1774
1922
|
|
|
1775
1923
|
// src/admin/services/OrganizationService.ts
|
|
1776
|
-
import
|
|
1777
|
-
var
|
|
1924
|
+
import debug12 from "debug";
|
|
1925
|
+
var log12 = debug12("lobe-market-sdk:admin:organizations");
|
|
1778
1926
|
var OrganizationService = class extends BaseSDK {
|
|
1779
1927
|
/**
|
|
1780
1928
|
* Retrieves a paginated list of organizations with admin details
|
|
@@ -1783,12 +1931,12 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1783
1931
|
* @returns Promise resolving to the organization list response
|
|
1784
1932
|
*/
|
|
1785
1933
|
async getOrganizations(params = {}) {
|
|
1786
|
-
|
|
1934
|
+
log12("Getting organizations with params: %O", params);
|
|
1787
1935
|
const queryString = this.buildQueryString(params);
|
|
1788
1936
|
const result = await this.request(
|
|
1789
1937
|
`/admin/organizations${queryString}`
|
|
1790
1938
|
);
|
|
1791
|
-
|
|
1939
|
+
log12("Retrieved %d organizations", result.data.length);
|
|
1792
1940
|
return result;
|
|
1793
1941
|
}
|
|
1794
1942
|
/**
|
|
@@ -1798,7 +1946,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1798
1946
|
* @returns Promise resolving to the organization detail
|
|
1799
1947
|
*/
|
|
1800
1948
|
async getOrganization(id) {
|
|
1801
|
-
|
|
1949
|
+
log12("Getting organization detail: %d", id);
|
|
1802
1950
|
return this.request(`/admin/organizations/${id}`);
|
|
1803
1951
|
}
|
|
1804
1952
|
/**
|
|
@@ -1808,7 +1956,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1808
1956
|
* @returns Promise resolving to the member list
|
|
1809
1957
|
*/
|
|
1810
1958
|
async getOrganizationMembers(id) {
|
|
1811
|
-
|
|
1959
|
+
log12("Getting organization members: %d", id);
|
|
1812
1960
|
return this.request(
|
|
1813
1961
|
`/admin/organizations/${id}/members`
|
|
1814
1962
|
);
|
|
@@ -1821,7 +1969,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1821
1969
|
* @returns Promise resolving to the updated organization
|
|
1822
1970
|
*/
|
|
1823
1971
|
async updateOrganization(id, data) {
|
|
1824
|
-
|
|
1972
|
+
log12("Updating organization: %d, data: %O", id, data);
|
|
1825
1973
|
return this.request(`/admin/organizations/${id}`, {
|
|
1826
1974
|
body: JSON.stringify(data),
|
|
1827
1975
|
method: "PUT"
|
|
@@ -1834,7 +1982,7 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1834
1982
|
* @returns Promise resolving to the archived organization
|
|
1835
1983
|
*/
|
|
1836
1984
|
async archiveOrganization(id) {
|
|
1837
|
-
|
|
1985
|
+
log12("Archiving organization: %d", id);
|
|
1838
1986
|
return this.request(`/admin/organizations/${id}/archive`, {
|
|
1839
1987
|
method: "PATCH"
|
|
1840
1988
|
});
|
|
@@ -1846,15 +1994,81 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1846
1994
|
* @returns Promise resolving to the restored organization
|
|
1847
1995
|
*/
|
|
1848
1996
|
async unarchiveOrganization(id) {
|
|
1849
|
-
|
|
1997
|
+
log12("Unarchiving organization: %d", id);
|
|
1850
1998
|
return this.request(`/admin/organizations/${id}/unarchive`, {
|
|
1851
1999
|
method: "PATCH"
|
|
1852
2000
|
});
|
|
1853
2001
|
}
|
|
1854
2002
|
};
|
|
1855
2003
|
|
|
2004
|
+
// src/admin/services/CategoryService.ts
|
|
2005
|
+
import debug13 from "debug";
|
|
2006
|
+
var log13 = debug13("lobe-market-sdk:admin:categories");
|
|
2007
|
+
var CategoryService = class extends BaseSDK {
|
|
2008
|
+
/** Lists categories and counts assets referencing them in any version. */
|
|
2009
|
+
async list(params) {
|
|
2010
|
+
log13("Listing categories for %s", params.assetType);
|
|
2011
|
+
return this.request(`/admin/categories${this.buildQueryString(params)}`);
|
|
2012
|
+
}
|
|
2013
|
+
/** Creates a category with a server-generated stable identifier. */
|
|
2014
|
+
async create(assetType, data) {
|
|
2015
|
+
log13("Creating category for %s", assetType);
|
|
2016
|
+
return this.request(`/admin/categories/${assetType}`, {
|
|
2017
|
+
body: JSON.stringify(data),
|
|
2018
|
+
method: "POST"
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
/** Updates presentation fields; icon: null clears the image, omission preserves it. */
|
|
2022
|
+
async update(assetType, identifier, data) {
|
|
2023
|
+
log13("Updating category %s for %s", identifier, assetType);
|
|
2024
|
+
return this.request(`/admin/categories/${assetType}/${encodeURIComponent(identifier)}`, {
|
|
2025
|
+
body: JSON.stringify(data),
|
|
2026
|
+
method: "PATCH"
|
|
2027
|
+
});
|
|
2028
|
+
}
|
|
2029
|
+
/** Deletes up to 200 categories and reassigns or clears all affected asset versions atomically. */
|
|
2030
|
+
async delete(assetType, data) {
|
|
2031
|
+
log13("Deleting %d categories for %s", data.identifiers.length, assetType);
|
|
2032
|
+
return this.request(`/admin/categories/${assetType}/delete`, {
|
|
2033
|
+
body: JSON.stringify(data),
|
|
2034
|
+
method: "POST"
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2039
|
+
// src/admin/services/SandboxSessionService.ts
|
|
2040
|
+
var SandboxSessionService = class extends BaseSDK {
|
|
2041
|
+
list(params = {}) {
|
|
2042
|
+
return this.request(`/admin/sandbox-sessions${this.buildQueryString(params)}`);
|
|
2043
|
+
}
|
|
2044
|
+
get(id) {
|
|
2045
|
+
return this.request(`/admin/sandbox-sessions/${id}`);
|
|
2046
|
+
}
|
|
2047
|
+
related(id, params = {}) {
|
|
2048
|
+
return this.request(`/admin/sandbox-sessions/${id}/related${this.buildQueryString(params)}`);
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
// src/admin/services/SandboxStorageService.ts
|
|
2053
|
+
var SandboxStorageService = class extends BaseSDK {
|
|
2054
|
+
measure(key) {
|
|
2055
|
+
return this.request(`/admin/sandbox-storage/${encodeURIComponent(key)}/measure`, {
|
|
2056
|
+
method: "POST"
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
efs() {
|
|
2060
|
+
return this.request("/admin/sandbox-storage/efs");
|
|
2061
|
+
}
|
|
2062
|
+
list(params = {}) {
|
|
2063
|
+
return this.request(`/admin/sandbox-storage${this.buildQueryString(params)}`);
|
|
2064
|
+
}
|
|
2065
|
+
get(key) {
|
|
2066
|
+
return this.request(`/admin/sandbox-storage/${encodeURIComponent(key)}`);
|
|
2067
|
+
}
|
|
2068
|
+
};
|
|
2069
|
+
|
|
1856
2070
|
// src/admin/MarketAdmin.ts
|
|
1857
|
-
var
|
|
2071
|
+
var log14 = debug14("lobe-market-sdk:admin");
|
|
1858
2072
|
var MarketAdmin = class extends BaseSDK {
|
|
1859
2073
|
/**
|
|
1860
2074
|
* Creates a new MarketAdmin instance
|
|
@@ -1868,7 +2082,10 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1868
2082
|
tokenExpiry: void 0
|
|
1869
2083
|
};
|
|
1870
2084
|
super({ ...options, apiKey }, void 0, sharedTokenState);
|
|
1871
|
-
|
|
2085
|
+
log14("MarketAdmin instance created");
|
|
2086
|
+
this.sandboxStorage = new SandboxStorageService(options, this.headers, sharedTokenState);
|
|
2087
|
+
this.sandboxSessions = new SandboxSessionService(options, this.headers, sharedTokenState);
|
|
2088
|
+
this.categories = new CategoryService(options, this.headers, sharedTokenState);
|
|
1872
2089
|
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
1873
2090
|
this.analysis = new AnalysisService(options, this.headers, sharedTokenState);
|
|
1874
2091
|
this.dependencies = new SystemDependencyService(options, this.headers, sharedTokenState);
|
|
@@ -1879,15 +2096,17 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1879
2096
|
this.reviews = new ReviewService(options, this.headers, sharedTokenState);
|
|
1880
2097
|
this.settings = new SettingsService(options, this.headers, sharedTokenState);
|
|
1881
2098
|
this.skillCollections = new SkillCollectionService(options, this.headers, sharedTokenState);
|
|
2099
|
+
this.skills = new SkillService(options, this.headers, sharedTokenState);
|
|
1882
2100
|
}
|
|
1883
2101
|
};
|
|
1884
2102
|
|
|
1885
2103
|
// src/market/market-sdk.ts
|
|
1886
|
-
import
|
|
2104
|
+
import { getAssetImagePath, getAssetInitialPath } from "@lobehub/market-types";
|
|
2105
|
+
import debug38 from "debug";
|
|
1887
2106
|
|
|
1888
2107
|
// src/market/services/AgentProfileService.ts
|
|
1889
|
-
import
|
|
1890
|
-
var
|
|
2108
|
+
import debug15 from "debug";
|
|
2109
|
+
var log15 = debug15("lobe-market-sdk:agent-profile");
|
|
1891
2110
|
var AgentProfileService = class extends BaseSDK {
|
|
1892
2111
|
/**
|
|
1893
2112
|
* Retrieves the current agent's profile
|
|
@@ -1899,9 +2118,9 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1899
2118
|
* @returns Promise resolving to the agent profile response
|
|
1900
2119
|
*/
|
|
1901
2120
|
async getProfile(options) {
|
|
1902
|
-
|
|
2121
|
+
log15("Getting agent profile");
|
|
1903
2122
|
const result = await this.request("/v1/agent/profile", options);
|
|
1904
|
-
|
|
2123
|
+
log15("Agent profile retrieved: id=%d, identifier=%s", result.agent.id, result.agent.identifier);
|
|
1905
2124
|
return result;
|
|
1906
2125
|
}
|
|
1907
2126
|
/**
|
|
@@ -1915,7 +2134,7 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1915
2134
|
* @returns Promise resolving to the updated agent profile response
|
|
1916
2135
|
*/
|
|
1917
2136
|
async updateProfile(data, options) {
|
|
1918
|
-
|
|
2137
|
+
log15("Updating agent profile: %O", data);
|
|
1919
2138
|
const result = await this.request("/v1/agent/profile", {
|
|
1920
2139
|
body: JSON.stringify(data),
|
|
1921
2140
|
headers: {
|
|
@@ -1924,18 +2143,20 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1924
2143
|
method: "PATCH",
|
|
1925
2144
|
...options
|
|
1926
2145
|
});
|
|
1927
|
-
|
|
2146
|
+
log15("Agent profile updated: id=%d, name=%s", result.agent.id, result.agent.name);
|
|
1928
2147
|
return result;
|
|
1929
2148
|
}
|
|
1930
2149
|
};
|
|
1931
2150
|
|
|
1932
2151
|
// src/market/services/AgentService.ts
|
|
1933
|
-
import
|
|
1934
|
-
var
|
|
2152
|
+
import debug16 from "debug";
|
|
2153
|
+
var log16 = debug16("lobe-market-sdk:agents");
|
|
1935
2154
|
var AgentService2 = class extends BaseSDK {
|
|
1936
2155
|
/**
|
|
1937
2156
|
* Retrieves a list of agents from the marketplace
|
|
1938
2157
|
*
|
|
2158
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
2159
|
+
*
|
|
1939
2160
|
* Supports filtering, pagination, and localization of results.
|
|
1940
2161
|
*
|
|
1941
2162
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -1946,9 +2167,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1946
2167
|
const locale = params.locale || this.defaultLocale;
|
|
1947
2168
|
const queryParams = { ...params, locale };
|
|
1948
2169
|
const queryString = this.buildQueryString(queryParams);
|
|
1949
|
-
|
|
2170
|
+
log16("Getting agent list: %O", queryParams);
|
|
1950
2171
|
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
1951
|
-
|
|
2172
|
+
log16("Retrieved %d agents", result.items.length);
|
|
1952
2173
|
return result;
|
|
1953
2174
|
}
|
|
1954
2175
|
/**
|
|
@@ -1965,9 +2186,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1965
2186
|
const locale = params.locale || this.defaultLocale;
|
|
1966
2187
|
const queryParams = { ...params, locale };
|
|
1967
2188
|
const queryString = this.buildQueryString(queryParams);
|
|
1968
|
-
|
|
2189
|
+
log16("Getting own agent list: %O", queryParams);
|
|
1969
2190
|
const result = await this.request(`/v1/agents/own${queryString}`, options);
|
|
1970
|
-
|
|
2191
|
+
log16("Retrieved %d own agents", result.items.length);
|
|
1971
2192
|
return result;
|
|
1972
2193
|
}
|
|
1973
2194
|
/**
|
|
@@ -1988,12 +2209,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1988
2209
|
queryParams.version = params.version.toString();
|
|
1989
2210
|
}
|
|
1990
2211
|
const queryString = this.buildQueryString(queryParams);
|
|
1991
|
-
|
|
2212
|
+
log16("Getting agent detail: %O", { id, ...params });
|
|
1992
2213
|
const result = await this.request(
|
|
1993
2214
|
`/v1/agents/detail/${id}${queryString}`,
|
|
1994
2215
|
options
|
|
1995
2216
|
);
|
|
1996
|
-
|
|
2217
|
+
log16("Agent detail successfully retrieved: %s", id);
|
|
1997
2218
|
return result;
|
|
1998
2219
|
}
|
|
1999
2220
|
/**
|
|
@@ -2009,12 +2230,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2009
2230
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
2010
2231
|
*/
|
|
2011
2232
|
async getPublishedIdentifiers(options) {
|
|
2012
|
-
|
|
2233
|
+
log16("Getting published agent identifiers");
|
|
2013
2234
|
const result = await this.request(
|
|
2014
2235
|
"/v1/agents/identifiers",
|
|
2015
2236
|
options
|
|
2016
2237
|
);
|
|
2017
|
-
|
|
2238
|
+
log16("Retrieved %d published agent identifiers", result.length);
|
|
2018
2239
|
return result;
|
|
2019
2240
|
}
|
|
2020
2241
|
/**
|
|
@@ -2025,9 +2246,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2025
2246
|
*/
|
|
2026
2247
|
async getSitemap(params = {}, options) {
|
|
2027
2248
|
const queryString = this.buildQueryString(params);
|
|
2028
|
-
|
|
2249
|
+
log16("Getting agent sitemap%s", queryString);
|
|
2029
2250
|
const result = await this.request(`/v1/agents/sitemap${queryString}`, options);
|
|
2030
|
-
|
|
2251
|
+
log16(
|
|
2031
2252
|
"Retrieved agent sitemap page %d/%d (%d items)",
|
|
2032
2253
|
result.currentPage,
|
|
2033
2254
|
result.totalPages,
|
|
@@ -2050,12 +2271,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2050
2271
|
const locale = params.locale || this.defaultLocale;
|
|
2051
2272
|
const queryParams = { ...params, locale };
|
|
2052
2273
|
const queryString = this.buildQueryString(queryParams);
|
|
2053
|
-
|
|
2274
|
+
log16("Getting agent categories: %O", queryParams);
|
|
2054
2275
|
const result = await this.request(
|
|
2055
2276
|
`/v1/agents/categories${queryString}`,
|
|
2056
2277
|
options
|
|
2057
2278
|
);
|
|
2058
|
-
|
|
2279
|
+
log16("Retrieved %d categories", result.length);
|
|
2059
2280
|
return result;
|
|
2060
2281
|
}
|
|
2061
2282
|
/**
|
|
@@ -2069,7 +2290,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2069
2290
|
* @returns Promise resolving to the upload response
|
|
2070
2291
|
*/
|
|
2071
2292
|
async uploadAgent(agentData, options) {
|
|
2072
|
-
|
|
2293
|
+
log16("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
2073
2294
|
const result = await this.request("/v1/agents/upload", {
|
|
2074
2295
|
body: JSON.stringify(agentData),
|
|
2075
2296
|
headers: {
|
|
@@ -2078,7 +2299,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2078
2299
|
method: "POST",
|
|
2079
2300
|
...options
|
|
2080
2301
|
});
|
|
2081
|
-
|
|
2302
|
+
log16("Agent uploaded successfully: %O", result);
|
|
2082
2303
|
return result;
|
|
2083
2304
|
}
|
|
2084
2305
|
/**
|
|
@@ -2089,7 +2310,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2089
2310
|
* @returns Promise resolving to the created agent response
|
|
2090
2311
|
*/
|
|
2091
2312
|
async createAgent(agentData, options) {
|
|
2092
|
-
|
|
2313
|
+
log16("Creating agent: %s", agentData.identifier);
|
|
2093
2314
|
const result = await this.request("/v1/agents/create", {
|
|
2094
2315
|
body: JSON.stringify(agentData),
|
|
2095
2316
|
headers: {
|
|
@@ -2098,7 +2319,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2098
2319
|
method: "POST",
|
|
2099
2320
|
...options
|
|
2100
2321
|
});
|
|
2101
|
-
|
|
2322
|
+
log16("Agent created successfully: %O", result);
|
|
2102
2323
|
return result;
|
|
2103
2324
|
}
|
|
2104
2325
|
/**
|
|
@@ -2109,7 +2330,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2109
2330
|
* @returns Promise resolving to the created version response
|
|
2110
2331
|
*/
|
|
2111
2332
|
async createAgentVersion(versionData, options) {
|
|
2112
|
-
|
|
2333
|
+
log16("Creating agent version: %s", versionData.identifier);
|
|
2113
2334
|
const result = await this.request("/v1/agents/version/create", {
|
|
2114
2335
|
body: JSON.stringify(versionData),
|
|
2115
2336
|
headers: {
|
|
@@ -2118,7 +2339,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2118
2339
|
method: "POST",
|
|
2119
2340
|
...options
|
|
2120
2341
|
});
|
|
2121
|
-
|
|
2342
|
+
log16("Agent version created successfully: %O", result);
|
|
2122
2343
|
return result;
|
|
2123
2344
|
}
|
|
2124
2345
|
/**
|
|
@@ -2129,7 +2350,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2129
2350
|
* @returns Promise resolving to the modified agent response
|
|
2130
2351
|
*/
|
|
2131
2352
|
async modifyAgent(agentData, options) {
|
|
2132
|
-
|
|
2353
|
+
log16("Modifying agent: %s", agentData.identifier);
|
|
2133
2354
|
const result = await this.request("/v1/agents/modify", {
|
|
2134
2355
|
body: JSON.stringify(agentData),
|
|
2135
2356
|
headers: {
|
|
@@ -2138,7 +2359,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2138
2359
|
method: "POST",
|
|
2139
2360
|
...options
|
|
2140
2361
|
});
|
|
2141
|
-
|
|
2362
|
+
log16("Agent modified successfully: %O", result);
|
|
2142
2363
|
return result;
|
|
2143
2364
|
}
|
|
2144
2365
|
/**
|
|
@@ -2149,7 +2370,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2149
2370
|
* @returns Promise resolving to the modified version response
|
|
2150
2371
|
*/
|
|
2151
2372
|
async modifyAgentVersion(versionData, options) {
|
|
2152
|
-
|
|
2373
|
+
log16("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
2153
2374
|
const result = await this.request("/v1/agents/version/modify", {
|
|
2154
2375
|
body: JSON.stringify(versionData),
|
|
2155
2376
|
headers: {
|
|
@@ -2158,7 +2379,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2158
2379
|
method: "POST",
|
|
2159
2380
|
...options
|
|
2160
2381
|
});
|
|
2161
|
-
|
|
2382
|
+
log16("Agent version modified successfully: %O", result);
|
|
2162
2383
|
return result;
|
|
2163
2384
|
}
|
|
2164
2385
|
/**
|
|
@@ -2169,13 +2390,13 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2169
2390
|
* @returns Promise resolving to true if agent exists, false otherwise
|
|
2170
2391
|
*/
|
|
2171
2392
|
async checkAgentExists(identifier, options) {
|
|
2172
|
-
|
|
2393
|
+
log16("Checking if agent exists: %s", identifier);
|
|
2173
2394
|
try {
|
|
2174
2395
|
await this.getAgentDetail(identifier, {}, options);
|
|
2175
|
-
|
|
2396
|
+
log16("Agent exists: %s", identifier);
|
|
2176
2397
|
return true;
|
|
2177
2398
|
} catch (e) {
|
|
2178
|
-
|
|
2399
|
+
log16("Agent does not exist: %s", identifier);
|
|
2179
2400
|
return false;
|
|
2180
2401
|
}
|
|
2181
2402
|
}
|
|
@@ -2188,7 +2409,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2188
2409
|
* @param options - Optional request init overrides
|
|
2189
2410
|
*/
|
|
2190
2411
|
async createEvent(eventData, options) {
|
|
2191
|
-
|
|
2412
|
+
log16("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
2192
2413
|
await this.request("/v1/agents/events", {
|
|
2193
2414
|
body: JSON.stringify(eventData),
|
|
2194
2415
|
headers: {
|
|
@@ -2209,7 +2430,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2209
2430
|
* @returns Promise resolving to the updated install count response
|
|
2210
2431
|
*/
|
|
2211
2432
|
async increaseInstallCount(identifier, options) {
|
|
2212
|
-
|
|
2433
|
+
log16("Increasing install count for agent: %s", identifier);
|
|
2213
2434
|
const result = await this.request("/v1/agents/install-count", {
|
|
2214
2435
|
body: JSON.stringify({ identifier }),
|
|
2215
2436
|
headers: {
|
|
@@ -2218,7 +2439,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2218
2439
|
method: "POST",
|
|
2219
2440
|
...options
|
|
2220
2441
|
});
|
|
2221
|
-
|
|
2442
|
+
log16("Install count increased for agent %s: %d", identifier, result.installCount);
|
|
2222
2443
|
return result;
|
|
2223
2444
|
}
|
|
2224
2445
|
/**
|
|
@@ -2233,9 +2454,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2233
2454
|
* @returns Promise resolving to the status change response
|
|
2234
2455
|
*/
|
|
2235
2456
|
async changeStatus(identifier, status, options) {
|
|
2236
|
-
|
|
2457
|
+
log16("Changing agent status: %s -> %s", identifier, status);
|
|
2237
2458
|
const result = await this.modifyAgent({ identifier, status }, options);
|
|
2238
|
-
|
|
2459
|
+
log16("Agent status changed: %s -> %s", identifier, result.status);
|
|
2239
2460
|
return {
|
|
2240
2461
|
identifier: result.identifier,
|
|
2241
2462
|
status: result.status,
|
|
@@ -2253,7 +2474,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2253
2474
|
* @returns Promise resolving to the status change response
|
|
2254
2475
|
*/
|
|
2255
2476
|
async publish(identifier, options) {
|
|
2256
|
-
|
|
2477
|
+
log16("Publishing agent: %s", identifier);
|
|
2257
2478
|
return this.changeStatus(identifier, "published", options);
|
|
2258
2479
|
}
|
|
2259
2480
|
/**
|
|
@@ -2268,7 +2489,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2268
2489
|
* @returns Promise resolving to the status change response
|
|
2269
2490
|
*/
|
|
2270
2491
|
async unpublish(identifier, options) {
|
|
2271
|
-
|
|
2492
|
+
log16("Unpublishing agent: %s", identifier);
|
|
2272
2493
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2273
2494
|
}
|
|
2274
2495
|
/**
|
|
@@ -2283,7 +2504,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2283
2504
|
* @returns Promise resolving to the status change response
|
|
2284
2505
|
*/
|
|
2285
2506
|
async archive(identifier, options) {
|
|
2286
|
-
|
|
2507
|
+
log16("Archiving agent: %s", identifier);
|
|
2287
2508
|
return this.changeStatus(identifier, "archived", options);
|
|
2288
2509
|
}
|
|
2289
2510
|
/**
|
|
@@ -2298,7 +2519,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2298
2519
|
* @returns Promise resolving to the status change response
|
|
2299
2520
|
*/
|
|
2300
2521
|
async deprecate(identifier, options) {
|
|
2301
|
-
|
|
2522
|
+
log16("Deprecating agent: %s", identifier);
|
|
2302
2523
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2303
2524
|
}
|
|
2304
2525
|
/**
|
|
@@ -2316,12 +2537,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2316
2537
|
const locale = params.locale || this.defaultLocale;
|
|
2317
2538
|
const queryParams = { ...params, locale };
|
|
2318
2539
|
const queryString = this.buildQueryString(queryParams);
|
|
2319
|
-
|
|
2540
|
+
log16("Getting agents by plugin: %s", params.pluginId);
|
|
2320
2541
|
const result = await this.request(
|
|
2321
2542
|
`/v1/agents/by-plugin${queryString}`,
|
|
2322
2543
|
options
|
|
2323
2544
|
);
|
|
2324
|
-
|
|
2545
|
+
log16("Retrieved %d agents for plugin %s", result.items.length, params.pluginId);
|
|
2325
2546
|
return result;
|
|
2326
2547
|
}
|
|
2327
2548
|
/**
|
|
@@ -2337,7 +2558,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2337
2558
|
* @returns Promise resolving to the fork response with new agent details
|
|
2338
2559
|
*/
|
|
2339
2560
|
async forkAgent(sourceIdentifier, forkData, options) {
|
|
2340
|
-
|
|
2561
|
+
log16("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2341
2562
|
const result = await this.request(`/v1/agents/${sourceIdentifier}/fork`, {
|
|
2342
2563
|
body: JSON.stringify(forkData),
|
|
2343
2564
|
headers: {
|
|
@@ -2346,7 +2567,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2346
2567
|
method: "POST",
|
|
2347
2568
|
...options
|
|
2348
2569
|
});
|
|
2349
|
-
|
|
2570
|
+
log16("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
2350
2571
|
return result;
|
|
2351
2572
|
}
|
|
2352
2573
|
/**
|
|
@@ -2360,12 +2581,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2360
2581
|
* @returns Promise resolving to the forks list response
|
|
2361
2582
|
*/
|
|
2362
2583
|
async getAgentForks(identifier, options) {
|
|
2363
|
-
|
|
2584
|
+
log16("Getting forks for agent: %s", identifier);
|
|
2364
2585
|
const result = await this.request(
|
|
2365
2586
|
`/v1/agents/${identifier}/forks`,
|
|
2366
2587
|
options
|
|
2367
2588
|
);
|
|
2368
|
-
|
|
2589
|
+
log16("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2369
2590
|
return result;
|
|
2370
2591
|
}
|
|
2371
2592
|
/**
|
|
@@ -2378,23 +2599,23 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2378
2599
|
* @returns Promise resolving to the fork source response
|
|
2379
2600
|
*/
|
|
2380
2601
|
async getAgentForkSource(identifier, options) {
|
|
2381
|
-
|
|
2602
|
+
log16("Getting fork source for agent: %s", identifier);
|
|
2382
2603
|
const result = await this.request(
|
|
2383
2604
|
`/v1/agents/${identifier}/fork-source`,
|
|
2384
2605
|
options
|
|
2385
2606
|
);
|
|
2386
2607
|
if (result.source) {
|
|
2387
|
-
|
|
2608
|
+
log16("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2388
2609
|
} else {
|
|
2389
|
-
|
|
2610
|
+
log16("Agent %s is not a fork (original agent)", identifier);
|
|
2390
2611
|
}
|
|
2391
2612
|
return result;
|
|
2392
2613
|
}
|
|
2393
2614
|
};
|
|
2394
2615
|
|
|
2395
2616
|
// src/market/services/AgentGroupService.ts
|
|
2396
|
-
import
|
|
2397
|
-
var
|
|
2617
|
+
import debug17 from "debug";
|
|
2618
|
+
var log17 = debug17("lobe-market-sdk:agent-groups");
|
|
2398
2619
|
var AgentGroupService = class extends BaseSDK {
|
|
2399
2620
|
/**
|
|
2400
2621
|
* Retrieves a list of agent groups from the marketplace
|
|
@@ -2409,12 +2630,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2409
2630
|
const locale = params.locale || this.defaultLocale;
|
|
2410
2631
|
const queryParams = { ...params, locale };
|
|
2411
2632
|
const queryString = this.buildQueryString(queryParams);
|
|
2412
|
-
|
|
2633
|
+
log17("Getting agent group list: %O", queryParams);
|
|
2413
2634
|
const result = await this.request(
|
|
2414
2635
|
`/v1/agent-groups${queryString}`,
|
|
2415
2636
|
options
|
|
2416
2637
|
);
|
|
2417
|
-
|
|
2638
|
+
log17("Retrieved %d agent groups", result.items.length);
|
|
2418
2639
|
return result;
|
|
2419
2640
|
}
|
|
2420
2641
|
/**
|
|
@@ -2431,12 +2652,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2431
2652
|
const locale = params.locale || this.defaultLocale;
|
|
2432
2653
|
const queryParams = { ...params, locale };
|
|
2433
2654
|
const queryString = this.buildQueryString(queryParams);
|
|
2434
|
-
|
|
2655
|
+
log17("Getting own agent group list: %O", queryParams);
|
|
2435
2656
|
const result = await this.request(
|
|
2436
2657
|
`/v1/agent-groups/own${queryString}`,
|
|
2437
2658
|
options
|
|
2438
2659
|
);
|
|
2439
|
-
|
|
2660
|
+
log17("Retrieved %d own agent groups", result.items.length);
|
|
2440
2661
|
return result;
|
|
2441
2662
|
}
|
|
2442
2663
|
/**
|
|
@@ -2457,12 +2678,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2457
2678
|
queryParams.version = params.version.toString();
|
|
2458
2679
|
}
|
|
2459
2680
|
const queryString = this.buildQueryString(queryParams);
|
|
2460
|
-
|
|
2681
|
+
log17("Getting agent group detail: %O", { identifier, ...params });
|
|
2461
2682
|
const result = await this.request(
|
|
2462
2683
|
`/v1/agent-groups/detail${queryString}`,
|
|
2463
2684
|
options
|
|
2464
2685
|
);
|
|
2465
|
-
|
|
2686
|
+
log17("Agent group detail successfully retrieved: %s", identifier);
|
|
2466
2687
|
return result;
|
|
2467
2688
|
}
|
|
2468
2689
|
/**
|
|
@@ -2476,7 +2697,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2476
2697
|
* @returns Promise resolving to the created agent group response
|
|
2477
2698
|
*/
|
|
2478
2699
|
async createAgentGroup(groupData, options) {
|
|
2479
|
-
|
|
2700
|
+
log17("Creating agent group: %s", groupData.identifier);
|
|
2480
2701
|
const result = await this.request("/v1/agent-groups/create", {
|
|
2481
2702
|
body: JSON.stringify(groupData),
|
|
2482
2703
|
headers: {
|
|
@@ -2485,7 +2706,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2485
2706
|
method: "POST",
|
|
2486
2707
|
...options
|
|
2487
2708
|
});
|
|
2488
|
-
|
|
2709
|
+
log17("Agent group created successfully: %O", result);
|
|
2489
2710
|
return result;
|
|
2490
2711
|
}
|
|
2491
2712
|
/**
|
|
@@ -2499,7 +2720,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2499
2720
|
* @returns Promise resolving to the created version response
|
|
2500
2721
|
*/
|
|
2501
2722
|
async createAgentGroupVersion(versionData, options) {
|
|
2502
|
-
|
|
2723
|
+
log17("Creating agent group version: %s", versionData.identifier);
|
|
2503
2724
|
const result = await this.request(
|
|
2504
2725
|
"/v1/agent-groups/version-create",
|
|
2505
2726
|
{
|
|
@@ -2511,7 +2732,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2511
2732
|
...options
|
|
2512
2733
|
}
|
|
2513
2734
|
);
|
|
2514
|
-
|
|
2735
|
+
log17("Agent group version created successfully: %O", result);
|
|
2515
2736
|
return result;
|
|
2516
2737
|
}
|
|
2517
2738
|
/**
|
|
@@ -2525,7 +2746,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2525
2746
|
* @returns Promise resolving to the modified agent group response
|
|
2526
2747
|
*/
|
|
2527
2748
|
async modifyAgentGroup(groupData, options) {
|
|
2528
|
-
|
|
2749
|
+
log17("Modifying agent group: %s", groupData.identifier);
|
|
2529
2750
|
const result = await this.request("/v1/agent-groups/modify", {
|
|
2530
2751
|
body: JSON.stringify(groupData),
|
|
2531
2752
|
headers: {
|
|
@@ -2534,7 +2755,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2534
2755
|
method: "POST",
|
|
2535
2756
|
...options
|
|
2536
2757
|
});
|
|
2537
|
-
|
|
2758
|
+
log17("Agent group modified successfully: %O", result);
|
|
2538
2759
|
return result;
|
|
2539
2760
|
}
|
|
2540
2761
|
/**
|
|
@@ -2545,13 +2766,13 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2545
2766
|
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2546
2767
|
*/
|
|
2547
2768
|
async checkAgentGroupExists(identifier, options) {
|
|
2548
|
-
|
|
2769
|
+
log17("Checking if agent group exists: %s", identifier);
|
|
2549
2770
|
try {
|
|
2550
2771
|
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2551
|
-
|
|
2772
|
+
log17("Agent group exists: %s", identifier);
|
|
2552
2773
|
return true;
|
|
2553
2774
|
} catch (e) {
|
|
2554
|
-
|
|
2775
|
+
log17("Agent group does not exist: %s", identifier);
|
|
2555
2776
|
return false;
|
|
2556
2777
|
}
|
|
2557
2778
|
}
|
|
@@ -2567,9 +2788,9 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2567
2788
|
* @returns Promise resolving to the status change response
|
|
2568
2789
|
*/
|
|
2569
2790
|
async changeStatus(identifier, status, options) {
|
|
2570
|
-
|
|
2791
|
+
log17("Changing agent group status: %s -> %s", identifier, status);
|
|
2571
2792
|
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2572
|
-
|
|
2793
|
+
log17("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2573
2794
|
return {
|
|
2574
2795
|
identifier: result.identifier,
|
|
2575
2796
|
status: result.status,
|
|
@@ -2588,7 +2809,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2588
2809
|
* @returns Promise resolving to the status change response
|
|
2589
2810
|
*/
|
|
2590
2811
|
async publish(identifier, options) {
|
|
2591
|
-
|
|
2812
|
+
log17("Publishing agent group: %s", identifier);
|
|
2592
2813
|
return this.changeStatus(identifier, "published", options);
|
|
2593
2814
|
}
|
|
2594
2815
|
/**
|
|
@@ -2603,7 +2824,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2603
2824
|
* @returns Promise resolving to the status change response
|
|
2604
2825
|
*/
|
|
2605
2826
|
async unpublish(identifier, options) {
|
|
2606
|
-
|
|
2827
|
+
log17("Unpublishing agent group: %s", identifier);
|
|
2607
2828
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2608
2829
|
}
|
|
2609
2830
|
/**
|
|
@@ -2618,7 +2839,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2618
2839
|
* @returns Promise resolving to the status change response
|
|
2619
2840
|
*/
|
|
2620
2841
|
async archive(identifier, options) {
|
|
2621
|
-
|
|
2842
|
+
log17("Archiving agent group: %s", identifier);
|
|
2622
2843
|
return this.changeStatus(identifier, "archived", options);
|
|
2623
2844
|
}
|
|
2624
2845
|
/**
|
|
@@ -2633,7 +2854,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2633
2854
|
* @returns Promise resolving to the status change response
|
|
2634
2855
|
*/
|
|
2635
2856
|
async deprecate(identifier, options) {
|
|
2636
|
-
|
|
2857
|
+
log17("Deprecating agent group: %s", identifier);
|
|
2637
2858
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2638
2859
|
}
|
|
2639
2860
|
/**
|
|
@@ -2649,7 +2870,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2649
2870
|
* @returns Promise resolving to the fork response with new group details
|
|
2650
2871
|
*/
|
|
2651
2872
|
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2652
|
-
|
|
2873
|
+
log17("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2653
2874
|
const result = await this.request(
|
|
2654
2875
|
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2655
2876
|
{
|
|
@@ -2661,7 +2882,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2661
2882
|
...options
|
|
2662
2883
|
}
|
|
2663
2884
|
);
|
|
2664
|
-
|
|
2885
|
+
log17(
|
|
2665
2886
|
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2666
2887
|
result.group.identifier,
|
|
2667
2888
|
result.group.id,
|
|
@@ -2680,12 +2901,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2680
2901
|
* @returns Promise resolving to the forks list response
|
|
2681
2902
|
*/
|
|
2682
2903
|
async getAgentGroupForks(identifier, options) {
|
|
2683
|
-
|
|
2904
|
+
log17("Getting forks for agent group: %s", identifier);
|
|
2684
2905
|
const result = await this.request(
|
|
2685
2906
|
`/v1/agent-groups/${identifier}/forks`,
|
|
2686
2907
|
options
|
|
2687
2908
|
);
|
|
2688
|
-
|
|
2909
|
+
log17("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2689
2910
|
return result;
|
|
2690
2911
|
}
|
|
2691
2912
|
/**
|
|
@@ -2698,24 +2919,24 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2698
2919
|
* @returns Promise resolving to the fork source response
|
|
2699
2920
|
*/
|
|
2700
2921
|
async getAgentGroupForkSource(identifier, options) {
|
|
2701
|
-
|
|
2922
|
+
log17("Getting fork source for agent group: %s", identifier);
|
|
2702
2923
|
const result = await this.request(
|
|
2703
2924
|
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2704
2925
|
options
|
|
2705
2926
|
);
|
|
2706
2927
|
if (result.source) {
|
|
2707
|
-
|
|
2928
|
+
log17("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2708
2929
|
} else {
|
|
2709
|
-
|
|
2930
|
+
log17("Agent group %s is not a fork (original group)", identifier);
|
|
2710
2931
|
}
|
|
2711
2932
|
return result;
|
|
2712
2933
|
}
|
|
2713
2934
|
};
|
|
2714
2935
|
|
|
2715
2936
|
// src/market/services/AuthService.ts
|
|
2716
|
-
import
|
|
2937
|
+
import debug18 from "debug";
|
|
2717
2938
|
import urlJoin2 from "url-join";
|
|
2718
|
-
var
|
|
2939
|
+
var log18 = debug18("lobe-market-sdk:auth");
|
|
2719
2940
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
2720
2941
|
/** Normalize token response from snake_case to camelCase fields */
|
|
2721
2942
|
static normalizeTokenResponse(data) {
|
|
@@ -2747,7 +2968,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2747
2968
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
2748
2969
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
2749
2970
|
}
|
|
2750
|
-
|
|
2971
|
+
log18("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2751
2972
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2752
2973
|
const params = new URLSearchParams();
|
|
2753
2974
|
params.set("grant_type", grantType);
|
|
@@ -2789,16 +3010,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2789
3010
|
try {
|
|
2790
3011
|
payload = await response.json();
|
|
2791
3012
|
} catch (error) {
|
|
2792
|
-
|
|
3013
|
+
log18("Failed to parse token response: %O", error);
|
|
2793
3014
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
2794
3015
|
}
|
|
2795
3016
|
if (!response.ok) {
|
|
2796
3017
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
2797
3018
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
2798
|
-
|
|
3019
|
+
log18("Error: %s", errorMsg);
|
|
2799
3020
|
throw new Error(errorMsg);
|
|
2800
3021
|
}
|
|
2801
|
-
|
|
3022
|
+
log18("Token exchange successful");
|
|
2802
3023
|
return _AuthService.normalizeTokenResponse(payload);
|
|
2803
3024
|
}
|
|
2804
3025
|
/**
|
|
@@ -2816,7 +3037,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2816
3037
|
if (!clientId || !token) {
|
|
2817
3038
|
throw new Error("clientId and token are required for token revocation");
|
|
2818
3039
|
}
|
|
2819
|
-
|
|
3040
|
+
log18("Revoking OAuth token (hint=%s)", tokenTypeHint != null ? tokenTypeHint : "none");
|
|
2820
3041
|
const revocationUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token/revocation");
|
|
2821
3042
|
const params = new URLSearchParams();
|
|
2822
3043
|
params.set("client_id", clientId);
|
|
@@ -2844,10 +3065,10 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2844
3065
|
} catch (e) {
|
|
2845
3066
|
}
|
|
2846
3067
|
const errorMsg = `Token revocation failed: ${response.status} ${errorDescription}`;
|
|
2847
|
-
|
|
3068
|
+
log18("Error: %s", errorMsg);
|
|
2848
3069
|
throw new Error(errorMsg);
|
|
2849
3070
|
}
|
|
2850
|
-
|
|
3071
|
+
log18("Token revocation successful");
|
|
2851
3072
|
}
|
|
2852
3073
|
/**
|
|
2853
3074
|
* Retrieves user information from the OIDC userinfo endpoint
|
|
@@ -2859,7 +3080,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2859
3080
|
* @returns Promise resolving to the user information
|
|
2860
3081
|
*/
|
|
2861
3082
|
async getUserInfo(accessToken, options) {
|
|
2862
|
-
|
|
3083
|
+
log18("Getting user info");
|
|
2863
3084
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
2864
3085
|
const response = await fetch(userInfoUrl, {
|
|
2865
3086
|
headers: {
|
|
@@ -2871,11 +3092,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2871
3092
|
});
|
|
2872
3093
|
if (!response.ok) {
|
|
2873
3094
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
2874
|
-
|
|
3095
|
+
log18("Error: %s", errorMsg);
|
|
2875
3096
|
throw new Error(errorMsg);
|
|
2876
3097
|
}
|
|
2877
3098
|
const userInfo = await response.json();
|
|
2878
|
-
|
|
3099
|
+
log18("User info retrieved successfully");
|
|
2879
3100
|
return userInfo;
|
|
2880
3101
|
}
|
|
2881
3102
|
/**
|
|
@@ -2889,7 +3110,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2889
3110
|
* @returns Promise resolving to the client credentials
|
|
2890
3111
|
*/
|
|
2891
3112
|
async registerClient(clientData, options) {
|
|
2892
|
-
|
|
3113
|
+
log18("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
2893
3114
|
const result = await this.request("/v1/clients/register", {
|
|
2894
3115
|
body: JSON.stringify(clientData),
|
|
2895
3116
|
headers: {
|
|
@@ -2898,7 +3119,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2898
3119
|
method: "POST",
|
|
2899
3120
|
...options
|
|
2900
3121
|
});
|
|
2901
|
-
|
|
3122
|
+
log18("Client registered successfully: %s", result.client_id);
|
|
2902
3123
|
return result;
|
|
2903
3124
|
}
|
|
2904
3125
|
/**
|
|
@@ -2910,9 +3131,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2910
3131
|
* @returns Promise resolving to the access token and expiration time
|
|
2911
3132
|
*/
|
|
2912
3133
|
async getM2MToken() {
|
|
2913
|
-
|
|
3134
|
+
log18("Fetching M2M token");
|
|
2914
3135
|
const tokenInfo = await this.fetchM2MToken();
|
|
2915
|
-
|
|
3136
|
+
log18("M2M token fetched successfully");
|
|
2916
3137
|
return tokenInfo;
|
|
2917
3138
|
}
|
|
2918
3139
|
/** OAuth handoff response shapes */
|
|
@@ -2938,7 +3159,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2938
3159
|
async getOAuthHandoff(id, options) {
|
|
2939
3160
|
var _a, _b;
|
|
2940
3161
|
if (!id) throw new Error("id is required");
|
|
2941
|
-
|
|
3162
|
+
log18("Getting OAuth handoff: %s", id);
|
|
2942
3163
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
2943
3164
|
const response = await fetch(handoffUrl, {
|
|
2944
3165
|
headers: {
|
|
@@ -2954,19 +3175,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2954
3175
|
code: json.code,
|
|
2955
3176
|
redirectUri: json.redirectUri
|
|
2956
3177
|
});
|
|
2957
|
-
|
|
3178
|
+
log18("OAuth handoff success for id: %s", id);
|
|
2958
3179
|
return result;
|
|
2959
3180
|
}
|
|
2960
3181
|
if (response.status === 202) {
|
|
2961
|
-
|
|
3182
|
+
log18("OAuth handoff pending for id: %s", id);
|
|
2962
3183
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
2963
3184
|
}
|
|
2964
3185
|
if (response.status === 404) {
|
|
2965
|
-
|
|
3186
|
+
log18("OAuth handoff consumed for id: %s", id);
|
|
2966
3187
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
2967
3188
|
}
|
|
2968
3189
|
if (response.status === 410) {
|
|
2969
|
-
|
|
3190
|
+
log18("OAuth handoff expired for id: %s", id);
|
|
2970
3191
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
2971
3192
|
}
|
|
2972
3193
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -2977,7 +3198,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2977
3198
|
}
|
|
2978
3199
|
} catch (e) {
|
|
2979
3200
|
}
|
|
2980
|
-
|
|
3201
|
+
log18("Error: %s", errorMessage);
|
|
2981
3202
|
throw new Error(errorMessage);
|
|
2982
3203
|
}
|
|
2983
3204
|
/**
|
|
@@ -2991,21 +3212,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2991
3212
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
2992
3213
|
const startedAt = Date.now();
|
|
2993
3214
|
const { signal, requestInit } = params;
|
|
2994
|
-
|
|
3215
|
+
log18("Start polling OAuth handoff: %s", id);
|
|
2995
3216
|
while (true) {
|
|
2996
3217
|
if (signal == null ? void 0 : signal.aborted) {
|
|
2997
3218
|
const err = new Error("Polling aborted");
|
|
2998
|
-
|
|
3219
|
+
log18("Error: %s", err.message);
|
|
2999
3220
|
throw err;
|
|
3000
3221
|
}
|
|
3001
3222
|
if (Date.now() - startedAt > timeoutMs) {
|
|
3002
3223
|
const err = new Error("Polling timeout");
|
|
3003
|
-
|
|
3224
|
+
log18("Error: %s", err.message);
|
|
3004
3225
|
throw err;
|
|
3005
3226
|
}
|
|
3006
3227
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
3007
3228
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
3008
|
-
|
|
3229
|
+
log18("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
3009
3230
|
return result;
|
|
3010
3231
|
}
|
|
3011
3232
|
await new Promise((resolve) => {
|
|
@@ -3026,9 +3247,9 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
3026
3247
|
var AuthService = _AuthService;
|
|
3027
3248
|
|
|
3028
3249
|
// src/market/services/ConnectService.ts
|
|
3029
|
-
import
|
|
3250
|
+
import debug19 from "debug";
|
|
3030
3251
|
import urlJoin3 from "url-join";
|
|
3031
|
-
var
|
|
3252
|
+
var log19 = debug19("lobe-market-sdk:connect");
|
|
3032
3253
|
var CIMD_CLIENT_METADATA_VERSION = "v1";
|
|
3033
3254
|
var CIMD_CLIENT_METADATA_VERSION_BY_PROVIDER = {
|
|
3034
3255
|
posthog: "v2"
|
|
@@ -3052,9 +3273,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3052
3273
|
*/
|
|
3053
3274
|
async listProviders(options) {
|
|
3054
3275
|
var _a;
|
|
3055
|
-
|
|
3276
|
+
log19("Listing connect providers");
|
|
3056
3277
|
const result = await this.request("/connect/providers", options);
|
|
3057
|
-
|
|
3278
|
+
log19("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
3058
3279
|
return result;
|
|
3059
3280
|
}
|
|
3060
3281
|
/**
|
|
@@ -3068,12 +3289,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3068
3289
|
*/
|
|
3069
3290
|
async getProvider(provider, options) {
|
|
3070
3291
|
var _a;
|
|
3071
|
-
|
|
3292
|
+
log19("Getting provider details: %s", provider);
|
|
3072
3293
|
const result = await this.request(
|
|
3073
3294
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
3074
3295
|
options
|
|
3075
3296
|
);
|
|
3076
|
-
|
|
3297
|
+
log19("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
3077
3298
|
return result;
|
|
3078
3299
|
}
|
|
3079
3300
|
/**
|
|
@@ -3092,12 +3313,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3092
3313
|
const metadataParams = hasParams ? params : void 0;
|
|
3093
3314
|
const requestOptions = hasParams ? options : params;
|
|
3094
3315
|
const version = getCimdClientMetadataVersion(provider, metadataParams == null ? void 0 : metadataParams.version);
|
|
3095
|
-
|
|
3316
|
+
log19("Getting CIMD client metadata for provider: %s version: %s", provider, version);
|
|
3096
3317
|
const result = await this.request(
|
|
3097
3318
|
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata/${encodeURIComponent(version)}.json`,
|
|
3098
3319
|
requestOptions
|
|
3099
3320
|
);
|
|
3100
|
-
|
|
3321
|
+
log19("Retrieved CIMD client metadata: %s", result.client_id);
|
|
3101
3322
|
return result;
|
|
3102
3323
|
}
|
|
3103
3324
|
/**
|
|
@@ -3137,7 +3358,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3137
3358
|
* ```
|
|
3138
3359
|
*/
|
|
3139
3360
|
async authorize(provider, params, options) {
|
|
3140
|
-
|
|
3361
|
+
log19("Requesting authorization code for provider: %s", provider);
|
|
3141
3362
|
const result = await this.request(
|
|
3142
3363
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
3143
3364
|
{
|
|
@@ -3149,7 +3370,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3149
3370
|
...options
|
|
3150
3371
|
}
|
|
3151
3372
|
);
|
|
3152
|
-
|
|
3373
|
+
log19("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
3153
3374
|
return result;
|
|
3154
3375
|
}
|
|
3155
3376
|
/**
|
|
@@ -3175,7 +3396,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3175
3396
|
* ```
|
|
3176
3397
|
*/
|
|
3177
3398
|
getAuthorizeUrl(provider, params) {
|
|
3178
|
-
|
|
3399
|
+
log19(
|
|
3179
3400
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
3180
3401
|
provider
|
|
3181
3402
|
);
|
|
@@ -3189,7 +3410,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3189
3410
|
const queryString = queryParams.toString();
|
|
3190
3411
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
3191
3412
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
3192
|
-
|
|
3413
|
+
log19("Generated authorize URL: %s", url);
|
|
3193
3414
|
return url;
|
|
3194
3415
|
}
|
|
3195
3416
|
/**
|
|
@@ -3203,12 +3424,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3203
3424
|
* @returns Promise resolving to the connection status
|
|
3204
3425
|
*/
|
|
3205
3426
|
async getStatus(provider, options) {
|
|
3206
|
-
|
|
3427
|
+
log19("Getting connection status for provider: %s", provider);
|
|
3207
3428
|
const result = await this.request(
|
|
3208
3429
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
3209
3430
|
options
|
|
3210
3431
|
);
|
|
3211
|
-
|
|
3432
|
+
log19("Provider %s connection status: connected=%s", provider, result.connected);
|
|
3212
3433
|
return result;
|
|
3213
3434
|
}
|
|
3214
3435
|
/**
|
|
@@ -3221,9 +3442,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3221
3442
|
*/
|
|
3222
3443
|
async listConnections(options) {
|
|
3223
3444
|
var _a;
|
|
3224
|
-
|
|
3445
|
+
log19("Listing user connections");
|
|
3225
3446
|
const result = await this.request("/connect/connections", options);
|
|
3226
|
-
|
|
3447
|
+
log19("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
3227
3448
|
return result;
|
|
3228
3449
|
}
|
|
3229
3450
|
/**
|
|
@@ -3237,12 +3458,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3237
3458
|
* @returns Promise resolving to the connection health status
|
|
3238
3459
|
*/
|
|
3239
3460
|
async getHealth(provider, options) {
|
|
3240
|
-
|
|
3461
|
+
log19("Checking health for provider: %s", provider);
|
|
3241
3462
|
const result = await this.request(
|
|
3242
3463
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
3243
3464
|
options
|
|
3244
3465
|
);
|
|
3245
|
-
|
|
3466
|
+
log19("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
3246
3467
|
return result;
|
|
3247
3468
|
}
|
|
3248
3469
|
/**
|
|
@@ -3255,9 +3476,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3255
3476
|
*/
|
|
3256
3477
|
async getAllHealth(options) {
|
|
3257
3478
|
var _a, _b, _c;
|
|
3258
|
-
|
|
3479
|
+
log19("Checking health for all connections");
|
|
3259
3480
|
const result = await this.request("/connect/health", options);
|
|
3260
|
-
|
|
3481
|
+
log19(
|
|
3261
3482
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
3262
3483
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
3263
3484
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -3276,7 +3497,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3276
3497
|
* @returns Promise resolving to the refresh result
|
|
3277
3498
|
*/
|
|
3278
3499
|
async refresh(provider, options) {
|
|
3279
|
-
|
|
3500
|
+
log19("Refreshing token for provider: %s", provider);
|
|
3280
3501
|
const result = await this.request(
|
|
3281
3502
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
3282
3503
|
{
|
|
@@ -3284,7 +3505,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3284
3505
|
...options
|
|
3285
3506
|
}
|
|
3286
3507
|
);
|
|
3287
|
-
|
|
3508
|
+
log19("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
3288
3509
|
return result;
|
|
3289
3510
|
}
|
|
3290
3511
|
/**
|
|
@@ -3298,7 +3519,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3298
3519
|
* @returns Promise resolving to the revoke result
|
|
3299
3520
|
*/
|
|
3300
3521
|
async revoke(provider, options) {
|
|
3301
|
-
|
|
3522
|
+
log19("Revoking connection for provider: %s", provider);
|
|
3302
3523
|
const result = await this.request(
|
|
3303
3524
|
`/connect/${encodeURIComponent(provider)}`,
|
|
3304
3525
|
{
|
|
@@ -3306,14 +3527,14 @@ var ConnectService = class extends BaseSDK {
|
|
|
3306
3527
|
...options
|
|
3307
3528
|
}
|
|
3308
3529
|
);
|
|
3309
|
-
|
|
3530
|
+
log19("Connection revoked for %s: success=%s", provider, result.success);
|
|
3310
3531
|
return result;
|
|
3311
3532
|
}
|
|
3312
3533
|
};
|
|
3313
3534
|
|
|
3314
3535
|
// src/market/services/CredService.ts
|
|
3315
|
-
import
|
|
3316
|
-
var
|
|
3536
|
+
import debug20 from "debug";
|
|
3537
|
+
var log20 = debug20("lobe-market-sdk:creds");
|
|
3317
3538
|
var CredService = class extends BaseSDK {
|
|
3318
3539
|
// ===========================================================================
|
|
3319
3540
|
// List & Get Operations
|
|
@@ -3329,9 +3550,9 @@ var CredService = class extends BaseSDK {
|
|
|
3329
3550
|
*/
|
|
3330
3551
|
async list(options) {
|
|
3331
3552
|
var _a;
|
|
3332
|
-
|
|
3553
|
+
log20("Listing user credentials");
|
|
3333
3554
|
const result = await this.request("/v1/user/creds", options);
|
|
3334
|
-
|
|
3555
|
+
log20("Found %d credentials", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
3335
3556
|
return result;
|
|
3336
3557
|
}
|
|
3337
3558
|
/**
|
|
@@ -3346,7 +3567,7 @@ var CredService = class extends BaseSDK {
|
|
|
3346
3567
|
* @returns Promise resolving to the credential details
|
|
3347
3568
|
*/
|
|
3348
3569
|
async get(id, getOptions, options) {
|
|
3349
|
-
|
|
3570
|
+
log20("Getting credential: %d (decrypt=%s)", id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
3350
3571
|
const queryParams = {};
|
|
3351
3572
|
if (getOptions == null ? void 0 : getOptions.decrypt) {
|
|
3352
3573
|
queryParams.decrypt = "true";
|
|
@@ -3356,7 +3577,7 @@ var CredService = class extends BaseSDK {
|
|
|
3356
3577
|
`/v1/user/creds/${id}${queryString}`,
|
|
3357
3578
|
options
|
|
3358
3579
|
);
|
|
3359
|
-
|
|
3580
|
+
log20("Retrieved credential: %s", result.key);
|
|
3360
3581
|
return result;
|
|
3361
3582
|
}
|
|
3362
3583
|
// ===========================================================================
|
|
@@ -3375,7 +3596,7 @@ var CredService = class extends BaseSDK {
|
|
|
3375
3596
|
* @returns Promise resolving to the created credential
|
|
3376
3597
|
*/
|
|
3377
3598
|
async createKV(data, options) {
|
|
3378
|
-
|
|
3599
|
+
log20("Creating KV credential: %s (type=%s)", data.key, data.type);
|
|
3379
3600
|
const result = await this.request("/v1/user/creds/kv", {
|
|
3380
3601
|
body: JSON.stringify(data),
|
|
3381
3602
|
headers: {
|
|
@@ -3384,7 +3605,7 @@ var CredService = class extends BaseSDK {
|
|
|
3384
3605
|
method: "POST",
|
|
3385
3606
|
...options
|
|
3386
3607
|
});
|
|
3387
|
-
|
|
3608
|
+
log20("Created KV credential: %d", result.id);
|
|
3388
3609
|
return result;
|
|
3389
3610
|
}
|
|
3390
3611
|
/**
|
|
@@ -3398,7 +3619,7 @@ var CredService = class extends BaseSDK {
|
|
|
3398
3619
|
* @returns Promise resolving to the created credential
|
|
3399
3620
|
*/
|
|
3400
3621
|
async createOAuth(data, options) {
|
|
3401
|
-
|
|
3622
|
+
log20("Creating OAuth credential: %s (connectionId=%d)", data.key, data.oauthConnectionId);
|
|
3402
3623
|
const result = await this.request("/v1/user/creds/oauth", {
|
|
3403
3624
|
body: JSON.stringify(data),
|
|
3404
3625
|
headers: {
|
|
@@ -3407,7 +3628,7 @@ var CredService = class extends BaseSDK {
|
|
|
3407
3628
|
method: "POST",
|
|
3408
3629
|
...options
|
|
3409
3630
|
});
|
|
3410
|
-
|
|
3631
|
+
log20("Created OAuth credential: %d", result.id);
|
|
3411
3632
|
return result;
|
|
3412
3633
|
}
|
|
3413
3634
|
/**
|
|
@@ -3421,7 +3642,7 @@ var CredService = class extends BaseSDK {
|
|
|
3421
3642
|
* @returns Promise resolving to the created credential
|
|
3422
3643
|
*/
|
|
3423
3644
|
async createFile(data, options) {
|
|
3424
|
-
|
|
3645
|
+
log20("Creating file credential: %s (fileName=%s)", data.key, data.fileName);
|
|
3425
3646
|
const result = await this.request("/v1/user/creds/file", {
|
|
3426
3647
|
body: JSON.stringify(data),
|
|
3427
3648
|
headers: {
|
|
@@ -3430,7 +3651,7 @@ var CredService = class extends BaseSDK {
|
|
|
3430
3651
|
method: "POST",
|
|
3431
3652
|
...options
|
|
3432
3653
|
});
|
|
3433
|
-
|
|
3654
|
+
log20("Created file credential: %d", result.id);
|
|
3434
3655
|
return result;
|
|
3435
3656
|
}
|
|
3436
3657
|
// ===========================================================================
|
|
@@ -3448,7 +3669,7 @@ var CredService = class extends BaseSDK {
|
|
|
3448
3669
|
* @returns Promise resolving to the updated credential
|
|
3449
3670
|
*/
|
|
3450
3671
|
async update(id, data, options) {
|
|
3451
|
-
|
|
3672
|
+
log20("Updating credential: %d", id);
|
|
3452
3673
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3453
3674
|
body: JSON.stringify(data),
|
|
3454
3675
|
headers: {
|
|
@@ -3457,7 +3678,7 @@ var CredService = class extends BaseSDK {
|
|
|
3457
3678
|
method: "PATCH",
|
|
3458
3679
|
...options
|
|
3459
3680
|
});
|
|
3460
|
-
|
|
3681
|
+
log20("Updated credential: %d", result.id);
|
|
3461
3682
|
return result;
|
|
3462
3683
|
}
|
|
3463
3684
|
// ===========================================================================
|
|
@@ -3478,7 +3699,7 @@ var CredService = class extends BaseSDK {
|
|
|
3478
3699
|
* @returns Promise resolving to the updated credential
|
|
3479
3700
|
*/
|
|
3480
3701
|
async share(id, data, options) {
|
|
3481
|
-
|
|
3702
|
+
log20("Sharing credential %d with org %s", id, data.orgId);
|
|
3482
3703
|
const result = await this.request(`/v1/user/creds/${id}/share`, {
|
|
3483
3704
|
body: JSON.stringify(data),
|
|
3484
3705
|
headers: {
|
|
@@ -3487,7 +3708,7 @@ var CredService = class extends BaseSDK {
|
|
|
3487
3708
|
method: "POST",
|
|
3488
3709
|
...options
|
|
3489
3710
|
});
|
|
3490
|
-
|
|
3711
|
+
log20("Shared credential: %d", result.id);
|
|
3491
3712
|
return result;
|
|
3492
3713
|
}
|
|
3493
3714
|
/**
|
|
@@ -3502,12 +3723,12 @@ var CredService = class extends BaseSDK {
|
|
|
3502
3723
|
* @returns Promise resolving to the updated credential
|
|
3503
3724
|
*/
|
|
3504
3725
|
async publish(id, options) {
|
|
3505
|
-
|
|
3726
|
+
log20("Publishing credential: %d", id);
|
|
3506
3727
|
const result = await this.request(`/v1/user/creds/${id}/publish`, {
|
|
3507
3728
|
method: "POST",
|
|
3508
3729
|
...options
|
|
3509
3730
|
});
|
|
3510
|
-
|
|
3731
|
+
log20("Published credential: %d", result.id);
|
|
3511
3732
|
return result;
|
|
3512
3733
|
}
|
|
3513
3734
|
/**
|
|
@@ -3522,12 +3743,12 @@ var CredService = class extends BaseSDK {
|
|
|
3522
3743
|
* @returns Promise resolving to the updated credential
|
|
3523
3744
|
*/
|
|
3524
3745
|
async unshare(id, options) {
|
|
3525
|
-
|
|
3746
|
+
log20("Unsharing credential: %d", id);
|
|
3526
3747
|
const result = await this.request(`/v1/user/creds/${id}/unshare`, {
|
|
3527
3748
|
method: "POST",
|
|
3528
3749
|
...options
|
|
3529
3750
|
});
|
|
3530
|
-
|
|
3751
|
+
log20("Unshared credential: %d", result.id);
|
|
3531
3752
|
return result;
|
|
3532
3753
|
}
|
|
3533
3754
|
// ===========================================================================
|
|
@@ -3543,12 +3764,12 @@ var CredService = class extends BaseSDK {
|
|
|
3543
3764
|
* @returns Promise resolving to the delete result
|
|
3544
3765
|
*/
|
|
3545
3766
|
async delete(id, options) {
|
|
3546
|
-
|
|
3767
|
+
log20("Deleting credential by ID: %d", id);
|
|
3547
3768
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3548
3769
|
method: "DELETE",
|
|
3549
3770
|
...options
|
|
3550
3771
|
});
|
|
3551
|
-
|
|
3772
|
+
log20("Deleted credential: %d, success=%s", id, result.success);
|
|
3552
3773
|
return result;
|
|
3553
3774
|
}
|
|
3554
3775
|
/**
|
|
@@ -3562,7 +3783,7 @@ var CredService = class extends BaseSDK {
|
|
|
3562
3783
|
* @returns Promise resolving to the delete result
|
|
3563
3784
|
*/
|
|
3564
3785
|
async deleteByKey(key, options) {
|
|
3565
|
-
|
|
3786
|
+
log20("Deleting credential by key: %s", key);
|
|
3566
3787
|
const result = await this.request(
|
|
3567
3788
|
`/v1/user/creds/key/${encodeURIComponent(key)}`,
|
|
3568
3789
|
{
|
|
@@ -3570,7 +3791,7 @@ var CredService = class extends BaseSDK {
|
|
|
3570
3791
|
...options
|
|
3571
3792
|
}
|
|
3572
3793
|
);
|
|
3573
|
-
|
|
3794
|
+
log20("Deleted credential by key: %s, success=%s", key, result.success);
|
|
3574
3795
|
return result;
|
|
3575
3796
|
}
|
|
3576
3797
|
// ===========================================================================
|
|
@@ -3589,12 +3810,12 @@ var CredService = class extends BaseSDK {
|
|
|
3589
3810
|
* @returns Promise resolving to the credential status list
|
|
3590
3811
|
*/
|
|
3591
3812
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
3592
|
-
|
|
3813
|
+
log20("Getting skill cred status: %s", skillIdentifier);
|
|
3593
3814
|
const result = await this.request(
|
|
3594
3815
|
`/v1/skills/${encodeURIComponent(skillIdentifier)}/creds/status`,
|
|
3595
3816
|
options
|
|
3596
3817
|
);
|
|
3597
|
-
|
|
3818
|
+
log20("Skill %s has %d credential requirements", skillIdentifier, result.length);
|
|
3598
3819
|
return result;
|
|
3599
3820
|
}
|
|
3600
3821
|
// ===========================================================================
|
|
@@ -3633,7 +3854,7 @@ var CredService = class extends BaseSDK {
|
|
|
3633
3854
|
*/
|
|
3634
3855
|
async inject(request, options) {
|
|
3635
3856
|
var _a, _b, _c, _d;
|
|
3636
|
-
|
|
3857
|
+
log20("Injecting credentials by keys: %O (sandbox=%s)", request.keys, request.sandbox);
|
|
3637
3858
|
const result = await this.request(
|
|
3638
3859
|
"/v1/plugins/run-buildin-tools/inject-creds",
|
|
3639
3860
|
{
|
|
@@ -3645,7 +3866,7 @@ var CredService = class extends BaseSDK {
|
|
|
3645
3866
|
...options
|
|
3646
3867
|
}
|
|
3647
3868
|
);
|
|
3648
|
-
|
|
3869
|
+
log20(
|
|
3649
3870
|
"Inject result: success=%s, env=%d, files=%d, notFound=%d",
|
|
3650
3871
|
result.success,
|
|
3651
3872
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3687,7 +3908,7 @@ var CredService = class extends BaseSDK {
|
|
|
3687
3908
|
*/
|
|
3688
3909
|
async injectForSkill(request, options) {
|
|
3689
3910
|
var _a, _b, _c, _d;
|
|
3690
|
-
|
|
3911
|
+
log20(
|
|
3691
3912
|
"Injecting credentials for skill: %s (sandbox=%s)",
|
|
3692
3913
|
request.skillIdentifier,
|
|
3693
3914
|
request.sandbox
|
|
@@ -3703,7 +3924,7 @@ var CredService = class extends BaseSDK {
|
|
|
3703
3924
|
...options
|
|
3704
3925
|
}
|
|
3705
3926
|
);
|
|
3706
|
-
|
|
3927
|
+
log20(
|
|
3707
3928
|
"Inject result: success=%s, env=%d, files=%d, missing=%d",
|
|
3708
3929
|
result.success,
|
|
3709
3930
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3714,10 +3935,44 @@ var CredService = class extends BaseSDK {
|
|
|
3714
3935
|
}
|
|
3715
3936
|
};
|
|
3716
3937
|
|
|
3938
|
+
// src/market/services/DeploymentService.ts
|
|
3939
|
+
import debug21 from "debug";
|
|
3940
|
+
var log21 = debug21("lobe-market-sdk:deployments");
|
|
3941
|
+
var DeploymentService = class extends BaseSDK {
|
|
3942
|
+
async prepareUpload(data, options) {
|
|
3943
|
+
log21("Preparing deployment upload with %d files", data.files.length);
|
|
3944
|
+
const result = await this.request(
|
|
3945
|
+
"/v1/deployments/uploads/prepare",
|
|
3946
|
+
{
|
|
3947
|
+
...options,
|
|
3948
|
+
body: JSON.stringify(data),
|
|
3949
|
+
method: "POST"
|
|
3950
|
+
}
|
|
3951
|
+
);
|
|
3952
|
+
return result.data;
|
|
3953
|
+
}
|
|
3954
|
+
async ingestUpload(uploadId, options) {
|
|
3955
|
+
log21("Ingesting deployment upload: %s", uploadId);
|
|
3956
|
+
const result = await this.request(
|
|
3957
|
+
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/ingest`,
|
|
3958
|
+
{ ...options, method: "POST" }
|
|
3959
|
+
);
|
|
3960
|
+
return result.data;
|
|
3961
|
+
}
|
|
3962
|
+
async finalizeUpload(uploadId, options) {
|
|
3963
|
+
log21("Finalizing deployment upload: %s", uploadId);
|
|
3964
|
+
const result = await this.request(
|
|
3965
|
+
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/finalize`,
|
|
3966
|
+
{ ...options, method: "POST" }
|
|
3967
|
+
);
|
|
3968
|
+
return result.data;
|
|
3969
|
+
}
|
|
3970
|
+
};
|
|
3971
|
+
|
|
3717
3972
|
// src/market/services/DiscoveryService.ts
|
|
3718
|
-
import
|
|
3973
|
+
import debug22 from "debug";
|
|
3719
3974
|
import urlJoin4 from "url-join";
|
|
3720
|
-
var
|
|
3975
|
+
var log22 = debug22("lobe-market-sdk:discovery");
|
|
3721
3976
|
var DiscoveryService = class extends BaseSDK {
|
|
3722
3977
|
/**
|
|
3723
3978
|
* Retrieves the service discovery document
|
|
@@ -3729,9 +3984,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3729
3984
|
* @returns Promise resolving to the service discovery document
|
|
3730
3985
|
*/
|
|
3731
3986
|
async getDiscoveryDocument() {
|
|
3732
|
-
|
|
3987
|
+
log22("Fetching discovery document");
|
|
3733
3988
|
if (this.discoveryDoc) {
|
|
3734
|
-
|
|
3989
|
+
log22("Returning cached discovery document");
|
|
3735
3990
|
return this.discoveryDoc;
|
|
3736
3991
|
}
|
|
3737
3992
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -3739,14 +3994,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3739
3994
|
throw new Error(await res.text());
|
|
3740
3995
|
}
|
|
3741
3996
|
this.discoveryDoc = await res.json();
|
|
3742
|
-
|
|
3997
|
+
log22("Discovery document successfully fetched");
|
|
3743
3998
|
return this.discoveryDoc;
|
|
3744
3999
|
}
|
|
3745
4000
|
};
|
|
3746
4001
|
|
|
3747
4002
|
// src/market/services/FeedbackService.ts
|
|
3748
|
-
import
|
|
3749
|
-
var
|
|
4003
|
+
import debug23 from "debug";
|
|
4004
|
+
var log23 = debug23("lobe-market-sdk:feedback");
|
|
3750
4005
|
var FeedbackService = class extends BaseSDK {
|
|
3751
4006
|
/**
|
|
3752
4007
|
* Submits user feedback
|
|
@@ -3776,7 +4031,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3776
4031
|
* ```
|
|
3777
4032
|
*/
|
|
3778
4033
|
async submitFeedback(data, options) {
|
|
3779
|
-
|
|
4034
|
+
log23("Submitting feedback: %s", data.title);
|
|
3780
4035
|
const result = await this.request("/v1/user/feedback", {
|
|
3781
4036
|
body: JSON.stringify(data),
|
|
3782
4037
|
headers: {
|
|
@@ -3785,18 +4040,29 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3785
4040
|
method: "POST",
|
|
3786
4041
|
...options
|
|
3787
4042
|
});
|
|
3788
|
-
|
|
4043
|
+
log23("Feedback submitted successfully: %s", result.issueId);
|
|
3789
4044
|
return result;
|
|
3790
4045
|
}
|
|
3791
4046
|
};
|
|
3792
4047
|
|
|
3793
4048
|
// src/market/services/PluginsService.ts
|
|
3794
|
-
import
|
|
3795
|
-
var
|
|
4049
|
+
import debug24 from "debug";
|
|
4050
|
+
var log24 = debug24("lobe-market-sdk:plugins");
|
|
4051
|
+
function encodeBase64(input) {
|
|
4052
|
+
if (typeof Buffer !== "undefined") {
|
|
4053
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
4054
|
+
}
|
|
4055
|
+
const bytes = new TextEncoder().encode(input);
|
|
4056
|
+
let binary = "";
|
|
4057
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
4058
|
+
return btoa(binary);
|
|
4059
|
+
}
|
|
3796
4060
|
var PluginsService = class extends BaseSDK {
|
|
3797
4061
|
/**
|
|
3798
4062
|
* Retrieves a list of plugins from the marketplace
|
|
3799
4063
|
*
|
|
4064
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
4065
|
+
*
|
|
3800
4066
|
* Supports filtering, pagination, and localization of results.
|
|
3801
4067
|
*
|
|
3802
4068
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -3807,9 +4073,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
3807
4073
|
const locale = params.locale || this.defaultLocale;
|
|
3808
4074
|
const queryParams = { ...params, locale };
|
|
3809
4075
|
const queryString = this.buildQueryString(queryParams);
|
|
3810
|
-
|
|
4076
|
+
log24("Getting plugin list: %O", queryParams);
|
|
3811
4077
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
3812
|
-
|
|
4078
|
+
log24("Retrieved %d plugins", result.items.length);
|
|
3813
4079
|
return result;
|
|
3814
4080
|
}
|
|
3815
4081
|
/**
|
|
@@ -3827,12 +4093,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3827
4093
|
const locale = params.locale || this.defaultLocale;
|
|
3828
4094
|
const queryParams = { ...params, locale };
|
|
3829
4095
|
const queryString = this.buildQueryString(queryParams);
|
|
3830
|
-
|
|
4096
|
+
log24("Getting plugin categories: %O", queryParams);
|
|
3831
4097
|
const result = await this.request(
|
|
3832
4098
|
`/v1/plugins/categories${queryString}`,
|
|
3833
4099
|
options
|
|
3834
4100
|
);
|
|
3835
|
-
|
|
4101
|
+
log24("Retrieved %d categories", result.length);
|
|
3836
4102
|
return result;
|
|
3837
4103
|
}
|
|
3838
4104
|
/**
|
|
@@ -3846,12 +4112,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3846
4112
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
3847
4113
|
*/
|
|
3848
4114
|
async getPublishedIdentifiers(options) {
|
|
3849
|
-
|
|
4115
|
+
log24("Getting published plugin identifiers");
|
|
3850
4116
|
const result = await this.request(
|
|
3851
4117
|
"/v1/plugins/identifiers",
|
|
3852
4118
|
options
|
|
3853
4119
|
);
|
|
3854
|
-
|
|
4120
|
+
log24("Retrieved %d published plugin identifiers", result.length);
|
|
3855
4121
|
return result;
|
|
3856
4122
|
}
|
|
3857
4123
|
/**
|
|
@@ -3862,12 +4128,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3862
4128
|
*/
|
|
3863
4129
|
async getSitemap(params = {}, options) {
|
|
3864
4130
|
const queryString = this.buildQueryString(params);
|
|
3865
|
-
|
|
4131
|
+
log24("Getting plugin sitemap%s", queryString);
|
|
3866
4132
|
const result = await this.request(
|
|
3867
4133
|
`/v1/plugins/sitemap${queryString}`,
|
|
3868
4134
|
options
|
|
3869
4135
|
);
|
|
3870
|
-
|
|
4136
|
+
log24(
|
|
3871
4137
|
"Retrieved plugin sitemap page %d/%d (%d items)",
|
|
3872
4138
|
result.currentPage,
|
|
3873
4139
|
result.totalPages,
|
|
@@ -3892,7 +4158,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3892
4158
|
version,
|
|
3893
4159
|
identifier
|
|
3894
4160
|
}, options) {
|
|
3895
|
-
|
|
4161
|
+
log24("Getting plugin manifest: %O", { identifier, locale, version });
|
|
3896
4162
|
const localeParam = locale || this.defaultLocale;
|
|
3897
4163
|
const params = { locale: localeParam };
|
|
3898
4164
|
if (version) {
|
|
@@ -3903,7 +4169,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3903
4169
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
3904
4170
|
options
|
|
3905
4171
|
);
|
|
3906
|
-
|
|
4172
|
+
log24("Plugin manifest successfully retrieved: %s", identifier);
|
|
3907
4173
|
return manifest;
|
|
3908
4174
|
}
|
|
3909
4175
|
/**
|
|
@@ -3920,7 +4186,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3920
4186
|
version,
|
|
3921
4187
|
identifier
|
|
3922
4188
|
}, options) {
|
|
3923
|
-
|
|
4189
|
+
log24("Getting plugin detail: %O", { identifier, locale, version });
|
|
3924
4190
|
const localeParam = locale || this.defaultLocale;
|
|
3925
4191
|
const params = { locale: localeParam };
|
|
3926
4192
|
if (version) {
|
|
@@ -3931,7 +4197,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3931
4197
|
`/v1/plugins/${identifier}${queryString}`,
|
|
3932
4198
|
options
|
|
3933
4199
|
);
|
|
3934
|
-
|
|
4200
|
+
log24("Plugin manifest successfully retrieved: %s", identifier);
|
|
3935
4201
|
return manifest;
|
|
3936
4202
|
}
|
|
3937
4203
|
/**
|
|
@@ -3946,7 +4212,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3946
4212
|
*
|
|
3947
4213
|
*/
|
|
3948
4214
|
async reportInstallation(reportData) {
|
|
3949
|
-
|
|
4215
|
+
log24("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
3950
4216
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
3951
4217
|
body: JSON.stringify(reportData),
|
|
3952
4218
|
headers: {
|
|
@@ -3954,7 +4220,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3954
4220
|
},
|
|
3955
4221
|
method: "POST"
|
|
3956
4222
|
});
|
|
3957
|
-
|
|
4223
|
+
log24("Installation report submitted successfully: %O", result);
|
|
3958
4224
|
return result;
|
|
3959
4225
|
}
|
|
3960
4226
|
/**
|
|
@@ -3968,7 +4234,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3968
4234
|
* @returns Promise resolving to the report submission response
|
|
3969
4235
|
*/
|
|
3970
4236
|
async reportCall(reportData) {
|
|
3971
|
-
|
|
4237
|
+
log24(
|
|
3972
4238
|
"Reporting call for %s@%s - %s:%s",
|
|
3973
4239
|
reportData.identifier,
|
|
3974
4240
|
reportData.version,
|
|
@@ -3982,7 +4248,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3982
4248
|
},
|
|
3983
4249
|
method: "POST"
|
|
3984
4250
|
});
|
|
3985
|
-
|
|
4251
|
+
log24("Call report submitted successfully: %O", result);
|
|
3986
4252
|
return result;
|
|
3987
4253
|
}
|
|
3988
4254
|
/**
|
|
@@ -3994,7 +4260,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3994
4260
|
* @param options - Optional request init overrides
|
|
3995
4261
|
*/
|
|
3996
4262
|
async createEvent(eventData, options) {
|
|
3997
|
-
|
|
4263
|
+
log24("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
3998
4264
|
await this.request("/v1/plugins/events", {
|
|
3999
4265
|
body: JSON.stringify(eventData),
|
|
4000
4266
|
headers: {
|
|
@@ -4024,7 +4290,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4024
4290
|
* ```
|
|
4025
4291
|
*/
|
|
4026
4292
|
async callCloudGateway(request, options) {
|
|
4027
|
-
|
|
4293
|
+
log24("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
4028
4294
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
4029
4295
|
body: JSON.stringify(request),
|
|
4030
4296
|
headers: {
|
|
@@ -4033,7 +4299,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4033
4299
|
method: "POST",
|
|
4034
4300
|
...options
|
|
4035
4301
|
});
|
|
4036
|
-
|
|
4302
|
+
log24("Cloud gateway call completed: %O", {
|
|
4037
4303
|
identifier: request.identifier,
|
|
4038
4304
|
isError: result.isError,
|
|
4039
4305
|
toolName: request.toolName
|
|
@@ -4073,19 +4339,27 @@ var PluginsService = class extends BaseSDK {
|
|
|
4073
4339
|
* );
|
|
4074
4340
|
* ```
|
|
4075
4341
|
*/
|
|
4076
|
-
async runBuildInTool(toolName, params,
|
|
4077
|
-
|
|
4342
|
+
async runBuildInTool(toolName, params, context2, options) {
|
|
4343
|
+
log24(
|
|
4078
4344
|
"Running built-in tool: %s for user %s, topic %s",
|
|
4079
4345
|
toolName,
|
|
4080
|
-
|
|
4081
|
-
|
|
4346
|
+
context2.userId,
|
|
4347
|
+
context2.topicId
|
|
4082
4348
|
);
|
|
4083
4349
|
const result = await this.request("/v1/plugins/run-buildin-tools", {
|
|
4084
4350
|
body: JSON.stringify({
|
|
4085
|
-
params,
|
|
4351
|
+
paramsB64: encodeBase64(JSON.stringify(params)),
|
|
4352
|
+
paramsEncoding: "base64",
|
|
4086
4353
|
toolName,
|
|
4087
|
-
|
|
4088
|
-
|
|
4354
|
+
...context2.sandboxCwd && { sandboxCwd: context2.sandboxCwd },
|
|
4355
|
+
...context2.sandboxSpecification && {
|
|
4356
|
+
sandboxSpecification: context2.sandboxSpecification
|
|
4357
|
+
},
|
|
4358
|
+
...context2.sandboxWorkingDir && { sandboxWorkingDir: context2.sandboxWorkingDir },
|
|
4359
|
+
...context2.sandboxInstanceId && { sandboxInstanceId: context2.sandboxInstanceId },
|
|
4360
|
+
...context2.sandboxMode && { sandboxMode: context2.sandboxMode },
|
|
4361
|
+
topicId: context2.topicId,
|
|
4362
|
+
userId: context2.userId
|
|
4089
4363
|
}),
|
|
4090
4364
|
headers: {
|
|
4091
4365
|
"Content-Type": "application/json"
|
|
@@ -4093,7 +4367,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4093
4367
|
method: "POST",
|
|
4094
4368
|
...options
|
|
4095
4369
|
});
|
|
4096
|
-
|
|
4370
|
+
log24("Built-in tool execution completed: %O", {
|
|
4097
4371
|
success: result.success,
|
|
4098
4372
|
toolName
|
|
4099
4373
|
});
|
|
@@ -4107,8 +4381,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4107
4381
|
* @param options - Additional options (background, timeout)
|
|
4108
4382
|
* @returns Promise resolving to command execution result
|
|
4109
4383
|
*/
|
|
4110
|
-
async runCommand(command,
|
|
4111
|
-
return this.runBuildInTool("runCommand", { command, ...options },
|
|
4384
|
+
async runCommand(command, context2, options) {
|
|
4385
|
+
return this.runBuildInTool("runCommand", { command, ...options }, context2);
|
|
4112
4386
|
}
|
|
4113
4387
|
/**
|
|
4114
4388
|
* Read a file from the Code Interpreter sandbox
|
|
@@ -4118,8 +4392,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4118
4392
|
* @param options - Line range options (startLine, endLine)
|
|
4119
4393
|
* @returns Promise resolving to file content
|
|
4120
4394
|
*/
|
|
4121
|
-
async readFile(path,
|
|
4122
|
-
return this.runBuildInTool("readLocalFile", { path, ...options },
|
|
4395
|
+
async readFile(path, context2, options) {
|
|
4396
|
+
return this.runBuildInTool("readLocalFile", { path, ...options }, context2);
|
|
4123
4397
|
}
|
|
4124
4398
|
/**
|
|
4125
4399
|
* Write content to a file in the Code Interpreter sandbox
|
|
@@ -4130,8 +4404,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4130
4404
|
* @param options - Additional options (createDirectories)
|
|
4131
4405
|
* @returns Promise resolving to write result
|
|
4132
4406
|
*/
|
|
4133
|
-
async writeFile(path, content,
|
|
4134
|
-
return this.runBuildInTool("writeLocalFile", { content, path, ...options },
|
|
4407
|
+
async writeFile(path, content, context2, options) {
|
|
4408
|
+
return this.runBuildInTool("writeLocalFile", { content, path, ...options }, context2);
|
|
4135
4409
|
}
|
|
4136
4410
|
/**
|
|
4137
4411
|
* List files in a directory in the Code Interpreter sandbox
|
|
@@ -4140,8 +4414,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4140
4414
|
* @param context - User and topic context
|
|
4141
4415
|
* @returns Promise resolving to directory listing
|
|
4142
4416
|
*/
|
|
4143
|
-
async listFiles(directoryPath,
|
|
4144
|
-
return this.runBuildInTool("listLocalFiles", { directoryPath },
|
|
4417
|
+
async listFiles(directoryPath, context2) {
|
|
4418
|
+
return this.runBuildInTool("listLocalFiles", { directoryPath }, context2);
|
|
4145
4419
|
}
|
|
4146
4420
|
/**
|
|
4147
4421
|
* Search for files matching a glob pattern
|
|
@@ -4151,8 +4425,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4151
4425
|
* @param directory - Base directory (optional)
|
|
4152
4426
|
* @returns Promise resolving to matching files
|
|
4153
4427
|
*/
|
|
4154
|
-
async globFiles(pattern,
|
|
4155
|
-
return this.runBuildInTool("globLocalFiles", { directory, pattern },
|
|
4428
|
+
async globFiles(pattern, context2, directory) {
|
|
4429
|
+
return this.runBuildInTool("globLocalFiles", { directory, pattern }, context2);
|
|
4156
4430
|
}
|
|
4157
4431
|
/**
|
|
4158
4432
|
* Search file contents using regex pattern
|
|
@@ -4163,8 +4437,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4163
4437
|
* @param options - Additional options (filePattern, recursive)
|
|
4164
4438
|
* @returns Promise resolving to grep results
|
|
4165
4439
|
*/
|
|
4166
|
-
async grepContent(pattern, directory,
|
|
4167
|
-
return this.runBuildInTool("grepContent", { directory, pattern, ...options },
|
|
4440
|
+
async grepContent(pattern, directory, context2, options) {
|
|
4441
|
+
return this.runBuildInTool("grepContent", { directory, pattern, ...options }, context2);
|
|
4168
4442
|
}
|
|
4169
4443
|
/**
|
|
4170
4444
|
* Export a file from the Code Interpreter sandbox to a pre-signed URL
|
|
@@ -4191,8 +4465,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4191
4465
|
* }
|
|
4192
4466
|
* ```
|
|
4193
4467
|
*/
|
|
4194
|
-
async exportFile(path, uploadUrl,
|
|
4195
|
-
return this.runBuildInTool("exportFile", { path, uploadUrl },
|
|
4468
|
+
async exportFile(path, uploadUrl, context2) {
|
|
4469
|
+
return this.runBuildInTool("exportFile", { path, uploadUrl }, context2);
|
|
4196
4470
|
}
|
|
4197
4471
|
// ============================================================================
|
|
4198
4472
|
// Rating Methods
|
|
@@ -4206,7 +4480,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4206
4480
|
* @returns Promise resolving to the submitted score
|
|
4207
4481
|
*/
|
|
4208
4482
|
async submitRating(identifier, score, options) {
|
|
4209
|
-
|
|
4483
|
+
log24("Submitting rating for plugin %s: %d", identifier, score);
|
|
4210
4484
|
const result = await this.request(
|
|
4211
4485
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4212
4486
|
{
|
|
@@ -4215,7 +4489,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4215
4489
|
method: "POST"
|
|
4216
4490
|
}
|
|
4217
4491
|
);
|
|
4218
|
-
|
|
4492
|
+
log24("Rating submitted for plugin %s: %d", identifier, result.score);
|
|
4219
4493
|
return result;
|
|
4220
4494
|
}
|
|
4221
4495
|
/**
|
|
@@ -4226,7 +4500,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4226
4500
|
* @returns Promise resolving to success status
|
|
4227
4501
|
*/
|
|
4228
4502
|
async deleteRating(identifier, options) {
|
|
4229
|
-
|
|
4503
|
+
log24("Deleting rating for plugin %s", identifier);
|
|
4230
4504
|
const result = await this.request(
|
|
4231
4505
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4232
4506
|
{
|
|
@@ -4234,7 +4508,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4234
4508
|
method: "DELETE"
|
|
4235
4509
|
}
|
|
4236
4510
|
);
|
|
4237
|
-
|
|
4511
|
+
log24("Rating deleted for plugin %s", identifier);
|
|
4238
4512
|
return result;
|
|
4239
4513
|
}
|
|
4240
4514
|
/**
|
|
@@ -4245,12 +4519,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4245
4519
|
* @returns Promise resolving to the rating distribution
|
|
4246
4520
|
*/
|
|
4247
4521
|
async getRatingDistribution(identifier, options) {
|
|
4248
|
-
|
|
4522
|
+
log24("Getting rating distribution for plugin: %s", identifier);
|
|
4249
4523
|
const result = await this.request(
|
|
4250
4524
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4251
4525
|
options
|
|
4252
4526
|
);
|
|
4253
|
-
|
|
4527
|
+
log24("Rating distribution retrieved for plugin %s: %d total", identifier, result.totalCount);
|
|
4254
4528
|
return result;
|
|
4255
4529
|
}
|
|
4256
4530
|
// ============================================================================
|
|
@@ -4266,12 +4540,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4266
4540
|
*/
|
|
4267
4541
|
async getComments(identifier, params = {}, options) {
|
|
4268
4542
|
const queryString = this.buildQueryString(params);
|
|
4269
|
-
|
|
4543
|
+
log24("Getting comments for plugin %s: %O", identifier, params);
|
|
4270
4544
|
const result = await this.request(
|
|
4271
4545
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4272
4546
|
options
|
|
4273
4547
|
);
|
|
4274
|
-
|
|
4548
|
+
log24(
|
|
4275
4549
|
"Retrieved %d comments for plugin %s (page %d/%d)",
|
|
4276
4550
|
result.items.length,
|
|
4277
4551
|
identifier,
|
|
@@ -4288,15 +4562,15 @@ var PluginsService = class extends BaseSDK {
|
|
|
4288
4562
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4289
4563
|
*/
|
|
4290
4564
|
async getLatestOwnComment(identifier, options) {
|
|
4291
|
-
|
|
4565
|
+
log24("Getting latest own comment for plugin %s", identifier);
|
|
4292
4566
|
const result = await this.request(
|
|
4293
4567
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4294
4568
|
options
|
|
4295
4569
|
);
|
|
4296
4570
|
if (result) {
|
|
4297
|
-
|
|
4571
|
+
log24("Retrieved latest own comment for plugin %s: id=%d", identifier, result.id);
|
|
4298
4572
|
} else {
|
|
4299
|
-
|
|
4573
|
+
log24("No own comments found for plugin %s", identifier);
|
|
4300
4574
|
}
|
|
4301
4575
|
return result;
|
|
4302
4576
|
}
|
|
@@ -4309,7 +4583,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4309
4583
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4310
4584
|
*/
|
|
4311
4585
|
async createComment(identifier, data, options) {
|
|
4312
|
-
|
|
4586
|
+
log24("Creating comment on plugin %s", identifier);
|
|
4313
4587
|
const result = await this.request(
|
|
4314
4588
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments`,
|
|
4315
4589
|
{
|
|
@@ -4318,7 +4592,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4318
4592
|
method: "POST"
|
|
4319
4593
|
}
|
|
4320
4594
|
);
|
|
4321
|
-
|
|
4595
|
+
log24("Comment created on plugin %s: id=%d", identifier, result.id);
|
|
4322
4596
|
return result;
|
|
4323
4597
|
}
|
|
4324
4598
|
/**
|
|
@@ -4330,7 +4604,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4330
4604
|
* @returns Promise resolving to success status
|
|
4331
4605
|
*/
|
|
4332
4606
|
async deleteComment(identifier, commentId, options) {
|
|
4333
|
-
|
|
4607
|
+
log24("Deleting comment %d from plugin %s", commentId, identifier);
|
|
4334
4608
|
const result = await this.request(
|
|
4335
4609
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4336
4610
|
{
|
|
@@ -4338,7 +4612,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4338
4612
|
method: "DELETE"
|
|
4339
4613
|
}
|
|
4340
4614
|
);
|
|
4341
|
-
|
|
4615
|
+
log24("Comment %d deleted from plugin %s", commentId, identifier);
|
|
4342
4616
|
return result;
|
|
4343
4617
|
}
|
|
4344
4618
|
// ============================================================================
|
|
@@ -4353,7 +4627,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4353
4627
|
* @returns Promise resolving to the created reaction
|
|
4354
4628
|
*/
|
|
4355
4629
|
async addReaction(commentId, type, options) {
|
|
4356
|
-
|
|
4630
|
+
log24("Adding %s reaction to comment %d", type, commentId);
|
|
4357
4631
|
const result = await this.request(
|
|
4358
4632
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4359
4633
|
{
|
|
@@ -4362,7 +4636,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4362
4636
|
method: "POST"
|
|
4363
4637
|
}
|
|
4364
4638
|
);
|
|
4365
|
-
|
|
4639
|
+
log24("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4366
4640
|
return result;
|
|
4367
4641
|
}
|
|
4368
4642
|
/**
|
|
@@ -4373,7 +4647,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4373
4647
|
* @returns Promise resolving to success status
|
|
4374
4648
|
*/
|
|
4375
4649
|
async removeReaction(commentId, options) {
|
|
4376
|
-
|
|
4650
|
+
log24("Removing reaction from comment %d", commentId);
|
|
4377
4651
|
const result = await this.request(
|
|
4378
4652
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4379
4653
|
{
|
|
@@ -4381,15 +4655,168 @@ var PluginsService = class extends BaseSDK {
|
|
|
4381
4655
|
method: "DELETE"
|
|
4382
4656
|
}
|
|
4383
4657
|
);
|
|
4384
|
-
|
|
4658
|
+
log24("Reaction removed from comment %d", commentId);
|
|
4385
4659
|
return result;
|
|
4386
4660
|
}
|
|
4387
4661
|
};
|
|
4388
4662
|
|
|
4663
|
+
// src/market/services/SandboxStorageService.ts
|
|
4664
|
+
import debug25 from "debug";
|
|
4665
|
+
var log25 = debug25("lobe-market-sdk:sandbox-storage");
|
|
4666
|
+
var SandboxStorageService2 = class extends BaseSDK {
|
|
4667
|
+
/** Storage directory, quota and the last measured usage. */
|
|
4668
|
+
async getStorage(key = "current", options) {
|
|
4669
|
+
log25("Getting sandbox storage: %s", key);
|
|
4670
|
+
const result = await this.request(
|
|
4671
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}`,
|
|
4672
|
+
{ ...options, method: "GET" }
|
|
4673
|
+
);
|
|
4674
|
+
return result.data;
|
|
4675
|
+
}
|
|
4676
|
+
/**
|
|
4677
|
+
* Re-measure the storage size. Costs a sandbox round trip and walks the
|
|
4678
|
+
* whole directory, so call it on demand rather than on every render.
|
|
4679
|
+
*/
|
|
4680
|
+
async refreshUsage(key = "current", context2 = {}, options) {
|
|
4681
|
+
log25("Refreshing sandbox storage usage: %s", key);
|
|
4682
|
+
const result = await this.request(
|
|
4683
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/usage`,
|
|
4684
|
+
{ ...options, body: JSON.stringify(context2), method: "POST" }
|
|
4685
|
+
);
|
|
4686
|
+
return result.data;
|
|
4687
|
+
}
|
|
4688
|
+
async listFiles(params = {}, options) {
|
|
4689
|
+
const { key = "current", path, recursive, topicId } = params;
|
|
4690
|
+
log25("Listing sandbox storage files: %s/%s", key, path != null ? path : "");
|
|
4691
|
+
const query = new URLSearchParams();
|
|
4692
|
+
if (path) query.set("path", path);
|
|
4693
|
+
if (recursive) query.set("recursive", "true");
|
|
4694
|
+
if (topicId) query.set("topicId", topicId);
|
|
4695
|
+
const result = await this.request(
|
|
4696
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/files?${query.toString()}`,
|
|
4697
|
+
{ ...options, method: "GET" }
|
|
4698
|
+
);
|
|
4699
|
+
return result.data;
|
|
4700
|
+
}
|
|
4701
|
+
async readFile(params, options) {
|
|
4702
|
+
const { key = "current", path, topicId } = params;
|
|
4703
|
+
log25("Reading sandbox storage file: %s/%s", key, path);
|
|
4704
|
+
const query = new URLSearchParams({ path });
|
|
4705
|
+
if (topicId) query.set("topicId", topicId);
|
|
4706
|
+
const result = await this.request(
|
|
4707
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/file?${query.toString()}`,
|
|
4708
|
+
{ ...options, method: "GET" }
|
|
4709
|
+
);
|
|
4710
|
+
return result.data;
|
|
4711
|
+
}
|
|
4712
|
+
async writeFile(params, options) {
|
|
4713
|
+
const { content, key = "current", path, topicId } = params;
|
|
4714
|
+
log25("Writing sandbox storage file: %s/%s (%d bytes)", key, path, content.length);
|
|
4715
|
+
const result = await this.request(
|
|
4716
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/file`,
|
|
4717
|
+
{
|
|
4718
|
+
...options,
|
|
4719
|
+
body: JSON.stringify({ content, path, topicId }),
|
|
4720
|
+
method: "PUT"
|
|
4721
|
+
}
|
|
4722
|
+
);
|
|
4723
|
+
return result.data;
|
|
4724
|
+
}
|
|
4725
|
+
/**
|
|
4726
|
+
* The storage's instances, newest first.
|
|
4727
|
+
*
|
|
4728
|
+
* Sizes come from the archives themselves rather than a cache, so they are
|
|
4729
|
+
* exact — but the call needs a live sandbox, so a cold start can take a few
|
|
4730
|
+
* seconds. Worth a loading state.
|
|
4731
|
+
*/
|
|
4732
|
+
/**
|
|
4733
|
+
* One instance's run history, newest first: every session that ran it
|
|
4734
|
+
* and every build of it. Answered from the control plane alone, so it is
|
|
4735
|
+
* cheap — no sandbox is started. Page with the `nextBefore` it returns.
|
|
4736
|
+
*/
|
|
4737
|
+
async listInstanceSessions(instance, params = {}, options) {
|
|
4738
|
+
const { before, key = "current", limit } = params;
|
|
4739
|
+
const query = new URLSearchParams();
|
|
4740
|
+
if (limit !== void 0) query.set("limit", String(limit));
|
|
4741
|
+
if (before) query.set("before", before);
|
|
4742
|
+
const suffix = query.size > 0 ? `?${query.toString()}` : "";
|
|
4743
|
+
const result = await this.request(
|
|
4744
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/instances/${encodeURIComponent(instance)}/sessions${suffix}`,
|
|
4745
|
+
{ ...options, method: "GET" }
|
|
4746
|
+
);
|
|
4747
|
+
return result.data;
|
|
4748
|
+
}
|
|
4749
|
+
async listInstances(params = {}, options) {
|
|
4750
|
+
const { key = "current", topicId } = params;
|
|
4751
|
+
const query = topicId ? `?topicId=${encodeURIComponent(topicId)}` : "";
|
|
4752
|
+
const result = await this.request(
|
|
4753
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/instances${query}`,
|
|
4754
|
+
{ ...options, method: "GET" }
|
|
4755
|
+
);
|
|
4756
|
+
return result.data;
|
|
4757
|
+
}
|
|
4758
|
+
/** Copy an instance to a new identifier, for "start from this one". */
|
|
4759
|
+
async copyInstance(params, options) {
|
|
4760
|
+
const { instanceDir, key = "current", name, to, topicId } = params;
|
|
4761
|
+
const result = await this.request(
|
|
4762
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/instances/${encodeURIComponent(name)}/copy`,
|
|
4763
|
+
{ ...options, body: JSON.stringify({ instanceDir, to, topicId }), method: "POST" }
|
|
4764
|
+
);
|
|
4765
|
+
return result.data;
|
|
4766
|
+
}
|
|
4767
|
+
/**
|
|
4768
|
+
* Delete an instance.
|
|
4769
|
+
*
|
|
4770
|
+
* Refused with 409 `INSTANCE_IN_USE` while a live session is running it —
|
|
4771
|
+
* that session would write the archive back when it ends, so the delete would
|
|
4772
|
+
* appear to work and then silently undo itself.
|
|
4773
|
+
*/
|
|
4774
|
+
async deleteInstance(params, options) {
|
|
4775
|
+
const { key = "current", name, topicId } = params;
|
|
4776
|
+
const query = topicId ? `?topicId=${encodeURIComponent(topicId)}` : "";
|
|
4777
|
+
const result = await this.request(
|
|
4778
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/instances/${encodeURIComponent(name)}${query}`,
|
|
4779
|
+
{ ...options, method: "DELETE" }
|
|
4780
|
+
);
|
|
4781
|
+
return result.data;
|
|
4782
|
+
}
|
|
4783
|
+
/**
|
|
4784
|
+
* Create a directory, parents included.
|
|
4785
|
+
*
|
|
4786
|
+
* Idempotent: a directory that already exists is reported as created, so a
|
|
4787
|
+
* picker can call it without checking first.
|
|
4788
|
+
*/
|
|
4789
|
+
async createDirectory(params, options) {
|
|
4790
|
+
const { key = "current", path, topicId } = params;
|
|
4791
|
+
log25("Creating sandbox storage directory: %s/%s", key, path);
|
|
4792
|
+
const result = await this.request(
|
|
4793
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/directory`,
|
|
4794
|
+
{
|
|
4795
|
+
...options,
|
|
4796
|
+
body: JSON.stringify({ path, topicId }),
|
|
4797
|
+
method: "POST"
|
|
4798
|
+
}
|
|
4799
|
+
);
|
|
4800
|
+
return result.data;
|
|
4801
|
+
}
|
|
4802
|
+
async deleteFile(params, options) {
|
|
4803
|
+
const { key = "current", path, recursive, topicId } = params;
|
|
4804
|
+
log25("Deleting sandbox storage path: %s/%s", key, path);
|
|
4805
|
+
const query = new URLSearchParams({ path });
|
|
4806
|
+
if (recursive) query.set("recursive", "true");
|
|
4807
|
+
if (topicId) query.set("topicId", topicId);
|
|
4808
|
+
const result = await this.request(
|
|
4809
|
+
`/v1/sandbox/storages/${encodeURIComponent(key)}/file?${query.toString()}`,
|
|
4810
|
+
{ ...options, method: "DELETE" }
|
|
4811
|
+
);
|
|
4812
|
+
return result.data;
|
|
4813
|
+
}
|
|
4814
|
+
};
|
|
4815
|
+
|
|
4389
4816
|
// src/market/services/SkillService.ts
|
|
4390
|
-
import
|
|
4391
|
-
var
|
|
4392
|
-
var
|
|
4817
|
+
import debug26 from "debug";
|
|
4818
|
+
var log26 = debug26("lobe-market-sdk:skill");
|
|
4819
|
+
var SkillService2 = class extends BaseSDK {
|
|
4393
4820
|
/**
|
|
4394
4821
|
* Lists all available skill providers
|
|
4395
4822
|
*
|
|
@@ -4401,9 +4828,9 @@ var SkillService = class extends BaseSDK {
|
|
|
4401
4828
|
*/
|
|
4402
4829
|
async listProviders(options) {
|
|
4403
4830
|
var _a;
|
|
4404
|
-
|
|
4831
|
+
log26("Listing skill providers");
|
|
4405
4832
|
const result = await this.request("/v1/skill/providers", options);
|
|
4406
|
-
|
|
4833
|
+
log26("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4407
4834
|
return result;
|
|
4408
4835
|
}
|
|
4409
4836
|
/**
|
|
@@ -4418,12 +4845,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4418
4845
|
*/
|
|
4419
4846
|
async listTools(provider, options) {
|
|
4420
4847
|
var _a;
|
|
4421
|
-
|
|
4848
|
+
log26("Listing tools for provider: %s", provider);
|
|
4422
4849
|
const result = await this.request(
|
|
4423
4850
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4424
4851
|
options
|
|
4425
4852
|
);
|
|
4426
|
-
|
|
4853
|
+
log26("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4427
4854
|
return result;
|
|
4428
4855
|
}
|
|
4429
4856
|
/**
|
|
@@ -4440,12 +4867,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4440
4867
|
*/
|
|
4441
4868
|
async listLiveTools(provider, options) {
|
|
4442
4869
|
var _a;
|
|
4443
|
-
|
|
4870
|
+
log26("Listing live tools for provider: %s", provider);
|
|
4444
4871
|
const result = await this.request(
|
|
4445
4872
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4446
4873
|
options
|
|
4447
4874
|
);
|
|
4448
|
-
|
|
4875
|
+
log26("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4449
4876
|
return result;
|
|
4450
4877
|
}
|
|
4451
4878
|
/**
|
|
@@ -4461,12 +4888,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4461
4888
|
*/
|
|
4462
4889
|
async getTool(provider, toolName, options) {
|
|
4463
4890
|
var _a;
|
|
4464
|
-
|
|
4891
|
+
log26("Getting tool %s from provider %s", toolName, provider);
|
|
4465
4892
|
const result = await this.request(
|
|
4466
4893
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
4467
4894
|
options
|
|
4468
4895
|
);
|
|
4469
|
-
|
|
4896
|
+
log26("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
4470
4897
|
return result;
|
|
4471
4898
|
}
|
|
4472
4899
|
/**
|
|
@@ -4480,12 +4907,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4480
4907
|
* @returns Promise resolving to the connection status
|
|
4481
4908
|
*/
|
|
4482
4909
|
async getStatus(provider, options) {
|
|
4483
|
-
|
|
4910
|
+
log26("Getting status for provider: %s", provider);
|
|
4484
4911
|
const result = await this.request(
|
|
4485
4912
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
4486
4913
|
options
|
|
4487
4914
|
);
|
|
4488
|
-
|
|
4915
|
+
log26("Provider %s status: connected=%s", provider, result.connected);
|
|
4489
4916
|
return result;
|
|
4490
4917
|
}
|
|
4491
4918
|
/**
|
|
@@ -4513,7 +4940,7 @@ var SkillService = class extends BaseSDK {
|
|
|
4513
4940
|
* ```
|
|
4514
4941
|
*/
|
|
4515
4942
|
async callTool(provider, params, options) {
|
|
4516
|
-
|
|
4943
|
+
log26("Calling tool %s on provider %s", params.tool, provider);
|
|
4517
4944
|
const { args, tool, ...rest } = params;
|
|
4518
4945
|
const result = await this.request(
|
|
4519
4946
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -4530,14 +4957,14 @@ var SkillService = class extends BaseSDK {
|
|
|
4530
4957
|
...options
|
|
4531
4958
|
}
|
|
4532
4959
|
);
|
|
4533
|
-
|
|
4960
|
+
log26("Tool %s call completed: success=%s", params.tool, result.success);
|
|
4534
4961
|
return result;
|
|
4535
4962
|
}
|
|
4536
4963
|
};
|
|
4537
4964
|
|
|
4538
4965
|
// src/market/services/MarketTaskTemplateService.ts
|
|
4539
|
-
import
|
|
4540
|
-
var
|
|
4966
|
+
import debug27 from "debug";
|
|
4967
|
+
var log27 = debug27("lobe-market-sdk:task-templates");
|
|
4541
4968
|
var MarketTaskTemplateService = class extends BaseSDK {
|
|
4542
4969
|
/**
|
|
4543
4970
|
* Retrieves personalized task template recommendations.
|
|
@@ -4560,7 +4987,7 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4560
4987
|
refreshSeed: params.refreshSeed,
|
|
4561
4988
|
seedKey: params.seedKey
|
|
4562
4989
|
};
|
|
4563
|
-
|
|
4990
|
+
log27("Getting task template recommendations: %O", body);
|
|
4564
4991
|
const result = await this.request(
|
|
4565
4992
|
"/v1/task-templates/recommendations",
|
|
4566
4993
|
{
|
|
@@ -4569,14 +4996,14 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4569
4996
|
method: "POST"
|
|
4570
4997
|
}
|
|
4571
4998
|
);
|
|
4572
|
-
|
|
4999
|
+
log27("Retrieved %d task template recommendations", result.items.length);
|
|
4573
5000
|
return result;
|
|
4574
5001
|
}
|
|
4575
5002
|
};
|
|
4576
5003
|
|
|
4577
5004
|
// src/market/services/MarketSkillCollectionService.ts
|
|
4578
|
-
import
|
|
4579
|
-
var
|
|
5005
|
+
import debug28 from "debug";
|
|
5006
|
+
var log28 = debug28("lobe-market-sdk:skill-collections");
|
|
4580
5007
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
4581
5008
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
4582
5009
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -4585,12 +5012,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4585
5012
|
locale
|
|
4586
5013
|
};
|
|
4587
5014
|
const queryString = this.buildQueryString(queryParams);
|
|
4588
|
-
|
|
5015
|
+
log28("Getting skill collection detail: %s %O", slug, queryParams);
|
|
4589
5016
|
const result = await this.request(
|
|
4590
5017
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
4591
5018
|
options
|
|
4592
5019
|
);
|
|
4593
|
-
|
|
5020
|
+
log28("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
4594
5021
|
return result;
|
|
4595
5022
|
}
|
|
4596
5023
|
async getSkillCollections(params = {}, options) {
|
|
@@ -4600,23 +5027,25 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4600
5027
|
locale
|
|
4601
5028
|
};
|
|
4602
5029
|
const queryString = this.buildQueryString(queryParams);
|
|
4603
|
-
|
|
5030
|
+
log28("Getting skill collections: %O", queryParams);
|
|
4604
5031
|
const result = await this.request(
|
|
4605
5032
|
`/v1/skills/collections${queryString}`,
|
|
4606
5033
|
options
|
|
4607
5034
|
);
|
|
4608
|
-
|
|
5035
|
+
log28("Retrieved %d skill collections", result.length);
|
|
4609
5036
|
return result;
|
|
4610
5037
|
}
|
|
4611
5038
|
};
|
|
4612
5039
|
|
|
4613
5040
|
// src/market/services/MarketSkillService.ts
|
|
4614
|
-
import
|
|
4615
|
-
var
|
|
5041
|
+
import debug29 from "debug";
|
|
5042
|
+
var log29 = debug29("lobe-market-sdk:market-skills");
|
|
4616
5043
|
var MarketSkillService = class extends BaseSDK {
|
|
4617
5044
|
/**
|
|
4618
5045
|
* Retrieves a list of skills from the marketplace
|
|
4619
5046
|
*
|
|
5047
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
5048
|
+
*
|
|
4620
5049
|
* Supports filtering, pagination, search, and various sorting options
|
|
4621
5050
|
* including GitHub stats (stars, forks, watchers). Locale localizes
|
|
4622
5051
|
* descriptions and summaries, but the returned skill name stays canonical.
|
|
@@ -4645,9 +5074,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4645
5074
|
const locale = params.locale || this.defaultLocale;
|
|
4646
5075
|
const queryParams = { ...params, locale };
|
|
4647
5076
|
const queryString = this.buildQueryString(queryParams);
|
|
4648
|
-
|
|
5077
|
+
log29("Getting skill list: %O", queryParams);
|
|
4649
5078
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
4650
|
-
|
|
5079
|
+
log29(
|
|
4651
5080
|
"Retrieved %d skills (page %d/%d)",
|
|
4652
5081
|
result.items.length,
|
|
4653
5082
|
result.currentPage,
|
|
@@ -4686,12 +5115,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4686
5115
|
queryParams.version = params.version;
|
|
4687
5116
|
}
|
|
4688
5117
|
const queryString = this.buildQueryString(queryParams);
|
|
4689
|
-
|
|
5118
|
+
log29("Getting skill detail: %s %O", identifier, params);
|
|
4690
5119
|
const result = await this.request(
|
|
4691
5120
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
4692
5121
|
options
|
|
4693
5122
|
);
|
|
4694
|
-
|
|
5123
|
+
log29("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
4695
5124
|
return result;
|
|
4696
5125
|
}
|
|
4697
5126
|
/**
|
|
@@ -4722,7 +5151,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4722
5151
|
if (version) {
|
|
4723
5152
|
url += `?version=${encodeURIComponent(version)}`;
|
|
4724
5153
|
}
|
|
4725
|
-
|
|
5154
|
+
log29("Generated download URL: %s", url);
|
|
4726
5155
|
return url;
|
|
4727
5156
|
}
|
|
4728
5157
|
/**
|
|
@@ -4746,7 +5175,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4746
5175
|
* ```
|
|
4747
5176
|
*/
|
|
4748
5177
|
async downloadSkill(identifier, version, options) {
|
|
4749
|
-
|
|
5178
|
+
log29("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
4750
5179
|
const queryParams = {};
|
|
4751
5180
|
if (version) {
|
|
4752
5181
|
queryParams.version = version;
|
|
@@ -4762,7 +5191,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4762
5191
|
});
|
|
4763
5192
|
if (!response.ok) {
|
|
4764
5193
|
const errorText = await response.text();
|
|
4765
|
-
|
|
5194
|
+
log29("Download failed: %s %s", response.status, errorText);
|
|
4766
5195
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
4767
5196
|
}
|
|
4768
5197
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -4774,7 +5203,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4774
5203
|
}
|
|
4775
5204
|
}
|
|
4776
5205
|
const buffer = await response.arrayBuffer();
|
|
4777
|
-
|
|
5206
|
+
log29("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
4778
5207
|
return { buffer, filename };
|
|
4779
5208
|
}
|
|
4780
5209
|
/**
|
|
@@ -4802,12 +5231,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4802
5231
|
const locale = params.locale || this.defaultLocale;
|
|
4803
5232
|
const queryParams = { ...params, locale };
|
|
4804
5233
|
const queryString = this.buildQueryString(queryParams);
|
|
4805
|
-
|
|
5234
|
+
log29("Getting skill categories: %O", queryParams);
|
|
4806
5235
|
const result = await this.request(
|
|
4807
5236
|
`/v1/skills/categories${queryString}`,
|
|
4808
5237
|
options
|
|
4809
5238
|
);
|
|
4810
|
-
|
|
5239
|
+
log29("Retrieved %d categories", result.length);
|
|
4811
5240
|
return result;
|
|
4812
5241
|
}
|
|
4813
5242
|
/**
|
|
@@ -4822,12 +5251,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4822
5251
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
4823
5252
|
*/
|
|
4824
5253
|
async getPublishedIdentifiers(options) {
|
|
4825
|
-
|
|
5254
|
+
log29("Getting published skill identifiers");
|
|
4826
5255
|
const result = await this.request(
|
|
4827
5256
|
"/v1/skills/identifiers",
|
|
4828
5257
|
options
|
|
4829
5258
|
);
|
|
4830
|
-
|
|
5259
|
+
log29("Retrieved %d published skill identifiers", result.length);
|
|
4831
5260
|
return result;
|
|
4832
5261
|
}
|
|
4833
5262
|
/**
|
|
@@ -4838,9 +5267,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4838
5267
|
*/
|
|
4839
5268
|
async getSitemap(params = {}, options) {
|
|
4840
5269
|
const queryString = this.buildQueryString(params);
|
|
4841
|
-
|
|
5270
|
+
log29("Getting skill sitemap%s", queryString);
|
|
4842
5271
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
4843
|
-
|
|
5272
|
+
log29(
|
|
4844
5273
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
4845
5274
|
result.currentPage,
|
|
4846
5275
|
result.totalPages,
|
|
@@ -4856,13 +5285,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4856
5285
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
4857
5286
|
*/
|
|
4858
5287
|
async checkSkillExists(identifier, options) {
|
|
4859
|
-
|
|
5288
|
+
log29("Checking if skill exists: %s", identifier);
|
|
4860
5289
|
try {
|
|
4861
5290
|
await this.getSkillDetail(identifier, {}, options);
|
|
4862
|
-
|
|
5291
|
+
log29("Skill exists: %s", identifier);
|
|
4863
5292
|
return true;
|
|
4864
5293
|
} catch (e) {
|
|
4865
|
-
|
|
5294
|
+
log29("Skill does not exist: %s", identifier);
|
|
4866
5295
|
return false;
|
|
4867
5296
|
}
|
|
4868
5297
|
}
|
|
@@ -4883,12 +5312,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4883
5312
|
* ```
|
|
4884
5313
|
*/
|
|
4885
5314
|
async getSkillVersions(identifier, options) {
|
|
4886
|
-
|
|
5315
|
+
log29("Getting skill versions: %s", identifier);
|
|
4887
5316
|
const result = await this.request(
|
|
4888
5317
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
4889
5318
|
options
|
|
4890
5319
|
);
|
|
4891
|
-
|
|
5320
|
+
log29("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
4892
5321
|
return result.data;
|
|
4893
5322
|
}
|
|
4894
5323
|
/**
|
|
@@ -4912,12 +5341,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4912
5341
|
const locale = params.locale || this.defaultLocale;
|
|
4913
5342
|
const queryParams = { locale };
|
|
4914
5343
|
const queryString = this.buildQueryString(queryParams);
|
|
4915
|
-
|
|
5344
|
+
log29("Getting skill version: %s@%s", identifier, version);
|
|
4916
5345
|
const result = await this.request(
|
|
4917
5346
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
4918
5347
|
options
|
|
4919
5348
|
);
|
|
4920
|
-
|
|
5349
|
+
log29("Skill version detail retrieved: %s@%s", identifier, version);
|
|
4921
5350
|
return result;
|
|
4922
5351
|
}
|
|
4923
5352
|
/**
|
|
@@ -4946,13 +5375,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4946
5375
|
* ```
|
|
4947
5376
|
*/
|
|
4948
5377
|
async reportGitHubSkill(params, options) {
|
|
4949
|
-
|
|
5378
|
+
log29("Reporting GitHub skill: %s", params.gitUrl);
|
|
4950
5379
|
const result = await this.request("/v1/skills/report/github", {
|
|
4951
5380
|
...options,
|
|
4952
5381
|
body: JSON.stringify(params),
|
|
4953
5382
|
method: "POST"
|
|
4954
5383
|
});
|
|
4955
|
-
|
|
5384
|
+
log29("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
4956
5385
|
return result;
|
|
4957
5386
|
}
|
|
4958
5387
|
/**
|
|
@@ -4977,7 +5406,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4977
5406
|
* ```
|
|
4978
5407
|
*/
|
|
4979
5408
|
async reportSkillInstall(params, options) {
|
|
4980
|
-
|
|
5409
|
+
log29("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
4981
5410
|
const result = await this.request(
|
|
4982
5411
|
"/v1/skills/report/installation",
|
|
4983
5412
|
{
|
|
@@ -4986,7 +5415,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4986
5415
|
method: "POST"
|
|
4987
5416
|
}
|
|
4988
5417
|
);
|
|
4989
|
-
|
|
5418
|
+
log29("Skill install reported: %s", result.message);
|
|
4990
5419
|
return result;
|
|
4991
5420
|
}
|
|
4992
5421
|
/**
|
|
@@ -4998,7 +5427,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4998
5427
|
* @returns Promise resolving to the submitted score
|
|
4999
5428
|
*/
|
|
5000
5429
|
async submitRating(identifier, score, options) {
|
|
5001
|
-
|
|
5430
|
+
log29("Submitting rating for skill %s: %d", identifier, score);
|
|
5002
5431
|
const result = await this.request(
|
|
5003
5432
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
5004
5433
|
{
|
|
@@ -5007,7 +5436,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5007
5436
|
method: "POST"
|
|
5008
5437
|
}
|
|
5009
5438
|
);
|
|
5010
|
-
|
|
5439
|
+
log29("Rating submitted for skill %s: %d", identifier, result.score);
|
|
5011
5440
|
return result;
|
|
5012
5441
|
}
|
|
5013
5442
|
/**
|
|
@@ -5018,12 +5447,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5018
5447
|
* @returns Promise resolving to the rating distribution
|
|
5019
5448
|
*/
|
|
5020
5449
|
async getRatingDistribution(identifier, options) {
|
|
5021
|
-
|
|
5450
|
+
log29("Getting rating distribution for skill: %s", identifier);
|
|
5022
5451
|
const result = await this.request(
|
|
5023
5452
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
5024
5453
|
options
|
|
5025
5454
|
);
|
|
5026
|
-
|
|
5455
|
+
log29("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
5027
5456
|
return result;
|
|
5028
5457
|
}
|
|
5029
5458
|
/**
|
|
@@ -5036,12 +5465,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5036
5465
|
*/
|
|
5037
5466
|
async getComments(identifier, params = {}, options) {
|
|
5038
5467
|
const queryString = this.buildQueryString(params);
|
|
5039
|
-
|
|
5468
|
+
log29("Getting comments for skill %s: %O", identifier, params);
|
|
5040
5469
|
const result = await this.request(
|
|
5041
5470
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
5042
5471
|
options
|
|
5043
5472
|
);
|
|
5044
|
-
|
|
5473
|
+
log29(
|
|
5045
5474
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
5046
5475
|
result.items.length,
|
|
5047
5476
|
identifier,
|
|
@@ -5058,15 +5487,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5058
5487
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
5059
5488
|
*/
|
|
5060
5489
|
async getLatestOwnComment(identifier, options) {
|
|
5061
|
-
|
|
5490
|
+
log29("Getting latest own comment for skill %s", identifier);
|
|
5062
5491
|
const result = await this.request(
|
|
5063
5492
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
5064
5493
|
options
|
|
5065
5494
|
);
|
|
5066
5495
|
if (result) {
|
|
5067
|
-
|
|
5496
|
+
log29("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
5068
5497
|
} else {
|
|
5069
|
-
|
|
5498
|
+
log29("No own comments found for skill %s", identifier);
|
|
5070
5499
|
}
|
|
5071
5500
|
return result;
|
|
5072
5501
|
}
|
|
@@ -5079,7 +5508,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5079
5508
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
5080
5509
|
*/
|
|
5081
5510
|
async createComment(identifier, data, options) {
|
|
5082
|
-
|
|
5511
|
+
log29("Creating comment on skill %s", identifier);
|
|
5083
5512
|
const result = await this.request(
|
|
5084
5513
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
5085
5514
|
{
|
|
@@ -5088,7 +5517,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5088
5517
|
method: "POST"
|
|
5089
5518
|
}
|
|
5090
5519
|
);
|
|
5091
|
-
|
|
5520
|
+
log29("Comment created on skill %s: id=%d", identifier, result.id);
|
|
5092
5521
|
return result;
|
|
5093
5522
|
}
|
|
5094
5523
|
/**
|
|
@@ -5100,7 +5529,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5100
5529
|
* @returns Promise resolving to success status
|
|
5101
5530
|
*/
|
|
5102
5531
|
async deleteComment(identifier, commentId, options) {
|
|
5103
|
-
|
|
5532
|
+
log29("Deleting comment %d from skill %s", commentId, identifier);
|
|
5104
5533
|
const result = await this.request(
|
|
5105
5534
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
5106
5535
|
{
|
|
@@ -5108,7 +5537,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5108
5537
|
method: "DELETE"
|
|
5109
5538
|
}
|
|
5110
5539
|
);
|
|
5111
|
-
|
|
5540
|
+
log29("Comment %d deleted from skill %s", commentId, identifier);
|
|
5112
5541
|
return result;
|
|
5113
5542
|
}
|
|
5114
5543
|
/**
|
|
@@ -5120,7 +5549,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5120
5549
|
* @returns Promise resolving to the created reaction
|
|
5121
5550
|
*/
|
|
5122
5551
|
async addReaction(commentId, type, options) {
|
|
5123
|
-
|
|
5552
|
+
log29("Adding %s reaction to comment %d", type, commentId);
|
|
5124
5553
|
const result = await this.request(
|
|
5125
5554
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5126
5555
|
{
|
|
@@ -5129,7 +5558,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5129
5558
|
method: "POST"
|
|
5130
5559
|
}
|
|
5131
5560
|
);
|
|
5132
|
-
|
|
5561
|
+
log29("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
5133
5562
|
return result;
|
|
5134
5563
|
}
|
|
5135
5564
|
/**
|
|
@@ -5140,7 +5569,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5140
5569
|
* @returns Promise resolving to success status
|
|
5141
5570
|
*/
|
|
5142
5571
|
async removeReaction(commentId, options) {
|
|
5143
|
-
|
|
5572
|
+
log29("Removing reaction from comment %d", commentId);
|
|
5144
5573
|
const result = await this.request(
|
|
5145
5574
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5146
5575
|
{
|
|
@@ -5148,19 +5577,19 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5148
5577
|
method: "DELETE"
|
|
5149
5578
|
}
|
|
5150
5579
|
);
|
|
5151
|
-
|
|
5580
|
+
log29("Reaction removed from comment %d", commentId);
|
|
5152
5581
|
return result;
|
|
5153
5582
|
}
|
|
5154
5583
|
};
|
|
5155
5584
|
|
|
5156
5585
|
// src/market/services/OrganizationCredsService.ts
|
|
5157
|
-
import
|
|
5586
|
+
import debug30 from "debug";
|
|
5158
5587
|
|
|
5159
5588
|
// src/utils/orgRef.ts
|
|
5160
5589
|
var orgRefToPathSegment = (ref) => typeof ref === "number" ? String(ref) : `workspace:${encodeURIComponent(ref.workspaceId)}`;
|
|
5161
5590
|
|
|
5162
5591
|
// src/market/services/OrganizationCredsService.ts
|
|
5163
|
-
var
|
|
5592
|
+
var log30 = debug30("lobe-market-sdk:org-creds");
|
|
5164
5593
|
var OrganizationCredsService = class extends BaseSDK {
|
|
5165
5594
|
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
5166
5595
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5192,9 +5621,9 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5192
5621
|
*/
|
|
5193
5622
|
async list(options) {
|
|
5194
5623
|
var _a;
|
|
5195
|
-
|
|
5624
|
+
log30("Listing org %s credentials", this.orgSegment);
|
|
5196
5625
|
const result = await this.request(this.base(), options);
|
|
5197
|
-
|
|
5626
|
+
log30("Found %d credentials for org %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgSegment);
|
|
5198
5627
|
return result;
|
|
5199
5628
|
}
|
|
5200
5629
|
/**
|
|
@@ -5203,20 +5632,20 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5203
5632
|
* owner via `CredService.get(id, { decrypt: true })`.
|
|
5204
5633
|
*/
|
|
5205
5634
|
async get(id, getOptions, options) {
|
|
5206
|
-
|
|
5635
|
+
log30("Getting org %s credential %d (decrypt=%s)", this.orgSegment, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
5207
5636
|
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
5208
5637
|
const result = await this.request(
|
|
5209
5638
|
`${this.base()}/${id}${queryString}`,
|
|
5210
5639
|
options
|
|
5211
5640
|
);
|
|
5212
|
-
|
|
5641
|
+
log30("Retrieved org credential: %s", result.key);
|
|
5213
5642
|
return result;
|
|
5214
5643
|
}
|
|
5215
5644
|
// ===========================================================================
|
|
5216
5645
|
// Create
|
|
5217
5646
|
// ===========================================================================
|
|
5218
5647
|
async createKV(data, options) {
|
|
5219
|
-
|
|
5648
|
+
log30("Creating org %s KV credential: %s (type=%s)", this.orgSegment, data.key, data.type);
|
|
5220
5649
|
return this.request(`${this.base()}/kv`, {
|
|
5221
5650
|
body: JSON.stringify(data),
|
|
5222
5651
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5225,7 +5654,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5225
5654
|
});
|
|
5226
5655
|
}
|
|
5227
5656
|
async createOAuth(data, options) {
|
|
5228
|
-
|
|
5657
|
+
log30("Creating org %s OAuth credential: %s", this.orgSegment, data.key);
|
|
5229
5658
|
return this.request(`${this.base()}/oauth`, {
|
|
5230
5659
|
body: JSON.stringify(data),
|
|
5231
5660
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5234,7 +5663,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5234
5663
|
});
|
|
5235
5664
|
}
|
|
5236
5665
|
async createFile(data, options) {
|
|
5237
|
-
|
|
5666
|
+
log30("Creating org %s file credential: %s", this.orgSegment, data.key);
|
|
5238
5667
|
return this.request(`${this.base()}/file`, {
|
|
5239
5668
|
body: JSON.stringify(data),
|
|
5240
5669
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5246,7 +5675,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5246
5675
|
// Update
|
|
5247
5676
|
// ===========================================================================
|
|
5248
5677
|
async update(id, data, options) {
|
|
5249
|
-
|
|
5678
|
+
log30("Updating org %s credential %d", this.orgSegment, id);
|
|
5250
5679
|
return this.request(`${this.base()}/${id}`, {
|
|
5251
5680
|
body: JSON.stringify(data),
|
|
5252
5681
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5258,14 +5687,14 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5258
5687
|
// Delete
|
|
5259
5688
|
// ===========================================================================
|
|
5260
5689
|
async delete(id, options) {
|
|
5261
|
-
|
|
5690
|
+
log30("Deleting org %s credential %d", this.orgSegment, id);
|
|
5262
5691
|
return this.request(`${this.base()}/${id}`, {
|
|
5263
5692
|
method: "DELETE",
|
|
5264
5693
|
...options
|
|
5265
5694
|
});
|
|
5266
5695
|
}
|
|
5267
5696
|
async deleteByKey(key, options) {
|
|
5268
|
-
|
|
5697
|
+
log30("Deleting org %s credential by key: %s", this.orgSegment, key);
|
|
5269
5698
|
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5270
5699
|
method: "DELETE",
|
|
5271
5700
|
...options
|
|
@@ -5279,7 +5708,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5279
5708
|
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5280
5709
|
*/
|
|
5281
5710
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
5282
|
-
|
|
5711
|
+
log30("Getting org %s skill cred status: %s", this.orgSegment, skillIdentifier);
|
|
5283
5712
|
const path = `/v1/organizations/${this.orgSegment}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5284
5713
|
const result = await this.request(
|
|
5285
5714
|
path,
|
|
@@ -5290,8 +5719,8 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5290
5719
|
};
|
|
5291
5720
|
|
|
5292
5721
|
// src/market/services/OrganizationService.ts
|
|
5293
|
-
import
|
|
5294
|
-
var
|
|
5722
|
+
import debug31 from "debug";
|
|
5723
|
+
var log31 = debug31("lobe-market-sdk:organization");
|
|
5295
5724
|
var OrganizationService2 = class extends BaseSDK {
|
|
5296
5725
|
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5297
5726
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5339,12 +5768,12 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5339
5768
|
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5340
5769
|
const locale = params.locale || this.defaultLocale;
|
|
5341
5770
|
const queryString = this.buildQueryString({ locale });
|
|
5342
|
-
|
|
5771
|
+
log31("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5343
5772
|
const result = await this.request(
|
|
5344
5773
|
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5345
5774
|
options
|
|
5346
5775
|
);
|
|
5347
|
-
|
|
5776
|
+
log31("Organization info retrieved for: %s", idOrNamespace);
|
|
5348
5777
|
return result;
|
|
5349
5778
|
}
|
|
5350
5779
|
/**
|
|
@@ -5354,7 +5783,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5354
5783
|
* @returns Promise resolving to the user's organizations
|
|
5355
5784
|
*/
|
|
5356
5785
|
async listMyOrganizations(options) {
|
|
5357
|
-
|
|
5786
|
+
log31("Listing organizations for current user");
|
|
5358
5787
|
const result = await this.request(
|
|
5359
5788
|
"/v1/organizations/me",
|
|
5360
5789
|
options
|
|
@@ -5372,7 +5801,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5372
5801
|
* @returns The created/existing organization and whether it was newly created
|
|
5373
5802
|
*/
|
|
5374
5803
|
async createOrganization(data, options) {
|
|
5375
|
-
|
|
5804
|
+
log31("Creating organization: %s", data.clerkId);
|
|
5376
5805
|
return this.request("/v1/organizations", {
|
|
5377
5806
|
...options,
|
|
5378
5807
|
body: JSON.stringify(data),
|
|
@@ -5387,7 +5816,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5387
5816
|
* @returns The updated organization
|
|
5388
5817
|
*/
|
|
5389
5818
|
async updateOrganization(orgId, data, options) {
|
|
5390
|
-
|
|
5819
|
+
log31("Updating organization %d: %O", orgId, data);
|
|
5391
5820
|
const result = await this.request(
|
|
5392
5821
|
`/v1/organizations/${orgRefToPathSegment(orgId)}`,
|
|
5393
5822
|
{
|
|
@@ -5406,7 +5835,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5406
5835
|
* @returns The archived organization
|
|
5407
5836
|
*/
|
|
5408
5837
|
async archiveOrganization(orgId, options) {
|
|
5409
|
-
|
|
5838
|
+
log31("Archiving organization %d", orgId);
|
|
5410
5839
|
const result = await this.request(
|
|
5411
5840
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/archive`,
|
|
5412
5841
|
{ ...options, method: "POST" }
|
|
@@ -5420,7 +5849,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5420
5849
|
* @returns The reactivated organization
|
|
5421
5850
|
*/
|
|
5422
5851
|
async unarchiveOrganization(orgId, options) {
|
|
5423
|
-
|
|
5852
|
+
log31("Unarchiving organization %d", orgId);
|
|
5424
5853
|
const result = await this.request(
|
|
5425
5854
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/unarchive`,
|
|
5426
5855
|
{ ...options, method: "POST" }
|
|
@@ -5434,7 +5863,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5434
5863
|
* @returns Hydrated member rows
|
|
5435
5864
|
*/
|
|
5436
5865
|
async listMembers(orgId, options) {
|
|
5437
|
-
|
|
5866
|
+
log31("Listing members of organization %d", orgId);
|
|
5438
5867
|
const result = await this.request(
|
|
5439
5868
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5440
5869
|
options
|
|
@@ -5451,7 +5880,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5451
5880
|
* @returns Whether the member was newly added and their effective role
|
|
5452
5881
|
*/
|
|
5453
5882
|
async addMember(orgId, userAccountId, role, options) {
|
|
5454
|
-
|
|
5883
|
+
log31("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
5455
5884
|
return this.request(
|
|
5456
5885
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5457
5886
|
{
|
|
@@ -5470,7 +5899,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5470
5899
|
* @returns Whether a membership row was removed
|
|
5471
5900
|
*/
|
|
5472
5901
|
async removeMember(orgId, userAccountId, options) {
|
|
5473
|
-
|
|
5902
|
+
log31("Removing member %d from organization %d", userAccountId, orgId);
|
|
5474
5903
|
return this.request(
|
|
5475
5904
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5476
5905
|
{ ...options, method: "DELETE" }
|
|
@@ -5486,7 +5915,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5486
5915
|
* @returns The effective role and whether it changed
|
|
5487
5916
|
*/
|
|
5488
5917
|
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
5489
|
-
|
|
5918
|
+
log31("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
5490
5919
|
return this.request(
|
|
5491
5920
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5492
5921
|
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
@@ -5504,7 +5933,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5504
5933
|
* @returns Counts of added / removed / updated members and skipped ids
|
|
5505
5934
|
*/
|
|
5506
5935
|
async reconcileMembers(orgId, members, options) {
|
|
5507
|
-
|
|
5936
|
+
log31("Reconciling %d members for organization %d", members.length, orgId);
|
|
5508
5937
|
return this.request(
|
|
5509
5938
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5510
5939
|
{
|
|
@@ -5517,8 +5946,8 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5517
5946
|
};
|
|
5518
5947
|
|
|
5519
5948
|
// src/market/services/UserService.ts
|
|
5520
|
-
import
|
|
5521
|
-
var
|
|
5949
|
+
import debug32 from "debug";
|
|
5950
|
+
var log32 = debug32("lobe-market-sdk:user");
|
|
5522
5951
|
var UserService = class extends BaseSDK {
|
|
5523
5952
|
/**
|
|
5524
5953
|
* Retrieves user information by account ID or userName
|
|
@@ -5535,12 +5964,12 @@ var UserService = class extends BaseSDK {
|
|
|
5535
5964
|
const locale = params.locale || this.defaultLocale;
|
|
5536
5965
|
const queryParams = { locale };
|
|
5537
5966
|
const queryString = this.buildQueryString(queryParams);
|
|
5538
|
-
|
|
5967
|
+
log32("Getting user info: %O", { idOrUserName, ...params });
|
|
5539
5968
|
const result = await this.request(
|
|
5540
5969
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
5541
5970
|
options
|
|
5542
5971
|
);
|
|
5543
|
-
|
|
5972
|
+
log32("User info successfully retrieved for: %s", idOrUserName);
|
|
5544
5973
|
return result;
|
|
5545
5974
|
}
|
|
5546
5975
|
/**
|
|
@@ -5555,7 +5984,7 @@ var UserService = class extends BaseSDK {
|
|
|
5555
5984
|
* @throws Error if userName is already taken or update fails
|
|
5556
5985
|
*/
|
|
5557
5986
|
async updateUserInfo(data, options) {
|
|
5558
|
-
|
|
5987
|
+
log32("Updating user info: %O", data);
|
|
5559
5988
|
const result = await this.request("/v1/user/update", {
|
|
5560
5989
|
body: JSON.stringify(data),
|
|
5561
5990
|
headers: {
|
|
@@ -5564,7 +5993,7 @@ var UserService = class extends BaseSDK {
|
|
|
5564
5993
|
method: "POST",
|
|
5565
5994
|
...options
|
|
5566
5995
|
});
|
|
5567
|
-
|
|
5996
|
+
log32("User info updated successfully");
|
|
5568
5997
|
return result;
|
|
5569
5998
|
}
|
|
5570
5999
|
/**
|
|
@@ -5594,7 +6023,7 @@ var UserService = class extends BaseSDK {
|
|
|
5594
6023
|
* ```
|
|
5595
6024
|
*/
|
|
5596
6025
|
async register(data, options) {
|
|
5597
|
-
|
|
6026
|
+
log32("Registering user: %O", {
|
|
5598
6027
|
followUserId: data.followUserId,
|
|
5599
6028
|
registerUserId: data.registerUserId
|
|
5600
6029
|
});
|
|
@@ -5606,14 +6035,14 @@ var UserService = class extends BaseSDK {
|
|
|
5606
6035
|
method: "POST",
|
|
5607
6036
|
...options
|
|
5608
6037
|
});
|
|
5609
|
-
|
|
6038
|
+
log32("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
5610
6039
|
return result;
|
|
5611
6040
|
}
|
|
5612
6041
|
};
|
|
5613
6042
|
|
|
5614
6043
|
// src/market/services/UserFollowService.ts
|
|
5615
|
-
import
|
|
5616
|
-
var
|
|
6044
|
+
import debug33 from "debug";
|
|
6045
|
+
var log33 = debug33("lobe-market-sdk:user-follow");
|
|
5617
6046
|
var UserFollowService = class extends BaseSDK {
|
|
5618
6047
|
/**
|
|
5619
6048
|
* Follow a user
|
|
@@ -5627,7 +6056,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5627
6056
|
* @throws Error if already following or cannot follow yourself
|
|
5628
6057
|
*/
|
|
5629
6058
|
async follow(followingId, options) {
|
|
5630
|
-
|
|
6059
|
+
log33("Following user: %d", followingId);
|
|
5631
6060
|
const body = { followingId };
|
|
5632
6061
|
const result = await this.request("/v1/user/follows", {
|
|
5633
6062
|
body: JSON.stringify(body),
|
|
@@ -5637,7 +6066,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5637
6066
|
method: "POST",
|
|
5638
6067
|
...options
|
|
5639
6068
|
});
|
|
5640
|
-
|
|
6069
|
+
log33("Successfully followed user: %d", followingId);
|
|
5641
6070
|
return result;
|
|
5642
6071
|
}
|
|
5643
6072
|
/**
|
|
@@ -5652,7 +6081,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5652
6081
|
* @throws Error if follow relationship not found
|
|
5653
6082
|
*/
|
|
5654
6083
|
async unfollow(followingId, options) {
|
|
5655
|
-
|
|
6084
|
+
log33("Unfollowing user: %d", followingId);
|
|
5656
6085
|
const body = { followingId };
|
|
5657
6086
|
const result = await this.request("/v1/user/follows", {
|
|
5658
6087
|
body: JSON.stringify(body),
|
|
@@ -5662,7 +6091,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5662
6091
|
method: "DELETE",
|
|
5663
6092
|
...options
|
|
5664
6093
|
});
|
|
5665
|
-
|
|
6094
|
+
log33("Successfully unfollowed user: %d", followingId);
|
|
5666
6095
|
return result;
|
|
5667
6096
|
}
|
|
5668
6097
|
/**
|
|
@@ -5676,13 +6105,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5676
6105
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
5677
6106
|
*/
|
|
5678
6107
|
async checkFollowStatus(targetUserId, options) {
|
|
5679
|
-
|
|
6108
|
+
log33("Checking follow status for user: %d", targetUserId);
|
|
5680
6109
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
5681
6110
|
const result = await this.request(
|
|
5682
6111
|
`/v1/user/follows/check${queryString}`,
|
|
5683
6112
|
options
|
|
5684
6113
|
);
|
|
5685
|
-
|
|
6114
|
+
log33("Follow status retrieved: %O", result);
|
|
5686
6115
|
return result;
|
|
5687
6116
|
}
|
|
5688
6117
|
/**
|
|
@@ -5697,7 +6126,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5697
6126
|
* @returns Promise resolving to list of following users
|
|
5698
6127
|
*/
|
|
5699
6128
|
async getFollowing(userId, params = {}, options) {
|
|
5700
|
-
|
|
6129
|
+
log33("Getting following list for user: %d", userId);
|
|
5701
6130
|
const queryParams = {};
|
|
5702
6131
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5703
6132
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5706,7 +6135,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5706
6135
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
5707
6136
|
options
|
|
5708
6137
|
);
|
|
5709
|
-
|
|
6138
|
+
log33("Following list retrieved for user: %d", userId);
|
|
5710
6139
|
return result;
|
|
5711
6140
|
}
|
|
5712
6141
|
/**
|
|
@@ -5721,7 +6150,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5721
6150
|
* @returns Promise resolving to list of followers
|
|
5722
6151
|
*/
|
|
5723
6152
|
async getFollowers(userId, params = {}, options) {
|
|
5724
|
-
|
|
6153
|
+
log33("Getting followers list for user: %d", userId);
|
|
5725
6154
|
const queryParams = {};
|
|
5726
6155
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5727
6156
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5730,14 +6159,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5730
6159
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
5731
6160
|
options
|
|
5732
6161
|
);
|
|
5733
|
-
|
|
6162
|
+
log33("Followers list retrieved for user: %d", userId);
|
|
5734
6163
|
return result;
|
|
5735
6164
|
}
|
|
5736
6165
|
};
|
|
5737
6166
|
|
|
5738
6167
|
// src/market/services/UserFavoriteService.ts
|
|
5739
|
-
import
|
|
5740
|
-
var
|
|
6168
|
+
import debug34 from "debug";
|
|
6169
|
+
var log34 = debug34("lobe-market-sdk:user-favorite");
|
|
5741
6170
|
var UserFavoriteService = class extends BaseSDK {
|
|
5742
6171
|
/**
|
|
5743
6172
|
* Add to favorites
|
|
@@ -5752,7 +6181,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5752
6181
|
* @throws Error if already in favorites
|
|
5753
6182
|
*/
|
|
5754
6183
|
async addFavorite(targetType, targetId, options) {
|
|
5755
|
-
|
|
6184
|
+
log34("Adding favorite: %s %d", targetType, targetId);
|
|
5756
6185
|
const body = { targetId, targetType };
|
|
5757
6186
|
const result = await this.request("/v1/user/favorites", {
|
|
5758
6187
|
body: JSON.stringify(body),
|
|
@@ -5762,7 +6191,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5762
6191
|
method: "POST",
|
|
5763
6192
|
...options
|
|
5764
6193
|
});
|
|
5765
|
-
|
|
6194
|
+
log34("Successfully added favorite: %s %d", targetType, targetId);
|
|
5766
6195
|
return result;
|
|
5767
6196
|
}
|
|
5768
6197
|
/**
|
|
@@ -5778,7 +6207,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5778
6207
|
* @throws Error if favorite not found
|
|
5779
6208
|
*/
|
|
5780
6209
|
async removeFavorite(targetType, targetId, options) {
|
|
5781
|
-
|
|
6210
|
+
log34("Removing favorite: %s %d", targetType, targetId);
|
|
5782
6211
|
const body = { targetId, targetType };
|
|
5783
6212
|
const result = await this.request("/v1/user/favorites", {
|
|
5784
6213
|
body: JSON.stringify(body),
|
|
@@ -5788,7 +6217,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5788
6217
|
method: "DELETE",
|
|
5789
6218
|
...options
|
|
5790
6219
|
});
|
|
5791
|
-
|
|
6220
|
+
log34("Successfully removed favorite: %s %d", targetType, targetId);
|
|
5792
6221
|
return result;
|
|
5793
6222
|
}
|
|
5794
6223
|
/**
|
|
@@ -5803,7 +6232,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5803
6232
|
* @returns Promise resolving to favorite status
|
|
5804
6233
|
*/
|
|
5805
6234
|
async checkFavorite(targetType, targetId, options) {
|
|
5806
|
-
|
|
6235
|
+
log34("Checking favorite status: %s %d", targetType, targetId);
|
|
5807
6236
|
const queryString = this.buildQueryString({
|
|
5808
6237
|
targetId: String(targetId),
|
|
5809
6238
|
targetType
|
|
@@ -5812,7 +6241,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5812
6241
|
`/v1/user/favorites/check${queryString}`,
|
|
5813
6242
|
options
|
|
5814
6243
|
);
|
|
5815
|
-
|
|
6244
|
+
log34("Favorite status retrieved: %O", result);
|
|
5816
6245
|
return result;
|
|
5817
6246
|
}
|
|
5818
6247
|
/**
|
|
@@ -5826,7 +6255,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5826
6255
|
* @returns Promise resolving to list of favorites
|
|
5827
6256
|
*/
|
|
5828
6257
|
async getMyFavorites(params = {}, options) {
|
|
5829
|
-
|
|
6258
|
+
log34("Getting my favorites: %O", params);
|
|
5830
6259
|
const queryParams = {};
|
|
5831
6260
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5832
6261
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5836,7 +6265,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5836
6265
|
`/v1/user/favorites/me${queryString}`,
|
|
5837
6266
|
options
|
|
5838
6267
|
);
|
|
5839
|
-
|
|
6268
|
+
log34("My favorites retrieved");
|
|
5840
6269
|
return result;
|
|
5841
6270
|
}
|
|
5842
6271
|
/**
|
|
@@ -5851,7 +6280,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5851
6280
|
* @returns Promise resolving to list of favorites
|
|
5852
6281
|
*/
|
|
5853
6282
|
async getUserFavorites(userId, params = {}, options) {
|
|
5854
|
-
|
|
6283
|
+
log34("Getting favorites for user: %d", userId);
|
|
5855
6284
|
const queryParams = {};
|
|
5856
6285
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5857
6286
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5861,7 +6290,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5861
6290
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
5862
6291
|
options
|
|
5863
6292
|
);
|
|
5864
|
-
|
|
6293
|
+
log34("Favorites retrieved for user: %d", userId);
|
|
5865
6294
|
return result;
|
|
5866
6295
|
}
|
|
5867
6296
|
/**
|
|
@@ -5876,7 +6305,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5876
6305
|
* @returns Promise resolving to list of favorite agents
|
|
5877
6306
|
*/
|
|
5878
6307
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
5879
|
-
|
|
6308
|
+
log34("Getting favorite agents for user: %d", userId);
|
|
5880
6309
|
const queryParams = {};
|
|
5881
6310
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5882
6311
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5885,7 +6314,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5885
6314
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
5886
6315
|
options
|
|
5887
6316
|
);
|
|
5888
|
-
|
|
6317
|
+
log34("Favorite agents retrieved for user: %d", userId);
|
|
5889
6318
|
return result;
|
|
5890
6319
|
}
|
|
5891
6320
|
/**
|
|
@@ -5900,7 +6329,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5900
6329
|
* @returns Promise resolving to list of favorite plugins
|
|
5901
6330
|
*/
|
|
5902
6331
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
5903
|
-
|
|
6332
|
+
log34("Getting favorite plugins for user: %d", userId);
|
|
5904
6333
|
const queryParams = {};
|
|
5905
6334
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5906
6335
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5909,14 +6338,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5909
6338
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
5910
6339
|
options
|
|
5911
6340
|
);
|
|
5912
|
-
|
|
6341
|
+
log34("Favorite plugins retrieved for user: %d", userId);
|
|
5913
6342
|
return result;
|
|
5914
6343
|
}
|
|
5915
6344
|
};
|
|
5916
6345
|
|
|
5917
6346
|
// src/market/services/UserLikeService.ts
|
|
5918
|
-
import
|
|
5919
|
-
var
|
|
6347
|
+
import debug35 from "debug";
|
|
6348
|
+
var log35 = debug35("lobe-market-sdk:user-like");
|
|
5920
6349
|
var UserLikeService = class extends BaseSDK {
|
|
5921
6350
|
/**
|
|
5922
6351
|
* Like content
|
|
@@ -5931,7 +6360,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5931
6360
|
* @throws Error if already liked
|
|
5932
6361
|
*/
|
|
5933
6362
|
async like(targetType, targetId, options) {
|
|
5934
|
-
|
|
6363
|
+
log35("Liking: %s %d", targetType, targetId);
|
|
5935
6364
|
const body = { targetId, targetType };
|
|
5936
6365
|
const result = await this.request("/v1/user/likes", {
|
|
5937
6366
|
body: JSON.stringify(body),
|
|
@@ -5941,7 +6370,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5941
6370
|
method: "POST",
|
|
5942
6371
|
...options
|
|
5943
6372
|
});
|
|
5944
|
-
|
|
6373
|
+
log35("Successfully liked: %s %d", targetType, targetId);
|
|
5945
6374
|
return result;
|
|
5946
6375
|
}
|
|
5947
6376
|
/**
|
|
@@ -5957,7 +6386,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5957
6386
|
* @throws Error if like not found
|
|
5958
6387
|
*/
|
|
5959
6388
|
async unlike(targetType, targetId, options) {
|
|
5960
|
-
|
|
6389
|
+
log35("Unliking: %s %d", targetType, targetId);
|
|
5961
6390
|
const body = { targetId, targetType };
|
|
5962
6391
|
const result = await this.request("/v1/user/likes", {
|
|
5963
6392
|
body: JSON.stringify(body),
|
|
@@ -5967,7 +6396,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5967
6396
|
method: "DELETE",
|
|
5968
6397
|
...options
|
|
5969
6398
|
});
|
|
5970
|
-
|
|
6399
|
+
log35("Successfully unliked: %s %d", targetType, targetId);
|
|
5971
6400
|
return result;
|
|
5972
6401
|
}
|
|
5973
6402
|
/**
|
|
@@ -5982,7 +6411,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5982
6411
|
* @returns Promise resolving to toggle response with new like status
|
|
5983
6412
|
*/
|
|
5984
6413
|
async toggleLike(targetType, targetId, options) {
|
|
5985
|
-
|
|
6414
|
+
log35("Toggling like: %s %d", targetType, targetId);
|
|
5986
6415
|
const body = { targetId, targetType };
|
|
5987
6416
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
5988
6417
|
body: JSON.stringify(body),
|
|
@@ -5992,7 +6421,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5992
6421
|
method: "POST",
|
|
5993
6422
|
...options
|
|
5994
6423
|
});
|
|
5995
|
-
|
|
6424
|
+
log35("Like toggled, new status: %O", result);
|
|
5996
6425
|
return result;
|
|
5997
6426
|
}
|
|
5998
6427
|
/**
|
|
@@ -6007,7 +6436,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6007
6436
|
* @returns Promise resolving to like status
|
|
6008
6437
|
*/
|
|
6009
6438
|
async checkLike(targetType, targetId, options) {
|
|
6010
|
-
|
|
6439
|
+
log35("Checking like status: %s %d", targetType, targetId);
|
|
6011
6440
|
const queryString = this.buildQueryString({
|
|
6012
6441
|
targetId: String(targetId),
|
|
6013
6442
|
targetType
|
|
@@ -6016,7 +6445,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6016
6445
|
`/v1/user/likes/check${queryString}`,
|
|
6017
6446
|
options
|
|
6018
6447
|
);
|
|
6019
|
-
|
|
6448
|
+
log35("Like status retrieved: %O", result);
|
|
6020
6449
|
return result;
|
|
6021
6450
|
}
|
|
6022
6451
|
/**
|
|
@@ -6030,7 +6459,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6030
6459
|
* @returns Promise resolving to list of likes
|
|
6031
6460
|
*/
|
|
6032
6461
|
async getMyLikes(params = {}, options) {
|
|
6033
|
-
|
|
6462
|
+
log35("Getting my likes: %O", params);
|
|
6034
6463
|
const queryParams = {};
|
|
6035
6464
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6036
6465
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6040,7 +6469,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6040
6469
|
`/v1/user/likes/me${queryString}`,
|
|
6041
6470
|
options
|
|
6042
6471
|
);
|
|
6043
|
-
|
|
6472
|
+
log35("My likes retrieved");
|
|
6044
6473
|
return result;
|
|
6045
6474
|
}
|
|
6046
6475
|
/**
|
|
@@ -6055,7 +6484,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6055
6484
|
* @returns Promise resolving to list of likes
|
|
6056
6485
|
*/
|
|
6057
6486
|
async getUserLikes(userId, params = {}, options) {
|
|
6058
|
-
|
|
6487
|
+
log35("Getting likes for user: %d", userId);
|
|
6059
6488
|
const queryParams = {};
|
|
6060
6489
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6061
6490
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6065,7 +6494,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6065
6494
|
`/v1/user/likes/${userId}${queryString}`,
|
|
6066
6495
|
options
|
|
6067
6496
|
);
|
|
6068
|
-
|
|
6497
|
+
log35("Likes retrieved for user: %d", userId);
|
|
6069
6498
|
return result;
|
|
6070
6499
|
}
|
|
6071
6500
|
/**
|
|
@@ -6080,7 +6509,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6080
6509
|
* @returns Promise resolving to list of liked agents
|
|
6081
6510
|
*/
|
|
6082
6511
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
6083
|
-
|
|
6512
|
+
log35("Getting liked agents for user: %d", userId);
|
|
6084
6513
|
const queryParams = {};
|
|
6085
6514
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6086
6515
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6089,7 +6518,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6089
6518
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
6090
6519
|
options
|
|
6091
6520
|
);
|
|
6092
|
-
|
|
6521
|
+
log35("Liked agents retrieved for user: %d", userId);
|
|
6093
6522
|
return result;
|
|
6094
6523
|
}
|
|
6095
6524
|
/**
|
|
@@ -6104,7 +6533,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6104
6533
|
* @returns Promise resolving to list of liked plugins
|
|
6105
6534
|
*/
|
|
6106
6535
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
6107
|
-
|
|
6536
|
+
log35("Getting liked plugins for user: %d", userId);
|
|
6108
6537
|
const queryParams = {};
|
|
6109
6538
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6110
6539
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6113,14 +6542,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6113
6542
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
6114
6543
|
options
|
|
6115
6544
|
);
|
|
6116
|
-
|
|
6545
|
+
log35("Liked plugins retrieved for user: %d", userId);
|
|
6117
6546
|
return result;
|
|
6118
6547
|
}
|
|
6119
6548
|
};
|
|
6120
6549
|
|
|
6121
6550
|
// src/market/services/UserPublishService.ts
|
|
6122
|
-
import
|
|
6123
|
-
var
|
|
6551
|
+
import debug36 from "debug";
|
|
6552
|
+
var log36 = debug36("lobe-market-sdk:user-publish");
|
|
6124
6553
|
var UserPublishService = class extends BaseSDK {
|
|
6125
6554
|
/**
|
|
6126
6555
|
* Lists all plugins owned by the authenticated user
|
|
@@ -6130,9 +6559,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6130
6559
|
*/
|
|
6131
6560
|
async listPlugins(options) {
|
|
6132
6561
|
var _a;
|
|
6133
|
-
|
|
6562
|
+
log36("Listing user plugins");
|
|
6134
6563
|
const result = await this.request("/v1/user/plugins", options);
|
|
6135
|
-
|
|
6564
|
+
log36("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6136
6565
|
return result;
|
|
6137
6566
|
}
|
|
6138
6567
|
/**
|
|
@@ -6143,9 +6572,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6143
6572
|
*/
|
|
6144
6573
|
async listSkills(options) {
|
|
6145
6574
|
var _a;
|
|
6146
|
-
|
|
6575
|
+
log36("Listing user skills");
|
|
6147
6576
|
const result = await this.request("/v1/user/skills", options);
|
|
6148
|
-
|
|
6577
|
+
log36("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6149
6578
|
return result;
|
|
6150
6579
|
}
|
|
6151
6580
|
/**
|
|
@@ -6157,7 +6586,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6157
6586
|
* @returns Promise resolving to the publish result
|
|
6158
6587
|
*/
|
|
6159
6588
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
6160
|
-
|
|
6589
|
+
log36("Publishing skill version for: %s", identifier);
|
|
6161
6590
|
const formData = new FormData();
|
|
6162
6591
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
6163
6592
|
zipBuffer.byteOffset,
|
|
@@ -6173,7 +6602,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6173
6602
|
...options
|
|
6174
6603
|
}
|
|
6175
6604
|
);
|
|
6176
|
-
|
|
6605
|
+
log36("Published skill version: %s@%s", identifier, result.version);
|
|
6177
6606
|
return result;
|
|
6178
6607
|
}
|
|
6179
6608
|
/**
|
|
@@ -6184,11 +6613,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6184
6613
|
*/
|
|
6185
6614
|
async scanClaimableAssets(assetType) {
|
|
6186
6615
|
var _a;
|
|
6187
|
-
|
|
6616
|
+
log36("Scanning claimable %s", assetType);
|
|
6188
6617
|
const result = await this.request(
|
|
6189
6618
|
`/v1/user/claims/scan/${assetType}`
|
|
6190
6619
|
);
|
|
6191
|
-
|
|
6620
|
+
log36("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
6192
6621
|
return result;
|
|
6193
6622
|
}
|
|
6194
6623
|
/**
|
|
@@ -6199,13 +6628,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6199
6628
|
* @returns Promise resolving to the claim result
|
|
6200
6629
|
*/
|
|
6201
6630
|
async claimAsset(assetId, assetType) {
|
|
6202
|
-
|
|
6631
|
+
log36("Claiming %s with id: %d", assetType, assetId);
|
|
6203
6632
|
const result = await this.request("/v1/user/claims", {
|
|
6204
6633
|
body: JSON.stringify({ assetId, assetType }),
|
|
6205
6634
|
headers: { "Content-Type": "application/json" },
|
|
6206
6635
|
method: "POST"
|
|
6207
6636
|
});
|
|
6208
|
-
|
|
6637
|
+
log36("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
6209
6638
|
return result;
|
|
6210
6639
|
}
|
|
6211
6640
|
/**
|
|
@@ -6219,13 +6648,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6219
6648
|
* @returns Promise resolving to the claim result
|
|
6220
6649
|
*/
|
|
6221
6650
|
async claimAssetByIdentifier(identifier, assetType) {
|
|
6222
|
-
|
|
6651
|
+
log36("Claiming %s with identifier: %s", assetType, identifier);
|
|
6223
6652
|
const result = await this.request("/v1/user/claims", {
|
|
6224
6653
|
body: JSON.stringify({ assetType, identifier }),
|
|
6225
6654
|
headers: { "Content-Type": "application/json" },
|
|
6226
6655
|
method: "POST"
|
|
6227
6656
|
});
|
|
6228
|
-
|
|
6657
|
+
log36("Claim result for %s %s: %s", assetType, identifier, result.success);
|
|
6229
6658
|
return result;
|
|
6230
6659
|
}
|
|
6231
6660
|
/**
|
|
@@ -6240,14 +6669,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6240
6669
|
* @returns Promise resolving to the submission result
|
|
6241
6670
|
*/
|
|
6242
6671
|
async submitRepo(params, options) {
|
|
6243
|
-
|
|
6672
|
+
log36("Submitting repository for import: %s (%s)", params.gitUrl, params.type);
|
|
6244
6673
|
const result = await this.request("/v1/user/claims/submit-repo", {
|
|
6245
6674
|
body: JSON.stringify(params),
|
|
6246
6675
|
headers: { "Content-Type": "application/json" },
|
|
6247
6676
|
method: "POST",
|
|
6248
6677
|
...options
|
|
6249
6678
|
});
|
|
6250
|
-
|
|
6679
|
+
log36("Submit result for %s: %s", params.gitUrl, result.success);
|
|
6251
6680
|
return result;
|
|
6252
6681
|
}
|
|
6253
6682
|
/**
|
|
@@ -6258,14 +6687,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6258
6687
|
* @returns Promise resolving immediately with the plugin identifier and version
|
|
6259
6688
|
*/
|
|
6260
6689
|
async publishPlugin(params, options) {
|
|
6261
|
-
|
|
6690
|
+
log36("Publishing plugin: %s@%s", params.identifier, params.version);
|
|
6262
6691
|
const result = await this.request("/v1/user/plugins", {
|
|
6263
6692
|
body: JSON.stringify(params),
|
|
6264
6693
|
headers: { "Content-Type": "application/json" },
|
|
6265
6694
|
method: "POST",
|
|
6266
6695
|
...options
|
|
6267
6696
|
});
|
|
6268
|
-
|
|
6697
|
+
log36("Published plugin: %s@%s (%s)", result.identifier, result.version, result.status);
|
|
6269
6698
|
return result;
|
|
6270
6699
|
}
|
|
6271
6700
|
/**
|
|
@@ -6276,12 +6705,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6276
6705
|
* @returns Promise resolving to the delete result
|
|
6277
6706
|
*/
|
|
6278
6707
|
async deleteSkill(identifier, options) {
|
|
6279
|
-
|
|
6708
|
+
log36("Deleting skill: %s", identifier);
|
|
6280
6709
|
const result = await this.request(
|
|
6281
6710
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
6282
6711
|
{ method: "DELETE", ...options }
|
|
6283
6712
|
);
|
|
6284
|
-
|
|
6713
|
+
log36("Deleted skill: %s", identifier);
|
|
6285
6714
|
return result;
|
|
6286
6715
|
}
|
|
6287
6716
|
/**
|
|
@@ -6293,7 +6722,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6293
6722
|
* @returns Promise resolving to the updated status
|
|
6294
6723
|
*/
|
|
6295
6724
|
async updateSkillStatus(identifier, status, options) {
|
|
6296
|
-
|
|
6725
|
+
log36("Updating skill status: %s \u2192 %s", identifier, status);
|
|
6297
6726
|
const result = await this.request(
|
|
6298
6727
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
6299
6728
|
{
|
|
@@ -6303,7 +6732,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6303
6732
|
...options
|
|
6304
6733
|
}
|
|
6305
6734
|
);
|
|
6306
|
-
|
|
6735
|
+
log36("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
6307
6736
|
return result;
|
|
6308
6737
|
}
|
|
6309
6738
|
/**
|
|
@@ -6314,12 +6743,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6314
6743
|
* @returns Promise resolving to the delete result
|
|
6315
6744
|
*/
|
|
6316
6745
|
async deletePlugin(identifier, options) {
|
|
6317
|
-
|
|
6746
|
+
log36("Deleting plugin: %s", identifier);
|
|
6318
6747
|
const result = await this.request(
|
|
6319
6748
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
6320
6749
|
{ method: "DELETE", ...options }
|
|
6321
6750
|
);
|
|
6322
|
-
|
|
6751
|
+
log36("Deleted plugin: %s", identifier);
|
|
6323
6752
|
return result;
|
|
6324
6753
|
}
|
|
6325
6754
|
/**
|
|
@@ -6331,7 +6760,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6331
6760
|
* @returns Promise resolving to the updated status
|
|
6332
6761
|
*/
|
|
6333
6762
|
async updatePluginStatus(identifier, status, options) {
|
|
6334
|
-
|
|
6763
|
+
log36("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
6335
6764
|
const result = await this.request(
|
|
6336
6765
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
6337
6766
|
{
|
|
@@ -6341,7 +6770,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6341
6770
|
...options
|
|
6342
6771
|
}
|
|
6343
6772
|
);
|
|
6344
|
-
|
|
6773
|
+
log36("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
6345
6774
|
return result;
|
|
6346
6775
|
}
|
|
6347
6776
|
/**
|
|
@@ -6353,7 +6782,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6353
6782
|
* @returns Promise resolving to the publish result
|
|
6354
6783
|
*/
|
|
6355
6784
|
async publishPluginVersion(identifier, data, options) {
|
|
6356
|
-
|
|
6785
|
+
log36("Publishing plugin version for: %s", identifier);
|
|
6357
6786
|
const result = await this.request(
|
|
6358
6787
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
6359
6788
|
{
|
|
@@ -6363,7 +6792,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6363
6792
|
...options
|
|
6364
6793
|
}
|
|
6365
6794
|
);
|
|
6366
|
-
|
|
6795
|
+
log36("Published plugin version: %s@%s", identifier, result.version);
|
|
6367
6796
|
return result;
|
|
6368
6797
|
}
|
|
6369
6798
|
/**
|
|
@@ -6376,13 +6805,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6376
6805
|
*/
|
|
6377
6806
|
async getPluginLocalizations(identifier, version, options) {
|
|
6378
6807
|
var _a;
|
|
6379
|
-
|
|
6808
|
+
log36("Listing localizations for plugin: %s", identifier);
|
|
6380
6809
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6381
6810
|
const result = await this.request(
|
|
6382
6811
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations${query}`,
|
|
6383
6812
|
options
|
|
6384
6813
|
);
|
|
6385
|
-
|
|
6814
|
+
log36("Found %d localizations for %s", ((_a = result.localizations) == null ? void 0 : _a.length) || 0, identifier);
|
|
6386
6815
|
return result;
|
|
6387
6816
|
}
|
|
6388
6817
|
/**
|
|
@@ -6399,7 +6828,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6399
6828
|
* @returns Promise resolving to the upsert result
|
|
6400
6829
|
*/
|
|
6401
6830
|
async updatePluginLocalizations(identifier, localizations, version, options) {
|
|
6402
|
-
|
|
6831
|
+
log36("Upserting %d localization(s) for plugin: %s", localizations.length, identifier);
|
|
6403
6832
|
const result = await this.request(
|
|
6404
6833
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations`,
|
|
6405
6834
|
{
|
|
@@ -6409,7 +6838,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6409
6838
|
...options
|
|
6410
6839
|
}
|
|
6411
6840
|
);
|
|
6412
|
-
|
|
6841
|
+
log36("Upserted localizations for %s@%s", identifier, result.version);
|
|
6413
6842
|
return result;
|
|
6414
6843
|
}
|
|
6415
6844
|
/**
|
|
@@ -6423,20 +6852,40 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6423
6852
|
* @returns Promise resolving to the delete result
|
|
6424
6853
|
*/
|
|
6425
6854
|
async deletePluginLocalization(identifier, locale, version, options) {
|
|
6426
|
-
|
|
6855
|
+
log36("Deleting localization %s for plugin: %s", locale, identifier);
|
|
6427
6856
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6428
6857
|
const result = await this.request(
|
|
6429
6858
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations/${encodeURIComponent(locale)}${query}`,
|
|
6430
6859
|
{ method: "DELETE", ...options }
|
|
6431
6860
|
);
|
|
6432
|
-
|
|
6861
|
+
log36("Deleted localization %s for %s", locale, identifier);
|
|
6433
6862
|
return result;
|
|
6434
6863
|
}
|
|
6435
6864
|
};
|
|
6436
6865
|
|
|
6866
|
+
// src/market/services/CategoryService.ts
|
|
6867
|
+
import debug37 from "debug";
|
|
6868
|
+
var log37 = debug37("lobe-market-sdk:market:categories");
|
|
6869
|
+
var CategoryService2 = class extends BaseSDK {
|
|
6870
|
+
/** Lists configured categories with nullable HTTP(S) image URLs or lucide:<name> icons and public asset counts, including empty categories. */
|
|
6871
|
+
async list(assetType, locale) {
|
|
6872
|
+
log37("Listing categories for %s", assetType);
|
|
6873
|
+
const query = this.buildQueryString({ assetType, locale });
|
|
6874
|
+
return this.request(`/v1/categories${query}`);
|
|
6875
|
+
}
|
|
6876
|
+
};
|
|
6877
|
+
|
|
6437
6878
|
// src/market/market-sdk.ts
|
|
6438
|
-
var
|
|
6879
|
+
var log38 = debug38("lobe-market-sdk");
|
|
6439
6880
|
var MarketSDK = class extends BaseSDK {
|
|
6881
|
+
/** Anonymous WebP byte URL. No signed token or public bucket is required. */
|
|
6882
|
+
getAssetImageUrl(id) {
|
|
6883
|
+
return new URL(getAssetImagePath(id), this.baseUrl).toString();
|
|
6884
|
+
}
|
|
6885
|
+
/** Anonymous SVG with a safely generated single initial; name must contain 1–255 characters. */
|
|
6886
|
+
getAssetInitialUrl(name) {
|
|
6887
|
+
return new URL(getAssetInitialPath(name), this.baseUrl).toString();
|
|
6888
|
+
}
|
|
6440
6889
|
/**
|
|
6441
6890
|
* Creates a new MarketSDK instance
|
|
6442
6891
|
*
|
|
@@ -6448,14 +6897,17 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6448
6897
|
tokenExpiry: void 0
|
|
6449
6898
|
};
|
|
6450
6899
|
super(options, void 0, sharedTokenState);
|
|
6451
|
-
|
|
6900
|
+
log38("MarketSDK instance created");
|
|
6452
6901
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
6902
|
+
this.categories = new CategoryService2(options, this.headers, sharedTokenState);
|
|
6453
6903
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
6454
6904
|
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
6455
6905
|
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
6456
6906
|
this.connect = new ConnectService(options, this.headers, sharedTokenState);
|
|
6457
6907
|
this.creds = new CredService(options, this.headers, sharedTokenState);
|
|
6908
|
+
this.deployments = new DeploymentService(options, this.headers, sharedTokenState);
|
|
6458
6909
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
6910
|
+
this.sandboxStorage = new SandboxStorageService2(options, this.headers, sharedTokenState);
|
|
6459
6911
|
this.organizations = new OrganizationService2(options, this.headers, sharedTokenState);
|
|
6460
6912
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
6461
6913
|
this.userPublish = new UserPublishService(options, this.headers, sharedTokenState);
|
|
@@ -6463,7 +6915,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6463
6915
|
this.favorites = new UserFavoriteService(options, this.headers, sharedTokenState);
|
|
6464
6916
|
this.likes = new UserLikeService(options, this.headers, sharedTokenState);
|
|
6465
6917
|
this.feedback = new FeedbackService(options, this.headers, sharedTokenState);
|
|
6466
|
-
this.skills = new
|
|
6918
|
+
this.skills = new SkillService2(options, this.headers, sharedTokenState);
|
|
6467
6919
|
this.skillCollections = new MarketSkillCollectionService(
|
|
6468
6920
|
options,
|
|
6469
6921
|
this.headers,
|
|
@@ -6497,7 +6949,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6497
6949
|
* @deprecated Use auth.registerClient() instead
|
|
6498
6950
|
*/
|
|
6499
6951
|
async registerClient(request) {
|
|
6500
|
-
|
|
6952
|
+
log38("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
6501
6953
|
return this.auth.registerClient(request);
|
|
6502
6954
|
}
|
|
6503
6955
|
};
|