@mixrpay/agent-sdk 0.8.6 → 0.8.8
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/README.md +58 -4
- package/dist/index.cjs +396 -1
- package/dist/index.d.cts +423 -2
- package/dist/index.d.ts +423 -2
- package/dist/index.js +396 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -129,8 +129,14 @@ interface PaymentEvent {
|
|
|
129
129
|
* Information about a session key.
|
|
130
130
|
*/
|
|
131
131
|
interface SessionKeyInfo {
|
|
132
|
-
/** The session key's address (
|
|
132
|
+
/** The session key's derived address (used for signing requests) */
|
|
133
133
|
address: string;
|
|
134
|
+
/**
|
|
135
|
+
* The wallet address this session key is authorized to spend from.
|
|
136
|
+
* This is the human's funded wallet, NOT your agent's external wallet.
|
|
137
|
+
* All charges are deducted from this wallet.
|
|
138
|
+
*/
|
|
139
|
+
walletAddress: string | null;
|
|
134
140
|
/** Whether the session key is currently valid */
|
|
135
141
|
isValid: boolean;
|
|
136
142
|
/** Spending limits configured for this session key */
|
|
@@ -379,7 +385,7 @@ interface SessionStats {
|
|
|
379
385
|
*/
|
|
380
386
|
|
|
381
387
|
/** Current SDK version */
|
|
382
|
-
declare const SDK_VERSION = "0.8.
|
|
388
|
+
declare const SDK_VERSION = "0.8.7";
|
|
383
389
|
/** Supported networks */
|
|
384
390
|
declare const NETWORKS: {
|
|
385
391
|
readonly BASE_MAINNET: {
|
|
@@ -1507,6 +1513,165 @@ declare class AgentWallet {
|
|
|
1507
1513
|
* Parse Glama server response data.
|
|
1508
1514
|
*/
|
|
1509
1515
|
private parseGlamaServer;
|
|
1516
|
+
/**
|
|
1517
|
+
* Deploy a JIT Task Agent - a serverless agent that executes a specific task.
|
|
1518
|
+
*
|
|
1519
|
+
* JIT Task Agents run on Cloudflare Workers and execute an agentic loop
|
|
1520
|
+
* (LLM + tools) within a budget cap. They self-destruct when complete.
|
|
1521
|
+
*
|
|
1522
|
+
* @param options - Task agent deployment options
|
|
1523
|
+
* @returns Deployed task agent instance with endpoints
|
|
1524
|
+
*
|
|
1525
|
+
* @example Basic usage
|
|
1526
|
+
* ```typescript
|
|
1527
|
+
* const result = await wallet.deployTaskAgent({
|
|
1528
|
+
* name: 'Research Agent',
|
|
1529
|
+
* prompt: 'Research the top 5 AI startups in San Francisco',
|
|
1530
|
+
* budgetUsd: 5.00,
|
|
1531
|
+
* tools: ['platform/exa-search', 'platform/firecrawl-scrape'],
|
|
1532
|
+
* });
|
|
1533
|
+
*
|
|
1534
|
+
* console.log('Task ID:', result.instance.id);
|
|
1535
|
+
* console.log('Status URL:', result.instance.statusUrl);
|
|
1536
|
+
* ```
|
|
1537
|
+
*
|
|
1538
|
+
* @example With auto-run
|
|
1539
|
+
* ```typescript
|
|
1540
|
+
* const result = await wallet.deployTaskAgent({
|
|
1541
|
+
* name: 'Data Collector',
|
|
1542
|
+
* prompt: 'Collect pricing data from competitor websites',
|
|
1543
|
+
* budgetUsd: 10.00,
|
|
1544
|
+
* tools: ['platform/firecrawl-scrape'],
|
|
1545
|
+
* autoRun: true, // Start immediately
|
|
1546
|
+
* });
|
|
1547
|
+
*
|
|
1548
|
+
* // Wait for completion
|
|
1549
|
+
* const finalResult = await wallet.waitForTaskAgent(result.instance.id);
|
|
1550
|
+
* console.log('Result:', finalResult.result);
|
|
1551
|
+
* ```
|
|
1552
|
+
*/
|
|
1553
|
+
deployTaskAgent(options: DeployTaskAgentOptions): Promise<DeployTaskAgentResult>;
|
|
1554
|
+
/**
|
|
1555
|
+
* Get the status of a JIT Task Agent.
|
|
1556
|
+
*
|
|
1557
|
+
* @param instanceId - The task agent instance ID
|
|
1558
|
+
* @returns Current status and details
|
|
1559
|
+
*
|
|
1560
|
+
* @example
|
|
1561
|
+
* ```typescript
|
|
1562
|
+
* const status = await wallet.getTaskAgentStatus('cuid_abc123');
|
|
1563
|
+
* console.log('Status:', status.status);
|
|
1564
|
+
* console.log('Iterations:', status.iterations.current, '/', status.iterations.max);
|
|
1565
|
+
* console.log('Spent:', status.budget.spentUsd, '/', status.budget.totalUsd);
|
|
1566
|
+
* ```
|
|
1567
|
+
*/
|
|
1568
|
+
getTaskAgentStatus(instanceId: string): Promise<TaskAgentStatus>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Trigger execution of a JIT Task Agent.
|
|
1571
|
+
*
|
|
1572
|
+
* Only works for agents in 'active' status (not yet started).
|
|
1573
|
+
*
|
|
1574
|
+
* @param instanceId - The task agent instance ID
|
|
1575
|
+
* @returns Trigger result
|
|
1576
|
+
*
|
|
1577
|
+
* @example
|
|
1578
|
+
* ```typescript
|
|
1579
|
+
* // Deploy without auto-run
|
|
1580
|
+
* const { instance } = await wallet.deployTaskAgent({
|
|
1581
|
+
* name: 'Research',
|
|
1582
|
+
* prompt: 'Research AI trends',
|
|
1583
|
+
* budgetUsd: 5.00,
|
|
1584
|
+
* });
|
|
1585
|
+
*
|
|
1586
|
+
* // Later, trigger execution
|
|
1587
|
+
* await wallet.triggerTaskAgent(instance.id);
|
|
1588
|
+
* ```
|
|
1589
|
+
*/
|
|
1590
|
+
triggerTaskAgent(instanceId: string): Promise<{
|
|
1591
|
+
success: boolean;
|
|
1592
|
+
status: string;
|
|
1593
|
+
}>;
|
|
1594
|
+
/**
|
|
1595
|
+
* Cancel a JIT Task Agent.
|
|
1596
|
+
*
|
|
1597
|
+
* Stops execution and marks the task as cancelled.
|
|
1598
|
+
* Cannot cancel tasks that are already completed/failed.
|
|
1599
|
+
*
|
|
1600
|
+
* @param instanceId - The task agent instance ID
|
|
1601
|
+
* @returns Cancel result
|
|
1602
|
+
*
|
|
1603
|
+
* @example
|
|
1604
|
+
* ```typescript
|
|
1605
|
+
* await wallet.cancelTaskAgent('cuid_abc123');
|
|
1606
|
+
* console.log('Task cancelled');
|
|
1607
|
+
* ```
|
|
1608
|
+
*/
|
|
1609
|
+
cancelTaskAgent(instanceId: string): Promise<{
|
|
1610
|
+
success: boolean;
|
|
1611
|
+
status: string;
|
|
1612
|
+
}>;
|
|
1613
|
+
/**
|
|
1614
|
+
* List JIT Task Agents for the authenticated user.
|
|
1615
|
+
*
|
|
1616
|
+
* Returns deployed task agents with optional filtering by status,
|
|
1617
|
+
* plan, or task. Includes pagination and summary statistics.
|
|
1618
|
+
*
|
|
1619
|
+
* @param options - Optional filter and pagination parameters
|
|
1620
|
+
* @returns List of task agents with pagination and stats
|
|
1621
|
+
*
|
|
1622
|
+
* @example List all task agents
|
|
1623
|
+
* ```typescript
|
|
1624
|
+
* const { taskAgents, pagination, stats } = await wallet.listTaskAgents();
|
|
1625
|
+
* console.log(`${pagination.total} total agents, ${stats.active} active`);
|
|
1626
|
+
* ```
|
|
1627
|
+
*
|
|
1628
|
+
* @example Filter by status
|
|
1629
|
+
* ```typescript
|
|
1630
|
+
* const { taskAgents } = await wallet.listTaskAgents({ status: 'running' });
|
|
1631
|
+
* for (const agent of taskAgents) {
|
|
1632
|
+
* console.log(`${agent.name}: $${agent.budget.spentUsd}/$${agent.budget.totalUsd}`);
|
|
1633
|
+
* }
|
|
1634
|
+
* ```
|
|
1635
|
+
*
|
|
1636
|
+
* @example Filter by plan
|
|
1637
|
+
* ```typescript
|
|
1638
|
+
* const { taskAgents } = await wallet.listTaskAgents({ planId: 'plan_abc' });
|
|
1639
|
+
* ```
|
|
1640
|
+
*/
|
|
1641
|
+
listTaskAgents(options?: ListTaskAgentsOptions): Promise<ListTaskAgentsResult>;
|
|
1642
|
+
/**
|
|
1643
|
+
* Wait for a JIT Task Agent to complete.
|
|
1644
|
+
*
|
|
1645
|
+
* Polls the status until the task reaches a terminal state
|
|
1646
|
+
* (completed, failed, cancelled, budget_exceeded, expired).
|
|
1647
|
+
*
|
|
1648
|
+
* @param instanceId - The task agent instance ID
|
|
1649
|
+
* @param options - Wait options
|
|
1650
|
+
* @returns Final task result
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* ```typescript
|
|
1654
|
+
* const result = await wallet.waitForTaskAgent('cuid_abc123', {
|
|
1655
|
+
* pollIntervalMs: 2000,
|
|
1656
|
+
* timeoutMs: 300000, // 5 minutes
|
|
1657
|
+
* });
|
|
1658
|
+
*
|
|
1659
|
+
* if (result.status === 'completed') {
|
|
1660
|
+
* console.log('Result:', result.result);
|
|
1661
|
+
* } else {
|
|
1662
|
+
* console.log('Failed:', result.error);
|
|
1663
|
+
* }
|
|
1664
|
+
* ```
|
|
1665
|
+
*/
|
|
1666
|
+
waitForTaskAgent(instanceId: string, options?: WaitForTaskAgentOptions): Promise<TaskAgentResult>;
|
|
1667
|
+
/**
|
|
1668
|
+
* Parse task agent instance from API response.
|
|
1669
|
+
*/
|
|
1670
|
+
private parseTaskAgentInstance;
|
|
1671
|
+
/**
|
|
1672
|
+
* Parse task agent status from API response.
|
|
1673
|
+
*/
|
|
1674
|
+
private parseTaskAgentStatus;
|
|
1510
1675
|
/**
|
|
1511
1676
|
* Simple LLM completion - single-turn, no tools.
|
|
1512
1677
|
*
|
|
@@ -2541,6 +2706,262 @@ interface AgentRunStatusResult {
|
|
|
2541
2706
|
/** When the run completed */
|
|
2542
2707
|
completedAt?: Date;
|
|
2543
2708
|
}
|
|
2709
|
+
/**
|
|
2710
|
+
* Options for deploying a JIT Task Agent
|
|
2711
|
+
*/
|
|
2712
|
+
interface DeployTaskAgentOptions {
|
|
2713
|
+
/** Display name for the task agent */
|
|
2714
|
+
name: string;
|
|
2715
|
+
/** The task prompt - what the agent should accomplish */
|
|
2716
|
+
prompt: string;
|
|
2717
|
+
/** Custom system prompt (optional) */
|
|
2718
|
+
systemPrompt?: string;
|
|
2719
|
+
/** LLM model to use (default: claude-sonnet-4-5) */
|
|
2720
|
+
model?: string;
|
|
2721
|
+
/** MCP tools to enable (e.g., ['platform/exa-search']) */
|
|
2722
|
+
tools?: string[];
|
|
2723
|
+
/** Budget cap in USD (min: $0.01, max: $1000) */
|
|
2724
|
+
budgetUsd: number;
|
|
2725
|
+
/** Time-to-live in hours (default: 24, max: 48) */
|
|
2726
|
+
ttlHours?: number;
|
|
2727
|
+
/** Maximum iterations (default: 10, max: 50) */
|
|
2728
|
+
maxIterations?: number;
|
|
2729
|
+
/** Optional plan ID for Mission Control integration */
|
|
2730
|
+
planId?: string;
|
|
2731
|
+
/** Optional task ID for Mission Control integration */
|
|
2732
|
+
taskId?: string;
|
|
2733
|
+
/** Idempotency key to prevent duplicate deploys */
|
|
2734
|
+
idempotencyKey?: string;
|
|
2735
|
+
/** Start execution immediately (default: false) */
|
|
2736
|
+
autoRun?: boolean;
|
|
2737
|
+
}
|
|
2738
|
+
/**
|
|
2739
|
+
* Result from deploying a JIT Task Agent
|
|
2740
|
+
*/
|
|
2741
|
+
interface DeployTaskAgentResult {
|
|
2742
|
+
/** The deployed task agent instance */
|
|
2743
|
+
instance: TaskAgentInstance;
|
|
2744
|
+
/** Whether this was an idempotent return */
|
|
2745
|
+
idempotent: boolean;
|
|
2746
|
+
/** Request ID for debugging */
|
|
2747
|
+
requestId: string;
|
|
2748
|
+
}
|
|
2749
|
+
/**
|
|
2750
|
+
* A deployed JIT Task Agent instance
|
|
2751
|
+
*/
|
|
2752
|
+
interface TaskAgentInstance {
|
|
2753
|
+
/** Unique instance ID */
|
|
2754
|
+
id: string;
|
|
2755
|
+
/** Display name */
|
|
2756
|
+
name: string;
|
|
2757
|
+
/** Base endpoint URL */
|
|
2758
|
+
endpointUrl: string;
|
|
2759
|
+
/** Status check URL */
|
|
2760
|
+
statusUrl: string;
|
|
2761
|
+
/** Trigger execution URL */
|
|
2762
|
+
triggerUrl: string;
|
|
2763
|
+
/** Cancel URL */
|
|
2764
|
+
cancelUrl: string;
|
|
2765
|
+
/** Result URL */
|
|
2766
|
+
resultUrl: string;
|
|
2767
|
+
/** Current status */
|
|
2768
|
+
status: string;
|
|
2769
|
+
/** Budget in USD */
|
|
2770
|
+
budgetUsd: number;
|
|
2771
|
+
/** When the instance expires */
|
|
2772
|
+
expiresAt: Date;
|
|
2773
|
+
/** Spawn depth (for nested agents) */
|
|
2774
|
+
depth: number;
|
|
2775
|
+
/** Maximum iterations allowed */
|
|
2776
|
+
maxIterations: number;
|
|
2777
|
+
}
|
|
2778
|
+
/**
|
|
2779
|
+
* Full status of a JIT Task Agent
|
|
2780
|
+
*/
|
|
2781
|
+
interface TaskAgentStatus {
|
|
2782
|
+
/** Unique instance ID */
|
|
2783
|
+
id: string;
|
|
2784
|
+
/** Display name */
|
|
2785
|
+
name: string;
|
|
2786
|
+
/** The task prompt */
|
|
2787
|
+
prompt: string;
|
|
2788
|
+
/** LLM model */
|
|
2789
|
+
model: string;
|
|
2790
|
+
/** Enabled tools */
|
|
2791
|
+
tools: string[];
|
|
2792
|
+
/** Current status */
|
|
2793
|
+
status: string;
|
|
2794
|
+
/** Budget tracking */
|
|
2795
|
+
budget: {
|
|
2796
|
+
totalUsd: number;
|
|
2797
|
+
spentUsd: number;
|
|
2798
|
+
remainingUsd: number;
|
|
2799
|
+
};
|
|
2800
|
+
/** Iteration tracking */
|
|
2801
|
+
iterations: {
|
|
2802
|
+
current: number;
|
|
2803
|
+
max: number;
|
|
2804
|
+
};
|
|
2805
|
+
/** Usage statistics */
|
|
2806
|
+
usage: {
|
|
2807
|
+
toolCalls: number;
|
|
2808
|
+
inputTokens: number;
|
|
2809
|
+
outputTokens: number;
|
|
2810
|
+
};
|
|
2811
|
+
/** Final result (if completed) */
|
|
2812
|
+
result?: string;
|
|
2813
|
+
/** Error message (if failed) */
|
|
2814
|
+
error?: string;
|
|
2815
|
+
/** Spawn depth */
|
|
2816
|
+
depth: number;
|
|
2817
|
+
/** Plan ID (if linked) */
|
|
2818
|
+
planId?: string;
|
|
2819
|
+
/** Task ID (if linked) */
|
|
2820
|
+
taskId?: string;
|
|
2821
|
+
/** Endpoint URLs */
|
|
2822
|
+
endpoints: {
|
|
2823
|
+
statusUrl: string;
|
|
2824
|
+
triggerUrl: string;
|
|
2825
|
+
cancelUrl: string;
|
|
2826
|
+
resultUrl: string;
|
|
2827
|
+
};
|
|
2828
|
+
/** TTL in hours */
|
|
2829
|
+
ttlHours: number;
|
|
2830
|
+
/** When the instance expires */
|
|
2831
|
+
expiresAt: Date;
|
|
2832
|
+
/** When the instance was created */
|
|
2833
|
+
createdAt: Date;
|
|
2834
|
+
/** When execution started */
|
|
2835
|
+
startedAt?: Date;
|
|
2836
|
+
/** When execution completed */
|
|
2837
|
+
completedAt?: Date;
|
|
2838
|
+
}
|
|
2839
|
+
/**
|
|
2840
|
+
* Options for waiting for a task agent to complete
|
|
2841
|
+
*/
|
|
2842
|
+
interface WaitForTaskAgentOptions {
|
|
2843
|
+
/** Poll interval in milliseconds (default: 2000) */
|
|
2844
|
+
pollIntervalMs?: number;
|
|
2845
|
+
/** Timeout in milliseconds (default: 300000 = 5 minutes) */
|
|
2846
|
+
timeoutMs?: number;
|
|
2847
|
+
}
|
|
2848
|
+
/**
|
|
2849
|
+
* Final result from a completed JIT Task Agent
|
|
2850
|
+
*/
|
|
2851
|
+
interface TaskAgentResult {
|
|
2852
|
+
/** Instance ID */
|
|
2853
|
+
id: string;
|
|
2854
|
+
/** Final status */
|
|
2855
|
+
status: 'completed' | 'failed' | 'cancelled' | 'budget_exceeded' | 'expired';
|
|
2856
|
+
/** Result text (if completed) */
|
|
2857
|
+
result?: string;
|
|
2858
|
+
/** Error message (if failed) */
|
|
2859
|
+
error?: string;
|
|
2860
|
+
/** Total USD spent */
|
|
2861
|
+
spentUsd: number;
|
|
2862
|
+
/** Number of iterations executed */
|
|
2863
|
+
iterations: number;
|
|
2864
|
+
/** Number of tool calls made */
|
|
2865
|
+
toolCalls: number;
|
|
2866
|
+
/** When execution completed */
|
|
2867
|
+
completedAt?: Date;
|
|
2868
|
+
}
|
|
2869
|
+
/**
|
|
2870
|
+
* Options for listing JIT Task Agents
|
|
2871
|
+
*/
|
|
2872
|
+
interface ListTaskAgentsOptions {
|
|
2873
|
+
/** Filter by status (e.g., 'running', 'completed', 'failed') */
|
|
2874
|
+
status?: string;
|
|
2875
|
+
/** Filter by plan ID */
|
|
2876
|
+
planId?: string;
|
|
2877
|
+
/** Filter by task ID */
|
|
2878
|
+
taskId?: string;
|
|
2879
|
+
/** Maximum results to return (default: 50, max: 100) */
|
|
2880
|
+
limit?: number;
|
|
2881
|
+
/** Pagination offset (default: 0) */
|
|
2882
|
+
offset?: number;
|
|
2883
|
+
}
|
|
2884
|
+
/**
|
|
2885
|
+
* Result from listing JIT Task Agents
|
|
2886
|
+
*/
|
|
2887
|
+
interface ListTaskAgentsResult {
|
|
2888
|
+
/** Array of task agents */
|
|
2889
|
+
taskAgents: TaskAgentListItem[];
|
|
2890
|
+
/** Pagination info */
|
|
2891
|
+
pagination: {
|
|
2892
|
+
total: number;
|
|
2893
|
+
limit: number;
|
|
2894
|
+
offset: number;
|
|
2895
|
+
hasMore: boolean;
|
|
2896
|
+
};
|
|
2897
|
+
/** Summary statistics */
|
|
2898
|
+
stats: {
|
|
2899
|
+
active: number;
|
|
2900
|
+
completed: number;
|
|
2901
|
+
failed: number;
|
|
2902
|
+
totalSpentUsd: number;
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
/**
|
|
2906
|
+
* A task agent summary in a list response
|
|
2907
|
+
*/
|
|
2908
|
+
interface TaskAgentListItem {
|
|
2909
|
+
/** Unique instance ID */
|
|
2910
|
+
id: string;
|
|
2911
|
+
/** Display name */
|
|
2912
|
+
name: string;
|
|
2913
|
+
/** Task prompt (truncated to 200 chars) */
|
|
2914
|
+
prompt: string;
|
|
2915
|
+
/** LLM model */
|
|
2916
|
+
model: string;
|
|
2917
|
+
/** Enabled tools */
|
|
2918
|
+
tools: string[];
|
|
2919
|
+
/** Current status */
|
|
2920
|
+
status: string;
|
|
2921
|
+
/** Budget tracking */
|
|
2922
|
+
budget: {
|
|
2923
|
+
totalUsd: number;
|
|
2924
|
+
spentUsd: number;
|
|
2925
|
+
remainingUsd: number;
|
|
2926
|
+
};
|
|
2927
|
+
/** Iteration tracking */
|
|
2928
|
+
iterations: {
|
|
2929
|
+
current: number;
|
|
2930
|
+
max: number;
|
|
2931
|
+
};
|
|
2932
|
+
/** Usage statistics */
|
|
2933
|
+
usage: {
|
|
2934
|
+
toolCalls: number;
|
|
2935
|
+
inputTokens: number;
|
|
2936
|
+
outputTokens: number;
|
|
2937
|
+
};
|
|
2938
|
+
/** Final result (truncated to 500 chars, if completed) */
|
|
2939
|
+
result?: string;
|
|
2940
|
+
/** Error message (if failed) */
|
|
2941
|
+
error?: string;
|
|
2942
|
+
/** Spawn depth */
|
|
2943
|
+
depth: number;
|
|
2944
|
+
/** Linked plan (if any) */
|
|
2945
|
+
plan: {
|
|
2946
|
+
id: string;
|
|
2947
|
+
title: string;
|
|
2948
|
+
} | null;
|
|
2949
|
+
/** Linked task (if any) */
|
|
2950
|
+
task: {
|
|
2951
|
+
id: string;
|
|
2952
|
+
title: string;
|
|
2953
|
+
} | null;
|
|
2954
|
+
/** TTL in hours */
|
|
2955
|
+
ttlHours: number;
|
|
2956
|
+
/** When the instance expires */
|
|
2957
|
+
expiresAt: Date;
|
|
2958
|
+
/** When the instance was created */
|
|
2959
|
+
createdAt: Date;
|
|
2960
|
+
/** When execution started */
|
|
2961
|
+
startedAt?: Date;
|
|
2962
|
+
/** When execution completed */
|
|
2963
|
+
completedAt?: Date;
|
|
2964
|
+
}
|
|
2544
2965
|
|
|
2545
2966
|
/**
|
|
2546
2967
|
* MixrPay Agent SDK - Custom Errors
|