@mixrpay/agent-sdk 0.8.4 → 0.8.5
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.
Potentially problematic release.
This version of @mixrpay/agent-sdk might be problematic. Click here for more details.
- package/dist/index.cjs +201 -1
- package/dist/index.d.cts +174 -2
- package/dist/index.d.ts +174 -2
- package/dist/index.js +201 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -532,7 +532,7 @@ function getAmountUsd(requirements) {
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
// src/agent-wallet.ts
|
|
535
|
-
var SDK_VERSION = "0.8.
|
|
535
|
+
var SDK_VERSION = "0.8.5";
|
|
536
536
|
var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
|
|
537
537
|
var DEFAULT_TIMEOUT = 3e4;
|
|
538
538
|
var NETWORKS = {
|
|
@@ -2532,6 +2532,206 @@ Timestamp: ${timestamp}`;
|
|
|
2532
2532
|
};
|
|
2533
2533
|
}
|
|
2534
2534
|
// ===========================================================================
|
|
2535
|
+
// JIT MCP Server Methods
|
|
2536
|
+
// ===========================================================================
|
|
2537
|
+
/**
|
|
2538
|
+
* Deploy a JIT MCP server from the Glama directory.
|
|
2539
|
+
*
|
|
2540
|
+
* Deploys any remote-capable MCP server to Cloudflare Workers.
|
|
2541
|
+
* Charges $1 from your session budget.
|
|
2542
|
+
*
|
|
2543
|
+
* @param options - Deployment options including Glama server details and env vars
|
|
2544
|
+
* @returns Deployed instance with private endpoint URL
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```typescript
|
|
2548
|
+
* const result = await wallet.deployJitMcp({
|
|
2549
|
+
* glamaId: 'notion-mcp',
|
|
2550
|
+
* glamaNamespace: 'notion',
|
|
2551
|
+
* glamaSlug: 'notion-mcp',
|
|
2552
|
+
* toolName: 'My Notion Server',
|
|
2553
|
+
* envVars: { NOTION_API_KEY: 'secret_...' },
|
|
2554
|
+
* ttlHours: 24,
|
|
2555
|
+
* });
|
|
2556
|
+
*
|
|
2557
|
+
* console.log('Endpoint:', result.instance.endpointUrl);
|
|
2558
|
+
* console.log('Expires:', result.instance.expiresAt);
|
|
2559
|
+
* ```
|
|
2560
|
+
*/
|
|
2561
|
+
async deployJitMcp(options) {
|
|
2562
|
+
this.logger.debug("deployJitMcp", { glamaId: options.glamaId, toolName: options.toolName });
|
|
2563
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2564
|
+
const response = await fetch(`${this.baseUrl}/api/v2/jit/deploy`, {
|
|
2565
|
+
method: "POST",
|
|
2566
|
+
headers: {
|
|
2567
|
+
"Content-Type": "application/json",
|
|
2568
|
+
...authHeaders
|
|
2569
|
+
},
|
|
2570
|
+
body: JSON.stringify({
|
|
2571
|
+
glama_id: options.glamaId,
|
|
2572
|
+
glama_namespace: options.glamaNamespace,
|
|
2573
|
+
glama_slug: options.glamaSlug,
|
|
2574
|
+
tool_name: options.toolName,
|
|
2575
|
+
tool_description: options.toolDescription,
|
|
2576
|
+
env_vars: options.envVars,
|
|
2577
|
+
ttl_hours: options.ttlHours || 24
|
|
2578
|
+
// session_id not needed - derived from X-Session-Auth
|
|
2579
|
+
})
|
|
2580
|
+
});
|
|
2581
|
+
if (!response.ok) {
|
|
2582
|
+
const error = await response.json().catch(() => ({}));
|
|
2583
|
+
throw new MixrPayError(error.error || `JIT deploy failed: ${response.status}`);
|
|
2584
|
+
}
|
|
2585
|
+
const data = await response.json();
|
|
2586
|
+
if (data.payment?.amount_usd > 0) {
|
|
2587
|
+
const payment = {
|
|
2588
|
+
amountUsd: data.payment.amount_usd,
|
|
2589
|
+
recipient: "mixrpay-jit-deploy",
|
|
2590
|
+
txHash: data.payment.tx_hash,
|
|
2591
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2592
|
+
description: `JIT Deploy: ${options.toolName}`,
|
|
2593
|
+
url: `${this.baseUrl}/api/v2/jit/deploy`,
|
|
2594
|
+
requestId: data.request_id || crypto.randomUUID()
|
|
2595
|
+
};
|
|
2596
|
+
this.payments.push(payment);
|
|
2597
|
+
this.totalSpentUsd += data.payment.amount_usd;
|
|
2598
|
+
this.logger.payment(data.payment.amount_usd, "jit-deploy", options.toolName);
|
|
2599
|
+
if (this.onPayment) {
|
|
2600
|
+
this.onPayment(payment);
|
|
2601
|
+
}
|
|
2602
|
+
}
|
|
2603
|
+
return {
|
|
2604
|
+
instance: this.parseJitInstance(data.instance),
|
|
2605
|
+
payment: {
|
|
2606
|
+
method: data.payment.method,
|
|
2607
|
+
amountUsd: data.payment.amount_usd,
|
|
2608
|
+
txHash: data.payment.tx_hash
|
|
2609
|
+
}
|
|
2610
|
+
};
|
|
2611
|
+
}
|
|
2612
|
+
/**
|
|
2613
|
+
* List your deployed JIT MCP server instances.
|
|
2614
|
+
*
|
|
2615
|
+
* @param options - Optional filters
|
|
2616
|
+
* @returns Array of JIT instances
|
|
2617
|
+
*
|
|
2618
|
+
* @example
|
|
2619
|
+
* ```typescript
|
|
2620
|
+
* const instances = await wallet.listJitInstances({ status: 'active' });
|
|
2621
|
+
* for (const inst of instances) {
|
|
2622
|
+
* console.log(`${inst.toolName}: ${inst.endpointUrl}`);
|
|
2623
|
+
* }
|
|
2624
|
+
* ```
|
|
2625
|
+
*/
|
|
2626
|
+
async listJitInstances(options) {
|
|
2627
|
+
this.logger.debug("listJitInstances", options);
|
|
2628
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2629
|
+
const params = new URLSearchParams();
|
|
2630
|
+
if (options?.status) params.set("status", options.status);
|
|
2631
|
+
const response = await fetch(
|
|
2632
|
+
`${this.baseUrl}/api/v2/jit/instances?${params}`,
|
|
2633
|
+
{ headers: authHeaders }
|
|
2634
|
+
);
|
|
2635
|
+
if (!response.ok) {
|
|
2636
|
+
const error = await response.json().catch(() => ({}));
|
|
2637
|
+
throw new MixrPayError(error.error || `Failed to list JIT instances: ${response.status}`);
|
|
2638
|
+
}
|
|
2639
|
+
const data = await response.json();
|
|
2640
|
+
return (data.instances || []).map((i) => this.parseJitInstance(i));
|
|
2641
|
+
}
|
|
2642
|
+
/**
|
|
2643
|
+
* Stop a running JIT MCP server instance.
|
|
2644
|
+
*
|
|
2645
|
+
* Instance will be marked as stopped and Worker cleaned up.
|
|
2646
|
+
* No refund is given - instances are billed at deploy time.
|
|
2647
|
+
*
|
|
2648
|
+
* @param instanceId - The instance ID to stop
|
|
2649
|
+
*
|
|
2650
|
+
* @example
|
|
2651
|
+
* ```typescript
|
|
2652
|
+
* await wallet.stopJitInstance('inst_abc123');
|
|
2653
|
+
* console.log('Instance stopped');
|
|
2654
|
+
* ```
|
|
2655
|
+
*/
|
|
2656
|
+
async stopJitInstance(instanceId) {
|
|
2657
|
+
this.logger.debug("stopJitInstance", { instanceId });
|
|
2658
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2659
|
+
const response = await fetch(
|
|
2660
|
+
`${this.baseUrl}/api/v2/jit/instances/${instanceId}`,
|
|
2661
|
+
{ method: "DELETE", headers: authHeaders }
|
|
2662
|
+
);
|
|
2663
|
+
if (!response.ok) {
|
|
2664
|
+
const error = await response.json().catch(() => ({}));
|
|
2665
|
+
throw new MixrPayError(error.error || `Failed to stop JIT instance: ${response.status}`);
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
/**
|
|
2669
|
+
* Parse JIT instance response data.
|
|
2670
|
+
*/
|
|
2671
|
+
parseJitInstance(data) {
|
|
2672
|
+
return {
|
|
2673
|
+
id: data.id,
|
|
2674
|
+
endpointUrl: data.endpoint_url,
|
|
2675
|
+
toolName: data.tool_name,
|
|
2676
|
+
glamaId: data.glama_id,
|
|
2677
|
+
glamaNamespace: data.glama_namespace,
|
|
2678
|
+
glamaSlug: data.glama_slug,
|
|
2679
|
+
status: data.status,
|
|
2680
|
+
mode: data.mode,
|
|
2681
|
+
ttlHours: data.ttl_hours,
|
|
2682
|
+
expiresAt: new Date(data.expires_at),
|
|
2683
|
+
createdAt: new Date(data.created_at)
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2686
|
+
// ===========================================================================
|
|
2687
|
+
// LLM Completion Methods
|
|
2688
|
+
// ===========================================================================
|
|
2689
|
+
/**
|
|
2690
|
+
* Simple LLM completion - single-turn, no tools.
|
|
2691
|
+
*
|
|
2692
|
+
* This is a convenience method for agents that just need to call an LLM
|
|
2693
|
+
* without the full agentic loop. Useful when Clawdbot spawns agents
|
|
2694
|
+
* that need to make their own LLM calls through MixrPay.
|
|
2695
|
+
*
|
|
2696
|
+
* @param prompt - The user prompt to send
|
|
2697
|
+
* @param options - Optional configuration
|
|
2698
|
+
* @returns The LLM response text and cost
|
|
2699
|
+
*
|
|
2700
|
+
* @example Basic usage
|
|
2701
|
+
* ```typescript
|
|
2702
|
+
* const result = await wallet.complete('Summarize this text: ...');
|
|
2703
|
+
* console.log(result.text);
|
|
2704
|
+
* console.log(`Cost: $${result.costUsd.toFixed(4)}`);
|
|
2705
|
+
* ```
|
|
2706
|
+
*
|
|
2707
|
+
* @example With custom model
|
|
2708
|
+
* ```typescript
|
|
2709
|
+
* const result = await wallet.complete(
|
|
2710
|
+
* 'Write a haiku about coding',
|
|
2711
|
+
* { model: 'gpt-4o', systemPrompt: 'You are a poet.' }
|
|
2712
|
+
* );
|
|
2713
|
+
* ```
|
|
2714
|
+
*/
|
|
2715
|
+
async complete(prompt, options) {
|
|
2716
|
+
this.logger.debug("complete", { promptLength: prompt.length, model: options?.model });
|
|
2717
|
+
const result = await this.runAgent({
|
|
2718
|
+
messages: [{ role: "user", content: prompt }],
|
|
2719
|
+
config: {
|
|
2720
|
+
model: options?.model || "gpt-4o-mini",
|
|
2721
|
+
maxIterations: 1,
|
|
2722
|
+
tools: [],
|
|
2723
|
+
// No tools - pure LLM completion
|
|
2724
|
+
systemPrompt: options?.systemPrompt
|
|
2725
|
+
}
|
|
2726
|
+
});
|
|
2727
|
+
return {
|
|
2728
|
+
text: result.response,
|
|
2729
|
+
costUsd: result.cost.totalUsd,
|
|
2730
|
+
tokens: result.tokens,
|
|
2731
|
+
model: options?.model || "gpt-4o-mini"
|
|
2732
|
+
};
|
|
2733
|
+
}
|
|
2734
|
+
// ===========================================================================
|
|
2535
2735
|
// Agent Runtime API
|
|
2536
2736
|
// ===========================================================================
|
|
2537
2737
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -380,7 +380,7 @@ interface SessionStats {
|
|
|
380
380
|
*/
|
|
381
381
|
|
|
382
382
|
/** Current SDK version */
|
|
383
|
-
declare const SDK_VERSION = "0.8.
|
|
383
|
+
declare const SDK_VERSION = "0.8.5";
|
|
384
384
|
/** Supported networks */
|
|
385
385
|
declare const NETWORKS: {
|
|
386
386
|
readonly BASE_MAINNET: {
|
|
@@ -1371,6 +1371,94 @@ declare class AgentWallet {
|
|
|
1371
1371
|
* ```
|
|
1372
1372
|
*/
|
|
1373
1373
|
callMCPTool(toolName: string, args?: Record<string, unknown>): Promise<MCPToolResult>;
|
|
1374
|
+
/**
|
|
1375
|
+
* Deploy a JIT MCP server from the Glama directory.
|
|
1376
|
+
*
|
|
1377
|
+
* Deploys any remote-capable MCP server to Cloudflare Workers.
|
|
1378
|
+
* Charges $1 from your session budget.
|
|
1379
|
+
*
|
|
1380
|
+
* @param options - Deployment options including Glama server details and env vars
|
|
1381
|
+
* @returns Deployed instance with private endpoint URL
|
|
1382
|
+
*
|
|
1383
|
+
* @example
|
|
1384
|
+
* ```typescript
|
|
1385
|
+
* const result = await wallet.deployJitMcp({
|
|
1386
|
+
* glamaId: 'notion-mcp',
|
|
1387
|
+
* glamaNamespace: 'notion',
|
|
1388
|
+
* glamaSlug: 'notion-mcp',
|
|
1389
|
+
* toolName: 'My Notion Server',
|
|
1390
|
+
* envVars: { NOTION_API_KEY: 'secret_...' },
|
|
1391
|
+
* ttlHours: 24,
|
|
1392
|
+
* });
|
|
1393
|
+
*
|
|
1394
|
+
* console.log('Endpoint:', result.instance.endpointUrl);
|
|
1395
|
+
* console.log('Expires:', result.instance.expiresAt);
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
deployJitMcp(options: DeployJitMcpOptions): Promise<DeployJitMcpResult>;
|
|
1399
|
+
/**
|
|
1400
|
+
* List your deployed JIT MCP server instances.
|
|
1401
|
+
*
|
|
1402
|
+
* @param options - Optional filters
|
|
1403
|
+
* @returns Array of JIT instances
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```typescript
|
|
1407
|
+
* const instances = await wallet.listJitInstances({ status: 'active' });
|
|
1408
|
+
* for (const inst of instances) {
|
|
1409
|
+
* console.log(`${inst.toolName}: ${inst.endpointUrl}`);
|
|
1410
|
+
* }
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
listJitInstances(options?: {
|
|
1414
|
+
status?: 'provisioning' | 'active' | 'stopped' | 'expired';
|
|
1415
|
+
}): Promise<JitInstance[]>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Stop a running JIT MCP server instance.
|
|
1418
|
+
*
|
|
1419
|
+
* Instance will be marked as stopped and Worker cleaned up.
|
|
1420
|
+
* No refund is given - instances are billed at deploy time.
|
|
1421
|
+
*
|
|
1422
|
+
* @param instanceId - The instance ID to stop
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
* ```typescript
|
|
1426
|
+
* await wallet.stopJitInstance('inst_abc123');
|
|
1427
|
+
* console.log('Instance stopped');
|
|
1428
|
+
* ```
|
|
1429
|
+
*/
|
|
1430
|
+
stopJitInstance(instanceId: string): Promise<void>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Parse JIT instance response data.
|
|
1433
|
+
*/
|
|
1434
|
+
private parseJitInstance;
|
|
1435
|
+
/**
|
|
1436
|
+
* Simple LLM completion - single-turn, no tools.
|
|
1437
|
+
*
|
|
1438
|
+
* This is a convenience method for agents that just need to call an LLM
|
|
1439
|
+
* without the full agentic loop. Useful when Clawdbot spawns agents
|
|
1440
|
+
* that need to make their own LLM calls through MixrPay.
|
|
1441
|
+
*
|
|
1442
|
+
* @param prompt - The user prompt to send
|
|
1443
|
+
* @param options - Optional configuration
|
|
1444
|
+
* @returns The LLM response text and cost
|
|
1445
|
+
*
|
|
1446
|
+
* @example Basic usage
|
|
1447
|
+
* ```typescript
|
|
1448
|
+
* const result = await wallet.complete('Summarize this text: ...');
|
|
1449
|
+
* console.log(result.text);
|
|
1450
|
+
* console.log(`Cost: $${result.costUsd.toFixed(4)}`);
|
|
1451
|
+
* ```
|
|
1452
|
+
*
|
|
1453
|
+
* @example With custom model
|
|
1454
|
+
* ```typescript
|
|
1455
|
+
* const result = await wallet.complete(
|
|
1456
|
+
* 'Write a haiku about coding',
|
|
1457
|
+
* { model: 'gpt-4o', systemPrompt: 'You are a poet.' }
|
|
1458
|
+
* );
|
|
1459
|
+
* ```
|
|
1460
|
+
*/
|
|
1461
|
+
complete(prompt: string, options?: CompleteOptions): Promise<CompleteResult>;
|
|
1374
1462
|
/**
|
|
1375
1463
|
* Run an AI agent with LLM and tool execution.
|
|
1376
1464
|
*
|
|
@@ -2081,6 +2169,90 @@ interface AgentMessage {
|
|
|
2081
2169
|
/** Message content */
|
|
2082
2170
|
content: string;
|
|
2083
2171
|
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Options for deploying a JIT MCP server
|
|
2174
|
+
*/
|
|
2175
|
+
interface DeployJitMcpOptions {
|
|
2176
|
+
/** Glama server ID (e.g., 'notion-mcp') */
|
|
2177
|
+
glamaId: string;
|
|
2178
|
+
/** Glama namespace (e.g., 'notion') */
|
|
2179
|
+
glamaNamespace: string;
|
|
2180
|
+
/** Glama slug (e.g., 'notion-mcp') */
|
|
2181
|
+
glamaSlug: string;
|
|
2182
|
+
/** Human-readable name for the tool */
|
|
2183
|
+
toolName: string;
|
|
2184
|
+
/** Optional description */
|
|
2185
|
+
toolDescription?: string;
|
|
2186
|
+
/** Environment variables for the MCP server (e.g., API keys) */
|
|
2187
|
+
envVars?: Record<string, string>;
|
|
2188
|
+
/** Time-to-live in hours (default: 24, max: 168) */
|
|
2189
|
+
ttlHours?: number;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Result from deploying a JIT MCP server
|
|
2193
|
+
*/
|
|
2194
|
+
interface DeployJitMcpResult {
|
|
2195
|
+
/** Deployed instance details */
|
|
2196
|
+
instance: JitInstance;
|
|
2197
|
+
/** Payment details */
|
|
2198
|
+
payment: {
|
|
2199
|
+
method: string;
|
|
2200
|
+
amountUsd: number;
|
|
2201
|
+
txHash?: string;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* JIT MCP server instance
|
|
2206
|
+
*/
|
|
2207
|
+
interface JitInstance {
|
|
2208
|
+
/** Instance ID */
|
|
2209
|
+
id: string;
|
|
2210
|
+
/** Private endpoint URL with secret token */
|
|
2211
|
+
endpointUrl: string;
|
|
2212
|
+
/** Tool name */
|
|
2213
|
+
toolName: string;
|
|
2214
|
+
/** Glama server ID */
|
|
2215
|
+
glamaId: string;
|
|
2216
|
+
/** Glama namespace */
|
|
2217
|
+
glamaNamespace: string;
|
|
2218
|
+
/** Glama slug */
|
|
2219
|
+
glamaSlug: string;
|
|
2220
|
+
/** Instance status */
|
|
2221
|
+
status: 'provisioning' | 'active' | 'stopped' | 'expired' | 'failed';
|
|
2222
|
+
/** Access mode */
|
|
2223
|
+
mode: 'private' | 'public';
|
|
2224
|
+
/** TTL in hours */
|
|
2225
|
+
ttlHours: number;
|
|
2226
|
+
/** Expiration time */
|
|
2227
|
+
expiresAt: Date;
|
|
2228
|
+
/** Creation time */
|
|
2229
|
+
createdAt: Date;
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Options for simple LLM completion
|
|
2233
|
+
*/
|
|
2234
|
+
interface CompleteOptions {
|
|
2235
|
+
/** LLM model to use (default: gpt-4o-mini) */
|
|
2236
|
+
model?: string;
|
|
2237
|
+
/** System prompt to set context */
|
|
2238
|
+
systemPrompt?: string;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Result from simple LLM completion
|
|
2242
|
+
*/
|
|
2243
|
+
interface CompleteResult {
|
|
2244
|
+
/** The LLM response text */
|
|
2245
|
+
text: string;
|
|
2246
|
+
/** Cost in USD */
|
|
2247
|
+
costUsd: number;
|
|
2248
|
+
/** Token usage */
|
|
2249
|
+
tokens: {
|
|
2250
|
+
prompt: number;
|
|
2251
|
+
completion: number;
|
|
2252
|
+
};
|
|
2253
|
+
/** Model used */
|
|
2254
|
+
model: string;
|
|
2255
|
+
}
|
|
2084
2256
|
/**
|
|
2085
2257
|
* Configuration for an agent run
|
|
2086
2258
|
*/
|
|
@@ -2664,4 +2836,4 @@ declare function isMixrPayError(error: unknown): error is MixrPayError;
|
|
|
2664
2836
|
*/
|
|
2665
2837
|
declare function getErrorMessage(error: unknown): string;
|
|
2666
2838
|
|
|
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 };
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -380,7 +380,7 @@ interface SessionStats {
|
|
|
380
380
|
*/
|
|
381
381
|
|
|
382
382
|
/** Current SDK version */
|
|
383
|
-
declare const SDK_VERSION = "0.8.
|
|
383
|
+
declare const SDK_VERSION = "0.8.5";
|
|
384
384
|
/** Supported networks */
|
|
385
385
|
declare const NETWORKS: {
|
|
386
386
|
readonly BASE_MAINNET: {
|
|
@@ -1371,6 +1371,94 @@ declare class AgentWallet {
|
|
|
1371
1371
|
* ```
|
|
1372
1372
|
*/
|
|
1373
1373
|
callMCPTool(toolName: string, args?: Record<string, unknown>): Promise<MCPToolResult>;
|
|
1374
|
+
/**
|
|
1375
|
+
* Deploy a JIT MCP server from the Glama directory.
|
|
1376
|
+
*
|
|
1377
|
+
* Deploys any remote-capable MCP server to Cloudflare Workers.
|
|
1378
|
+
* Charges $1 from your session budget.
|
|
1379
|
+
*
|
|
1380
|
+
* @param options - Deployment options including Glama server details and env vars
|
|
1381
|
+
* @returns Deployed instance with private endpoint URL
|
|
1382
|
+
*
|
|
1383
|
+
* @example
|
|
1384
|
+
* ```typescript
|
|
1385
|
+
* const result = await wallet.deployJitMcp({
|
|
1386
|
+
* glamaId: 'notion-mcp',
|
|
1387
|
+
* glamaNamespace: 'notion',
|
|
1388
|
+
* glamaSlug: 'notion-mcp',
|
|
1389
|
+
* toolName: 'My Notion Server',
|
|
1390
|
+
* envVars: { NOTION_API_KEY: 'secret_...' },
|
|
1391
|
+
* ttlHours: 24,
|
|
1392
|
+
* });
|
|
1393
|
+
*
|
|
1394
|
+
* console.log('Endpoint:', result.instance.endpointUrl);
|
|
1395
|
+
* console.log('Expires:', result.instance.expiresAt);
|
|
1396
|
+
* ```
|
|
1397
|
+
*/
|
|
1398
|
+
deployJitMcp(options: DeployJitMcpOptions): Promise<DeployJitMcpResult>;
|
|
1399
|
+
/**
|
|
1400
|
+
* List your deployed JIT MCP server instances.
|
|
1401
|
+
*
|
|
1402
|
+
* @param options - Optional filters
|
|
1403
|
+
* @returns Array of JIT instances
|
|
1404
|
+
*
|
|
1405
|
+
* @example
|
|
1406
|
+
* ```typescript
|
|
1407
|
+
* const instances = await wallet.listJitInstances({ status: 'active' });
|
|
1408
|
+
* for (const inst of instances) {
|
|
1409
|
+
* console.log(`${inst.toolName}: ${inst.endpointUrl}`);
|
|
1410
|
+
* }
|
|
1411
|
+
* ```
|
|
1412
|
+
*/
|
|
1413
|
+
listJitInstances(options?: {
|
|
1414
|
+
status?: 'provisioning' | 'active' | 'stopped' | 'expired';
|
|
1415
|
+
}): Promise<JitInstance[]>;
|
|
1416
|
+
/**
|
|
1417
|
+
* Stop a running JIT MCP server instance.
|
|
1418
|
+
*
|
|
1419
|
+
* Instance will be marked as stopped and Worker cleaned up.
|
|
1420
|
+
* No refund is given - instances are billed at deploy time.
|
|
1421
|
+
*
|
|
1422
|
+
* @param instanceId - The instance ID to stop
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
* ```typescript
|
|
1426
|
+
* await wallet.stopJitInstance('inst_abc123');
|
|
1427
|
+
* console.log('Instance stopped');
|
|
1428
|
+
* ```
|
|
1429
|
+
*/
|
|
1430
|
+
stopJitInstance(instanceId: string): Promise<void>;
|
|
1431
|
+
/**
|
|
1432
|
+
* Parse JIT instance response data.
|
|
1433
|
+
*/
|
|
1434
|
+
private parseJitInstance;
|
|
1435
|
+
/**
|
|
1436
|
+
* Simple LLM completion - single-turn, no tools.
|
|
1437
|
+
*
|
|
1438
|
+
* This is a convenience method for agents that just need to call an LLM
|
|
1439
|
+
* without the full agentic loop. Useful when Clawdbot spawns agents
|
|
1440
|
+
* that need to make their own LLM calls through MixrPay.
|
|
1441
|
+
*
|
|
1442
|
+
* @param prompt - The user prompt to send
|
|
1443
|
+
* @param options - Optional configuration
|
|
1444
|
+
* @returns The LLM response text and cost
|
|
1445
|
+
*
|
|
1446
|
+
* @example Basic usage
|
|
1447
|
+
* ```typescript
|
|
1448
|
+
* const result = await wallet.complete('Summarize this text: ...');
|
|
1449
|
+
* console.log(result.text);
|
|
1450
|
+
* console.log(`Cost: $${result.costUsd.toFixed(4)}`);
|
|
1451
|
+
* ```
|
|
1452
|
+
*
|
|
1453
|
+
* @example With custom model
|
|
1454
|
+
* ```typescript
|
|
1455
|
+
* const result = await wallet.complete(
|
|
1456
|
+
* 'Write a haiku about coding',
|
|
1457
|
+
* { model: 'gpt-4o', systemPrompt: 'You are a poet.' }
|
|
1458
|
+
* );
|
|
1459
|
+
* ```
|
|
1460
|
+
*/
|
|
1461
|
+
complete(prompt: string, options?: CompleteOptions): Promise<CompleteResult>;
|
|
1374
1462
|
/**
|
|
1375
1463
|
* Run an AI agent with LLM and tool execution.
|
|
1376
1464
|
*
|
|
@@ -2081,6 +2169,90 @@ interface AgentMessage {
|
|
|
2081
2169
|
/** Message content */
|
|
2082
2170
|
content: string;
|
|
2083
2171
|
}
|
|
2172
|
+
/**
|
|
2173
|
+
* Options for deploying a JIT MCP server
|
|
2174
|
+
*/
|
|
2175
|
+
interface DeployJitMcpOptions {
|
|
2176
|
+
/** Glama server ID (e.g., 'notion-mcp') */
|
|
2177
|
+
glamaId: string;
|
|
2178
|
+
/** Glama namespace (e.g., 'notion') */
|
|
2179
|
+
glamaNamespace: string;
|
|
2180
|
+
/** Glama slug (e.g., 'notion-mcp') */
|
|
2181
|
+
glamaSlug: string;
|
|
2182
|
+
/** Human-readable name for the tool */
|
|
2183
|
+
toolName: string;
|
|
2184
|
+
/** Optional description */
|
|
2185
|
+
toolDescription?: string;
|
|
2186
|
+
/** Environment variables for the MCP server (e.g., API keys) */
|
|
2187
|
+
envVars?: Record<string, string>;
|
|
2188
|
+
/** Time-to-live in hours (default: 24, max: 168) */
|
|
2189
|
+
ttlHours?: number;
|
|
2190
|
+
}
|
|
2191
|
+
/**
|
|
2192
|
+
* Result from deploying a JIT MCP server
|
|
2193
|
+
*/
|
|
2194
|
+
interface DeployJitMcpResult {
|
|
2195
|
+
/** Deployed instance details */
|
|
2196
|
+
instance: JitInstance;
|
|
2197
|
+
/** Payment details */
|
|
2198
|
+
payment: {
|
|
2199
|
+
method: string;
|
|
2200
|
+
amountUsd: number;
|
|
2201
|
+
txHash?: string;
|
|
2202
|
+
};
|
|
2203
|
+
}
|
|
2204
|
+
/**
|
|
2205
|
+
* JIT MCP server instance
|
|
2206
|
+
*/
|
|
2207
|
+
interface JitInstance {
|
|
2208
|
+
/** Instance ID */
|
|
2209
|
+
id: string;
|
|
2210
|
+
/** Private endpoint URL with secret token */
|
|
2211
|
+
endpointUrl: string;
|
|
2212
|
+
/** Tool name */
|
|
2213
|
+
toolName: string;
|
|
2214
|
+
/** Glama server ID */
|
|
2215
|
+
glamaId: string;
|
|
2216
|
+
/** Glama namespace */
|
|
2217
|
+
glamaNamespace: string;
|
|
2218
|
+
/** Glama slug */
|
|
2219
|
+
glamaSlug: string;
|
|
2220
|
+
/** Instance status */
|
|
2221
|
+
status: 'provisioning' | 'active' | 'stopped' | 'expired' | 'failed';
|
|
2222
|
+
/** Access mode */
|
|
2223
|
+
mode: 'private' | 'public';
|
|
2224
|
+
/** TTL in hours */
|
|
2225
|
+
ttlHours: number;
|
|
2226
|
+
/** Expiration time */
|
|
2227
|
+
expiresAt: Date;
|
|
2228
|
+
/** Creation time */
|
|
2229
|
+
createdAt: Date;
|
|
2230
|
+
}
|
|
2231
|
+
/**
|
|
2232
|
+
* Options for simple LLM completion
|
|
2233
|
+
*/
|
|
2234
|
+
interface CompleteOptions {
|
|
2235
|
+
/** LLM model to use (default: gpt-4o-mini) */
|
|
2236
|
+
model?: string;
|
|
2237
|
+
/** System prompt to set context */
|
|
2238
|
+
systemPrompt?: string;
|
|
2239
|
+
}
|
|
2240
|
+
/**
|
|
2241
|
+
* Result from simple LLM completion
|
|
2242
|
+
*/
|
|
2243
|
+
interface CompleteResult {
|
|
2244
|
+
/** The LLM response text */
|
|
2245
|
+
text: string;
|
|
2246
|
+
/** Cost in USD */
|
|
2247
|
+
costUsd: number;
|
|
2248
|
+
/** Token usage */
|
|
2249
|
+
tokens: {
|
|
2250
|
+
prompt: number;
|
|
2251
|
+
completion: number;
|
|
2252
|
+
};
|
|
2253
|
+
/** Model used */
|
|
2254
|
+
model: string;
|
|
2255
|
+
}
|
|
2084
2256
|
/**
|
|
2085
2257
|
* Configuration for an agent run
|
|
2086
2258
|
*/
|
|
@@ -2664,4 +2836,4 @@ declare function isMixrPayError(error: unknown): error is MixrPayError;
|
|
|
2664
2836
|
*/
|
|
2665
2837
|
declare function getErrorMessage(error: unknown): string;
|
|
2666
2838
|
|
|
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 };
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -495,7 +495,7 @@ function getAmountUsd(requirements) {
|
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
// src/agent-wallet.ts
|
|
498
|
-
var SDK_VERSION = "0.8.
|
|
498
|
+
var SDK_VERSION = "0.8.5";
|
|
499
499
|
var DEFAULT_BASE_URL = process.env.MIXRPAY_BASE_URL || "https://www.mixrpay.com";
|
|
500
500
|
var DEFAULT_TIMEOUT = 3e4;
|
|
501
501
|
var NETWORKS = {
|
|
@@ -2495,6 +2495,206 @@ Timestamp: ${timestamp}`;
|
|
|
2495
2495
|
};
|
|
2496
2496
|
}
|
|
2497
2497
|
// ===========================================================================
|
|
2498
|
+
// JIT MCP Server Methods
|
|
2499
|
+
// ===========================================================================
|
|
2500
|
+
/**
|
|
2501
|
+
* Deploy a JIT MCP server from the Glama directory.
|
|
2502
|
+
*
|
|
2503
|
+
* Deploys any remote-capable MCP server to Cloudflare Workers.
|
|
2504
|
+
* Charges $1 from your session budget.
|
|
2505
|
+
*
|
|
2506
|
+
* @param options - Deployment options including Glama server details and env vars
|
|
2507
|
+
* @returns Deployed instance with private endpoint URL
|
|
2508
|
+
*
|
|
2509
|
+
* @example
|
|
2510
|
+
* ```typescript
|
|
2511
|
+
* const result = await wallet.deployJitMcp({
|
|
2512
|
+
* glamaId: 'notion-mcp',
|
|
2513
|
+
* glamaNamespace: 'notion',
|
|
2514
|
+
* glamaSlug: 'notion-mcp',
|
|
2515
|
+
* toolName: 'My Notion Server',
|
|
2516
|
+
* envVars: { NOTION_API_KEY: 'secret_...' },
|
|
2517
|
+
* ttlHours: 24,
|
|
2518
|
+
* });
|
|
2519
|
+
*
|
|
2520
|
+
* console.log('Endpoint:', result.instance.endpointUrl);
|
|
2521
|
+
* console.log('Expires:', result.instance.expiresAt);
|
|
2522
|
+
* ```
|
|
2523
|
+
*/
|
|
2524
|
+
async deployJitMcp(options) {
|
|
2525
|
+
this.logger.debug("deployJitMcp", { glamaId: options.glamaId, toolName: options.toolName });
|
|
2526
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2527
|
+
const response = await fetch(`${this.baseUrl}/api/v2/jit/deploy`, {
|
|
2528
|
+
method: "POST",
|
|
2529
|
+
headers: {
|
|
2530
|
+
"Content-Type": "application/json",
|
|
2531
|
+
...authHeaders
|
|
2532
|
+
},
|
|
2533
|
+
body: JSON.stringify({
|
|
2534
|
+
glama_id: options.glamaId,
|
|
2535
|
+
glama_namespace: options.glamaNamespace,
|
|
2536
|
+
glama_slug: options.glamaSlug,
|
|
2537
|
+
tool_name: options.toolName,
|
|
2538
|
+
tool_description: options.toolDescription,
|
|
2539
|
+
env_vars: options.envVars,
|
|
2540
|
+
ttl_hours: options.ttlHours || 24
|
|
2541
|
+
// session_id not needed - derived from X-Session-Auth
|
|
2542
|
+
})
|
|
2543
|
+
});
|
|
2544
|
+
if (!response.ok) {
|
|
2545
|
+
const error = await response.json().catch(() => ({}));
|
|
2546
|
+
throw new MixrPayError(error.error || `JIT deploy failed: ${response.status}`);
|
|
2547
|
+
}
|
|
2548
|
+
const data = await response.json();
|
|
2549
|
+
if (data.payment?.amount_usd > 0) {
|
|
2550
|
+
const payment = {
|
|
2551
|
+
amountUsd: data.payment.amount_usd,
|
|
2552
|
+
recipient: "mixrpay-jit-deploy",
|
|
2553
|
+
txHash: data.payment.tx_hash,
|
|
2554
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
2555
|
+
description: `JIT Deploy: ${options.toolName}`,
|
|
2556
|
+
url: `${this.baseUrl}/api/v2/jit/deploy`,
|
|
2557
|
+
requestId: data.request_id || crypto.randomUUID()
|
|
2558
|
+
};
|
|
2559
|
+
this.payments.push(payment);
|
|
2560
|
+
this.totalSpentUsd += data.payment.amount_usd;
|
|
2561
|
+
this.logger.payment(data.payment.amount_usd, "jit-deploy", options.toolName);
|
|
2562
|
+
if (this.onPayment) {
|
|
2563
|
+
this.onPayment(payment);
|
|
2564
|
+
}
|
|
2565
|
+
}
|
|
2566
|
+
return {
|
|
2567
|
+
instance: this.parseJitInstance(data.instance),
|
|
2568
|
+
payment: {
|
|
2569
|
+
method: data.payment.method,
|
|
2570
|
+
amountUsd: data.payment.amount_usd,
|
|
2571
|
+
txHash: data.payment.tx_hash
|
|
2572
|
+
}
|
|
2573
|
+
};
|
|
2574
|
+
}
|
|
2575
|
+
/**
|
|
2576
|
+
* List your deployed JIT MCP server instances.
|
|
2577
|
+
*
|
|
2578
|
+
* @param options - Optional filters
|
|
2579
|
+
* @returns Array of JIT instances
|
|
2580
|
+
*
|
|
2581
|
+
* @example
|
|
2582
|
+
* ```typescript
|
|
2583
|
+
* const instances = await wallet.listJitInstances({ status: 'active' });
|
|
2584
|
+
* for (const inst of instances) {
|
|
2585
|
+
* console.log(`${inst.toolName}: ${inst.endpointUrl}`);
|
|
2586
|
+
* }
|
|
2587
|
+
* ```
|
|
2588
|
+
*/
|
|
2589
|
+
async listJitInstances(options) {
|
|
2590
|
+
this.logger.debug("listJitInstances", options);
|
|
2591
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2592
|
+
const params = new URLSearchParams();
|
|
2593
|
+
if (options?.status) params.set("status", options.status);
|
|
2594
|
+
const response = await fetch(
|
|
2595
|
+
`${this.baseUrl}/api/v2/jit/instances?${params}`,
|
|
2596
|
+
{ headers: authHeaders }
|
|
2597
|
+
);
|
|
2598
|
+
if (!response.ok) {
|
|
2599
|
+
const error = await response.json().catch(() => ({}));
|
|
2600
|
+
throw new MixrPayError(error.error || `Failed to list JIT instances: ${response.status}`);
|
|
2601
|
+
}
|
|
2602
|
+
const data = await response.json();
|
|
2603
|
+
return (data.instances || []).map((i) => this.parseJitInstance(i));
|
|
2604
|
+
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Stop a running JIT MCP server instance.
|
|
2607
|
+
*
|
|
2608
|
+
* Instance will be marked as stopped and Worker cleaned up.
|
|
2609
|
+
* No refund is given - instances are billed at deploy time.
|
|
2610
|
+
*
|
|
2611
|
+
* @param instanceId - The instance ID to stop
|
|
2612
|
+
*
|
|
2613
|
+
* @example
|
|
2614
|
+
* ```typescript
|
|
2615
|
+
* await wallet.stopJitInstance('inst_abc123');
|
|
2616
|
+
* console.log('Instance stopped');
|
|
2617
|
+
* ```
|
|
2618
|
+
*/
|
|
2619
|
+
async stopJitInstance(instanceId) {
|
|
2620
|
+
this.logger.debug("stopJitInstance", { instanceId });
|
|
2621
|
+
const authHeaders = await this.getSessionAuthHeaders();
|
|
2622
|
+
const response = await fetch(
|
|
2623
|
+
`${this.baseUrl}/api/v2/jit/instances/${instanceId}`,
|
|
2624
|
+
{ method: "DELETE", headers: authHeaders }
|
|
2625
|
+
);
|
|
2626
|
+
if (!response.ok) {
|
|
2627
|
+
const error = await response.json().catch(() => ({}));
|
|
2628
|
+
throw new MixrPayError(error.error || `Failed to stop JIT instance: ${response.status}`);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
/**
|
|
2632
|
+
* Parse JIT instance response data.
|
|
2633
|
+
*/
|
|
2634
|
+
parseJitInstance(data) {
|
|
2635
|
+
return {
|
|
2636
|
+
id: data.id,
|
|
2637
|
+
endpointUrl: data.endpoint_url,
|
|
2638
|
+
toolName: data.tool_name,
|
|
2639
|
+
glamaId: data.glama_id,
|
|
2640
|
+
glamaNamespace: data.glama_namespace,
|
|
2641
|
+
glamaSlug: data.glama_slug,
|
|
2642
|
+
status: data.status,
|
|
2643
|
+
mode: data.mode,
|
|
2644
|
+
ttlHours: data.ttl_hours,
|
|
2645
|
+
expiresAt: new Date(data.expires_at),
|
|
2646
|
+
createdAt: new Date(data.created_at)
|
|
2647
|
+
};
|
|
2648
|
+
}
|
|
2649
|
+
// ===========================================================================
|
|
2650
|
+
// LLM Completion Methods
|
|
2651
|
+
// ===========================================================================
|
|
2652
|
+
/**
|
|
2653
|
+
* Simple LLM completion - single-turn, no tools.
|
|
2654
|
+
*
|
|
2655
|
+
* This is a convenience method for agents that just need to call an LLM
|
|
2656
|
+
* without the full agentic loop. Useful when Clawdbot spawns agents
|
|
2657
|
+
* that need to make their own LLM calls through MixrPay.
|
|
2658
|
+
*
|
|
2659
|
+
* @param prompt - The user prompt to send
|
|
2660
|
+
* @param options - Optional configuration
|
|
2661
|
+
* @returns The LLM response text and cost
|
|
2662
|
+
*
|
|
2663
|
+
* @example Basic usage
|
|
2664
|
+
* ```typescript
|
|
2665
|
+
* const result = await wallet.complete('Summarize this text: ...');
|
|
2666
|
+
* console.log(result.text);
|
|
2667
|
+
* console.log(`Cost: $${result.costUsd.toFixed(4)}`);
|
|
2668
|
+
* ```
|
|
2669
|
+
*
|
|
2670
|
+
* @example With custom model
|
|
2671
|
+
* ```typescript
|
|
2672
|
+
* const result = await wallet.complete(
|
|
2673
|
+
* 'Write a haiku about coding',
|
|
2674
|
+
* { model: 'gpt-4o', systemPrompt: 'You are a poet.' }
|
|
2675
|
+
* );
|
|
2676
|
+
* ```
|
|
2677
|
+
*/
|
|
2678
|
+
async complete(prompt, options) {
|
|
2679
|
+
this.logger.debug("complete", { promptLength: prompt.length, model: options?.model });
|
|
2680
|
+
const result = await this.runAgent({
|
|
2681
|
+
messages: [{ role: "user", content: prompt }],
|
|
2682
|
+
config: {
|
|
2683
|
+
model: options?.model || "gpt-4o-mini",
|
|
2684
|
+
maxIterations: 1,
|
|
2685
|
+
tools: [],
|
|
2686
|
+
// No tools - pure LLM completion
|
|
2687
|
+
systemPrompt: options?.systemPrompt
|
|
2688
|
+
}
|
|
2689
|
+
});
|
|
2690
|
+
return {
|
|
2691
|
+
text: result.response,
|
|
2692
|
+
costUsd: result.cost.totalUsd,
|
|
2693
|
+
tokens: result.tokens,
|
|
2694
|
+
model: options?.model || "gpt-4o-mini"
|
|
2695
|
+
};
|
|
2696
|
+
}
|
|
2697
|
+
// ===========================================================================
|
|
2498
2698
|
// Agent Runtime API
|
|
2499
2699
|
// ===========================================================================
|
|
2500
2700
|
/**
|