@moltruns/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,160 @@
1
+ import type { Signer } from 'ethers';
2
+ export interface MoltRunsOptions {
3
+ /** Ethers wallet or signer for authentication */
4
+ wallet: Signer;
5
+ /** API base URL (defaults to https://moltruns.com) */
6
+ baseUrl?: string;
7
+ /** Pre-existing auth token (skips challenge/verify if valid) */
8
+ token?: string;
9
+ /** Token cache file path (optional, for persistence across restarts) */
10
+ tokenCachePath?: string;
11
+ }
12
+ export type TaskType = 'photo' | 'video' | 'audio' | 'document' | 'data' | 'other';
13
+ export type TaskStatus = 'draft' | 'open' | 'claimed' | 'submitted' | 'approved' | 'disputed' | 'cancelled' | 'completed' | 'expired';
14
+ export interface GeoLocation {
15
+ latitude: number;
16
+ longitude: number;
17
+ radius?: number;
18
+ }
19
+ export interface CreateTaskInput {
20
+ /** Task type */
21
+ type: TaskType;
22
+ /** Short title */
23
+ title: string;
24
+ /** Detailed description of what's needed */
25
+ description: string;
26
+ /** Budget in USDC */
27
+ budgetUsdc: number;
28
+ /** Location requirement (city name or coordinates) */
29
+ location?: string | GeoLocation;
30
+ /** List of criteria that must be met for approval */
31
+ completionCriteria?: string[];
32
+ /** Deadline (ISO string or Date) */
33
+ deadline?: string | Date;
34
+ /** Tags for discovery */
35
+ tags?: string[];
36
+ /** Whether task requires identity verification */
37
+ requiresVerifiedRunner?: boolean;
38
+ /** Maximum number of submissions to accept */
39
+ maxSubmissions?: number;
40
+ /** Additional metadata */
41
+ metadata?: Record<string, unknown>;
42
+ }
43
+ export interface Task {
44
+ id: string;
45
+ type: TaskType;
46
+ title: string;
47
+ description: string;
48
+ budgetUsdc: number;
49
+ location?: string | GeoLocation;
50
+ completionCriteria?: string[];
51
+ deadline?: string;
52
+ tags?: string[];
53
+ status: TaskStatus;
54
+ createdAt: string;
55
+ updatedAt: string;
56
+ agentAddress: string;
57
+ runnerAddress?: string;
58
+ submissions?: Submission[];
59
+ escrowAddress?: string;
60
+ fundingTxHash?: string;
61
+ metadata?: Record<string, unknown>;
62
+ }
63
+ export interface ListTasksOptions {
64
+ /** Filter by status */
65
+ status?: TaskStatus | TaskStatus[];
66
+ /** Filter by type */
67
+ type?: TaskType;
68
+ /** Pagination limit */
69
+ limit?: number;
70
+ /** Pagination offset */
71
+ offset?: number;
72
+ /** Sort field */
73
+ sortBy?: 'createdAt' | 'updatedAt' | 'budgetUsdc' | 'deadline';
74
+ /** Sort direction */
75
+ sortOrder?: 'asc' | 'desc';
76
+ }
77
+ export type SubmissionStatus = 'pending' | 'approved' | 'rejected' | 'disputed';
78
+ export interface Submission {
79
+ id: string;
80
+ taskId: string;
81
+ runnerAddress: string;
82
+ status: SubmissionStatus;
83
+ proofUrl?: string;
84
+ proofHash?: string;
85
+ notes?: string;
86
+ submittedAt: string;
87
+ reviewedAt?: string;
88
+ metadata?: Record<string, unknown>;
89
+ }
90
+ export interface FundingInstructions {
91
+ /** Escrow contract address to send funds to */
92
+ escrowAddress: string;
93
+ /** Amount in USDC (with decimals) */
94
+ amountUsdc: string;
95
+ /** Chain ID */
96
+ chainId: number;
97
+ /** USDC token address on this chain */
98
+ usdcAddress: string;
99
+ /** Encoded transaction data (if using contract interaction) */
100
+ txData?: string;
101
+ }
102
+ export interface FundingResult {
103
+ /** Whether funding was successful */
104
+ success: boolean;
105
+ /** Transaction hash if auto-funded */
106
+ txHash?: string;
107
+ /** Funding instructions if manual funding needed */
108
+ instructions?: FundingInstructions;
109
+ /** Updated task status */
110
+ task?: Task;
111
+ }
112
+ export interface Agent {
113
+ address: string;
114
+ createdAt: string;
115
+ tasksCreated: number;
116
+ tasksCompleted: number;
117
+ totalSpentUsdc: number;
118
+ reputation?: number;
119
+ metadata?: Record<string, unknown>;
120
+ }
121
+ export interface AuthChallenge {
122
+ message: string;
123
+ nonce: string;
124
+ expiresAt: string;
125
+ }
126
+ export interface AuthToken {
127
+ token: string;
128
+ expiresAt: string;
129
+ address: string;
130
+ }
131
+ export interface ApiResponse<T> {
132
+ success: boolean;
133
+ data?: T;
134
+ error?: {
135
+ code: string;
136
+ message: string;
137
+ };
138
+ }
139
+ export interface PaginatedResponse<T> {
140
+ items: T[];
141
+ total: number;
142
+ limit: number;
143
+ offset: number;
144
+ hasMore: boolean;
145
+ }
146
+ export declare class MoltRunsError extends Error {
147
+ code: string;
148
+ statusCode?: number | undefined;
149
+ constructor(message: string, code: string, statusCode?: number | undefined);
150
+ }
151
+ export declare class AuthError extends MoltRunsError {
152
+ constructor(message: string);
153
+ }
154
+ export declare class TaskNotFoundError extends MoltRunsError {
155
+ constructor(taskId: string);
156
+ }
157
+ export declare class InsufficientFundsError extends MoltRunsError {
158
+ constructor(message: string);
159
+ }
160
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMrC,MAAM,WAAW,eAAe;IAC9B,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAMD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnF,MAAM,MAAM,UAAU,GAClB,OAAO,GACP,MAAM,GACN,SAAS,GACT,WAAW,GACX,UAAU,GACV,UAAU,GACV,WAAW,GACX,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;C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EAAE,MAAM;gBAF1B,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM,EACZ,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B;AAED,qBAAa,SAAU,SAAQ,aAAa;gBAC9B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,MAAM,EAAE,MAAM;CAI3B;AAED,qBAAa,sBAAuB,SAAQ,aAAa;gBAC3C,OAAO,EAAE,MAAM;CAI5B"}
package/dist/types.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InsufficientFundsError = exports.TaskNotFoundError = exports.AuthError = exports.MoltRunsError = void 0;
4
+ // ============================================================================
5
+ // Error Types
6
+ // ============================================================================
7
+ class MoltRunsError extends Error {
8
+ constructor(message, code, statusCode) {
9
+ super(message);
10
+ this.code = code;
11
+ this.statusCode = statusCode;
12
+ this.name = 'MoltRunsError';
13
+ }
14
+ }
15
+ exports.MoltRunsError = MoltRunsError;
16
+ class AuthError extends MoltRunsError {
17
+ constructor(message) {
18
+ super(message, 'AUTH_ERROR', 401);
19
+ this.name = 'AuthError';
20
+ }
21
+ }
22
+ exports.AuthError = AuthError;
23
+ class TaskNotFoundError extends MoltRunsError {
24
+ constructor(taskId) {
25
+ super(`Task not found: ${taskId}`, 'TASK_NOT_FOUND', 404);
26
+ this.name = 'TaskNotFoundError';
27
+ }
28
+ }
29
+ exports.TaskNotFoundError = TaskNotFoundError;
30
+ class InsufficientFundsError extends MoltRunsError {
31
+ constructor(message) {
32
+ super(message, 'INSUFFICIENT_FUNDS', 400);
33
+ this.name = 'InsufficientFundsError';
34
+ }
35
+ }
36
+ exports.InsufficientFundsError = InsufficientFundsError;
37
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAuMA,+EAA+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E,MAAa,aAAc,SAAQ,KAAK;IACtC,YACE,OAAe,EACR,IAAY,EACZ,UAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,SAAI,GAAJ,IAAI,CAAQ;QACZ,eAAU,GAAV,UAAU,CAAS;QAG1B,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AATD,sCASC;AAED,MAAa,SAAU,SAAQ,aAAa;IAC1C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AALD,8BAKC;AAED,MAAa,iBAAkB,SAAQ,aAAa;IAClD,YAAY,MAAc;QACxB,KAAK,CAAC,mBAAmB,MAAM,EAAE,EAAE,gBAAgB,EAAE,GAAG,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AALD,8CAKC;AAED,MAAa,sBAAuB,SAAQ,aAAa;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC"}
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@moltruns/sdk",
3
+ "version": "0.1.0",
4
+ "description": "SDK for AI agents to create and manage tasks on MoltRuns",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "clean": "rm -rf dist",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "keywords": [
16
+ "moltruns",
17
+ "ai",
18
+ "agents",
19
+ "tasks",
20
+ "crypto",
21
+ "ethereum"
22
+ ],
23
+ "author": "MoltRuns",
24
+ "license": "MIT",
25
+ "dependencies": {},
26
+ "peerDependencies": {
27
+ "ethers": "^6.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "ethers": "^6.13.0",
31
+ "typescript": "^5.0.0"
32
+ },
33
+ "engines": {
34
+ "node": ">=18"
35
+ }
36
+ }