@mixrpay/agent-sdk 0.8.4 → 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.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's MixrPay dashboard
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
  */
@@ -380,7 +379,7 @@ interface SessionStats {
380
379
  */
381
380
 
382
381
  /** Current SDK version */
383
- declare const SDK_VERSION = "0.8.3";
382
+ declare const SDK_VERSION = "0.8.5";
384
383
  /** Supported networks */
385
384
  declare const NETWORKS: {
386
385
  readonly BASE_MAINNET: {
@@ -890,7 +889,7 @@ declare class AgentWallet {
890
889
  *
891
890
  * @example
892
891
  * ```typescript
893
- * // Human creates invite at their dashboard, shares code "mixr-abc123"
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
  *
@@ -1371,6 +1378,162 @@ declare class AgentWallet {
1371
1378
  * ```
1372
1379
  */
1373
1380
  callMCPTool(toolName: string, args?: Record<string, unknown>): Promise<MCPToolResult>;
1381
+ /**
1382
+ * Deploy a JIT MCP server from the Glama directory.
1383
+ *
1384
+ * Deploys any remote-capable MCP server to Cloudflare Workers.
1385
+ * Charges $1 from your session budget.
1386
+ *
1387
+ * @param options - Deployment options including Glama server details and env vars
1388
+ * @returns Deployed instance with private endpoint URL
1389
+ *
1390
+ * @example
1391
+ * ```typescript
1392
+ * const result = await wallet.deployJitMcp({
1393
+ * glamaId: 'notion-mcp',
1394
+ * glamaNamespace: 'notion',
1395
+ * glamaSlug: 'notion-mcp',
1396
+ * toolName: 'My Notion Server',
1397
+ * envVars: { NOTION_API_KEY: 'secret_...' },
1398
+ * ttlHours: 24,
1399
+ * });
1400
+ *
1401
+ * console.log('Endpoint:', result.instance.endpointUrl);
1402
+ * console.log('Expires:', result.instance.expiresAt);
1403
+ * ```
1404
+ */
1405
+ deployJitMcp(options: DeployJitMcpOptions): Promise<DeployJitMcpResult>;
1406
+ /**
1407
+ * List your deployed JIT MCP server instances.
1408
+ *
1409
+ * @param options - Optional filters
1410
+ * @returns Array of JIT instances
1411
+ *
1412
+ * @example
1413
+ * ```typescript
1414
+ * const instances = await wallet.listJitInstances({ status: 'active' });
1415
+ * for (const inst of instances) {
1416
+ * console.log(`${inst.toolName}: ${inst.endpointUrl}`);
1417
+ * }
1418
+ * ```
1419
+ */
1420
+ listJitInstances(options?: {
1421
+ status?: 'provisioning' | 'active' | 'stopped' | 'expired';
1422
+ }): Promise<JitInstance[]>;
1423
+ /**
1424
+ * Stop a running JIT MCP server instance.
1425
+ *
1426
+ * Instance will be marked as stopped and Worker cleaned up.
1427
+ * No refund is given - instances are billed at deploy time.
1428
+ *
1429
+ * @param instanceId - The instance ID to stop
1430
+ *
1431
+ * @example
1432
+ * ```typescript
1433
+ * await wallet.stopJitInstance('inst_abc123');
1434
+ * console.log('Instance stopped');
1435
+ * ```
1436
+ */
1437
+ stopJitInstance(instanceId: string): Promise<void>;
1438
+ /**
1439
+ * Parse JIT instance response data.
1440
+ */
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;
1510
+ /**
1511
+ * Simple LLM completion - single-turn, no tools.
1512
+ *
1513
+ * This is a convenience method for agents that just need to call an LLM
1514
+ * without the full agentic loop. Useful when Clawdbot spawns agents
1515
+ * that need to make their own LLM calls through MixrPay.
1516
+ *
1517
+ * @param prompt - The user prompt to send
1518
+ * @param options - Optional configuration
1519
+ * @returns The LLM response text and cost
1520
+ *
1521
+ * @example Basic usage
1522
+ * ```typescript
1523
+ * const result = await wallet.complete('Summarize this text: ...');
1524
+ * console.log(result.text);
1525
+ * console.log(`Cost: $${result.costUsd.toFixed(4)}`);
1526
+ * ```
1527
+ *
1528
+ * @example With custom model
1529
+ * ```typescript
1530
+ * const result = await wallet.complete(
1531
+ * 'Write a haiku about coding',
1532
+ * { model: 'gpt-4o', systemPrompt: 'You are a poet.' }
1533
+ * );
1534
+ * ```
1535
+ */
1536
+ complete(prompt: string, options?: CompleteOptions): Promise<CompleteResult>;
1374
1537
  /**
1375
1538
  * Run an AI agent with LLM and tool execution.
1376
1539
  *
@@ -2081,6 +2244,161 @@ interface AgentMessage {
2081
2244
  /** Message content */
2082
2245
  content: string;
2083
2246
  }
2247
+ /**
2248
+ * Options for deploying a JIT MCP server
2249
+ */
2250
+ interface DeployJitMcpOptions {
2251
+ /** Glama server ID (e.g., 'notion-mcp') */
2252
+ glamaId: string;
2253
+ /** Glama namespace (e.g., 'notion') */
2254
+ glamaNamespace: string;
2255
+ /** Glama slug (e.g., 'notion-mcp') */
2256
+ glamaSlug: string;
2257
+ /** Human-readable name for the tool */
2258
+ toolName: string;
2259
+ /** Optional description */
2260
+ toolDescription?: string;
2261
+ /** Environment variables for the MCP server (e.g., API keys) */
2262
+ envVars?: Record<string, string>;
2263
+ /** Time-to-live in hours (default: 24, max: 168) */
2264
+ ttlHours?: number;
2265
+ }
2266
+ /**
2267
+ * Result from deploying a JIT MCP server
2268
+ */
2269
+ interface DeployJitMcpResult {
2270
+ /** Deployed instance details */
2271
+ instance: JitInstance;
2272
+ /** Payment details */
2273
+ payment: {
2274
+ method: string;
2275
+ amountUsd: number;
2276
+ txHash?: string;
2277
+ };
2278
+ }
2279
+ /**
2280
+ * JIT MCP server instance
2281
+ */
2282
+ interface JitInstance {
2283
+ /** Instance ID */
2284
+ id: string;
2285
+ /** Private endpoint URL with secret token */
2286
+ endpointUrl: string;
2287
+ /** Tool name */
2288
+ toolName: string;
2289
+ /** Glama server ID */
2290
+ glamaId: string;
2291
+ /** Glama namespace */
2292
+ glamaNamespace: string;
2293
+ /** Glama slug */
2294
+ glamaSlug: string;
2295
+ /** Instance status */
2296
+ status: 'provisioning' | 'active' | 'stopped' | 'expired' | 'failed';
2297
+ /** Access mode */
2298
+ mode: 'private' | 'public';
2299
+ /** TTL in hours */
2300
+ ttlHours: number;
2301
+ /** Expiration time */
2302
+ expiresAt: Date;
2303
+ /** Creation time */
2304
+ createdAt: Date;
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
+ }
2377
+ /**
2378
+ * Options for simple LLM completion
2379
+ */
2380
+ interface CompleteOptions {
2381
+ /** LLM model to use (default: gpt-4o-mini) */
2382
+ model?: string;
2383
+ /** System prompt to set context */
2384
+ systemPrompt?: string;
2385
+ }
2386
+ /**
2387
+ * Result from simple LLM completion
2388
+ */
2389
+ interface CompleteResult {
2390
+ /** The LLM response text */
2391
+ text: string;
2392
+ /** Cost in USD */
2393
+ costUsd: number;
2394
+ /** Token usage */
2395
+ tokens: {
2396
+ prompt: number;
2397
+ completion: number;
2398
+ };
2399
+ /** Model used */
2400
+ model: string;
2401
+ }
2084
2402
  /**
2085
2403
  * Configuration for an agent run
2086
2404
  */
@@ -2446,7 +2764,7 @@ declare class PaymentFailedError extends MixrPayError {
2446
2764
  * catch (error) {
2447
2765
  * if (error instanceof InvalidSessionKeyError) {
2448
2766
  * console.log(`Invalid key: ${error.reason}`);
2449
- * console.log('Get a valid session key from your MixrPay server /wallet/sessions');
2767
+ * console.log('Get a valid session key from https://mixrpay.com/manage/invites');
2450
2768
  * }
2451
2769
  * }
2452
2770
  * ```
@@ -2664,4 +2982,4 @@ declare function isMixrPayError(error: unknown): error is MixrPayError;
2664
2982
  */
2665
2983
  declare function getErrorMessage(error: unknown): string;
2666
2984
 
2667
- 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 DiagnosticsResult, InsufficientBalanceError, InvalidSessionKeyError, 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 };