@lobehub/market-sdk 0.33.6 → 0.34.0-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 +516 -2
- package/dist/index.mjs +783 -350
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/admin/MarketAdmin.ts
|
|
2
|
-
import
|
|
2
|
+
import debug11 from "debug";
|
|
3
3
|
|
|
4
4
|
// src/core/BaseSDK.ts
|
|
5
5
|
import debug from "debug";
|
|
@@ -112,16 +112,41 @@ var BaseSDK = class {
|
|
|
112
112
|
this.headers["x-lobe-trust-token"] = options.trustedClientToken;
|
|
113
113
|
log("Trusted client token configured");
|
|
114
114
|
}
|
|
115
|
+
if (options.ownerAccountId !== void 0) {
|
|
116
|
+
this.headers["x-lobe-owner-account-id"] = String(options.ownerAccountId);
|
|
117
|
+
log("Owner account id configured: %d", options.ownerAccountId);
|
|
118
|
+
}
|
|
115
119
|
log("BaseSDK instance created: %O", {
|
|
116
120
|
baseUrl: this.baseUrl,
|
|
117
121
|
defaultLocale: this.defaultLocale,
|
|
118
122
|
hasApiKey: !!apiKey,
|
|
119
123
|
hasInitialAccessToken: !!this.initialAccessToken,
|
|
120
124
|
hasM2MCredentials: !!this.clientId,
|
|
125
|
+
hasOwnerAccountId: options.ownerAccountId !== void 0,
|
|
121
126
|
hasSharedTokenState: !!this.sharedTokenState,
|
|
122
127
|
hasTrustedClientToken: !!options.trustedClientToken
|
|
123
128
|
});
|
|
124
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Sets the owner account id header for subsequent requests.
|
|
132
|
+
*
|
|
133
|
+
* Mirrors the constructor `ownerAccountId` option. Useful when the
|
|
134
|
+
* organization context is not known at SDK construction time.
|
|
135
|
+
*
|
|
136
|
+
* @param ownerAccountId - The organization account id to act on behalf of
|
|
137
|
+
*/
|
|
138
|
+
setOwnerAccountId(ownerAccountId) {
|
|
139
|
+
log("Setting owner account id: %d", ownerAccountId);
|
|
140
|
+
this.headers["x-lobe-owner-account-id"] = String(ownerAccountId);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Clears the owner account id header. Subsequent requests will be
|
|
144
|
+
* attributed to the actor's personal account.
|
|
145
|
+
*/
|
|
146
|
+
clearOwnerAccountId() {
|
|
147
|
+
log("Clearing owner account id");
|
|
148
|
+
delete this.headers["x-lobe-owner-account-id"];
|
|
149
|
+
}
|
|
125
150
|
/**
|
|
126
151
|
* Sends an HTTP request to the API and handles the response
|
|
127
152
|
*
|
|
@@ -1705,8 +1730,89 @@ var PluginEnvService = class extends BaseSDK {
|
|
|
1705
1730
|
}
|
|
1706
1731
|
};
|
|
1707
1732
|
|
|
1733
|
+
// src/admin/services/OrganizationService.ts
|
|
1734
|
+
import debug10 from "debug";
|
|
1735
|
+
var log10 = debug10("lobe-market-sdk:admin:organizations");
|
|
1736
|
+
var OrganizationService = class extends BaseSDK {
|
|
1737
|
+
/**
|
|
1738
|
+
* Retrieves a paginated list of organizations with admin details
|
|
1739
|
+
*
|
|
1740
|
+
* @param params - Query parameters for filtering, search and pagination
|
|
1741
|
+
* @returns Promise resolving to the organization list response
|
|
1742
|
+
*/
|
|
1743
|
+
async getOrganizations(params = {}) {
|
|
1744
|
+
log10("Getting organizations with params: %O", params);
|
|
1745
|
+
const queryString = this.buildQueryString(params);
|
|
1746
|
+
const result = await this.request(
|
|
1747
|
+
`/admin/organizations${queryString}`
|
|
1748
|
+
);
|
|
1749
|
+
log10("Retrieved %d organizations", result.data.length);
|
|
1750
|
+
return result;
|
|
1751
|
+
}
|
|
1752
|
+
/**
|
|
1753
|
+
* Retrieves a single organization detail (profile + members + published content)
|
|
1754
|
+
*
|
|
1755
|
+
* @param id - Organization account ID
|
|
1756
|
+
* @returns Promise resolving to the organization detail
|
|
1757
|
+
*/
|
|
1758
|
+
async getOrganization(id) {
|
|
1759
|
+
log10("Getting organization detail: %d", id);
|
|
1760
|
+
return this.request(`/admin/organizations/${id}`);
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Lists an organization's members
|
|
1764
|
+
*
|
|
1765
|
+
* @param id - Organization account ID
|
|
1766
|
+
* @returns Promise resolving to the member list
|
|
1767
|
+
*/
|
|
1768
|
+
async getOrganizationMembers(id) {
|
|
1769
|
+
log10("Getting organization members: %d", id);
|
|
1770
|
+
return this.request(
|
|
1771
|
+
`/admin/organizations/${id}/members`
|
|
1772
|
+
);
|
|
1773
|
+
}
|
|
1774
|
+
/**
|
|
1775
|
+
* Updates an organization's information
|
|
1776
|
+
*
|
|
1777
|
+
* @param id - Organization account ID
|
|
1778
|
+
* @param data - Fields to update
|
|
1779
|
+
* @returns Promise resolving to the updated organization
|
|
1780
|
+
*/
|
|
1781
|
+
async updateOrganization(id, data) {
|
|
1782
|
+
log10("Updating organization: %d, data: %O", id, data);
|
|
1783
|
+
return this.request(`/admin/organizations/${id}`, {
|
|
1784
|
+
body: JSON.stringify(data),
|
|
1785
|
+
method: "PUT"
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* Archives (soft-disables) an organization
|
|
1790
|
+
*
|
|
1791
|
+
* @param id - Organization account ID
|
|
1792
|
+
* @returns Promise resolving to the archived organization
|
|
1793
|
+
*/
|
|
1794
|
+
async archiveOrganization(id) {
|
|
1795
|
+
log10("Archiving organization: %d", id);
|
|
1796
|
+
return this.request(`/admin/organizations/${id}/archive`, {
|
|
1797
|
+
method: "PATCH"
|
|
1798
|
+
});
|
|
1799
|
+
}
|
|
1800
|
+
/**
|
|
1801
|
+
* Unarchives (restores) an organization
|
|
1802
|
+
*
|
|
1803
|
+
* @param id - Organization account ID
|
|
1804
|
+
* @returns Promise resolving to the restored organization
|
|
1805
|
+
*/
|
|
1806
|
+
async unarchiveOrganization(id) {
|
|
1807
|
+
log10("Unarchiving organization: %d", id);
|
|
1808
|
+
return this.request(`/admin/organizations/${id}/unarchive`, {
|
|
1809
|
+
method: "PATCH"
|
|
1810
|
+
});
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1708
1814
|
// src/admin/MarketAdmin.ts
|
|
1709
|
-
var
|
|
1815
|
+
var log11 = debug11("lobe-market-sdk:admin");
|
|
1710
1816
|
var MarketAdmin = class extends BaseSDK {
|
|
1711
1817
|
/**
|
|
1712
1818
|
* Creates a new MarketAdmin instance
|
|
@@ -1720,11 +1826,12 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1720
1826
|
tokenExpiry: void 0
|
|
1721
1827
|
};
|
|
1722
1828
|
super({ ...options, apiKey }, void 0, sharedTokenState);
|
|
1723
|
-
|
|
1829
|
+
log11("MarketAdmin instance created");
|
|
1724
1830
|
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
1725
1831
|
this.analysis = new AnalysisService(options, this.headers, sharedTokenState);
|
|
1726
1832
|
this.dependencies = new SystemDependencyService(options, this.headers, sharedTokenState);
|
|
1727
1833
|
this.env = new PluginEnvService(options, this.headers, sharedTokenState);
|
|
1834
|
+
this.organizations = new OrganizationService(options, this.headers, sharedTokenState);
|
|
1728
1835
|
this.plugins = new PluginService(options, this.headers, sharedTokenState);
|
|
1729
1836
|
this.reviews = new ReviewService(options, this.headers, sharedTokenState);
|
|
1730
1837
|
this.settings = new SettingsService(options, this.headers, sharedTokenState);
|
|
@@ -1733,11 +1840,11 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1733
1840
|
};
|
|
1734
1841
|
|
|
1735
1842
|
// src/market/market-sdk.ts
|
|
1736
|
-
import
|
|
1843
|
+
import debug31 from "debug";
|
|
1737
1844
|
|
|
1738
1845
|
// src/market/services/AgentProfileService.ts
|
|
1739
|
-
import
|
|
1740
|
-
var
|
|
1846
|
+
import debug12 from "debug";
|
|
1847
|
+
var log12 = debug12("lobe-market-sdk:agent-profile");
|
|
1741
1848
|
var AgentProfileService = class extends BaseSDK {
|
|
1742
1849
|
/**
|
|
1743
1850
|
* Retrieves the current agent's profile
|
|
@@ -1749,9 +1856,9 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1749
1856
|
* @returns Promise resolving to the agent profile response
|
|
1750
1857
|
*/
|
|
1751
1858
|
async getProfile(options) {
|
|
1752
|
-
|
|
1859
|
+
log12("Getting agent profile");
|
|
1753
1860
|
const result = await this.request("/v1/agent/profile", options);
|
|
1754
|
-
|
|
1861
|
+
log12("Agent profile retrieved: id=%d, identifier=%s", result.agent.id, result.agent.identifier);
|
|
1755
1862
|
return result;
|
|
1756
1863
|
}
|
|
1757
1864
|
/**
|
|
@@ -1765,7 +1872,7 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1765
1872
|
* @returns Promise resolving to the updated agent profile response
|
|
1766
1873
|
*/
|
|
1767
1874
|
async updateProfile(data, options) {
|
|
1768
|
-
|
|
1875
|
+
log12("Updating agent profile: %O", data);
|
|
1769
1876
|
const result = await this.request("/v1/agent/profile", {
|
|
1770
1877
|
body: JSON.stringify(data),
|
|
1771
1878
|
headers: {
|
|
@@ -1774,14 +1881,14 @@ var AgentProfileService = class extends BaseSDK {
|
|
|
1774
1881
|
method: "PATCH",
|
|
1775
1882
|
...options
|
|
1776
1883
|
});
|
|
1777
|
-
|
|
1884
|
+
log12("Agent profile updated: id=%d, name=%s", result.agent.id, result.agent.name);
|
|
1778
1885
|
return result;
|
|
1779
1886
|
}
|
|
1780
1887
|
};
|
|
1781
1888
|
|
|
1782
1889
|
// src/market/services/AgentService.ts
|
|
1783
|
-
import
|
|
1784
|
-
var
|
|
1890
|
+
import debug13 from "debug";
|
|
1891
|
+
var log13 = debug13("lobe-market-sdk:agents");
|
|
1785
1892
|
var AgentService2 = class extends BaseSDK {
|
|
1786
1893
|
/**
|
|
1787
1894
|
* Retrieves a list of agents from the marketplace
|
|
@@ -1796,9 +1903,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1796
1903
|
const locale = params.locale || this.defaultLocale;
|
|
1797
1904
|
const queryParams = { ...params, locale };
|
|
1798
1905
|
const queryString = this.buildQueryString(queryParams);
|
|
1799
|
-
|
|
1906
|
+
log13("Getting agent list: %O", queryParams);
|
|
1800
1907
|
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
1801
|
-
|
|
1908
|
+
log13("Retrieved %d agents", result.items.length);
|
|
1802
1909
|
return result;
|
|
1803
1910
|
}
|
|
1804
1911
|
/**
|
|
@@ -1815,9 +1922,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1815
1922
|
const locale = params.locale || this.defaultLocale;
|
|
1816
1923
|
const queryParams = { ...params, locale };
|
|
1817
1924
|
const queryString = this.buildQueryString(queryParams);
|
|
1818
|
-
|
|
1925
|
+
log13("Getting own agent list: %O", queryParams);
|
|
1819
1926
|
const result = await this.request(`/v1/agents/own${queryString}`, options);
|
|
1820
|
-
|
|
1927
|
+
log13("Retrieved %d own agents", result.items.length);
|
|
1821
1928
|
return result;
|
|
1822
1929
|
}
|
|
1823
1930
|
/**
|
|
@@ -1838,12 +1945,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1838
1945
|
queryParams.version = params.version.toString();
|
|
1839
1946
|
}
|
|
1840
1947
|
const queryString = this.buildQueryString(queryParams);
|
|
1841
|
-
|
|
1948
|
+
log13("Getting agent detail: %O", { id, ...params });
|
|
1842
1949
|
const result = await this.request(
|
|
1843
1950
|
`/v1/agents/detail/${id}${queryString}`,
|
|
1844
1951
|
options
|
|
1845
1952
|
);
|
|
1846
|
-
|
|
1953
|
+
log13("Agent detail successfully retrieved: %s", id);
|
|
1847
1954
|
return result;
|
|
1848
1955
|
}
|
|
1849
1956
|
/**
|
|
@@ -1859,12 +1966,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1859
1966
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
1860
1967
|
*/
|
|
1861
1968
|
async getPublishedIdentifiers(options) {
|
|
1862
|
-
|
|
1969
|
+
log13("Getting published agent identifiers");
|
|
1863
1970
|
const result = await this.request(
|
|
1864
1971
|
"/v1/agents/identifiers",
|
|
1865
1972
|
options
|
|
1866
1973
|
);
|
|
1867
|
-
|
|
1974
|
+
log13("Retrieved %d published agent identifiers", result.length);
|
|
1868
1975
|
return result;
|
|
1869
1976
|
}
|
|
1870
1977
|
/**
|
|
@@ -1875,9 +1982,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1875
1982
|
*/
|
|
1876
1983
|
async getSitemap(params = {}, options) {
|
|
1877
1984
|
const queryString = this.buildQueryString(params);
|
|
1878
|
-
|
|
1985
|
+
log13("Getting agent sitemap%s", queryString);
|
|
1879
1986
|
const result = await this.request(`/v1/agents/sitemap${queryString}`, options);
|
|
1880
|
-
|
|
1987
|
+
log13(
|
|
1881
1988
|
"Retrieved agent sitemap page %d/%d (%d items)",
|
|
1882
1989
|
result.currentPage,
|
|
1883
1990
|
result.totalPages,
|
|
@@ -1900,12 +2007,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1900
2007
|
const locale = params.locale || this.defaultLocale;
|
|
1901
2008
|
const queryParams = { ...params, locale };
|
|
1902
2009
|
const queryString = this.buildQueryString(queryParams);
|
|
1903
|
-
|
|
2010
|
+
log13("Getting agent categories: %O", queryParams);
|
|
1904
2011
|
const result = await this.request(
|
|
1905
2012
|
`/v1/agents/categories${queryString}`,
|
|
1906
2013
|
options
|
|
1907
2014
|
);
|
|
1908
|
-
|
|
2015
|
+
log13("Retrieved %d categories", result.length);
|
|
1909
2016
|
return result;
|
|
1910
2017
|
}
|
|
1911
2018
|
/**
|
|
@@ -1919,7 +2026,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1919
2026
|
* @returns Promise resolving to the upload response
|
|
1920
2027
|
*/
|
|
1921
2028
|
async uploadAgent(agentData, options) {
|
|
1922
|
-
|
|
2029
|
+
log13("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
1923
2030
|
const result = await this.request("/v1/agents/upload", {
|
|
1924
2031
|
body: JSON.stringify(agentData),
|
|
1925
2032
|
headers: {
|
|
@@ -1928,7 +2035,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1928
2035
|
method: "POST",
|
|
1929
2036
|
...options
|
|
1930
2037
|
});
|
|
1931
|
-
|
|
2038
|
+
log13("Agent uploaded successfully: %O", result);
|
|
1932
2039
|
return result;
|
|
1933
2040
|
}
|
|
1934
2041
|
/**
|
|
@@ -1939,7 +2046,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1939
2046
|
* @returns Promise resolving to the created agent response
|
|
1940
2047
|
*/
|
|
1941
2048
|
async createAgent(agentData, options) {
|
|
1942
|
-
|
|
2049
|
+
log13("Creating agent: %s", agentData.identifier);
|
|
1943
2050
|
const result = await this.request("/v1/agents/create", {
|
|
1944
2051
|
body: JSON.stringify(agentData),
|
|
1945
2052
|
headers: {
|
|
@@ -1948,7 +2055,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1948
2055
|
method: "POST",
|
|
1949
2056
|
...options
|
|
1950
2057
|
});
|
|
1951
|
-
|
|
2058
|
+
log13("Agent created successfully: %O", result);
|
|
1952
2059
|
return result;
|
|
1953
2060
|
}
|
|
1954
2061
|
/**
|
|
@@ -1959,7 +2066,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1959
2066
|
* @returns Promise resolving to the created version response
|
|
1960
2067
|
*/
|
|
1961
2068
|
async createAgentVersion(versionData, options) {
|
|
1962
|
-
|
|
2069
|
+
log13("Creating agent version: %s", versionData.identifier);
|
|
1963
2070
|
const result = await this.request("/v1/agents/version/create", {
|
|
1964
2071
|
body: JSON.stringify(versionData),
|
|
1965
2072
|
headers: {
|
|
@@ -1968,7 +2075,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1968
2075
|
method: "POST",
|
|
1969
2076
|
...options
|
|
1970
2077
|
});
|
|
1971
|
-
|
|
2078
|
+
log13("Agent version created successfully: %O", result);
|
|
1972
2079
|
return result;
|
|
1973
2080
|
}
|
|
1974
2081
|
/**
|
|
@@ -1979,7 +2086,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1979
2086
|
* @returns Promise resolving to the modified agent response
|
|
1980
2087
|
*/
|
|
1981
2088
|
async modifyAgent(agentData, options) {
|
|
1982
|
-
|
|
2089
|
+
log13("Modifying agent: %s", agentData.identifier);
|
|
1983
2090
|
const result = await this.request("/v1/agents/modify", {
|
|
1984
2091
|
body: JSON.stringify(agentData),
|
|
1985
2092
|
headers: {
|
|
@@ -1988,7 +2095,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1988
2095
|
method: "POST",
|
|
1989
2096
|
...options
|
|
1990
2097
|
});
|
|
1991
|
-
|
|
2098
|
+
log13("Agent modified successfully: %O", result);
|
|
1992
2099
|
return result;
|
|
1993
2100
|
}
|
|
1994
2101
|
/**
|
|
@@ -1999,7 +2106,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
1999
2106
|
* @returns Promise resolving to the modified version response
|
|
2000
2107
|
*/
|
|
2001
2108
|
async modifyAgentVersion(versionData, options) {
|
|
2002
|
-
|
|
2109
|
+
log13("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
2003
2110
|
const result = await this.request("/v1/agents/version/modify", {
|
|
2004
2111
|
body: JSON.stringify(versionData),
|
|
2005
2112
|
headers: {
|
|
@@ -2008,7 +2115,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2008
2115
|
method: "POST",
|
|
2009
2116
|
...options
|
|
2010
2117
|
});
|
|
2011
|
-
|
|
2118
|
+
log13("Agent version modified successfully: %O", result);
|
|
2012
2119
|
return result;
|
|
2013
2120
|
}
|
|
2014
2121
|
/**
|
|
@@ -2019,13 +2126,13 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2019
2126
|
* @returns Promise resolving to true if agent exists, false otherwise
|
|
2020
2127
|
*/
|
|
2021
2128
|
async checkAgentExists(identifier, options) {
|
|
2022
|
-
|
|
2129
|
+
log13("Checking if agent exists: %s", identifier);
|
|
2023
2130
|
try {
|
|
2024
2131
|
await this.getAgentDetail(identifier, {}, options);
|
|
2025
|
-
|
|
2132
|
+
log13("Agent exists: %s", identifier);
|
|
2026
2133
|
return true;
|
|
2027
2134
|
} catch (e) {
|
|
2028
|
-
|
|
2135
|
+
log13("Agent does not exist: %s", identifier);
|
|
2029
2136
|
return false;
|
|
2030
2137
|
}
|
|
2031
2138
|
}
|
|
@@ -2038,7 +2145,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2038
2145
|
* @param options - Optional request init overrides
|
|
2039
2146
|
*/
|
|
2040
2147
|
async createEvent(eventData, options) {
|
|
2041
|
-
|
|
2148
|
+
log13("Recording agent event: %s for %s", eventData.event, eventData.identifier);
|
|
2042
2149
|
await this.request("/v1/agents/events", {
|
|
2043
2150
|
body: JSON.stringify(eventData),
|
|
2044
2151
|
headers: {
|
|
@@ -2059,7 +2166,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2059
2166
|
* @returns Promise resolving to the updated install count response
|
|
2060
2167
|
*/
|
|
2061
2168
|
async increaseInstallCount(identifier, options) {
|
|
2062
|
-
|
|
2169
|
+
log13("Increasing install count for agent: %s", identifier);
|
|
2063
2170
|
const result = await this.request("/v1/agents/install-count", {
|
|
2064
2171
|
body: JSON.stringify({ identifier }),
|
|
2065
2172
|
headers: {
|
|
@@ -2068,7 +2175,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2068
2175
|
method: "POST",
|
|
2069
2176
|
...options
|
|
2070
2177
|
});
|
|
2071
|
-
|
|
2178
|
+
log13("Install count increased for agent %s: %d", identifier, result.installCount);
|
|
2072
2179
|
return result;
|
|
2073
2180
|
}
|
|
2074
2181
|
/**
|
|
@@ -2083,9 +2190,9 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2083
2190
|
* @returns Promise resolving to the status change response
|
|
2084
2191
|
*/
|
|
2085
2192
|
async changeStatus(identifier, status, options) {
|
|
2086
|
-
|
|
2193
|
+
log13("Changing agent status: %s -> %s", identifier, status);
|
|
2087
2194
|
const result = await this.modifyAgent({ identifier, status }, options);
|
|
2088
|
-
|
|
2195
|
+
log13("Agent status changed: %s -> %s", identifier, result.status);
|
|
2089
2196
|
return {
|
|
2090
2197
|
identifier: result.identifier,
|
|
2091
2198
|
status: result.status,
|
|
@@ -2103,7 +2210,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2103
2210
|
* @returns Promise resolving to the status change response
|
|
2104
2211
|
*/
|
|
2105
2212
|
async publish(identifier, options) {
|
|
2106
|
-
|
|
2213
|
+
log13("Publishing agent: %s", identifier);
|
|
2107
2214
|
return this.changeStatus(identifier, "published", options);
|
|
2108
2215
|
}
|
|
2109
2216
|
/**
|
|
@@ -2118,7 +2225,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2118
2225
|
* @returns Promise resolving to the status change response
|
|
2119
2226
|
*/
|
|
2120
2227
|
async unpublish(identifier, options) {
|
|
2121
|
-
|
|
2228
|
+
log13("Unpublishing agent: %s", identifier);
|
|
2122
2229
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2123
2230
|
}
|
|
2124
2231
|
/**
|
|
@@ -2133,7 +2240,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2133
2240
|
* @returns Promise resolving to the status change response
|
|
2134
2241
|
*/
|
|
2135
2242
|
async archive(identifier, options) {
|
|
2136
|
-
|
|
2243
|
+
log13("Archiving agent: %s", identifier);
|
|
2137
2244
|
return this.changeStatus(identifier, "archived", options);
|
|
2138
2245
|
}
|
|
2139
2246
|
/**
|
|
@@ -2148,7 +2255,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2148
2255
|
* @returns Promise resolving to the status change response
|
|
2149
2256
|
*/
|
|
2150
2257
|
async deprecate(identifier, options) {
|
|
2151
|
-
|
|
2258
|
+
log13("Deprecating agent: %s", identifier);
|
|
2152
2259
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2153
2260
|
}
|
|
2154
2261
|
/**
|
|
@@ -2166,12 +2273,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2166
2273
|
const locale = params.locale || this.defaultLocale;
|
|
2167
2274
|
const queryParams = { ...params, locale };
|
|
2168
2275
|
const queryString = this.buildQueryString(queryParams);
|
|
2169
|
-
|
|
2276
|
+
log13("Getting agents by plugin: %s", params.pluginId);
|
|
2170
2277
|
const result = await this.request(
|
|
2171
2278
|
`/v1/agents/by-plugin${queryString}`,
|
|
2172
2279
|
options
|
|
2173
2280
|
);
|
|
2174
|
-
|
|
2281
|
+
log13("Retrieved %d agents for plugin %s", result.items.length, params.pluginId);
|
|
2175
2282
|
return result;
|
|
2176
2283
|
}
|
|
2177
2284
|
/**
|
|
@@ -2187,7 +2294,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2187
2294
|
* @returns Promise resolving to the fork response with new agent details
|
|
2188
2295
|
*/
|
|
2189
2296
|
async forkAgent(sourceIdentifier, forkData, options) {
|
|
2190
|
-
|
|
2297
|
+
log13("Forking agent: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2191
2298
|
const result = await this.request(`/v1/agents/${sourceIdentifier}/fork`, {
|
|
2192
2299
|
body: JSON.stringify(forkData),
|
|
2193
2300
|
headers: {
|
|
@@ -2196,7 +2303,7 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2196
2303
|
method: "POST",
|
|
2197
2304
|
...options
|
|
2198
2305
|
});
|
|
2199
|
-
|
|
2306
|
+
log13("Agent forked successfully: %s (id: %d)", result.agent.identifier, result.agent.id);
|
|
2200
2307
|
return result;
|
|
2201
2308
|
}
|
|
2202
2309
|
/**
|
|
@@ -2210,12 +2317,12 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2210
2317
|
* @returns Promise resolving to the forks list response
|
|
2211
2318
|
*/
|
|
2212
2319
|
async getAgentForks(identifier, options) {
|
|
2213
|
-
|
|
2320
|
+
log13("Getting forks for agent: %s", identifier);
|
|
2214
2321
|
const result = await this.request(
|
|
2215
2322
|
`/v1/agents/${identifier}/forks`,
|
|
2216
2323
|
options
|
|
2217
2324
|
);
|
|
2218
|
-
|
|
2325
|
+
log13("Retrieved %d forks for agent: %s", result.totalCount, identifier);
|
|
2219
2326
|
return result;
|
|
2220
2327
|
}
|
|
2221
2328
|
/**
|
|
@@ -2228,23 +2335,23 @@ var AgentService2 = class extends BaseSDK {
|
|
|
2228
2335
|
* @returns Promise resolving to the fork source response
|
|
2229
2336
|
*/
|
|
2230
2337
|
async getAgentForkSource(identifier, options) {
|
|
2231
|
-
|
|
2338
|
+
log13("Getting fork source for agent: %s", identifier);
|
|
2232
2339
|
const result = await this.request(
|
|
2233
2340
|
`/v1/agents/${identifier}/fork-source`,
|
|
2234
2341
|
options
|
|
2235
2342
|
);
|
|
2236
2343
|
if (result.source) {
|
|
2237
|
-
|
|
2344
|
+
log13("Agent %s was forked from: %s", identifier, result.source.identifier);
|
|
2238
2345
|
} else {
|
|
2239
|
-
|
|
2346
|
+
log13("Agent %s is not a fork (original agent)", identifier);
|
|
2240
2347
|
}
|
|
2241
2348
|
return result;
|
|
2242
2349
|
}
|
|
2243
2350
|
};
|
|
2244
2351
|
|
|
2245
2352
|
// src/market/services/AgentGroupService.ts
|
|
2246
|
-
import
|
|
2247
|
-
var
|
|
2353
|
+
import debug14 from "debug";
|
|
2354
|
+
var log14 = debug14("lobe-market-sdk:agent-groups");
|
|
2248
2355
|
var AgentGroupService = class extends BaseSDK {
|
|
2249
2356
|
/**
|
|
2250
2357
|
* Retrieves a list of agent groups from the marketplace
|
|
@@ -2259,12 +2366,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2259
2366
|
const locale = params.locale || this.defaultLocale;
|
|
2260
2367
|
const queryParams = { ...params, locale };
|
|
2261
2368
|
const queryString = this.buildQueryString(queryParams);
|
|
2262
|
-
|
|
2369
|
+
log14("Getting agent group list: %O", queryParams);
|
|
2263
2370
|
const result = await this.request(
|
|
2264
2371
|
`/v1/agent-groups${queryString}`,
|
|
2265
2372
|
options
|
|
2266
2373
|
);
|
|
2267
|
-
|
|
2374
|
+
log14("Retrieved %d agent groups", result.items.length);
|
|
2268
2375
|
return result;
|
|
2269
2376
|
}
|
|
2270
2377
|
/**
|
|
@@ -2281,12 +2388,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2281
2388
|
const locale = params.locale || this.defaultLocale;
|
|
2282
2389
|
const queryParams = { ...params, locale };
|
|
2283
2390
|
const queryString = this.buildQueryString(queryParams);
|
|
2284
|
-
|
|
2391
|
+
log14("Getting own agent group list: %O", queryParams);
|
|
2285
2392
|
const result = await this.request(
|
|
2286
2393
|
`/v1/agent-groups/own${queryString}`,
|
|
2287
2394
|
options
|
|
2288
2395
|
);
|
|
2289
|
-
|
|
2396
|
+
log14("Retrieved %d own agent groups", result.items.length);
|
|
2290
2397
|
return result;
|
|
2291
2398
|
}
|
|
2292
2399
|
/**
|
|
@@ -2307,12 +2414,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2307
2414
|
queryParams.version = params.version.toString();
|
|
2308
2415
|
}
|
|
2309
2416
|
const queryString = this.buildQueryString(queryParams);
|
|
2310
|
-
|
|
2417
|
+
log14("Getting agent group detail: %O", { identifier, ...params });
|
|
2311
2418
|
const result = await this.request(
|
|
2312
2419
|
`/v1/agent-groups/detail${queryString}`,
|
|
2313
2420
|
options
|
|
2314
2421
|
);
|
|
2315
|
-
|
|
2422
|
+
log14("Agent group detail successfully retrieved: %s", identifier);
|
|
2316
2423
|
return result;
|
|
2317
2424
|
}
|
|
2318
2425
|
/**
|
|
@@ -2326,7 +2433,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2326
2433
|
* @returns Promise resolving to the created agent group response
|
|
2327
2434
|
*/
|
|
2328
2435
|
async createAgentGroup(groupData, options) {
|
|
2329
|
-
|
|
2436
|
+
log14("Creating agent group: %s", groupData.identifier);
|
|
2330
2437
|
const result = await this.request("/v1/agent-groups/create", {
|
|
2331
2438
|
body: JSON.stringify(groupData),
|
|
2332
2439
|
headers: {
|
|
@@ -2335,7 +2442,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2335
2442
|
method: "POST",
|
|
2336
2443
|
...options
|
|
2337
2444
|
});
|
|
2338
|
-
|
|
2445
|
+
log14("Agent group created successfully: %O", result);
|
|
2339
2446
|
return result;
|
|
2340
2447
|
}
|
|
2341
2448
|
/**
|
|
@@ -2349,7 +2456,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2349
2456
|
* @returns Promise resolving to the created version response
|
|
2350
2457
|
*/
|
|
2351
2458
|
async createAgentGroupVersion(versionData, options) {
|
|
2352
|
-
|
|
2459
|
+
log14("Creating agent group version: %s", versionData.identifier);
|
|
2353
2460
|
const result = await this.request(
|
|
2354
2461
|
"/v1/agent-groups/version-create",
|
|
2355
2462
|
{
|
|
@@ -2361,7 +2468,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2361
2468
|
...options
|
|
2362
2469
|
}
|
|
2363
2470
|
);
|
|
2364
|
-
|
|
2471
|
+
log14("Agent group version created successfully: %O", result);
|
|
2365
2472
|
return result;
|
|
2366
2473
|
}
|
|
2367
2474
|
/**
|
|
@@ -2375,7 +2482,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2375
2482
|
* @returns Promise resolving to the modified agent group response
|
|
2376
2483
|
*/
|
|
2377
2484
|
async modifyAgentGroup(groupData, options) {
|
|
2378
|
-
|
|
2485
|
+
log14("Modifying agent group: %s", groupData.identifier);
|
|
2379
2486
|
const result = await this.request("/v1/agent-groups/modify", {
|
|
2380
2487
|
body: JSON.stringify(groupData),
|
|
2381
2488
|
headers: {
|
|
@@ -2384,7 +2491,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2384
2491
|
method: "POST",
|
|
2385
2492
|
...options
|
|
2386
2493
|
});
|
|
2387
|
-
|
|
2494
|
+
log14("Agent group modified successfully: %O", result);
|
|
2388
2495
|
return result;
|
|
2389
2496
|
}
|
|
2390
2497
|
/**
|
|
@@ -2395,13 +2502,13 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2395
2502
|
* @returns Promise resolving to true if agent group exists, false otherwise
|
|
2396
2503
|
*/
|
|
2397
2504
|
async checkAgentGroupExists(identifier, options) {
|
|
2398
|
-
|
|
2505
|
+
log14("Checking if agent group exists: %s", identifier);
|
|
2399
2506
|
try {
|
|
2400
2507
|
await this.getAgentGroupDetail(identifier, {}, options);
|
|
2401
|
-
|
|
2508
|
+
log14("Agent group exists: %s", identifier);
|
|
2402
2509
|
return true;
|
|
2403
2510
|
} catch (e) {
|
|
2404
|
-
|
|
2511
|
+
log14("Agent group does not exist: %s", identifier);
|
|
2405
2512
|
return false;
|
|
2406
2513
|
}
|
|
2407
2514
|
}
|
|
@@ -2417,9 +2524,9 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2417
2524
|
* @returns Promise resolving to the status change response
|
|
2418
2525
|
*/
|
|
2419
2526
|
async changeStatus(identifier, status, options) {
|
|
2420
|
-
|
|
2527
|
+
log14("Changing agent group status: %s -> %s", identifier, status);
|
|
2421
2528
|
const result = await this.modifyAgentGroup({ identifier, status }, options);
|
|
2422
|
-
|
|
2529
|
+
log14("Agent group status changed: %s -> %s", identifier, result.status);
|
|
2423
2530
|
return {
|
|
2424
2531
|
identifier: result.identifier,
|
|
2425
2532
|
status: result.status,
|
|
@@ -2438,7 +2545,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2438
2545
|
* @returns Promise resolving to the status change response
|
|
2439
2546
|
*/
|
|
2440
2547
|
async publish(identifier, options) {
|
|
2441
|
-
|
|
2548
|
+
log14("Publishing agent group: %s", identifier);
|
|
2442
2549
|
return this.changeStatus(identifier, "published", options);
|
|
2443
2550
|
}
|
|
2444
2551
|
/**
|
|
@@ -2453,7 +2560,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2453
2560
|
* @returns Promise resolving to the status change response
|
|
2454
2561
|
*/
|
|
2455
2562
|
async unpublish(identifier, options) {
|
|
2456
|
-
|
|
2563
|
+
log14("Unpublishing agent group: %s", identifier);
|
|
2457
2564
|
return this.changeStatus(identifier, "unpublished", options);
|
|
2458
2565
|
}
|
|
2459
2566
|
/**
|
|
@@ -2468,7 +2575,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2468
2575
|
* @returns Promise resolving to the status change response
|
|
2469
2576
|
*/
|
|
2470
2577
|
async archive(identifier, options) {
|
|
2471
|
-
|
|
2578
|
+
log14("Archiving agent group: %s", identifier);
|
|
2472
2579
|
return this.changeStatus(identifier, "archived", options);
|
|
2473
2580
|
}
|
|
2474
2581
|
/**
|
|
@@ -2483,7 +2590,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2483
2590
|
* @returns Promise resolving to the status change response
|
|
2484
2591
|
*/
|
|
2485
2592
|
async deprecate(identifier, options) {
|
|
2486
|
-
|
|
2593
|
+
log14("Deprecating agent group: %s", identifier);
|
|
2487
2594
|
return this.changeStatus(identifier, "deprecated", options);
|
|
2488
2595
|
}
|
|
2489
2596
|
/**
|
|
@@ -2499,7 +2606,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2499
2606
|
* @returns Promise resolving to the fork response with new group details
|
|
2500
2607
|
*/
|
|
2501
2608
|
async forkAgentGroup(sourceIdentifier, forkData, options) {
|
|
2502
|
-
|
|
2609
|
+
log14("Forking agent group: %s -> %s", sourceIdentifier, forkData.identifier);
|
|
2503
2610
|
const result = await this.request(
|
|
2504
2611
|
`/v1/agent-groups/${sourceIdentifier}/fork`,
|
|
2505
2612
|
{
|
|
@@ -2511,7 +2618,7 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2511
2618
|
...options
|
|
2512
2619
|
}
|
|
2513
2620
|
);
|
|
2514
|
-
|
|
2621
|
+
log14(
|
|
2515
2622
|
"Agent group forked successfully: %s (id: %d, members: %d)",
|
|
2516
2623
|
result.group.identifier,
|
|
2517
2624
|
result.group.id,
|
|
@@ -2530,12 +2637,12 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2530
2637
|
* @returns Promise resolving to the forks list response
|
|
2531
2638
|
*/
|
|
2532
2639
|
async getAgentGroupForks(identifier, options) {
|
|
2533
|
-
|
|
2640
|
+
log14("Getting forks for agent group: %s", identifier);
|
|
2534
2641
|
const result = await this.request(
|
|
2535
2642
|
`/v1/agent-groups/${identifier}/forks`,
|
|
2536
2643
|
options
|
|
2537
2644
|
);
|
|
2538
|
-
|
|
2645
|
+
log14("Retrieved %d forks for agent group: %s", result.totalCount, identifier);
|
|
2539
2646
|
return result;
|
|
2540
2647
|
}
|
|
2541
2648
|
/**
|
|
@@ -2548,24 +2655,24 @@ var AgentGroupService = class extends BaseSDK {
|
|
|
2548
2655
|
* @returns Promise resolving to the fork source response
|
|
2549
2656
|
*/
|
|
2550
2657
|
async getAgentGroupForkSource(identifier, options) {
|
|
2551
|
-
|
|
2658
|
+
log14("Getting fork source for agent group: %s", identifier);
|
|
2552
2659
|
const result = await this.request(
|
|
2553
2660
|
`/v1/agent-groups/${identifier}/fork-source`,
|
|
2554
2661
|
options
|
|
2555
2662
|
);
|
|
2556
2663
|
if (result.source) {
|
|
2557
|
-
|
|
2664
|
+
log14("Agent group %s was forked from: %s", identifier, result.source.identifier);
|
|
2558
2665
|
} else {
|
|
2559
|
-
|
|
2666
|
+
log14("Agent group %s is not a fork (original group)", identifier);
|
|
2560
2667
|
}
|
|
2561
2668
|
return result;
|
|
2562
2669
|
}
|
|
2563
2670
|
};
|
|
2564
2671
|
|
|
2565
2672
|
// src/market/services/AuthService.ts
|
|
2566
|
-
import
|
|
2673
|
+
import debug15 from "debug";
|
|
2567
2674
|
import urlJoin2 from "url-join";
|
|
2568
|
-
var
|
|
2675
|
+
var log15 = debug15("lobe-market-sdk:auth");
|
|
2569
2676
|
var _AuthService = class _AuthService extends BaseSDK {
|
|
2570
2677
|
/** Normalize token response from snake_case to camelCase fields */
|
|
2571
2678
|
static normalizeTokenResponse(data) {
|
|
@@ -2597,7 +2704,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2597
2704
|
if (grantType !== "authorization_code" && grantType !== "refresh_token") {
|
|
2598
2705
|
throw new Error(`Unsupported grant type: ${grantType}`);
|
|
2599
2706
|
}
|
|
2600
|
-
|
|
2707
|
+
log15("Exchanging OAuth token using grant_type=%s", grantType);
|
|
2601
2708
|
const tokenUrl = urlJoin2(this.baseUrl, "lobehub-oidc/token");
|
|
2602
2709
|
const params = new URLSearchParams();
|
|
2603
2710
|
params.set("grant_type", grantType);
|
|
@@ -2639,16 +2746,16 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2639
2746
|
try {
|
|
2640
2747
|
payload = await response.json();
|
|
2641
2748
|
} catch (error) {
|
|
2642
|
-
|
|
2749
|
+
log15("Failed to parse token response: %O", error);
|
|
2643
2750
|
throw new Error(`Failed to parse token response: ${response.status} ${response.statusText}`);
|
|
2644
2751
|
}
|
|
2645
2752
|
if (!response.ok) {
|
|
2646
2753
|
const errorDescription = (payload == null ? void 0 : payload.error_description) || (payload == null ? void 0 : payload.error) || response.statusText;
|
|
2647
2754
|
const errorMsg = `Token exchange failed: ${response.status} ${errorDescription}`;
|
|
2648
|
-
|
|
2755
|
+
log15("Error: %s", errorMsg);
|
|
2649
2756
|
throw new Error(errorMsg);
|
|
2650
2757
|
}
|
|
2651
|
-
|
|
2758
|
+
log15("Token exchange successful");
|
|
2652
2759
|
return _AuthService.normalizeTokenResponse(payload);
|
|
2653
2760
|
}
|
|
2654
2761
|
/**
|
|
@@ -2661,7 +2768,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2661
2768
|
* @returns Promise resolving to the user information
|
|
2662
2769
|
*/
|
|
2663
2770
|
async getUserInfo(accessToken, options) {
|
|
2664
|
-
|
|
2771
|
+
log15("Getting user info");
|
|
2665
2772
|
const userInfoUrl = urlJoin2(this.baseUrl, "lobehub-oidc/userinfo");
|
|
2666
2773
|
const response = await fetch(userInfoUrl, {
|
|
2667
2774
|
headers: {
|
|
@@ -2673,11 +2780,11 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2673
2780
|
});
|
|
2674
2781
|
if (!response.ok) {
|
|
2675
2782
|
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
2676
|
-
|
|
2783
|
+
log15("Error: %s", errorMsg);
|
|
2677
2784
|
throw new Error(errorMsg);
|
|
2678
2785
|
}
|
|
2679
2786
|
const userInfo = await response.json();
|
|
2680
|
-
|
|
2787
|
+
log15("User info retrieved successfully");
|
|
2681
2788
|
return userInfo;
|
|
2682
2789
|
}
|
|
2683
2790
|
/**
|
|
@@ -2691,7 +2798,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2691
2798
|
* @returns Promise resolving to the client credentials
|
|
2692
2799
|
*/
|
|
2693
2800
|
async registerClient(clientData, options) {
|
|
2694
|
-
|
|
2801
|
+
log15("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
2695
2802
|
const result = await this.request("/v1/clients/register", {
|
|
2696
2803
|
body: JSON.stringify(clientData),
|
|
2697
2804
|
headers: {
|
|
@@ -2700,7 +2807,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2700
2807
|
method: "POST",
|
|
2701
2808
|
...options
|
|
2702
2809
|
});
|
|
2703
|
-
|
|
2810
|
+
log15("Client registered successfully: %s", result.client_id);
|
|
2704
2811
|
return result;
|
|
2705
2812
|
}
|
|
2706
2813
|
/**
|
|
@@ -2712,9 +2819,9 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2712
2819
|
* @returns Promise resolving to the access token and expiration time
|
|
2713
2820
|
*/
|
|
2714
2821
|
async getM2MToken() {
|
|
2715
|
-
|
|
2822
|
+
log15("Fetching M2M token");
|
|
2716
2823
|
const tokenInfo = await this.fetchM2MToken();
|
|
2717
|
-
|
|
2824
|
+
log15("M2M token fetched successfully");
|
|
2718
2825
|
return tokenInfo;
|
|
2719
2826
|
}
|
|
2720
2827
|
/** OAuth handoff response shapes */
|
|
@@ -2740,7 +2847,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2740
2847
|
async getOAuthHandoff(id, options) {
|
|
2741
2848
|
var _a, _b;
|
|
2742
2849
|
if (!id) throw new Error("id is required");
|
|
2743
|
-
|
|
2850
|
+
log15("Getting OAuth handoff: %s", id);
|
|
2744
2851
|
const handoffUrl = `${urlJoin2(this.baseUrl, "lobehub-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
2745
2852
|
const response = await fetch(handoffUrl, {
|
|
2746
2853
|
headers: {
|
|
@@ -2756,19 +2863,19 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2756
2863
|
code: json.code,
|
|
2757
2864
|
redirectUri: json.redirectUri
|
|
2758
2865
|
});
|
|
2759
|
-
|
|
2866
|
+
log15("OAuth handoff success for id: %s", id);
|
|
2760
2867
|
return result;
|
|
2761
2868
|
}
|
|
2762
2869
|
if (response.status === 202) {
|
|
2763
|
-
|
|
2870
|
+
log15("OAuth handoff pending for id: %s", id);
|
|
2764
2871
|
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
2765
2872
|
}
|
|
2766
2873
|
if (response.status === 404) {
|
|
2767
|
-
|
|
2874
|
+
log15("OAuth handoff consumed for id: %s", id);
|
|
2768
2875
|
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
2769
2876
|
}
|
|
2770
2877
|
if (response.status === 410) {
|
|
2771
|
-
|
|
2878
|
+
log15("OAuth handoff expired for id: %s", id);
|
|
2772
2879
|
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
2773
2880
|
}
|
|
2774
2881
|
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
@@ -2779,7 +2886,7 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2779
2886
|
}
|
|
2780
2887
|
} catch (e) {
|
|
2781
2888
|
}
|
|
2782
|
-
|
|
2889
|
+
log15("Error: %s", errorMessage);
|
|
2783
2890
|
throw new Error(errorMessage);
|
|
2784
2891
|
}
|
|
2785
2892
|
/**
|
|
@@ -2793,21 +2900,21 @@ var _AuthService = class _AuthService extends BaseSDK {
|
|
|
2793
2900
|
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
2794
2901
|
const startedAt = Date.now();
|
|
2795
2902
|
const { signal, requestInit } = params;
|
|
2796
|
-
|
|
2903
|
+
log15("Start polling OAuth handoff: %s", id);
|
|
2797
2904
|
while (true) {
|
|
2798
2905
|
if (signal == null ? void 0 : signal.aborted) {
|
|
2799
2906
|
const err = new Error("Polling aborted");
|
|
2800
|
-
|
|
2907
|
+
log15("Error: %s", err.message);
|
|
2801
2908
|
throw err;
|
|
2802
2909
|
}
|
|
2803
2910
|
if (Date.now() - startedAt > timeoutMs) {
|
|
2804
2911
|
const err = new Error("Polling timeout");
|
|
2805
|
-
|
|
2912
|
+
log15("Error: %s", err.message);
|
|
2806
2913
|
throw err;
|
|
2807
2914
|
}
|
|
2808
2915
|
const result = await this.getOAuthHandoff(id, requestInit);
|
|
2809
2916
|
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
2810
|
-
|
|
2917
|
+
log15("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
2811
2918
|
return result;
|
|
2812
2919
|
}
|
|
2813
2920
|
await new Promise((resolve) => {
|
|
@@ -2828,9 +2935,9 @@ _AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
|
2828
2935
|
var AuthService = _AuthService;
|
|
2829
2936
|
|
|
2830
2937
|
// src/market/services/ConnectService.ts
|
|
2831
|
-
import
|
|
2938
|
+
import debug16 from "debug";
|
|
2832
2939
|
import urlJoin3 from "url-join";
|
|
2833
|
-
var
|
|
2940
|
+
var log16 = debug16("lobe-market-sdk:connect");
|
|
2834
2941
|
var ConnectService = class extends BaseSDK {
|
|
2835
2942
|
/**
|
|
2836
2943
|
* Lists all available OAuth providers
|
|
@@ -2843,9 +2950,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
2843
2950
|
*/
|
|
2844
2951
|
async listProviders(options) {
|
|
2845
2952
|
var _a;
|
|
2846
|
-
|
|
2953
|
+
log16("Listing connect providers");
|
|
2847
2954
|
const result = await this.request("/connect/providers", options);
|
|
2848
|
-
|
|
2955
|
+
log16("Found %d connect providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
2849
2956
|
return result;
|
|
2850
2957
|
}
|
|
2851
2958
|
/**
|
|
@@ -2859,12 +2966,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2859
2966
|
*/
|
|
2860
2967
|
async getProvider(provider, options) {
|
|
2861
2968
|
var _a;
|
|
2862
|
-
|
|
2969
|
+
log16("Getting provider details: %s", provider);
|
|
2863
2970
|
const result = await this.request(
|
|
2864
2971
|
`/connect/providers/${encodeURIComponent(provider)}`,
|
|
2865
2972
|
options
|
|
2866
2973
|
);
|
|
2867
|
-
|
|
2974
|
+
log16("Retrieved provider: %s", (_a = result.provider) == null ? void 0 : _a.name);
|
|
2868
2975
|
return result;
|
|
2869
2976
|
}
|
|
2870
2977
|
/**
|
|
@@ -2878,12 +2985,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2878
2985
|
* @returns Promise resolving to the CIMD client metadata document
|
|
2879
2986
|
*/
|
|
2880
2987
|
async getClientMetadata(provider, options) {
|
|
2881
|
-
|
|
2988
|
+
log16("Getting CIMD client metadata for provider: %s", provider);
|
|
2882
2989
|
const result = await this.request(
|
|
2883
2990
|
`/connect/${encodeURIComponent(provider)}/oauth/client-metadata/v1.json`,
|
|
2884
2991
|
options
|
|
2885
2992
|
);
|
|
2886
|
-
|
|
2993
|
+
log16("Retrieved CIMD client metadata: %s", result.client_id);
|
|
2887
2994
|
return result;
|
|
2888
2995
|
}
|
|
2889
2996
|
/**
|
|
@@ -2923,7 +3030,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2923
3030
|
* ```
|
|
2924
3031
|
*/
|
|
2925
3032
|
async authorize(provider, params, options) {
|
|
2926
|
-
|
|
3033
|
+
log16("Requesting authorization code for provider: %s", provider);
|
|
2927
3034
|
const result = await this.request(
|
|
2928
3035
|
`/connect/${encodeURIComponent(provider)}/authorize`,
|
|
2929
3036
|
{
|
|
@@ -2935,7 +3042,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2935
3042
|
...options
|
|
2936
3043
|
}
|
|
2937
3044
|
);
|
|
2938
|
-
|
|
3045
|
+
log16("Authorization code obtained, expires in %d seconds", result.expires_in);
|
|
2939
3046
|
return result;
|
|
2940
3047
|
}
|
|
2941
3048
|
/**
|
|
@@ -2961,7 +3068,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2961
3068
|
* ```
|
|
2962
3069
|
*/
|
|
2963
3070
|
getAuthorizeUrl(provider, params) {
|
|
2964
|
-
|
|
3071
|
+
log16(
|
|
2965
3072
|
"Generating authorize URL for provider: %s (deprecated, use authorize() instead)",
|
|
2966
3073
|
provider
|
|
2967
3074
|
);
|
|
@@ -2975,7 +3082,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
2975
3082
|
const queryString = queryParams.toString();
|
|
2976
3083
|
const path = `/connect/${encodeURIComponent(provider)}/start${queryString ? `?${queryString}` : ""}`;
|
|
2977
3084
|
const url = urlJoin3(this.baseUrl, "api", path);
|
|
2978
|
-
|
|
3085
|
+
log16("Generated authorize URL: %s", url);
|
|
2979
3086
|
return url;
|
|
2980
3087
|
}
|
|
2981
3088
|
/**
|
|
@@ -2989,12 +3096,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
2989
3096
|
* @returns Promise resolving to the connection status
|
|
2990
3097
|
*/
|
|
2991
3098
|
async getStatus(provider, options) {
|
|
2992
|
-
|
|
3099
|
+
log16("Getting connection status for provider: %s", provider);
|
|
2993
3100
|
const result = await this.request(
|
|
2994
3101
|
`/connect/${encodeURIComponent(provider)}/status`,
|
|
2995
3102
|
options
|
|
2996
3103
|
);
|
|
2997
|
-
|
|
3104
|
+
log16("Provider %s connection status: connected=%s", provider, result.connected);
|
|
2998
3105
|
return result;
|
|
2999
3106
|
}
|
|
3000
3107
|
/**
|
|
@@ -3007,9 +3114,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3007
3114
|
*/
|
|
3008
3115
|
async listConnections(options) {
|
|
3009
3116
|
var _a;
|
|
3010
|
-
|
|
3117
|
+
log16("Listing user connections");
|
|
3011
3118
|
const result = await this.request("/connect/connections", options);
|
|
3012
|
-
|
|
3119
|
+
log16("Found %d connections", ((_a = result.connections) == null ? void 0 : _a.length) || 0);
|
|
3013
3120
|
return result;
|
|
3014
3121
|
}
|
|
3015
3122
|
/**
|
|
@@ -3023,12 +3130,12 @@ var ConnectService = class extends BaseSDK {
|
|
|
3023
3130
|
* @returns Promise resolving to the connection health status
|
|
3024
3131
|
*/
|
|
3025
3132
|
async getHealth(provider, options) {
|
|
3026
|
-
|
|
3133
|
+
log16("Checking health for provider: %s", provider);
|
|
3027
3134
|
const result = await this.request(
|
|
3028
3135
|
`/connect/${encodeURIComponent(provider)}/health`,
|
|
3029
3136
|
options
|
|
3030
3137
|
);
|
|
3031
|
-
|
|
3138
|
+
log16("Provider %s health: healthy=%s, status=%s", provider, result.healthy, result.tokenStatus);
|
|
3032
3139
|
return result;
|
|
3033
3140
|
}
|
|
3034
3141
|
/**
|
|
@@ -3041,9 +3148,9 @@ var ConnectService = class extends BaseSDK {
|
|
|
3041
3148
|
*/
|
|
3042
3149
|
async getAllHealth(options) {
|
|
3043
3150
|
var _a, _b, _c;
|
|
3044
|
-
|
|
3151
|
+
log16("Checking health for all connections");
|
|
3045
3152
|
const result = await this.request("/connect/health", options);
|
|
3046
|
-
|
|
3153
|
+
log16(
|
|
3047
3154
|
"Health check complete: total=%d, healthy=%d, unhealthy=%d",
|
|
3048
3155
|
((_a = result.summary) == null ? void 0 : _a.total) || 0,
|
|
3049
3156
|
((_b = result.summary) == null ? void 0 : _b.healthy) || 0,
|
|
@@ -3062,7 +3169,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3062
3169
|
* @returns Promise resolving to the refresh result
|
|
3063
3170
|
*/
|
|
3064
3171
|
async refresh(provider, options) {
|
|
3065
|
-
|
|
3172
|
+
log16("Refreshing token for provider: %s", provider);
|
|
3066
3173
|
const result = await this.request(
|
|
3067
3174
|
`/connect/${encodeURIComponent(provider)}/refresh`,
|
|
3068
3175
|
{
|
|
@@ -3070,7 +3177,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3070
3177
|
...options
|
|
3071
3178
|
}
|
|
3072
3179
|
);
|
|
3073
|
-
|
|
3180
|
+
log16("Token refresh for %s: refreshed=%s", provider, result.refreshed);
|
|
3074
3181
|
return result;
|
|
3075
3182
|
}
|
|
3076
3183
|
/**
|
|
@@ -3084,7 +3191,7 @@ var ConnectService = class extends BaseSDK {
|
|
|
3084
3191
|
* @returns Promise resolving to the revoke result
|
|
3085
3192
|
*/
|
|
3086
3193
|
async revoke(provider, options) {
|
|
3087
|
-
|
|
3194
|
+
log16("Revoking connection for provider: %s", provider);
|
|
3088
3195
|
const result = await this.request(
|
|
3089
3196
|
`/connect/${encodeURIComponent(provider)}`,
|
|
3090
3197
|
{
|
|
@@ -3092,14 +3199,14 @@ var ConnectService = class extends BaseSDK {
|
|
|
3092
3199
|
...options
|
|
3093
3200
|
}
|
|
3094
3201
|
);
|
|
3095
|
-
|
|
3202
|
+
log16("Connection revoked for %s: success=%s", provider, result.success);
|
|
3096
3203
|
return result;
|
|
3097
3204
|
}
|
|
3098
3205
|
};
|
|
3099
3206
|
|
|
3100
3207
|
// src/market/services/CredService.ts
|
|
3101
|
-
import
|
|
3102
|
-
var
|
|
3208
|
+
import debug17 from "debug";
|
|
3209
|
+
var log17 = debug17("lobe-market-sdk:creds");
|
|
3103
3210
|
var CredService = class extends BaseSDK {
|
|
3104
3211
|
// ===========================================================================
|
|
3105
3212
|
// List & Get Operations
|
|
@@ -3115,9 +3222,9 @@ var CredService = class extends BaseSDK {
|
|
|
3115
3222
|
*/
|
|
3116
3223
|
async list(options) {
|
|
3117
3224
|
var _a;
|
|
3118
|
-
|
|
3225
|
+
log17("Listing user credentials");
|
|
3119
3226
|
const result = await this.request("/v1/user/creds", options);
|
|
3120
|
-
|
|
3227
|
+
log17("Found %d credentials", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
3121
3228
|
return result;
|
|
3122
3229
|
}
|
|
3123
3230
|
/**
|
|
@@ -3132,7 +3239,7 @@ var CredService = class extends BaseSDK {
|
|
|
3132
3239
|
* @returns Promise resolving to the credential details
|
|
3133
3240
|
*/
|
|
3134
3241
|
async get(id, getOptions, options) {
|
|
3135
|
-
|
|
3242
|
+
log17("Getting credential: %d (decrypt=%s)", id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
3136
3243
|
const queryParams = {};
|
|
3137
3244
|
if (getOptions == null ? void 0 : getOptions.decrypt) {
|
|
3138
3245
|
queryParams.decrypt = "true";
|
|
@@ -3142,7 +3249,7 @@ var CredService = class extends BaseSDK {
|
|
|
3142
3249
|
`/v1/user/creds/${id}${queryString}`,
|
|
3143
3250
|
options
|
|
3144
3251
|
);
|
|
3145
|
-
|
|
3252
|
+
log17("Retrieved credential: %s", result.key);
|
|
3146
3253
|
return result;
|
|
3147
3254
|
}
|
|
3148
3255
|
// ===========================================================================
|
|
@@ -3161,7 +3268,7 @@ var CredService = class extends BaseSDK {
|
|
|
3161
3268
|
* @returns Promise resolving to the created credential
|
|
3162
3269
|
*/
|
|
3163
3270
|
async createKV(data, options) {
|
|
3164
|
-
|
|
3271
|
+
log17("Creating KV credential: %s (type=%s)", data.key, data.type);
|
|
3165
3272
|
const result = await this.request("/v1/user/creds/kv", {
|
|
3166
3273
|
body: JSON.stringify(data),
|
|
3167
3274
|
headers: {
|
|
@@ -3170,7 +3277,7 @@ var CredService = class extends BaseSDK {
|
|
|
3170
3277
|
method: "POST",
|
|
3171
3278
|
...options
|
|
3172
3279
|
});
|
|
3173
|
-
|
|
3280
|
+
log17("Created KV credential: %d", result.id);
|
|
3174
3281
|
return result;
|
|
3175
3282
|
}
|
|
3176
3283
|
/**
|
|
@@ -3184,7 +3291,7 @@ var CredService = class extends BaseSDK {
|
|
|
3184
3291
|
* @returns Promise resolving to the created credential
|
|
3185
3292
|
*/
|
|
3186
3293
|
async createOAuth(data, options) {
|
|
3187
|
-
|
|
3294
|
+
log17("Creating OAuth credential: %s (connectionId=%d)", data.key, data.oauthConnectionId);
|
|
3188
3295
|
const result = await this.request("/v1/user/creds/oauth", {
|
|
3189
3296
|
body: JSON.stringify(data),
|
|
3190
3297
|
headers: {
|
|
@@ -3193,7 +3300,7 @@ var CredService = class extends BaseSDK {
|
|
|
3193
3300
|
method: "POST",
|
|
3194
3301
|
...options
|
|
3195
3302
|
});
|
|
3196
|
-
|
|
3303
|
+
log17("Created OAuth credential: %d", result.id);
|
|
3197
3304
|
return result;
|
|
3198
3305
|
}
|
|
3199
3306
|
/**
|
|
@@ -3207,7 +3314,7 @@ var CredService = class extends BaseSDK {
|
|
|
3207
3314
|
* @returns Promise resolving to the created credential
|
|
3208
3315
|
*/
|
|
3209
3316
|
async createFile(data, options) {
|
|
3210
|
-
|
|
3317
|
+
log17("Creating file credential: %s (fileName=%s)", data.key, data.fileName);
|
|
3211
3318
|
const result = await this.request("/v1/user/creds/file", {
|
|
3212
3319
|
body: JSON.stringify(data),
|
|
3213
3320
|
headers: {
|
|
@@ -3216,7 +3323,7 @@ var CredService = class extends BaseSDK {
|
|
|
3216
3323
|
method: "POST",
|
|
3217
3324
|
...options
|
|
3218
3325
|
});
|
|
3219
|
-
|
|
3326
|
+
log17("Created file credential: %d", result.id);
|
|
3220
3327
|
return result;
|
|
3221
3328
|
}
|
|
3222
3329
|
// ===========================================================================
|
|
@@ -3234,7 +3341,7 @@ var CredService = class extends BaseSDK {
|
|
|
3234
3341
|
* @returns Promise resolving to the updated credential
|
|
3235
3342
|
*/
|
|
3236
3343
|
async update(id, data, options) {
|
|
3237
|
-
|
|
3344
|
+
log17("Updating credential: %d", id);
|
|
3238
3345
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3239
3346
|
body: JSON.stringify(data),
|
|
3240
3347
|
headers: {
|
|
@@ -3243,7 +3350,7 @@ var CredService = class extends BaseSDK {
|
|
|
3243
3350
|
method: "PATCH",
|
|
3244
3351
|
...options
|
|
3245
3352
|
});
|
|
3246
|
-
|
|
3353
|
+
log17("Updated credential: %d", result.id);
|
|
3247
3354
|
return result;
|
|
3248
3355
|
}
|
|
3249
3356
|
// ===========================================================================
|
|
@@ -3259,12 +3366,12 @@ var CredService = class extends BaseSDK {
|
|
|
3259
3366
|
* @returns Promise resolving to the delete result
|
|
3260
3367
|
*/
|
|
3261
3368
|
async delete(id, options) {
|
|
3262
|
-
|
|
3369
|
+
log17("Deleting credential by ID: %d", id);
|
|
3263
3370
|
const result = await this.request(`/v1/user/creds/${id}`, {
|
|
3264
3371
|
method: "DELETE",
|
|
3265
3372
|
...options
|
|
3266
3373
|
});
|
|
3267
|
-
|
|
3374
|
+
log17("Deleted credential: %d, success=%s", id, result.success);
|
|
3268
3375
|
return result;
|
|
3269
3376
|
}
|
|
3270
3377
|
/**
|
|
@@ -3278,7 +3385,7 @@ var CredService = class extends BaseSDK {
|
|
|
3278
3385
|
* @returns Promise resolving to the delete result
|
|
3279
3386
|
*/
|
|
3280
3387
|
async deleteByKey(key, options) {
|
|
3281
|
-
|
|
3388
|
+
log17("Deleting credential by key: %s", key);
|
|
3282
3389
|
const result = await this.request(
|
|
3283
3390
|
`/v1/user/creds/key/${encodeURIComponent(key)}`,
|
|
3284
3391
|
{
|
|
@@ -3286,7 +3393,7 @@ var CredService = class extends BaseSDK {
|
|
|
3286
3393
|
...options
|
|
3287
3394
|
}
|
|
3288
3395
|
);
|
|
3289
|
-
|
|
3396
|
+
log17("Deleted credential by key: %s, success=%s", key, result.success);
|
|
3290
3397
|
return result;
|
|
3291
3398
|
}
|
|
3292
3399
|
// ===========================================================================
|
|
@@ -3305,12 +3412,12 @@ var CredService = class extends BaseSDK {
|
|
|
3305
3412
|
* @returns Promise resolving to the credential status list
|
|
3306
3413
|
*/
|
|
3307
3414
|
async getSkillCredStatus(skillIdentifier, options) {
|
|
3308
|
-
|
|
3415
|
+
log17("Getting skill cred status: %s", skillIdentifier);
|
|
3309
3416
|
const result = await this.request(
|
|
3310
3417
|
`/v1/skills/${encodeURIComponent(skillIdentifier)}/creds/status`,
|
|
3311
3418
|
options
|
|
3312
3419
|
);
|
|
3313
|
-
|
|
3420
|
+
log17("Skill %s has %d credential requirements", skillIdentifier, result.length);
|
|
3314
3421
|
return result;
|
|
3315
3422
|
}
|
|
3316
3423
|
// ===========================================================================
|
|
@@ -3349,7 +3456,7 @@ var CredService = class extends BaseSDK {
|
|
|
3349
3456
|
*/
|
|
3350
3457
|
async inject(request, options) {
|
|
3351
3458
|
var _a, _b, _c, _d;
|
|
3352
|
-
|
|
3459
|
+
log17("Injecting credentials by keys: %O (sandbox=%s)", request.keys, request.sandbox);
|
|
3353
3460
|
const result = await this.request(
|
|
3354
3461
|
"/v1/plugins/run-buildin-tools/inject-creds",
|
|
3355
3462
|
{
|
|
@@ -3361,7 +3468,7 @@ var CredService = class extends BaseSDK {
|
|
|
3361
3468
|
...options
|
|
3362
3469
|
}
|
|
3363
3470
|
);
|
|
3364
|
-
|
|
3471
|
+
log17(
|
|
3365
3472
|
"Inject result: success=%s, env=%d, files=%d, notFound=%d",
|
|
3366
3473
|
result.success,
|
|
3367
3474
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3403,7 +3510,7 @@ var CredService = class extends BaseSDK {
|
|
|
3403
3510
|
*/
|
|
3404
3511
|
async injectForSkill(request, options) {
|
|
3405
3512
|
var _a, _b, _c, _d;
|
|
3406
|
-
|
|
3513
|
+
log17(
|
|
3407
3514
|
"Injecting credentials for skill: %s (sandbox=%s)",
|
|
3408
3515
|
request.skillIdentifier,
|
|
3409
3516
|
request.sandbox
|
|
@@ -3419,7 +3526,7 @@ var CredService = class extends BaseSDK {
|
|
|
3419
3526
|
...options
|
|
3420
3527
|
}
|
|
3421
3528
|
);
|
|
3422
|
-
|
|
3529
|
+
log17(
|
|
3423
3530
|
"Inject result: success=%s, env=%d, files=%d, missing=%d",
|
|
3424
3531
|
result.success,
|
|
3425
3532
|
Object.keys(((_a = result.credentials) == null ? void 0 : _a.env) || {}).length,
|
|
@@ -3431,9 +3538,9 @@ var CredService = class extends BaseSDK {
|
|
|
3431
3538
|
};
|
|
3432
3539
|
|
|
3433
3540
|
// src/market/services/DiscoveryService.ts
|
|
3434
|
-
import
|
|
3541
|
+
import debug18 from "debug";
|
|
3435
3542
|
import urlJoin4 from "url-join";
|
|
3436
|
-
var
|
|
3543
|
+
var log18 = debug18("lobe-market-sdk:discovery");
|
|
3437
3544
|
var DiscoveryService = class extends BaseSDK {
|
|
3438
3545
|
/**
|
|
3439
3546
|
* Retrieves the service discovery document
|
|
@@ -3445,9 +3552,9 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3445
3552
|
* @returns Promise resolving to the service discovery document
|
|
3446
3553
|
*/
|
|
3447
3554
|
async getDiscoveryDocument() {
|
|
3448
|
-
|
|
3555
|
+
log18("Fetching discovery document");
|
|
3449
3556
|
if (this.discoveryDoc) {
|
|
3450
|
-
|
|
3557
|
+
log18("Returning cached discovery document");
|
|
3451
3558
|
return this.discoveryDoc;
|
|
3452
3559
|
}
|
|
3453
3560
|
const res = await fetch(urlJoin4(this.baseUrl, "/.well-known/discovery"));
|
|
@@ -3455,14 +3562,14 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
3455
3562
|
throw new Error(await res.text());
|
|
3456
3563
|
}
|
|
3457
3564
|
this.discoveryDoc = await res.json();
|
|
3458
|
-
|
|
3565
|
+
log18("Discovery document successfully fetched");
|
|
3459
3566
|
return this.discoveryDoc;
|
|
3460
3567
|
}
|
|
3461
3568
|
};
|
|
3462
3569
|
|
|
3463
3570
|
// src/market/services/FeedbackService.ts
|
|
3464
|
-
import
|
|
3465
|
-
var
|
|
3571
|
+
import debug19 from "debug";
|
|
3572
|
+
var log19 = debug19("lobe-market-sdk:feedback");
|
|
3466
3573
|
var FeedbackService = class extends BaseSDK {
|
|
3467
3574
|
/**
|
|
3468
3575
|
* Submits user feedback
|
|
@@ -3492,7 +3599,7 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3492
3599
|
* ```
|
|
3493
3600
|
*/
|
|
3494
3601
|
async submitFeedback(data, options) {
|
|
3495
|
-
|
|
3602
|
+
log19("Submitting feedback: %s", data.title);
|
|
3496
3603
|
const result = await this.request("/v1/user/feedback", {
|
|
3497
3604
|
body: JSON.stringify(data),
|
|
3498
3605
|
headers: {
|
|
@@ -3501,14 +3608,14 @@ var FeedbackService = class extends BaseSDK {
|
|
|
3501
3608
|
method: "POST",
|
|
3502
3609
|
...options
|
|
3503
3610
|
});
|
|
3504
|
-
|
|
3611
|
+
log19("Feedback submitted successfully: %s", result.issueId);
|
|
3505
3612
|
return result;
|
|
3506
3613
|
}
|
|
3507
3614
|
};
|
|
3508
3615
|
|
|
3509
3616
|
// src/market/services/PluginsService.ts
|
|
3510
|
-
import
|
|
3511
|
-
var
|
|
3617
|
+
import debug20 from "debug";
|
|
3618
|
+
var log20 = debug20("lobe-market-sdk:plugins");
|
|
3512
3619
|
var PluginsService = class extends BaseSDK {
|
|
3513
3620
|
/**
|
|
3514
3621
|
* Retrieves a list of plugins from the marketplace
|
|
@@ -3523,9 +3630,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
3523
3630
|
const locale = params.locale || this.defaultLocale;
|
|
3524
3631
|
const queryParams = { ...params, locale };
|
|
3525
3632
|
const queryString = this.buildQueryString(queryParams);
|
|
3526
|
-
|
|
3633
|
+
log20("Getting plugin list: %O", queryParams);
|
|
3527
3634
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
3528
|
-
|
|
3635
|
+
log20("Retrieved %d plugins", result.items.length);
|
|
3529
3636
|
return result;
|
|
3530
3637
|
}
|
|
3531
3638
|
/**
|
|
@@ -3543,12 +3650,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3543
3650
|
const locale = params.locale || this.defaultLocale;
|
|
3544
3651
|
const queryParams = { ...params, locale };
|
|
3545
3652
|
const queryString = this.buildQueryString(queryParams);
|
|
3546
|
-
|
|
3653
|
+
log20("Getting plugin categories: %O", queryParams);
|
|
3547
3654
|
const result = await this.request(
|
|
3548
3655
|
`/v1/plugins/categories${queryString}`,
|
|
3549
3656
|
options
|
|
3550
3657
|
);
|
|
3551
|
-
|
|
3658
|
+
log20("Retrieved %d categories", result.length);
|
|
3552
3659
|
return result;
|
|
3553
3660
|
}
|
|
3554
3661
|
/**
|
|
@@ -3562,12 +3669,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3562
3669
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
3563
3670
|
*/
|
|
3564
3671
|
async getPublishedIdentifiers(options) {
|
|
3565
|
-
|
|
3672
|
+
log20("Getting published plugin identifiers");
|
|
3566
3673
|
const result = await this.request(
|
|
3567
3674
|
"/v1/plugins/identifiers",
|
|
3568
3675
|
options
|
|
3569
3676
|
);
|
|
3570
|
-
|
|
3677
|
+
log20("Retrieved %d published plugin identifiers", result.length);
|
|
3571
3678
|
return result;
|
|
3572
3679
|
}
|
|
3573
3680
|
/**
|
|
@@ -3578,12 +3685,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3578
3685
|
*/
|
|
3579
3686
|
async getSitemap(params = {}, options) {
|
|
3580
3687
|
const queryString = this.buildQueryString(params);
|
|
3581
|
-
|
|
3688
|
+
log20("Getting plugin sitemap%s", queryString);
|
|
3582
3689
|
const result = await this.request(
|
|
3583
3690
|
`/v1/plugins/sitemap${queryString}`,
|
|
3584
3691
|
options
|
|
3585
3692
|
);
|
|
3586
|
-
|
|
3693
|
+
log20(
|
|
3587
3694
|
"Retrieved plugin sitemap page %d/%d (%d items)",
|
|
3588
3695
|
result.currentPage,
|
|
3589
3696
|
result.totalPages,
|
|
@@ -3608,7 +3715,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3608
3715
|
version,
|
|
3609
3716
|
identifier
|
|
3610
3717
|
}, options) {
|
|
3611
|
-
|
|
3718
|
+
log20("Getting plugin manifest: %O", { identifier, locale, version });
|
|
3612
3719
|
const localeParam = locale || this.defaultLocale;
|
|
3613
3720
|
const params = { locale: localeParam };
|
|
3614
3721
|
if (version) {
|
|
@@ -3619,7 +3726,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3619
3726
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
3620
3727
|
options
|
|
3621
3728
|
);
|
|
3622
|
-
|
|
3729
|
+
log20("Plugin manifest successfully retrieved: %s", identifier);
|
|
3623
3730
|
return manifest;
|
|
3624
3731
|
}
|
|
3625
3732
|
/**
|
|
@@ -3636,7 +3743,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3636
3743
|
version,
|
|
3637
3744
|
identifier
|
|
3638
3745
|
}, options) {
|
|
3639
|
-
|
|
3746
|
+
log20("Getting plugin detail: %O", { identifier, locale, version });
|
|
3640
3747
|
const localeParam = locale || this.defaultLocale;
|
|
3641
3748
|
const params = { locale: localeParam };
|
|
3642
3749
|
if (version) {
|
|
@@ -3647,7 +3754,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3647
3754
|
`/v1/plugins/${identifier}${queryString}`,
|
|
3648
3755
|
options
|
|
3649
3756
|
);
|
|
3650
|
-
|
|
3757
|
+
log20("Plugin manifest successfully retrieved: %s", identifier);
|
|
3651
3758
|
return manifest;
|
|
3652
3759
|
}
|
|
3653
3760
|
/**
|
|
@@ -3662,7 +3769,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3662
3769
|
*
|
|
3663
3770
|
*/
|
|
3664
3771
|
async reportInstallation(reportData) {
|
|
3665
|
-
|
|
3772
|
+
log20("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
3666
3773
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
3667
3774
|
body: JSON.stringify(reportData),
|
|
3668
3775
|
headers: {
|
|
@@ -3670,7 +3777,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3670
3777
|
},
|
|
3671
3778
|
method: "POST"
|
|
3672
3779
|
});
|
|
3673
|
-
|
|
3780
|
+
log20("Installation report submitted successfully: %O", result);
|
|
3674
3781
|
return result;
|
|
3675
3782
|
}
|
|
3676
3783
|
/**
|
|
@@ -3684,7 +3791,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3684
3791
|
* @returns Promise resolving to the report submission response
|
|
3685
3792
|
*/
|
|
3686
3793
|
async reportCall(reportData) {
|
|
3687
|
-
|
|
3794
|
+
log20(
|
|
3688
3795
|
"Reporting call for %s@%s - %s:%s",
|
|
3689
3796
|
reportData.identifier,
|
|
3690
3797
|
reportData.version,
|
|
@@ -3698,7 +3805,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3698
3805
|
},
|
|
3699
3806
|
method: "POST"
|
|
3700
3807
|
});
|
|
3701
|
-
|
|
3808
|
+
log20("Call report submitted successfully: %O", result);
|
|
3702
3809
|
return result;
|
|
3703
3810
|
}
|
|
3704
3811
|
/**
|
|
@@ -3710,7 +3817,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3710
3817
|
* @param options - Optional request init overrides
|
|
3711
3818
|
*/
|
|
3712
3819
|
async createEvent(eventData, options) {
|
|
3713
|
-
|
|
3820
|
+
log20("Recording plugin event: %s for %s", eventData.event, eventData.identifier);
|
|
3714
3821
|
await this.request("/v1/plugins/events", {
|
|
3715
3822
|
body: JSON.stringify(eventData),
|
|
3716
3823
|
headers: {
|
|
@@ -3740,7 +3847,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3740
3847
|
* ```
|
|
3741
3848
|
*/
|
|
3742
3849
|
async callCloudGateway(request, options) {
|
|
3743
|
-
|
|
3850
|
+
log20("Calling cloud gateway for plugin %s, tool %s", request.identifier, request.toolName);
|
|
3744
3851
|
const result = await this.request("/v1/plugins/cloud-gateway", {
|
|
3745
3852
|
body: JSON.stringify(request),
|
|
3746
3853
|
headers: {
|
|
@@ -3749,7 +3856,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3749
3856
|
method: "POST",
|
|
3750
3857
|
...options
|
|
3751
3858
|
});
|
|
3752
|
-
|
|
3859
|
+
log20("Cloud gateway call completed: %O", {
|
|
3753
3860
|
identifier: request.identifier,
|
|
3754
3861
|
isError: result.isError,
|
|
3755
3862
|
toolName: request.toolName
|
|
@@ -3790,7 +3897,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3790
3897
|
* ```
|
|
3791
3898
|
*/
|
|
3792
3899
|
async runBuildInTool(toolName, params, context, options) {
|
|
3793
|
-
|
|
3900
|
+
log20(
|
|
3794
3901
|
"Running built-in tool: %s for user %s, topic %s",
|
|
3795
3902
|
toolName,
|
|
3796
3903
|
context.userId,
|
|
@@ -3809,7 +3916,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3809
3916
|
method: "POST",
|
|
3810
3917
|
...options
|
|
3811
3918
|
});
|
|
3812
|
-
|
|
3919
|
+
log20("Built-in tool execution completed: %O", {
|
|
3813
3920
|
success: result.success,
|
|
3814
3921
|
toolName
|
|
3815
3922
|
});
|
|
@@ -3922,7 +4029,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3922
4029
|
* @returns Promise resolving to the submitted score
|
|
3923
4030
|
*/
|
|
3924
4031
|
async submitRating(identifier, score, options) {
|
|
3925
|
-
|
|
4032
|
+
log20("Submitting rating for plugin %s: %d", identifier, score);
|
|
3926
4033
|
const result = await this.request(
|
|
3927
4034
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
3928
4035
|
{
|
|
@@ -3931,7 +4038,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3931
4038
|
method: "POST"
|
|
3932
4039
|
}
|
|
3933
4040
|
);
|
|
3934
|
-
|
|
4041
|
+
log20("Rating submitted for plugin %s: %d", identifier, result.score);
|
|
3935
4042
|
return result;
|
|
3936
4043
|
}
|
|
3937
4044
|
/**
|
|
@@ -3942,7 +4049,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3942
4049
|
* @returns Promise resolving to success status
|
|
3943
4050
|
*/
|
|
3944
4051
|
async deleteRating(identifier, options) {
|
|
3945
|
-
|
|
4052
|
+
log20("Deleting rating for plugin %s", identifier);
|
|
3946
4053
|
const result = await this.request(
|
|
3947
4054
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings`,
|
|
3948
4055
|
{
|
|
@@ -3950,7 +4057,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
3950
4057
|
method: "DELETE"
|
|
3951
4058
|
}
|
|
3952
4059
|
);
|
|
3953
|
-
|
|
4060
|
+
log20("Rating deleted for plugin %s", identifier);
|
|
3954
4061
|
return result;
|
|
3955
4062
|
}
|
|
3956
4063
|
/**
|
|
@@ -3961,12 +4068,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3961
4068
|
* @returns Promise resolving to the rating distribution
|
|
3962
4069
|
*/
|
|
3963
4070
|
async getRatingDistribution(identifier, options) {
|
|
3964
|
-
|
|
4071
|
+
log20("Getting rating distribution for plugin: %s", identifier);
|
|
3965
4072
|
const result = await this.request(
|
|
3966
4073
|
`/v1/plugins/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
3967
4074
|
options
|
|
3968
4075
|
);
|
|
3969
|
-
|
|
4076
|
+
log20("Rating distribution retrieved for plugin %s: %d total", identifier, result.totalCount);
|
|
3970
4077
|
return result;
|
|
3971
4078
|
}
|
|
3972
4079
|
// ============================================================================
|
|
@@ -3982,12 +4089,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
3982
4089
|
*/
|
|
3983
4090
|
async getComments(identifier, params = {}, options) {
|
|
3984
4091
|
const queryString = this.buildQueryString(params);
|
|
3985
|
-
|
|
4092
|
+
log20("Getting comments for plugin %s: %O", identifier, params);
|
|
3986
4093
|
const result = await this.request(
|
|
3987
4094
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
3988
4095
|
options
|
|
3989
4096
|
);
|
|
3990
|
-
|
|
4097
|
+
log20(
|
|
3991
4098
|
"Retrieved %d comments for plugin %s (page %d/%d)",
|
|
3992
4099
|
result.items.length,
|
|
3993
4100
|
identifier,
|
|
@@ -4004,15 +4111,15 @@ var PluginsService = class extends BaseSDK {
|
|
|
4004
4111
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4005
4112
|
*/
|
|
4006
4113
|
async getLatestOwnComment(identifier, options) {
|
|
4007
|
-
|
|
4114
|
+
log20("Getting latest own comment for plugin %s", identifier);
|
|
4008
4115
|
const result = await this.request(
|
|
4009
4116
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4010
4117
|
options
|
|
4011
4118
|
);
|
|
4012
4119
|
if (result) {
|
|
4013
|
-
|
|
4120
|
+
log20("Retrieved latest own comment for plugin %s: id=%d", identifier, result.id);
|
|
4014
4121
|
} else {
|
|
4015
|
-
|
|
4122
|
+
log20("No own comments found for plugin %s", identifier);
|
|
4016
4123
|
}
|
|
4017
4124
|
return result;
|
|
4018
4125
|
}
|
|
@@ -4025,7 +4132,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4025
4132
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4026
4133
|
*/
|
|
4027
4134
|
async createComment(identifier, data, options) {
|
|
4028
|
-
|
|
4135
|
+
log20("Creating comment on plugin %s", identifier);
|
|
4029
4136
|
const result = await this.request(
|
|
4030
4137
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments`,
|
|
4031
4138
|
{
|
|
@@ -4034,7 +4141,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4034
4141
|
method: "POST"
|
|
4035
4142
|
}
|
|
4036
4143
|
);
|
|
4037
|
-
|
|
4144
|
+
log20("Comment created on plugin %s: id=%d", identifier, result.id);
|
|
4038
4145
|
return result;
|
|
4039
4146
|
}
|
|
4040
4147
|
/**
|
|
@@ -4046,7 +4153,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4046
4153
|
* @returns Promise resolving to success status
|
|
4047
4154
|
*/
|
|
4048
4155
|
async deleteComment(identifier, commentId, options) {
|
|
4049
|
-
|
|
4156
|
+
log20("Deleting comment %d from plugin %s", commentId, identifier);
|
|
4050
4157
|
const result = await this.request(
|
|
4051
4158
|
`/v1/plugins/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4052
4159
|
{
|
|
@@ -4054,7 +4161,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4054
4161
|
method: "DELETE"
|
|
4055
4162
|
}
|
|
4056
4163
|
);
|
|
4057
|
-
|
|
4164
|
+
log20("Comment %d deleted from plugin %s", commentId, identifier);
|
|
4058
4165
|
return result;
|
|
4059
4166
|
}
|
|
4060
4167
|
// ============================================================================
|
|
@@ -4069,7 +4176,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4069
4176
|
* @returns Promise resolving to the created reaction
|
|
4070
4177
|
*/
|
|
4071
4178
|
async addReaction(commentId, type, options) {
|
|
4072
|
-
|
|
4179
|
+
log20("Adding %s reaction to comment %d", type, commentId);
|
|
4073
4180
|
const result = await this.request(
|
|
4074
4181
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4075
4182
|
{
|
|
@@ -4078,7 +4185,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4078
4185
|
method: "POST"
|
|
4079
4186
|
}
|
|
4080
4187
|
);
|
|
4081
|
-
|
|
4188
|
+
log20("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4082
4189
|
return result;
|
|
4083
4190
|
}
|
|
4084
4191
|
/**
|
|
@@ -4089,7 +4196,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
4089
4196
|
* @returns Promise resolving to success status
|
|
4090
4197
|
*/
|
|
4091
4198
|
async removeReaction(commentId, options) {
|
|
4092
|
-
|
|
4199
|
+
log20("Removing reaction from comment %d", commentId);
|
|
4093
4200
|
const result = await this.request(
|
|
4094
4201
|
`/v1/plugins/comments/${commentId}/reactions`,
|
|
4095
4202
|
{
|
|
@@ -4097,14 +4204,14 @@ var PluginsService = class extends BaseSDK {
|
|
|
4097
4204
|
method: "DELETE"
|
|
4098
4205
|
}
|
|
4099
4206
|
);
|
|
4100
|
-
|
|
4207
|
+
log20("Reaction removed from comment %d", commentId);
|
|
4101
4208
|
return result;
|
|
4102
4209
|
}
|
|
4103
4210
|
};
|
|
4104
4211
|
|
|
4105
4212
|
// src/market/services/SkillService.ts
|
|
4106
|
-
import
|
|
4107
|
-
var
|
|
4213
|
+
import debug21 from "debug";
|
|
4214
|
+
var log21 = debug21("lobe-market-sdk:skill");
|
|
4108
4215
|
var SkillService = class extends BaseSDK {
|
|
4109
4216
|
/**
|
|
4110
4217
|
* Lists all available skill providers
|
|
@@ -4117,9 +4224,9 @@ var SkillService = class extends BaseSDK {
|
|
|
4117
4224
|
*/
|
|
4118
4225
|
async listProviders(options) {
|
|
4119
4226
|
var _a;
|
|
4120
|
-
|
|
4227
|
+
log21("Listing skill providers");
|
|
4121
4228
|
const result = await this.request("/v1/skill/providers", options);
|
|
4122
|
-
|
|
4229
|
+
log21("Found %d skill providers", ((_a = result.providers) == null ? void 0 : _a.length) || 0);
|
|
4123
4230
|
return result;
|
|
4124
4231
|
}
|
|
4125
4232
|
/**
|
|
@@ -4134,12 +4241,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4134
4241
|
*/
|
|
4135
4242
|
async listTools(provider, options) {
|
|
4136
4243
|
var _a;
|
|
4137
|
-
|
|
4244
|
+
log21("Listing tools for provider: %s", provider);
|
|
4138
4245
|
const result = await this.request(
|
|
4139
4246
|
`/v1/skill/${encodeURIComponent(provider)}/tools`,
|
|
4140
4247
|
options
|
|
4141
4248
|
);
|
|
4142
|
-
|
|
4249
|
+
log21("Found %d tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4143
4250
|
return result;
|
|
4144
4251
|
}
|
|
4145
4252
|
/**
|
|
@@ -4156,12 +4263,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4156
4263
|
*/
|
|
4157
4264
|
async listLiveTools(provider, options) {
|
|
4158
4265
|
var _a;
|
|
4159
|
-
|
|
4266
|
+
log21("Listing live tools for provider: %s", provider);
|
|
4160
4267
|
const result = await this.request(
|
|
4161
4268
|
`/v1/skill/${encodeURIComponent(provider)}/tools/live`,
|
|
4162
4269
|
options
|
|
4163
4270
|
);
|
|
4164
|
-
|
|
4271
|
+
log21("Found %d live tools for provider %s", ((_a = result.tools) == null ? void 0 : _a.length) || 0, provider);
|
|
4165
4272
|
return result;
|
|
4166
4273
|
}
|
|
4167
4274
|
/**
|
|
@@ -4177,12 +4284,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4177
4284
|
*/
|
|
4178
4285
|
async getTool(provider, toolName, options) {
|
|
4179
4286
|
var _a;
|
|
4180
|
-
|
|
4287
|
+
log21("Getting tool %s from provider %s", toolName, provider);
|
|
4181
4288
|
const result = await this.request(
|
|
4182
4289
|
`/v1/skill/${encodeURIComponent(provider)}/tool/${encodeURIComponent(toolName)}`,
|
|
4183
4290
|
options
|
|
4184
4291
|
);
|
|
4185
|
-
|
|
4292
|
+
log21("Retrieved tool: %s", (_a = result.tool) == null ? void 0 : _a.name);
|
|
4186
4293
|
return result;
|
|
4187
4294
|
}
|
|
4188
4295
|
/**
|
|
@@ -4196,12 +4303,12 @@ var SkillService = class extends BaseSDK {
|
|
|
4196
4303
|
* @returns Promise resolving to the connection status
|
|
4197
4304
|
*/
|
|
4198
4305
|
async getStatus(provider, options) {
|
|
4199
|
-
|
|
4306
|
+
log21("Getting status for provider: %s", provider);
|
|
4200
4307
|
const result = await this.request(
|
|
4201
4308
|
`/v1/skill/${encodeURIComponent(provider)}/status`,
|
|
4202
4309
|
options
|
|
4203
4310
|
);
|
|
4204
|
-
|
|
4311
|
+
log21("Provider %s status: connected=%s", provider, result.connected);
|
|
4205
4312
|
return result;
|
|
4206
4313
|
}
|
|
4207
4314
|
/**
|
|
@@ -4229,7 +4336,7 @@ var SkillService = class extends BaseSDK {
|
|
|
4229
4336
|
* ```
|
|
4230
4337
|
*/
|
|
4231
4338
|
async callTool(provider, params, options) {
|
|
4232
|
-
|
|
4339
|
+
log21("Calling tool %s on provider %s", params.tool, provider);
|
|
4233
4340
|
const { args, tool, ...rest } = params;
|
|
4234
4341
|
const result = await this.request(
|
|
4235
4342
|
`/v1/skill/${encodeURIComponent(provider)}/call`,
|
|
@@ -4246,14 +4353,14 @@ var SkillService = class extends BaseSDK {
|
|
|
4246
4353
|
...options
|
|
4247
4354
|
}
|
|
4248
4355
|
);
|
|
4249
|
-
|
|
4356
|
+
log21("Tool %s call completed: success=%s", params.tool, result.success);
|
|
4250
4357
|
return result;
|
|
4251
4358
|
}
|
|
4252
4359
|
};
|
|
4253
4360
|
|
|
4254
4361
|
// src/market/services/MarketSkillCollectionService.ts
|
|
4255
|
-
import
|
|
4256
|
-
var
|
|
4362
|
+
import debug22 from "debug";
|
|
4363
|
+
var log22 = debug22("lobe-market-sdk:skill-collections");
|
|
4257
4364
|
var MarketSkillCollectionService = class extends BaseSDK {
|
|
4258
4365
|
async getSkillCollectionDetail(slug, params = {}, options) {
|
|
4259
4366
|
const locale = params.locale || this.defaultLocale;
|
|
@@ -4262,12 +4369,12 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4262
4369
|
locale
|
|
4263
4370
|
};
|
|
4264
4371
|
const queryString = this.buildQueryString(queryParams);
|
|
4265
|
-
|
|
4372
|
+
log22("Getting skill collection detail: %s %O", slug, queryParams);
|
|
4266
4373
|
const result = await this.request(
|
|
4267
4374
|
`/v1/skills/collections/${encodeURIComponent(slug)}${queryString}`,
|
|
4268
4375
|
options
|
|
4269
4376
|
);
|
|
4270
|
-
|
|
4377
|
+
log22("Skill collection detail retrieved: %s (%d items)", slug, result.items.length);
|
|
4271
4378
|
return result;
|
|
4272
4379
|
}
|
|
4273
4380
|
async getSkillCollections(params = {}, options) {
|
|
@@ -4277,19 +4384,19 @@ var MarketSkillCollectionService = class extends BaseSDK {
|
|
|
4277
4384
|
locale
|
|
4278
4385
|
};
|
|
4279
4386
|
const queryString = this.buildQueryString(queryParams);
|
|
4280
|
-
|
|
4387
|
+
log22("Getting skill collections: %O", queryParams);
|
|
4281
4388
|
const result = await this.request(
|
|
4282
4389
|
`/v1/skills/collections${queryString}`,
|
|
4283
4390
|
options
|
|
4284
4391
|
);
|
|
4285
|
-
|
|
4392
|
+
log22("Retrieved %d skill collections", result.length);
|
|
4286
4393
|
return result;
|
|
4287
4394
|
}
|
|
4288
4395
|
};
|
|
4289
4396
|
|
|
4290
4397
|
// src/market/services/MarketSkillService.ts
|
|
4291
|
-
import
|
|
4292
|
-
var
|
|
4398
|
+
import debug23 from "debug";
|
|
4399
|
+
var log23 = debug23("lobe-market-sdk:market-skills");
|
|
4293
4400
|
var MarketSkillService = class extends BaseSDK {
|
|
4294
4401
|
/**
|
|
4295
4402
|
* Retrieves a list of skills from the marketplace
|
|
@@ -4322,9 +4429,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4322
4429
|
const locale = params.locale || this.defaultLocale;
|
|
4323
4430
|
const queryParams = { ...params, locale };
|
|
4324
4431
|
const queryString = this.buildQueryString(queryParams);
|
|
4325
|
-
|
|
4432
|
+
log23("Getting skill list: %O", queryParams);
|
|
4326
4433
|
const result = await this.request(`/v1/skills${queryString}`, options);
|
|
4327
|
-
|
|
4434
|
+
log23(
|
|
4328
4435
|
"Retrieved %d skills (page %d/%d)",
|
|
4329
4436
|
result.items.length,
|
|
4330
4437
|
result.currentPage,
|
|
@@ -4363,12 +4470,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4363
4470
|
queryParams.version = params.version;
|
|
4364
4471
|
}
|
|
4365
4472
|
const queryString = this.buildQueryString(queryParams);
|
|
4366
|
-
|
|
4473
|
+
log23("Getting skill detail: %s %O", identifier, params);
|
|
4367
4474
|
const result = await this.request(
|
|
4368
4475
|
`/v1/skills/${encodeURIComponent(identifier)}${queryString}`,
|
|
4369
4476
|
options
|
|
4370
4477
|
);
|
|
4371
|
-
|
|
4478
|
+
log23("Skill detail retrieved: %s (v%s)", identifier, result.version);
|
|
4372
4479
|
return result;
|
|
4373
4480
|
}
|
|
4374
4481
|
/**
|
|
@@ -4399,7 +4506,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4399
4506
|
if (version) {
|
|
4400
4507
|
url += `?version=${encodeURIComponent(version)}`;
|
|
4401
4508
|
}
|
|
4402
|
-
|
|
4509
|
+
log23("Generated download URL: %s", url);
|
|
4403
4510
|
return url;
|
|
4404
4511
|
}
|
|
4405
4512
|
/**
|
|
@@ -4423,7 +4530,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4423
4530
|
* ```
|
|
4424
4531
|
*/
|
|
4425
4532
|
async downloadSkill(identifier, version, options) {
|
|
4426
|
-
|
|
4533
|
+
log23("Downloading skill: %s (version: %s)", identifier, version || "latest");
|
|
4427
4534
|
const queryParams = {};
|
|
4428
4535
|
if (version) {
|
|
4429
4536
|
queryParams.version = version;
|
|
@@ -4439,7 +4546,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4439
4546
|
});
|
|
4440
4547
|
if (!response.ok) {
|
|
4441
4548
|
const errorText = await response.text();
|
|
4442
|
-
|
|
4549
|
+
log23("Download failed: %s %s", response.status, errorText);
|
|
4443
4550
|
throw new Error(`Failed to download skill: ${response.statusText}`);
|
|
4444
4551
|
}
|
|
4445
4552
|
const contentDisposition = response.headers.get("content-disposition");
|
|
@@ -4451,7 +4558,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4451
4558
|
}
|
|
4452
4559
|
}
|
|
4453
4560
|
const buffer = await response.arrayBuffer();
|
|
4454
|
-
|
|
4561
|
+
log23("Downloaded skill: %s (%d bytes)", filename, buffer.byteLength);
|
|
4455
4562
|
return { buffer, filename };
|
|
4456
4563
|
}
|
|
4457
4564
|
/**
|
|
@@ -4479,12 +4586,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4479
4586
|
const locale = params.locale || this.defaultLocale;
|
|
4480
4587
|
const queryParams = { ...params, locale };
|
|
4481
4588
|
const queryString = this.buildQueryString(queryParams);
|
|
4482
|
-
|
|
4589
|
+
log23("Getting skill categories: %O", queryParams);
|
|
4483
4590
|
const result = await this.request(
|
|
4484
4591
|
`/v1/skills/categories${queryString}`,
|
|
4485
4592
|
options
|
|
4486
4593
|
);
|
|
4487
|
-
|
|
4594
|
+
log23("Retrieved %d categories", result.length);
|
|
4488
4595
|
return result;
|
|
4489
4596
|
}
|
|
4490
4597
|
/**
|
|
@@ -4499,12 +4606,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4499
4606
|
* @returns Promise resolving to an array of identifiers with last modified times
|
|
4500
4607
|
*/
|
|
4501
4608
|
async getPublishedIdentifiers(options) {
|
|
4502
|
-
|
|
4609
|
+
log23("Getting published skill identifiers");
|
|
4503
4610
|
const result = await this.request(
|
|
4504
4611
|
"/v1/skills/identifiers",
|
|
4505
4612
|
options
|
|
4506
4613
|
);
|
|
4507
|
-
|
|
4614
|
+
log23("Retrieved %d published skill identifiers", result.length);
|
|
4508
4615
|
return result;
|
|
4509
4616
|
}
|
|
4510
4617
|
/**
|
|
@@ -4515,9 +4622,9 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4515
4622
|
*/
|
|
4516
4623
|
async getSitemap(params = {}, options) {
|
|
4517
4624
|
const queryString = this.buildQueryString(params);
|
|
4518
|
-
|
|
4625
|
+
log23("Getting skill sitemap%s", queryString);
|
|
4519
4626
|
const result = await this.request(`/v1/skills/sitemap${queryString}`, options);
|
|
4520
|
-
|
|
4627
|
+
log23(
|
|
4521
4628
|
"Retrieved skill sitemap page %d/%d (%d items)",
|
|
4522
4629
|
result.currentPage,
|
|
4523
4630
|
result.totalPages,
|
|
@@ -4533,13 +4640,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4533
4640
|
* @returns Promise resolving to true if skill exists, false otherwise
|
|
4534
4641
|
*/
|
|
4535
4642
|
async checkSkillExists(identifier, options) {
|
|
4536
|
-
|
|
4643
|
+
log23("Checking if skill exists: %s", identifier);
|
|
4537
4644
|
try {
|
|
4538
4645
|
await this.getSkillDetail(identifier, {}, options);
|
|
4539
|
-
|
|
4646
|
+
log23("Skill exists: %s", identifier);
|
|
4540
4647
|
return true;
|
|
4541
4648
|
} catch (e) {
|
|
4542
|
-
|
|
4649
|
+
log23("Skill does not exist: %s", identifier);
|
|
4543
4650
|
return false;
|
|
4544
4651
|
}
|
|
4545
4652
|
}
|
|
@@ -4560,12 +4667,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4560
4667
|
* ```
|
|
4561
4668
|
*/
|
|
4562
4669
|
async getSkillVersions(identifier, options) {
|
|
4563
|
-
|
|
4670
|
+
log23("Getting skill versions: %s", identifier);
|
|
4564
4671
|
const result = await this.request(
|
|
4565
4672
|
`/v1/skills/${encodeURIComponent(identifier)}/versions`,
|
|
4566
4673
|
options
|
|
4567
4674
|
);
|
|
4568
|
-
|
|
4675
|
+
log23("Retrieved %d versions for skill %s", result.data.length, identifier);
|
|
4569
4676
|
return result.data;
|
|
4570
4677
|
}
|
|
4571
4678
|
/**
|
|
@@ -4589,12 +4696,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4589
4696
|
const locale = params.locale || this.defaultLocale;
|
|
4590
4697
|
const queryParams = { locale };
|
|
4591
4698
|
const queryString = this.buildQueryString(queryParams);
|
|
4592
|
-
|
|
4699
|
+
log23("Getting skill version: %s@%s", identifier, version);
|
|
4593
4700
|
const result = await this.request(
|
|
4594
4701
|
`/v1/skills/${encodeURIComponent(identifier)}/versions/${encodeURIComponent(version)}${queryString}`,
|
|
4595
4702
|
options
|
|
4596
4703
|
);
|
|
4597
|
-
|
|
4704
|
+
log23("Skill version detail retrieved: %s@%s", identifier, version);
|
|
4598
4705
|
return result;
|
|
4599
4706
|
}
|
|
4600
4707
|
/**
|
|
@@ -4623,13 +4730,13 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4623
4730
|
* ```
|
|
4624
4731
|
*/
|
|
4625
4732
|
async reportGitHubSkill(params, options) {
|
|
4626
|
-
|
|
4733
|
+
log23("Reporting GitHub skill: %s", params.gitUrl);
|
|
4627
4734
|
const result = await this.request("/v1/skills/report/github", {
|
|
4628
4735
|
...options,
|
|
4629
4736
|
body: JSON.stringify(params),
|
|
4630
4737
|
method: "POST"
|
|
4631
4738
|
});
|
|
4632
|
-
|
|
4739
|
+
log23("GitHub skill reported: %s (status: %s)", result.identifier, result.status);
|
|
4633
4740
|
return result;
|
|
4634
4741
|
}
|
|
4635
4742
|
/**
|
|
@@ -4654,7 +4761,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4654
4761
|
* ```
|
|
4655
4762
|
*/
|
|
4656
4763
|
async reportSkillInstall(params, options) {
|
|
4657
|
-
|
|
4764
|
+
log23("Reporting skill install: %s (success: %s)", params.identifier, params.success);
|
|
4658
4765
|
const result = await this.request(
|
|
4659
4766
|
"/v1/skills/report/installation",
|
|
4660
4767
|
{
|
|
@@ -4663,7 +4770,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4663
4770
|
method: "POST"
|
|
4664
4771
|
}
|
|
4665
4772
|
);
|
|
4666
|
-
|
|
4773
|
+
log23("Skill install reported: %s", result.message);
|
|
4667
4774
|
return result;
|
|
4668
4775
|
}
|
|
4669
4776
|
/**
|
|
@@ -4675,7 +4782,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4675
4782
|
* @returns Promise resolving to the submitted score
|
|
4676
4783
|
*/
|
|
4677
4784
|
async submitRating(identifier, score, options) {
|
|
4678
|
-
|
|
4785
|
+
log23("Submitting rating for skill %s: %d", identifier, score);
|
|
4679
4786
|
const result = await this.request(
|
|
4680
4787
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings`,
|
|
4681
4788
|
{
|
|
@@ -4684,7 +4791,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4684
4791
|
method: "POST"
|
|
4685
4792
|
}
|
|
4686
4793
|
);
|
|
4687
|
-
|
|
4794
|
+
log23("Rating submitted for skill %s: %d", identifier, result.score);
|
|
4688
4795
|
return result;
|
|
4689
4796
|
}
|
|
4690
4797
|
/**
|
|
@@ -4695,12 +4802,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4695
4802
|
* @returns Promise resolving to the rating distribution
|
|
4696
4803
|
*/
|
|
4697
4804
|
async getRatingDistribution(identifier, options) {
|
|
4698
|
-
|
|
4805
|
+
log23("Getting rating distribution for skill: %s", identifier);
|
|
4699
4806
|
const result = await this.request(
|
|
4700
4807
|
`/v1/skills/${encodeURIComponent(identifier)}/ratings/distribution`,
|
|
4701
4808
|
options
|
|
4702
4809
|
);
|
|
4703
|
-
|
|
4810
|
+
log23("Rating distribution retrieved for skill %s: %d total", identifier, result.totalCount);
|
|
4704
4811
|
return result;
|
|
4705
4812
|
}
|
|
4706
4813
|
/**
|
|
@@ -4713,12 +4820,12 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4713
4820
|
*/
|
|
4714
4821
|
async getComments(identifier, params = {}, options) {
|
|
4715
4822
|
const queryString = this.buildQueryString(params);
|
|
4716
|
-
|
|
4823
|
+
log23("Getting comments for skill %s: %O", identifier, params);
|
|
4717
4824
|
const result = await this.request(
|
|
4718
4825
|
`/v1/skills/${encodeURIComponent(identifier)}/comments${queryString}`,
|
|
4719
4826
|
options
|
|
4720
4827
|
);
|
|
4721
|
-
|
|
4828
|
+
log23(
|
|
4722
4829
|
"Retrieved %d comments for skill %s (page %d/%d)",
|
|
4723
4830
|
result.items.length,
|
|
4724
4831
|
identifier,
|
|
@@ -4735,15 +4842,15 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4735
4842
|
* @returns Promise resolving to the latest own comment or null when none exists
|
|
4736
4843
|
*/
|
|
4737
4844
|
async getLatestOwnComment(identifier, options) {
|
|
4738
|
-
|
|
4845
|
+
log23("Getting latest own comment for skill %s", identifier);
|
|
4739
4846
|
const result = await this.request(
|
|
4740
4847
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/latest`,
|
|
4741
4848
|
options
|
|
4742
4849
|
);
|
|
4743
4850
|
if (result) {
|
|
4744
|
-
|
|
4851
|
+
log23("Retrieved latest own comment for skill %s: id=%d", identifier, result.id);
|
|
4745
4852
|
} else {
|
|
4746
|
-
|
|
4853
|
+
log23("No own comments found for skill %s", identifier);
|
|
4747
4854
|
}
|
|
4748
4855
|
return result;
|
|
4749
4856
|
}
|
|
@@ -4756,7 +4863,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4756
4863
|
* @returns Promise resolving to the created comment (with optional rating field)
|
|
4757
4864
|
*/
|
|
4758
4865
|
async createComment(identifier, data, options) {
|
|
4759
|
-
|
|
4866
|
+
log23("Creating comment on skill %s", identifier);
|
|
4760
4867
|
const result = await this.request(
|
|
4761
4868
|
`/v1/skills/${encodeURIComponent(identifier)}/comments`,
|
|
4762
4869
|
{
|
|
@@ -4765,7 +4872,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4765
4872
|
method: "POST"
|
|
4766
4873
|
}
|
|
4767
4874
|
);
|
|
4768
|
-
|
|
4875
|
+
log23("Comment created on skill %s: id=%d", identifier, result.id);
|
|
4769
4876
|
return result;
|
|
4770
4877
|
}
|
|
4771
4878
|
/**
|
|
@@ -4777,7 +4884,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4777
4884
|
* @returns Promise resolving to success status
|
|
4778
4885
|
*/
|
|
4779
4886
|
async deleteComment(identifier, commentId, options) {
|
|
4780
|
-
|
|
4887
|
+
log23("Deleting comment %d from skill %s", commentId, identifier);
|
|
4781
4888
|
const result = await this.request(
|
|
4782
4889
|
`/v1/skills/${encodeURIComponent(identifier)}/comments/${commentId}`,
|
|
4783
4890
|
{
|
|
@@ -4785,7 +4892,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4785
4892
|
method: "DELETE"
|
|
4786
4893
|
}
|
|
4787
4894
|
);
|
|
4788
|
-
|
|
4895
|
+
log23("Comment %d deleted from skill %s", commentId, identifier);
|
|
4789
4896
|
return result;
|
|
4790
4897
|
}
|
|
4791
4898
|
/**
|
|
@@ -4797,7 +4904,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4797
4904
|
* @returns Promise resolving to the created reaction
|
|
4798
4905
|
*/
|
|
4799
4906
|
async addReaction(commentId, type, options) {
|
|
4800
|
-
|
|
4907
|
+
log23("Adding %s reaction to comment %d", type, commentId);
|
|
4801
4908
|
const result = await this.request(
|
|
4802
4909
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
4803
4910
|
{
|
|
@@ -4806,7 +4913,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4806
4913
|
method: "POST"
|
|
4807
4914
|
}
|
|
4808
4915
|
);
|
|
4809
|
-
|
|
4916
|
+
log23("Reaction added to comment %d: %s (id=%d)", commentId, result.type, result.id);
|
|
4810
4917
|
return result;
|
|
4811
4918
|
}
|
|
4812
4919
|
/**
|
|
@@ -4817,7 +4924,7 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4817
4924
|
* @returns Promise resolving to success status
|
|
4818
4925
|
*/
|
|
4819
4926
|
async removeReaction(commentId, options) {
|
|
4820
|
-
|
|
4927
|
+
log23("Removing reaction from comment %d", commentId);
|
|
4821
4928
|
const result = await this.request(
|
|
4822
4929
|
`/v1/skills/comments/${commentId}/reactions`,
|
|
4823
4930
|
{
|
|
@@ -4825,14 +4932,339 @@ var MarketSkillService = class extends BaseSDK {
|
|
|
4825
4932
|
method: "DELETE"
|
|
4826
4933
|
}
|
|
4827
4934
|
);
|
|
4828
|
-
|
|
4935
|
+
log23("Reaction removed from comment %d", commentId);
|
|
4936
|
+
return result;
|
|
4937
|
+
}
|
|
4938
|
+
};
|
|
4939
|
+
|
|
4940
|
+
// src/market/services/OrganizationCredsService.ts
|
|
4941
|
+
import debug24 from "debug";
|
|
4942
|
+
var log24 = debug24("lobe-market-sdk:org-creds");
|
|
4943
|
+
var OrganizationCredsService = class extends BaseSDK {
|
|
4944
|
+
constructor(orgId, options = {}, sharedHeaders, sharedTokenState) {
|
|
4945
|
+
super(options, sharedHeaders, sharedTokenState);
|
|
4946
|
+
if (!Number.isInteger(orgId) || orgId <= 0) {
|
|
4947
|
+
throw new Error(`OrganizationCredsService requires a positive integer orgId, got: ${orgId}`);
|
|
4948
|
+
}
|
|
4949
|
+
this.orgId = orgId;
|
|
4950
|
+
}
|
|
4951
|
+
base() {
|
|
4952
|
+
return `/v1/organizations/${this.orgId}/creds`;
|
|
4953
|
+
}
|
|
4954
|
+
// ===========================================================================
|
|
4955
|
+
// Read
|
|
4956
|
+
// ===========================================================================
|
|
4957
|
+
async list(options) {
|
|
4958
|
+
var _a;
|
|
4959
|
+
log24("Listing org %d credentials", this.orgId);
|
|
4960
|
+
const result = await this.request(this.base(), options);
|
|
4961
|
+
log24("Found %d credentials for org %d", ((_a = result.data) == null ? void 0 : _a.length) || 0, this.orgId);
|
|
4962
|
+
return result;
|
|
4963
|
+
}
|
|
4964
|
+
async get(id, getOptions, options) {
|
|
4965
|
+
log24("Getting org %d credential %d (decrypt=%s)", this.orgId, id, getOptions == null ? void 0 : getOptions.decrypt);
|
|
4966
|
+
const queryString = this.buildQueryString((getOptions == null ? void 0 : getOptions.decrypt) ? { decrypt: "true" } : {});
|
|
4967
|
+
const result = await this.request(
|
|
4968
|
+
`${this.base()}/${id}${queryString}`,
|
|
4969
|
+
options
|
|
4970
|
+
);
|
|
4971
|
+
log24("Retrieved org credential: %s", result.key);
|
|
4972
|
+
return result;
|
|
4973
|
+
}
|
|
4974
|
+
// ===========================================================================
|
|
4975
|
+
// Create
|
|
4976
|
+
// ===========================================================================
|
|
4977
|
+
async createKV(data, options) {
|
|
4978
|
+
log24("Creating org %d KV credential: %s (type=%s)", this.orgId, data.key, data.type);
|
|
4979
|
+
return this.request(`${this.base()}/kv`, {
|
|
4980
|
+
body: JSON.stringify(data),
|
|
4981
|
+
headers: { "Content-Type": "application/json" },
|
|
4982
|
+
method: "POST",
|
|
4983
|
+
...options
|
|
4984
|
+
});
|
|
4985
|
+
}
|
|
4986
|
+
async createOAuth(data, options) {
|
|
4987
|
+
log24("Creating org %d OAuth credential: %s", this.orgId, data.key);
|
|
4988
|
+
return this.request(`${this.base()}/oauth`, {
|
|
4989
|
+
body: JSON.stringify(data),
|
|
4990
|
+
headers: { "Content-Type": "application/json" },
|
|
4991
|
+
method: "POST",
|
|
4992
|
+
...options
|
|
4993
|
+
});
|
|
4994
|
+
}
|
|
4995
|
+
async createFile(data, options) {
|
|
4996
|
+
log24("Creating org %d file credential: %s", this.orgId, data.key);
|
|
4997
|
+
return this.request(`${this.base()}/file`, {
|
|
4998
|
+
body: JSON.stringify(data),
|
|
4999
|
+
headers: { "Content-Type": "application/json" },
|
|
5000
|
+
method: "POST",
|
|
5001
|
+
...options
|
|
5002
|
+
});
|
|
5003
|
+
}
|
|
5004
|
+
// ===========================================================================
|
|
5005
|
+
// Update
|
|
5006
|
+
// ===========================================================================
|
|
5007
|
+
async update(id, data, options) {
|
|
5008
|
+
log24("Updating org %d credential %d", this.orgId, id);
|
|
5009
|
+
return this.request(`${this.base()}/${id}`, {
|
|
5010
|
+
body: JSON.stringify(data),
|
|
5011
|
+
headers: { "Content-Type": "application/json" },
|
|
5012
|
+
method: "PATCH",
|
|
5013
|
+
...options
|
|
5014
|
+
});
|
|
5015
|
+
}
|
|
5016
|
+
// ===========================================================================
|
|
5017
|
+
// Delete
|
|
5018
|
+
// ===========================================================================
|
|
5019
|
+
async delete(id, options) {
|
|
5020
|
+
log24("Deleting org %d credential %d", this.orgId, id);
|
|
5021
|
+
return this.request(`${this.base()}/${id}`, {
|
|
5022
|
+
method: "DELETE",
|
|
5023
|
+
...options
|
|
5024
|
+
});
|
|
5025
|
+
}
|
|
5026
|
+
async deleteByKey(key, options) {
|
|
5027
|
+
log24("Deleting org %d credential by key: %s", this.orgId, key);
|
|
5028
|
+
return this.request(`${this.base()}/key/${encodeURIComponent(key)}`, {
|
|
5029
|
+
method: "DELETE",
|
|
5030
|
+
...options
|
|
5031
|
+
});
|
|
5032
|
+
}
|
|
5033
|
+
// ===========================================================================
|
|
5034
|
+
// Skill cred status
|
|
5035
|
+
// ===========================================================================
|
|
5036
|
+
/**
|
|
5037
|
+
* Returns this org's credential status for a skill — which required creds
|
|
5038
|
+
* the org has bound vs. is missing. Reads only; any org member may call.
|
|
5039
|
+
*/
|
|
5040
|
+
async getSkillCredStatus(skillIdentifier, options) {
|
|
5041
|
+
log24("Getting org %d skill cred status: %s", this.orgId, skillIdentifier);
|
|
5042
|
+
const path = `/v1/organizations/${this.orgId}/skills/${encodeURIComponent(skillIdentifier)}/creds/status`;
|
|
5043
|
+
const result = await this.request(
|
|
5044
|
+
path,
|
|
5045
|
+
options
|
|
5046
|
+
);
|
|
5047
|
+
return Array.isArray(result) ? result : result.data;
|
|
5048
|
+
}
|
|
5049
|
+
};
|
|
5050
|
+
|
|
5051
|
+
// src/market/services/OrganizationService.ts
|
|
5052
|
+
import debug25 from "debug";
|
|
5053
|
+
var log25 = debug25("lobe-market-sdk:organization");
|
|
5054
|
+
var OrganizationService2 = class extends BaseSDK {
|
|
5055
|
+
constructor(options = {}, sharedHeaders, sharedTokenState) {
|
|
5056
|
+
super(options, sharedHeaders, sharedTokenState);
|
|
5057
|
+
this.initOptions = options;
|
|
5058
|
+
this.tokenState = sharedTokenState;
|
|
5059
|
+
}
|
|
5060
|
+
/**
|
|
5061
|
+
* Returns an org-scoped credentials sub-service bound to `orgId`.
|
|
5062
|
+
*
|
|
5063
|
+
* The returned service hits `/v1/organizations/:orgId/creds/*` and shares
|
|
5064
|
+
* this `OrganizationService`'s headers + token state, so it inherits the
|
|
5065
|
+
* same auth context as the rest of the SDK (no need to re-attach an access
|
|
5066
|
+
* token).
|
|
5067
|
+
*
|
|
5068
|
+
* Returns a fresh instance per call; suitable for short-lived UIs where the
|
|
5069
|
+
* orgId varies. For long-lived use, cache the returned service.
|
|
5070
|
+
*
|
|
5071
|
+
* @example
|
|
5072
|
+
* ```typescript
|
|
5073
|
+
* const orgCreds = market.organizations.creds(42);
|
|
5074
|
+
* await orgCreds.list();
|
|
5075
|
+
* ```
|
|
5076
|
+
*/
|
|
5077
|
+
creds(orgId) {
|
|
5078
|
+
return new OrganizationCredsService(orgId, this.initOptions, this.headers, this.tokenState);
|
|
5079
|
+
}
|
|
5080
|
+
/**
|
|
5081
|
+
* Retrieves an organization's public profile and everything it has
|
|
5082
|
+
* published — agents, agent groups, skills, plugins.
|
|
5083
|
+
*
|
|
5084
|
+
* Public endpoint; authentication is optional. If the caller is an
|
|
5085
|
+
* authenticated admin of the organization, the response additionally
|
|
5086
|
+
* includes unpublished/private content (useful for the workspace owner's
|
|
5087
|
+
* own Community page).
|
|
5088
|
+
*
|
|
5089
|
+
* @param idOrNamespace - The account ID (number) or organization namespace string (e.g. `ws-acme`)
|
|
5090
|
+
* @param params - Query parameters for locale
|
|
5091
|
+
* @param options - Optional request options
|
|
5092
|
+
* @returns Promise resolving to the organization info response
|
|
5093
|
+
*/
|
|
5094
|
+
async getOrganizationInfo(idOrNamespace, params = {}, options) {
|
|
5095
|
+
const locale = params.locale || this.defaultLocale;
|
|
5096
|
+
const queryString = this.buildQueryString({ locale });
|
|
5097
|
+
log25("Getting organization info: %O", { idOrNamespace, ...params });
|
|
5098
|
+
const result = await this.request(
|
|
5099
|
+
`/v1/organizations/info/${idOrNamespace}${queryString}`,
|
|
5100
|
+
options
|
|
5101
|
+
);
|
|
5102
|
+
log25("Organization info retrieved for: %s", idOrNamespace);
|
|
4829
5103
|
return result;
|
|
4830
5104
|
}
|
|
5105
|
+
/**
|
|
5106
|
+
* Lists the organizations the authenticated user belongs to, each annotated
|
|
5107
|
+
* with the caller's membership role. Excludes archived organizations.
|
|
5108
|
+
*
|
|
5109
|
+
* @returns Promise resolving to the user's organizations
|
|
5110
|
+
*/
|
|
5111
|
+
async listMyOrganizations(options) {
|
|
5112
|
+
log25("Listing organizations for current user");
|
|
5113
|
+
const result = await this.request(
|
|
5114
|
+
"/v1/organizations/me",
|
|
5115
|
+
options
|
|
5116
|
+
);
|
|
5117
|
+
return result.data;
|
|
5118
|
+
}
|
|
5119
|
+
/**
|
|
5120
|
+
* Idempotently creates an organization (mirrors a cloud workspace).
|
|
5121
|
+
*
|
|
5122
|
+
* Trusted-client only — construct the SDK with `{ trustedClientToken }`. Uses
|
|
5123
|
+
* `clerkId` as the idempotency key; a second call with the same `clerkId`
|
|
5124
|
+
* returns the existing org with `created: false` (and revives it if archived).
|
|
5125
|
+
*
|
|
5126
|
+
* @param data - Organization fields + optional initial members
|
|
5127
|
+
* @returns The created/existing organization and whether it was newly created
|
|
5128
|
+
*/
|
|
5129
|
+
async createOrganization(data, options) {
|
|
5130
|
+
log25("Creating organization: %s", data.clerkId);
|
|
5131
|
+
return this.request("/v1/organizations", {
|
|
5132
|
+
...options,
|
|
5133
|
+
body: JSON.stringify(data),
|
|
5134
|
+
method: "POST"
|
|
5135
|
+
});
|
|
5136
|
+
}
|
|
5137
|
+
/**
|
|
5138
|
+
* Updates an organization's metadata. Requires org admin (or trusted client).
|
|
5139
|
+
*
|
|
5140
|
+
* @param orgId - Organization account id
|
|
5141
|
+
* @param data - Fields to update
|
|
5142
|
+
* @returns The updated organization
|
|
5143
|
+
*/
|
|
5144
|
+
async updateOrganization(orgId, data, options) {
|
|
5145
|
+
log25("Updating organization %d: %O", orgId, data);
|
|
5146
|
+
const result = await this.request(`/v1/organizations/${orgId}`, {
|
|
5147
|
+
...options,
|
|
5148
|
+
body: JSON.stringify(data),
|
|
5149
|
+
method: "PATCH"
|
|
5150
|
+
});
|
|
5151
|
+
return result.data;
|
|
5152
|
+
}
|
|
5153
|
+
/**
|
|
5154
|
+
* Soft-disables an organization (e.g. its cloud workspace was deleted).
|
|
5155
|
+
* Trusted-client only. Reversible; creds and published content are preserved.
|
|
5156
|
+
*
|
|
5157
|
+
* @param orgId - Organization account id
|
|
5158
|
+
* @returns The archived organization
|
|
5159
|
+
*/
|
|
5160
|
+
async archiveOrganization(orgId, options) {
|
|
5161
|
+
log25("Archiving organization %d", orgId);
|
|
5162
|
+
const result = await this.request(
|
|
5163
|
+
`/v1/organizations/${orgId}/archive`,
|
|
5164
|
+
{ ...options, method: "POST" }
|
|
5165
|
+
);
|
|
5166
|
+
return result.data;
|
|
5167
|
+
}
|
|
5168
|
+
/**
|
|
5169
|
+
* Reactivates a previously archived organization. Trusted-client only.
|
|
5170
|
+
*
|
|
5171
|
+
* @param orgId - Organization account id
|
|
5172
|
+
* @returns The reactivated organization
|
|
5173
|
+
*/
|
|
5174
|
+
async unarchiveOrganization(orgId, options) {
|
|
5175
|
+
log25("Unarchiving organization %d", orgId);
|
|
5176
|
+
const result = await this.request(
|
|
5177
|
+
`/v1/organizations/${orgId}/unarchive`,
|
|
5178
|
+
{ ...options, method: "POST" }
|
|
5179
|
+
);
|
|
5180
|
+
return result.data;
|
|
5181
|
+
}
|
|
5182
|
+
/**
|
|
5183
|
+
* Lists the members of an organization. Any authenticated org member may call.
|
|
5184
|
+
*
|
|
5185
|
+
* @param orgId - Organization account id
|
|
5186
|
+
* @returns Hydrated member rows
|
|
5187
|
+
*/
|
|
5188
|
+
async listMembers(orgId, options) {
|
|
5189
|
+
log25("Listing members of organization %d", orgId);
|
|
5190
|
+
const result = await this.request(
|
|
5191
|
+
`/v1/organizations/${orgId}/members`,
|
|
5192
|
+
options
|
|
5193
|
+
);
|
|
5194
|
+
return result.data;
|
|
5195
|
+
}
|
|
5196
|
+
/**
|
|
5197
|
+
* Adds a member to an organization. Trusted-client only. Idempotent: if the
|
|
5198
|
+
* user is already a member, the existing role is preserved (`added: false`).
|
|
5199
|
+
*
|
|
5200
|
+
* @param orgId - Organization account id
|
|
5201
|
+
* @param userAccountId - The user's account id
|
|
5202
|
+
* @param role - Role to grant (defaults server-side to `member`)
|
|
5203
|
+
* @returns Whether the member was newly added and their effective role
|
|
5204
|
+
*/
|
|
5205
|
+
async addMember(orgId, userAccountId, role, options) {
|
|
5206
|
+
log25("Adding member %d to organization %d (role=%s)", userAccountId, orgId, role);
|
|
5207
|
+
return this.request(`/v1/organizations/${orgId}/members`, {
|
|
5208
|
+
...options,
|
|
5209
|
+
body: JSON.stringify({ role, userAccountId }),
|
|
5210
|
+
method: "POST"
|
|
5211
|
+
});
|
|
5212
|
+
}
|
|
5213
|
+
/**
|
|
5214
|
+
* Removes a member from an organization. Trusted-client only. Refuses to
|
|
5215
|
+
* remove the last admin (server returns 409).
|
|
5216
|
+
*
|
|
5217
|
+
* @param orgId - Organization account id
|
|
5218
|
+
* @param userAccountId - The user's account id
|
|
5219
|
+
* @returns Whether a membership row was removed
|
|
5220
|
+
*/
|
|
5221
|
+
async removeMember(orgId, userAccountId, options) {
|
|
5222
|
+
log25("Removing member %d from organization %d", userAccountId, orgId);
|
|
5223
|
+
return this.request(
|
|
5224
|
+
`/v1/organizations/${orgId}/members/${userAccountId}`,
|
|
5225
|
+
{ ...options, method: "DELETE" }
|
|
5226
|
+
);
|
|
5227
|
+
}
|
|
5228
|
+
/**
|
|
5229
|
+
* Updates a member's role. Trusted-client only. Refuses to demote the last
|
|
5230
|
+
* admin (server returns 409).
|
|
5231
|
+
*
|
|
5232
|
+
* @param orgId - Organization account id
|
|
5233
|
+
* @param userAccountId - The user's account id
|
|
5234
|
+
* @param role - The new role
|
|
5235
|
+
* @returns The effective role and whether it changed
|
|
5236
|
+
*/
|
|
5237
|
+
async updateMemberRole(orgId, userAccountId, role, options) {
|
|
5238
|
+
log25("Updating member %d role to %s in organization %d", userAccountId, role, orgId);
|
|
5239
|
+
return this.request(
|
|
5240
|
+
`/v1/organizations/${orgId}/members/${userAccountId}`,
|
|
5241
|
+
{ ...options, body: JSON.stringify({ role }), method: "PATCH" }
|
|
5242
|
+
);
|
|
5243
|
+
}
|
|
5244
|
+
/**
|
|
5245
|
+
* Reconciles the full member list against a desired snapshot (idempotent).
|
|
5246
|
+
* Trusted-client only — the canonical way for Cloud to mirror a workspace's
|
|
5247
|
+
* complete membership: absent members are removed, missing ones added, and
|
|
5248
|
+
* changed roles updated, all in one transaction. Rejects a snapshot with no
|
|
5249
|
+
* admin (server returns 409).
|
|
5250
|
+
*
|
|
5251
|
+
* @param orgId - Organization account id
|
|
5252
|
+
* @param members - The complete desired member list
|
|
5253
|
+
* @returns Counts of added / removed / updated members and skipped ids
|
|
5254
|
+
*/
|
|
5255
|
+
async reconcileMembers(orgId, members, options) {
|
|
5256
|
+
log25("Reconciling %d members for organization %d", members.length, orgId);
|
|
5257
|
+
return this.request(`/v1/organizations/${orgId}/members`, {
|
|
5258
|
+
...options,
|
|
5259
|
+
body: JSON.stringify({ members }),
|
|
5260
|
+
method: "PUT"
|
|
5261
|
+
});
|
|
5262
|
+
}
|
|
4831
5263
|
};
|
|
4832
5264
|
|
|
4833
5265
|
// src/market/services/UserService.ts
|
|
4834
|
-
import
|
|
4835
|
-
var
|
|
5266
|
+
import debug26 from "debug";
|
|
5267
|
+
var log26 = debug26("lobe-market-sdk:user");
|
|
4836
5268
|
var UserService = class extends BaseSDK {
|
|
4837
5269
|
/**
|
|
4838
5270
|
* Retrieves user information by account ID or userName
|
|
@@ -4849,12 +5281,12 @@ var UserService = class extends BaseSDK {
|
|
|
4849
5281
|
const locale = params.locale || this.defaultLocale;
|
|
4850
5282
|
const queryParams = { locale };
|
|
4851
5283
|
const queryString = this.buildQueryString(queryParams);
|
|
4852
|
-
|
|
5284
|
+
log26("Getting user info: %O", { idOrUserName, ...params });
|
|
4853
5285
|
const result = await this.request(
|
|
4854
5286
|
`/v1/user/info/${idOrUserName}${queryString}`,
|
|
4855
5287
|
options
|
|
4856
5288
|
);
|
|
4857
|
-
|
|
5289
|
+
log26("User info successfully retrieved for: %s", idOrUserName);
|
|
4858
5290
|
return result;
|
|
4859
5291
|
}
|
|
4860
5292
|
/**
|
|
@@ -4869,7 +5301,7 @@ var UserService = class extends BaseSDK {
|
|
|
4869
5301
|
* @throws Error if userName is already taken or update fails
|
|
4870
5302
|
*/
|
|
4871
5303
|
async updateUserInfo(data, options) {
|
|
4872
|
-
|
|
5304
|
+
log26("Updating user info: %O", data);
|
|
4873
5305
|
const result = await this.request("/v1/user/update", {
|
|
4874
5306
|
body: JSON.stringify(data),
|
|
4875
5307
|
headers: {
|
|
@@ -4878,7 +5310,7 @@ var UserService = class extends BaseSDK {
|
|
|
4878
5310
|
method: "POST",
|
|
4879
5311
|
...options
|
|
4880
5312
|
});
|
|
4881
|
-
|
|
5313
|
+
log26("User info updated successfully");
|
|
4882
5314
|
return result;
|
|
4883
5315
|
}
|
|
4884
5316
|
/**
|
|
@@ -4908,7 +5340,7 @@ var UserService = class extends BaseSDK {
|
|
|
4908
5340
|
* ```
|
|
4909
5341
|
*/
|
|
4910
5342
|
async register(data, options) {
|
|
4911
|
-
|
|
5343
|
+
log26("Registering user: %O", {
|
|
4912
5344
|
followUserId: data.followUserId,
|
|
4913
5345
|
registerUserId: data.registerUserId
|
|
4914
5346
|
});
|
|
@@ -4920,14 +5352,14 @@ var UserService = class extends BaseSDK {
|
|
|
4920
5352
|
method: "POST",
|
|
4921
5353
|
...options
|
|
4922
5354
|
});
|
|
4923
|
-
|
|
5355
|
+
log26("User registered successfully: created=%s, userId=%s", result.created, result.user.clerkId);
|
|
4924
5356
|
return result;
|
|
4925
5357
|
}
|
|
4926
5358
|
};
|
|
4927
5359
|
|
|
4928
5360
|
// src/market/services/UserFollowService.ts
|
|
4929
|
-
import
|
|
4930
|
-
var
|
|
5361
|
+
import debug27 from "debug";
|
|
5362
|
+
var log27 = debug27("lobe-market-sdk:user-follow");
|
|
4931
5363
|
var UserFollowService = class extends BaseSDK {
|
|
4932
5364
|
/**
|
|
4933
5365
|
* Follow a user
|
|
@@ -4941,7 +5373,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
4941
5373
|
* @throws Error if already following or cannot follow yourself
|
|
4942
5374
|
*/
|
|
4943
5375
|
async follow(followingId, options) {
|
|
4944
|
-
|
|
5376
|
+
log27("Following user: %d", followingId);
|
|
4945
5377
|
const body = { followingId };
|
|
4946
5378
|
const result = await this.request("/v1/user/follows", {
|
|
4947
5379
|
body: JSON.stringify(body),
|
|
@@ -4951,7 +5383,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
4951
5383
|
method: "POST",
|
|
4952
5384
|
...options
|
|
4953
5385
|
});
|
|
4954
|
-
|
|
5386
|
+
log27("Successfully followed user: %d", followingId);
|
|
4955
5387
|
return result;
|
|
4956
5388
|
}
|
|
4957
5389
|
/**
|
|
@@ -4966,7 +5398,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
4966
5398
|
* @throws Error if follow relationship not found
|
|
4967
5399
|
*/
|
|
4968
5400
|
async unfollow(followingId, options) {
|
|
4969
|
-
|
|
5401
|
+
log27("Unfollowing user: %d", followingId);
|
|
4970
5402
|
const body = { followingId };
|
|
4971
5403
|
const result = await this.request("/v1/user/follows", {
|
|
4972
5404
|
body: JSON.stringify(body),
|
|
@@ -4976,7 +5408,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
4976
5408
|
method: "DELETE",
|
|
4977
5409
|
...options
|
|
4978
5410
|
});
|
|
4979
|
-
|
|
5411
|
+
log27("Successfully unfollowed user: %d", followingId);
|
|
4980
5412
|
return result;
|
|
4981
5413
|
}
|
|
4982
5414
|
/**
|
|
@@ -4990,13 +5422,13 @@ var UserFollowService = class extends BaseSDK {
|
|
|
4990
5422
|
* @returns Promise resolving to follow status (isFollowing, isMutual)
|
|
4991
5423
|
*/
|
|
4992
5424
|
async checkFollowStatus(targetUserId, options) {
|
|
4993
|
-
|
|
5425
|
+
log27("Checking follow status for user: %d", targetUserId);
|
|
4994
5426
|
const queryString = this.buildQueryString({ targetUserId: String(targetUserId) });
|
|
4995
5427
|
const result = await this.request(
|
|
4996
5428
|
`/v1/user/follows/check${queryString}`,
|
|
4997
5429
|
options
|
|
4998
5430
|
);
|
|
4999
|
-
|
|
5431
|
+
log27("Follow status retrieved: %O", result);
|
|
5000
5432
|
return result;
|
|
5001
5433
|
}
|
|
5002
5434
|
/**
|
|
@@ -5011,7 +5443,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5011
5443
|
* @returns Promise resolving to list of following users
|
|
5012
5444
|
*/
|
|
5013
5445
|
async getFollowing(userId, params = {}, options) {
|
|
5014
|
-
|
|
5446
|
+
log27("Getting following list for user: %d", userId);
|
|
5015
5447
|
const queryParams = {};
|
|
5016
5448
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5017
5449
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5020,7 +5452,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5020
5452
|
`/v1/user/follows/${userId}/following${queryString}`,
|
|
5021
5453
|
options
|
|
5022
5454
|
);
|
|
5023
|
-
|
|
5455
|
+
log27("Following list retrieved for user: %d", userId);
|
|
5024
5456
|
return result;
|
|
5025
5457
|
}
|
|
5026
5458
|
/**
|
|
@@ -5035,7 +5467,7 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5035
5467
|
* @returns Promise resolving to list of followers
|
|
5036
5468
|
*/
|
|
5037
5469
|
async getFollowers(userId, params = {}, options) {
|
|
5038
|
-
|
|
5470
|
+
log27("Getting followers list for user: %d", userId);
|
|
5039
5471
|
const queryParams = {};
|
|
5040
5472
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5041
5473
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5044,14 +5476,14 @@ var UserFollowService = class extends BaseSDK {
|
|
|
5044
5476
|
`/v1/user/follows/${userId}/followers${queryString}`,
|
|
5045
5477
|
options
|
|
5046
5478
|
);
|
|
5047
|
-
|
|
5479
|
+
log27("Followers list retrieved for user: %d", userId);
|
|
5048
5480
|
return result;
|
|
5049
5481
|
}
|
|
5050
5482
|
};
|
|
5051
5483
|
|
|
5052
5484
|
// src/market/services/UserFavoriteService.ts
|
|
5053
|
-
import
|
|
5054
|
-
var
|
|
5485
|
+
import debug28 from "debug";
|
|
5486
|
+
var log28 = debug28("lobe-market-sdk:user-favorite");
|
|
5055
5487
|
var UserFavoriteService = class extends BaseSDK {
|
|
5056
5488
|
/**
|
|
5057
5489
|
* Add to favorites
|
|
@@ -5066,7 +5498,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5066
5498
|
* @throws Error if already in favorites
|
|
5067
5499
|
*/
|
|
5068
5500
|
async addFavorite(targetType, targetId, options) {
|
|
5069
|
-
|
|
5501
|
+
log28("Adding favorite: %s %d", targetType, targetId);
|
|
5070
5502
|
const body = { targetId, targetType };
|
|
5071
5503
|
const result = await this.request("/v1/user/favorites", {
|
|
5072
5504
|
body: JSON.stringify(body),
|
|
@@ -5076,7 +5508,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5076
5508
|
method: "POST",
|
|
5077
5509
|
...options
|
|
5078
5510
|
});
|
|
5079
|
-
|
|
5511
|
+
log28("Successfully added favorite: %s %d", targetType, targetId);
|
|
5080
5512
|
return result;
|
|
5081
5513
|
}
|
|
5082
5514
|
/**
|
|
@@ -5092,7 +5524,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5092
5524
|
* @throws Error if favorite not found
|
|
5093
5525
|
*/
|
|
5094
5526
|
async removeFavorite(targetType, targetId, options) {
|
|
5095
|
-
|
|
5527
|
+
log28("Removing favorite: %s %d", targetType, targetId);
|
|
5096
5528
|
const body = { targetId, targetType };
|
|
5097
5529
|
const result = await this.request("/v1/user/favorites", {
|
|
5098
5530
|
body: JSON.stringify(body),
|
|
@@ -5102,7 +5534,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5102
5534
|
method: "DELETE",
|
|
5103
5535
|
...options
|
|
5104
5536
|
});
|
|
5105
|
-
|
|
5537
|
+
log28("Successfully removed favorite: %s %d", targetType, targetId);
|
|
5106
5538
|
return result;
|
|
5107
5539
|
}
|
|
5108
5540
|
/**
|
|
@@ -5117,7 +5549,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5117
5549
|
* @returns Promise resolving to favorite status
|
|
5118
5550
|
*/
|
|
5119
5551
|
async checkFavorite(targetType, targetId, options) {
|
|
5120
|
-
|
|
5552
|
+
log28("Checking favorite status: %s %d", targetType, targetId);
|
|
5121
5553
|
const queryString = this.buildQueryString({
|
|
5122
5554
|
targetId: String(targetId),
|
|
5123
5555
|
targetType
|
|
@@ -5126,7 +5558,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5126
5558
|
`/v1/user/favorites/check${queryString}`,
|
|
5127
5559
|
options
|
|
5128
5560
|
);
|
|
5129
|
-
|
|
5561
|
+
log28("Favorite status retrieved: %O", result);
|
|
5130
5562
|
return result;
|
|
5131
5563
|
}
|
|
5132
5564
|
/**
|
|
@@ -5140,7 +5572,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5140
5572
|
* @returns Promise resolving to list of favorites
|
|
5141
5573
|
*/
|
|
5142
5574
|
async getMyFavorites(params = {}, options) {
|
|
5143
|
-
|
|
5575
|
+
log28("Getting my favorites: %O", params);
|
|
5144
5576
|
const queryParams = {};
|
|
5145
5577
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5146
5578
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5150,7 +5582,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5150
5582
|
`/v1/user/favorites/me${queryString}`,
|
|
5151
5583
|
options
|
|
5152
5584
|
);
|
|
5153
|
-
|
|
5585
|
+
log28("My favorites retrieved");
|
|
5154
5586
|
return result;
|
|
5155
5587
|
}
|
|
5156
5588
|
/**
|
|
@@ -5165,7 +5597,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5165
5597
|
* @returns Promise resolving to list of favorites
|
|
5166
5598
|
*/
|
|
5167
5599
|
async getUserFavorites(userId, params = {}, options) {
|
|
5168
|
-
|
|
5600
|
+
log28("Getting favorites for user: %d", userId);
|
|
5169
5601
|
const queryParams = {};
|
|
5170
5602
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5171
5603
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5175,7 +5607,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5175
5607
|
`/v1/user/favorites/${userId}${queryString}`,
|
|
5176
5608
|
options
|
|
5177
5609
|
);
|
|
5178
|
-
|
|
5610
|
+
log28("Favorites retrieved for user: %d", userId);
|
|
5179
5611
|
return result;
|
|
5180
5612
|
}
|
|
5181
5613
|
/**
|
|
@@ -5190,7 +5622,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5190
5622
|
* @returns Promise resolving to list of favorite agents
|
|
5191
5623
|
*/
|
|
5192
5624
|
async getUserFavoriteAgents(userId, params = {}, options) {
|
|
5193
|
-
|
|
5625
|
+
log28("Getting favorite agents for user: %d", userId);
|
|
5194
5626
|
const queryParams = {};
|
|
5195
5627
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5196
5628
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5199,7 +5631,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5199
5631
|
`/v1/user/favorites/${userId}/agents${queryString}`,
|
|
5200
5632
|
options
|
|
5201
5633
|
);
|
|
5202
|
-
|
|
5634
|
+
log28("Favorite agents retrieved for user: %d", userId);
|
|
5203
5635
|
return result;
|
|
5204
5636
|
}
|
|
5205
5637
|
/**
|
|
@@ -5214,7 +5646,7 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5214
5646
|
* @returns Promise resolving to list of favorite plugins
|
|
5215
5647
|
*/
|
|
5216
5648
|
async getUserFavoritePlugins(userId, params = {}, options) {
|
|
5217
|
-
|
|
5649
|
+
log28("Getting favorite plugins for user: %d", userId);
|
|
5218
5650
|
const queryParams = {};
|
|
5219
5651
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5220
5652
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5223,14 +5655,14 @@ var UserFavoriteService = class extends BaseSDK {
|
|
|
5223
5655
|
`/v1/user/favorites/${userId}/plugins${queryString}`,
|
|
5224
5656
|
options
|
|
5225
5657
|
);
|
|
5226
|
-
|
|
5658
|
+
log28("Favorite plugins retrieved for user: %d", userId);
|
|
5227
5659
|
return result;
|
|
5228
5660
|
}
|
|
5229
5661
|
};
|
|
5230
5662
|
|
|
5231
5663
|
// src/market/services/UserLikeService.ts
|
|
5232
|
-
import
|
|
5233
|
-
var
|
|
5664
|
+
import debug29 from "debug";
|
|
5665
|
+
var log29 = debug29("lobe-market-sdk:user-like");
|
|
5234
5666
|
var UserLikeService = class extends BaseSDK {
|
|
5235
5667
|
/**
|
|
5236
5668
|
* Like content
|
|
@@ -5245,7 +5677,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5245
5677
|
* @throws Error if already liked
|
|
5246
5678
|
*/
|
|
5247
5679
|
async like(targetType, targetId, options) {
|
|
5248
|
-
|
|
5680
|
+
log29("Liking: %s %d", targetType, targetId);
|
|
5249
5681
|
const body = { targetId, targetType };
|
|
5250
5682
|
const result = await this.request("/v1/user/likes", {
|
|
5251
5683
|
body: JSON.stringify(body),
|
|
@@ -5255,7 +5687,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5255
5687
|
method: "POST",
|
|
5256
5688
|
...options
|
|
5257
5689
|
});
|
|
5258
|
-
|
|
5690
|
+
log29("Successfully liked: %s %d", targetType, targetId);
|
|
5259
5691
|
return result;
|
|
5260
5692
|
}
|
|
5261
5693
|
/**
|
|
@@ -5271,7 +5703,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5271
5703
|
* @throws Error if like not found
|
|
5272
5704
|
*/
|
|
5273
5705
|
async unlike(targetType, targetId, options) {
|
|
5274
|
-
|
|
5706
|
+
log29("Unliking: %s %d", targetType, targetId);
|
|
5275
5707
|
const body = { targetId, targetType };
|
|
5276
5708
|
const result = await this.request("/v1/user/likes", {
|
|
5277
5709
|
body: JSON.stringify(body),
|
|
@@ -5281,7 +5713,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5281
5713
|
method: "DELETE",
|
|
5282
5714
|
...options
|
|
5283
5715
|
});
|
|
5284
|
-
|
|
5716
|
+
log29("Successfully unliked: %s %d", targetType, targetId);
|
|
5285
5717
|
return result;
|
|
5286
5718
|
}
|
|
5287
5719
|
/**
|
|
@@ -5296,7 +5728,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5296
5728
|
* @returns Promise resolving to toggle response with new like status
|
|
5297
5729
|
*/
|
|
5298
5730
|
async toggleLike(targetType, targetId, options) {
|
|
5299
|
-
|
|
5731
|
+
log29("Toggling like: %s %d", targetType, targetId);
|
|
5300
5732
|
const body = { targetId, targetType };
|
|
5301
5733
|
const result = await this.request("/v1/user/likes/toggle", {
|
|
5302
5734
|
body: JSON.stringify(body),
|
|
@@ -5306,7 +5738,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5306
5738
|
method: "POST",
|
|
5307
5739
|
...options
|
|
5308
5740
|
});
|
|
5309
|
-
|
|
5741
|
+
log29("Like toggled, new status: %O", result);
|
|
5310
5742
|
return result;
|
|
5311
5743
|
}
|
|
5312
5744
|
/**
|
|
@@ -5321,7 +5753,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5321
5753
|
* @returns Promise resolving to like status
|
|
5322
5754
|
*/
|
|
5323
5755
|
async checkLike(targetType, targetId, options) {
|
|
5324
|
-
|
|
5756
|
+
log29("Checking like status: %s %d", targetType, targetId);
|
|
5325
5757
|
const queryString = this.buildQueryString({
|
|
5326
5758
|
targetId: String(targetId),
|
|
5327
5759
|
targetType
|
|
@@ -5330,7 +5762,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5330
5762
|
`/v1/user/likes/check${queryString}`,
|
|
5331
5763
|
options
|
|
5332
5764
|
);
|
|
5333
|
-
|
|
5765
|
+
log29("Like status retrieved: %O", result);
|
|
5334
5766
|
return result;
|
|
5335
5767
|
}
|
|
5336
5768
|
/**
|
|
@@ -5344,7 +5776,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5344
5776
|
* @returns Promise resolving to list of likes
|
|
5345
5777
|
*/
|
|
5346
5778
|
async getMyLikes(params = {}, options) {
|
|
5347
|
-
|
|
5779
|
+
log29("Getting my likes: %O", params);
|
|
5348
5780
|
const queryParams = {};
|
|
5349
5781
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5350
5782
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5354,7 +5786,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5354
5786
|
`/v1/user/likes/me${queryString}`,
|
|
5355
5787
|
options
|
|
5356
5788
|
);
|
|
5357
|
-
|
|
5789
|
+
log29("My likes retrieved");
|
|
5358
5790
|
return result;
|
|
5359
5791
|
}
|
|
5360
5792
|
/**
|
|
@@ -5369,7 +5801,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5369
5801
|
* @returns Promise resolving to list of likes
|
|
5370
5802
|
*/
|
|
5371
5803
|
async getUserLikes(userId, params = {}, options) {
|
|
5372
|
-
|
|
5804
|
+
log29("Getting likes for user: %d", userId);
|
|
5373
5805
|
const queryParams = {};
|
|
5374
5806
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5375
5807
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5379,7 +5811,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5379
5811
|
`/v1/user/likes/${userId}${queryString}`,
|
|
5380
5812
|
options
|
|
5381
5813
|
);
|
|
5382
|
-
|
|
5814
|
+
log29("Likes retrieved for user: %d", userId);
|
|
5383
5815
|
return result;
|
|
5384
5816
|
}
|
|
5385
5817
|
/**
|
|
@@ -5394,7 +5826,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5394
5826
|
* @returns Promise resolving to list of liked agents
|
|
5395
5827
|
*/
|
|
5396
5828
|
async getUserLikedAgents(userId, params = {}, options) {
|
|
5397
|
-
|
|
5829
|
+
log29("Getting liked agents for user: %d", userId);
|
|
5398
5830
|
const queryParams = {};
|
|
5399
5831
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5400
5832
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5403,7 +5835,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5403
5835
|
`/v1/user/likes/${userId}/agents${queryString}`,
|
|
5404
5836
|
options
|
|
5405
5837
|
);
|
|
5406
|
-
|
|
5838
|
+
log29("Liked agents retrieved for user: %d", userId);
|
|
5407
5839
|
return result;
|
|
5408
5840
|
}
|
|
5409
5841
|
/**
|
|
@@ -5418,7 +5850,7 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5418
5850
|
* @returns Promise resolving to list of liked plugins
|
|
5419
5851
|
*/
|
|
5420
5852
|
async getUserLikedPlugins(userId, params = {}, options) {
|
|
5421
|
-
|
|
5853
|
+
log29("Getting liked plugins for user: %d", userId);
|
|
5422
5854
|
const queryParams = {};
|
|
5423
5855
|
if (params.limit !== void 0) queryParams.limit = String(params.limit);
|
|
5424
5856
|
if (params.offset !== void 0) queryParams.offset = String(params.offset);
|
|
@@ -5427,14 +5859,14 @@ var UserLikeService = class extends BaseSDK {
|
|
|
5427
5859
|
`/v1/user/likes/${userId}/plugins${queryString}`,
|
|
5428
5860
|
options
|
|
5429
5861
|
);
|
|
5430
|
-
|
|
5862
|
+
log29("Liked plugins retrieved for user: %d", userId);
|
|
5431
5863
|
return result;
|
|
5432
5864
|
}
|
|
5433
5865
|
};
|
|
5434
5866
|
|
|
5435
5867
|
// src/market/services/UserPublishService.ts
|
|
5436
|
-
import
|
|
5437
|
-
var
|
|
5868
|
+
import debug30 from "debug";
|
|
5869
|
+
var log30 = debug30("lobe-market-sdk:user-publish");
|
|
5438
5870
|
var UserPublishService = class extends BaseSDK {
|
|
5439
5871
|
/**
|
|
5440
5872
|
* Lists all plugins owned by the authenticated user
|
|
@@ -5444,9 +5876,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5444
5876
|
*/
|
|
5445
5877
|
async listPlugins(options) {
|
|
5446
5878
|
var _a;
|
|
5447
|
-
|
|
5879
|
+
log30("Listing user plugins");
|
|
5448
5880
|
const result = await this.request("/v1/user/plugins", options);
|
|
5449
|
-
|
|
5881
|
+
log30("Found %d user plugins", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
5450
5882
|
return result;
|
|
5451
5883
|
}
|
|
5452
5884
|
/**
|
|
@@ -5457,9 +5889,9 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5457
5889
|
*/
|
|
5458
5890
|
async listSkills(options) {
|
|
5459
5891
|
var _a;
|
|
5460
|
-
|
|
5892
|
+
log30("Listing user skills");
|
|
5461
5893
|
const result = await this.request("/v1/user/skills", options);
|
|
5462
|
-
|
|
5894
|
+
log30("Found %d user skills", ((_a = result.data) == null ? void 0 : _a.length) || 0);
|
|
5463
5895
|
return result;
|
|
5464
5896
|
}
|
|
5465
5897
|
/**
|
|
@@ -5471,7 +5903,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5471
5903
|
* @returns Promise resolving to the publish result
|
|
5472
5904
|
*/
|
|
5473
5905
|
async publishSkillVersion(identifier, zipBuffer, options) {
|
|
5474
|
-
|
|
5906
|
+
log30("Publishing skill version for: %s", identifier);
|
|
5475
5907
|
const formData = new FormData();
|
|
5476
5908
|
const arrayBuffer = zipBuffer instanceof ArrayBuffer ? zipBuffer : zipBuffer.buffer.slice(
|
|
5477
5909
|
zipBuffer.byteOffset,
|
|
@@ -5487,7 +5919,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5487
5919
|
...options
|
|
5488
5920
|
}
|
|
5489
5921
|
);
|
|
5490
|
-
|
|
5922
|
+
log30("Published skill version: %s@%s", identifier, result.version);
|
|
5491
5923
|
return result;
|
|
5492
5924
|
}
|
|
5493
5925
|
/**
|
|
@@ -5498,11 +5930,11 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5498
5930
|
*/
|
|
5499
5931
|
async scanClaimableAssets(assetType) {
|
|
5500
5932
|
var _a;
|
|
5501
|
-
|
|
5933
|
+
log30("Scanning claimable %s", assetType);
|
|
5502
5934
|
const result = await this.request(
|
|
5503
5935
|
`/v1/user/claims/scan/${assetType}`
|
|
5504
5936
|
);
|
|
5505
|
-
|
|
5937
|
+
log30("Found %d claimable %s", ((_a = result.data) == null ? void 0 : _a.length) || 0, assetType);
|
|
5506
5938
|
return result;
|
|
5507
5939
|
}
|
|
5508
5940
|
/**
|
|
@@ -5513,13 +5945,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5513
5945
|
* @returns Promise resolving to the claim result
|
|
5514
5946
|
*/
|
|
5515
5947
|
async claimAsset(assetId, assetType) {
|
|
5516
|
-
|
|
5948
|
+
log30("Claiming %s with id: %d", assetType, assetId);
|
|
5517
5949
|
const result = await this.request("/v1/user/claims", {
|
|
5518
5950
|
body: JSON.stringify({ assetId, assetType }),
|
|
5519
5951
|
headers: { "Content-Type": "application/json" },
|
|
5520
5952
|
method: "POST"
|
|
5521
5953
|
});
|
|
5522
|
-
|
|
5954
|
+
log30("Claim result for %s %d: %s", assetType, assetId, result.success);
|
|
5523
5955
|
return result;
|
|
5524
5956
|
}
|
|
5525
5957
|
/**
|
|
@@ -5530,12 +5962,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5530
5962
|
* @returns Promise resolving to the delete result
|
|
5531
5963
|
*/
|
|
5532
5964
|
async deleteSkill(identifier, options) {
|
|
5533
|
-
|
|
5965
|
+
log30("Deleting skill: %s", identifier);
|
|
5534
5966
|
const result = await this.request(
|
|
5535
5967
|
`/v1/user/skills/${encodeURIComponent(identifier)}`,
|
|
5536
5968
|
{ method: "DELETE", ...options }
|
|
5537
5969
|
);
|
|
5538
|
-
|
|
5970
|
+
log30("Deleted skill: %s", identifier);
|
|
5539
5971
|
return result;
|
|
5540
5972
|
}
|
|
5541
5973
|
/**
|
|
@@ -5547,7 +5979,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5547
5979
|
* @returns Promise resolving to the updated status
|
|
5548
5980
|
*/
|
|
5549
5981
|
async updateSkillStatus(identifier, status, options) {
|
|
5550
|
-
|
|
5982
|
+
log30("Updating skill status: %s \u2192 %s", identifier, status);
|
|
5551
5983
|
const result = await this.request(
|
|
5552
5984
|
`/v1/user/skills/${encodeURIComponent(identifier)}/status`,
|
|
5553
5985
|
{
|
|
@@ -5557,7 +5989,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5557
5989
|
...options
|
|
5558
5990
|
}
|
|
5559
5991
|
);
|
|
5560
|
-
|
|
5992
|
+
log30("Updated skill status: %s \u2192 %s", identifier, result.status);
|
|
5561
5993
|
return result;
|
|
5562
5994
|
}
|
|
5563
5995
|
/**
|
|
@@ -5568,12 +6000,12 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5568
6000
|
* @returns Promise resolving to the delete result
|
|
5569
6001
|
*/
|
|
5570
6002
|
async deletePlugin(identifier, options) {
|
|
5571
|
-
|
|
6003
|
+
log30("Deleting plugin: %s", identifier);
|
|
5572
6004
|
const result = await this.request(
|
|
5573
6005
|
`/v1/user/plugins/${encodeURIComponent(identifier)}`,
|
|
5574
6006
|
{ method: "DELETE", ...options }
|
|
5575
6007
|
);
|
|
5576
|
-
|
|
6008
|
+
log30("Deleted plugin: %s", identifier);
|
|
5577
6009
|
return result;
|
|
5578
6010
|
}
|
|
5579
6011
|
/**
|
|
@@ -5585,7 +6017,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5585
6017
|
* @returns Promise resolving to the updated status
|
|
5586
6018
|
*/
|
|
5587
6019
|
async updatePluginStatus(identifier, status, options) {
|
|
5588
|
-
|
|
6020
|
+
log30("Updating plugin status: %s \u2192 %s", identifier, status);
|
|
5589
6021
|
const result = await this.request(
|
|
5590
6022
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/status`,
|
|
5591
6023
|
{
|
|
@@ -5595,7 +6027,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5595
6027
|
...options
|
|
5596
6028
|
}
|
|
5597
6029
|
);
|
|
5598
|
-
|
|
6030
|
+
log30("Updated plugin status: %s \u2192 %s", identifier, result.status);
|
|
5599
6031
|
return result;
|
|
5600
6032
|
}
|
|
5601
6033
|
/**
|
|
@@ -5607,7 +6039,7 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5607
6039
|
* @returns Promise resolving to the publish result
|
|
5608
6040
|
*/
|
|
5609
6041
|
async publishPluginVersion(identifier, data, options) {
|
|
5610
|
-
|
|
6042
|
+
log30("Publishing plugin version for: %s", identifier);
|
|
5611
6043
|
const result = await this.request(
|
|
5612
6044
|
`/v1/user/plugins/${encodeURIComponent(identifier)}/versions`,
|
|
5613
6045
|
{
|
|
@@ -5617,13 +6049,13 @@ var UserPublishService = class extends BaseSDK {
|
|
|
5617
6049
|
...options
|
|
5618
6050
|
}
|
|
5619
6051
|
);
|
|
5620
|
-
|
|
6052
|
+
log30("Published plugin version: %s@%s", identifier, result.version);
|
|
5621
6053
|
return result;
|
|
5622
6054
|
}
|
|
5623
6055
|
};
|
|
5624
6056
|
|
|
5625
6057
|
// src/market/market-sdk.ts
|
|
5626
|
-
var
|
|
6058
|
+
var log31 = debug31("lobe-market-sdk");
|
|
5627
6059
|
var MarketSDK = class extends BaseSDK {
|
|
5628
6060
|
/**
|
|
5629
6061
|
* Creates a new MarketSDK instance
|
|
@@ -5636,7 +6068,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
5636
6068
|
tokenExpiry: void 0
|
|
5637
6069
|
};
|
|
5638
6070
|
super(options, void 0, sharedTokenState);
|
|
5639
|
-
|
|
6071
|
+
log31("MarketSDK instance created");
|
|
5640
6072
|
this.agentProfile = new AgentProfileService(options, this.headers, sharedTokenState);
|
|
5641
6073
|
this.agents = new AgentService2(options, this.headers, sharedTokenState);
|
|
5642
6074
|
this.agentGroups = new AgentGroupService(options, this.headers, sharedTokenState);
|
|
@@ -5644,6 +6076,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
5644
6076
|
this.connect = new ConnectService(options, this.headers, sharedTokenState);
|
|
5645
6077
|
this.creds = new CredService(options, this.headers, sharedTokenState);
|
|
5646
6078
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
6079
|
+
this.organizations = new OrganizationService2(options, this.headers, sharedTokenState);
|
|
5647
6080
|
this.user = new UserService(options, this.headers, sharedTokenState);
|
|
5648
6081
|
this.userPublish = new UserPublishService(options, this.headers, sharedTokenState);
|
|
5649
6082
|
this.follows = new UserFollowService(options, this.headers, sharedTokenState);
|
|
@@ -5683,7 +6116,7 @@ var MarketSDK = class extends BaseSDK {
|
|
|
5683
6116
|
* @deprecated Use auth.registerClient() instead
|
|
5684
6117
|
*/
|
|
5685
6118
|
async registerClient(request) {
|
|
5686
|
-
|
|
6119
|
+
log31("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
5687
6120
|
return this.auth.registerClient(request);
|
|
5688
6121
|
}
|
|
5689
6122
|
};
|