@lobehub/market-sdk 0.41.0 → 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 +403 -354
- package/dist/index.mjs +783 -448
- 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,19 +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
|
};
|
|
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
|
+
}
|
|
169
175
|
if (typeof FormData !== "undefined" && options.body instanceof FormData) {
|
|
170
|
-
|
|
176
|
+
for (const key of Object.keys(mergedHeaders)) {
|
|
177
|
+
if (key.toLowerCase() === "content-type") delete mergedHeaders[key];
|
|
178
|
+
}
|
|
171
179
|
}
|
|
172
|
-
log("Request headers: %O", mergedHeaders);
|
|
173
180
|
const response = await fetch(requestUrl, {
|
|
174
181
|
...options,
|
|
175
182
|
headers: mergedHeaders
|
|
@@ -178,13 +185,19 @@ var BaseSDK = class {
|
|
|
178
185
|
let errorBody;
|
|
179
186
|
try {
|
|
180
187
|
errorBody = await response.json();
|
|
181
|
-
console.error("Request error: %s", JSON.stringify(errorBody));
|
|
182
188
|
} catch (e) {
|
|
183
189
|
errorBody = void 0;
|
|
184
190
|
}
|
|
185
|
-
|
|
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;
|
|
186
199
|
}
|
|
187
|
-
log("Request successful:
|
|
200
|
+
log("Request successful: status=%d", response.status);
|
|
188
201
|
if (response.status === 204) {
|
|
189
202
|
return void 0;
|
|
190
203
|
}
|
|
@@ -264,7 +277,7 @@ var BaseSDK = class {
|
|
|
264
277
|
}
|
|
265
278
|
async exchangeTokenForServer(clientAssertion) {
|
|
266
279
|
const tokenEndpoint = urlJoin(this.oauthBaseUrl, "token");
|
|
267
|
-
log("Exchanging token
|
|
280
|
+
log("Exchanging token");
|
|
268
281
|
const params = new URLSearchParams();
|
|
269
282
|
params.append("grant_type", "client_credentials");
|
|
270
283
|
params.append(
|
|
@@ -346,7 +359,7 @@ import debug2 from "debug";
|
|
|
346
359
|
var log2 = debug2("lobe-market-sdk:admin:agents");
|
|
347
360
|
var AgentService = class extends BaseSDK {
|
|
348
361
|
/**
|
|
349
|
-
* Creates
|
|
362
|
+
* Creates a cloud Agent and its current initial version, including required A2A metadata.
|
|
350
363
|
*/
|
|
351
364
|
async createAgent(data) {
|
|
352
365
|
log2("Creating Agent with initial version: %s", data.identifier);
|
|
@@ -358,6 +371,8 @@ var AgentService = class extends BaseSDK {
|
|
|
358
371
|
/**
|
|
359
372
|
* Retrieves a list of agents with admin details
|
|
360
373
|
*
|
|
374
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
375
|
+
*
|
|
361
376
|
* Supports filtering, pagination, and sorting of results.
|
|
362
377
|
*
|
|
363
378
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -449,6 +464,26 @@ var AgentService = class extends BaseSDK {
|
|
|
449
464
|
log2("Agent version updated successfully: %s@%s", id, version);
|
|
450
465
|
return result;
|
|
451
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
|
+
}
|
|
452
487
|
/**
|
|
453
488
|
* Updates agent publication status
|
|
454
489
|
*
|
|
@@ -921,6 +956,8 @@ var PluginService = class extends BaseSDK {
|
|
|
921
956
|
/**
|
|
922
957
|
* Retrieves a list of plugins with admin details
|
|
923
958
|
*
|
|
959
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
960
|
+
*
|
|
924
961
|
* Supports filtering, pagination, and sorting of results.
|
|
925
962
|
*
|
|
926
963
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -1716,9 +1753,47 @@ var SkillCollectionService = class extends BaseSDK {
|
|
|
1716
1753
|
import debug10 from "debug";
|
|
1717
1754
|
var log10 = debug10("lobe-market-sdk:admin:skills");
|
|
1718
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
|
+
}
|
|
1719
1792
|
/**
|
|
1720
1793
|
* Retrieve Skills with Admin API status and visibility fields.
|
|
1721
1794
|
*
|
|
1795
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
1796
|
+
*
|
|
1722
1797
|
* @param params - Query parameters for filtering and pagination
|
|
1723
1798
|
* @returns Paginated Skill list
|
|
1724
1799
|
*/
|
|
@@ -1740,6 +1815,8 @@ var SkillService = class extends BaseSDK {
|
|
|
1740
1815
|
const filename = options.filename || (typeof File !== "undefined" && file instanceof File ? file.name : "skill.zip");
|
|
1741
1816
|
const formData = new FormData();
|
|
1742
1817
|
formData.set("file", file, filename);
|
|
1818
|
+
if (options.icon !== void 0)
|
|
1819
|
+
formData.set("icon", options.icon === null ? "null" : options.icon);
|
|
1743
1820
|
if (options.identifier) formData.set("identifier", options.identifier);
|
|
1744
1821
|
log10("Importing skill package: %s", filename);
|
|
1745
1822
|
const result = await this.request("/admin/skills/import/upload", {
|
|
@@ -1924,8 +2001,74 @@ var OrganizationService = class extends BaseSDK {
|
|
|
1924
2001
|
}
|
|
1925
2002
|
};
|
|
1926
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
|
+
|
|
1927
2070
|
// src/admin/MarketAdmin.ts
|
|
1928
|
-
var
|
|
2071
|
+
var log14 = debug14("lobe-market-sdk:admin");
|
|
1929
2072
|
var MarketAdmin = class extends BaseSDK {
|
|
1930
2073
|
/**
|
|
1931
2074
|
* Creates a new MarketAdmin instance
|
|
@@ -1939,7 +2082,10 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1939
2082
|
tokenExpiry: void 0
|
|
1940
2083
|
};
|
|
1941
2084
|
super({ ...options, apiKey }, void 0, sharedTokenState);
|
|
1942
|
-
|
|
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);
|
|
1943
2089
|
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
1944
2090
|
this.analysis = new AnalysisService(options, this.headers, sharedTokenState);
|
|
1945
2091
|
this.dependencies = new SystemDependencyService(options, this.headers, sharedTokenState);
|
|
@@ -1955,11 +2101,12 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1955
2101
|
};
|
|
1956
2102
|
|
|
1957
2103
|
// src/market/market-sdk.ts
|
|
1958
|
-
import
|
|
2104
|
+
import { getAssetImagePath, getAssetInitialPath } from "@lobehub/market-types";
|
|
2105
|
+
import debug38 from "debug";
|
|
1959
2106
|
|
|
1960
2107
|
// src/market/services/AgentProfileService.ts
|
|
1961
|
-
import
|
|
1962
|
-
var
|
|
2108
|
+
import debug15 from "debug";
|
|
2109
|
+
var log15 = debug15("lobe-market-sdk:agent-profile");
|
|
1963
2110
|
var AgentProfileService = class extends BaseSDK {
|
|
1964
2111
|
/**
|
|
1965
2112
|
* Retrieves the current agent's profile
|
|
@@ -1971,9 +2118,9 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1971
2118
|
* @returns Promise resolving to the agent profile response
|
|
1972
2119
|
*/
|
|
1973
2120
|
async getProfile(options) {
|
|
1974
|
-
|
|
2121
|
+
log15("Getting agent profile");
|
|
1975
2122
|
const result = await this.request("/v1/agent/profile", options);
|
|
1976
|
-
|
|
2123
|
+
log15("Agent profile retrieved: id=%d, identifier=%s", result.agent.id, result.agent.identifier);
|
|
1977
2124
|
return result;
|
|
1978
2125
|
}
|
|
1979
2126
|
/**
|
|
@@ -1987,7 +2134,7 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1987
2134
|
* @returns Promise resolving to the updated agent profile response
|
|
1988
2135
|
*/
|
|
1989
2136
|
async updateProfile(data, options) {
|
|
1990
|
-
|
|
2137
|
+
log15("Updating agent profile: %O", data);
|
|
1991
2138
|
const result = await this.request("/v1/agent/profile", {
|
|
1992
2139
|
body: JSON.stringify(data),
|
|
1993
2140
|
headers: {
|
|
@@ -1996,18 +2143,20 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1996
2143
|
method: "PATCH",
|
|
1997
2144
|
...options
|
|
1998
2145
|
});
|
|
1999
|
-
|
|
2146
|
+
log15("Agent profile updated: id=%d, name=%s", result.agent.id, result.agent.name);
|
|
2000
2147
|
return result;
|
|
2001
2148
|
}
|
|
2002
2149
|
};
|
|
2003
2150
|
|
|
2004
2151
|
// src/market/services/AgentService.ts
|
|
2005
|
-
import
|
|
2006
|
-
var
|
|
2152
|
+
import debug16 from "debug";
|
|
2153
|
+
var log16 = debug16("lobe-market-sdk:agents");
|
|
2007
2154
|
var AgentService2 = class extends BaseSDK {
|
|
2008
2155
|
/**
|
|
2009
2156
|
* Retrieves a list of agents from the marketplace
|
|
2010
2157
|
*
|
|
2158
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
2159
|
+
*
|
|
2011
2160
|
* Supports filtering, pagination, and localization of results.
|
|
2012
2161
|
*
|
|
2013
2162
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -2018,9 +2167,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2018
2167
|
const locale = params.locale || this.defaultLocale;
|
|
2019
2168
|
const queryParams = { ...params, locale };
|
|
2020
2169
|
const queryString = this.buildQueryString(queryParams);
|
|
2021
|
-
|
|
2170
|
+
log16("Getting agent list: %O", queryParams);
|
|
2022
2171
|
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
2023
|
-
|
|
2172
|
+
log16("Retrieved %d agents", result.items.length);
|
|
2024
2173
|
return result;
|
|
2025
2174
|
}
|
|
2026
2175
|
/**
|
|
@@ -2037,9 +2186,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2037
2186
|
const locale = params.locale || this.defaultLocale;
|
|
2038
2187
|
const queryParams = { ...params, locale };
|
|
2039
2188
|
const queryString = this.buildQueryString(queryParams);
|
|
2040
|
-
|
|
2189
|
+
log16("Getting own agent list: %O", queryParams);
|
|
2041
2190
|
const result = await this.request(`/v1/agents/own${queryString}`, options);
|
|
2042
|
-
|
|
2191
|
+
log16("Retrieved %d own agents", result.items.length);
|
|
2043
2192
|
return result;
|
|
2044
2193
|
}
|
|
2045
2194
|
/**
|
|
@@ -2060,12 +2209,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2060
2209
|
queryParams.version = params.version.toString();
|
|
2061
2210
|
}
|
|
2062
2211
|
const queryString = this.buildQueryString(queryParams);
|
|
2063
|
-
|
|
2212
|
+
log16("Getting agent detail: %O", { id, ...params });
|
|
2064
2213
|
const result = await this.request(
|
|
2065
2214
|
`/v1/agents/detail/${id}${queryString}`,
|
|
2066
2215
|
options
|
|
2067
2216
|
);
|
|
2068
|
-
|
|
2217
|
+
log16("Agent detail successfully retrieved: %s", id);
|
|
2069
2218
|
return result;
|
|
2070
2219
|
}
|
|
2071
2220
|
/**
|
|
@@ -2081,12 +2230,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2081
2230
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
2082
2231
|
*/
|
|
2083
2232
|
async getPublishedIdentifiers(options) {
|
|
2084
|
-
|
|
2233
|
+
log16("Getting published agent identifiers");
|
|
2085
2234
|
const result = await this.request(
|
|
2086
2235
|
"/v1/agents/identifiers",
|
|
2087
2236
|
options
|
|
2088
2237
|
);
|
|
2089
|
-
|
|
2238
|
+
log16("Retrieved %d published agent identifiers", result.length);
|
|
2090
2239
|
return result;
|
|
2091
2240
|
}
|
|
2092
2241
|
/**
|
|
@@ -2097,9 +2246,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2097
2246
|
*/
|
|
2098
2247
|
async getSitemap(params = {}, options) {
|
|
2099
2248
|
const queryString = this.buildQueryString(params);
|
|
2100
|
-
|
|
2249
|
+
log16("Getting agent sitemap%s", queryString);
|
|
2101
2250
|
const result = await this.request(`/v1/agents/sitemap${queryString}`, options);
|
|
2102
|
-
|
|
2251
|
+
log16(
|
|
2103
2252
|
"Retrieved agent sitemap page %d/%d (%d items)",
|
|
2104
2253
|
result.currentPage,
|
|
2105
2254
|
result.totalPages,
|
|
@@ -2122,12 +2271,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2122
2271
|
const locale = params.locale || this.defaultLocale;
|
|
2123
2272
|
const queryParams = { ...params, locale };
|
|
2124
2273
|
const queryString = this.buildQueryString(queryParams);
|
|
2125
|
-
|
|
2274
|
+
log16("Getting agent categories: %O", queryParams);
|
|
2126
2275
|
const result = await this.request(
|
|
2127
2276
|
`/v1/agents/categories${queryString}`,
|
|
2128
2277
|
options
|
|
2129
2278
|
);
|
|
2130
|
-
|
|
2279
|
+
log16("Retrieved %d categories", result.length);
|
|
2131
2280
|
return result;
|
|
2132
2281
|
}
|
|
2133
2282
|
/**
|
|
@@ -2141,7 +2290,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2141
2290
|
* @returns Promise resolving to the upload response
|
|
2142
2291
|
*/
|
|
2143
2292
|
async uploadAgent(agentData, options) {
|
|
2144
|
-
|
|
2293
|
+
log16("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
2145
2294
|
const result = await this.request("/v1/agents/upload", {
|
|
2146
2295
|
body: JSON.stringify(agentData),
|
|
2147
2296
|
headers: {
|
|
@@ -2150,7 +2299,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2150
2299
|
method: "POST",
|
|
2151
2300
|
...options
|
|
2152
2301
|
});
|
|
2153
|
-
|
|
2302
|
+
log16("Agent uploaded successfully: %O", result);
|
|
2154
2303
|
return result;
|
|
2155
2304
|
}
|
|
2156
2305
|
/**
|
|
@@ -2161,7 +2310,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2161
2310
|
* @returns Promise resolving to the created agent response
|
|
2162
2311
|
*/
|
|
2163
2312
|
async createAgent(agentData, options) {
|
|
2164
|
-
|
|
2313
|
+
log16("Creating agent: %s", agentData.identifier);
|
|
2165
2314
|
const result = await this.request("/v1/agents/create", {
|
|
2166
2315
|
body: JSON.stringify(agentData),
|
|
2167
2316
|
headers: {
|
|
@@ -2170,7 +2319,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2170
2319
|
method: "POST",
|
|
2171
2320
|
...options
|
|
2172
2321
|
});
|
|
2173
|
-
|
|
2322
|
+
log16("Agent created successfully: %O", result);
|
|
2174
2323
|
return result;
|
|
2175
2324
|
}
|
|
2176
2325
|
/**
|
|
@@ -2181,7 +2330,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2181
2330
|
* @returns Promise resolving to the created version response
|
|
2182
2331
|
*/
|
|
2183
2332
|
async createAgentVersion(versionData, options) {
|
|
2184
|
-
|
|
2333
|
+
log16("Creating agent version: %s", versionData.identifier);
|
|
2185
2334
|
const result = await this.request("/v1/agents/version/create", {
|
|
2186
2335
|
body: JSON.stringify(versionData),
|
|
2187
2336
|
headers: {
|
|
@@ -2190,7 +2339,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2190
2339
|
method: "POST",
|
|
2191
2340
|
...options
|
|
2192
2341
|
});
|
|
2193
|
-
|
|
2342
|
+
log16("Agent version created successfully: %O", result);
|
|
2194
2343
|
return result;
|
|
2195
2344
|
}
|
|
2196
2345
|
/**
|
|
@@ -2201,7 +2350,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2201
2350
|
* @returns Promise resolving to the modified agent response
|
|
2202
2351
|
*/
|
|
2203
2352
|
async modifyAgent(agentData, options) {
|
|
2204
|
-
|
|
2353
|
+
log16("Modifying agent: %s", agentData.identifier);
|
|
2205
2354
|
const result = await this.request("/v1/agents/modify", {
|
|
2206
2355
|
body: JSON.stringify(agentData),
|
|
2207
2356
|
headers: {
|
|
@@ -2210,7 +2359,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2210
2359
|
method: "POST",
|
|
2211
2360
|
...options
|
|
2212
2361
|
});
|
|
2213
|
-
|
|
2362
|
+
log16("Agent modified successfully: %O", result);
|
|
2214
2363
|
return result;
|
|
2215
2364
|
}
|
|
2216
2365
|
/**
|
|
@@ -2221,7 +2370,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2221
2370
|
* @returns Promise resolving to the modified version response
|
|
2222
2371
|
*/
|
|
2223
2372
|
async modifyAgentVersion(versionData, options) {
|
|
2224
|
-
|
|
2373
|
+
log16("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
2225
2374
|
const result = await this.request("/v1/agents/version/modify", {
|
|
2226
2375
|
body: JSON.stringify(versionData),
|
|
2227
2376
|
headers: {
|
|
@@ -2230,7 +2379,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2230
2379
|
method: "POST",
|
|
2231
2380
|
...options
|
|
2232
2381
|
});
|
|
2233
|
-
|
|
2382
|
+
log16("Agent version modified successfully: %O", result);
|
|
2234
2383
|
return result;
|
|
2235
2384
|
}
|
|
2236
2385
|
/**
|
|
@@ -2241,13 +2390,13 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2241
2390
|
* @returns Promise resolving to true if agent exists, false otherwise
|
|
2242
2391
|
*/
|
|
2243
2392
|
async checkAgentExists(identifier, options) {
|
|
2244
|
-
|
|
2393
|
+
log16("Checking if agent exists: %s", identifier);
|
|
2245
2394
|
try {
|
|
2246
2395
|
await this.getAgentDetail(identifier, {}, options);
|
|
2247
|
-
|
|
2396
|
+
log16("Agent exists: %s", identifier);
|
|
2248
2397
|
return true;
|
|
2249
2398
|
} catch (e) {
|
|
2250
|
-
|
|
2399
|
+
log16("Agent does not exist: %s", identifier);
|
|
2251
2400
|
return false;
|
|
2252
2401
|
}
|
|
2253
2402
|
}
|
|
@@ -2260,7 +2409,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2260
2409
|
* @param options - Optional request init overrides
|
|
2261
2410
|
*/
|
|
2262
2411
|
async createEvent(eventData, options) {
|
|
2263
|
-
|
|
2412
|
+
log16("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
2264
2413
|
await this.request("/v1/agents/events", {
|
|
2265
2414
|
body: JSON.stringify(eventData),
|
|
2266
2415
|
headers: {
|
|
@@ -2281,7 +2430,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2281
2430
|
* @returns Promise resolving to the updated install count response
|
|
2282
2431
|
*/
|
|
2283
2432
|
async increaseInstallCount(identifier, options) {
|
|
2284
|
-
|
|
2433
|
+
log16("Increasing install count for agent: %s", identifier);
|
|
2285
2434
|
const result = await this.request("/v1/agents/install-count", {
|
|
2286
2435
|
body: JSON.stringify({ identifier }),
|
|
2287
2436
|
headers: {
|
|
@@ -2290,7 +2439,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2290
2439
|
method: "POST",
|
|
2291
2440
|
...options
|
|
2292
2441
|
});
|
|
2293
|
-
|
|
2442
|
+
log16("Install count increased for agent %s: %d", identifier, result.installCount);
|
|
2294
2443
|
return result;
|
|
2295
2444
|
}
|
|
2296
2445
|
/**
|
|
@@ -2305,9 +2454,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2305
2454
|
* @returns Promise resolving to the status change response
|
|
2306
2455
|
*/
|
|
2307
2456
|
async changeStatus(identifier, status, options) {
|
|
2308
|
-
|
|
2457
|
+
log16("Changing agent status: %s -> %s", identifier, status);
|
|
2309
2458
|
const result = await this.modifyAgent({ identifier, status }, options);
|
|
2310
|
-
|
|
2459
|
+
log16("Agent status changed: %s -> %s", identifier, result.status);
|
|
2311
2460
|
return {
|
|
2312
2461
|
identifier: result.identifier,
|
|
2313
2462
|
status: result.status,
|
|
@@ -2325,7 +2474,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2325
2474
|
* @returns Promise resolving to the status change response
|
|
2326
2475
|
*/
|
|
2327
2476
|
async publish(identifier, options) {
|
|
2328
|
-
|
|
2477
|
+
log16("Publishing agent: %s", identifier);
|
|
2329
2478
|
return this.changeStatus(identifier, "published", options);
|
|
2330
2479
|
}
|
|
2331
2480
|
/**
|
|
@@ -2340,7 +2489,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2340
2489
|
* @returns Promise resolving to the status change response
|
|
2341
2490
|
*/
|
|
2342
2491
|
async unpublish(identifier, options) {
|
|
2343
|
-
|
|
2492
|
+
log16("Unpublishing agent: %s", identifier);
|
|
2344
2493
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2345
2494
|
}
|
|
2346
2495
|
/**
|
|
@@ -2355,7 +2504,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2355
2504
|
* @returns Promise resolving to the status change response
|
|
2356
2505
|
*/
|
|
2357
2506
|
async archive(identifier, options) {
|
|
2358
|
-
|
|
2507
|
+
log16("Archiving agent: %s", identifier);
|
|
2359
2508
|
return this.changeStatus(identifier, "archived", options);
|
|
2360
2509
|
}
|
|
2361
2510
|
/**
|
|
@@ -2370,7 +2519,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2370
2519
|
* @returns Promise resolving to the status change response
|
|
2371
2520
|
*/
|
|
2372
2521
|
async deprecate(identifier, options) {
|
|
2373
|
-
|
|
2522
|
+
log16("Deprecating agent: %s", identifier);
|
|
2374
2523
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2375
2524
|
}
|
|
2376
2525
|
/**
|
|
@@ -2388,12 +2537,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2388
2537
|
const locale = params.locale || this.defaultLocale;
|
|
2389
2538
|
const queryParams = { ...params, locale };
|
|
2390
2539
|
const queryString = this.buildQueryString(queryParams);
|
|
2391
|
-
|
|
2540
|
+
log16("Getting agents by plugin: %s", params.pluginId);
|
|
2392
2541
|
const result = await this.request(
|
|
2393
2542
|
`/v1/agents/by-plugin${queryString}`,
|
|
2394
2543
|
options
|
|
2395
2544
|
);
|
|
2396
|
-
|
|
2545
|
+
log16("Retrieved %d agents for plugin %s", result.items.length, params.pluginId);
|
|
2397
2546
|
return result;
|
|
2398
2547
|
}
|
|
2399
2548
|
/**
|
|
@@ -2409,7 +2558,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2409
2558
|
* @returns Promise resolving to the fork response with new agent details
|
|
2410
2559
|
*/
|
|
2411
2560
|
async forkAgent(sourceIdentifier, forkData, options) {
|
|
2412
|
-
|
|
2561
|
+
log16("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2413
2562
|
const result = await this.request(`/v1/agents/${sourceIdentifier}/fork`, {
|
|
2414
2563
|
body: JSON.stringify(forkData),
|
|
2415
2564
|
headers: {
|
|
@@ -2418,7 +2567,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2418
2567
|
method: "POST",
|
|
2419
2568
|
...options
|
|
2420
2569
|
});
|
|
2421
|
-
|
|
2570
|
+
log16("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
2422
2571
|
return result;
|
|
2423
2572
|
}
|
|
2424
2573
|
/**
|
|
@@ -2432,12 +2581,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2432
2581
|
* @returns Promise resolving to the forks list response
|
|
2433
2582
|
*/
|
|
2434
2583
|
async getAgentForks(identifier, options) {
|
|
2435
|
-
|
|
2584
|
+
log16("Getting forks for agent: %s", identifier);
|
|
2436
2585
|
const result = await this.request(
|
|
2437
2586
|
`/v1/agents/${identifier}/forks`,
|
|
2438
2587
|
options
|
|
2439
2588
|
);
|
|
2440
|
-
|
|
2589
|
+
log16("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2441
2590
|
return result;
|
|
2442
2591
|
}
|
|
2443
2592
|
/**
|
|
@@ -2450,23 +2599,23 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2450
2599
|
* @returns Promise resolving to the fork source response
|
|
2451
2600
|
*/
|
|
2452
2601
|
async getAgentForkSource(identifier, options) {
|
|
2453
|
-
|
|
2602
|
+
log16("Getting fork source for agent: %s", identifier);
|
|
2454
2603
|
const result = await this.request(
|
|
2455
2604
|
`/v1/agents/${identifier}/fork-source`,
|
|
2456
2605
|
options
|
|
2457
2606
|
);
|
|
2458
2607
|
if (result.source) {
|
|
2459
|
-
|
|
2608
|
+
log16("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2460
2609
|
} else {
|
|
2461
|
-
|
|
2610
|
+
log16("Agent %s is not a fork (original agent)", identifier);
|
|
2462
2611
|
}
|
|
2463
2612
|
return result;
|
|
2464
2613
|
}
|
|
2465
2614
|
};
|
|
2466
2615
|
|
|
2467
2616
|
// src/market/services/AgentGroupService.ts
|
|
2468
|
-
import
|
|
2469
|
-
var
|
|
2617
|
+
import debug17 from "debug";
|
|
2618
|
+
var log17 = debug17("lobe-market-sdk:agent-groups");
|
|
2470
2619
|
var AgentGroupService = class extends BaseSDK {
|
|
2471
2620
|
/**
|
|
2472
2621
|
* Retrieves a list of agent groups from the marketplace
|
|
@@ -2481,12 +2630,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2481
2630
|
const locale = params.locale || this.defaultLocale;
|
|
2482
2631
|
const queryParams = { ...params, locale };
|
|
2483
2632
|
const queryString = this.buildQueryString(queryParams);
|
|
2484
|
-
|
|
2633
|
+
log17("Getting agent group list: %O", queryParams);
|
|
2485
2634
|
const result = await this.request(
|
|
2486
2635
|
`/v1/agent-groups${queryString}`,
|
|
2487
2636
|
options
|
|
2488
2637
|
);
|
|
2489
|
-
|
|
2638
|
+
log17("Retrieved %d agent groups", result.items.length);
|
|
2490
2639
|
return result;
|
|
2491
2640
|
}
|
|
2492
2641
|
/**
|
|
@@ -2503,12 +2652,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2503
2652
|
const locale = params.locale || this.defaultLocale;
|
|
2504
2653
|
const queryParams = { ...params, locale };
|
|
2505
2654
|
const queryString = this.buildQueryString(queryParams);
|
|
2506
|
-
|
|
2655
|
+
log17("Getting own agent group list: %O", queryParams);
|
|
2507
2656
|
const result = await this.request(
|
|
2508
2657
|
`/v1/agent-groups/own${queryString}`,
|
|
2509
2658
|
options
|
|
2510
2659
|
);
|
|
2511
|
-
|
|
2660
|
+
log17("Retrieved %d own agent groups", result.items.length);
|
|
2512
2661
|
return result;
|
|
2513
2662
|
}
|
|
2514
2663
|
/**
|
|
@@ -2529,12 +2678,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2529
2678
|
queryParams.version = params.version.toString();
|
|
2530
2679
|
}
|
|
2531
2680
|
const queryString = this.buildQueryString(queryParams);
|
|
2532
|
-
|
|
2681
|
+
log17("Getting agent group detail: %O", { identifier, ...params });
|
|
2533
2682
|
const result = await this.request(
|
|
2534
2683
|
`/v1/agent-groups/detail${queryString}`,
|
|
2535
2684
|
options
|
|
2536
2685
|
);
|
|
2537
|
-
|
|
2686
|
+
log17("Agent group detail successfully retrieved: %s", identifier);
|
|
2538
2687
|
return result;
|
|
2539
2688
|
}
|
|
2540
2689
|
/**
|
|
@@ -2548,7 +2697,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2548
2697
|
* @returns Promise resolving to the created agent group response
|
|
2549
2698
|
*/
|
|
2550
2699
|
async createAgentGroup(groupData, options) {
|
|
2551
|
-
|
|
2700
|
+
log17("Creating agent group: %s", groupData.identifier);
|
|
2552
2701
|
const result = await this.request("/v1/agent-groups/create", {
|
|
2553
2702
|
body: JSON.stringify(groupData),
|
|
2554
2703
|
headers: {
|
|
@@ -2557,7 +2706,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2557
2706
|
method: "POST",
|
|
2558
2707
|
...options
|
|
2559
2708
|
});
|
|
2560
|
-
|
|
2709
|
+
log17("Agent group created successfully: %O", result);
|
|
2561
2710
|
return result;
|
|
2562
2711
|
}
|
|
2563
2712
|
/**
|
|
@@ -2571,7 +2720,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2571
2720
|
* @returns Promise resolving to the created version response
|
|
2572
2721
|
*/
|
|
2573
2722
|
async createAgentGroupVersion(versionData, options) {
|
|
2574
|
-
|
|
2723
|
+
log17("Creating agent group version: %s", versionData.identifier);
|
|
2575
2724
|
const result = await this.request(
|
|
2576
2725
|
"/v1/agent-groups/version-create",
|
|
2577
2726
|
{
|
|
@@ -2583,7 +2732,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2583
2732
|
...options
|
|
2584
2733
|
}
|
|
2585
2734
|
);
|
|
2586
|
-
|
|
2735
|
+
log17("Agent group version created successfully: %O", result);
|
|
2587
2736
|
return result;
|
|
2588
2737
|
}
|
|
2589
2738
|
/**
|
|
@@ -2597,7 +2746,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2597
2746
|
* @returns Promise resolving to the modified agent group response
|
|
2598
2747
|
*/
|
|
2599
2748
|
async modifyAgentGroup(groupData, options) {
|
|
2600
|
-
|
|
2749
|
+
log17("Modifying agent group: %s", groupData.identifier);
|
|
2601
2750
|
const result = await this.request("/v1/agent-groups/modify", {
|
|
2602
2751
|
body: JSON.stringify(groupData),
|
|
2603
2752
|
headers: {
|
|
@@ -2606,7 +2755,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2606
2755
|
method: "POST",
|
|
2607
2756
|
...options
|
|
2608
2757
|
});
|
|
2609
|
-
|
|
2758
|
+
log17("Agent group modified successfully: %O", result);
|
|
2610
2759
|
return result;
|
|
2611
2760
|
}
|
|
2612
2761
|
/**
|
|
@@ -2617,13 +2766,13 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2617
2766
|
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2618
2767
|
*/
|
|
2619
2768
|
async checkAgentGroupExists(identifier, options) {
|
|
2620
|
-
|
|
2769
|
+
log17("Checking if agent group exists: %s", identifier);
|
|
2621
2770
|
try {
|
|
2622
2771
|
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2623
|
-
|
|
2772
|
+
log17("Agent group exists: %s", identifier);
|
|
2624
2773
|
return true;
|
|
2625
2774
|
} catch (e) {
|
|
2626
|
-
|
|
2775
|
+
log17("Agent group does not exist: %s", identifier);
|
|
2627
2776
|
return false;
|
|
2628
2777
|
}
|
|
2629
2778
|
}
|
|
@@ -2639,9 +2788,9 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2639
2788
|
* @returns Promise resolving to the status change response
|
|
2640
2789
|
*/
|
|
2641
2790
|
async changeStatus(identifier, status, options) {
|
|
2642
|
-
|
|
2791
|
+
log17("Changing agent group status: %s -> %s", identifier, status);
|
|
2643
2792
|
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2644
|
-
|
|
2793
|
+
log17("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2645
2794
|
return {
|
|
2646
2795
|
identifier: result.identifier,
|
|
2647
2796
|
status: result.status,
|
|
@@ -2660,7 +2809,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2660
2809
|
* @returns Promise resolving to the status change response
|
|
2661
2810
|
*/
|
|
2662
2811
|
async publish(identifier, options) {
|
|
2663
|
-
|
|
2812
|
+
log17("Publishing agent group: %s", identifier);
|
|
2664
2813
|
return this.changeStatus(identifier, "published", options);
|
|
2665
2814
|
}
|
|
2666
2815
|
/**
|
|
@@ -2675,7 +2824,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2675
2824
|
* @returns Promise resolving to the status change response
|
|
2676
2825
|
*/
|
|
2677
2826
|
async unpublish(identifier, options) {
|
|
2678
|
-
|
|
2827
|
+
log17("Unpublishing agent group: %s", identifier);
|
|
2679
2828
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2680
2829
|
}
|
|
2681
2830
|
/**
|
|
@@ -2690,7 +2839,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2690
2839
|
* @returns Promise resolving to the status change response
|
|
2691
2840
|
*/
|
|
2692
2841
|
async archive(identifier, options) {
|
|
2693
|
-
|
|
2842
|
+
log17("Archiving agent group: %s", identifier);
|
|
2694
2843
|
return this.changeStatus(identifier, "archived", options);
|
|
2695
2844
|
}
|
|
2696
2845
|
/**
|
|
@@ -2705,7 +2854,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2705
2854
|
* @returns Promise resolving to the status change response
|
|
2706
2855
|
*/
|
|
2707
2856
|
async deprecate(identifier, options) {
|
|
2708
|
-
|
|
2857
|
+
log17("Deprecating agent group: %s", identifier);
|
|
2709
2858
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2710
2859
|
}
|
|
2711
2860
|
/**
|
|
@@ -2721,7 +2870,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2721
2870
|
* @returns Promise resolving to the fork response with new group details
|
|
2722
2871
|
*/
|
|
2723
2872
|
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2724
|
-
|
|
2873
|
+
log17("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2725
2874
|
const result = await this.request(
|
|
2726
2875
|
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2727
2876
|
{
|
|
@@ -2733,7 +2882,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2733
2882
|
...options
|
|
2734
2883
|
}
|
|
2735
2884
|
);
|
|
2736
|
-
|
|
2885
|
+
log17(
|
|
2737
2886
|
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2738
2887
|
result.group.identifier,
|
|
2739
2888
|
result.group.id,
|
|
@@ -2752,12 +2901,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2752
2901
|
* @returns Promise resolving to the forks list response
|
|
2753
2902
|
*/
|
|
2754
2903
|
async getAgentGroupForks(identifier, options) {
|
|
2755
|
-
|
|
2904
|
+
log17("Getting forks for agent group: %s", identifier);
|
|
2756
2905
|
const result = await this.request(
|
|
2757
2906
|
`/v1/agent-groups/${identifier}/forks`,
|
|
2758
2907
|
options
|
|
2759
2908
|
);
|
|
2760
|
-
|
|
2909
|
+
log17("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2761
2910
|
return result;
|
|
2762
2911
|
}
|
|
2763
2912
|
/**
|
|
@@ -2770,24 +2919,24 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2770
2919
|
* @returns Promise resolving to the fork source response
|
|
2771
2920
|
*/
|
|
2772
2921
|
async getAgentGroupForkSource(identifier, options) {
|
|
2773
|
-
|
|
2922
|
+
log17("Getting fork source for agent group: %s", identifier);
|
|
2774
2923
|
const result = await this.request(
|
|
2775
2924
|
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2776
2925
|
options
|
|
2777
2926
|
);
|
|
2778
2927
|
if (result.source) {
|
|
2779
|
-
|
|
2928
|
+
log17("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2780
2929
|
} else {
|
|
2781
|
-
|
|
2930
|
+
log17("Agent group %s is not a fork (original group)", identifier);
|
|
2782
2931
|
}
|
|
2783
2932
|
return result;
|
|
2784
2933
|
}
|
|
2785
2934
|
};
|
|
2786
2935
|
|
|
2787
2936
|
// src/market/services/AuthService.ts
|
|
2788
|
-
import
|
|
2937
|
+
import debug18 from "debug";
|
|
2789
2938
|
import urlJoin2 from "url-join";
|
|
2790
|
-
var
|
|
2939
|
+
var log18 = debug18("lobe-market-sdk:auth");
|
|
2791
2940
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
2792
2941
|
/** Normalize token response from snake_case to camelCase fields */
|
|
2793
2942
|
static normalizeTokenResponse(data) {
|
|
@@ -2819,7 +2968,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2819
2968
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
2820
2969
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
2821
2970
|
}
|
|
2822
|
-
|
|
2971
|
+
log18("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2823
2972
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2824
2973
|
const params = new URLSearchParams();
|
|
2825
2974
|
params.set("grant_type", grantType);
|
|
@@ -2861,16 +3010,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2861
3010
|
try {
|
|
2862
3011
|
payload = await response.json();
|
|
2863
3012
|
} catch (error) {
|
|
2864
|
-
|
|
3013
|
+
log18("Failed to parse token response: %O", error);
|
|
2865
3014
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
2866
3015
|
}
|
|
2867
3016
|
if (!response.ok) {
|
|
2868
3017
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
2869
3018
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
2870
|
-
|
|
3019
|
+
log18("Error: %s", errorMsg);
|
|
2871
3020
|
throw new Error(errorMsg);
|
|
2872
3021
|
}
|
|
2873
|
-
|
|
3022
|
+
log18("Token exchange successful");
|
|
2874
3023
|
return _AuthService.normalizeTokenResponse(payload);
|
|
2875
3024
|
}
|
|
2876
3025
|
/**
|
|
@@ -2888,7 +3037,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2888
3037
|
if (!clientId || !token) {
|
|
2889
3038
|
throw new Error("clientId and token are required for token revocation");
|
|
2890
3039
|
}
|
|
2891
|
-
|
|
3040
|
+
log18("Revoking OAuth token (hint=%s)", tokenTypeHint != null ? tokenTypeHint : "none");
|
|
2892
3041
|
const revocationUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token/revocation");
|
|
2893
3042
|
const params = new URLSearchParams();
|
|
2894
3043
|
params.set("client_id", clientId);
|
|
@@ -2916,10 +3065,10 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2916
3065
|
} catch (e) {
|
|
2917
3066
|
}
|
|
2918
3067
|
const errorMsg = `Token revocation failed: ${response.status} ${errorDescription}`;
|
|
2919
|
-
|
|
3068
|
+
log18("Error: %s", errorMsg);
|
|
2920
3069
|
throw new Error(errorMsg);
|
|
2921
3070
|
}
|
|
2922
|
-
|
|
3071
|
+
log18("Token revocation successful");
|
|
2923
3072
|
}
|
|
2924
3073
|
/**
|
|
2925
3074
|
* Retrieves user information from the OIDC userinfo endpoint
|
|
@@ -2931,7 +3080,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2931
3080
|
* @returns Promise resolving to the user information
|
|
2932
3081
|
*/
|
|
2933
3082
|
async getUserInfo(accessToken, options) {
|
|
2934
|
-
|
|
3083
|
+
log18("Getting user info");
|
|
2935
3084
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
2936
3085
|
const response = await fetch(userInfoUrl, {
|
|
2937
3086
|
headers: {
|
|
@@ -2943,11 +3092,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2943
3092
|
});
|
|
2944
3093
|
if (!response.ok) {
|
|
2945
3094
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
2946
|
-
|
|
3095
|
+
log18("Error: %s", errorMsg);
|
|
2947
3096
|
throw new Error(errorMsg);
|
|
2948
3097
|
}
|
|
2949
3098
|
const userInfo = await response.json();
|
|
2950
|
-
|
|
3099
|
+
log18("User info retrieved successfully");
|
|
2951
3100
|
return userInfo;
|
|
2952
3101
|
}
|
|
2953
3102
|
/**
|
|
@@ -2961,7 +3110,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2961
3110
|
* @returns Promise resolving to the client credentials
|
|
2962
3111
|
*/
|
|
2963
3112
|
async registerClient(clientData, options) {
|
|
2964
|
-
|
|
3113
|
+
log18("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
2965
3114
|
const result = await this.request("/v1/clients/register", {
|
|
2966
3115
|
body: JSON.stringify(clientData),
|
|
2967
3116
|
headers: {
|
|
@@ -2970,7 +3119,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2970
3119
|
method: "POST",
|
|
2971
3120
|
...options
|
|
2972
3121
|
});
|
|
2973
|
-
|
|
3122
|
+
log18("Client registered successfully: %s", result.client_id);
|
|
2974
3123
|
return result;
|
|
2975
3124
|
}
|
|
2976
3125
|
/**
|
|
@@ -2982,9 +3131,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2982
3131
|
* @returns Promise resolving to the access token and expiration time
|
|
2983
3132
|
*/
|
|
2984
3133
|
async getM2MToken() {
|
|
2985
|
-
|
|
3134
|
+
log18("Fetching M2M token");
|
|
2986
3135
|
const tokenInfo = await this.fetchM2MToken();
|
|
2987
|
-
|
|
3136
|
+
log18("M2M token fetched successfully");
|
|
2988
3137
|
return tokenInfo;
|
|
2989
3138
|
}
|
|
2990
3139
|
/** OAuth handoff response shapes */
|
|
@@ -3010,7 +3159,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3010
3159
|
async getOAuthHandoff(id, options) {
|
|
3011
3160
|
var _a, _b;
|
|
3012
3161
|
if (!id) throw new Error("id is required");
|
|
3013
|
-
|
|
3162
|
+
log18("Getting OAuth handoff: %s", id);
|
|
3014
3163
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
3015
3164
|
const response = await fetch(handoffUrl, {
|
|
3016
3165
|
headers: {
|
|
@@ -3026,19 +3175,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3026
3175
|
code: json.code,
|
|
3027
3176
|
redirectUri: json.redirectUri
|
|
3028
3177
|
});
|
|
3029
|
-
|
|
3178
|
+
log18("OAuth handoff success for id: %s", id);
|
|
3030
3179
|
return result;
|
|
3031
3180
|
}
|
|
3032
3181
|
if (response.status === 202) {
|
|
3033
|
-
|
|
3182
|
+
log18("OAuth handoff pending for id: %s", id);
|
|
3034
3183
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
3035
3184
|
}
|
|
3036
3185
|
if (response.status === 404) {
|
|
3037
|
-
|
|
3186
|
+
log18("OAuth handoff consumed for id: %s", id);
|
|
3038
3187
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
3039
3188
|
}
|
|
3040
3189
|
if (response.status === 410) {
|
|
3041
|
-
|
|
3190
|
+
log18("OAuth handoff expired for id: %s", id);
|
|
3042
3191
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
3043
3192
|
}
|
|
3044
3193
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -3049,7 +3198,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3049
3198
|
}
|
|
3050
3199
|
} catch (e) {
|
|
3051
3200
|
}
|
|
3052
|
-
|
|
3201
|
+
log18("Error: %s", errorMessage);
|
|
3053
3202
|
throw new Error(errorMessage);
|
|
3054
3203
|
}
|
|
3055
3204
|
/**
|
|
@@ -3063,21 +3212,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
3063
3212
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
3064
3213
|
const startedAt = Date.now();
|
|
3065
3214
|
const { signal, requestInit } = params;
|
|
3066
|
-
|
|
3215
|
+
log18("Start polling OAuth handoff: %s", id);
|
|
3067
3216
|
while (true) {
|
|
3068
3217
|
if (signal == null ? void 0 : signal.aborted) {
|
|
3069
3218
|
const err = new Error("Polling aborted");
|
|
3070
|
-
|
|
3219
|
+
log18("Error: %s", err.message);
|
|
3071
3220
|
throw err;
|
|
3072
3221
|
}
|
|
3073
3222
|
if (Date.now() - startedAt > timeoutMs) {
|
|
3074
3223
|
const err = new Error("Polling timeout");
|
|
3075
|
-
|
|
3224
|
+
log18("Error: %s", err.message);
|
|
3076
3225
|
throw err;
|
|
3077
3226
|
}
|
|
3078
3227
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
3079
3228
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
3080
|
-
|
|
3229
|
+
log18("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
3081
3230
|
return result;
|
|
3082
3231
|
}
|
|
3083
3232
|
await new Promise((resolve) => {
|
|
@@ -3098,9 +3247,9 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
3098
3247
|
var AuthService = _AuthService;
|
|
3099
3248
|
|
|
3100
3249
|
// src/market/services/ConnectService.ts
|
|
3101
|
-
import
|
|
3250
|
+
import debug19 from "debug";
|
|
3102
3251
|
import urlJoin3 from "url-join";
|
|
3103
|
-
var
|
|
3252
|
+
var log19 = debug19("lobe-market-sdk:connect");
|
|
3104
3253
|
var CIMD_CLIENT_METADATA_VERSION = "v1";
|
|
3105
3254
|
var CIMD_CLIENT_METADATA_VERSION_BY_PROVIDER = {
|
|
3106
3255
|
posthog: "v2"
|
|
@@ -3124,9 +3273,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3124
3273
|
*/
|
|
3125
3274
|
async listProviders(options) {
|
|
3126
3275
|
var _a;
|
|
3127
|
-
|
|
3276
|
+
log19("Listing connect providers");
|
|
3128
3277
|
const result = await this.request("/connect/providers", options);
|
|
3129
|
-
|
|
3278
|
+
log19("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
3130
3279
|
return result;
|
|
3131
3280
|
}
|
|
3132
3281
|
/**
|
|
@@ -3140,12 +3289,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3140
3289
|
*/
|
|
3141
3290
|
async getProvider(provider, options) {
|
|
3142
3291
|
var _a;
|
|
3143
|
-
|
|
3292
|
+
log19("Getting provider details: %s", provider);
|
|
3144
3293
|
const result = await this.request(
|
|
3145
3294
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
3146
3295
|
options
|
|
3147
3296
|
);
|
|
3148
|
-
|
|
3297
|
+
log19("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
3149
3298
|
return result;
|
|
3150
3299
|
}
|
|
3151
3300
|
/**
|
|
@@ -3164,12 +3313,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3164
3313
|
const metadataParams = hasParams ? params : void 0;
|
|
3165
3314
|
const requestOptions = hasParams ? options : params;
|
|
3166
3315
|
const version = getCimdClientMetadataVersion(provider, metadataParams == null ? void 0 : metadataParams.version);
|
|
3167
|
-
|
|
3316
|
+
log19("Getting CIMD client metadata for provider: %s version: %s", provider, version);
|
|
3168
3317
|
const result = await this.request(
|
|
3169
3318
|
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata/${encodeURIComponent(version)}.json`,
|
|
3170
3319
|
requestOptions
|
|
3171
3320
|
);
|
|
3172
|
-
|
|
3321
|
+
log19("Retrieved CIMD client metadata: %s", result.client_id);
|
|
3173
3322
|
return result;
|
|
3174
3323
|
}
|
|
3175
3324
|
/**
|
|
@@ -3209,7 +3358,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3209
3358
|
* ```
|
|
3210
3359
|
*/
|
|
3211
3360
|
async authorize(provider, params, options) {
|
|
3212
|
-
|
|
3361
|
+
log19("Requesting authorization code for provider: %s", provider);
|
|
3213
3362
|
const result = await this.request(
|
|
3214
3363
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
3215
3364
|
{
|
|
@@ -3221,7 +3370,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3221
3370
|
...options
|
|
3222
3371
|
}
|
|
3223
3372
|
);
|
|
3224
|
-
|
|
3373
|
+
log19("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
3225
3374
|
return result;
|
|
3226
3375
|
}
|
|
3227
3376
|
/**
|
|
@@ -3247,7 +3396,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3247
3396
|
* ```
|
|
3248
3397
|
*/
|
|
3249
3398
|
getAuthorizeUrl(provider, params) {
|
|
3250
|
-
|
|
3399
|
+
log19(
|
|
3251
3400
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
3252
3401
|
provider
|
|
3253
3402
|
);
|
|
@@ -3261,7 +3410,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3261
3410
|
const queryString = queryParams.toString();
|
|
3262
3411
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
3263
3412
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
3264
|
-
|
|
3413
|
+
log19("Generated authorize URL: %s", url);
|
|
3265
3414
|
return url;
|
|
3266
3415
|
}
|
|
3267
3416
|
/**
|
|
@@ -3275,12 +3424,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3275
3424
|
* @returns Promise resolving to the connection status
|
|
3276
3425
|
*/
|
|
3277
3426
|
async getStatus(provider, options) {
|
|
3278
|
-
|
|
3427
|
+
log19("Getting connection status for provider: %s", provider);
|
|
3279
3428
|
const result = await this.request(
|
|
3280
3429
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
3281
3430
|
options
|
|
3282
3431
|
);
|
|
3283
|
-
|
|
3432
|
+
log19("Provider %s connection status: connected=%s", provider, result.connected);
|
|
3284
3433
|
return result;
|
|
3285
3434
|
}
|
|
3286
3435
|
/**
|
|
@@ -3293,9 +3442,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3293
3442
|
*/
|
|
3294
3443
|
async listConnections(options) {
|
|
3295
3444
|
var _a;
|
|
3296
|
-
|
|
3445
|
+
log19("Listing user connections");
|
|
3297
3446
|
const result = await this.request("/connect/connections", options);
|
|
3298
|
-
|
|
3447
|
+
log19("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
3299
3448
|
return result;
|
|
3300
3449
|
}
|
|
3301
3450
|
/**
|
|
@@ -3309,12 +3458,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3309
3458
|
* @returns Promise resolving to the connection health status
|
|
3310
3459
|
*/
|
|
3311
3460
|
async getHealth(provider, options) {
|
|
3312
|
-
|
|
3461
|
+
log19("Checking health for provider: %s", provider);
|
|
3313
3462
|
const result = await this.request(
|
|
3314
3463
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
3315
3464
|
options
|
|
3316
3465
|
);
|
|
3317
|
-
|
|
3466
|
+
log19("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
3318
3467
|
return result;
|
|
3319
3468
|
}
|
|
3320
3469
|
/**
|
|
@@ -3327,9 +3476,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3327
3476
|
*/
|
|
3328
3477
|
async getAllHealth(options) {
|
|
3329
3478
|
var _a, _b, _c;
|
|
3330
|
-
|
|
3479
|
+
log19("Checking health for all connections");
|
|
3331
3480
|
const result = await this.request("/connect/health", options);
|
|
3332
|
-
|
|
3481
|
+
log19(
|
|
3333
3482
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
3334
3483
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
3335
3484
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -3348,7 +3497,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3348
3497
|
* @returns Promise resolving to the refresh result
|
|
3349
3498
|
*/
|
|
3350
3499
|
async refresh(provider, options) {
|
|
3351
|
-
|
|
3500
|
+
log19("Refreshing token for provider: %s", provider);
|
|
3352
3501
|
const result = await this.request(
|
|
3353
3502
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
3354
3503
|
{
|
|
@@ -3356,7 +3505,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3356
3505
|
...options
|
|
3357
3506
|
}
|
|
3358
3507
|
);
|
|
3359
|
-
|
|
3508
|
+
log19("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
3360
3509
|
return result;
|
|
3361
3510
|
}
|
|
3362
3511
|
/**
|
|
@@ -3370,7 +3519,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3370
3519
|
* @returns Promise resolving to the revoke result
|
|
3371
3520
|
*/
|
|
3372
3521
|
async revoke(provider, options) {
|
|
3373
|
-
|
|
3522
|
+
log19("Revoking connection for provider: %s", provider);
|
|
3374
3523
|
const result = await this.request(
|
|
3375
3524
|
`/connect/${encodeURIComponent(provider)}`,
|
|
3376
3525
|
{
|
|
@@ -3378,14 +3527,14 @@ var ConnectService = class extends BaseSDK {
|
|
|
3378
3527
|
...options
|
|
3379
3528
|
}
|
|
3380
3529
|
);
|
|
3381
|
-
|
|
3530
|
+
log19("Connection revoked for %s: success=%s", provider, result.success);
|
|
3382
3531
|
return result;
|
|
3383
3532
|
}
|
|
3384
3533
|
};
|
|
3385
3534
|
|
|
3386
3535
|
// src/market/services/CredService.ts
|
|
3387
|
-
import
|
|
3388
|
-
var
|
|
3536
|
+
import debug20 from "debug";
|
|
3537
|
+
var log20 = debug20("lobe-market-sdk:creds");
|
|
3389
3538
|
var CredService = class extends BaseSDK {
|
|
3390
3539
|
// ===========================================================================
|
|
3391
3540
|
// List & Get Operations
|
|
@@ -3401,9 +3550,9 @@ var CredService = class extends BaseSDK {
|
|
|
3401
3550
|
*/
|
|
3402
3551
|
async list(options) {
|
|
3403
3552
|
var _a;
|
|
3404
|
-
|
|
3553
|
+
log20("Listing user credentials");
|
|
3405
3554
|
const result = await this.request("/v1/user/creds", options);
|
|
3406
|
-
|
|
3555
|
+
log20("Found %d credentials", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
3407
3556
|
return result;
|
|
3408
3557
|
}
|
|
3409
3558
|
/**
|
|
@@ -3418,7 +3567,7 @@ var CredService = class extends BaseSDK {
|
|
|
3418
3567
|
* @returns Promise resolving to the credential details
|
|
3419
3568
|
*/
|
|
3420
3569
|
async get(id, getOptions, options) {
|
|
3421
|
-
|
|
3570
|
+
log20("Getting credential: %d (decrypt=%s)", id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
3422
3571
|
const queryParams = {};
|
|
3423
3572
|
if (getOptions == null ? void 0 : getOptions.decrypt) {
|
|
3424
3573
|
queryParams.decrypt = "true";
|
|
@@ -3428,7 +3577,7 @@ var CredService = class extends BaseSDK {
|
|
|
3428
3577
|
`/v1/user/creds/${id}${queryString}`,
|
|
3429
3578
|
options
|
|
3430
3579
|
);
|
|
3431
|
-
|
|
3580
|
+
log20("Retrieved credential: %s", result.key);
|
|
3432
3581
|
return result;
|
|
3433
3582
|
}
|
|
3434
3583
|
// ===========================================================================
|
|
@@ -3447,7 +3596,7 @@ var CredService = class extends BaseSDK {
|
|
|
3447
3596
|
* @returns Promise resolving to the created credential
|
|
3448
3597
|
*/
|
|
3449
3598
|
async createKV(data, options) {
|
|
3450
|
-
|
|
3599
|
+
log20("Creating KV credential: %s (type=%s)", data.key, data.type);
|
|
3451
3600
|
const result = await this.request("/v1/user/creds/kv", {
|
|
3452
3601
|
body: JSON.stringify(data),
|
|
3453
3602
|
headers: {
|
|
@@ -3456,7 +3605,7 @@ var CredService = class extends BaseSDK {
|
|
|
3456
3605
|
method: "POST",
|
|
3457
3606
|
...options
|
|
3458
3607
|
});
|
|
3459
|
-
|
|
3608
|
+
log20("Created KV credential: %d", result.id);
|
|
3460
3609
|
return result;
|
|
3461
3610
|
}
|
|
3462
3611
|
/**
|
|
@@ -3470,7 +3619,7 @@ var CredService = class extends BaseSDK {
|
|
|
3470
3619
|
* @returns Promise resolving to the created credential
|
|
3471
3620
|
*/
|
|
3472
3621
|
async createOAuth(data, options) {
|
|
3473
|
-
|
|
3622
|
+
log20("Creating OAuth credential: %s (connectionId=%d)", data.key, data.oauthConnectionId);
|
|
3474
3623
|
const result = await this.request("/v1/user/creds/oauth", {
|
|
3475
3624
|
body: JSON.stringify(data),
|
|
3476
3625
|
headers: {
|
|
@@ -3479,7 +3628,7 @@ var CredService = class extends BaseSDK {
|
|
|
3479
3628
|
method: "POST",
|
|
3480
3629
|
...options
|
|
3481
3630
|
});
|
|
3482
|
-
|
|
3631
|
+
log20("Created OAuth credential: %d", result.id);
|
|
3483
3632
|
return result;
|
|
3484
3633
|
}
|
|
3485
3634
|
/**
|
|
@@ -3493,7 +3642,7 @@ var CredService = class extends BaseSDK {
|
|
|
3493
3642
|
* @returns Promise resolving to the created credential
|
|
3494
3643
|
*/
|
|
3495
3644
|
async createFile(data, options) {
|
|
3496
|
-
|
|
3645
|
+
log20("Creating file credential: %s (fileName=%s)", data.key, data.fileName);
|
|
3497
3646
|
const result = await this.request("/v1/user/creds/file", {
|
|
3498
3647
|
body: JSON.stringify(data),
|
|
3499
3648
|
headers: {
|
|
@@ -3502,7 +3651,7 @@ var CredService = class extends BaseSDK {
|
|
|
3502
3651
|
method: "POST",
|
|
3503
3652
|
...options
|
|
3504
3653
|
});
|
|
3505
|
-
|
|
3654
|
+
log20("Created file credential: %d", result.id);
|
|
3506
3655
|
return result;
|
|
3507
3656
|
}
|
|
3508
3657
|
// ===========================================================================
|
|
@@ -3520,7 +3669,7 @@ var CredService = class extends BaseSDK {
|
|
|
3520
3669
|
* @returns Promise resolving to the updated credential
|
|
3521
3670
|
*/
|
|
3522
3671
|
async update(id, data, options) {
|
|
3523
|
-
|
|
3672
|
+
log20("Updating credential: %d", id);
|
|
3524
3673
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3525
3674
|
body: JSON.stringify(data),
|
|
3526
3675
|
headers: {
|
|
@@ -3529,7 +3678,7 @@ var CredService = class extends BaseSDK {
|
|
|
3529
3678
|
method: "PATCH",
|
|
3530
3679
|
...options
|
|
3531
3680
|
});
|
|
3532
|
-
|
|
3681
|
+
log20("Updated credential: %d", result.id);
|
|
3533
3682
|
return result;
|
|
3534
3683
|
}
|
|
3535
3684
|
// ===========================================================================
|
|
@@ -3550,7 +3699,7 @@ var CredService = class extends BaseSDK {
|
|
|
3550
3699
|
* @returns Promise resolving to the updated credential
|
|
3551
3700
|
*/
|
|
3552
3701
|
async share(id, data, options) {
|
|
3553
|
-
|
|
3702
|
+
log20("Sharing credential %d with org %s", id, data.orgId);
|
|
3554
3703
|
const result = await this.request(`/v1/user/creds/${id}/share`, {
|
|
3555
3704
|
body: JSON.stringify(data),
|
|
3556
3705
|
headers: {
|
|
@@ -3559,7 +3708,7 @@ var CredService = class extends BaseSDK {
|
|
|
3559
3708
|
method: "POST",
|
|
3560
3709
|
...options
|
|
3561
3710
|
});
|
|
3562
|
-
|
|
3711
|
+
log20("Shared credential: %d", result.id);
|
|
3563
3712
|
return result;
|
|
3564
3713
|
}
|
|
3565
3714
|
/**
|
|
@@ -3574,12 +3723,12 @@ var CredService = class extends BaseSDK {
|
|
|
3574
3723
|
* @returns Promise resolving to the updated credential
|
|
3575
3724
|
*/
|
|
3576
3725
|
async publish(id, options) {
|
|
3577
|
-
|
|
3726
|
+
log20("Publishing credential: %d", id);
|
|
3578
3727
|
const result = await this.request(`/v1/user/creds/${id}/publish`, {
|
|
3579
3728
|
method: "POST",
|
|
3580
3729
|
...options
|
|
3581
3730
|
});
|
|
3582
|
-
|
|
3731
|
+
log20("Published credential: %d", result.id);
|
|
3583
3732
|
return result;
|
|
3584
3733
|
}
|
|
3585
3734
|
/**
|
|
@@ -3594,12 +3743,12 @@ var CredService = class extends BaseSDK {
|
|
|
3594
3743
|
* @returns Promise resolving to the updated credential
|
|
3595
3744
|
*/
|
|
3596
3745
|
async unshare(id, options) {
|
|
3597
|
-
|
|
3746
|
+
log20("Unsharing credential: %d", id);
|
|
3598
3747
|
const result = await this.request(`/v1/user/creds/${id}/unshare`, {
|
|
3599
3748
|
method: "POST",
|
|
3600
3749
|
...options
|
|
3601
3750
|
});
|
|
3602
|
-
|
|
3751
|
+
log20("Unshared credential: %d", result.id);
|
|
3603
3752
|
return result;
|
|
3604
3753
|
}
|
|
3605
3754
|
// ===========================================================================
|
|
@@ -3615,12 +3764,12 @@ var CredService = class extends BaseSDK {
|
|
|
3615
3764
|
* @returns Promise resolving to the delete result
|
|
3616
3765
|
*/
|
|
3617
3766
|
async delete(id, options) {
|
|
3618
|
-
|
|
3767
|
+
log20("Deleting credential by ID: %d", id);
|
|
3619
3768
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3620
3769
|
method: "DELETE",
|
|
3621
3770
|
...options
|
|
3622
3771
|
});
|
|
3623
|
-
|
|
3772
|
+
log20("Deleted credential: %d, success=%s", id, result.success);
|
|
3624
3773
|
return result;
|
|
3625
3774
|
}
|
|
3626
3775
|
/**
|
|
@@ -3634,7 +3783,7 @@ var CredService = class extends BaseSDK {
|
|
|
3634
3783
|
* @returns Promise resolving to the delete result
|
|
3635
3784
|
*/
|
|
3636
3785
|
async deleteByKey(key, options) {
|
|
3637
|
-
|
|
3786
|
+
log20("Deleting credential by key: %s", key);
|
|
3638
3787
|
const result = await this.request(
|
|
3639
3788
|
`/v1/user/creds/key/${encodeURIComponent(key)}`,
|
|
3640
3789
|
{
|
|
@@ -3642,7 +3791,7 @@ var CredService = class extends BaseSDK {
|
|
|
3642
3791
|
...options
|
|
3643
3792
|
}
|
|
3644
3793
|
);
|
|
3645
|
-
|
|
3794
|
+
log20("Deleted credential by key: %s, success=%s", key, result.success);
|
|
3646
3795
|
return result;
|
|
3647
3796
|
}
|
|
3648
3797
|
// ===========================================================================
|
|
@@ -3661,12 +3810,12 @@ var CredService = class extends BaseSDK {
|
|
|
3661
3810
|
* @returns Promise resolving to the credential status list
|
|
3662
3811
|
*/
|
|
3663
3812
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
3664
|
-
|
|
3813
|
+
log20("Getting skill cred status: %s", skillIdentifier);
|
|
3665
3814
|
const result = await this.request(
|
|
3666
3815
|
`/v1/skills/${encodeURIComponent(skillIdentifier)}/creds/status`,
|
|
3667
3816
|
options
|
|
3668
3817
|
);
|
|
3669
|
-
|
|
3818
|
+
log20("Skill %s has %d credential requirements", skillIdentifier, result.length);
|
|
3670
3819
|
return result;
|
|
3671
3820
|
}
|
|
3672
3821
|
// ===========================================================================
|
|
@@ -3705,7 +3854,7 @@ var CredService = class extends BaseSDK {
|
|
|
3705
3854
|
*/
|
|
3706
3855
|
async inject(request, options) {
|
|
3707
3856
|
var _a, _b, _c, _d;
|
|
3708
|
-
|
|
3857
|
+
log20("Injecting credentials by keys: %O (sandbox=%s)", request.keys, request.sandbox);
|
|
3709
3858
|
const result = await this.request(
|
|
3710
3859
|
"/v1/plugins/run-buildin-tools/inject-creds",
|
|
3711
3860
|
{
|
|
@@ -3717,7 +3866,7 @@ var CredService = class extends BaseSDK {
|
|
|
3717
3866
|
...options
|
|
3718
3867
|
}
|
|
3719
3868
|
);
|
|
3720
|
-
|
|
3869
|
+
log20(
|
|
3721
3870
|
"Inject result: success=%s, env=%d, files=%d, notFound=%d",
|
|
3722
3871
|
result.success,
|
|
3723
3872
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3759,7 +3908,7 @@ var CredService = class extends BaseSDK {
|
|
|
3759
3908
|
*/
|
|
3760
3909
|
async injectForSkill(request, options) {
|
|
3761
3910
|
var _a, _b, _c, _d;
|
|
3762
|
-
|
|
3911
|
+
log20(
|
|
3763
3912
|
"Injecting credentials for skill: %s (sandbox=%s)",
|
|
3764
3913
|
request.skillIdentifier,
|
|
3765
3914
|
request.sandbox
|
|
@@ -3775,7 +3924,7 @@ var CredService = class extends BaseSDK {
|
|
|
3775
3924
|
...options
|
|
3776
3925
|
}
|
|
3777
3926
|
);
|
|
3778
|
-
|
|
3927
|
+
log20(
|
|
3779
3928
|
"Inject result: success=%s, env=%d, files=%d, missing=%d",
|
|
3780
3929
|
result.success,
|
|
3781
3930
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3787,11 +3936,11 @@ var CredService = class extends BaseSDK {
|
|
|
3787
3936
|
};
|
|
3788
3937
|
|
|
3789
3938
|
// src/market/services/DeploymentService.ts
|
|
3790
|
-
import
|
|
3791
|
-
var
|
|
3939
|
+
import debug21 from "debug";
|
|
3940
|
+
var log21 = debug21("lobe-market-sdk:deployments");
|
|
3792
3941
|
var DeploymentService = class extends BaseSDK {
|
|
3793
3942
|
async prepareUpload(data, options) {
|
|
3794
|
-
|
|
3943
|
+
log21("Preparing deployment upload with %d files", data.files.length);
|
|
3795
3944
|
const result = await this.request(
|
|
3796
3945
|
"/v1/deployments/uploads/prepare",
|
|
3797
3946
|
{
|
|
@@ -3803,7 +3952,7 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3803
3952
|
return result.data;
|
|
3804
3953
|
}
|
|
3805
3954
|
async ingestUpload(uploadId, options) {
|
|
3806
|
-
|
|
3955
|
+
log21("Ingesting deployment upload: %s", uploadId);
|
|
3807
3956
|
const result = await this.request(
|
|
3808
3957
|
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/ingest`,
|
|
3809
3958
|
{ ...options, method: "POST" }
|
|
@@ -3811,7 +3960,7 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3811
3960
|
return result.data;
|
|
3812
3961
|
}
|
|
3813
3962
|
async finalizeUpload(uploadId, options) {
|
|
3814
|
-
|
|
3963
|
+
log21("Finalizing deployment upload: %s", uploadId);
|
|
3815
3964
|
const result = await this.request(
|
|
3816
3965
|
`/v1/deployments/uploads/${encodeURIComponent(uploadId)}/finalize`,
|
|
3817
3966
|
{ ...options, method: "POST" }
|
|
@@ -3821,9 +3970,9 @@ var DeploymentService = class extends BaseSDK {
|
|
|
3821
3970
|
};
|
|
3822
3971
|
|
|
3823
3972
|
// src/market/services/DiscoveryService.ts
|
|
3824
|
-
import
|
|
3973
|
+
import debug22 from "debug";
|
|
3825
3974
|
import urlJoin4 from "url-join";
|
|
3826
|
-
var
|
|
3975
|
+
var log22 = debug22("lobe-market-sdk:discovery");
|
|
3827
3976
|
var DiscoveryService = class extends BaseSDK {
|
|
3828
3977
|
/**
|
|
3829
3978
|
* Retrieves the service discovery document
|
|
@@ -3835,9 +3984,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3835
3984
|
* @returns Promise resolving to the service discovery document
|
|
3836
3985
|
*/
|
|
3837
3986
|
async getDiscoveryDocument() {
|
|
3838
|
-
|
|
3987
|
+
log22("Fetching discovery document");
|
|
3839
3988
|
if (this.discoveryDoc) {
|
|
3840
|
-
|
|
3989
|
+
log22("Returning cached discovery document");
|
|
3841
3990
|
return this.discoveryDoc;
|
|
3842
3991
|
}
|
|
3843
3992
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -3845,14 +3994,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3845
3994
|
throw new Error(await res.text());
|
|
3846
3995
|
}
|
|
3847
3996
|
this.discoveryDoc = await res.json();
|
|
3848
|
-
|
|
3997
|
+
log22("Discovery document successfully fetched");
|
|
3849
3998
|
return this.discoveryDoc;
|
|
3850
3999
|
}
|
|
3851
4000
|
};
|
|
3852
4001
|
|
|
3853
4002
|
// src/market/services/FeedbackService.ts
|
|
3854
|
-
import
|
|
3855
|
-
var
|
|
4003
|
+
import debug23 from "debug";
|
|
4004
|
+
var log23 = debug23("lobe-market-sdk:feedback");
|
|
3856
4005
|
var FeedbackService = class extends BaseSDK {
|
|
3857
4006
|
/**
|
|
3858
4007
|
* Submits user feedback
|
|
@@ -3882,7 +4031,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3882
4031
|
* ```
|
|
3883
4032
|
*/
|
|
3884
4033
|
async submitFeedback(data, options) {
|
|
3885
|
-
|
|
4034
|
+
log23("Submitting feedback: %s", data.title);
|
|
3886
4035
|
const result = await this.request("/v1/user/feedback", {
|
|
3887
4036
|
body: JSON.stringify(data),
|
|
3888
4037
|
headers: {
|
|
@@ -3891,14 +4040,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3891
4040
|
method: "POST",
|
|
3892
4041
|
...options
|
|
3893
4042
|
});
|
|
3894
|
-
|
|
4043
|
+
log23("Feedback submitted successfully: %s", result.issueId);
|
|
3895
4044
|
return result;
|
|
3896
4045
|
}
|
|
3897
4046
|
};
|
|
3898
4047
|
|
|
3899
4048
|
// src/market/services/PluginsService.ts
|
|
3900
|
-
import
|
|
3901
|
-
var
|
|
4049
|
+
import debug24 from "debug";
|
|
4050
|
+
var log24 = debug24("lobe-market-sdk:plugins");
|
|
3902
4051
|
function encodeBase64(input) {
|
|
3903
4052
|
if (typeof Buffer !== "undefined") {
|
|
3904
4053
|
return Buffer.from(input, "utf8").toString("base64");
|
|
@@ -3912,6 +4061,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
3912
4061
|
/**
|
|
3913
4062
|
* Retrieves a list of plugins from the marketplace
|
|
3914
4063
|
*
|
|
4064
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
4065
|
+
*
|
|
3915
4066
|
* Supports filtering, pagination, and localization of results.
|
|
3916
4067
|
*
|
|
3917
4068
|
* @param params - Query parameters for filtering and pagination
|
|
@@ -3922,9 +4073,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
3922
4073
|
const locale = params.locale || this.defaultLocale;
|
|
3923
4074
|
const queryParams = { ...params, locale };
|
|
3924
4075
|
const queryString = this.buildQueryString(queryParams);
|
|
3925
|
-
|
|
4076
|
+
log24("Getting plugin list: %O", queryParams);
|
|
3926
4077
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
3927
|
-
|
|
4078
|
+
log24("Retrieved %d plugins", result.items.length);
|
|
3928
4079
|
return result;
|
|
3929
4080
|
}
|
|
3930
4081
|
/**
|
|
@@ -3942,12 +4093,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3942
4093
|
const locale = params.locale || this.defaultLocale;
|
|
3943
4094
|
const queryParams = { ...params, locale };
|
|
3944
4095
|
const queryString = this.buildQueryString(queryParams);
|
|
3945
|
-
|
|
4096
|
+
log24("Getting plugin categories: %O", queryParams);
|
|
3946
4097
|
const result = await this.request(
|
|
3947
4098
|
`/v1/plugins/categories${queryString}`,
|
|
3948
4099
|
options
|
|
3949
4100
|
);
|
|
3950
|
-
|
|
4101
|
+
log24("Retrieved %d categories", result.length);
|
|
3951
4102
|
return result;
|
|
3952
4103
|
}
|
|
3953
4104
|
/**
|
|
@@ -3961,12 +4112,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3961
4112
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
3962
4113
|
*/
|
|
3963
4114
|
async getPublishedIdentifiers(options) {
|
|
3964
|
-
|
|
4115
|
+
log24("Getting published plugin identifiers");
|
|
3965
4116
|
const result = await this.request(
|
|
3966
4117
|
"/v1/plugins/identifiers",
|
|
3967
4118
|
options
|
|
3968
4119
|
);
|
|
3969
|
-
|
|
4120
|
+
log24("Retrieved %d published plugin identifiers", result.length);
|
|
3970
4121
|
return result;
|
|
3971
4122
|
}
|
|
3972
4123
|
/**
|
|
@@ -3977,12 +4128,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3977
4128
|
*/
|
|
3978
4129
|
async getSitemap(params = {}, options) {
|
|
3979
4130
|
const queryString = this.buildQueryString(params);
|
|
3980
|
-
|
|
4131
|
+
log24("Getting plugin sitemap%s", queryString);
|
|
3981
4132
|
const result = await this.request(
|
|
3982
4133
|
`/v1/plugins/sitemap${queryString}`,
|
|
3983
4134
|
options
|
|
3984
4135
|
);
|
|
3985
|
-
|
|
4136
|
+
log24(
|
|
3986
4137
|
"Retrieved plugin sitemap page %d/%d (%d items)",
|
|
3987
4138
|
result.currentPage,
|
|
3988
4139
|
result.totalPages,
|
|
@@ -4007,7 +4158,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4007
4158
|
version,
|
|
4008
4159
|
identifier
|
|
4009
4160
|
}, options) {
|
|
4010
|
-
|
|
4161
|
+
log24("Getting plugin manifest: %O", { identifier, locale, version });
|
|
4011
4162
|
const localeParam = locale || this.defaultLocale;
|
|
4012
4163
|
const params = { locale: localeParam };
|
|
4013
4164
|
if (version) {
|
|
@@ -4018,7 +4169,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4018
4169
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
4019
4170
|
options
|
|
4020
4171
|
);
|
|
4021
|
-
|
|
4172
|
+
log24("Plugin manifest successfully retrieved: %s", identifier);
|
|
4022
4173
|
return manifest;
|
|
4023
4174
|
}
|
|
4024
4175
|
/**
|
|
@@ -4035,7 +4186,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4035
4186
|
version,
|
|
4036
4187
|
identifier
|
|
4037
4188
|
}, options) {
|
|
4038
|
-
|
|
4189
|
+
log24("Getting plugin detail: %O", { identifier, locale, version });
|
|
4039
4190
|
const localeParam = locale || this.defaultLocale;
|
|
4040
4191
|
const params = { locale: localeParam };
|
|
4041
4192
|
if (version) {
|
|
@@ -4046,7 +4197,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4046
4197
|
`/v1/plugins/${identifier}${queryString}`,
|
|
4047
4198
|
options
|
|
4048
4199
|
);
|
|
4049
|
-
|
|
4200
|
+
log24("Plugin manifest successfully retrieved: %s", identifier);
|
|
4050
4201
|
return manifest;
|
|
4051
4202
|
}
|
|
4052
4203
|
/**
|
|
@@ -4061,7 +4212,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4061
4212
|
*
|
|
4062
4213
|
*/
|
|
4063
4214
|
async reportInstallation(reportData) {
|
|
4064
|
-
|
|
4215
|
+
log24("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
4065
4216
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
4066
4217
|
body: JSON.stringify(reportData),
|
|
4067
4218
|
headers: {
|
|
@@ -4069,7 +4220,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4069
4220
|
},
|
|
4070
4221
|
method: "POST"
|
|
4071
4222
|
});
|
|
4072
|
-
|
|
4223
|
+
log24("Installation report submitted successfully: %O", result);
|
|
4073
4224
|
return result;
|
|
4074
4225
|
}
|
|
4075
4226
|
/**
|
|
@@ -4083,7 +4234,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4083
4234
|
* @returns Promise resolving to the report submission response
|
|
4084
4235
|
*/
|
|
4085
4236
|
async reportCall(reportData) {
|
|
4086
|
-
|
|
4237
|
+
log24(
|
|
4087
4238
|
"Reporting call for %s@%s - %s:%s",
|
|
4088
4239
|
reportData.identifier,
|
|
4089
4240
|
reportData.version,
|
|
@@ -4097,7 +4248,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4097
4248
|
},
|
|
4098
4249
|
method: "POST"
|
|
4099
4250
|
});
|
|
4100
|
-
|
|
4251
|
+
log24("Call report submitted successfully: %O", result);
|
|
4101
4252
|
return result;
|
|
4102
4253
|
}
|
|
4103
4254
|
/**
|
|
@@ -4109,7 +4260,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4109
4260
|
* @param options - Optional request init overrides
|
|
4110
4261
|
*/
|
|
4111
4262
|
async createEvent(eventData, options) {
|
|
4112
|
-
|
|
4263
|
+
log24("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
4113
4264
|
await this.request("/v1/plugins/events", {
|
|
4114
4265
|
body: JSON.stringify(eventData),
|
|
4115
4266
|
headers: {
|
|
@@ -4139,7 +4290,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4139
4290
|
* ```
|
|
4140
4291
|
*/
|
|
4141
4292
|
async callCloudGateway(request, options) {
|
|
4142
|
-
|
|
4293
|
+
log24("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
4143
4294
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
4144
4295
|
body: JSON.stringify(request),
|
|
4145
4296
|
headers: {
|
|
@@ -4148,7 +4299,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4148
4299
|
method: "POST",
|
|
4149
4300
|
...options
|
|
4150
4301
|
});
|
|
4151
|
-
|
|
4302
|
+
log24("Cloud gateway call completed: %O", {
|
|
4152
4303
|
identifier: request.identifier,
|
|
4153
4304
|
isError: result.isError,
|
|
4154
4305
|
toolName: request.toolName
|
|
@@ -4188,20 +4339,27 @@ var PluginsService = class extends BaseSDK {
|
|
|
4188
4339
|
* );
|
|
4189
4340
|
* ```
|
|
4190
4341
|
*/
|
|
4191
|
-
async runBuildInTool(toolName, params,
|
|
4192
|
-
|
|
4342
|
+
async runBuildInTool(toolName, params, context2, options) {
|
|
4343
|
+
log24(
|
|
4193
4344
|
"Running built-in tool: %s for user %s, topic %s",
|
|
4194
4345
|
toolName,
|
|
4195
|
-
|
|
4196
|
-
|
|
4346
|
+
context2.userId,
|
|
4347
|
+
context2.topicId
|
|
4197
4348
|
);
|
|
4198
4349
|
const result = await this.request("/v1/plugins/run-buildin-tools", {
|
|
4199
4350
|
body: JSON.stringify({
|
|
4200
4351
|
paramsB64: encodeBase64(JSON.stringify(params)),
|
|
4201
4352
|
paramsEncoding: "base64",
|
|
4202
4353
|
toolName,
|
|
4203
|
-
|
|
4204
|
-
|
|
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
|
|
4205
4363
|
}),
|
|
4206
4364
|
headers: {
|
|
4207
4365
|
"Content-Type": "application/json"
|
|
@@ -4209,7 +4367,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4209
4367
|
method: "POST",
|
|
4210
4368
|
...options
|
|
4211
4369
|
});
|
|
4212
|
-
|
|
4370
|
+
log24("Built-in tool execution completed: %O", {
|
|
4213
4371
|
success: result.success,
|
|
4214
4372
|
toolName
|
|
4215
4373
|
});
|
|
@@ -4223,8 +4381,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4223
4381
|
* @param options - Additional options (background, timeout)
|
|
4224
4382
|
* @returns Promise resolving to command execution result
|
|
4225
4383
|
*/
|
|
4226
|
-
async runCommand(command,
|
|
4227
|
-
return this.runBuildInTool("runCommand", { command, ...options },
|
|
4384
|
+
async runCommand(command, context2, options) {
|
|
4385
|
+
return this.runBuildInTool("runCommand", { command, ...options }, context2);
|
|
4228
4386
|
}
|
|
4229
4387
|
/**
|
|
4230
4388
|
* Read a file from the Code Interpreter sandbox
|
|
@@ -4234,8 +4392,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4234
4392
|
* @param options - Line range options (startLine, endLine)
|
|
4235
4393
|
* @returns Promise resolving to file content
|
|
4236
4394
|
*/
|
|
4237
|
-
async readFile(path,
|
|
4238
|
-
return this.runBuildInTool("readLocalFile", { path, ...options },
|
|
4395
|
+
async readFile(path, context2, options) {
|
|
4396
|
+
return this.runBuildInTool("readLocalFile", { path, ...options }, context2);
|
|
4239
4397
|
}
|
|
4240
4398
|
/**
|
|
4241
4399
|
* Write content to a file in the Code Interpreter sandbox
|
|
@@ -4246,8 +4404,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4246
4404
|
* @param options - Additional options (createDirectories)
|
|
4247
4405
|
* @returns Promise resolving to write result
|
|
4248
4406
|
*/
|
|
4249
|
-
async writeFile(path, content,
|
|
4250
|
-
return this.runBuildInTool("writeLocalFile", { content, path, ...options },
|
|
4407
|
+
async writeFile(path, content, context2, options) {
|
|
4408
|
+
return this.runBuildInTool("writeLocalFile", { content, path, ...options }, context2);
|
|
4251
4409
|
}
|
|
4252
4410
|
/**
|
|
4253
4411
|
* List files in a directory in the Code Interpreter sandbox
|
|
@@ -4256,8 +4414,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4256
4414
|
* @param context - User and topic context
|
|
4257
4415
|
* @returns Promise resolving to directory listing
|
|
4258
4416
|
*/
|
|
4259
|
-
async listFiles(directoryPath,
|
|
4260
|
-
return this.runBuildInTool("listLocalFiles", { directoryPath },
|
|
4417
|
+
async listFiles(directoryPath, context2) {
|
|
4418
|
+
return this.runBuildInTool("listLocalFiles", { directoryPath }, context2);
|
|
4261
4419
|
}
|
|
4262
4420
|
/**
|
|
4263
4421
|
* Search for files matching a glob pattern
|
|
@@ -4267,8 +4425,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4267
4425
|
* @param directory - Base directory (optional)
|
|
4268
4426
|
* @returns Promise resolving to matching files
|
|
4269
4427
|
*/
|
|
4270
|
-
async globFiles(pattern,
|
|
4271
|
-
return this.runBuildInTool("globLocalFiles", { directory, pattern },
|
|
4428
|
+
async globFiles(pattern, context2, directory) {
|
|
4429
|
+
return this.runBuildInTool("globLocalFiles", { directory, pattern }, context2);
|
|
4272
4430
|
}
|
|
4273
4431
|
/**
|
|
4274
4432
|
* Search file contents using regex pattern
|
|
@@ -4279,8 +4437,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4279
4437
|
* @param options - Additional options (filePattern, recursive)
|
|
4280
4438
|
* @returns Promise resolving to grep results
|
|
4281
4439
|
*/
|
|
4282
|
-
async grepContent(pattern, directory,
|
|
4283
|
-
return this.runBuildInTool("grepContent", { directory, pattern, ...options },
|
|
4440
|
+
async grepContent(pattern, directory, context2, options) {
|
|
4441
|
+
return this.runBuildInTool("grepContent", { directory, pattern, ...options }, context2);
|
|
4284
4442
|
}
|
|
4285
4443
|
/**
|
|
4286
4444
|
* Export a file from the Code Interpreter sandbox to a pre-signed URL
|
|
@@ -4307,8 +4465,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
4307
4465
|
* }
|
|
4308
4466
|
* ```
|
|
4309
4467
|
*/
|
|
4310
|
-
async exportFile(path, uploadUrl,
|
|
4311
|
-
return this.runBuildInTool("exportFile", { path, uploadUrl },
|
|
4468
|
+
async exportFile(path, uploadUrl, context2) {
|
|
4469
|
+
return this.runBuildInTool("exportFile", { path, uploadUrl }, context2);
|
|
4312
4470
|
}
|
|
4313
4471
|
// ============================================================================
|
|
4314
4472
|
// Rating Methods
|
|
@@ -4322,7 +4480,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4322
4480
|
* @returns Promise resolving to the submitted score
|
|
4323
4481
|
*/
|
|
4324
4482
|
async submitRating(identifier, score, options) {
|
|
4325
|
-
|
|
4483
|
+
log24("Submitting rating for plugin %s: %d", identifier, score);
|
|
4326
4484
|
const result = await this.request(
|
|
4327
4485
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4328
4486
|
{
|
|
@@ -4331,7 +4489,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4331
4489
|
method: "POST"
|
|
4332
4490
|
}
|
|
4333
4491
|
);
|
|
4334
|
-
|
|
4492
|
+
log24("Rating submitted for plugin %s: %d", identifier, result.score);
|
|
4335
4493
|
return result;
|
|
4336
4494
|
}
|
|
4337
4495
|
/**
|
|
@@ -4342,7 +4500,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4342
4500
|
* @returns Promise resolving to success status
|
|
4343
4501
|
*/
|
|
4344
4502
|
async deleteRating(identifier, options) {
|
|
4345
|
-
|
|
4503
|
+
log24("Deleting rating for plugin %s", identifier);
|
|
4346
4504
|
const result = await this.request(
|
|
4347
4505
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
4348
4506
|
{
|
|
@@ -4350,7 +4508,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4350
4508
|
method: "DELETE"
|
|
4351
4509
|
}
|
|
4352
4510
|
);
|
|
4353
|
-
|
|
4511
|
+
log24("Rating deleted for plugin %s", identifier);
|
|
4354
4512
|
return result;
|
|
4355
4513
|
}
|
|
4356
4514
|
/**
|
|
@@ -4361,12 +4519,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4361
4519
|
* @returns Promise resolving to the rating distribution
|
|
4362
4520
|
*/
|
|
4363
4521
|
async getRatingDistribution(identifier, options) {
|
|
4364
|
-
|
|
4522
|
+
log24("Getting rating distribution for plugin: %s", identifier);
|
|
4365
4523
|
const result = await this.request(
|
|
4366
4524
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4367
4525
|
options
|
|
4368
4526
|
);
|
|
4369
|
-
|
|
4527
|
+
log24("Rating distribution retrieved for plugin %s: %d total", identifier, result.totalCount);
|
|
4370
4528
|
return result;
|
|
4371
4529
|
}
|
|
4372
4530
|
// ============================================================================
|
|
@@ -4382,12 +4540,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
4382
4540
|
*/
|
|
4383
4541
|
async getComments(identifier, params = {}, options) {
|
|
4384
4542
|
const queryString = this.buildQueryString(params);
|
|
4385
|
-
|
|
4543
|
+
log24("Getting comments for plugin %s: %O", identifier, params);
|
|
4386
4544
|
const result = await this.request(
|
|
4387
4545
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4388
4546
|
options
|
|
4389
4547
|
);
|
|
4390
|
-
|
|
4548
|
+
log24(
|
|
4391
4549
|
"Retrieved %d comments for plugin %s (page %d/%d)",
|
|
4392
4550
|
result.items.length,
|
|
4393
4551
|
identifier,
|
|
@@ -4404,15 +4562,15 @@ var PluginsService = class extends BaseSDK {
|
|
|
4404
4562
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4405
4563
|
*/
|
|
4406
4564
|
async getLatestOwnComment(identifier, options) {
|
|
4407
|
-
|
|
4565
|
+
log24("Getting latest own comment for plugin %s", identifier);
|
|
4408
4566
|
const result = await this.request(
|
|
4409
4567
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4410
4568
|
options
|
|
4411
4569
|
);
|
|
4412
4570
|
if (result) {
|
|
4413
|
-
|
|
4571
|
+
log24("Retrieved latest own comment for plugin %s: id=%d", identifier, result.id);
|
|
4414
4572
|
} else {
|
|
4415
|
-
|
|
4573
|
+
log24("No own comments found for plugin %s", identifier);
|
|
4416
4574
|
}
|
|
4417
4575
|
return result;
|
|
4418
4576
|
}
|
|
@@ -4425,7 +4583,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4425
4583
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4426
4584
|
*/
|
|
4427
4585
|
async createComment(identifier, data, options) {
|
|
4428
|
-
|
|
4586
|
+
log24("Creating comment on plugin %s", identifier);
|
|
4429
4587
|
const result = await this.request(
|
|
4430
4588
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments`,
|
|
4431
4589
|
{
|
|
@@ -4434,7 +4592,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4434
4592
|
method: "POST"
|
|
4435
4593
|
}
|
|
4436
4594
|
);
|
|
4437
|
-
|
|
4595
|
+
log24("Comment created on plugin %s: id=%d", identifier, result.id);
|
|
4438
4596
|
return result;
|
|
4439
4597
|
}
|
|
4440
4598
|
/**
|
|
@@ -4446,7 +4604,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4446
4604
|
* @returns Promise resolving to success status
|
|
4447
4605
|
*/
|
|
4448
4606
|
async deleteComment(identifier, commentId, options) {
|
|
4449
|
-
|
|
4607
|
+
log24("Deleting comment %d from plugin %s", commentId, identifier);
|
|
4450
4608
|
const result = await this.request(
|
|
4451
4609
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4452
4610
|
{
|
|
@@ -4454,7 +4612,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4454
4612
|
method: "DELETE"
|
|
4455
4613
|
}
|
|
4456
4614
|
);
|
|
4457
|
-
|
|
4615
|
+
log24("Comment %d deleted from plugin %s", commentId, identifier);
|
|
4458
4616
|
return result;
|
|
4459
4617
|
}
|
|
4460
4618
|
// ============================================================================
|
|
@@ -4469,7 +4627,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4469
4627
|
* @returns Promise resolving to the created reaction
|
|
4470
4628
|
*/
|
|
4471
4629
|
async addReaction(commentId, type, options) {
|
|
4472
|
-
|
|
4630
|
+
log24("Adding %s reaction to comment %d", type, commentId);
|
|
4473
4631
|
const result = await this.request(
|
|
4474
4632
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4475
4633
|
{
|
|
@@ -4478,7 +4636,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4478
4636
|
method: "POST"
|
|
4479
4637
|
}
|
|
4480
4638
|
);
|
|
4481
|
-
|
|
4639
|
+
log24("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4482
4640
|
return result;
|
|
4483
4641
|
}
|
|
4484
4642
|
/**
|
|
@@ -4489,7 +4647,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4489
4647
|
* @returns Promise resolving to success status
|
|
4490
4648
|
*/
|
|
4491
4649
|
async removeReaction(commentId, options) {
|
|
4492
|
-
|
|
4650
|
+
log24("Removing reaction from comment %d", commentId);
|
|
4493
4651
|
const result = await this.request(
|
|
4494
4652
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4495
4653
|
{
|
|
@@ -4497,14 +4655,167 @@ var PluginsService = class extends BaseSDK {
|
|
|
4497
4655
|
method: "DELETE"
|
|
4498
4656
|
}
|
|
4499
4657
|
);
|
|
4500
|
-
|
|
4658
|
+
log24("Reaction removed from comment %d", commentId);
|
|
4501
4659
|
return result;
|
|
4502
4660
|
}
|
|
4503
4661
|
};
|
|
4504
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
|
+
|
|
4505
4816
|
// src/market/services/SkillService.ts
|
|
4506
|
-
import
|
|
4507
|
-
var
|
|
4817
|
+
import debug26 from "debug";
|
|
4818
|
+
var log26 = debug26("lobe-market-sdk:skill");
|
|
4508
4819
|
var SkillService2 = class extends BaseSDK {
|
|
4509
4820
|
/**
|
|
4510
4821
|
* Lists all available skill providers
|
|
@@ -4517,9 +4828,9 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4517
4828
|
*/
|
|
4518
4829
|
async listProviders(options) {
|
|
4519
4830
|
var _a;
|
|
4520
|
-
|
|
4831
|
+
log26("Listing skill providers");
|
|
4521
4832
|
const result = await this.request("/v1/skill/providers", options);
|
|
4522
|
-
|
|
4833
|
+
log26("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4523
4834
|
return result;
|
|
4524
4835
|
}
|
|
4525
4836
|
/**
|
|
@@ -4534,12 +4845,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4534
4845
|
*/
|
|
4535
4846
|
async listTools(provider, options) {
|
|
4536
4847
|
var _a;
|
|
4537
|
-
|
|
4848
|
+
log26("Listing tools for provider: %s", provider);
|
|
4538
4849
|
const result = await this.request(
|
|
4539
4850
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4540
4851
|
options
|
|
4541
4852
|
);
|
|
4542
|
-
|
|
4853
|
+
log26("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4543
4854
|
return result;
|
|
4544
4855
|
}
|
|
4545
4856
|
/**
|
|
@@ -4556,12 +4867,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4556
4867
|
*/
|
|
4557
4868
|
async listLiveTools(provider, options) {
|
|
4558
4869
|
var _a;
|
|
4559
|
-
|
|
4870
|
+
log26("Listing live tools for provider: %s", provider);
|
|
4560
4871
|
const result = await this.request(
|
|
4561
4872
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4562
4873
|
options
|
|
4563
4874
|
);
|
|
4564
|
-
|
|
4875
|
+
log26("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4565
4876
|
return result;
|
|
4566
4877
|
}
|
|
4567
4878
|
/**
|
|
@@ -4577,12 +4888,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4577
4888
|
*/
|
|
4578
4889
|
async getTool(provider, toolName, options) {
|
|
4579
4890
|
var _a;
|
|
4580
|
-
|
|
4891
|
+
log26("Getting tool %s from provider %s", toolName, provider);
|
|
4581
4892
|
const result = await this.request(
|
|
4582
4893
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
4583
4894
|
options
|
|
4584
4895
|
);
|
|
4585
|
-
|
|
4896
|
+
log26("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
4586
4897
|
return result;
|
|
4587
4898
|
}
|
|
4588
4899
|
/**
|
|
@@ -4596,12 +4907,12 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4596
4907
|
* @returns Promise resolving to the connection status
|
|
4597
4908
|
*/
|
|
4598
4909
|
async getStatus(provider, options) {
|
|
4599
|
-
|
|
4910
|
+
log26("Getting status for provider: %s", provider);
|
|
4600
4911
|
const result = await this.request(
|
|
4601
4912
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
4602
4913
|
options
|
|
4603
4914
|
);
|
|
4604
|
-
|
|
4915
|
+
log26("Provider %s status: connected=%s", provider, result.connected);
|
|
4605
4916
|
return result;
|
|
4606
4917
|
}
|
|
4607
4918
|
/**
|
|
@@ -4629,7 +4940,7 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4629
4940
|
* ```
|
|
4630
4941
|
*/
|
|
4631
4942
|
async callTool(provider, params, options) {
|
|
4632
|
-
|
|
4943
|
+
log26("Calling tool %s on provider %s", params.tool, provider);
|
|
4633
4944
|
const { args, tool, ...rest } = params;
|
|
4634
4945
|
const result = await this.request(
|
|
4635
4946
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -4646,14 +4957,14 @@ var SkillService2 = class extends BaseSDK {
|
|
|
4646
4957
|
...options
|
|
4647
4958
|
}
|
|
4648
4959
|
);
|
|
4649
|
-
|
|
4960
|
+
log26("Tool %s call completed: success=%s", params.tool, result.success);
|
|
4650
4961
|
return result;
|
|
4651
4962
|
}
|
|
4652
4963
|
};
|
|
4653
4964
|
|
|
4654
4965
|
// src/market/services/MarketTaskTemplateService.ts
|
|
4655
|
-
import
|
|
4656
|
-
var
|
|
4966
|
+
import debug27 from "debug";
|
|
4967
|
+
var log27 = debug27("lobe-market-sdk:task-templates");
|
|
4657
4968
|
var MarketTaskTemplateService = class extends BaseSDK {
|
|
4658
4969
|
/**
|
|
4659
4970
|
* Retrieves personalized task template recommendations.
|
|
@@ -4676,7 +4987,7 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4676
4987
|
refreshSeed: params.refreshSeed,
|
|
4677
4988
|
seedKey: params.seedKey
|
|
4678
4989
|
};
|
|
4679
|
-
|
|
4990
|
+
log27("Getting task template recommendations: %O", body);
|
|
4680
4991
|
const result = await this.request(
|
|
4681
4992
|
"/v1/task-templates/recommendations",
|
|
4682
4993
|
{
|
|
@@ -4685,14 +4996,14 @@ var MarketTaskTemplateService = class extends BaseSDK {
|
|
|
4685
4996
|
method: "POST"
|
|
4686
4997
|
}
|
|
4687
4998
|
);
|
|
4688
|
-
|
|
4999
|
+
log27("Retrieved %d task template recommendations", result.items.length);
|
|
4689
5000
|
return result;
|
|
4690
5001
|
}
|
|
4691
5002
|
};
|
|
4692
5003
|
|
|
4693
5004
|
// src/market/services/MarketSkillCollectionService.ts
|
|
4694
|
-
import
|
|
4695
|
-
var
|
|
5005
|
+
import debug28 from "debug";
|
|
5006
|
+
var log28 = debug28("lobe-market-sdk:skill-collections");
|
|
4696
5007
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
4697
5008
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
4698
5009
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -4701,12 +5012,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4701
5012
|
locale
|
|
4702
5013
|
};
|
|
4703
5014
|
const queryString = this.buildQueryString(queryParams);
|
|
4704
|
-
|
|
5015
|
+
log28("Getting skill collection detail: %s %O", slug, queryParams);
|
|
4705
5016
|
const result = await this.request(
|
|
4706
5017
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
4707
5018
|
options
|
|
4708
5019
|
);
|
|
4709
|
-
|
|
5020
|
+
log28("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
4710
5021
|
return result;
|
|
4711
5022
|
}
|
|
4712
5023
|
async getSkillCollections(params = {}, options) {
|
|
@@ -4716,23 +5027,25 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4716
5027
|
locale
|
|
4717
5028
|
};
|
|
4718
5029
|
const queryString = this.buildQueryString(queryParams);
|
|
4719
|
-
|
|
5030
|
+
log28("Getting skill collections: %O", queryParams);
|
|
4720
5031
|
const result = await this.request(
|
|
4721
5032
|
`/v1/skills/collections${queryString}`,
|
|
4722
5033
|
options
|
|
4723
5034
|
);
|
|
4724
|
-
|
|
5035
|
+
log28("Retrieved %d skill collections", result.length);
|
|
4725
5036
|
return result;
|
|
4726
5037
|
}
|
|
4727
5038
|
};
|
|
4728
5039
|
|
|
4729
5040
|
// src/market/services/MarketSkillService.ts
|
|
4730
|
-
import
|
|
4731
|
-
var
|
|
5041
|
+
import debug29 from "debug";
|
|
5042
|
+
var log29 = debug29("lobe-market-sdk:market-skills");
|
|
4732
5043
|
var MarketSkillService = class extends BaseSDK {
|
|
4733
5044
|
/**
|
|
4734
5045
|
* Retrieves a list of skills from the marketplace
|
|
4735
5046
|
*
|
|
5047
|
+
* Set category to UNCATEGORIZED_CATEGORY to select assets with no assigned category.
|
|
5048
|
+
*
|
|
4736
5049
|
* Supports filtering, pagination, search, and various sorting options
|
|
4737
5050
|
* including GitHub stats (stars, forks, watchers). Locale localizes
|
|
4738
5051
|
* descriptions and summaries, but the returned skill name stays canonical.
|
|
@@ -4761,9 +5074,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4761
5074
|
const locale = params.locale || this.defaultLocale;
|
|
4762
5075
|
const queryParams = { ...params, locale };
|
|
4763
5076
|
const queryString = this.buildQueryString(queryParams);
|
|
4764
|
-
|
|
5077
|
+
log29("Getting skill list: %O", queryParams);
|
|
4765
5078
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
4766
|
-
|
|
5079
|
+
log29(
|
|
4767
5080
|
"Retrieved %d skills (page %d/%d)",
|
|
4768
5081
|
result.items.length,
|
|
4769
5082
|
result.currentPage,
|
|
@@ -4802,12 +5115,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4802
5115
|
queryParams.version = params.version;
|
|
4803
5116
|
}
|
|
4804
5117
|
const queryString = this.buildQueryString(queryParams);
|
|
4805
|
-
|
|
5118
|
+
log29("Getting skill detail: %s %O", identifier, params);
|
|
4806
5119
|
const result = await this.request(
|
|
4807
5120
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
4808
5121
|
options
|
|
4809
5122
|
);
|
|
4810
|
-
|
|
5123
|
+
log29("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
4811
5124
|
return result;
|
|
4812
5125
|
}
|
|
4813
5126
|
/**
|
|
@@ -4838,7 +5151,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4838
5151
|
if (version) {
|
|
4839
5152
|
url += `?version=${encodeURIComponent(version)}`;
|
|
4840
5153
|
}
|
|
4841
|
-
|
|
5154
|
+
log29("Generated download URL: %s", url);
|
|
4842
5155
|
return url;
|
|
4843
5156
|
}
|
|
4844
5157
|
/**
|
|
@@ -4862,7 +5175,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4862
5175
|
* ```
|
|
4863
5176
|
*/
|
|
4864
5177
|
async downloadSkill(identifier, version, options) {
|
|
4865
|
-
|
|
5178
|
+
log29("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
4866
5179
|
const queryParams = {};
|
|
4867
5180
|
if (version) {
|
|
4868
5181
|
queryParams.version = version;
|
|
@@ -4878,7 +5191,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4878
5191
|
});
|
|
4879
5192
|
if (!response.ok) {
|
|
4880
5193
|
const errorText = await response.text();
|
|
4881
|
-
|
|
5194
|
+
log29("Download failed: %s %s", response.status, errorText);
|
|
4882
5195
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
4883
5196
|
}
|
|
4884
5197
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -4890,7 +5203,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4890
5203
|
}
|
|
4891
5204
|
}
|
|
4892
5205
|
const buffer = await response.arrayBuffer();
|
|
4893
|
-
|
|
5206
|
+
log29("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
4894
5207
|
return { buffer, filename };
|
|
4895
5208
|
}
|
|
4896
5209
|
/**
|
|
@@ -4918,12 +5231,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4918
5231
|
const locale = params.locale || this.defaultLocale;
|
|
4919
5232
|
const queryParams = { ...params, locale };
|
|
4920
5233
|
const queryString = this.buildQueryString(queryParams);
|
|
4921
|
-
|
|
5234
|
+
log29("Getting skill categories: %O", queryParams);
|
|
4922
5235
|
const result = await this.request(
|
|
4923
5236
|
`/v1/skills/categories${queryString}`,
|
|
4924
5237
|
options
|
|
4925
5238
|
);
|
|
4926
|
-
|
|
5239
|
+
log29("Retrieved %d categories", result.length);
|
|
4927
5240
|
return result;
|
|
4928
5241
|
}
|
|
4929
5242
|
/**
|
|
@@ -4938,12 +5251,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4938
5251
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
4939
5252
|
*/
|
|
4940
5253
|
async getPublishedIdentifiers(options) {
|
|
4941
|
-
|
|
5254
|
+
log29("Getting published skill identifiers");
|
|
4942
5255
|
const result = await this.request(
|
|
4943
5256
|
"/v1/skills/identifiers",
|
|
4944
5257
|
options
|
|
4945
5258
|
);
|
|
4946
|
-
|
|
5259
|
+
log29("Retrieved %d published skill identifiers", result.length);
|
|
4947
5260
|
return result;
|
|
4948
5261
|
}
|
|
4949
5262
|
/**
|
|
@@ -4954,9 +5267,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4954
5267
|
*/
|
|
4955
5268
|
async getSitemap(params = {}, options) {
|
|
4956
5269
|
const queryString = this.buildQueryString(params);
|
|
4957
|
-
|
|
5270
|
+
log29("Getting skill sitemap%s", queryString);
|
|
4958
5271
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
4959
|
-
|
|
5272
|
+
log29(
|
|
4960
5273
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
4961
5274
|
result.currentPage,
|
|
4962
5275
|
result.totalPages,
|
|
@@ -4972,13 +5285,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4972
5285
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
4973
5286
|
*/
|
|
4974
5287
|
async checkSkillExists(identifier, options) {
|
|
4975
|
-
|
|
5288
|
+
log29("Checking if skill exists: %s", identifier);
|
|
4976
5289
|
try {
|
|
4977
5290
|
await this.getSkillDetail(identifier, {}, options);
|
|
4978
|
-
|
|
5291
|
+
log29("Skill exists: %s", identifier);
|
|
4979
5292
|
return true;
|
|
4980
5293
|
} catch (e) {
|
|
4981
|
-
|
|
5294
|
+
log29("Skill does not exist: %s", identifier);
|
|
4982
5295
|
return false;
|
|
4983
5296
|
}
|
|
4984
5297
|
}
|
|
@@ -4999,12 +5312,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4999
5312
|
* ```
|
|
5000
5313
|
*/
|
|
5001
5314
|
async getSkillVersions(identifier, options) {
|
|
5002
|
-
|
|
5315
|
+
log29("Getting skill versions: %s", identifier);
|
|
5003
5316
|
const result = await this.request(
|
|
5004
5317
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
5005
5318
|
options
|
|
5006
5319
|
);
|
|
5007
|
-
|
|
5320
|
+
log29("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
5008
5321
|
return result.data;
|
|
5009
5322
|
}
|
|
5010
5323
|
/**
|
|
@@ -5028,12 +5341,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5028
5341
|
const locale = params.locale || this.defaultLocale;
|
|
5029
5342
|
const queryParams = { locale };
|
|
5030
5343
|
const queryString = this.buildQueryString(queryParams);
|
|
5031
|
-
|
|
5344
|
+
log29("Getting skill version: %s@%s", identifier, version);
|
|
5032
5345
|
const result = await this.request(
|
|
5033
5346
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
5034
5347
|
options
|
|
5035
5348
|
);
|
|
5036
|
-
|
|
5349
|
+
log29("Skill version detail retrieved: %s@%s", identifier, version);
|
|
5037
5350
|
return result;
|
|
5038
5351
|
}
|
|
5039
5352
|
/**
|
|
@@ -5062,13 +5375,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5062
5375
|
* ```
|
|
5063
5376
|
*/
|
|
5064
5377
|
async reportGitHubSkill(params, options) {
|
|
5065
|
-
|
|
5378
|
+
log29("Reporting GitHub skill: %s", params.gitUrl);
|
|
5066
5379
|
const result = await this.request("/v1/skills/report/github", {
|
|
5067
5380
|
...options,
|
|
5068
5381
|
body: JSON.stringify(params),
|
|
5069
5382
|
method: "POST"
|
|
5070
5383
|
});
|
|
5071
|
-
|
|
5384
|
+
log29("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
5072
5385
|
return result;
|
|
5073
5386
|
}
|
|
5074
5387
|
/**
|
|
@@ -5093,7 +5406,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5093
5406
|
* ```
|
|
5094
5407
|
*/
|
|
5095
5408
|
async reportSkillInstall(params, options) {
|
|
5096
|
-
|
|
5409
|
+
log29("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
5097
5410
|
const result = await this.request(
|
|
5098
5411
|
"/v1/skills/report/installation",
|
|
5099
5412
|
{
|
|
@@ -5102,7 +5415,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5102
5415
|
method: "POST"
|
|
5103
5416
|
}
|
|
5104
5417
|
);
|
|
5105
|
-
|
|
5418
|
+
log29("Skill install reported: %s", result.message);
|
|
5106
5419
|
return result;
|
|
5107
5420
|
}
|
|
5108
5421
|
/**
|
|
@@ -5114,7 +5427,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5114
5427
|
* @returns Promise resolving to the submitted score
|
|
5115
5428
|
*/
|
|
5116
5429
|
async submitRating(identifier, score, options) {
|
|
5117
|
-
|
|
5430
|
+
log29("Submitting rating for skill %s: %d", identifier, score);
|
|
5118
5431
|
const result = await this.request(
|
|
5119
5432
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
5120
5433
|
{
|
|
@@ -5123,7 +5436,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5123
5436
|
method: "POST"
|
|
5124
5437
|
}
|
|
5125
5438
|
);
|
|
5126
|
-
|
|
5439
|
+
log29("Rating submitted for skill %s: %d", identifier, result.score);
|
|
5127
5440
|
return result;
|
|
5128
5441
|
}
|
|
5129
5442
|
/**
|
|
@@ -5134,12 +5447,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5134
5447
|
* @returns Promise resolving to the rating distribution
|
|
5135
5448
|
*/
|
|
5136
5449
|
async getRatingDistribution(identifier, options) {
|
|
5137
|
-
|
|
5450
|
+
log29("Getting rating distribution for skill: %s", identifier);
|
|
5138
5451
|
const result = await this.request(
|
|
5139
5452
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
5140
5453
|
options
|
|
5141
5454
|
);
|
|
5142
|
-
|
|
5455
|
+
log29("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
5143
5456
|
return result;
|
|
5144
5457
|
}
|
|
5145
5458
|
/**
|
|
@@ -5152,12 +5465,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5152
5465
|
*/
|
|
5153
5466
|
async getComments(identifier, params = {}, options) {
|
|
5154
5467
|
const queryString = this.buildQueryString(params);
|
|
5155
|
-
|
|
5468
|
+
log29("Getting comments for skill %s: %O", identifier, params);
|
|
5156
5469
|
const result = await this.request(
|
|
5157
5470
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
5158
5471
|
options
|
|
5159
5472
|
);
|
|
5160
|
-
|
|
5473
|
+
log29(
|
|
5161
5474
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
5162
5475
|
result.items.length,
|
|
5163
5476
|
identifier,
|
|
@@ -5174,15 +5487,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5174
5487
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
5175
5488
|
*/
|
|
5176
5489
|
async getLatestOwnComment(identifier, options) {
|
|
5177
|
-
|
|
5490
|
+
log29("Getting latest own comment for skill %s", identifier);
|
|
5178
5491
|
const result = await this.request(
|
|
5179
5492
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
5180
5493
|
options
|
|
5181
5494
|
);
|
|
5182
5495
|
if (result) {
|
|
5183
|
-
|
|
5496
|
+
log29("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
5184
5497
|
} else {
|
|
5185
|
-
|
|
5498
|
+
log29("No own comments found for skill %s", identifier);
|
|
5186
5499
|
}
|
|
5187
5500
|
return result;
|
|
5188
5501
|
}
|
|
@@ -5195,7 +5508,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5195
5508
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
5196
5509
|
*/
|
|
5197
5510
|
async createComment(identifier, data, options) {
|
|
5198
|
-
|
|
5511
|
+
log29("Creating comment on skill %s", identifier);
|
|
5199
5512
|
const result = await this.request(
|
|
5200
5513
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
5201
5514
|
{
|
|
@@ -5204,7 +5517,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5204
5517
|
method: "POST"
|
|
5205
5518
|
}
|
|
5206
5519
|
);
|
|
5207
|
-
|
|
5520
|
+
log29("Comment created on skill %s: id=%d", identifier, result.id);
|
|
5208
5521
|
return result;
|
|
5209
5522
|
}
|
|
5210
5523
|
/**
|
|
@@ -5216,7 +5529,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5216
5529
|
* @returns Promise resolving to success status
|
|
5217
5530
|
*/
|
|
5218
5531
|
async deleteComment(identifier, commentId, options) {
|
|
5219
|
-
|
|
5532
|
+
log29("Deleting comment %d from skill %s", commentId, identifier);
|
|
5220
5533
|
const result = await this.request(
|
|
5221
5534
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
5222
5535
|
{
|
|
@@ -5224,7 +5537,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5224
5537
|
method: "DELETE"
|
|
5225
5538
|
}
|
|
5226
5539
|
);
|
|
5227
|
-
|
|
5540
|
+
log29("Comment %d deleted from skill %s", commentId, identifier);
|
|
5228
5541
|
return result;
|
|
5229
5542
|
}
|
|
5230
5543
|
/**
|
|
@@ -5236,7 +5549,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5236
5549
|
* @returns Promise resolving to the created reaction
|
|
5237
5550
|
*/
|
|
5238
5551
|
async addReaction(commentId, type, options) {
|
|
5239
|
-
|
|
5552
|
+
log29("Adding %s reaction to comment %d", type, commentId);
|
|
5240
5553
|
const result = await this.request(
|
|
5241
5554
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5242
5555
|
{
|
|
@@ -5245,7 +5558,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5245
5558
|
method: "POST"
|
|
5246
5559
|
}
|
|
5247
5560
|
);
|
|
5248
|
-
|
|
5561
|
+
log29("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
5249
5562
|
return result;
|
|
5250
5563
|
}
|
|
5251
5564
|
/**
|
|
@@ -5256,7 +5569,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5256
5569
|
* @returns Promise resolving to success status
|
|
5257
5570
|
*/
|
|
5258
5571
|
async removeReaction(commentId, options) {
|
|
5259
|
-
|
|
5572
|
+
log29("Removing reaction from comment %d", commentId);
|
|
5260
5573
|
const result = await this.request(
|
|
5261
5574
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
5262
5575
|
{
|
|
@@ -5264,19 +5577,19 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
5264
5577
|
method: "DELETE"
|
|
5265
5578
|
}
|
|
5266
5579
|
);
|
|
5267
|
-
|
|
5580
|
+
log29("Reaction removed from comment %d", commentId);
|
|
5268
5581
|
return result;
|
|
5269
5582
|
}
|
|
5270
5583
|
};
|
|
5271
5584
|
|
|
5272
5585
|
// src/market/services/OrganizationCredsService.ts
|
|
5273
|
-
import
|
|
5586
|
+
import debug30 from "debug";
|
|
5274
5587
|
|
|
5275
5588
|
// src/utils/orgRef.ts
|
|
5276
5589
|
var orgRefToPathSegment = (ref) => typeof ref === "number" ? String(ref) : `workspace:${encodeURIComponent(ref.workspaceId)}`;
|
|
5277
5590
|
|
|
5278
5591
|
// src/market/services/OrganizationCredsService.ts
|
|
5279
|
-
var
|
|
5592
|
+
var log30 = debug30("lobe-market-sdk:org-creds");
|
|
5280
5593
|
var OrganizationCredsService = class extends BaseSDK {
|
|
5281
5594
|
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
5282
5595
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5308,9 +5621,9 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5308
5621
|
*/
|
|
5309
5622
|
async list(options) {
|
|
5310
5623
|
var _a;
|
|
5311
|
-
|
|
5624
|
+
log30("Listing org %s credentials", this.orgSegment);
|
|
5312
5625
|
const result = await this.request(this.base(), options);
|
|
5313
|
-
|
|
5626
|
+
log30("Found %d credentials for org %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgSegment);
|
|
5314
5627
|
return result;
|
|
5315
5628
|
}
|
|
5316
5629
|
/**
|
|
@@ -5319,20 +5632,20 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5319
5632
|
* owner via `CredService.get(id, { decrypt: true })`.
|
|
5320
5633
|
*/
|
|
5321
5634
|
async get(id, getOptions, options) {
|
|
5322
|
-
|
|
5635
|
+
log30("Getting org %s credential %d (decrypt=%s)", this.orgSegment, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
5323
5636
|
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
5324
5637
|
const result = await this.request(
|
|
5325
5638
|
`${this.base()}/${id}${queryString}`,
|
|
5326
5639
|
options
|
|
5327
5640
|
);
|
|
5328
|
-
|
|
5641
|
+
log30("Retrieved org credential: %s", result.key);
|
|
5329
5642
|
return result;
|
|
5330
5643
|
}
|
|
5331
5644
|
// ===========================================================================
|
|
5332
5645
|
// Create
|
|
5333
5646
|
// ===========================================================================
|
|
5334
5647
|
async createKV(data, options) {
|
|
5335
|
-
|
|
5648
|
+
log30("Creating org %s KV credential: %s (type=%s)", this.orgSegment, data.key, data.type);
|
|
5336
5649
|
return this.request(`${this.base()}/kv`, {
|
|
5337
5650
|
body: JSON.stringify(data),
|
|
5338
5651
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5341,7 +5654,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5341
5654
|
});
|
|
5342
5655
|
}
|
|
5343
5656
|
async createOAuth(data, options) {
|
|
5344
|
-
|
|
5657
|
+
log30("Creating org %s OAuth credential: %s", this.orgSegment, data.key);
|
|
5345
5658
|
return this.request(`${this.base()}/oauth`, {
|
|
5346
5659
|
body: JSON.stringify(data),
|
|
5347
5660
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5350,7 +5663,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5350
5663
|
});
|
|
5351
5664
|
}
|
|
5352
5665
|
async createFile(data, options) {
|
|
5353
|
-
|
|
5666
|
+
log30("Creating org %s file credential: %s", this.orgSegment, data.key);
|
|
5354
5667
|
return this.request(`${this.base()}/file`, {
|
|
5355
5668
|
body: JSON.stringify(data),
|
|
5356
5669
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5362,7 +5675,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5362
5675
|
// Update
|
|
5363
5676
|
// ===========================================================================
|
|
5364
5677
|
async update(id, data, options) {
|
|
5365
|
-
|
|
5678
|
+
log30("Updating org %s credential %d", this.orgSegment, id);
|
|
5366
5679
|
return this.request(`${this.base()}/${id}`, {
|
|
5367
5680
|
body: JSON.stringify(data),
|
|
5368
5681
|
headers: { "Content-Type": "application/json" },
|
|
@@ -5374,14 +5687,14 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5374
5687
|
// Delete
|
|
5375
5688
|
// ===========================================================================
|
|
5376
5689
|
async delete(id, options) {
|
|
5377
|
-
|
|
5690
|
+
log30("Deleting org %s credential %d", this.orgSegment, id);
|
|
5378
5691
|
return this.request(`${this.base()}/${id}`, {
|
|
5379
5692
|
method: "DELETE",
|
|
5380
5693
|
...options
|
|
5381
5694
|
});
|
|
5382
5695
|
}
|
|
5383
5696
|
async deleteByKey(key, options) {
|
|
5384
|
-
|
|
5697
|
+
log30("Deleting org %s credential by key: %s", this.orgSegment, key);
|
|
5385
5698
|
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5386
5699
|
method: "DELETE",
|
|
5387
5700
|
...options
|
|
@@ -5395,7 +5708,7 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5395
5708
|
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5396
5709
|
*/
|
|
5397
5710
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
5398
|
-
|
|
5711
|
+
log30("Getting org %s skill cred status: %s", this.orgSegment, skillIdentifier);
|
|
5399
5712
|
const path = `/v1/organizations/${this.orgSegment}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5400
5713
|
const result = await this.request(
|
|
5401
5714
|
path,
|
|
@@ -5406,8 +5719,8 @@ var OrganizationCredsService = class extends BaseSDK {
|
|
|
5406
5719
|
};
|
|
5407
5720
|
|
|
5408
5721
|
// src/market/services/OrganizationService.ts
|
|
5409
|
-
import
|
|
5410
|
-
var
|
|
5722
|
+
import debug31 from "debug";
|
|
5723
|
+
var log31 = debug31("lobe-market-sdk:organization");
|
|
5411
5724
|
var OrganizationService2 = class extends BaseSDK {
|
|
5412
5725
|
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5413
5726
|
super(options, sharedHeaders, sharedTokenState);
|
|
@@ -5455,12 +5768,12 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5455
5768
|
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5456
5769
|
const locale = params.locale || this.defaultLocale;
|
|
5457
5770
|
const queryString = this.buildQueryString({ locale });
|
|
5458
|
-
|
|
5771
|
+
log31("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5459
5772
|
const result = await this.request(
|
|
5460
5773
|
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5461
5774
|
options
|
|
5462
5775
|
);
|
|
5463
|
-
|
|
5776
|
+
log31("Organization info retrieved for: %s", idOrNamespace);
|
|
5464
5777
|
return result;
|
|
5465
5778
|
}
|
|
5466
5779
|
/**
|
|
@@ -5470,7 +5783,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5470
5783
|
* @returns Promise resolving to the user's organizations
|
|
5471
5784
|
*/
|
|
5472
5785
|
async listMyOrganizations(options) {
|
|
5473
|
-
|
|
5786
|
+
log31("Listing organizations for current user");
|
|
5474
5787
|
const result = await this.request(
|
|
5475
5788
|
"/v1/organizations/me",
|
|
5476
5789
|
options
|
|
@@ -5488,7 +5801,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5488
5801
|
* @returns The created/existing organization and whether it was newly created
|
|
5489
5802
|
*/
|
|
5490
5803
|
async createOrganization(data, options) {
|
|
5491
|
-
|
|
5804
|
+
log31("Creating organization: %s", data.clerkId);
|
|
5492
5805
|
return this.request("/v1/organizations", {
|
|
5493
5806
|
...options,
|
|
5494
5807
|
body: JSON.stringify(data),
|
|
@@ -5503,7 +5816,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5503
5816
|
* @returns The updated organization
|
|
5504
5817
|
*/
|
|
5505
5818
|
async updateOrganization(orgId, data, options) {
|
|
5506
|
-
|
|
5819
|
+
log31("Updating organization %d: %O", orgId, data);
|
|
5507
5820
|
const result = await this.request(
|
|
5508
5821
|
`/v1/organizations/${orgRefToPathSegment(orgId)}`,
|
|
5509
5822
|
{
|
|
@@ -5522,7 +5835,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5522
5835
|
* @returns The archived organization
|
|
5523
5836
|
*/
|
|
5524
5837
|
async archiveOrganization(orgId, options) {
|
|
5525
|
-
|
|
5838
|
+
log31("Archiving organization %d", orgId);
|
|
5526
5839
|
const result = await this.request(
|
|
5527
5840
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/archive`,
|
|
5528
5841
|
{ ...options, method: "POST" }
|
|
@@ -5536,7 +5849,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5536
5849
|
* @returns The reactivated organization
|
|
5537
5850
|
*/
|
|
5538
5851
|
async unarchiveOrganization(orgId, options) {
|
|
5539
|
-
|
|
5852
|
+
log31("Unarchiving organization %d", orgId);
|
|
5540
5853
|
const result = await this.request(
|
|
5541
5854
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/unarchive`,
|
|
5542
5855
|
{ ...options, method: "POST" }
|
|
@@ -5550,7 +5863,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5550
5863
|
* @returns Hydrated member rows
|
|
5551
5864
|
*/
|
|
5552
5865
|
async listMembers(orgId, options) {
|
|
5553
|
-
|
|
5866
|
+
log31("Listing members of organization %d", orgId);
|
|
5554
5867
|
const result = await this.request(
|
|
5555
5868
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5556
5869
|
options
|
|
@@ -5567,7 +5880,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5567
5880
|
* @returns Whether the member was newly added and their effective role
|
|
5568
5881
|
*/
|
|
5569
5882
|
async addMember(orgId, userAccountId, role, options) {
|
|
5570
|
-
|
|
5883
|
+
log31("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
5571
5884
|
return this.request(
|
|
5572
5885
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5573
5886
|
{
|
|
@@ -5586,7 +5899,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5586
5899
|
* @returns Whether a membership row was removed
|
|
5587
5900
|
*/
|
|
5588
5901
|
async removeMember(orgId, userAccountId, options) {
|
|
5589
|
-
|
|
5902
|
+
log31("Removing member %d from organization %d", userAccountId, orgId);
|
|
5590
5903
|
return this.request(
|
|
5591
5904
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5592
5905
|
{ ...options, method: "DELETE" }
|
|
@@ -5602,7 +5915,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5602
5915
|
* @returns The effective role and whether it changed
|
|
5603
5916
|
*/
|
|
5604
5917
|
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
5605
|
-
|
|
5918
|
+
log31("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
5606
5919
|
return this.request(
|
|
5607
5920
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members/${userAccountId}`,
|
|
5608
5921
|
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
@@ -5620,7 +5933,7 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5620
5933
|
* @returns Counts of added / removed / updated members and skipped ids
|
|
5621
5934
|
*/
|
|
5622
5935
|
async reconcileMembers(orgId, members, options) {
|
|
5623
|
-
|
|
5936
|
+
log31("Reconciling %d members for organization %d", members.length, orgId);
|
|
5624
5937
|
return this.request(
|
|
5625
5938
|
`/v1/organizations/${orgRefToPathSegment(orgId)}/members`,
|
|
5626
5939
|
{
|
|
@@ -5633,8 +5946,8 @@ var OrganizationService2 = class extends BaseSDK {
|
|
|
5633
5946
|
};
|
|
5634
5947
|
|
|
5635
5948
|
// src/market/services/UserService.ts
|
|
5636
|
-
import
|
|
5637
|
-
var
|
|
5949
|
+
import debug32 from "debug";
|
|
5950
|
+
var log32 = debug32("lobe-market-sdk:user");
|
|
5638
5951
|
var UserService = class extends BaseSDK {
|
|
5639
5952
|
/**
|
|
5640
5953
|
* Retrieves user information by account ID or userName
|
|
@@ -5651,12 +5964,12 @@ var UserService = class extends BaseSDK {
|
|
|
5651
5964
|
const locale = params.locale || this.defaultLocale;
|
|
5652
5965
|
const queryParams = { locale };
|
|
5653
5966
|
const queryString = this.buildQueryString(queryParams);
|
|
5654
|
-
|
|
5967
|
+
log32("Getting user info: %O", { idOrUserName, ...params });
|
|
5655
5968
|
const result = await this.request(
|
|
5656
5969
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
5657
5970
|
options
|
|
5658
5971
|
);
|
|
5659
|
-
|
|
5972
|
+
log32("User info successfully retrieved for: %s", idOrUserName);
|
|
5660
5973
|
return result;
|
|
5661
5974
|
}
|
|
5662
5975
|
/**
|
|
@@ -5671,7 +5984,7 @@ var UserService = class extends BaseSDK {
|
|
|
5671
5984
|
* @throws Error if userName is already taken or update fails
|
|
5672
5985
|
*/
|
|
5673
5986
|
async updateUserInfo(data, options) {
|
|
5674
|
-
|
|
5987
|
+
log32("Updating user info: %O", data);
|
|
5675
5988
|
const result = await this.request("/v1/user/update", {
|
|
5676
5989
|
body: JSON.stringify(data),
|
|
5677
5990
|
headers: {
|
|
@@ -5680,7 +5993,7 @@ var UserService = class extends BaseSDK {
|
|
|
5680
5993
|
method: "POST",
|
|
5681
5994
|
...options
|
|
5682
5995
|
});
|
|
5683
|
-
|
|
5996
|
+
log32("User info updated successfully");
|
|
5684
5997
|
return result;
|
|
5685
5998
|
}
|
|
5686
5999
|
/**
|
|
@@ -5710,7 +6023,7 @@ var UserService = class extends BaseSDK {
|
|
|
5710
6023
|
* ```
|
|
5711
6024
|
*/
|
|
5712
6025
|
async register(data, options) {
|
|
5713
|
-
|
|
6026
|
+
log32("Registering user: %O", {
|
|
5714
6027
|
followUserId: data.followUserId,
|
|
5715
6028
|
registerUserId: data.registerUserId
|
|
5716
6029
|
});
|
|
@@ -5722,14 +6035,14 @@ var UserService = class extends BaseSDK {
|
|
|
5722
6035
|
method: "POST",
|
|
5723
6036
|
...options
|
|
5724
6037
|
});
|
|
5725
|
-
|
|
6038
|
+
log32("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
5726
6039
|
return result;
|
|
5727
6040
|
}
|
|
5728
6041
|
};
|
|
5729
6042
|
|
|
5730
6043
|
// src/market/services/UserFollowService.ts
|
|
5731
|
-
import
|
|
5732
|
-
var
|
|
6044
|
+
import debug33 from "debug";
|
|
6045
|
+
var log33 = debug33("lobe-market-sdk:user-follow");
|
|
5733
6046
|
var UserFollowService = class extends BaseSDK {
|
|
5734
6047
|
/**
|
|
5735
6048
|
* Follow a user
|
|
@@ -5743,7 +6056,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5743
6056
|
* @throws Error if already following or cannot follow yourself
|
|
5744
6057
|
*/
|
|
5745
6058
|
async follow(followingId, options) {
|
|
5746
|
-
|
|
6059
|
+
log33("Following user: %d", followingId);
|
|
5747
6060
|
const body = { followingId };
|
|
5748
6061
|
const result = await this.request("/v1/user/follows", {
|
|
5749
6062
|
body: JSON.stringify(body),
|
|
@@ -5753,7 +6066,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5753
6066
|
method: "POST",
|
|
5754
6067
|
...options
|
|
5755
6068
|
});
|
|
5756
|
-
|
|
6069
|
+
log33("Successfully followed user: %d", followingId);
|
|
5757
6070
|
return result;
|
|
5758
6071
|
}
|
|
5759
6072
|
/**
|
|
@@ -5768,7 +6081,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5768
6081
|
* @throws Error if follow relationship not found
|
|
5769
6082
|
*/
|
|
5770
6083
|
async unfollow(followingId, options) {
|
|
5771
|
-
|
|
6084
|
+
log33("Unfollowing user: %d", followingId);
|
|
5772
6085
|
const body = { followingId };
|
|
5773
6086
|
const result = await this.request("/v1/user/follows", {
|
|
5774
6087
|
body: JSON.stringify(body),
|
|
@@ -5778,7 +6091,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5778
6091
|
method: "DELETE",
|
|
5779
6092
|
...options
|
|
5780
6093
|
});
|
|
5781
|
-
|
|
6094
|
+
log33("Successfully unfollowed user: %d", followingId);
|
|
5782
6095
|
return result;
|
|
5783
6096
|
}
|
|
5784
6097
|
/**
|
|
@@ -5792,13 +6105,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5792
6105
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
5793
6106
|
*/
|
|
5794
6107
|
async checkFollowStatus(targetUserId, options) {
|
|
5795
|
-
|
|
6108
|
+
log33("Checking follow status for user: %d", targetUserId);
|
|
5796
6109
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
5797
6110
|
const result = await this.request(
|
|
5798
6111
|
`/v1/user/follows/check${queryString}`,
|
|
5799
6112
|
options
|
|
5800
6113
|
);
|
|
5801
|
-
|
|
6114
|
+
log33("Follow status retrieved: %O", result);
|
|
5802
6115
|
return result;
|
|
5803
6116
|
}
|
|
5804
6117
|
/**
|
|
@@ -5813,7 +6126,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5813
6126
|
* @returns Promise resolving to list of following users
|
|
5814
6127
|
*/
|
|
5815
6128
|
async getFollowing(userId, params = {}, options) {
|
|
5816
|
-
|
|
6129
|
+
log33("Getting following list for user: %d", userId);
|
|
5817
6130
|
const queryParams = {};
|
|
5818
6131
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5819
6132
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5822,7 +6135,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5822
6135
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
5823
6136
|
options
|
|
5824
6137
|
);
|
|
5825
|
-
|
|
6138
|
+
log33("Following list retrieved for user: %d", userId);
|
|
5826
6139
|
return result;
|
|
5827
6140
|
}
|
|
5828
6141
|
/**
|
|
@@ -5837,7 +6150,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5837
6150
|
* @returns Promise resolving to list of followers
|
|
5838
6151
|
*/
|
|
5839
6152
|
async getFollowers(userId, params = {}, options) {
|
|
5840
|
-
|
|
6153
|
+
log33("Getting followers list for user: %d", userId);
|
|
5841
6154
|
const queryParams = {};
|
|
5842
6155
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5843
6156
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5846,14 +6159,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5846
6159
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
5847
6160
|
options
|
|
5848
6161
|
);
|
|
5849
|
-
|
|
6162
|
+
log33("Followers list retrieved for user: %d", userId);
|
|
5850
6163
|
return result;
|
|
5851
6164
|
}
|
|
5852
6165
|
};
|
|
5853
6166
|
|
|
5854
6167
|
// src/market/services/UserFavoriteService.ts
|
|
5855
|
-
import
|
|
5856
|
-
var
|
|
6168
|
+
import debug34 from "debug";
|
|
6169
|
+
var log34 = debug34("lobe-market-sdk:user-favorite");
|
|
5857
6170
|
var UserFavoriteService = class extends BaseSDK {
|
|
5858
6171
|
/**
|
|
5859
6172
|
* Add to favorites
|
|
@@ -5868,7 +6181,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5868
6181
|
* @throws Error if already in favorites
|
|
5869
6182
|
*/
|
|
5870
6183
|
async addFavorite(targetType, targetId, options) {
|
|
5871
|
-
|
|
6184
|
+
log34("Adding favorite: %s %d", targetType, targetId);
|
|
5872
6185
|
const body = { targetId, targetType };
|
|
5873
6186
|
const result = await this.request("/v1/user/favorites", {
|
|
5874
6187
|
body: JSON.stringify(body),
|
|
@@ -5878,7 +6191,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5878
6191
|
method: "POST",
|
|
5879
6192
|
...options
|
|
5880
6193
|
});
|
|
5881
|
-
|
|
6194
|
+
log34("Successfully added favorite: %s %d", targetType, targetId);
|
|
5882
6195
|
return result;
|
|
5883
6196
|
}
|
|
5884
6197
|
/**
|
|
@@ -5894,7 +6207,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5894
6207
|
* @throws Error if favorite not found
|
|
5895
6208
|
*/
|
|
5896
6209
|
async removeFavorite(targetType, targetId, options) {
|
|
5897
|
-
|
|
6210
|
+
log34("Removing favorite: %s %d", targetType, targetId);
|
|
5898
6211
|
const body = { targetId, targetType };
|
|
5899
6212
|
const result = await this.request("/v1/user/favorites", {
|
|
5900
6213
|
body: JSON.stringify(body),
|
|
@@ -5904,7 +6217,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5904
6217
|
method: "DELETE",
|
|
5905
6218
|
...options
|
|
5906
6219
|
});
|
|
5907
|
-
|
|
6220
|
+
log34("Successfully removed favorite: %s %d", targetType, targetId);
|
|
5908
6221
|
return result;
|
|
5909
6222
|
}
|
|
5910
6223
|
/**
|
|
@@ -5919,7 +6232,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5919
6232
|
* @returns Promise resolving to favorite status
|
|
5920
6233
|
*/
|
|
5921
6234
|
async checkFavorite(targetType, targetId, options) {
|
|
5922
|
-
|
|
6235
|
+
log34("Checking favorite status: %s %d", targetType, targetId);
|
|
5923
6236
|
const queryString = this.buildQueryString({
|
|
5924
6237
|
targetId: String(targetId),
|
|
5925
6238
|
targetType
|
|
@@ -5928,7 +6241,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5928
6241
|
`/v1/user/favorites/check${queryString}`,
|
|
5929
6242
|
options
|
|
5930
6243
|
);
|
|
5931
|
-
|
|
6244
|
+
log34("Favorite status retrieved: %O", result);
|
|
5932
6245
|
return result;
|
|
5933
6246
|
}
|
|
5934
6247
|
/**
|
|
@@ -5942,7 +6255,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5942
6255
|
* @returns Promise resolving to list of favorites
|
|
5943
6256
|
*/
|
|
5944
6257
|
async getMyFavorites(params = {}, options) {
|
|
5945
|
-
|
|
6258
|
+
log34("Getting my favorites: %O", params);
|
|
5946
6259
|
const queryParams = {};
|
|
5947
6260
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5948
6261
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5952,7 +6265,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5952
6265
|
`/v1/user/favorites/me${queryString}`,
|
|
5953
6266
|
options
|
|
5954
6267
|
);
|
|
5955
|
-
|
|
6268
|
+
log34("My favorites retrieved");
|
|
5956
6269
|
return result;
|
|
5957
6270
|
}
|
|
5958
6271
|
/**
|
|
@@ -5967,7 +6280,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5967
6280
|
* @returns Promise resolving to list of favorites
|
|
5968
6281
|
*/
|
|
5969
6282
|
async getUserFavorites(userId, params = {}, options) {
|
|
5970
|
-
|
|
6283
|
+
log34("Getting favorites for user: %d", userId);
|
|
5971
6284
|
const queryParams = {};
|
|
5972
6285
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5973
6286
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5977,7 +6290,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5977
6290
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
5978
6291
|
options
|
|
5979
6292
|
);
|
|
5980
|
-
|
|
6293
|
+
log34("Favorites retrieved for user: %d", userId);
|
|
5981
6294
|
return result;
|
|
5982
6295
|
}
|
|
5983
6296
|
/**
|
|
@@ -5992,7 +6305,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5992
6305
|
* @returns Promise resolving to list of favorite agents
|
|
5993
6306
|
*/
|
|
5994
6307
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
5995
|
-
|
|
6308
|
+
log34("Getting favorite agents for user: %d", userId);
|
|
5996
6309
|
const queryParams = {};
|
|
5997
6310
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5998
6311
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6001,7 +6314,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6001
6314
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
6002
6315
|
options
|
|
6003
6316
|
);
|
|
6004
|
-
|
|
6317
|
+
log34("Favorite agents retrieved for user: %d", userId);
|
|
6005
6318
|
return result;
|
|
6006
6319
|
}
|
|
6007
6320
|
/**
|
|
@@ -6016,7 +6329,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6016
6329
|
* @returns Promise resolving to list of favorite plugins
|
|
6017
6330
|
*/
|
|
6018
6331
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
6019
|
-
|
|
6332
|
+
log34("Getting favorite plugins for user: %d", userId);
|
|
6020
6333
|
const queryParams = {};
|
|
6021
6334
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6022
6335
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6025,14 +6338,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
6025
6338
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
6026
6339
|
options
|
|
6027
6340
|
);
|
|
6028
|
-
|
|
6341
|
+
log34("Favorite plugins retrieved for user: %d", userId);
|
|
6029
6342
|
return result;
|
|
6030
6343
|
}
|
|
6031
6344
|
};
|
|
6032
6345
|
|
|
6033
6346
|
// src/market/services/UserLikeService.ts
|
|
6034
|
-
import
|
|
6035
|
-
var
|
|
6347
|
+
import debug35 from "debug";
|
|
6348
|
+
var log35 = debug35("lobe-market-sdk:user-like");
|
|
6036
6349
|
var UserLikeService = class extends BaseSDK {
|
|
6037
6350
|
/**
|
|
6038
6351
|
* Like content
|
|
@@ -6047,7 +6360,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6047
6360
|
* @throws Error if already liked
|
|
6048
6361
|
*/
|
|
6049
6362
|
async like(targetType, targetId, options) {
|
|
6050
|
-
|
|
6363
|
+
log35("Liking: %s %d", targetType, targetId);
|
|
6051
6364
|
const body = { targetId, targetType };
|
|
6052
6365
|
const result = await this.request("/v1/user/likes", {
|
|
6053
6366
|
body: JSON.stringify(body),
|
|
@@ -6057,7 +6370,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6057
6370
|
method: "POST",
|
|
6058
6371
|
...options
|
|
6059
6372
|
});
|
|
6060
|
-
|
|
6373
|
+
log35("Successfully liked: %s %d", targetType, targetId);
|
|
6061
6374
|
return result;
|
|
6062
6375
|
}
|
|
6063
6376
|
/**
|
|
@@ -6073,7 +6386,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6073
6386
|
* @throws Error if like not found
|
|
6074
6387
|
*/
|
|
6075
6388
|
async unlike(targetType, targetId, options) {
|
|
6076
|
-
|
|
6389
|
+
log35("Unliking: %s %d", targetType, targetId);
|
|
6077
6390
|
const body = { targetId, targetType };
|
|
6078
6391
|
const result = await this.request("/v1/user/likes", {
|
|
6079
6392
|
body: JSON.stringify(body),
|
|
@@ -6083,7 +6396,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6083
6396
|
method: "DELETE",
|
|
6084
6397
|
...options
|
|
6085
6398
|
});
|
|
6086
|
-
|
|
6399
|
+
log35("Successfully unliked: %s %d", targetType, targetId);
|
|
6087
6400
|
return result;
|
|
6088
6401
|
}
|
|
6089
6402
|
/**
|
|
@@ -6098,7 +6411,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6098
6411
|
* @returns Promise resolving to toggle response with new like status
|
|
6099
6412
|
*/
|
|
6100
6413
|
async toggleLike(targetType, targetId, options) {
|
|
6101
|
-
|
|
6414
|
+
log35("Toggling like: %s %d", targetType, targetId);
|
|
6102
6415
|
const body = { targetId, targetType };
|
|
6103
6416
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
6104
6417
|
body: JSON.stringify(body),
|
|
@@ -6108,7 +6421,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6108
6421
|
method: "POST",
|
|
6109
6422
|
...options
|
|
6110
6423
|
});
|
|
6111
|
-
|
|
6424
|
+
log35("Like toggled, new status: %O", result);
|
|
6112
6425
|
return result;
|
|
6113
6426
|
}
|
|
6114
6427
|
/**
|
|
@@ -6123,7 +6436,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6123
6436
|
* @returns Promise resolving to like status
|
|
6124
6437
|
*/
|
|
6125
6438
|
async checkLike(targetType, targetId, options) {
|
|
6126
|
-
|
|
6439
|
+
log35("Checking like status: %s %d", targetType, targetId);
|
|
6127
6440
|
const queryString = this.buildQueryString({
|
|
6128
6441
|
targetId: String(targetId),
|
|
6129
6442
|
targetType
|
|
@@ -6132,7 +6445,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6132
6445
|
`/v1/user/likes/check${queryString}`,
|
|
6133
6446
|
options
|
|
6134
6447
|
);
|
|
6135
|
-
|
|
6448
|
+
log35("Like status retrieved: %O", result);
|
|
6136
6449
|
return result;
|
|
6137
6450
|
}
|
|
6138
6451
|
/**
|
|
@@ -6146,7 +6459,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6146
6459
|
* @returns Promise resolving to list of likes
|
|
6147
6460
|
*/
|
|
6148
6461
|
async getMyLikes(params = {}, options) {
|
|
6149
|
-
|
|
6462
|
+
log35("Getting my likes: %O", params);
|
|
6150
6463
|
const queryParams = {};
|
|
6151
6464
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6152
6465
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6156,7 +6469,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6156
6469
|
`/v1/user/likes/me${queryString}`,
|
|
6157
6470
|
options
|
|
6158
6471
|
);
|
|
6159
|
-
|
|
6472
|
+
log35("My likes retrieved");
|
|
6160
6473
|
return result;
|
|
6161
6474
|
}
|
|
6162
6475
|
/**
|
|
@@ -6171,7 +6484,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6171
6484
|
* @returns Promise resolving to list of likes
|
|
6172
6485
|
*/
|
|
6173
6486
|
async getUserLikes(userId, params = {}, options) {
|
|
6174
|
-
|
|
6487
|
+
log35("Getting likes for user: %d", userId);
|
|
6175
6488
|
const queryParams = {};
|
|
6176
6489
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6177
6490
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6181,7 +6494,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6181
6494
|
`/v1/user/likes/${userId}${queryString}`,
|
|
6182
6495
|
options
|
|
6183
6496
|
);
|
|
6184
|
-
|
|
6497
|
+
log35("Likes retrieved for user: %d", userId);
|
|
6185
6498
|
return result;
|
|
6186
6499
|
}
|
|
6187
6500
|
/**
|
|
@@ -6196,7 +6509,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6196
6509
|
* @returns Promise resolving to list of liked agents
|
|
6197
6510
|
*/
|
|
6198
6511
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
6199
|
-
|
|
6512
|
+
log35("Getting liked agents for user: %d", userId);
|
|
6200
6513
|
const queryParams = {};
|
|
6201
6514
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6202
6515
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6205,7 +6518,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6205
6518
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
6206
6519
|
options
|
|
6207
6520
|
);
|
|
6208
|
-
|
|
6521
|
+
log35("Liked agents retrieved for user: %d", userId);
|
|
6209
6522
|
return result;
|
|
6210
6523
|
}
|
|
6211
6524
|
/**
|
|
@@ -6220,7 +6533,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6220
6533
|
* @returns Promise resolving to list of liked plugins
|
|
6221
6534
|
*/
|
|
6222
6535
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
6223
|
-
|
|
6536
|
+
log35("Getting liked plugins for user: %d", userId);
|
|
6224
6537
|
const queryParams = {};
|
|
6225
6538
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
6226
6539
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -6229,14 +6542,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
6229
6542
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
6230
6543
|
options
|
|
6231
6544
|
);
|
|
6232
|
-
|
|
6545
|
+
log35("Liked plugins retrieved for user: %d", userId);
|
|
6233
6546
|
return result;
|
|
6234
6547
|
}
|
|
6235
6548
|
};
|
|
6236
6549
|
|
|
6237
6550
|
// src/market/services/UserPublishService.ts
|
|
6238
|
-
import
|
|
6239
|
-
var
|
|
6551
|
+
import debug36 from "debug";
|
|
6552
|
+
var log36 = debug36("lobe-market-sdk:user-publish");
|
|
6240
6553
|
var UserPublishService = class extends BaseSDK {
|
|
6241
6554
|
/**
|
|
6242
6555
|
* Lists all plugins owned by the authenticated user
|
|
@@ -6246,9 +6559,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6246
6559
|
*/
|
|
6247
6560
|
async listPlugins(options) {
|
|
6248
6561
|
var _a;
|
|
6249
|
-
|
|
6562
|
+
log36("Listing user plugins");
|
|
6250
6563
|
const result = await this.request("/v1/user/plugins", options);
|
|
6251
|
-
|
|
6564
|
+
log36("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6252
6565
|
return result;
|
|
6253
6566
|
}
|
|
6254
6567
|
/**
|
|
@@ -6259,9 +6572,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6259
6572
|
*/
|
|
6260
6573
|
async listSkills(options) {
|
|
6261
6574
|
var _a;
|
|
6262
|
-
|
|
6575
|
+
log36("Listing user skills");
|
|
6263
6576
|
const result = await this.request("/v1/user/skills", options);
|
|
6264
|
-
|
|
6577
|
+
log36("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
6265
6578
|
return result;
|
|
6266
6579
|
}
|
|
6267
6580
|
/**
|
|
@@ -6273,7 +6586,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6273
6586
|
* @returns Promise resolving to the publish result
|
|
6274
6587
|
*/
|
|
6275
6588
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
6276
|
-
|
|
6589
|
+
log36("Publishing skill version for: %s", identifier);
|
|
6277
6590
|
const formData = new FormData();
|
|
6278
6591
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
6279
6592
|
zipBuffer.byteOffset,
|
|
@@ -6289,7 +6602,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6289
6602
|
...options
|
|
6290
6603
|
}
|
|
6291
6604
|
);
|
|
6292
|
-
|
|
6605
|
+
log36("Published skill version: %s@%s", identifier, result.version);
|
|
6293
6606
|
return result;
|
|
6294
6607
|
}
|
|
6295
6608
|
/**
|
|
@@ -6300,11 +6613,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6300
6613
|
*/
|
|
6301
6614
|
async scanClaimableAssets(assetType) {
|
|
6302
6615
|
var _a;
|
|
6303
|
-
|
|
6616
|
+
log36("Scanning claimable %s", assetType);
|
|
6304
6617
|
const result = await this.request(
|
|
6305
6618
|
`/v1/user/claims/scan/${assetType}`
|
|
6306
6619
|
);
|
|
6307
|
-
|
|
6620
|
+
log36("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
6308
6621
|
return result;
|
|
6309
6622
|
}
|
|
6310
6623
|
/**
|
|
@@ -6315,13 +6628,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6315
6628
|
* @returns Promise resolving to the claim result
|
|
6316
6629
|
*/
|
|
6317
6630
|
async claimAsset(assetId, assetType) {
|
|
6318
|
-
|
|
6631
|
+
log36("Claiming %s with id: %d", assetType, assetId);
|
|
6319
6632
|
const result = await this.request("/v1/user/claims", {
|
|
6320
6633
|
body: JSON.stringify({ assetId, assetType }),
|
|
6321
6634
|
headers: { "Content-Type": "application/json" },
|
|
6322
6635
|
method: "POST"
|
|
6323
6636
|
});
|
|
6324
|
-
|
|
6637
|
+
log36("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
6325
6638
|
return result;
|
|
6326
6639
|
}
|
|
6327
6640
|
/**
|
|
@@ -6335,13 +6648,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6335
6648
|
* @returns Promise resolving to the claim result
|
|
6336
6649
|
*/
|
|
6337
6650
|
async claimAssetByIdentifier(identifier, assetType) {
|
|
6338
|
-
|
|
6651
|
+
log36("Claiming %s with identifier: %s", assetType, identifier);
|
|
6339
6652
|
const result = await this.request("/v1/user/claims", {
|
|
6340
6653
|
body: JSON.stringify({ assetType, identifier }),
|
|
6341
6654
|
headers: { "Content-Type": "application/json" },
|
|
6342
6655
|
method: "POST"
|
|
6343
6656
|
});
|
|
6344
|
-
|
|
6657
|
+
log36("Claim result for %s %s: %s", assetType, identifier, result.success);
|
|
6345
6658
|
return result;
|
|
6346
6659
|
}
|
|
6347
6660
|
/**
|
|
@@ -6356,14 +6669,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6356
6669
|
* @returns Promise resolving to the submission result
|
|
6357
6670
|
*/
|
|
6358
6671
|
async submitRepo(params, options) {
|
|
6359
|
-
|
|
6672
|
+
log36("Submitting repository for import: %s (%s)", params.gitUrl, params.type);
|
|
6360
6673
|
const result = await this.request("/v1/user/claims/submit-repo", {
|
|
6361
6674
|
body: JSON.stringify(params),
|
|
6362
6675
|
headers: { "Content-Type": "application/json" },
|
|
6363
6676
|
method: "POST",
|
|
6364
6677
|
...options
|
|
6365
6678
|
});
|
|
6366
|
-
|
|
6679
|
+
log36("Submit result for %s: %s", params.gitUrl, result.success);
|
|
6367
6680
|
return result;
|
|
6368
6681
|
}
|
|
6369
6682
|
/**
|
|
@@ -6374,14 +6687,14 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6374
6687
|
* @returns Promise resolving immediately with the plugin identifier and version
|
|
6375
6688
|
*/
|
|
6376
6689
|
async publishPlugin(params, options) {
|
|
6377
|
-
|
|
6690
|
+
log36("Publishing plugin: %s@%s", params.identifier, params.version);
|
|
6378
6691
|
const result = await this.request("/v1/user/plugins", {
|
|
6379
6692
|
body: JSON.stringify(params),
|
|
6380
6693
|
headers: { "Content-Type": "application/json" },
|
|
6381
6694
|
method: "POST",
|
|
6382
6695
|
...options
|
|
6383
6696
|
});
|
|
6384
|
-
|
|
6697
|
+
log36("Published plugin: %s@%s (%s)", result.identifier, result.version, result.status);
|
|
6385
6698
|
return result;
|
|
6386
6699
|
}
|
|
6387
6700
|
/**
|
|
@@ -6392,12 +6705,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6392
6705
|
* @returns Promise resolving to the delete result
|
|
6393
6706
|
*/
|
|
6394
6707
|
async deleteSkill(identifier, options) {
|
|
6395
|
-
|
|
6708
|
+
log36("Deleting skill: %s", identifier);
|
|
6396
6709
|
const result = await this.request(
|
|
6397
6710
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
6398
6711
|
{ method: "DELETE", ...options }
|
|
6399
6712
|
);
|
|
6400
|
-
|
|
6713
|
+
log36("Deleted skill: %s", identifier);
|
|
6401
6714
|
return result;
|
|
6402
6715
|
}
|
|
6403
6716
|
/**
|
|
@@ -6409,7 +6722,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6409
6722
|
* @returns Promise resolving to the updated status
|
|
6410
6723
|
*/
|
|
6411
6724
|
async updateSkillStatus(identifier, status, options) {
|
|
6412
|
-
|
|
6725
|
+
log36("Updating skill status: %s \u2192 %s", identifier, status);
|
|
6413
6726
|
const result = await this.request(
|
|
6414
6727
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
6415
6728
|
{
|
|
@@ -6419,7 +6732,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6419
6732
|
...options
|
|
6420
6733
|
}
|
|
6421
6734
|
);
|
|
6422
|
-
|
|
6735
|
+
log36("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
6423
6736
|
return result;
|
|
6424
6737
|
}
|
|
6425
6738
|
/**
|
|
@@ -6430,12 +6743,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6430
6743
|
* @returns Promise resolving to the delete result
|
|
6431
6744
|
*/
|
|
6432
6745
|
async deletePlugin(identifier, options) {
|
|
6433
|
-
|
|
6746
|
+
log36("Deleting plugin: %s", identifier);
|
|
6434
6747
|
const result = await this.request(
|
|
6435
6748
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
6436
6749
|
{ method: "DELETE", ...options }
|
|
6437
6750
|
);
|
|
6438
|
-
|
|
6751
|
+
log36("Deleted plugin: %s", identifier);
|
|
6439
6752
|
return result;
|
|
6440
6753
|
}
|
|
6441
6754
|
/**
|
|
@@ -6447,7 +6760,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6447
6760
|
* @returns Promise resolving to the updated status
|
|
6448
6761
|
*/
|
|
6449
6762
|
async updatePluginStatus(identifier, status, options) {
|
|
6450
|
-
|
|
6763
|
+
log36("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
6451
6764
|
const result = await this.request(
|
|
6452
6765
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
6453
6766
|
{
|
|
@@ -6457,7 +6770,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6457
6770
|
...options
|
|
6458
6771
|
}
|
|
6459
6772
|
);
|
|
6460
|
-
|
|
6773
|
+
log36("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
6461
6774
|
return result;
|
|
6462
6775
|
}
|
|
6463
6776
|
/**
|
|
@@ -6469,7 +6782,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6469
6782
|
* @returns Promise resolving to the publish result
|
|
6470
6783
|
*/
|
|
6471
6784
|
async publishPluginVersion(identifier, data, options) {
|
|
6472
|
-
|
|
6785
|
+
log36("Publishing plugin version for: %s", identifier);
|
|
6473
6786
|
const result = await this.request(
|
|
6474
6787
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
6475
6788
|
{
|
|
@@ -6479,7 +6792,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6479
6792
|
...options
|
|
6480
6793
|
}
|
|
6481
6794
|
);
|
|
6482
|
-
|
|
6795
|
+
log36("Published plugin version: %s@%s", identifier, result.version);
|
|
6483
6796
|
return result;
|
|
6484
6797
|
}
|
|
6485
6798
|
/**
|
|
@@ -6492,13 +6805,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6492
6805
|
*/
|
|
6493
6806
|
async getPluginLocalizations(identifier, version, options) {
|
|
6494
6807
|
var _a;
|
|
6495
|
-
|
|
6808
|
+
log36("Listing localizations for plugin: %s", identifier);
|
|
6496
6809
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6497
6810
|
const result = await this.request(
|
|
6498
6811
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations${query}`,
|
|
6499
6812
|
options
|
|
6500
6813
|
);
|
|
6501
|
-
|
|
6814
|
+
log36("Found %d localizations for %s", ((_a = result.localizations) == null ? void 0 : _a.length) || 0, identifier);
|
|
6502
6815
|
return result;
|
|
6503
6816
|
}
|
|
6504
6817
|
/**
|
|
@@ -6515,7 +6828,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6515
6828
|
* @returns Promise resolving to the upsert result
|
|
6516
6829
|
*/
|
|
6517
6830
|
async updatePluginLocalizations(identifier, localizations, version, options) {
|
|
6518
|
-
|
|
6831
|
+
log36("Upserting %d localization(s) for plugin: %s", localizations.length, identifier);
|
|
6519
6832
|
const result = await this.request(
|
|
6520
6833
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations`,
|
|
6521
6834
|
{
|
|
@@ -6525,7 +6838,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6525
6838
|
...options
|
|
6526
6839
|
}
|
|
6527
6840
|
);
|
|
6528
|
-
|
|
6841
|
+
log36("Upserted localizations for %s@%s", identifier, result.version);
|
|
6529
6842
|
return result;
|
|
6530
6843
|
}
|
|
6531
6844
|
/**
|
|
@@ -6539,20 +6852,40 @@ var UserPublishService = class extends BaseSDK {
|
|
|
6539
6852
|
* @returns Promise resolving to the delete result
|
|
6540
6853
|
*/
|
|
6541
6854
|
async deletePluginLocalization(identifier, locale, version, options) {
|
|
6542
|
-
|
|
6855
|
+
log36("Deleting localization %s for plugin: %s", locale, identifier);
|
|
6543
6856
|
const query = version ? `?version=${encodeURIComponent(version)}` : "";
|
|
6544
6857
|
const result = await this.request(
|
|
6545
6858
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/localizations/${encodeURIComponent(locale)}${query}`,
|
|
6546
6859
|
{ method: "DELETE", ...options }
|
|
6547
6860
|
);
|
|
6548
|
-
|
|
6861
|
+
log36("Deleted localization %s for %s", locale, identifier);
|
|
6549
6862
|
return result;
|
|
6550
6863
|
}
|
|
6551
6864
|
};
|
|
6552
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
|
+
|
|
6553
6878
|
// src/market/market-sdk.ts
|
|
6554
|
-
var
|
|
6879
|
+
var log38 = debug38("lobe-market-sdk");
|
|
6555
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
|
+
}
|
|
6556
6889
|
/**
|
|
6557
6890
|
* Creates a new MarketSDK instance
|
|
6558
6891
|
*
|
|
@@ -6564,8 +6897,9 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6564
6897
|
tokenExpiry: void 0
|
|
6565
6898
|
};
|
|
6566
6899
|
super(options, void 0, sharedTokenState);
|
|
6567
|
-
|
|
6900
|
+
log38("MarketSDK instance created");
|
|
6568
6901
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
6902
|
+
this.categories = new CategoryService2(options, this.headers, sharedTokenState);
|
|
6569
6903
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
6570
6904
|
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
6571
6905
|
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
@@ -6573,6 +6907,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6573
6907
|
this.creds = new CredService(options, this.headers, sharedTokenState);
|
|
6574
6908
|
this.deployments = new DeploymentService(options, this.headers, sharedTokenState);
|
|
6575
6909
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
6910
|
+
this.sandboxStorage = new SandboxStorageService2(options, this.headers, sharedTokenState);
|
|
6576
6911
|
this.organizations = new OrganizationService2(options, this.headers, sharedTokenState);
|
|
6577
6912
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
6578
6913
|
this.userPublish = new UserPublishService(options, this.headers, sharedTokenState);
|
|
@@ -6614,7 +6949,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
6614
6949
|
* @deprecated Use auth.registerClient() instead
|
|
6615
6950
|
*/
|
|
6616
6951
|
async registerClient(request) {
|
|
6617
|
-
|
|
6952
|
+
log38("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
6618
6953
|
return this.auth.registerClient(request);
|
|
6619
6954
|
}
|
|
6620
6955
|
};
|