@mixrpay/agent-sdk 0.8.5 → 0.8.6
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.cjs +152 -7
- package/dist/index.d.cts +151 -5
- package/dist/index.d.ts +151 -5
- package/dist/index.js +152 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -100,7 +100,7 @@ var InsufficientBalanceError = class extends MixrPayError {
|
|
|
100
100
|
this.name = "InsufficientBalanceError";
|
|
101
101
|
this.required = required;
|
|
102
102
|
this.available = available;
|
|
103
|
-
this.topUpUrl = "/wallet";
|
|
103
|
+
this.topUpUrl = "https://mixrpay.com/manage/wallet";
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
106
|
var SessionKeyExpiredError = class extends MixrPayError {
|
|
@@ -108,7 +108,7 @@ var SessionKeyExpiredError = class extends MixrPayError {
|
|
|
108
108
|
expiredAt;
|
|
109
109
|
constructor(expiredAt) {
|
|
110
110
|
super(
|
|
111
|
-
`Session key expired at ${expiredAt}. Request a new session key from the wallet owner
|
|
111
|
+
`Session key expired at ${expiredAt}. Request a new session key from the wallet owner at https://mixrpay.com/manage/invites`,
|
|
112
112
|
"SESSION_KEY_EXPIRED"
|
|
113
113
|
);
|
|
114
114
|
this.name = "SessionKeyExpiredError";
|
|
@@ -177,7 +177,7 @@ var InvalidSessionKeyError = class extends MixrPayError {
|
|
|
177
177
|
reason;
|
|
178
178
|
constructor(reason = "Invalid session key format") {
|
|
179
179
|
super(
|
|
180
|
-
`${reason}. Session keys should be in format: sk_live_<64 hex chars> or sk_test_<64 hex chars>. Get one from
|
|
180
|
+
`${reason}. Session keys should be in format: sk_live_<64 hex chars> or sk_test_<64 hex chars>. Get one from https://mixrpay.com/manage/invites`,
|
|
181
181
|
"INVALID_SESSION_KEY"
|
|
182
182
|
);
|
|
183
183
|
this.name = "InvalidSessionKeyError";
|
|
@@ -648,7 +648,7 @@ var AgentWallet = class {
|
|
|
648
648
|
validateConfig(config) {
|
|
649
649
|
if (!config.sessionKey) {
|
|
650
650
|
throw new InvalidSessionKeyError(
|
|
651
|
-
"Session key is required. Get one from the wallet owner
|
|
651
|
+
"Session key is required. Get one from the wallet owner at https://mixrpay.com/manage/invites"
|
|
652
652
|
);
|
|
653
653
|
}
|
|
654
654
|
const key = config.sessionKey.trim();
|
|
@@ -1161,7 +1161,7 @@ var AgentWallet = class {
|
|
|
1161
1161
|
*
|
|
1162
1162
|
* @example
|
|
1163
1163
|
* ```typescript
|
|
1164
|
-
* // Human creates invite at
|
|
1164
|
+
* // Human creates invite at https://mixrpay.com/manage/invites, shares code "mixr-abc123"
|
|
1165
1165
|
*
|
|
1166
1166
|
* const result = await AgentWallet.claimInvite({
|
|
1167
1167
|
* inviteCode: 'mixr-abc123',
|
|
@@ -1387,6 +1387,16 @@ var AgentWallet = class {
|
|
|
1387
1387
|
const data = await response.json();
|
|
1388
1388
|
return data.children || [];
|
|
1389
1389
|
}
|
|
1390
|
+
/**
|
|
1391
|
+
* List child sessions spawned by this agent.
|
|
1392
|
+
*
|
|
1393
|
+
* Alias for `getChildSessions()` for naming consistency.
|
|
1394
|
+
*
|
|
1395
|
+
* @returns Array of child session info
|
|
1396
|
+
*/
|
|
1397
|
+
async listChildSessions() {
|
|
1398
|
+
return this.getChildSessions();
|
|
1399
|
+
}
|
|
1390
1400
|
// ===========================================================================
|
|
1391
1401
|
// Core Methods
|
|
1392
1402
|
// ===========================================================================
|
|
@@ -1840,7 +1850,7 @@ var AgentWallet = class {
|
|
|
1840
1850
|
checks.sessionKeyValid = info.isValid;
|
|
1841
1851
|
if (!info.isValid) {
|
|
1842
1852
|
issues.push("Session key is invalid or has been revoked.");
|
|
1843
|
-
recommendations.push("Request a new session key from the wallet owner
|
|
1853
|
+
recommendations.push("Request a new session key from the wallet owner at https://mixrpay.com/manage/invites");
|
|
1844
1854
|
}
|
|
1845
1855
|
const now = /* @__PURE__ */ new Date();
|
|
1846
1856
|
let expiresInHours = null;
|
|
@@ -1880,7 +1890,7 @@ var AgentWallet = class {
|
|
|
1880
1890
|
balance = await this.getBalance();
|
|
1881
1891
|
checks.hasBalance = balance > 0;
|
|
1882
1892
|
if (balance <= 0) {
|
|
1883
|
-
issues.push("Wallet has no USDC balance. Top up at
|
|
1893
|
+
issues.push("Wallet has no USDC balance. Top up at https://mixrpay.com/manage/wallet");
|
|
1884
1894
|
recommendations.push("Deposit USDC to your wallet address to enable payments.");
|
|
1885
1895
|
} else if (balance < 1) {
|
|
1886
1896
|
issues.push(`Low balance: $${balance.toFixed(2)}. Consider topping up.`);
|
|
@@ -2683,6 +2693,141 @@ Timestamp: ${timestamp}`;
|
|
|
2683
2693
|
createdAt: new Date(data.created_at)
|
|
2684
2694
|
};
|
|
2685
2695
|
}
|
|
2696
|
+
/**
|
|
2697
|
+
* Get details of a specific JIT MCP server instance.
|
|
2698
|
+
*
|
|
2699
|
+
* @param instanceId - The instance ID to retrieve
|
|
2700
|
+
* @returns Full instance details including endpoint URL
|
|
2701
|
+
*
|
|
2702
|
+
* @example
|
|
2703
|
+
* ```typescript
|
|
2704
|
+
* const instance = await wallet.getJitInstance('inst_abc123');
|
|
2705
|
+
* console.log('Endpoint:', instance.endpointUrl);
|
|
2706
|
+
* console.log('Expires:', instance.expiresAt);
|
|
2707
|
+
* ```
|
|
2708
|
+
*/
|
|
2709
|
+
async getJitInstance(instanceId) {
|
|
2710
|
+
this.logger.debug("getJitInstance", { instanceId });
|
|
2711
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2712
|
+
const response = await fetch(
|
|
2713
|
+
`${this.baseUrl}/api/v2/jit/instances/${instanceId}`,
|
|
2714
|
+
{ headers: authHeaders }
|
|
2715
|
+
);
|
|
2716
|
+
if (!response.ok) {
|
|
2717
|
+
const error = await response.json().catch(() => ({}));
|
|
2718
|
+
throw new MixrPayError(error.error || `Failed to get JIT instance: ${response.status}`);
|
|
2719
|
+
}
|
|
2720
|
+
const data = await response.json();
|
|
2721
|
+
return this.parseJitInstance(data.instance);
|
|
2722
|
+
}
|
|
2723
|
+
// ===========================================================================
|
|
2724
|
+
// Glama MCP Directory Methods
|
|
2725
|
+
// ===========================================================================
|
|
2726
|
+
/**
|
|
2727
|
+
* Search the Glama MCP server directory.
|
|
2728
|
+
*
|
|
2729
|
+
* Glama indexes 15,000+ MCP servers. Use this to discover tools
|
|
2730
|
+
* that can be deployed as JIT servers.
|
|
2731
|
+
*
|
|
2732
|
+
* Note: This is a public API and does not require authentication.
|
|
2733
|
+
*
|
|
2734
|
+
* @param query - Search query (e.g., "notion", "github", "database")
|
|
2735
|
+
* @returns Array of matching servers with hosting info
|
|
2736
|
+
*
|
|
2737
|
+
* @example
|
|
2738
|
+
* ```typescript
|
|
2739
|
+
* const results = await wallet.searchGlamaDirectory('notion');
|
|
2740
|
+
*
|
|
2741
|
+
* // Filter to only hostable servers
|
|
2742
|
+
* const hostable = results.servers.filter(s => s.canHost);
|
|
2743
|
+
* console.log(`Found ${hostable.length} deployable servers`);
|
|
2744
|
+
*
|
|
2745
|
+
* // Deploy one
|
|
2746
|
+
* if (hostable.length > 0) {
|
|
2747
|
+
* const server = hostable[0];
|
|
2748
|
+
* await wallet.deployJitMcp({
|
|
2749
|
+
* glamaId: server.id,
|
|
2750
|
+
* glamaNamespace: server.namespace,
|
|
2751
|
+
* glamaSlug: server.slug,
|
|
2752
|
+
* toolName: server.name,
|
|
2753
|
+
* envVars: { API_KEY: '...' },
|
|
2754
|
+
* });
|
|
2755
|
+
* }
|
|
2756
|
+
* ```
|
|
2757
|
+
*/
|
|
2758
|
+
async searchGlamaDirectory(query) {
|
|
2759
|
+
this.logger.debug("searchGlamaDirectory", { query });
|
|
2760
|
+
const params = new URLSearchParams({ q: query });
|
|
2761
|
+
const response = await fetch(`${this.baseUrl}/api/mcp/glama?${params}`);
|
|
2762
|
+
if (!response.ok) {
|
|
2763
|
+
const error = await response.json().catch(() => ({}));
|
|
2764
|
+
throw new MixrPayError(error.error || `Glama search failed: ${response.status}`);
|
|
2765
|
+
}
|
|
2766
|
+
const data = await response.json();
|
|
2767
|
+
return {
|
|
2768
|
+
servers: (data.servers || []).map((s) => this.parseGlamaServer(s)),
|
|
2769
|
+
pageInfo: data.pageInfo,
|
|
2770
|
+
query: data.query
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
/**
|
|
2774
|
+
* Get featured/popular MCP servers from the Glama directory.
|
|
2775
|
+
*
|
|
2776
|
+
* Returns curated list of popular servers when you don't have
|
|
2777
|
+
* a specific search query.
|
|
2778
|
+
*
|
|
2779
|
+
* Note: This is a public API and does not require authentication.
|
|
2780
|
+
*
|
|
2781
|
+
* @returns Array of featured servers with hosting info
|
|
2782
|
+
*
|
|
2783
|
+
* @example
|
|
2784
|
+
* ```typescript
|
|
2785
|
+
* const { servers } = await wallet.getFeaturedGlamaServers();
|
|
2786
|
+
* console.log('Featured servers:', servers.map(s => s.name));
|
|
2787
|
+
* ```
|
|
2788
|
+
*/
|
|
2789
|
+
async getFeaturedGlamaServers() {
|
|
2790
|
+
this.logger.debug("getFeaturedGlamaServers");
|
|
2791
|
+
const response = await fetch(`${this.baseUrl}/api/mcp/glama`);
|
|
2792
|
+
if (!response.ok) {
|
|
2793
|
+
const error = await response.json().catch(() => ({}));
|
|
2794
|
+
throw new MixrPayError(error.error || `Failed to get featured servers: ${response.status}`);
|
|
2795
|
+
}
|
|
2796
|
+
const data = await response.json();
|
|
2797
|
+
return {
|
|
2798
|
+
servers: (data.servers || []).map((s) => this.parseGlamaServer(s)),
|
|
2799
|
+
featured: data.featured
|
|
2800
|
+
};
|
|
2801
|
+
}
|
|
2802
|
+
/**
|
|
2803
|
+
* Parse Glama server response data.
|
|
2804
|
+
*/
|
|
2805
|
+
parseGlamaServer(data) {
|
|
2806
|
+
const importData = data.importData;
|
|
2807
|
+
return {
|
|
2808
|
+
id: data.id,
|
|
2809
|
+
name: data.name,
|
|
2810
|
+
namespace: data.namespace,
|
|
2811
|
+
slug: data.slug,
|
|
2812
|
+
description: data.description,
|
|
2813
|
+
url: data.url,
|
|
2814
|
+
attributes: data.attributes,
|
|
2815
|
+
canHost: data.canHost,
|
|
2816
|
+
tools: data.tools || [],
|
|
2817
|
+
repository: data.repository,
|
|
2818
|
+
license: data.spdxLicense?.name,
|
|
2819
|
+
importData: importData ? {
|
|
2820
|
+
glamaId: importData.glamaId,
|
|
2821
|
+
glamaNamespace: importData.glamaNamespace,
|
|
2822
|
+
glamaSlug: importData.glamaSlug,
|
|
2823
|
+
suggestedName: importData.suggestedName,
|
|
2824
|
+
suggestedDescription: importData.suggestedDescription,
|
|
2825
|
+
hostingType: importData.hostingType,
|
|
2826
|
+
requiredEnvVars: importData.requiredEnvVars,
|
|
2827
|
+
optionalEnvVars: importData.optionalEnvVars
|
|
2828
|
+
} : void 0
|
|
2829
|
+
};
|
|
2830
|
+
}
|
|
2686
2831
|
// ===========================================================================
|
|
2687
2832
|
// LLM Completion Methods
|
|
2688
2833
|
// ===========================================================================
|
package/dist/index.d.cts
CHANGED
|
@@ -31,9 +31,8 @@ interface AgentWalletConfig {
|
|
|
31
31
|
* Format: `sk_live_` (mainnet) or `sk_test_` (testnet) followed by 64 hex characters.
|
|
32
32
|
*
|
|
33
33
|
* Get session keys from:
|
|
34
|
-
* - The wallet owner
|
|
34
|
+
* - The wallet owner at https://mixrpay.com/manage/invites
|
|
35
35
|
* - Programmatically via the MixrPay API
|
|
36
|
-
* - The MixrPay widget session key management
|
|
37
36
|
*
|
|
38
37
|
* @example 'sk_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
|
|
39
38
|
*/
|
|
@@ -890,7 +889,7 @@ declare class AgentWallet {
|
|
|
890
889
|
*
|
|
891
890
|
* @example
|
|
892
891
|
* ```typescript
|
|
893
|
-
* // Human creates invite at
|
|
892
|
+
* // Human creates invite at https://mixrpay.com/manage/invites, shares code "mixr-abc123"
|
|
894
893
|
*
|
|
895
894
|
* const result = await AgentWallet.claimInvite({
|
|
896
895
|
* inviteCode: 'mixr-abc123',
|
|
@@ -983,6 +982,14 @@ declare class AgentWallet {
|
|
|
983
982
|
* ```
|
|
984
983
|
*/
|
|
985
984
|
getChildSessions(): Promise<ChildSession[]>;
|
|
985
|
+
/**
|
|
986
|
+
* List child sessions spawned by this agent.
|
|
987
|
+
*
|
|
988
|
+
* Alias for `getChildSessions()` for naming consistency.
|
|
989
|
+
*
|
|
990
|
+
* @returns Array of child session info
|
|
991
|
+
*/
|
|
992
|
+
listChildSessions(): Promise<ChildSession[]>;
|
|
986
993
|
/**
|
|
987
994
|
* Make an HTTP request, automatically handling x402 payment if required.
|
|
988
995
|
*
|
|
@@ -1432,6 +1439,74 @@ declare class AgentWallet {
|
|
|
1432
1439
|
* Parse JIT instance response data.
|
|
1433
1440
|
*/
|
|
1434
1441
|
private parseJitInstance;
|
|
1442
|
+
/**
|
|
1443
|
+
* Get details of a specific JIT MCP server instance.
|
|
1444
|
+
*
|
|
1445
|
+
* @param instanceId - The instance ID to retrieve
|
|
1446
|
+
* @returns Full instance details including endpoint URL
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```typescript
|
|
1450
|
+
* const instance = await wallet.getJitInstance('inst_abc123');
|
|
1451
|
+
* console.log('Endpoint:', instance.endpointUrl);
|
|
1452
|
+
* console.log('Expires:', instance.expiresAt);
|
|
1453
|
+
* ```
|
|
1454
|
+
*/
|
|
1455
|
+
getJitInstance(instanceId: string): Promise<JitInstance>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Search the Glama MCP server directory.
|
|
1458
|
+
*
|
|
1459
|
+
* Glama indexes 15,000+ MCP servers. Use this to discover tools
|
|
1460
|
+
* that can be deployed as JIT servers.
|
|
1461
|
+
*
|
|
1462
|
+
* Note: This is a public API and does not require authentication.
|
|
1463
|
+
*
|
|
1464
|
+
* @param query - Search query (e.g., "notion", "github", "database")
|
|
1465
|
+
* @returns Array of matching servers with hosting info
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```typescript
|
|
1469
|
+
* const results = await wallet.searchGlamaDirectory('notion');
|
|
1470
|
+
*
|
|
1471
|
+
* // Filter to only hostable servers
|
|
1472
|
+
* const hostable = results.servers.filter(s => s.canHost);
|
|
1473
|
+
* console.log(`Found ${hostable.length} deployable servers`);
|
|
1474
|
+
*
|
|
1475
|
+
* // Deploy one
|
|
1476
|
+
* if (hostable.length > 0) {
|
|
1477
|
+
* const server = hostable[0];
|
|
1478
|
+
* await wallet.deployJitMcp({
|
|
1479
|
+
* glamaId: server.id,
|
|
1480
|
+
* glamaNamespace: server.namespace,
|
|
1481
|
+
* glamaSlug: server.slug,
|
|
1482
|
+
* toolName: server.name,
|
|
1483
|
+
* envVars: { API_KEY: '...' },
|
|
1484
|
+
* });
|
|
1485
|
+
* }
|
|
1486
|
+
* ```
|
|
1487
|
+
*/
|
|
1488
|
+
searchGlamaDirectory(query: string): Promise<GlamaSearchResult>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Get featured/popular MCP servers from the Glama directory.
|
|
1491
|
+
*
|
|
1492
|
+
* Returns curated list of popular servers when you don't have
|
|
1493
|
+
* a specific search query.
|
|
1494
|
+
*
|
|
1495
|
+
* Note: This is a public API and does not require authentication.
|
|
1496
|
+
*
|
|
1497
|
+
* @returns Array of featured servers with hosting info
|
|
1498
|
+
*
|
|
1499
|
+
* @example
|
|
1500
|
+
* ```typescript
|
|
1501
|
+
* const { servers } = await wallet.getFeaturedGlamaServers();
|
|
1502
|
+
* console.log('Featured servers:', servers.map(s => s.name));
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
getFeaturedGlamaServers(): Promise<GlamaSearchResult>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Parse Glama server response data.
|
|
1508
|
+
*/
|
|
1509
|
+
private parseGlamaServer;
|
|
1435
1510
|
/**
|
|
1436
1511
|
* Simple LLM completion - single-turn, no tools.
|
|
1437
1512
|
*
|
|
@@ -2228,6 +2303,77 @@ interface JitInstance {
|
|
|
2228
2303
|
/** Creation time */
|
|
2229
2304
|
createdAt: Date;
|
|
2230
2305
|
}
|
|
2306
|
+
/**
|
|
2307
|
+
* MCP server from the Glama directory
|
|
2308
|
+
*/
|
|
2309
|
+
interface GlamaServer {
|
|
2310
|
+
/** Glama server ID */
|
|
2311
|
+
id: string;
|
|
2312
|
+
/** Server name */
|
|
2313
|
+
name: string;
|
|
2314
|
+
/** Namespace (e.g., "anthropics", "notion") */
|
|
2315
|
+
namespace: string;
|
|
2316
|
+
/** URL slug */
|
|
2317
|
+
slug: string;
|
|
2318
|
+
/** Server description */
|
|
2319
|
+
description: string;
|
|
2320
|
+
/** Glama URL */
|
|
2321
|
+
url: string;
|
|
2322
|
+
/** Server attributes (e.g., ["hosting:remote-capable", "author:official"]) */
|
|
2323
|
+
attributes: string[];
|
|
2324
|
+
/** Whether this server can be hosted as a JIT instance */
|
|
2325
|
+
canHost: boolean;
|
|
2326
|
+
/** Available tools */
|
|
2327
|
+
tools: Array<{
|
|
2328
|
+
name: string;
|
|
2329
|
+
description?: string;
|
|
2330
|
+
}>;
|
|
2331
|
+
/** Repository info */
|
|
2332
|
+
repository?: {
|
|
2333
|
+
url: string;
|
|
2334
|
+
};
|
|
2335
|
+
/** License name */
|
|
2336
|
+
license?: string;
|
|
2337
|
+
/** Import data for deploying as JIT server */
|
|
2338
|
+
importData?: GlamaImportData;
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Import data for deploying a Glama server as JIT
|
|
2342
|
+
*/
|
|
2343
|
+
interface GlamaImportData {
|
|
2344
|
+
/** Glama server ID */
|
|
2345
|
+
glamaId: string;
|
|
2346
|
+
/** Namespace */
|
|
2347
|
+
glamaNamespace: string;
|
|
2348
|
+
/** Slug */
|
|
2349
|
+
glamaSlug: string;
|
|
2350
|
+
/** Suggested display name */
|
|
2351
|
+
suggestedName: string;
|
|
2352
|
+
/** Suggested description */
|
|
2353
|
+
suggestedDescription: string;
|
|
2354
|
+
/** Hosting type */
|
|
2355
|
+
hostingType: 'local' | 'remote' | 'hybrid';
|
|
2356
|
+
/** Required environment variables (API keys) */
|
|
2357
|
+
requiredEnvVars: string[];
|
|
2358
|
+
/** Optional environment variables */
|
|
2359
|
+
optionalEnvVars: string[];
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Result from searching the Glama directory
|
|
2363
|
+
*/
|
|
2364
|
+
interface GlamaSearchResult {
|
|
2365
|
+
/** Matching servers */
|
|
2366
|
+
servers: GlamaServer[];
|
|
2367
|
+
/** Pagination info */
|
|
2368
|
+
pageInfo?: {
|
|
2369
|
+
hasNextPage: boolean;
|
|
2370
|
+
endCursor?: string;
|
|
2371
|
+
};
|
|
2372
|
+
/** Original query (for search results) */
|
|
2373
|
+
query?: string;
|
|
2374
|
+
/** Whether these are featured servers */
|
|
2375
|
+
featured?: boolean;
|
|
2376
|
+
}
|
|
2231
2377
|
/**
|
|
2232
2378
|
* Options for simple LLM completion
|
|
2233
2379
|
*/
|
|
@@ -2618,7 +2764,7 @@ declare class PaymentFailedError extends MixrPayError {
|
|
|
2618
2764
|
* catch (error) {
|
|
2619
2765
|
* if (error instanceof InvalidSessionKeyError) {
|
|
2620
2766
|
* console.log(`Invalid key: ${error.reason}`);
|
|
2621
|
-
* console.log('Get a valid session key from
|
|
2767
|
+
* console.log('Get a valid session key from https://mixrpay.com/manage/invites');
|
|
2622
2768
|
* }
|
|
2623
2769
|
* }
|
|
2624
2770
|
* ```
|
|
@@ -2836,4 +2982,4 @@ declare function isMixrPayError(error: unknown): error is MixrPayError;
|
|
|
2836
2982
|
*/
|
|
2837
2983
|
declare function getErrorMessage(error: unknown): string;
|
|
2838
2984
|
|
|
2839
|
-
export { type AgentClaimInviteOptions, type AgentClaimInviteResult, type AgentMessage, type AgentRunConfig, type AgentRunEvent, type AgentRunOptions, type AgentRunResult, type AgentRunStatusResult, AgentWallet, type AgentWalletConfig, type AvailableBudget, type CallMerchantApiOptions, type ChargeResult, type ChildSession, type CompleteOptions, type CompleteResult, type DeployJitMcpOptions, type DeployJitMcpResult, type DiagnosticsResult, InsufficientBalanceError, InvalidSessionKeyError, type JitInstance, MerchantNotAllowedError, MixrPayError, type PaymentEvent, PaymentFailedError, SDK_VERSION, type SessionAuthorization, SessionExpiredError, SessionKeyExpiredError, type SessionKeyInfo, SessionLimitExceededError, SessionNotFoundError, SessionRevokedError, type SessionStats, type SpawnChildOptions, type SpawnChildResult, SpendingLimitExceededError, type SpendingStats, X402ProtocolError, getErrorMessage, isMixrPayError };
|
|
2985
|
+
export { type AgentClaimInviteOptions, type AgentClaimInviteResult, type AgentMessage, type AgentRunConfig, type AgentRunEvent, type AgentRunOptions, type AgentRunResult, type AgentRunStatusResult, AgentWallet, type AgentWalletConfig, type AvailableBudget, type CallMerchantApiOptions, type ChargeResult, type ChildSession, type CompleteOptions, type CompleteResult, type DeployJitMcpOptions, type DeployJitMcpResult, type DiagnosticsResult, type GlamaImportData, type GlamaSearchResult, type GlamaServer, InsufficientBalanceError, InvalidSessionKeyError, type JitInstance, MerchantNotAllowedError, MixrPayError, type PaymentEvent, PaymentFailedError, SDK_VERSION, type SessionAuthorization, SessionExpiredError, SessionKeyExpiredError, type SessionKeyInfo, SessionLimitExceededError, SessionNotFoundError, SessionRevokedError, type SessionStats, type SpawnChildOptions, type SpawnChildResult, SpendingLimitExceededError, type SpendingStats, X402ProtocolError, getErrorMessage, isMixrPayError };
|
package/dist/index.d.ts
CHANGED
|
@@ -31,9 +31,8 @@ interface AgentWalletConfig {
|
|
|
31
31
|
* Format: `sk_live_` (mainnet) or `sk_test_` (testnet) followed by 64 hex characters.
|
|
32
32
|
*
|
|
33
33
|
* Get session keys from:
|
|
34
|
-
* - The wallet owner
|
|
34
|
+
* - The wallet owner at https://mixrpay.com/manage/invites
|
|
35
35
|
* - Programmatically via the MixrPay API
|
|
36
|
-
* - The MixrPay widget session key management
|
|
37
36
|
*
|
|
38
37
|
* @example 'sk_live_0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef'
|
|
39
38
|
*/
|
|
@@ -890,7 +889,7 @@ declare class AgentWallet {
|
|
|
890
889
|
*
|
|
891
890
|
* @example
|
|
892
891
|
* ```typescript
|
|
893
|
-
* // Human creates invite at
|
|
892
|
+
* // Human creates invite at https://mixrpay.com/manage/invites, shares code "mixr-abc123"
|
|
894
893
|
*
|
|
895
894
|
* const result = await AgentWallet.claimInvite({
|
|
896
895
|
* inviteCode: 'mixr-abc123',
|
|
@@ -983,6 +982,14 @@ declare class AgentWallet {
|
|
|
983
982
|
* ```
|
|
984
983
|
*/
|
|
985
984
|
getChildSessions(): Promise<ChildSession[]>;
|
|
985
|
+
/**
|
|
986
|
+
* List child sessions spawned by this agent.
|
|
987
|
+
*
|
|
988
|
+
* Alias for `getChildSessions()` for naming consistency.
|
|
989
|
+
*
|
|
990
|
+
* @returns Array of child session info
|
|
991
|
+
*/
|
|
992
|
+
listChildSessions(): Promise<ChildSession[]>;
|
|
986
993
|
/**
|
|
987
994
|
* Make an HTTP request, automatically handling x402 payment if required.
|
|
988
995
|
*
|
|
@@ -1432,6 +1439,74 @@ declare class AgentWallet {
|
|
|
1432
1439
|
* Parse JIT instance response data.
|
|
1433
1440
|
*/
|
|
1434
1441
|
private parseJitInstance;
|
|
1442
|
+
/**
|
|
1443
|
+
* Get details of a specific JIT MCP server instance.
|
|
1444
|
+
*
|
|
1445
|
+
* @param instanceId - The instance ID to retrieve
|
|
1446
|
+
* @returns Full instance details including endpoint URL
|
|
1447
|
+
*
|
|
1448
|
+
* @example
|
|
1449
|
+
* ```typescript
|
|
1450
|
+
* const instance = await wallet.getJitInstance('inst_abc123');
|
|
1451
|
+
* console.log('Endpoint:', instance.endpointUrl);
|
|
1452
|
+
* console.log('Expires:', instance.expiresAt);
|
|
1453
|
+
* ```
|
|
1454
|
+
*/
|
|
1455
|
+
getJitInstance(instanceId: string): Promise<JitInstance>;
|
|
1456
|
+
/**
|
|
1457
|
+
* Search the Glama MCP server directory.
|
|
1458
|
+
*
|
|
1459
|
+
* Glama indexes 15,000+ MCP servers. Use this to discover tools
|
|
1460
|
+
* that can be deployed as JIT servers.
|
|
1461
|
+
*
|
|
1462
|
+
* Note: This is a public API and does not require authentication.
|
|
1463
|
+
*
|
|
1464
|
+
* @param query - Search query (e.g., "notion", "github", "database")
|
|
1465
|
+
* @returns Array of matching servers with hosting info
|
|
1466
|
+
*
|
|
1467
|
+
* @example
|
|
1468
|
+
* ```typescript
|
|
1469
|
+
* const results = await wallet.searchGlamaDirectory('notion');
|
|
1470
|
+
*
|
|
1471
|
+
* // Filter to only hostable servers
|
|
1472
|
+
* const hostable = results.servers.filter(s => s.canHost);
|
|
1473
|
+
* console.log(`Found ${hostable.length} deployable servers`);
|
|
1474
|
+
*
|
|
1475
|
+
* // Deploy one
|
|
1476
|
+
* if (hostable.length > 0) {
|
|
1477
|
+
* const server = hostable[0];
|
|
1478
|
+
* await wallet.deployJitMcp({
|
|
1479
|
+
* glamaId: server.id,
|
|
1480
|
+
* glamaNamespace: server.namespace,
|
|
1481
|
+
* glamaSlug: server.slug,
|
|
1482
|
+
* toolName: server.name,
|
|
1483
|
+
* envVars: { API_KEY: '...' },
|
|
1484
|
+
* });
|
|
1485
|
+
* }
|
|
1486
|
+
* ```
|
|
1487
|
+
*/
|
|
1488
|
+
searchGlamaDirectory(query: string): Promise<GlamaSearchResult>;
|
|
1489
|
+
/**
|
|
1490
|
+
* Get featured/popular MCP servers from the Glama directory.
|
|
1491
|
+
*
|
|
1492
|
+
* Returns curated list of popular servers when you don't have
|
|
1493
|
+
* a specific search query.
|
|
1494
|
+
*
|
|
1495
|
+
* Note: This is a public API and does not require authentication.
|
|
1496
|
+
*
|
|
1497
|
+
* @returns Array of featured servers with hosting info
|
|
1498
|
+
*
|
|
1499
|
+
* @example
|
|
1500
|
+
* ```typescript
|
|
1501
|
+
* const { servers } = await wallet.getFeaturedGlamaServers();
|
|
1502
|
+
* console.log('Featured servers:', servers.map(s => s.name));
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
getFeaturedGlamaServers(): Promise<GlamaSearchResult>;
|
|
1506
|
+
/**
|
|
1507
|
+
* Parse Glama server response data.
|
|
1508
|
+
*/
|
|
1509
|
+
private parseGlamaServer;
|
|
1435
1510
|
/**
|
|
1436
1511
|
* Simple LLM completion - single-turn, no tools.
|
|
1437
1512
|
*
|
|
@@ -2228,6 +2303,77 @@ interface JitInstance {
|
|
|
2228
2303
|
/** Creation time */
|
|
2229
2304
|
createdAt: Date;
|
|
2230
2305
|
}
|
|
2306
|
+
/**
|
|
2307
|
+
* MCP server from the Glama directory
|
|
2308
|
+
*/
|
|
2309
|
+
interface GlamaServer {
|
|
2310
|
+
/** Glama server ID */
|
|
2311
|
+
id: string;
|
|
2312
|
+
/** Server name */
|
|
2313
|
+
name: string;
|
|
2314
|
+
/** Namespace (e.g., "anthropics", "notion") */
|
|
2315
|
+
namespace: string;
|
|
2316
|
+
/** URL slug */
|
|
2317
|
+
slug: string;
|
|
2318
|
+
/** Server description */
|
|
2319
|
+
description: string;
|
|
2320
|
+
/** Glama URL */
|
|
2321
|
+
url: string;
|
|
2322
|
+
/** Server attributes (e.g., ["hosting:remote-capable", "author:official"]) */
|
|
2323
|
+
attributes: string[];
|
|
2324
|
+
/** Whether this server can be hosted as a JIT instance */
|
|
2325
|
+
canHost: boolean;
|
|
2326
|
+
/** Available tools */
|
|
2327
|
+
tools: Array<{
|
|
2328
|
+
name: string;
|
|
2329
|
+
description?: string;
|
|
2330
|
+
}>;
|
|
2331
|
+
/** Repository info */
|
|
2332
|
+
repository?: {
|
|
2333
|
+
url: string;
|
|
2334
|
+
};
|
|
2335
|
+
/** License name */
|
|
2336
|
+
license?: string;
|
|
2337
|
+
/** Import data for deploying as JIT server */
|
|
2338
|
+
importData?: GlamaImportData;
|
|
2339
|
+
}
|
|
2340
|
+
/**
|
|
2341
|
+
* Import data for deploying a Glama server as JIT
|
|
2342
|
+
*/
|
|
2343
|
+
interface GlamaImportData {
|
|
2344
|
+
/** Glama server ID */
|
|
2345
|
+
glamaId: string;
|
|
2346
|
+
/** Namespace */
|
|
2347
|
+
glamaNamespace: string;
|
|
2348
|
+
/** Slug */
|
|
2349
|
+
glamaSlug: string;
|
|
2350
|
+
/** Suggested display name */
|
|
2351
|
+
suggestedName: string;
|
|
2352
|
+
/** Suggested description */
|
|
2353
|
+
suggestedDescription: string;
|
|
2354
|
+
/** Hosting type */
|
|
2355
|
+
hostingType: 'local' | 'remote' | 'hybrid';
|
|
2356
|
+
/** Required environment variables (API keys) */
|
|
2357
|
+
requiredEnvVars: string[];
|
|
2358
|
+
/** Optional environment variables */
|
|
2359
|
+
optionalEnvVars: string[];
|
|
2360
|
+
}
|
|
2361
|
+
/**
|
|
2362
|
+
* Result from searching the Glama directory
|
|
2363
|
+
*/
|
|
2364
|
+
interface GlamaSearchResult {
|
|
2365
|
+
/** Matching servers */
|
|
2366
|
+
servers: GlamaServer[];
|
|
2367
|
+
/** Pagination info */
|
|
2368
|
+
pageInfo?: {
|
|
2369
|
+
hasNextPage: boolean;
|
|
2370
|
+
endCursor?: string;
|
|
2371
|
+
};
|
|
2372
|
+
/** Original query (for search results) */
|
|
2373
|
+
query?: string;
|
|
2374
|
+
/** Whether these are featured servers */
|
|
2375
|
+
featured?: boolean;
|
|
2376
|
+
}
|
|
2231
2377
|
/**
|
|
2232
2378
|
* Options for simple LLM completion
|
|
2233
2379
|
*/
|
|
@@ -2618,7 +2764,7 @@ declare class PaymentFailedError extends MixrPayError {
|
|
|
2618
2764
|
* catch (error) {
|
|
2619
2765
|
* if (error instanceof InvalidSessionKeyError) {
|
|
2620
2766
|
* console.log(`Invalid key: ${error.reason}`);
|
|
2621
|
-
* console.log('Get a valid session key from
|
|
2767
|
+
* console.log('Get a valid session key from https://mixrpay.com/manage/invites');
|
|
2622
2768
|
* }
|
|
2623
2769
|
* }
|
|
2624
2770
|
* ```
|
|
@@ -2836,4 +2982,4 @@ declare function isMixrPayError(error: unknown): error is MixrPayError;
|
|
|
2836
2982
|
*/
|
|
2837
2983
|
declare function getErrorMessage(error: unknown): string;
|
|
2838
2984
|
|
|
2839
|
-
export { type AgentClaimInviteOptions, type AgentClaimInviteResult, type AgentMessage, type AgentRunConfig, type AgentRunEvent, type AgentRunOptions, type AgentRunResult, type AgentRunStatusResult, AgentWallet, type AgentWalletConfig, type AvailableBudget, type CallMerchantApiOptions, type ChargeResult, type ChildSession, type CompleteOptions, type CompleteResult, type DeployJitMcpOptions, type DeployJitMcpResult, type DiagnosticsResult, InsufficientBalanceError, InvalidSessionKeyError, type JitInstance, MerchantNotAllowedError, MixrPayError, type PaymentEvent, PaymentFailedError, SDK_VERSION, type SessionAuthorization, SessionExpiredError, SessionKeyExpiredError, type SessionKeyInfo, SessionLimitExceededError, SessionNotFoundError, SessionRevokedError, type SessionStats, type SpawnChildOptions, type SpawnChildResult, SpendingLimitExceededError, type SpendingStats, X402ProtocolError, getErrorMessage, isMixrPayError };
|
|
2985
|
+
export { type AgentClaimInviteOptions, type AgentClaimInviteResult, type AgentMessage, type AgentRunConfig, type AgentRunEvent, type AgentRunOptions, type AgentRunResult, type AgentRunStatusResult, AgentWallet, type AgentWalletConfig, type AvailableBudget, type CallMerchantApiOptions, type ChargeResult, type ChildSession, type CompleteOptions, type CompleteResult, type DeployJitMcpOptions, type DeployJitMcpResult, type DiagnosticsResult, type GlamaImportData, type GlamaSearchResult, type GlamaServer, InsufficientBalanceError, InvalidSessionKeyError, type JitInstance, MerchantNotAllowedError, MixrPayError, type PaymentEvent, PaymentFailedError, SDK_VERSION, type SessionAuthorization, SessionExpiredError, SessionKeyExpiredError, type SessionKeyInfo, SessionLimitExceededError, SessionNotFoundError, SessionRevokedError, type SessionStats, type SpawnChildOptions, type SpawnChildResult, SpendingLimitExceededError, type SpendingStats, X402ProtocolError, getErrorMessage, isMixrPayError };
|
package/dist/index.js
CHANGED
|
@@ -63,7 +63,7 @@ var InsufficientBalanceError = class extends MixrPayError {
|
|
|
63
63
|
this.name = "InsufficientBalanceError";
|
|
64
64
|
this.required = required;
|
|
65
65
|
this.available = available;
|
|
66
|
-
this.topUpUrl = "/wallet";
|
|
66
|
+
this.topUpUrl = "https://mixrpay.com/manage/wallet";
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
var SessionKeyExpiredError = class extends MixrPayError {
|
|
@@ -71,7 +71,7 @@ var SessionKeyExpiredError = class extends MixrPayError {
|
|
|
71
71
|
expiredAt;
|
|
72
72
|
constructor(expiredAt) {
|
|
73
73
|
super(
|
|
74
|
-
`Session key expired at ${expiredAt}. Request a new session key from the wallet owner
|
|
74
|
+
`Session key expired at ${expiredAt}. Request a new session key from the wallet owner at https://mixrpay.com/manage/invites`,
|
|
75
75
|
"SESSION_KEY_EXPIRED"
|
|
76
76
|
);
|
|
77
77
|
this.name = "SessionKeyExpiredError";
|
|
@@ -140,7 +140,7 @@ var InvalidSessionKeyError = class extends MixrPayError {
|
|
|
140
140
|
reason;
|
|
141
141
|
constructor(reason = "Invalid session key format") {
|
|
142
142
|
super(
|
|
143
|
-
`${reason}. Session keys should be in format: sk_live_<64 hex chars> or sk_test_<64 hex chars>. Get one from
|
|
143
|
+
`${reason}. Session keys should be in format: sk_live_<64 hex chars> or sk_test_<64 hex chars>. Get one from https://mixrpay.com/manage/invites`,
|
|
144
144
|
"INVALID_SESSION_KEY"
|
|
145
145
|
);
|
|
146
146
|
this.name = "InvalidSessionKeyError";
|
|
@@ -611,7 +611,7 @@ var AgentWallet = class {
|
|
|
611
611
|
validateConfig(config) {
|
|
612
612
|
if (!config.sessionKey) {
|
|
613
613
|
throw new InvalidSessionKeyError(
|
|
614
|
-
"Session key is required. Get one from the wallet owner
|
|
614
|
+
"Session key is required. Get one from the wallet owner at https://mixrpay.com/manage/invites"
|
|
615
615
|
);
|
|
616
616
|
}
|
|
617
617
|
const key = config.sessionKey.trim();
|
|
@@ -1124,7 +1124,7 @@ var AgentWallet = class {
|
|
|
1124
1124
|
*
|
|
1125
1125
|
* @example
|
|
1126
1126
|
* ```typescript
|
|
1127
|
-
* // Human creates invite at
|
|
1127
|
+
* // Human creates invite at https://mixrpay.com/manage/invites, shares code "mixr-abc123"
|
|
1128
1128
|
*
|
|
1129
1129
|
* const result = await AgentWallet.claimInvite({
|
|
1130
1130
|
* inviteCode: 'mixr-abc123',
|
|
@@ -1350,6 +1350,16 @@ var AgentWallet = class {
|
|
|
1350
1350
|
const data = await response.json();
|
|
1351
1351
|
return data.children || [];
|
|
1352
1352
|
}
|
|
1353
|
+
/**
|
|
1354
|
+
* List child sessions spawned by this agent.
|
|
1355
|
+
*
|
|
1356
|
+
* Alias for `getChildSessions()` for naming consistency.
|
|
1357
|
+
*
|
|
1358
|
+
* @returns Array of child session info
|
|
1359
|
+
*/
|
|
1360
|
+
async listChildSessions() {
|
|
1361
|
+
return this.getChildSessions();
|
|
1362
|
+
}
|
|
1353
1363
|
// ===========================================================================
|
|
1354
1364
|
// Core Methods
|
|
1355
1365
|
// ===========================================================================
|
|
@@ -1803,7 +1813,7 @@ var AgentWallet = class {
|
|
|
1803
1813
|
checks.sessionKeyValid = info.isValid;
|
|
1804
1814
|
if (!info.isValid) {
|
|
1805
1815
|
issues.push("Session key is invalid or has been revoked.");
|
|
1806
|
-
recommendations.push("Request a new session key from the wallet owner
|
|
1816
|
+
recommendations.push("Request a new session key from the wallet owner at https://mixrpay.com/manage/invites");
|
|
1807
1817
|
}
|
|
1808
1818
|
const now = /* @__PURE__ */ new Date();
|
|
1809
1819
|
let expiresInHours = null;
|
|
@@ -1843,7 +1853,7 @@ var AgentWallet = class {
|
|
|
1843
1853
|
balance = await this.getBalance();
|
|
1844
1854
|
checks.hasBalance = balance > 0;
|
|
1845
1855
|
if (balance <= 0) {
|
|
1846
|
-
issues.push("Wallet has no USDC balance. Top up at
|
|
1856
|
+
issues.push("Wallet has no USDC balance. Top up at https://mixrpay.com/manage/wallet");
|
|
1847
1857
|
recommendations.push("Deposit USDC to your wallet address to enable payments.");
|
|
1848
1858
|
} else if (balance < 1) {
|
|
1849
1859
|
issues.push(`Low balance: $${balance.toFixed(2)}. Consider topping up.`);
|
|
@@ -2646,6 +2656,141 @@ Timestamp: ${timestamp}`;
|
|
|
2646
2656
|
createdAt: new Date(data.created_at)
|
|
2647
2657
|
};
|
|
2648
2658
|
}
|
|
2659
|
+
/**
|
|
2660
|
+
* Get details of a specific JIT MCP server instance.
|
|
2661
|
+
*
|
|
2662
|
+
* @param instanceId - The instance ID to retrieve
|
|
2663
|
+
* @returns Full instance details including endpoint URL
|
|
2664
|
+
*
|
|
2665
|
+
* @example
|
|
2666
|
+
* ```typescript
|
|
2667
|
+
* const instance = await wallet.getJitInstance('inst_abc123');
|
|
2668
|
+
* console.log('Endpoint:', instance.endpointUrl);
|
|
2669
|
+
* console.log('Expires:', instance.expiresAt);
|
|
2670
|
+
* ```
|
|
2671
|
+
*/
|
|
2672
|
+
async getJitInstance(instanceId) {
|
|
2673
|
+
this.logger.debug("getJitInstance", { instanceId });
|
|
2674
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2675
|
+
const response = await fetch(
|
|
2676
|
+
`${this.baseUrl}/api/v2/jit/instances/${instanceId}`,
|
|
2677
|
+
{ headers: authHeaders }
|
|
2678
|
+
);
|
|
2679
|
+
if (!response.ok) {
|
|
2680
|
+
const error = await response.json().catch(() => ({}));
|
|
2681
|
+
throw new MixrPayError(error.error || `Failed to get JIT instance: ${response.status}`);
|
|
2682
|
+
}
|
|
2683
|
+
const data = await response.json();
|
|
2684
|
+
return this.parseJitInstance(data.instance);
|
|
2685
|
+
}
|
|
2686
|
+
// ===========================================================================
|
|
2687
|
+
// Glama MCP Directory Methods
|
|
2688
|
+
// ===========================================================================
|
|
2689
|
+
/**
|
|
2690
|
+
* Search the Glama MCP server directory.
|
|
2691
|
+
*
|
|
2692
|
+
* Glama indexes 15,000+ MCP servers. Use this to discover tools
|
|
2693
|
+
* that can be deployed as JIT servers.
|
|
2694
|
+
*
|
|
2695
|
+
* Note: This is a public API and does not require authentication.
|
|
2696
|
+
*
|
|
2697
|
+
* @param query - Search query (e.g., "notion", "github", "database")
|
|
2698
|
+
* @returns Array of matching servers with hosting info
|
|
2699
|
+
*
|
|
2700
|
+
* @example
|
|
2701
|
+
* ```typescript
|
|
2702
|
+
* const results = await wallet.searchGlamaDirectory('notion');
|
|
2703
|
+
*
|
|
2704
|
+
* // Filter to only hostable servers
|
|
2705
|
+
* const hostable = results.servers.filter(s => s.canHost);
|
|
2706
|
+
* console.log(`Found ${hostable.length} deployable servers`);
|
|
2707
|
+
*
|
|
2708
|
+
* // Deploy one
|
|
2709
|
+
* if (hostable.length > 0) {
|
|
2710
|
+
* const server = hostable[0];
|
|
2711
|
+
* await wallet.deployJitMcp({
|
|
2712
|
+
* glamaId: server.id,
|
|
2713
|
+
* glamaNamespace: server.namespace,
|
|
2714
|
+
* glamaSlug: server.slug,
|
|
2715
|
+
* toolName: server.name,
|
|
2716
|
+
* envVars: { API_KEY: '...' },
|
|
2717
|
+
* });
|
|
2718
|
+
* }
|
|
2719
|
+
* ```
|
|
2720
|
+
*/
|
|
2721
|
+
async searchGlamaDirectory(query) {
|
|
2722
|
+
this.logger.debug("searchGlamaDirectory", { query });
|
|
2723
|
+
const params = new URLSearchParams({ q: query });
|
|
2724
|
+
const response = await fetch(`${this.baseUrl}/api/mcp/glama?${params}`);
|
|
2725
|
+
if (!response.ok) {
|
|
2726
|
+
const error = await response.json().catch(() => ({}));
|
|
2727
|
+
throw new MixrPayError(error.error || `Glama search failed: ${response.status}`);
|
|
2728
|
+
}
|
|
2729
|
+
const data = await response.json();
|
|
2730
|
+
return {
|
|
2731
|
+
servers: (data.servers || []).map((s) => this.parseGlamaServer(s)),
|
|
2732
|
+
pageInfo: data.pageInfo,
|
|
2733
|
+
query: data.query
|
|
2734
|
+
};
|
|
2735
|
+
}
|
|
2736
|
+
/**
|
|
2737
|
+
* Get featured/popular MCP servers from the Glama directory.
|
|
2738
|
+
*
|
|
2739
|
+
* Returns curated list of popular servers when you don't have
|
|
2740
|
+
* a specific search query.
|
|
2741
|
+
*
|
|
2742
|
+
* Note: This is a public API and does not require authentication.
|
|
2743
|
+
*
|
|
2744
|
+
* @returns Array of featured servers with hosting info
|
|
2745
|
+
*
|
|
2746
|
+
* @example
|
|
2747
|
+
* ```typescript
|
|
2748
|
+
* const { servers } = await wallet.getFeaturedGlamaServers();
|
|
2749
|
+
* console.log('Featured servers:', servers.map(s => s.name));
|
|
2750
|
+
* ```
|
|
2751
|
+
*/
|
|
2752
|
+
async getFeaturedGlamaServers() {
|
|
2753
|
+
this.logger.debug("getFeaturedGlamaServers");
|
|
2754
|
+
const response = await fetch(`${this.baseUrl}/api/mcp/glama`);
|
|
2755
|
+
if (!response.ok) {
|
|
2756
|
+
const error = await response.json().catch(() => ({}));
|
|
2757
|
+
throw new MixrPayError(error.error || `Failed to get featured servers: ${response.status}`);
|
|
2758
|
+
}
|
|
2759
|
+
const data = await response.json();
|
|
2760
|
+
return {
|
|
2761
|
+
servers: (data.servers || []).map((s) => this.parseGlamaServer(s)),
|
|
2762
|
+
featured: data.featured
|
|
2763
|
+
};
|
|
2764
|
+
}
|
|
2765
|
+
/**
|
|
2766
|
+
* Parse Glama server response data.
|
|
2767
|
+
*/
|
|
2768
|
+
parseGlamaServer(data) {
|
|
2769
|
+
const importData = data.importData;
|
|
2770
|
+
return {
|
|
2771
|
+
id: data.id,
|
|
2772
|
+
name: data.name,
|
|
2773
|
+
namespace: data.namespace,
|
|
2774
|
+
slug: data.slug,
|
|
2775
|
+
description: data.description,
|
|
2776
|
+
url: data.url,
|
|
2777
|
+
attributes: data.attributes,
|
|
2778
|
+
canHost: data.canHost,
|
|
2779
|
+
tools: data.tools || [],
|
|
2780
|
+
repository: data.repository,
|
|
2781
|
+
license: data.spdxLicense?.name,
|
|
2782
|
+
importData: importData ? {
|
|
2783
|
+
glamaId: importData.glamaId,
|
|
2784
|
+
glamaNamespace: importData.glamaNamespace,
|
|
2785
|
+
glamaSlug: importData.glamaSlug,
|
|
2786
|
+
suggestedName: importData.suggestedName,
|
|
2787
|
+
suggestedDescription: importData.suggestedDescription,
|
|
2788
|
+
hostingType: importData.hostingType,
|
|
2789
|
+
requiredEnvVars: importData.requiredEnvVars,
|
|
2790
|
+
optionalEnvVars: importData.optionalEnvVars
|
|
2791
|
+
} : void 0
|
|
2792
|
+
};
|
|
2793
|
+
}
|
|
2649
2794
|
// ===========================================================================
|
|
2650
2795
|
// LLM Completion Methods
|
|
2651
2796
|
// ===========================================================================
|