@lobehub/market-sdk 0.22.7 → 0.22.9-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +664 -2
- package/dist/index.mjs +424 -37
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1380,12 +1380,406 @@ var MarketAdmin = class extends BaseSDK {
|
|
|
1380
1380
|
};
|
|
1381
1381
|
|
|
1382
1382
|
// src/market/market-sdk.ts
|
|
1383
|
-
import
|
|
1383
|
+
import debug13 from "debug";
|
|
1384
1384
|
|
|
1385
|
-
// src/market/services/
|
|
1385
|
+
// src/market/services/AgentService.ts
|
|
1386
1386
|
import debug9 from "debug";
|
|
1387
|
+
var log9 = debug9("lobe-market-sdk:agents");
|
|
1388
|
+
var AgentService = class extends BaseSDK {
|
|
1389
|
+
/**
|
|
1390
|
+
* Retrieves a list of agents from the marketplace
|
|
1391
|
+
*
|
|
1392
|
+
* Supports filtering, pagination, and localization of results.
|
|
1393
|
+
*
|
|
1394
|
+
* @param params - Query parameters for filtering and pagination
|
|
1395
|
+
* @param options - Optional request options
|
|
1396
|
+
* @returns Promise resolving to the agent list response containing items and pagination info
|
|
1397
|
+
*/
|
|
1398
|
+
async getAgentList(params = {}, options) {
|
|
1399
|
+
const locale = params.locale || this.defaultLocale;
|
|
1400
|
+
const queryParams = { ...params, locale };
|
|
1401
|
+
const queryString = this.buildQueryString(queryParams);
|
|
1402
|
+
log9("Getting agent list: %O", queryParams);
|
|
1403
|
+
const result = await this.request(`/v1/agents${queryString}`, options);
|
|
1404
|
+
log9("Retrieved %d agents", result.items.length);
|
|
1405
|
+
return result;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* Retrieves detailed information about a specific agent
|
|
1409
|
+
*
|
|
1410
|
+
* Returns complete agent information including A2A AgentCard data,
|
|
1411
|
+
* configuration, skills, and localized content.
|
|
1412
|
+
*
|
|
1413
|
+
* @param id - Unique identifier of the agent
|
|
1414
|
+
* @param params - Query parameters for locale and version
|
|
1415
|
+
* @param options - Optional request options
|
|
1416
|
+
* @returns Promise resolving to the agent detail information
|
|
1417
|
+
*/
|
|
1418
|
+
async getAgentDetail(id, params = {}, options) {
|
|
1419
|
+
const locale = params.locale || this.defaultLocale;
|
|
1420
|
+
const queryParams = { locale };
|
|
1421
|
+
if (params.version !== void 0) {
|
|
1422
|
+
queryParams.version = params.version.toString();
|
|
1423
|
+
}
|
|
1424
|
+
const queryString = this.buildQueryString(queryParams);
|
|
1425
|
+
log9("Getting agent detail: %O", { id, ...params });
|
|
1426
|
+
const result = await this.request(
|
|
1427
|
+
`/v1/agents/detail/${id}${queryString}`,
|
|
1428
|
+
options
|
|
1429
|
+
);
|
|
1430
|
+
log9("Agent detail successfully retrieved: %s", id);
|
|
1431
|
+
return result;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* Retrieves all published agent identifiers
|
|
1435
|
+
*
|
|
1436
|
+
* Returns a lightweight list of all published agent identifiers without
|
|
1437
|
+
* full agent metadata. This is useful for clients that need to know which
|
|
1438
|
+
* agents are available without fetching complete agent information.
|
|
1439
|
+
*
|
|
1440
|
+
* @param options - Optional request options
|
|
1441
|
+
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
1442
|
+
*/
|
|
1443
|
+
async getPublishedIdentifiers(options) {
|
|
1444
|
+
log9("Getting published agent identifiers");
|
|
1445
|
+
const result = await this.request(
|
|
1446
|
+
"/v1/agents/identifiers",
|
|
1447
|
+
options
|
|
1448
|
+
);
|
|
1449
|
+
log9("Retrieved %d published agent identifiers", result.length);
|
|
1450
|
+
return result;
|
|
1451
|
+
}
|
|
1452
|
+
/**
|
|
1453
|
+
* Retrieves agent categories and their counts
|
|
1454
|
+
*
|
|
1455
|
+
* Returns a list of categories along with the number of agents in each category.
|
|
1456
|
+
* Useful for building category filters in a UI. Supports optional search filtering
|
|
1457
|
+
* via 'q' parameter and locale specification.
|
|
1458
|
+
*
|
|
1459
|
+
* @param params - Query parameters for filtering categories
|
|
1460
|
+
* @param options - Optional request options
|
|
1461
|
+
* @returns Promise resolving to an array of category items with counts
|
|
1462
|
+
*/
|
|
1463
|
+
async getCategories(params = {}, options) {
|
|
1464
|
+
const locale = params.locale || this.defaultLocale;
|
|
1465
|
+
const queryParams = { ...params, locale };
|
|
1466
|
+
const queryString = this.buildQueryString(queryParams);
|
|
1467
|
+
log9("Getting agent categories: %O", queryParams);
|
|
1468
|
+
const result = await this.request(
|
|
1469
|
+
`/v1/agents/categories${queryString}`,
|
|
1470
|
+
options
|
|
1471
|
+
);
|
|
1472
|
+
log9("Retrieved %d categories", result.length);
|
|
1473
|
+
return result;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Uploads an agent to the marketplace
|
|
1477
|
+
*
|
|
1478
|
+
* Allows users to upload new agents or update existing ones.
|
|
1479
|
+
* The agent data should conform to the A2A AgentCard specification.
|
|
1480
|
+
*
|
|
1481
|
+
* @param agentData - The agent data to upload
|
|
1482
|
+
* @param options - Optional request options
|
|
1483
|
+
* @returns Promise resolving to the upload response
|
|
1484
|
+
*/
|
|
1485
|
+
async uploadAgent(agentData, options) {
|
|
1486
|
+
log9("Uploading agent: %s@%s", agentData.agentIdentifier, agentData.version.version);
|
|
1487
|
+
const result = await this.request("/v1/agents/upload", {
|
|
1488
|
+
body: JSON.stringify(agentData),
|
|
1489
|
+
headers: {
|
|
1490
|
+
"Content-Type": "application/json"
|
|
1491
|
+
},
|
|
1492
|
+
method: "POST",
|
|
1493
|
+
...options
|
|
1494
|
+
});
|
|
1495
|
+
log9("Agent uploaded successfully: %O", result);
|
|
1496
|
+
return result;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* Creates a new agent in the marketplace
|
|
1500
|
+
*
|
|
1501
|
+
* @param agentData - The agent data to create
|
|
1502
|
+
* @param options - Optional request options
|
|
1503
|
+
* @returns Promise resolving to the created agent response
|
|
1504
|
+
*/
|
|
1505
|
+
async createAgent(agentData, options) {
|
|
1506
|
+
log9("Creating agent: %s", agentData.identifier);
|
|
1507
|
+
const result = await this.request("/v1/agents/create", {
|
|
1508
|
+
body: JSON.stringify(agentData),
|
|
1509
|
+
headers: {
|
|
1510
|
+
"Content-Type": "application/json"
|
|
1511
|
+
},
|
|
1512
|
+
method: "POST",
|
|
1513
|
+
...options
|
|
1514
|
+
});
|
|
1515
|
+
log9("Agent created successfully: %O", result);
|
|
1516
|
+
return result;
|
|
1517
|
+
}
|
|
1518
|
+
/**
|
|
1519
|
+
* Creates a new version for an existing agent
|
|
1520
|
+
*
|
|
1521
|
+
* @param versionData - The version data to create
|
|
1522
|
+
* @param options - Optional request options
|
|
1523
|
+
* @returns Promise resolving to the created version response
|
|
1524
|
+
*/
|
|
1525
|
+
async createAgentVersion(versionData, options) {
|
|
1526
|
+
log9("Creating agent version: %s", versionData.identifier);
|
|
1527
|
+
const result = await this.request("/v1/agents/version/create", {
|
|
1528
|
+
body: JSON.stringify(versionData),
|
|
1529
|
+
headers: {
|
|
1530
|
+
"Content-Type": "application/json"
|
|
1531
|
+
},
|
|
1532
|
+
method: "POST",
|
|
1533
|
+
...options
|
|
1534
|
+
});
|
|
1535
|
+
log9("Agent version created successfully: %O", result);
|
|
1536
|
+
return result;
|
|
1537
|
+
}
|
|
1538
|
+
/**
|
|
1539
|
+
* Modifies an existing agent
|
|
1540
|
+
*
|
|
1541
|
+
* @param agentData - The agent data to modify
|
|
1542
|
+
* @param options - Optional request options
|
|
1543
|
+
* @returns Promise resolving to the modified agent response
|
|
1544
|
+
*/
|
|
1545
|
+
async modifyAgent(agentData, options) {
|
|
1546
|
+
log9("Modifying agent: %s", agentData.identifier);
|
|
1547
|
+
const result = await this.request("/v1/agents/modify", {
|
|
1548
|
+
body: JSON.stringify(agentData),
|
|
1549
|
+
headers: {
|
|
1550
|
+
"Content-Type": "application/json"
|
|
1551
|
+
},
|
|
1552
|
+
method: "POST",
|
|
1553
|
+
...options
|
|
1554
|
+
});
|
|
1555
|
+
log9("Agent modified successfully: %O", result);
|
|
1556
|
+
return result;
|
|
1557
|
+
}
|
|
1558
|
+
/**
|
|
1559
|
+
* Modifies a specific version of an existing agent
|
|
1560
|
+
*
|
|
1561
|
+
* @param versionData - The version data to modify
|
|
1562
|
+
* @param options - Optional request options
|
|
1563
|
+
* @returns Promise resolving to the modified version response
|
|
1564
|
+
*/
|
|
1565
|
+
async modifyAgentVersion(versionData, options) {
|
|
1566
|
+
log9("Modifying agent version: %s@%s", versionData.identifier, versionData.version);
|
|
1567
|
+
const result = await this.request("/v1/agents/version/modify", {
|
|
1568
|
+
body: JSON.stringify(versionData),
|
|
1569
|
+
headers: {
|
|
1570
|
+
"Content-Type": "application/json"
|
|
1571
|
+
},
|
|
1572
|
+
method: "POST",
|
|
1573
|
+
...options
|
|
1574
|
+
});
|
|
1575
|
+
log9("Agent version modified successfully: %O", result);
|
|
1576
|
+
return result;
|
|
1577
|
+
}
|
|
1578
|
+
/**
|
|
1579
|
+
* Checks if an agent exists in the marketplace
|
|
1580
|
+
*
|
|
1581
|
+
* @param identifier - Unique identifier of the agent
|
|
1582
|
+
* @param options - Optional request options
|
|
1583
|
+
* @returns Promise resolving to true if agent exists, false otherwise
|
|
1584
|
+
*/
|
|
1585
|
+
async checkAgentExists(identifier, options) {
|
|
1586
|
+
log9("Checking if agent exists: %s", identifier);
|
|
1587
|
+
try {
|
|
1588
|
+
await this.getAgentDetail(identifier, {}, options);
|
|
1589
|
+
log9("Agent exists: %s", identifier);
|
|
1590
|
+
return true;
|
|
1591
|
+
} catch (e) {
|
|
1592
|
+
log9("Agent does not exist: %s", identifier);
|
|
1593
|
+
return false;
|
|
1594
|
+
}
|
|
1595
|
+
}
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
// src/market/services/AuthService.ts
|
|
1599
|
+
import debug10 from "debug";
|
|
1387
1600
|
import urlJoin2 from "url-join";
|
|
1388
|
-
var
|
|
1601
|
+
var log10 = debug10("lobe-market-sdk:auth");
|
|
1602
|
+
var _AuthService = class _AuthService extends BaseSDK {
|
|
1603
|
+
/**
|
|
1604
|
+
* Retrieves user information from the OIDC userinfo endpoint
|
|
1605
|
+
*
|
|
1606
|
+
* Requires a valid access token in the Authorization header.
|
|
1607
|
+
*
|
|
1608
|
+
* @param accessToken - The access token to use for authentication
|
|
1609
|
+
* @param options - Optional request options
|
|
1610
|
+
* @returns Promise resolving to the user information
|
|
1611
|
+
*/
|
|
1612
|
+
async getUserInfo(accessToken, options) {
|
|
1613
|
+
log10("Getting user info");
|
|
1614
|
+
const userInfoUrl = urlJoin2(this.baseUrl, "market-oidc/userinfo");
|
|
1615
|
+
const response = await fetch(userInfoUrl, {
|
|
1616
|
+
headers: {
|
|
1617
|
+
"Authorization": `Bearer ${accessToken}`,
|
|
1618
|
+
"Content-Type": "application/json"
|
|
1619
|
+
},
|
|
1620
|
+
method: "GET",
|
|
1621
|
+
...options
|
|
1622
|
+
});
|
|
1623
|
+
if (!response.ok) {
|
|
1624
|
+
const errorMsg = `Failed to fetch user info: ${response.status} ${response.statusText}`;
|
|
1625
|
+
log10("Error: %s", errorMsg);
|
|
1626
|
+
throw new Error(errorMsg);
|
|
1627
|
+
}
|
|
1628
|
+
const userInfo = await response.json();
|
|
1629
|
+
log10("User info retrieved successfully");
|
|
1630
|
+
return userInfo;
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Registers a new OAuth client with the marketplace
|
|
1634
|
+
*
|
|
1635
|
+
* This is typically used for device registration or application setup.
|
|
1636
|
+
* Returns client credentials that can be used for M2M authentication.
|
|
1637
|
+
*
|
|
1638
|
+
* @param clientData - The client registration data
|
|
1639
|
+
* @param options - Optional request options
|
|
1640
|
+
* @returns Promise resolving to the client credentials
|
|
1641
|
+
*/
|
|
1642
|
+
async registerClient(clientData, options) {
|
|
1643
|
+
log10("Registering client: %s (%s)", clientData.clientName, clientData.clientType);
|
|
1644
|
+
const result = await this.request("/v1/clients/register", {
|
|
1645
|
+
body: JSON.stringify(clientData),
|
|
1646
|
+
headers: {
|
|
1647
|
+
"Content-Type": "application/json"
|
|
1648
|
+
},
|
|
1649
|
+
method: "POST",
|
|
1650
|
+
...options
|
|
1651
|
+
});
|
|
1652
|
+
log10("Client registered successfully: %s", result.client_id);
|
|
1653
|
+
return result;
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Fetches an M2M (Machine-to-Machine) access token
|
|
1657
|
+
*
|
|
1658
|
+
* Uses client credentials to obtain an access token for server-to-server communication.
|
|
1659
|
+
* This method requires clientId and clientSecret to be set in the SDK options.
|
|
1660
|
+
*
|
|
1661
|
+
* @returns Promise resolving to the access token and expiration time
|
|
1662
|
+
*/
|
|
1663
|
+
async getM2MToken() {
|
|
1664
|
+
log10("Fetching M2M token");
|
|
1665
|
+
const tokenInfo = await this.fetchM2MToken();
|
|
1666
|
+
log10("M2M token fetched successfully");
|
|
1667
|
+
return tokenInfo;
|
|
1668
|
+
}
|
|
1669
|
+
/** OAuth handoff response shapes */
|
|
1670
|
+
// Using inline type aliases inside the class for better encapsulation
|
|
1671
|
+
// success: 200
|
|
1672
|
+
static typeHandoffSuccess(data) {
|
|
1673
|
+
return {
|
|
1674
|
+
clientId: data.clientId,
|
|
1675
|
+
code: data.code,
|
|
1676
|
+
redirectUri: data.redirectUri,
|
|
1677
|
+
status: _AuthService.HANDOFF_SUCCESS_STATUS
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
/**
|
|
1681
|
+
* Get OAuth handoff status and data by id.
|
|
1682
|
+
* Maps server HTTP statuses to a typed status union:
|
|
1683
|
+
* - 200: success
|
|
1684
|
+
* - 202: pending
|
|
1685
|
+
* - 404: consumed
|
|
1686
|
+
* - 410: expired
|
|
1687
|
+
* - others: error (throws)
|
|
1688
|
+
*/
|
|
1689
|
+
async getOAuthHandoff(id, options) {
|
|
1690
|
+
var _a, _b;
|
|
1691
|
+
if (!id) throw new Error("id is required");
|
|
1692
|
+
log10("Getting OAuth handoff: %s", id);
|
|
1693
|
+
const handoffUrl = `${urlJoin2(this.baseUrl, "market-oidc/handoff")}?id=${encodeURIComponent(id)}`;
|
|
1694
|
+
const response = await fetch(handoffUrl, {
|
|
1695
|
+
headers: {
|
|
1696
|
+
"Content-Type": "application/json"
|
|
1697
|
+
},
|
|
1698
|
+
method: "GET",
|
|
1699
|
+
...options
|
|
1700
|
+
});
|
|
1701
|
+
if (response.status === 200) {
|
|
1702
|
+
const json = await response.json();
|
|
1703
|
+
const result = _AuthService.typeHandoffSuccess({
|
|
1704
|
+
clientId: json.clientId,
|
|
1705
|
+
code: json.code,
|
|
1706
|
+
redirectUri: json.redirectUri
|
|
1707
|
+
});
|
|
1708
|
+
log10("OAuth handoff success for id: %s", id);
|
|
1709
|
+
return result;
|
|
1710
|
+
}
|
|
1711
|
+
if (response.status === 202) {
|
|
1712
|
+
log10("OAuth handoff pending for id: %s", id);
|
|
1713
|
+
return { status: _AuthService.HANDOFF_PENDING_STATUS };
|
|
1714
|
+
}
|
|
1715
|
+
if (response.status === 404) {
|
|
1716
|
+
log10("OAuth handoff consumed for id: %s", id);
|
|
1717
|
+
return { status: _AuthService.HANDOFF_CONSUMED_STATUS };
|
|
1718
|
+
}
|
|
1719
|
+
if (response.status === 410) {
|
|
1720
|
+
log10("OAuth handoff expired for id: %s", id);
|
|
1721
|
+
return { status: _AuthService.HANDOFF_EXPIRED_STATUS };
|
|
1722
|
+
}
|
|
1723
|
+
let errorMessage = `Failed to fetch OAuth handoff (status ${response.status} ${response.statusText})`;
|
|
1724
|
+
try {
|
|
1725
|
+
const errJson = await response.json();
|
|
1726
|
+
if (errJson && (errJson.message || errJson.error)) {
|
|
1727
|
+
errorMessage = `${errorMessage}: ${(_a = errJson.error) != null ? _a : ""} ${(_b = errJson.message) != null ? _b : ""}`.trim();
|
|
1728
|
+
}
|
|
1729
|
+
} catch (e) {
|
|
1730
|
+
}
|
|
1731
|
+
log10("Error: %s", errorMessage);
|
|
1732
|
+
throw new Error(errorMessage);
|
|
1733
|
+
}
|
|
1734
|
+
/**
|
|
1735
|
+
* Poll OAuth handoff result until it becomes terminal.
|
|
1736
|
+
* Terminal statuses: success, expired, consumed.
|
|
1737
|
+
* Non-terminal: pending → continue polling.
|
|
1738
|
+
*/
|
|
1739
|
+
async pollOAuthHandoff(id, params = {}) {
|
|
1740
|
+
var _a, _b;
|
|
1741
|
+
const intervalMs = (_a = params.intervalMs) != null ? _a : 1500;
|
|
1742
|
+
const timeoutMs = (_b = params.timeoutMs) != null ? _b : 6e4;
|
|
1743
|
+
const startedAt = Date.now();
|
|
1744
|
+
const { signal, requestInit } = params;
|
|
1745
|
+
log10("Start polling OAuth handoff: %s", id);
|
|
1746
|
+
while (true) {
|
|
1747
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
1748
|
+
const err = new Error("Polling aborted");
|
|
1749
|
+
log10("Error: %s", err.message);
|
|
1750
|
+
throw err;
|
|
1751
|
+
}
|
|
1752
|
+
if (Date.now() - startedAt > timeoutMs) {
|
|
1753
|
+
const err = new Error("Polling timeout");
|
|
1754
|
+
log10("Error: %s", err.message);
|
|
1755
|
+
throw err;
|
|
1756
|
+
}
|
|
1757
|
+
const result = await this.getOAuthHandoff(id, requestInit);
|
|
1758
|
+
if (result.status === "success" || result.status === "expired" || result.status === "consumed") {
|
|
1759
|
+
log10("Stop polling OAuth handoff (terminal): %s -> %s", id, result.status);
|
|
1760
|
+
return result;
|
|
1761
|
+
}
|
|
1762
|
+
await new Promise((resolve) => {
|
|
1763
|
+
setTimeout(resolve, intervalMs);
|
|
1764
|
+
});
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
};
|
|
1768
|
+
// ===== OAuth Handoff Types =====
|
|
1769
|
+
/** Successful handoff payload */
|
|
1770
|
+
_AuthService.HANDOFF_SUCCESS_STATUS = "success";
|
|
1771
|
+
/** Pending handoff status */
|
|
1772
|
+
_AuthService.HANDOFF_PENDING_STATUS = "pending";
|
|
1773
|
+
/** Consumed handoff status */
|
|
1774
|
+
_AuthService.HANDOFF_CONSUMED_STATUS = "consumed";
|
|
1775
|
+
/** Expired handoff status */
|
|
1776
|
+
_AuthService.HANDOFF_EXPIRED_STATUS = "expired";
|
|
1777
|
+
var AuthService = _AuthService;
|
|
1778
|
+
|
|
1779
|
+
// src/market/services/DiscoveryService.ts
|
|
1780
|
+
import debug11 from "debug";
|
|
1781
|
+
import urlJoin3 from "url-join";
|
|
1782
|
+
var log11 = debug11("lobe-market-sdk:discovery");
|
|
1389
1783
|
var DiscoveryService = class extends BaseSDK {
|
|
1390
1784
|
/**
|
|
1391
1785
|
* Retrieves the service discovery document
|
|
@@ -1397,24 +1791,24 @@ var DiscoveryService = class extends BaseSDK {
|
|
|
1397
1791
|
* @returns Promise resolving to the service discovery document
|
|
1398
1792
|
*/
|
|
1399
1793
|
async getDiscoveryDocument() {
|
|
1400
|
-
|
|
1794
|
+
log11("Fetching discovery document");
|
|
1401
1795
|
if (this.discoveryDoc) {
|
|
1402
|
-
|
|
1796
|
+
log11("Returning cached discovery document");
|
|
1403
1797
|
return this.discoveryDoc;
|
|
1404
1798
|
}
|
|
1405
|
-
const res = await fetch(
|
|
1799
|
+
const res = await fetch(urlJoin3(this.baseUrl, "/.well-known/discovery"));
|
|
1406
1800
|
if (!res.ok) {
|
|
1407
1801
|
throw new Error(await res.text());
|
|
1408
1802
|
}
|
|
1409
1803
|
this.discoveryDoc = await res.json();
|
|
1410
|
-
|
|
1804
|
+
log11("Discovery document successfully fetched");
|
|
1411
1805
|
return this.discoveryDoc;
|
|
1412
1806
|
}
|
|
1413
1807
|
};
|
|
1414
1808
|
|
|
1415
1809
|
// src/market/services/PluginsService.ts
|
|
1416
|
-
import
|
|
1417
|
-
var
|
|
1810
|
+
import debug12 from "debug";
|
|
1811
|
+
var log12 = debug12("lobe-market-sdk:plugins");
|
|
1418
1812
|
var PluginsService = class extends BaseSDK {
|
|
1419
1813
|
/**
|
|
1420
1814
|
* Retrieves a list of plugins from the marketplace
|
|
@@ -1429,9 +1823,9 @@ var PluginsService = class extends BaseSDK {
|
|
|
1429
1823
|
const locale = params.locale || this.defaultLocale;
|
|
1430
1824
|
const queryParams = { ...params, locale };
|
|
1431
1825
|
const queryString = this.buildQueryString(queryParams);
|
|
1432
|
-
|
|
1826
|
+
log12("Getting plugin list: %O", queryParams);
|
|
1433
1827
|
const result = await this.request(`/v1/plugins${queryString}`, options);
|
|
1434
|
-
|
|
1828
|
+
log12("Retrieved %d plugins", result.items.length);
|
|
1435
1829
|
return result;
|
|
1436
1830
|
}
|
|
1437
1831
|
/**
|
|
@@ -1449,12 +1843,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
1449
1843
|
const locale = params.locale || this.defaultLocale;
|
|
1450
1844
|
const queryParams = { ...params, locale };
|
|
1451
1845
|
const queryString = this.buildQueryString(queryParams);
|
|
1452
|
-
|
|
1846
|
+
log12("Getting plugin categories: %O", queryParams);
|
|
1453
1847
|
const result = await this.request(
|
|
1454
1848
|
`/v1/plugins/categories${queryString}`,
|
|
1455
1849
|
options
|
|
1456
1850
|
);
|
|
1457
|
-
|
|
1851
|
+
log12("Retrieved %d categories", result.length);
|
|
1458
1852
|
return result;
|
|
1459
1853
|
}
|
|
1460
1854
|
/**
|
|
@@ -1467,12 +1861,12 @@ var PluginsService = class extends BaseSDK {
|
|
|
1467
1861
|
* @returns Promise resolving to an array containing identifiers array and last modified time
|
|
1468
1862
|
*/
|
|
1469
1863
|
async getPublishedIdentifiers(options) {
|
|
1470
|
-
|
|
1864
|
+
log12("Getting published plugin identifiers");
|
|
1471
1865
|
const result = await this.request(
|
|
1472
1866
|
"/v1/plugins/identifiers",
|
|
1473
1867
|
options
|
|
1474
1868
|
);
|
|
1475
|
-
|
|
1869
|
+
log12("Retrieved %d published plugin identifiers", result.length);
|
|
1476
1870
|
return result;
|
|
1477
1871
|
}
|
|
1478
1872
|
/**
|
|
@@ -1492,7 +1886,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1492
1886
|
version,
|
|
1493
1887
|
identifier
|
|
1494
1888
|
}, options) {
|
|
1495
|
-
|
|
1889
|
+
log12("Getting plugin manifest: %O", { identifier, locale, version });
|
|
1496
1890
|
const localeParam = locale || this.defaultLocale;
|
|
1497
1891
|
const params = { locale: localeParam };
|
|
1498
1892
|
if (version) {
|
|
@@ -1503,7 +1897,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1503
1897
|
`/v1/plugins/${identifier}/manifest${queryString}`,
|
|
1504
1898
|
options
|
|
1505
1899
|
);
|
|
1506
|
-
|
|
1900
|
+
log12("Plugin manifest successfully retrieved: %s", identifier);
|
|
1507
1901
|
return manifest;
|
|
1508
1902
|
}
|
|
1509
1903
|
/**
|
|
@@ -1520,7 +1914,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1520
1914
|
version,
|
|
1521
1915
|
identifier
|
|
1522
1916
|
}, options) {
|
|
1523
|
-
|
|
1917
|
+
log12("Getting plugin detail: %O", { identifier, locale, version });
|
|
1524
1918
|
const localeParam = locale || this.defaultLocale;
|
|
1525
1919
|
const params = { locale: localeParam };
|
|
1526
1920
|
if (version) {
|
|
@@ -1531,7 +1925,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1531
1925
|
`/v1/plugins/${identifier}${queryString}`,
|
|
1532
1926
|
options
|
|
1533
1927
|
);
|
|
1534
|
-
|
|
1928
|
+
log12("Plugin manifest successfully retrieved: %s", identifier);
|
|
1535
1929
|
return manifest;
|
|
1536
1930
|
}
|
|
1537
1931
|
/**
|
|
@@ -1546,7 +1940,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1546
1940
|
*
|
|
1547
1941
|
*/
|
|
1548
1942
|
async reportInstallation(reportData) {
|
|
1549
|
-
|
|
1943
|
+
log12("Reporting installation for %s@%s", reportData.identifier, reportData.version);
|
|
1550
1944
|
const result = await this.request("/v1/plugins/report/installation", {
|
|
1551
1945
|
body: JSON.stringify(reportData),
|
|
1552
1946
|
headers: {
|
|
@@ -1554,7 +1948,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1554
1948
|
},
|
|
1555
1949
|
method: "POST"
|
|
1556
1950
|
});
|
|
1557
|
-
|
|
1951
|
+
log12("Installation report submitted successfully: %O", result);
|
|
1558
1952
|
return result;
|
|
1559
1953
|
}
|
|
1560
1954
|
/**
|
|
@@ -1568,7 +1962,7 @@ var PluginsService = class extends BaseSDK {
|
|
|
1568
1962
|
* @returns Promise resolving to the report submission response
|
|
1569
1963
|
*/
|
|
1570
1964
|
async reportCall(reportData) {
|
|
1571
|
-
|
|
1965
|
+
log12(
|
|
1572
1966
|
"Reporting call for %s@%s - %s:%s",
|
|
1573
1967
|
reportData.identifier,
|
|
1574
1968
|
reportData.version,
|
|
@@ -1582,13 +1976,13 @@ var PluginsService = class extends BaseSDK {
|
|
|
1582
1976
|
},
|
|
1583
1977
|
method: "POST"
|
|
1584
1978
|
});
|
|
1585
|
-
|
|
1979
|
+
log12("Call report submitted successfully: %O", result);
|
|
1586
1980
|
return result;
|
|
1587
1981
|
}
|
|
1588
1982
|
};
|
|
1589
1983
|
|
|
1590
1984
|
// src/market/market-sdk.ts
|
|
1591
|
-
var
|
|
1985
|
+
var log13 = debug13("lobe-market-sdk");
|
|
1592
1986
|
var MarketSDK = class extends BaseSDK {
|
|
1593
1987
|
/**
|
|
1594
1988
|
* Creates a new MarketSDK instance
|
|
@@ -1601,7 +1995,9 @@ var MarketSDK = class extends BaseSDK {
|
|
|
1601
1995
|
tokenExpiry: void 0
|
|
1602
1996
|
};
|
|
1603
1997
|
super(options, void 0, sharedTokenState);
|
|
1604
|
-
|
|
1998
|
+
log13("MarketSDK instance created");
|
|
1999
|
+
this.agents = new AgentService(options, this.headers, sharedTokenState);
|
|
2000
|
+
this.auth = new AuthService(options, this.headers, sharedTokenState);
|
|
1605
2001
|
this.plugins = new PluginsService(options, this.headers, sharedTokenState);
|
|
1606
2002
|
this.discovery = new DiscoveryService(options, this.headers, sharedTokenState);
|
|
1607
2003
|
}
|
|
@@ -1626,20 +2022,11 @@ var MarketSDK = class extends BaseSDK {
|
|
|
1626
2022
|
* @param request - Client registration request data
|
|
1627
2023
|
* @returns Promise resolving to the client registration response with credentials
|
|
1628
2024
|
* @throws Error if registration fails
|
|
2025
|
+
* @deprecated Use auth.registerClient() instead
|
|
1629
2026
|
*/
|
|
1630
2027
|
async registerClient(request) {
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
const response = await this.request("v1/clients/register", {
|
|
1634
|
-
body: JSON.stringify(request),
|
|
1635
|
-
method: "POST"
|
|
1636
|
-
});
|
|
1637
|
-
log11("Client registered successfully: %s", response.client_id);
|
|
1638
|
-
return response;
|
|
1639
|
-
} catch (error) {
|
|
1640
|
-
console.error("Client registration failed: %o", error);
|
|
1641
|
-
throw error;
|
|
1642
|
-
}
|
|
2028
|
+
log13("Registering client (deprecated method, use auth.registerClient): %s", request.clientName);
|
|
2029
|
+
return this.auth.registerClient(request);
|
|
1643
2030
|
}
|
|
1644
2031
|
};
|
|
1645
2032
|
|