@lobehub/market-sdk 0.28.3 → 0.28.4-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +850 -6
- package/dist/index.mjs +539 -145
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1606,7 +1606,7 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1606
1606
|
};
|
|
1607
1607
|
|
|
1608
1608
|
// src/market/market-sdk.ts
|
|
1609
|
-
import
|
|
1609
|
+
import debug22 from "debug";
|
|
1610
1610
|
|
|
1611
1611
|
// src/market/services/AgentService.ts
|
|
1612
1612
|
import debug10 from "debug";
|
|
@@ -1678,6 +1678,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1678
1678
|
/**
|
|
1679
1679
|
* Retrieves all published agent identifiers
|
|
1680
1680
|
*
|
|
1681
|
+
*
|
|
1681
1682
|
* Returns a lightweight list of all published agent identifiers without
|
|
1682
1683
|
* full agent metadata. This is useful for clients that need to know which
|
|
1683
1684
|
* agents are available without fetching complete agent information.
|
|
@@ -1960,12 +1961,401 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1960
1961
|
log10("Deprecating agent: %s", identifier);
|
|
1961
1962
|
return this.changeStatus(identifier, "deprecated", options);
|
|
1962
1963
|
}
|
|
1964
|
+
/**
|
|
1965
|
+
* Forks an existing agent to create a new agent owned by the current user
|
|
1966
|
+
*
|
|
1967
|
+
* Creates a complete copy of the agent including configuration, skills,
|
|
1968
|
+
* and version data. Statistical data (ratings, likes, etc.) are reset to zero.
|
|
1969
|
+
* Requires authentication.
|
|
1970
|
+
*
|
|
1971
|
+
* @param sourceIdentifier - Identifier of the agent to fork
|
|
1972
|
+
* @param forkData - Fork request parameters (new identifier, name, etc.)
|
|
1973
|
+
* @param options - Optional request options
|
|
1974
|
+
* @returns Promise resolving to the fork response with new agent details
|
|
1975
|
+
*/
|
|
1976
|
+
async forkAgent(sourceIdentifier, forkData, options) {
|
|
1977
|
+
log10("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
1978
|
+
const result = await this.request(
|
|
1979
|
+
`/v1/agents/${sourceIdentifier}/fork`,
|
|
1980
|
+
{
|
|
1981
|
+
body: JSON.stringify(forkData),
|
|
1982
|
+
headers: {
|
|
1983
|
+
"Content-Type": "application/json"
|
|
1984
|
+
},
|
|
1985
|
+
method: "POST",
|
|
1986
|
+
...options
|
|
1987
|
+
}
|
|
1988
|
+
);
|
|
1989
|
+
log10("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
1990
|
+
return result;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Retrieves all public forks of a specific agent
|
|
1994
|
+
*
|
|
1995
|
+
* Returns a list of agents that were forked from the specified agent.
|
|
1996
|
+
* Only returns forks that are public and published.
|
|
1997
|
+
*
|
|
1998
|
+
* @param identifier - Identifier of the source agent
|
|
1999
|
+
* @param options - Optional request options
|
|
2000
|
+
* @returns Promise resolving to the forks list response
|
|
2001
|
+
*/
|
|
2002
|
+
async getAgentForks(identifier, options) {
|
|
2003
|
+
log10("Getting forks for agent: %s", identifier);
|
|
2004
|
+
const result = await this.request(
|
|
2005
|
+
`/v1/agents/${identifier}/forks`,
|
|
2006
|
+
options
|
|
2007
|
+
);
|
|
2008
|
+
log10("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2009
|
+
return result;
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Retrieves the source agent that this agent was forked from
|
|
2013
|
+
*
|
|
2014
|
+
* Returns null if the agent is not a fork (original agent).
|
|
2015
|
+
*
|
|
2016
|
+
* @param identifier - Identifier of the agent to check
|
|
2017
|
+
* @param options - Optional request options
|
|
2018
|
+
* @returns Promise resolving to the fork source response
|
|
2019
|
+
*/
|
|
2020
|
+
async getAgentForkSource(identifier, options) {
|
|
2021
|
+
log10("Getting fork source for agent: %s", identifier);
|
|
2022
|
+
const result = await this.request(
|
|
2023
|
+
`/v1/agents/${identifier}/fork-source`,
|
|
2024
|
+
options
|
|
2025
|
+
);
|
|
2026
|
+
if (result.source) {
|
|
2027
|
+
log10("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2028
|
+
} else {
|
|
2029
|
+
log10("Agent %s is not a fork (original agent)", identifier);
|
|
2030
|
+
}
|
|
2031
|
+
return result;
|
|
2032
|
+
}
|
|
1963
2033
|
};
|
|
1964
2034
|
|
|
1965
|
-
// src/market/services/
|
|
2035
|
+
// src/market/services/AgentGroupService.ts
|
|
1966
2036
|
import debug11 from "debug";
|
|
2037
|
+
var log11 = debug11("lobe-market-sdk:agent-groups");
|
|
2038
|
+
var AgentGroupService = class extends BaseSDK {
|
|
2039
|
+
/**
|
|
2040
|
+
* Retrieves a list of agent groups from the marketplace
|
|
2041
|
+
*
|
|
2042
|
+
* Supports filtering, pagination, and localization of results.
|
|
2043
|
+
*
|
|
2044
|
+
* @param params - Query parameters for filtering and pagination
|
|
2045
|
+
* @param options - Optional request options
|
|
2046
|
+
* @returns Promise resolving to the agent group list response containing items and pagination info
|
|
2047
|
+
*/
|
|
2048
|
+
async getAgentGroupList(params = {}, options) {
|
|
2049
|
+
const locale = params.locale || this.defaultLocale;
|
|
2050
|
+
const queryParams = { ...params, locale };
|
|
2051
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2052
|
+
log11("Getting agent group list: %O", queryParams);
|
|
2053
|
+
const result = await this.request(
|
|
2054
|
+
`/v1/agent-groups${queryString}`,
|
|
2055
|
+
options
|
|
2056
|
+
);
|
|
2057
|
+
log11("Retrieved %d agent groups", result.items.length);
|
|
2058
|
+
return result;
|
|
2059
|
+
}
|
|
2060
|
+
/**
|
|
2061
|
+
* Retrieves a list of agent groups owned by the authenticated user
|
|
2062
|
+
*
|
|
2063
|
+
* Returns all agent groups regardless of their publish status (published, unpublished,
|
|
2064
|
+
* archived, deprecated). Requires authentication.
|
|
2065
|
+
*
|
|
2066
|
+
* @param params - Query parameters for filtering and pagination
|
|
2067
|
+
* @param options - Optional request options (must include authentication)
|
|
2068
|
+
* @returns Promise resolving to the agent group list response containing items with status field
|
|
2069
|
+
*/
|
|
2070
|
+
async getOwnAgentGroups(params = {}, options) {
|
|
2071
|
+
const locale = params.locale || this.defaultLocale;
|
|
2072
|
+
const queryParams = { ...params, locale };
|
|
2073
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2074
|
+
log11("Getting own agent group list: %O", queryParams);
|
|
2075
|
+
const result = await this.request(
|
|
2076
|
+
`/v1/agent-groups/own${queryString}`,
|
|
2077
|
+
options
|
|
2078
|
+
);
|
|
2079
|
+
log11("Retrieved %d own agent groups", result.items.length);
|
|
2080
|
+
return result;
|
|
2081
|
+
}
|
|
2082
|
+
/**
|
|
2083
|
+
* Retrieves detailed information about a specific agent group
|
|
2084
|
+
*
|
|
2085
|
+
* Returns complete agent group information including group metadata,
|
|
2086
|
+
* all member agents, and localized content.
|
|
2087
|
+
*
|
|
2088
|
+
* @param identifier - Unique identifier of the agent group
|
|
2089
|
+
* @param params - Query parameters for locale and version
|
|
2090
|
+
* @param options - Optional request options
|
|
2091
|
+
* @returns Promise resolving to the agent group detail information
|
|
2092
|
+
*/
|
|
2093
|
+
async getAgentGroupDetail(identifier, params = {}, options) {
|
|
2094
|
+
const locale = params.locale || this.defaultLocale;
|
|
2095
|
+
const queryParams = { identifier, locale };
|
|
2096
|
+
if (params.version !== void 0) {
|
|
2097
|
+
queryParams.version = params.version.toString();
|
|
2098
|
+
}
|
|
2099
|
+
const queryString = this.buildQueryString(queryParams);
|
|
2100
|
+
log11("Getting agent group detail: %O", { identifier, ...params });
|
|
2101
|
+
const result = await this.request(
|
|
2102
|
+
`/v1/agent-groups/detail${queryString}`,
|
|
2103
|
+
options
|
|
2104
|
+
);
|
|
2105
|
+
log11("Agent group detail successfully retrieved: %s", identifier);
|
|
2106
|
+
return result;
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Creates a new agent group in the marketplace
|
|
2110
|
+
*
|
|
2111
|
+
* Creates a new agent group with initial version (v1) and all member agents.
|
|
2112
|
+
* Requires authentication and ownership.
|
|
2113
|
+
*
|
|
2114
|
+
* @param groupData - The agent group data to create
|
|
2115
|
+
* @param options - Optional request options
|
|
2116
|
+
* @returns Promise resolving to the created agent group response
|
|
2117
|
+
*/
|
|
2118
|
+
async createAgentGroup(groupData, options) {
|
|
2119
|
+
log11("Creating agent group: %s", groupData.identifier);
|
|
2120
|
+
const result = await this.request("/v1/agent-groups/create", {
|
|
2121
|
+
body: JSON.stringify(groupData),
|
|
2122
|
+
headers: {
|
|
2123
|
+
"Content-Type": "application/json"
|
|
2124
|
+
},
|
|
2125
|
+
method: "POST",
|
|
2126
|
+
...options
|
|
2127
|
+
});
|
|
2128
|
+
log11("Agent group created successfully: %O", result);
|
|
2129
|
+
return result;
|
|
2130
|
+
}
|
|
2131
|
+
/**
|
|
2132
|
+
* Creates a new version for an existing agent group
|
|
2133
|
+
*
|
|
2134
|
+
* Creates a new version with unified version number for the group and all member agents.
|
|
2135
|
+
* Fields not provided will be inherited from the latest version.
|
|
2136
|
+
*
|
|
2137
|
+
* @param versionData - The version data to create
|
|
2138
|
+
* @param options - Optional request options
|
|
2139
|
+
* @returns Promise resolving to the created version response
|
|
2140
|
+
*/
|
|
2141
|
+
async createAgentGroupVersion(versionData, options) {
|
|
2142
|
+
log11("Creating agent group version: %s", versionData.identifier);
|
|
2143
|
+
const result = await this.request(
|
|
2144
|
+
"/v1/agent-groups/version-create",
|
|
2145
|
+
{
|
|
2146
|
+
body: JSON.stringify(versionData),
|
|
2147
|
+
headers: {
|
|
2148
|
+
"Content-Type": "application/json"
|
|
2149
|
+
},
|
|
2150
|
+
method: "POST",
|
|
2151
|
+
...options
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
log11("Agent group version created successfully: %O", result);
|
|
2155
|
+
return result;
|
|
2156
|
+
}
|
|
2157
|
+
/**
|
|
2158
|
+
* Modifies an existing agent group
|
|
2159
|
+
*
|
|
2160
|
+
* Updates the agent group's base information. Can be used to change status,
|
|
2161
|
+
* metadata, or other group properties. Only the owner can modify the group.
|
|
2162
|
+
*
|
|
2163
|
+
* @param groupData - The agent group data to modify
|
|
2164
|
+
* @param options - Optional request options
|
|
2165
|
+
* @returns Promise resolving to the modified agent group response
|
|
2166
|
+
*/
|
|
2167
|
+
async modifyAgentGroup(groupData, options) {
|
|
2168
|
+
log11("Modifying agent group: %s", groupData.identifier);
|
|
2169
|
+
const result = await this.request("/v1/agent-groups/modify", {
|
|
2170
|
+
body: JSON.stringify(groupData),
|
|
2171
|
+
headers: {
|
|
2172
|
+
"Content-Type": "application/json"
|
|
2173
|
+
},
|
|
2174
|
+
method: "POST",
|
|
2175
|
+
...options
|
|
2176
|
+
});
|
|
2177
|
+
log11("Agent group modified successfully: %O", result);
|
|
2178
|
+
return result;
|
|
2179
|
+
}
|
|
2180
|
+
/**
|
|
2181
|
+
* Checks if an agent group exists in the marketplace
|
|
2182
|
+
*
|
|
2183
|
+
* @param identifier - Unique identifier of the agent group
|
|
2184
|
+
* @param options - Optional request options
|
|
2185
|
+
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2186
|
+
*/
|
|
2187
|
+
async checkAgentGroupExists(identifier, options) {
|
|
2188
|
+
log11("Checking if agent group exists: %s", identifier);
|
|
2189
|
+
try {
|
|
2190
|
+
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2191
|
+
log11("Agent group exists: %s", identifier);
|
|
2192
|
+
return true;
|
|
2193
|
+
} catch (e) {
|
|
2194
|
+
log11("Agent group does not exist: %s", identifier);
|
|
2195
|
+
return false;
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Changes the status of an agent group
|
|
2200
|
+
*
|
|
2201
|
+
* Internal helper method used by publish/unpublish/archive/deprecate methods.
|
|
2202
|
+
* Requires authentication.
|
|
2203
|
+
*
|
|
2204
|
+
* @param identifier - Unique identifier of the agent group
|
|
2205
|
+
* @param status - New status to set
|
|
2206
|
+
* @param options - Optional request options
|
|
2207
|
+
* @returns Promise resolving to the status change response
|
|
2208
|
+
*/
|
|
2209
|
+
async changeStatus(identifier, status, options) {
|
|
2210
|
+
log11("Changing agent group status: %s -> %s", identifier, status);
|
|
2211
|
+
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2212
|
+
log11("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2213
|
+
return {
|
|
2214
|
+
identifier: result.identifier,
|
|
2215
|
+
status: result.status,
|
|
2216
|
+
success: true
|
|
2217
|
+
};
|
|
2218
|
+
}
|
|
2219
|
+
/**
|
|
2220
|
+
* Publishes an agent group to the marketplace
|
|
2221
|
+
*
|
|
2222
|
+
* Makes the agent group publicly visible and available for use.
|
|
2223
|
+
* Requires authentication and ownership of the agent group.
|
|
2224
|
+
* Only groups with "Safe" safety check status can be published.
|
|
2225
|
+
*
|
|
2226
|
+
* @param identifier - Unique identifier of the agent group
|
|
2227
|
+
* @param options - Optional request options
|
|
2228
|
+
* @returns Promise resolving to the status change response
|
|
2229
|
+
*/
|
|
2230
|
+
async publish(identifier, options) {
|
|
2231
|
+
log11("Publishing agent group: %s", identifier);
|
|
2232
|
+
return this.changeStatus(identifier, "published", options);
|
|
2233
|
+
}
|
|
2234
|
+
/**
|
|
2235
|
+
* Unpublishes an agent group from the marketplace
|
|
2236
|
+
*
|
|
2237
|
+
* Hides the agent group from public view. The agent group data is preserved
|
|
2238
|
+
* and can be republished later.
|
|
2239
|
+
* Requires authentication and ownership of the agent group.
|
|
2240
|
+
*
|
|
2241
|
+
* @param identifier - Unique identifier of the agent group
|
|
2242
|
+
* @param options - Optional request options
|
|
2243
|
+
* @returns Promise resolving to the status change response
|
|
2244
|
+
*/
|
|
2245
|
+
async unpublish(identifier, options) {
|
|
2246
|
+
log11("Unpublishing agent group: %s", identifier);
|
|
2247
|
+
return this.changeStatus(identifier, "unpublished", options);
|
|
2248
|
+
}
|
|
2249
|
+
/**
|
|
2250
|
+
* Archives an agent group
|
|
2251
|
+
*
|
|
2252
|
+
* Marks the agent group as archived. Archived agent groups are typically
|
|
2253
|
+
* no longer actively maintained but may still be accessible.
|
|
2254
|
+
* Requires authentication and ownership of the agent group.
|
|
2255
|
+
*
|
|
2256
|
+
* @param identifier - Unique identifier of the agent group
|
|
2257
|
+
* @param options - Optional request options
|
|
2258
|
+
* @returns Promise resolving to the status change response
|
|
2259
|
+
*/
|
|
2260
|
+
async archive(identifier, options) {
|
|
2261
|
+
log11("Archiving agent group: %s", identifier);
|
|
2262
|
+
return this.changeStatus(identifier, "archived", options);
|
|
2263
|
+
}
|
|
2264
|
+
/**
|
|
2265
|
+
* Deprecates an agent group
|
|
2266
|
+
*
|
|
2267
|
+
* Marks the agent group as deprecated. Deprecated agent groups are still
|
|
2268
|
+
* accessible but users are encouraged to migrate to alternatives.
|
|
2269
|
+
* Requires authentication and ownership of the agent group.
|
|
2270
|
+
*
|
|
2271
|
+
* @param identifier - Unique identifier of the agent group
|
|
2272
|
+
* @param options - Optional request options
|
|
2273
|
+
* @returns Promise resolving to the status change response
|
|
2274
|
+
*/
|
|
2275
|
+
async deprecate(identifier, options) {
|
|
2276
|
+
log11("Deprecating agent group: %s", identifier);
|
|
2277
|
+
return this.changeStatus(identifier, "deprecated", options);
|
|
2278
|
+
}
|
|
2279
|
+
/**
|
|
2280
|
+
* Forks an existing agent group to create a new group owned by the current user
|
|
2281
|
+
*
|
|
2282
|
+
* Creates a complete copy of the agent group including all member agents,
|
|
2283
|
+
* their configurations, and version data. Statistical data (ratings, likes, etc.)
|
|
2284
|
+
* are reset to zero. Requires authentication.
|
|
2285
|
+
*
|
|
2286
|
+
* @param sourceIdentifier - Identifier of the agent group to fork
|
|
2287
|
+
* @param forkData - Fork request parameters (new identifier, name, etc.)
|
|
2288
|
+
* @param options - Optional request options
|
|
2289
|
+
* @returns Promise resolving to the fork response with new group details
|
|
2290
|
+
*/
|
|
2291
|
+
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2292
|
+
log11("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2293
|
+
const result = await this.request(
|
|
2294
|
+
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2295
|
+
{
|
|
2296
|
+
body: JSON.stringify(forkData),
|
|
2297
|
+
headers: {
|
|
2298
|
+
"Content-Type": "application/json"
|
|
2299
|
+
},
|
|
2300
|
+
method: "POST",
|
|
2301
|
+
...options
|
|
2302
|
+
}
|
|
2303
|
+
);
|
|
2304
|
+
log11(
|
|
2305
|
+
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2306
|
+
result.group.identifier,
|
|
2307
|
+
result.group.id,
|
|
2308
|
+
result.memberAgents.length
|
|
2309
|
+
);
|
|
2310
|
+
return result;
|
|
2311
|
+
}
|
|
2312
|
+
/**
|
|
2313
|
+
* Retrieves all public forks of a specific agent group
|
|
2314
|
+
*
|
|
2315
|
+
* Returns a list of agent groups that were forked from the specified group.
|
|
2316
|
+
* Only returns forks that are public and published.
|
|
2317
|
+
*
|
|
2318
|
+
* @param identifier - Identifier of the source agent group
|
|
2319
|
+
* @param options - Optional request options
|
|
2320
|
+
* @returns Promise resolving to the forks list response
|
|
2321
|
+
*/
|
|
2322
|
+
async getAgentGroupForks(identifier, options) {
|
|
2323
|
+
log11("Getting forks for agent group: %s", identifier);
|
|
2324
|
+
const result = await this.request(
|
|
2325
|
+
`/v1/agent-groups/${identifier}/forks`,
|
|
2326
|
+
options
|
|
2327
|
+
);
|
|
2328
|
+
log11("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2329
|
+
return result;
|
|
2330
|
+
}
|
|
2331
|
+
/**
|
|
2332
|
+
* Retrieves the source agent group that this group was forked from
|
|
2333
|
+
*
|
|
2334
|
+
* Returns null if the agent group is not a fork (original group).
|
|
2335
|
+
*
|
|
2336
|
+
* @param identifier - Identifier of the agent group to check
|
|
2337
|
+
* @param options - Optional request options
|
|
2338
|
+
* @returns Promise resolving to the fork source response
|
|
2339
|
+
*/
|
|
2340
|
+
async getAgentGroupForkSource(identifier, options) {
|
|
2341
|
+
log11("Getting fork source for agent group: %s", identifier);
|
|
2342
|
+
const result = await this.request(
|
|
2343
|
+
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2344
|
+
options
|
|
2345
|
+
);
|
|
2346
|
+
if (result.source) {
|
|
2347
|
+
log11("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2348
|
+
} else {
|
|
2349
|
+
log11("Agent group %s is not a fork (original group)", identifier);
|
|
2350
|
+
}
|
|
2351
|
+
return result;
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
|
|
2355
|
+
// src/market/services/AuthService.ts
|
|
2356
|
+
import debug12 from "debug";
|
|
1967
2357
|
import urlJoin2 from "url-join";
|
|
1968
|
-
var
|
|
2358
|
+
var log12 = debug12("lobe-market-sdk:auth");
|
|
1969
2359
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
1970
2360
|
/** Normalize token response from snake_case to camelCase fields */
|
|
1971
2361
|
static normalizeTokenResponse(data) {
|
|
@@ -1997,7 +2387,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
1997
2387
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
1998
2388
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
1999
2389
|
}
|
|
2000
|
-
|
|
2390
|
+
log12("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2001
2391
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2002
2392
|
const params = new URLSearchParams();
|
|
2003
2393
|
params.set("grant_type", grantType);
|
|
@@ -2039,16 +2429,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2039
2429
|
try {
|
|
2040
2430
|
payload = await response.json();
|
|
2041
2431
|
} catch (error) {
|
|
2042
|
-
|
|
2432
|
+
log12("Failed to parse token response: %O", error);
|
|
2043
2433
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
2044
2434
|
}
|
|
2045
2435
|
if (!response.ok) {
|
|
2046
2436
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
2047
2437
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
2048
|
-
|
|
2438
|
+
log12("Error: %s", errorMsg);
|
|
2049
2439
|
throw new Error(errorMsg);
|
|
2050
2440
|
}
|
|
2051
|
-
|
|
2441
|
+
log12("Token exchange successful");
|
|
2052
2442
|
return _AuthService.normalizeTokenResponse(payload);
|
|
2053
2443
|
}
|
|
2054
2444
|
/**
|
|
@@ -2061,7 +2451,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2061
2451
|
* @returns Promise resolving to the user information
|
|
2062
2452
|
*/
|
|
2063
2453
|
async getUserInfo(accessToken, options) {
|
|
2064
|
-
|
|
2454
|
+
log12("Getting user info");
|
|
2065
2455
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
2066
2456
|
const response = await fetch(userInfoUrl, {
|
|
2067
2457
|
headers: {
|
|
@@ -2073,11 +2463,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2073
2463
|
});
|
|
2074
2464
|
if (!response.ok) {
|
|
2075
2465
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
2076
|
-
|
|
2466
|
+
log12("Error: %s", errorMsg);
|
|
2077
2467
|
throw new Error(errorMsg);
|
|
2078
2468
|
}
|
|
2079
2469
|
const userInfo = await response.json();
|
|
2080
|
-
|
|
2470
|
+
log12("User info retrieved successfully");
|
|
2081
2471
|
return userInfo;
|
|
2082
2472
|
}
|
|
2083
2473
|
/**
|
|
@@ -2091,7 +2481,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2091
2481
|
* @returns Promise resolving to the client credentials
|
|
2092
2482
|
*/
|
|
2093
2483
|
async registerClient(clientData, options) {
|
|
2094
|
-
|
|
2484
|
+
log12("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
2095
2485
|
const result = await this.request("/v1/clients/register", {
|
|
2096
2486
|
body: JSON.stringify(clientData),
|
|
2097
2487
|
headers: {
|
|
@@ -2100,7 +2490,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2100
2490
|
method: "POST",
|
|
2101
2491
|
...options
|
|
2102
2492
|
});
|
|
2103
|
-
|
|
2493
|
+
log12("Client registered successfully: %s", result.client_id);
|
|
2104
2494
|
return result;
|
|
2105
2495
|
}
|
|
2106
2496
|
/**
|
|
@@ -2112,9 +2502,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2112
2502
|
* @returns Promise resolving to the access token and expiration time
|
|
2113
2503
|
*/
|
|
2114
2504
|
async getM2MToken() {
|
|
2115
|
-
|
|
2505
|
+
log12("Fetching M2M token");
|
|
2116
2506
|
const tokenInfo = await this.fetchM2MToken();
|
|
2117
|
-
|
|
2507
|
+
log12("M2M token fetched successfully");
|
|
2118
2508
|
return tokenInfo;
|
|
2119
2509
|
}
|
|
2120
2510
|
/** OAuth handoff response shapes */
|
|
@@ -2140,7 +2530,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2140
2530
|
async getOAuthHandoff(id, options) {
|
|
2141
2531
|
var _a, _b;
|
|
2142
2532
|
if (!id) throw new Error("id is required");
|
|
2143
|
-
|
|
2533
|
+
log12("Getting OAuth handoff: %s", id);
|
|
2144
2534
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
2145
2535
|
const response = await fetch(handoffUrl, {
|
|
2146
2536
|
headers: {
|
|
@@ -2156,19 +2546,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2156
2546
|
code: json.code,
|
|
2157
2547
|
redirectUri: json.redirectUri
|
|
2158
2548
|
});
|
|
2159
|
-
|
|
2549
|
+
log12("OAuth handoff success for id: %s", id);
|
|
2160
2550
|
return result;
|
|
2161
2551
|
}
|
|
2162
2552
|
if (response.status === 202) {
|
|
2163
|
-
|
|
2553
|
+
log12("OAuth handoff pending for id: %s", id);
|
|
2164
2554
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
2165
2555
|
}
|
|
2166
2556
|
if (response.status === 404) {
|
|
2167
|
-
|
|
2557
|
+
log12("OAuth handoff consumed for id: %s", id);
|
|
2168
2558
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
2169
2559
|
}
|
|
2170
2560
|
if (response.status === 410) {
|
|
2171
|
-
|
|
2561
|
+
log12("OAuth handoff expired for id: %s", id);
|
|
2172
2562
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
2173
2563
|
}
|
|
2174
2564
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -2179,7 +2569,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2179
2569
|
}
|
|
2180
2570
|
} catch (e) {
|
|
2181
2571
|
}
|
|
2182
|
-
|
|
2572
|
+
log12("Error: %s", errorMessage);
|
|
2183
2573
|
throw new Error(errorMessage);
|
|
2184
2574
|
}
|
|
2185
2575
|
/**
|
|
@@ -2193,21 +2583,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2193
2583
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
2194
2584
|
const startedAt = Date.now();
|
|
2195
2585
|
const { signal, requestInit } = params;
|
|
2196
|
-
|
|
2586
|
+
log12("Start polling OAuth handoff: %s", id);
|
|
2197
2587
|
while (true) {
|
|
2198
2588
|
if (signal == null ? void 0 : signal.aborted) {
|
|
2199
2589
|
const err = new Error("Polling aborted");
|
|
2200
|
-
|
|
2590
|
+
log12("Error: %s", err.message);
|
|
2201
2591
|
throw err;
|
|
2202
2592
|
}
|
|
2203
2593
|
if (Date.now() - startedAt > timeoutMs) {
|
|
2204
2594
|
const err = new Error("Polling timeout");
|
|
2205
|
-
|
|
2595
|
+
log12("Error: %s", err.message);
|
|
2206
2596
|
throw err;
|
|
2207
2597
|
}
|
|
2208
2598
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
2209
2599
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
2210
|
-
|
|
2600
|
+
log12("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
2211
2601
|
return result;
|
|
2212
2602
|
}
|
|
2213
2603
|
await new Promise((resolve) => {
|
|
@@ -2228,9 +2618,9 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
2228
2618
|
var AuthService = _AuthService;
|
|
2229
2619
|
|
|
2230
2620
|
// src/market/services/ConnectService.ts
|
|
2231
|
-
import
|
|
2621
|
+
import debug13 from "debug";
|
|
2232
2622
|
import urlJoin3 from "url-join";
|
|
2233
|
-
var
|
|
2623
|
+
var log13 = debug13("lobe-market-sdk:connect");
|
|
2234
2624
|
var ConnectService = class extends BaseSDK {
|
|
2235
2625
|
/**
|
|
2236
2626
|
* Lists all available OAuth providers
|
|
@@ -2243,9 +2633,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
2243
2633
|
*/
|
|
2244
2634
|
async listProviders(options) {
|
|
2245
2635
|
var _a;
|
|
2246
|
-
|
|
2636
|
+
log13("Listing connect providers");
|
|
2247
2637
|
const result = await this.request("/connect/providers", options);
|
|
2248
|
-
|
|
2638
|
+
log13("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
2249
2639
|
return result;
|
|
2250
2640
|
}
|
|
2251
2641
|
/**
|
|
@@ -2259,12 +2649,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2259
2649
|
*/
|
|
2260
2650
|
async getProvider(provider, options) {
|
|
2261
2651
|
var _a;
|
|
2262
|
-
|
|
2652
|
+
log13("Getting provider details: %s", provider);
|
|
2263
2653
|
const result = await this.request(
|
|
2264
2654
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
2265
2655
|
options
|
|
2266
2656
|
);
|
|
2267
|
-
|
|
2657
|
+
log13("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
2268
2658
|
return result;
|
|
2269
2659
|
}
|
|
2270
2660
|
/**
|
|
@@ -2304,7 +2694,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2304
2694
|
* ```
|
|
2305
2695
|
*/
|
|
2306
2696
|
async authorize(provider, params, options) {
|
|
2307
|
-
|
|
2697
|
+
log13("Requesting authorization code for provider: %s", provider);
|
|
2308
2698
|
const result = await this.request(
|
|
2309
2699
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
2310
2700
|
{
|
|
@@ -2316,7 +2706,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2316
2706
|
...options
|
|
2317
2707
|
}
|
|
2318
2708
|
);
|
|
2319
|
-
|
|
2709
|
+
log13("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
2320
2710
|
return result;
|
|
2321
2711
|
}
|
|
2322
2712
|
/**
|
|
@@ -2342,7 +2732,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2342
2732
|
* ```
|
|
2343
2733
|
*/
|
|
2344
2734
|
getAuthorizeUrl(provider, params) {
|
|
2345
|
-
|
|
2735
|
+
log13(
|
|
2346
2736
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
2347
2737
|
provider
|
|
2348
2738
|
);
|
|
@@ -2356,7 +2746,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2356
2746
|
const queryString = queryParams.toString();
|
|
2357
2747
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
2358
2748
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
2359
|
-
|
|
2749
|
+
log13("Generated authorize URL: %s", url);
|
|
2360
2750
|
return url;
|
|
2361
2751
|
}
|
|
2362
2752
|
/**
|
|
@@ -2370,12 +2760,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2370
2760
|
* @returns Promise resolving to the connection status
|
|
2371
2761
|
*/
|
|
2372
2762
|
async getStatus(provider, options) {
|
|
2373
|
-
|
|
2763
|
+
log13("Getting connection status for provider: %s", provider);
|
|
2374
2764
|
const result = await this.request(
|
|
2375
2765
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
2376
2766
|
options
|
|
2377
2767
|
);
|
|
2378
|
-
|
|
2768
|
+
log13("Provider %s connection status: connected=%s", provider, result.connected);
|
|
2379
2769
|
return result;
|
|
2380
2770
|
}
|
|
2381
2771
|
/**
|
|
@@ -2388,9 +2778,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
2388
2778
|
*/
|
|
2389
2779
|
async listConnections(options) {
|
|
2390
2780
|
var _a;
|
|
2391
|
-
|
|
2781
|
+
log13("Listing user connections");
|
|
2392
2782
|
const result = await this.request("/connect/connections", options);
|
|
2393
|
-
|
|
2783
|
+
log13("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
2394
2784
|
return result;
|
|
2395
2785
|
}
|
|
2396
2786
|
/**
|
|
@@ -2404,12 +2794,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2404
2794
|
* @returns Promise resolving to the connection health status
|
|
2405
2795
|
*/
|
|
2406
2796
|
async getHealth(provider, options) {
|
|
2407
|
-
|
|
2797
|
+
log13("Checking health for provider: %s", provider);
|
|
2408
2798
|
const result = await this.request(
|
|
2409
2799
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
2410
2800
|
options
|
|
2411
2801
|
);
|
|
2412
|
-
|
|
2802
|
+
log13("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
2413
2803
|
return result;
|
|
2414
2804
|
}
|
|
2415
2805
|
/**
|
|
@@ -2422,9 +2812,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
2422
2812
|
*/
|
|
2423
2813
|
async getAllHealth(options) {
|
|
2424
2814
|
var _a, _b, _c;
|
|
2425
|
-
|
|
2815
|
+
log13("Checking health for all connections");
|
|
2426
2816
|
const result = await this.request("/connect/health", options);
|
|
2427
|
-
|
|
2817
|
+
log13(
|
|
2428
2818
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
2429
2819
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
2430
2820
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -2443,7 +2833,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2443
2833
|
* @returns Promise resolving to the refresh result
|
|
2444
2834
|
*/
|
|
2445
2835
|
async refresh(provider, options) {
|
|
2446
|
-
|
|
2836
|
+
log13("Refreshing token for provider: %s", provider);
|
|
2447
2837
|
const result = await this.request(
|
|
2448
2838
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
2449
2839
|
{
|
|
@@ -2451,7 +2841,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2451
2841
|
...options
|
|
2452
2842
|
}
|
|
2453
2843
|
);
|
|
2454
|
-
|
|
2844
|
+
log13("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
2455
2845
|
return result;
|
|
2456
2846
|
}
|
|
2457
2847
|
/**
|
|
@@ -2465,7 +2855,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2465
2855
|
* @returns Promise resolving to the revoke result
|
|
2466
2856
|
*/
|
|
2467
2857
|
async revoke(provider, options) {
|
|
2468
|
-
|
|
2858
|
+
log13("Revoking connection for provider: %s", provider);
|
|
2469
2859
|
const result = await this.request(
|
|
2470
2860
|
`/connect/${encodeURIComponent(provider)}`,
|
|
2471
2861
|
{
|
|
@@ -2473,15 +2863,15 @@ var ConnectService = class extends BaseSDK {
|
|
|
2473
2863
|
...options
|
|
2474
2864
|
}
|
|
2475
2865
|
);
|
|
2476
|
-
|
|
2866
|
+
log13("Connection revoked for %s: success=%s", provider, result.success);
|
|
2477
2867
|
return result;
|
|
2478
2868
|
}
|
|
2479
2869
|
};
|
|
2480
2870
|
|
|
2481
2871
|
// src/market/services/DiscoveryService.ts
|
|
2482
|
-
import
|
|
2872
|
+
import debug14 from "debug";
|
|
2483
2873
|
import urlJoin4 from "url-join";
|
|
2484
|
-
var
|
|
2874
|
+
var log14 = debug14("lobe-market-sdk:discovery");
|
|
2485
2875
|
var DiscoveryService = class extends BaseSDK {
|
|
2486
2876
|
/**
|
|
2487
2877
|
* Retrieves the service discovery document
|
|
@@ -2493,9 +2883,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
2493
2883
|
* @returns Promise resolving to the service discovery document
|
|
2494
2884
|
*/
|
|
2495
2885
|
async getDiscoveryDocument() {
|
|
2496
|
-
|
|
2886
|
+
log14("Fetching discovery document");
|
|
2497
2887
|
if (this.discoveryDoc) {
|
|
2498
|
-
|
|
2888
|
+
log14("Returning cached discovery document");
|
|
2499
2889
|
return this.discoveryDoc;
|
|
2500
2890
|
}
|
|
2501
2891
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -2503,14 +2893,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
2503
2893
|
throw new Error(await res.text());
|
|
2504
2894
|
}
|
|
2505
2895
|
this.discoveryDoc = await res.json();
|
|
2506
|
-
|
|
2896
|
+
log14("Discovery document successfully fetched");
|
|
2507
2897
|
return this.discoveryDoc;
|
|
2508
2898
|
}
|
|
2509
2899
|
};
|
|
2510
2900
|
|
|
2511
2901
|
// src/market/services/FeedbackService.ts
|
|
2512
|
-
import
|
|
2513
|
-
var
|
|
2902
|
+
import debug15 from "debug";
|
|
2903
|
+
var log15 = debug15("lobe-market-sdk:feedback");
|
|
2514
2904
|
var FeedbackService = class extends BaseSDK {
|
|
2515
2905
|
/**
|
|
2516
2906
|
* Submits user feedback
|
|
@@ -2540,7 +2930,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
2540
2930
|
* ```
|
|
2541
2931
|
*/
|
|
2542
2932
|
async submitFeedback(data, options) {
|
|
2543
|
-
|
|
2933
|
+
log15("Submitting feedback: %s", data.title);
|
|
2544
2934
|
const result = await this.request("/v1/user/feedback", {
|
|
2545
2935
|
body: JSON.stringify(data),
|
|
2546
2936
|
headers: {
|
|
@@ -2549,14 +2939,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
2549
2939
|
method: "POST",
|
|
2550
2940
|
...options
|
|
2551
2941
|
});
|
|
2552
|
-
|
|
2942
|
+
log15("Feedback submitted successfully: %s", result.issueId);
|
|
2553
2943
|
return result;
|
|
2554
2944
|
}
|
|
2555
2945
|
};
|
|
2556
2946
|
|
|
2557
2947
|
// src/market/services/PluginsService.ts
|
|
2558
|
-
import
|
|
2559
|
-
var
|
|
2948
|
+
import debug16 from "debug";
|
|
2949
|
+
var log16 = debug16("lobe-market-sdk:plugins");
|
|
2560
2950
|
var PluginsService = class extends BaseSDK {
|
|
2561
2951
|
/**
|
|
2562
2952
|
* Retrieves a list of plugins from the marketplace
|
|
@@ -2571,9 +2961,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
2571
2961
|
const locale = params.locale || this.defaultLocale;
|
|
2572
2962
|
const queryParams = { ...params, locale };
|
|
2573
2963
|
const queryString = this.buildQueryString(queryParams);
|
|
2574
|
-
|
|
2964
|
+
log16("Getting plugin list: %O", queryParams);
|
|
2575
2965
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
2576
|
-
|
|
2966
|
+
log16("Retrieved %d plugins", result.items.length);
|
|
2577
2967
|
return result;
|
|
2578
2968
|
}
|
|
2579
2969
|
/**
|
|
@@ -2591,12 +2981,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
2591
2981
|
const locale = params.locale || this.defaultLocale;
|
|
2592
2982
|
const queryParams = { ...params, locale };
|
|
2593
2983
|
const queryString = this.buildQueryString(queryParams);
|
|
2594
|
-
|
|
2984
|
+
log16("Getting plugin categories: %O", queryParams);
|
|
2595
2985
|
const result = await this.request(
|
|
2596
2986
|
`/v1/plugins/categories${queryString}`,
|
|
2597
2987
|
options
|
|
2598
2988
|
);
|
|
2599
|
-
|
|
2989
|
+
log16("Retrieved %d categories", result.length);
|
|
2600
2990
|
return result;
|
|
2601
2991
|
}
|
|
2602
2992
|
/**
|
|
@@ -2609,12 +2999,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
2609
2999
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
2610
3000
|
*/
|
|
2611
3001
|
async getPublishedIdentifiers(options) {
|
|
2612
|
-
|
|
3002
|
+
log16("Getting published plugin identifiers");
|
|
2613
3003
|
const result = await this.request(
|
|
2614
3004
|
"/v1/plugins/identifiers",
|
|
2615
3005
|
options
|
|
2616
3006
|
);
|
|
2617
|
-
|
|
3007
|
+
log16("Retrieved %d published plugin identifiers", result.length);
|
|
2618
3008
|
return result;
|
|
2619
3009
|
}
|
|
2620
3010
|
/**
|
|
@@ -2634,7 +3024,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2634
3024
|
version,
|
|
2635
3025
|
identifier
|
|
2636
3026
|
}, options) {
|
|
2637
|
-
|
|
3027
|
+
log16("Getting plugin manifest: %O", { identifier, locale, version });
|
|
2638
3028
|
const localeParam = locale || this.defaultLocale;
|
|
2639
3029
|
const params = { locale: localeParam };
|
|
2640
3030
|
if (version) {
|
|
@@ -2645,7 +3035,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2645
3035
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
2646
3036
|
options
|
|
2647
3037
|
);
|
|
2648
|
-
|
|
3038
|
+
log16("Plugin manifest successfully retrieved: %s", identifier);
|
|
2649
3039
|
return manifest;
|
|
2650
3040
|
}
|
|
2651
3041
|
/**
|
|
@@ -2662,7 +3052,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2662
3052
|
version,
|
|
2663
3053
|
identifier
|
|
2664
3054
|
}, options) {
|
|
2665
|
-
|
|
3055
|
+
log16("Getting plugin detail: %O", { identifier, locale, version });
|
|
2666
3056
|
const localeParam = locale || this.defaultLocale;
|
|
2667
3057
|
const params = { locale: localeParam };
|
|
2668
3058
|
if (version) {
|
|
@@ -2673,7 +3063,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2673
3063
|
`/v1/plugins/${identifier}${queryString}`,
|
|
2674
3064
|
options
|
|
2675
3065
|
);
|
|
2676
|
-
|
|
3066
|
+
log16("Plugin manifest successfully retrieved: %s", identifier);
|
|
2677
3067
|
return manifest;
|
|
2678
3068
|
}
|
|
2679
3069
|
/**
|
|
@@ -2688,7 +3078,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2688
3078
|
*
|
|
2689
3079
|
*/
|
|
2690
3080
|
async reportInstallation(reportData) {
|
|
2691
|
-
|
|
3081
|
+
log16("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
2692
3082
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
2693
3083
|
body: JSON.stringify(reportData),
|
|
2694
3084
|
headers: {
|
|
@@ -2696,7 +3086,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2696
3086
|
},
|
|
2697
3087
|
method: "POST"
|
|
2698
3088
|
});
|
|
2699
|
-
|
|
3089
|
+
log16("Installation report submitted successfully: %O", result);
|
|
2700
3090
|
return result;
|
|
2701
3091
|
}
|
|
2702
3092
|
/**
|
|
@@ -2710,7 +3100,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2710
3100
|
* @returns Promise resolving to the report submission response
|
|
2711
3101
|
*/
|
|
2712
3102
|
async reportCall(reportData) {
|
|
2713
|
-
|
|
3103
|
+
log16(
|
|
2714
3104
|
"Reporting call for %s@%s - %s:%s",
|
|
2715
3105
|
reportData.identifier,
|
|
2716
3106
|
reportData.version,
|
|
@@ -2724,7 +3114,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2724
3114
|
},
|
|
2725
3115
|
method: "POST"
|
|
2726
3116
|
});
|
|
2727
|
-
|
|
3117
|
+
log16("Call report submitted successfully: %O", result);
|
|
2728
3118
|
return result;
|
|
2729
3119
|
}
|
|
2730
3120
|
/**
|
|
@@ -2736,7 +3126,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2736
3126
|
* @param options - Optional request init overrides
|
|
2737
3127
|
*/
|
|
2738
3128
|
async createEvent(eventData, options) {
|
|
2739
|
-
|
|
3129
|
+
log16("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
2740
3130
|
await this.request("/v1/plugins/events", {
|
|
2741
3131
|
body: JSON.stringify(eventData),
|
|
2742
3132
|
headers: {
|
|
@@ -2766,7 +3156,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2766
3156
|
* ```
|
|
2767
3157
|
*/
|
|
2768
3158
|
async callCloudGateway(request, options) {
|
|
2769
|
-
|
|
3159
|
+
log16("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
2770
3160
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
2771
3161
|
body: JSON.stringify(request),
|
|
2772
3162
|
headers: {
|
|
@@ -2775,7 +3165,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2775
3165
|
method: "POST",
|
|
2776
3166
|
...options
|
|
2777
3167
|
});
|
|
2778
|
-
|
|
3168
|
+
log16("Cloud gateway call completed: %O", {
|
|
2779
3169
|
identifier: request.identifier,
|
|
2780
3170
|
isError: result.isError,
|
|
2781
3171
|
toolName: request.toolName
|
|
@@ -2816,7 +3206,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2816
3206
|
* ```
|
|
2817
3207
|
*/
|
|
2818
3208
|
async runBuildInTool(toolName, params, context, options) {
|
|
2819
|
-
|
|
3209
|
+
log16(
|
|
2820
3210
|
"Running built-in tool: %s for user %s, topic %s",
|
|
2821
3211
|
toolName,
|
|
2822
3212
|
context.userId,
|
|
@@ -2835,7 +3225,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
2835
3225
|
method: "POST",
|
|
2836
3226
|
...options
|
|
2837
3227
|
});
|
|
2838
|
-
|
|
3228
|
+
log16("Built-in tool execution completed: %O", {
|
|
2839
3229
|
success: result.success,
|
|
2840
3230
|
toolName
|
|
2841
3231
|
});
|
|
@@ -2939,8 +3329,8 @@ var PluginsService = class extends BaseSDK {
|
|
|
2939
3329
|
};
|
|
2940
3330
|
|
|
2941
3331
|
// src/market/services/SkillService.ts
|
|
2942
|
-
import
|
|
2943
|
-
var
|
|
3332
|
+
import debug17 from "debug";
|
|
3333
|
+
var log17 = debug17("lobe-market-sdk:skill");
|
|
2944
3334
|
var SkillService = class extends BaseSDK {
|
|
2945
3335
|
/**
|
|
2946
3336
|
* Lists all available skill providers
|
|
@@ -2953,9 +3343,9 @@ var SkillService = class extends BaseSDK {
|
|
|
2953
3343
|
*/
|
|
2954
3344
|
async listProviders(options) {
|
|
2955
3345
|
var _a;
|
|
2956
|
-
|
|
3346
|
+
log17("Listing skill providers");
|
|
2957
3347
|
const result = await this.request("/v1/skill/providers", options);
|
|
2958
|
-
|
|
3348
|
+
log17("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
2959
3349
|
return result;
|
|
2960
3350
|
}
|
|
2961
3351
|
/**
|
|
@@ -2970,12 +3360,12 @@ var SkillService = class extends BaseSDK {
|
|
|
2970
3360
|
*/
|
|
2971
3361
|
async listTools(provider, options) {
|
|
2972
3362
|
var _a;
|
|
2973
|
-
|
|
3363
|
+
log17("Listing tools for provider: %s", provider);
|
|
2974
3364
|
const result = await this.request(
|
|
2975
3365
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
2976
3366
|
options
|
|
2977
3367
|
);
|
|
2978
|
-
|
|
3368
|
+
log17("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
2979
3369
|
return result;
|
|
2980
3370
|
}
|
|
2981
3371
|
/**
|
|
@@ -2991,12 +3381,12 @@ var SkillService = class extends BaseSDK {
|
|
|
2991
3381
|
*/
|
|
2992
3382
|
async getTool(provider, toolName, options) {
|
|
2993
3383
|
var _a;
|
|
2994
|
-
|
|
3384
|
+
log17("Getting tool %s from provider %s", toolName, provider);
|
|
2995
3385
|
const result = await this.request(
|
|
2996
3386
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
2997
3387
|
options
|
|
2998
3388
|
);
|
|
2999
|
-
|
|
3389
|
+
log17("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
3000
3390
|
return result;
|
|
3001
3391
|
}
|
|
3002
3392
|
/**
|
|
@@ -3010,12 +3400,12 @@ var SkillService = class extends BaseSDK {
|
|
|
3010
3400
|
* @returns Promise resolving to the connection status
|
|
3011
3401
|
*/
|
|
3012
3402
|
async getStatus(provider, options) {
|
|
3013
|
-
|
|
3403
|
+
log17("Getting status for provider: %s", provider);
|
|
3014
3404
|
const result = await this.request(
|
|
3015
3405
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
3016
3406
|
options
|
|
3017
3407
|
);
|
|
3018
|
-
|
|
3408
|
+
log17("Provider %s status: connected=%s", provider, result.connected);
|
|
3019
3409
|
return result;
|
|
3020
3410
|
}
|
|
3021
3411
|
/**
|
|
@@ -3043,7 +3433,7 @@ var SkillService = class extends BaseSDK {
|
|
|
3043
3433
|
* ```
|
|
3044
3434
|
*/
|
|
3045
3435
|
async callTool(provider, params, options) {
|
|
3046
|
-
|
|
3436
|
+
log17("Calling tool %s on provider %s", params.tool, provider);
|
|
3047
3437
|
const result = await this.request(
|
|
3048
3438
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
3049
3439
|
{
|
|
@@ -3058,14 +3448,14 @@ var SkillService = class extends BaseSDK {
|
|
|
3058
3448
|
...options
|
|
3059
3449
|
}
|
|
3060
3450
|
);
|
|
3061
|
-
|
|
3451
|
+
log17("Tool %s call completed: success=%s", params.tool, result.success);
|
|
3062
3452
|
return result;
|
|
3063
3453
|
}
|
|
3064
3454
|
};
|
|
3065
3455
|
|
|
3066
3456
|
// src/market/services/UserService.ts
|
|
3067
|
-
import
|
|
3068
|
-
var
|
|
3457
|
+
import debug18 from "debug";
|
|
3458
|
+
var log18 = debug18("lobe-market-sdk:user");
|
|
3069
3459
|
var UserService = class extends BaseSDK {
|
|
3070
3460
|
/**
|
|
3071
3461
|
* Retrieves user information by account ID or userName
|
|
@@ -3082,12 +3472,12 @@ var UserService = class extends BaseSDK {
|
|
|
3082
3472
|
const locale = params.locale || this.defaultLocale;
|
|
3083
3473
|
const queryParams = { locale };
|
|
3084
3474
|
const queryString = this.buildQueryString(queryParams);
|
|
3085
|
-
|
|
3475
|
+
log18("Getting user info: %O", { idOrUserName, ...params });
|
|
3086
3476
|
const result = await this.request(
|
|
3087
3477
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
3088
3478
|
options
|
|
3089
3479
|
);
|
|
3090
|
-
|
|
3480
|
+
log18("User info successfully retrieved for: %s", idOrUserName);
|
|
3091
3481
|
return result;
|
|
3092
3482
|
}
|
|
3093
3483
|
/**
|
|
@@ -3102,7 +3492,7 @@ var UserService = class extends BaseSDK {
|
|
|
3102
3492
|
* @throws Error if userName is already taken or update fails
|
|
3103
3493
|
*/
|
|
3104
3494
|
async updateUserInfo(data, options) {
|
|
3105
|
-
|
|
3495
|
+
log18("Updating user info: %O", data);
|
|
3106
3496
|
const result = await this.request("/v1/user/update", {
|
|
3107
3497
|
body: JSON.stringify(data),
|
|
3108
3498
|
headers: {
|
|
@@ -3111,7 +3501,7 @@ var UserService = class extends BaseSDK {
|
|
|
3111
3501
|
method: "POST",
|
|
3112
3502
|
...options
|
|
3113
3503
|
});
|
|
3114
|
-
|
|
3504
|
+
log18("User info updated successfully");
|
|
3115
3505
|
return result;
|
|
3116
3506
|
}
|
|
3117
3507
|
/**
|
|
@@ -3141,7 +3531,10 @@ var UserService = class extends BaseSDK {
|
|
|
3141
3531
|
* ```
|
|
3142
3532
|
*/
|
|
3143
3533
|
async register(data, options) {
|
|
3144
|
-
|
|
3534
|
+
log18("Registering user: %O", {
|
|
3535
|
+
followUserId: data.followUserId,
|
|
3536
|
+
registerUserId: data.registerUserId
|
|
3537
|
+
});
|
|
3145
3538
|
const result = await this.request("/v1/user/register", {
|
|
3146
3539
|
body: JSON.stringify(data),
|
|
3147
3540
|
headers: {
|
|
@@ -3150,14 +3543,14 @@ var UserService = class extends BaseSDK {
|
|
|
3150
3543
|
method: "POST",
|
|
3151
3544
|
...options
|
|
3152
3545
|
});
|
|
3153
|
-
|
|
3546
|
+
log18("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
3154
3547
|
return result;
|
|
3155
3548
|
}
|
|
3156
3549
|
};
|
|
3157
3550
|
|
|
3158
3551
|
// src/market/services/UserFollowService.ts
|
|
3159
|
-
import
|
|
3160
|
-
var
|
|
3552
|
+
import debug19 from "debug";
|
|
3553
|
+
var log19 = debug19("lobe-market-sdk:user-follow");
|
|
3161
3554
|
var UserFollowService = class extends BaseSDK {
|
|
3162
3555
|
/**
|
|
3163
3556
|
* Follow a user
|
|
@@ -3171,7 +3564,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3171
3564
|
* @throws Error if already following or cannot follow yourself
|
|
3172
3565
|
*/
|
|
3173
3566
|
async follow(followingId, options) {
|
|
3174
|
-
|
|
3567
|
+
log19("Following user: %d", followingId);
|
|
3175
3568
|
const body = { followingId };
|
|
3176
3569
|
const result = await this.request("/v1/user/follows", {
|
|
3177
3570
|
body: JSON.stringify(body),
|
|
@@ -3181,7 +3574,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3181
3574
|
method: "POST",
|
|
3182
3575
|
...options
|
|
3183
3576
|
});
|
|
3184
|
-
|
|
3577
|
+
log19("Successfully followed user: %d", followingId);
|
|
3185
3578
|
return result;
|
|
3186
3579
|
}
|
|
3187
3580
|
/**
|
|
@@ -3196,7 +3589,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3196
3589
|
* @throws Error if follow relationship not found
|
|
3197
3590
|
*/
|
|
3198
3591
|
async unfollow(followingId, options) {
|
|
3199
|
-
|
|
3592
|
+
log19("Unfollowing user: %d", followingId);
|
|
3200
3593
|
const body = { followingId };
|
|
3201
3594
|
const result = await this.request("/v1/user/follows", {
|
|
3202
3595
|
body: JSON.stringify(body),
|
|
@@ -3206,7 +3599,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3206
3599
|
method: "DELETE",
|
|
3207
3600
|
...options
|
|
3208
3601
|
});
|
|
3209
|
-
|
|
3602
|
+
log19("Successfully unfollowed user: %d", followingId);
|
|
3210
3603
|
return result;
|
|
3211
3604
|
}
|
|
3212
3605
|
/**
|
|
@@ -3220,13 +3613,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3220
3613
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
3221
3614
|
*/
|
|
3222
3615
|
async checkFollowStatus(targetUserId, options) {
|
|
3223
|
-
|
|
3616
|
+
log19("Checking follow status for user: %d", targetUserId);
|
|
3224
3617
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
3225
3618
|
const result = await this.request(
|
|
3226
3619
|
`/v1/user/follows/check${queryString}`,
|
|
3227
3620
|
options
|
|
3228
3621
|
);
|
|
3229
|
-
|
|
3622
|
+
log19("Follow status retrieved: %O", result);
|
|
3230
3623
|
return result;
|
|
3231
3624
|
}
|
|
3232
3625
|
/**
|
|
@@ -3241,7 +3634,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3241
3634
|
* @returns Promise resolving to list of following users
|
|
3242
3635
|
*/
|
|
3243
3636
|
async getFollowing(userId, params = {}, options) {
|
|
3244
|
-
|
|
3637
|
+
log19("Getting following list for user: %d", userId);
|
|
3245
3638
|
const queryParams = {};
|
|
3246
3639
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3247
3640
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3250,7 +3643,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3250
3643
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
3251
3644
|
options
|
|
3252
3645
|
);
|
|
3253
|
-
|
|
3646
|
+
log19("Following list retrieved for user: %d", userId);
|
|
3254
3647
|
return result;
|
|
3255
3648
|
}
|
|
3256
3649
|
/**
|
|
@@ -3265,7 +3658,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3265
3658
|
* @returns Promise resolving to list of followers
|
|
3266
3659
|
*/
|
|
3267
3660
|
async getFollowers(userId, params = {}, options) {
|
|
3268
|
-
|
|
3661
|
+
log19("Getting followers list for user: %d", userId);
|
|
3269
3662
|
const queryParams = {};
|
|
3270
3663
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3271
3664
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3274,14 +3667,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
3274
3667
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
3275
3668
|
options
|
|
3276
3669
|
);
|
|
3277
|
-
|
|
3670
|
+
log19("Followers list retrieved for user: %d", userId);
|
|
3278
3671
|
return result;
|
|
3279
3672
|
}
|
|
3280
3673
|
};
|
|
3281
3674
|
|
|
3282
3675
|
// src/market/services/UserFavoriteService.ts
|
|
3283
|
-
import
|
|
3284
|
-
var
|
|
3676
|
+
import debug20 from "debug";
|
|
3677
|
+
var log20 = debug20("lobe-market-sdk:user-favorite");
|
|
3285
3678
|
var UserFavoriteService = class extends BaseSDK {
|
|
3286
3679
|
/**
|
|
3287
3680
|
* Add to favorites
|
|
@@ -3296,7 +3689,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3296
3689
|
* @throws Error if already in favorites
|
|
3297
3690
|
*/
|
|
3298
3691
|
async addFavorite(targetType, targetId, options) {
|
|
3299
|
-
|
|
3692
|
+
log20("Adding favorite: %s %d", targetType, targetId);
|
|
3300
3693
|
const body = { targetId, targetType };
|
|
3301
3694
|
const result = await this.request("/v1/user/favorites", {
|
|
3302
3695
|
body: JSON.stringify(body),
|
|
@@ -3306,7 +3699,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3306
3699
|
method: "POST",
|
|
3307
3700
|
...options
|
|
3308
3701
|
});
|
|
3309
|
-
|
|
3702
|
+
log20("Successfully added favorite: %s %d", targetType, targetId);
|
|
3310
3703
|
return result;
|
|
3311
3704
|
}
|
|
3312
3705
|
/**
|
|
@@ -3322,7 +3715,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3322
3715
|
* @throws Error if favorite not found
|
|
3323
3716
|
*/
|
|
3324
3717
|
async removeFavorite(targetType, targetId, options) {
|
|
3325
|
-
|
|
3718
|
+
log20("Removing favorite: %s %d", targetType, targetId);
|
|
3326
3719
|
const body = { targetId, targetType };
|
|
3327
3720
|
const result = await this.request("/v1/user/favorites", {
|
|
3328
3721
|
body: JSON.stringify(body),
|
|
@@ -3332,7 +3725,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3332
3725
|
method: "DELETE",
|
|
3333
3726
|
...options
|
|
3334
3727
|
});
|
|
3335
|
-
|
|
3728
|
+
log20("Successfully removed favorite: %s %d", targetType, targetId);
|
|
3336
3729
|
return result;
|
|
3337
3730
|
}
|
|
3338
3731
|
/**
|
|
@@ -3347,7 +3740,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3347
3740
|
* @returns Promise resolving to favorite status
|
|
3348
3741
|
*/
|
|
3349
3742
|
async checkFavorite(targetType, targetId, options) {
|
|
3350
|
-
|
|
3743
|
+
log20("Checking favorite status: %s %d", targetType, targetId);
|
|
3351
3744
|
const queryString = this.buildQueryString({
|
|
3352
3745
|
targetId: String(targetId),
|
|
3353
3746
|
targetType
|
|
@@ -3356,7 +3749,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3356
3749
|
`/v1/user/favorites/check${queryString}`,
|
|
3357
3750
|
options
|
|
3358
3751
|
);
|
|
3359
|
-
|
|
3752
|
+
log20("Favorite status retrieved: %O", result);
|
|
3360
3753
|
return result;
|
|
3361
3754
|
}
|
|
3362
3755
|
/**
|
|
@@ -3370,7 +3763,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3370
3763
|
* @returns Promise resolving to list of favorites
|
|
3371
3764
|
*/
|
|
3372
3765
|
async getMyFavorites(params = {}, options) {
|
|
3373
|
-
|
|
3766
|
+
log20("Getting my favorites: %O", params);
|
|
3374
3767
|
const queryParams = {};
|
|
3375
3768
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3376
3769
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3380,7 +3773,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3380
3773
|
`/v1/user/favorites/me${queryString}`,
|
|
3381
3774
|
options
|
|
3382
3775
|
);
|
|
3383
|
-
|
|
3776
|
+
log20("My favorites retrieved");
|
|
3384
3777
|
return result;
|
|
3385
3778
|
}
|
|
3386
3779
|
/**
|
|
@@ -3395,7 +3788,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3395
3788
|
* @returns Promise resolving to list of favorites
|
|
3396
3789
|
*/
|
|
3397
3790
|
async getUserFavorites(userId, params = {}, options) {
|
|
3398
|
-
|
|
3791
|
+
log20("Getting favorites for user: %d", userId);
|
|
3399
3792
|
const queryParams = {};
|
|
3400
3793
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3401
3794
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3405,7 +3798,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3405
3798
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
3406
3799
|
options
|
|
3407
3800
|
);
|
|
3408
|
-
|
|
3801
|
+
log20("Favorites retrieved for user: %d", userId);
|
|
3409
3802
|
return result;
|
|
3410
3803
|
}
|
|
3411
3804
|
/**
|
|
@@ -3420,7 +3813,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3420
3813
|
* @returns Promise resolving to list of favorite agents
|
|
3421
3814
|
*/
|
|
3422
3815
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
3423
|
-
|
|
3816
|
+
log20("Getting favorite agents for user: %d", userId);
|
|
3424
3817
|
const queryParams = {};
|
|
3425
3818
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3426
3819
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3429,7 +3822,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3429
3822
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
3430
3823
|
options
|
|
3431
3824
|
);
|
|
3432
|
-
|
|
3825
|
+
log20("Favorite agents retrieved for user: %d", userId);
|
|
3433
3826
|
return result;
|
|
3434
3827
|
}
|
|
3435
3828
|
/**
|
|
@@ -3444,7 +3837,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3444
3837
|
* @returns Promise resolving to list of favorite plugins
|
|
3445
3838
|
*/
|
|
3446
3839
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
3447
|
-
|
|
3840
|
+
log20("Getting favorite plugins for user: %d", userId);
|
|
3448
3841
|
const queryParams = {};
|
|
3449
3842
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3450
3843
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3453,14 +3846,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
3453
3846
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
3454
3847
|
options
|
|
3455
3848
|
);
|
|
3456
|
-
|
|
3849
|
+
log20("Favorite plugins retrieved for user: %d", userId);
|
|
3457
3850
|
return result;
|
|
3458
3851
|
}
|
|
3459
3852
|
};
|
|
3460
3853
|
|
|
3461
3854
|
// src/market/services/UserLikeService.ts
|
|
3462
|
-
import
|
|
3463
|
-
var
|
|
3855
|
+
import debug21 from "debug";
|
|
3856
|
+
var log21 = debug21("lobe-market-sdk:user-like");
|
|
3464
3857
|
var UserLikeService = class extends BaseSDK {
|
|
3465
3858
|
/**
|
|
3466
3859
|
* Like content
|
|
@@ -3475,7 +3868,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3475
3868
|
* @throws Error if already liked
|
|
3476
3869
|
*/
|
|
3477
3870
|
async like(targetType, targetId, options) {
|
|
3478
|
-
|
|
3871
|
+
log21("Liking: %s %d", targetType, targetId);
|
|
3479
3872
|
const body = { targetId, targetType };
|
|
3480
3873
|
const result = await this.request("/v1/user/likes", {
|
|
3481
3874
|
body: JSON.stringify(body),
|
|
@@ -3485,7 +3878,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3485
3878
|
method: "POST",
|
|
3486
3879
|
...options
|
|
3487
3880
|
});
|
|
3488
|
-
|
|
3881
|
+
log21("Successfully liked: %s %d", targetType, targetId);
|
|
3489
3882
|
return result;
|
|
3490
3883
|
}
|
|
3491
3884
|
/**
|
|
@@ -3501,7 +3894,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3501
3894
|
* @throws Error if like not found
|
|
3502
3895
|
*/
|
|
3503
3896
|
async unlike(targetType, targetId, options) {
|
|
3504
|
-
|
|
3897
|
+
log21("Unliking: %s %d", targetType, targetId);
|
|
3505
3898
|
const body = { targetId, targetType };
|
|
3506
3899
|
const result = await this.request("/v1/user/likes", {
|
|
3507
3900
|
body: JSON.stringify(body),
|
|
@@ -3511,7 +3904,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3511
3904
|
method: "DELETE",
|
|
3512
3905
|
...options
|
|
3513
3906
|
});
|
|
3514
|
-
|
|
3907
|
+
log21("Successfully unliked: %s %d", targetType, targetId);
|
|
3515
3908
|
return result;
|
|
3516
3909
|
}
|
|
3517
3910
|
/**
|
|
@@ -3526,7 +3919,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3526
3919
|
* @returns Promise resolving to toggle response with new like status
|
|
3527
3920
|
*/
|
|
3528
3921
|
async toggleLike(targetType, targetId, options) {
|
|
3529
|
-
|
|
3922
|
+
log21("Toggling like: %s %d", targetType, targetId);
|
|
3530
3923
|
const body = { targetId, targetType };
|
|
3531
3924
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
3532
3925
|
body: JSON.stringify(body),
|
|
@@ -3536,7 +3929,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3536
3929
|
method: "POST",
|
|
3537
3930
|
...options
|
|
3538
3931
|
});
|
|
3539
|
-
|
|
3932
|
+
log21("Like toggled, new status: %O", result);
|
|
3540
3933
|
return result;
|
|
3541
3934
|
}
|
|
3542
3935
|
/**
|
|
@@ -3551,7 +3944,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3551
3944
|
* @returns Promise resolving to like status
|
|
3552
3945
|
*/
|
|
3553
3946
|
async checkLike(targetType, targetId, options) {
|
|
3554
|
-
|
|
3947
|
+
log21("Checking like status: %s %d", targetType, targetId);
|
|
3555
3948
|
const queryString = this.buildQueryString({
|
|
3556
3949
|
targetId: String(targetId),
|
|
3557
3950
|
targetType
|
|
@@ -3560,7 +3953,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3560
3953
|
`/v1/user/likes/check${queryString}`,
|
|
3561
3954
|
options
|
|
3562
3955
|
);
|
|
3563
|
-
|
|
3956
|
+
log21("Like status retrieved: %O", result);
|
|
3564
3957
|
return result;
|
|
3565
3958
|
}
|
|
3566
3959
|
/**
|
|
@@ -3574,7 +3967,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3574
3967
|
* @returns Promise resolving to list of likes
|
|
3575
3968
|
*/
|
|
3576
3969
|
async getMyLikes(params = {}, options) {
|
|
3577
|
-
|
|
3970
|
+
log21("Getting my likes: %O", params);
|
|
3578
3971
|
const queryParams = {};
|
|
3579
3972
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3580
3973
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3584,7 +3977,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3584
3977
|
`/v1/user/likes/me${queryString}`,
|
|
3585
3978
|
options
|
|
3586
3979
|
);
|
|
3587
|
-
|
|
3980
|
+
log21("My likes retrieved");
|
|
3588
3981
|
return result;
|
|
3589
3982
|
}
|
|
3590
3983
|
/**
|
|
@@ -3599,7 +3992,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3599
3992
|
* @returns Promise resolving to list of likes
|
|
3600
3993
|
*/
|
|
3601
3994
|
async getUserLikes(userId, params = {}, options) {
|
|
3602
|
-
|
|
3995
|
+
log21("Getting likes for user: %d", userId);
|
|
3603
3996
|
const queryParams = {};
|
|
3604
3997
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3605
3998
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3609,7 +4002,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3609
4002
|
`/v1/user/likes/${userId}${queryString}`,
|
|
3610
4003
|
options
|
|
3611
4004
|
);
|
|
3612
|
-
|
|
4005
|
+
log21("Likes retrieved for user: %d", userId);
|
|
3613
4006
|
return result;
|
|
3614
4007
|
}
|
|
3615
4008
|
/**
|
|
@@ -3624,7 +4017,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3624
4017
|
* @returns Promise resolving to list of liked agents
|
|
3625
4018
|
*/
|
|
3626
4019
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
3627
|
-
|
|
4020
|
+
log21("Getting liked agents for user: %d", userId);
|
|
3628
4021
|
const queryParams = {};
|
|
3629
4022
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3630
4023
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3633,7 +4026,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3633
4026
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
3634
4027
|
options
|
|
3635
4028
|
);
|
|
3636
|
-
|
|
4029
|
+
log21("Liked agents retrieved for user: %d", userId);
|
|
3637
4030
|
return result;
|
|
3638
4031
|
}
|
|
3639
4032
|
/**
|
|
@@ -3648,7 +4041,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3648
4041
|
* @returns Promise resolving to list of liked plugins
|
|
3649
4042
|
*/
|
|
3650
4043
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
3651
|
-
|
|
4044
|
+
log21("Getting liked plugins for user: %d", userId);
|
|
3652
4045
|
const queryParams = {};
|
|
3653
4046
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
3654
4047
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -3657,13 +4050,13 @@ var UserLikeService = class extends BaseSDK {
|
|
|
3657
4050
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
3658
4051
|
options
|
|
3659
4052
|
);
|
|
3660
|
-
|
|
4053
|
+
log21("Liked plugins retrieved for user: %d", userId);
|
|
3661
4054
|
return result;
|
|
3662
4055
|
}
|
|
3663
4056
|
};
|
|
3664
4057
|
|
|
3665
4058
|
// src/market/market-sdk.ts
|
|
3666
|
-
var
|
|
4059
|
+
var log22 = debug22("lobe-market-sdk");
|
|
3667
4060
|
var MarketSDK = class extends BaseSDK {
|
|
3668
4061
|
/**
|
|
3669
4062
|
* Creates a new MarketSDK instance
|
|
@@ -3676,8 +4069,9 @@ var MarketSDK = class extends BaseSDK {
|
|
|
3676
4069
|
tokenExpiry: void 0
|
|
3677
4070
|
};
|
|
3678
4071
|
super(options, void 0, sharedTokenState);
|
|
3679
|
-
|
|
4072
|
+
log22("MarketSDK instance created");
|
|
3680
4073
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
4074
|
+
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
3681
4075
|
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
3682
4076
|
this.connect = new ConnectService(options, this.headers, sharedTokenState);
|
|
3683
4077
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
@@ -3713,7 +4107,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
3713
4107
|
* @deprecated Use auth.registerClient() instead
|
|
3714
4108
|
*/
|
|
3715
4109
|
async registerClient(request) {
|
|
3716
|
-
|
|
4110
|
+
log22("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
3717
4111
|
return this.auth.registerClient(request);
|
|
3718
4112
|
}
|
|
3719
4113
|
};
|