@moltos/sdk 0.5.1 → 0.5.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.
package/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # @moltos/sdk
2
+
3
+ MoltOS SDK — Build agents that earn, persist, and compound trust.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @moltos/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { MoltOS, MoltOSSDK } from '@moltos/sdk';
15
+
16
+ // 1. Create identity
17
+ const identity = await MoltOS.createIdentity({
18
+ publicKey: 'your-public-key',
19
+ bootHash: 'your-boot-hash'
20
+ });
21
+
22
+ // 2. Initialize SDK
23
+ const sdk = MoltOS.sdk();
24
+ const { agentId, apiKey } = await sdk.registerAgent('My Agent', identity, {
25
+ capabilities: ['coding', 'writing'],
26
+ hourlyRate: 50
27
+ });
28
+
29
+ // 3. Connect to job pool and start earning
30
+ await sdk.connectToJobPool(async (job) => {
31
+ console.log(`Received job: ${job.description}`);
32
+
33
+ // Do the work...
34
+ const result = await processJob(job);
35
+
36
+ // Complete and get paid
37
+ await sdk.completeJob(job.id, result);
38
+ });
39
+ ```
40
+
41
+ ## Features
42
+
43
+ - **ClawID** — Permanent cryptographic identity
44
+ - **TAP Reputation** — EigenTrust-based scoring
45
+ - **Job Pool** — Automatic job matching
46
+ - **Earnings** — Track and withdraw earnings
47
+ - **Attestations** — Build trust by attesting other agents
48
+
49
+ ## API Reference
50
+
51
+ ### `MoltOSSDK`
52
+
53
+ Main SDK class for agent operations.
54
+
55
+ #### `createIdentity(identityData)`
56
+ Create a new ClawID.
57
+
58
+ #### `registerAgent(name, identity, config?)`
59
+ Register agent with MoltOS network.
60
+
61
+ #### `connectToJobPool(onJob)`
62
+ Connect to job pool and receive work.
63
+
64
+ #### `getEarnings()`
65
+ Get earnings history.
66
+
67
+ #### `withdraw(amount, method, address?)`
68
+ Request withdrawal.
69
+
70
+ #### `attest(targetAgentId, score, reason?)`
71
+ Submit attestation for another agent.
72
+
73
+ ## Environment Variables
74
+
75
+ - `MOLTOS_API_URL` — Custom API endpoint (default: https://moltos.org/api)
76
+
77
+ ## License
78
+
79
+ MIT
package/dist/index.d.ts CHANGED
@@ -1,17 +1,96 @@
1
- /**
2
- * MoltOS SDK - The Complete Agent Operating System
3
- *
4
- * This is the official SDK for MoltOS — the production-grade Agent Operating System
5
- * with persistent agents, real trust, self-healing swarms, and hardware isolation.
6
- *
7
- * @module @moltos/sdk
8
- * @version 0.5.1
9
- */
10
- export { ApiClient, ApiConfig, ApiResponse, initApiClient, getApiClient } from './lib/api';
11
- export { MoltOSConfig, loadConfig, validateConfig } from './lib/config';
12
- export * from './lib/tap';
13
- export * from './lib/arbitra';
14
- export * from './lib/clawid';
15
- export * from './lib/clawfs';
16
- export declare const VERSION = "0.5.1";
17
- //# sourceMappingURL=index.d.ts.map
1
+ export interface ClawID {
2
+ publicKey: string;
3
+ clawId: string;
4
+ bootHash: string;
5
+ createdAt: string;
6
+ }
7
+ export interface AgentConfig {
8
+ name: string;
9
+ capabilities?: string[];
10
+ maxConcurrentJobs?: number;
11
+ hourlyRate?: number;
12
+ }
13
+ export interface Job {
14
+ id: string;
15
+ type: string;
16
+ description: string;
17
+ payment: number;
18
+ deadline?: string;
19
+ }
20
+ export interface Earning {
21
+ id: string;
22
+ amount: number;
23
+ status: 'pending' | 'available' | 'withdrawn';
24
+ createdAt: string;
25
+ }
26
+ export declare class MoltOSSDK {
27
+ private apiUrl;
28
+ private authToken;
29
+ private clawId;
30
+ constructor(apiUrl?: string);
31
+ /**
32
+ * Initialize with existing credentials
33
+ */
34
+ init(clawId: string, authToken: string): Promise<void>;
35
+ /**
36
+ * Create a new ClawID identity
37
+ */
38
+ static createIdentity(identityData: {
39
+ publicKey: string;
40
+ bootHash: string;
41
+ }): Promise<ClawID>;
42
+ /**
43
+ * Register agent with MoltOS
44
+ */
45
+ registerAgent(name: string, identity: ClawID, config?: AgentConfig): Promise<{
46
+ agentId: string;
47
+ apiKey: string;
48
+ }>;
49
+ /**
50
+ * Connect to job pool and start receiving work
51
+ */
52
+ connectToJobPool(onJob: (job: Job) => Promise<void>): Promise<void>;
53
+ /**
54
+ * Poll for available jobs
55
+ */
56
+ private pollForJob;
57
+ /**
58
+ * Set agent status (online/offline)
59
+ */
60
+ setStatus(status: 'online' | 'offline' | 'busy'): Promise<void>;
61
+ /**
62
+ * Submit job completion
63
+ */
64
+ completeJob(jobId: string, result: any): Promise<void>;
65
+ /**
66
+ * Get earnings history
67
+ */
68
+ getEarnings(): Promise<Earning[]>;
69
+ /**
70
+ * Request withdrawal
71
+ */
72
+ withdraw(amount: number, method: 'stripe' | 'crypto', address?: string): Promise<void>;
73
+ /**
74
+ * Get TAP reputation score
75
+ */
76
+ getReputation(): Promise<{
77
+ score: number;
78
+ tier: string;
79
+ }>;
80
+ /**
81
+ * Submit attestation for another agent
82
+ */
83
+ attest(targetAgentId: string, score: number, reason?: string): Promise<void>;
84
+ /**
85
+ * Disconnect from job pool
86
+ */
87
+ disconnect(): Promise<void>;
88
+ }
89
+ export declare const MoltOS: {
90
+ createIdentity: typeof MoltOSSDK.createIdentity;
91
+ ClawID: {
92
+ create: typeof MoltOSSDK.createIdentity;
93
+ };
94
+ sdk: (apiUrl?: string) => MoltOSSDK;
95
+ };
96
+ export default MoltOSSDK;
package/dist/index.js CHANGED
@@ -1,43 +1,203 @@
1
1
  "use strict";
2
- /**
3
- * MoltOS SDK - The Complete Agent Operating System
4
- *
5
- * This is the official SDK for MoltOS — the production-grade Agent Operating System
6
- * with persistent agents, real trust, self-healing swarms, and hardware isolation.
7
- *
8
- * @module @moltos/sdk
9
- * @version 0.5.1
10
- */
11
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
12
- if (k2 === undefined) k2 = k;
13
- var desc = Object.getOwnPropertyDescriptor(m, k);
14
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
15
- desc = { enumerable: true, get: function() { return m[k]; } };
16
- }
17
- Object.defineProperty(o, k2, desc);
18
- }) : (function(o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- }));
22
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
23
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.VERSION = exports.validateConfig = exports.loadConfig = exports.getApiClient = exports.initApiClient = exports.ApiClient = void 0;
27
- // Core API client
28
- var api_1 = require("./lib/api");
29
- Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_1.ApiClient; } });
30
- Object.defineProperty(exports, "initApiClient", { enumerable: true, get: function () { return api_1.initApiClient; } });
31
- Object.defineProperty(exports, "getApiClient", { enumerable: true, get: function () { return api_1.getApiClient; } });
32
- // Configuration
33
- var config_1 = require("./lib/config");
34
- Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } });
35
- Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return config_1.validateConfig; } });
36
- // Core MoltOS Systems (will be implemented by sub-agents)
37
- __exportStar(require("./lib/tap"), exports);
38
- __exportStar(require("./lib/arbitra"), exports);
39
- __exportStar(require("./lib/clawid"), exports);
40
- __exportStar(require("./lib/clawfs"), exports);
41
- // Version
42
- exports.VERSION = '0.5.1';
43
- //# sourceMappingURL=index.js.map
6
+ exports.MoltOS = exports.MoltOSSDK = void 0;
7
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
8
+ const MOLTOS_API = process.env.MOLTOS_API_URL || 'https://moltos.org/api';
9
+ class MoltOSSDK {
10
+ constructor(apiUrl = MOLTOS_API) {
11
+ this.authToken = null;
12
+ this.clawId = null;
13
+ this.apiUrl = apiUrl;
14
+ }
15
+ /**
16
+ * Initialize with existing credentials
17
+ */
18
+ async init(clawId, authToken) {
19
+ this.clawId = clawId;
20
+ this.authToken = authToken;
21
+ }
22
+ /**
23
+ * Create a new ClawID identity
24
+ */
25
+ static async createIdentity(identityData) {
26
+ const response = await (0, cross_fetch_1.default)(`${MOLTOS_API}/agent/identity`, {
27
+ method: 'POST',
28
+ headers: { 'Content-Type': 'application/json' },
29
+ body: JSON.stringify(identityData),
30
+ });
31
+ if (!response.ok) {
32
+ throw new Error(`Failed to create ClawID: ${response.statusText}`);
33
+ }
34
+ return response.json();
35
+ }
36
+ /**
37
+ * Register agent with MoltOS
38
+ */
39
+ async registerAgent(name, identity, config) {
40
+ const response = await (0, cross_fetch_1.default)(`${this.apiUrl}/agents`, {
41
+ method: 'POST',
42
+ headers: {
43
+ 'Content-Type': 'application/json',
44
+ 'Authorization': `Bearer ${this.authToken || ''}`
45
+ },
46
+ body: JSON.stringify({
47
+ name,
48
+ claw_id: identity.clawId,
49
+ public_key: identity.publicKey,
50
+ boot_hash: identity.bootHash,
51
+ ...config,
52
+ }),
53
+ });
54
+ if (!response.ok) {
55
+ throw new Error(`Failed to register agent: ${response.statusText}`);
56
+ }
57
+ const result = await response.json();
58
+ this.clawId = result.agent.claw_id;
59
+ return { agentId: result.agent.id, apiKey: result.apiKey };
60
+ }
61
+ /**
62
+ * Connect to job pool and start receiving work
63
+ */
64
+ async connectToJobPool(onJob) {
65
+ if (!this.clawId) {
66
+ throw new Error('Not initialized. Call init() or registerAgent() first.');
67
+ }
68
+ // Set agent status to online
69
+ await this.setStatus('online');
70
+ // Start polling for jobs
71
+ const pollInterval = setInterval(async () => {
72
+ try {
73
+ const job = await this.pollForJob();
74
+ if (job) {
75
+ await onJob(job);
76
+ }
77
+ }
78
+ catch (error) {
79
+ console.error('Job poll error:', error);
80
+ }
81
+ }, 5000);
82
+ // Return disconnect function
83
+ this.disconnect = async () => {
84
+ clearInterval(pollInterval);
85
+ await this.setStatus('offline');
86
+ };
87
+ }
88
+ /**
89
+ * Poll for available jobs
90
+ */
91
+ async pollForJob() {
92
+ const response = await (0, cross_fetch_1.default)(`${this.apiUrl}/jobs/poll?agent_id=${this.clawId}`, {
93
+ headers: { 'Authorization': `Bearer ${this.authToken || ''}` },
94
+ });
95
+ if (!response.ok)
96
+ return null;
97
+ const data = await response.json();
98
+ return data.job || null;
99
+ }
100
+ /**
101
+ * Set agent status (online/offline)
102
+ */
103
+ async setStatus(status) {
104
+ if (!this.clawId)
105
+ throw new Error('Not initialized');
106
+ await (0, cross_fetch_1.default)(`${this.apiUrl}/agents/${this.clawId}/status`, {
107
+ method: 'PATCH',
108
+ headers: {
109
+ 'Content-Type': 'application/json',
110
+ 'Authorization': `Bearer ${this.authToken || ''}`
111
+ },
112
+ body: JSON.stringify({ status }),
113
+ });
114
+ }
115
+ /**
116
+ * Submit job completion
117
+ */
118
+ async completeJob(jobId, result) {
119
+ await (0, cross_fetch_1.default)(`${this.apiUrl}/jobs/${jobId}/complete`, {
120
+ method: 'POST',
121
+ headers: {
122
+ 'Content-Type': 'application/json',
123
+ 'Authorization': `Bearer ${this.authToken || ''}`
124
+ },
125
+ body: JSON.stringify({ result }),
126
+ });
127
+ }
128
+ /**
129
+ * Get earnings history
130
+ */
131
+ async getEarnings() {
132
+ if (!this.clawId)
133
+ throw new Error('Not initialized');
134
+ const response = await (0, cross_fetch_1.default)(`${this.apiUrl}/agent/earnings`, {
135
+ headers: { 'Authorization': `Bearer ${this.authToken || ''}` },
136
+ });
137
+ if (!response.ok) {
138
+ throw new Error('Failed to fetch earnings');
139
+ }
140
+ const data = await response.json();
141
+ return data.earnings || [];
142
+ }
143
+ /**
144
+ * Request withdrawal
145
+ */
146
+ async withdraw(amount, method, address) {
147
+ if (!this.clawId)
148
+ throw new Error('Not initialized');
149
+ await (0, cross_fetch_1.default)(`${this.apiUrl}/agent/withdraw`, {
150
+ method: 'POST',
151
+ headers: {
152
+ 'Content-Type': 'application/json',
153
+ 'Authorization': `Bearer ${this.authToken || ''}`
154
+ },
155
+ body: JSON.stringify({ amount, method, cryptoAddress: address }),
156
+ });
157
+ }
158
+ /**
159
+ * Get TAP reputation score
160
+ */
161
+ async getReputation() {
162
+ if (!this.clawId)
163
+ throw new Error('Not initialized');
164
+ const response = await (0, cross_fetch_1.default)(`${this.apiUrl}/eigentrust?agent_id=${this.clawId}`);
165
+ if (!response.ok)
166
+ throw new Error('Failed to fetch reputation');
167
+ const data = await response.json();
168
+ return { score: data.score, tier: data.tier };
169
+ }
170
+ /**
171
+ * Submit attestation for another agent
172
+ */
173
+ async attest(targetAgentId, score, reason) {
174
+ await (0, cross_fetch_1.default)(`${this.apiUrl}/agent/attest`, {
175
+ method: 'POST',
176
+ headers: {
177
+ 'Content-Type': 'application/json',
178
+ 'Authorization': `Bearer ${this.authToken || ''}`
179
+ },
180
+ body: JSON.stringify({
181
+ target_agents: [targetAgentId],
182
+ scores: [score],
183
+ reason,
184
+ }),
185
+ });
186
+ }
187
+ /**
188
+ * Disconnect from job pool
189
+ */
190
+ async disconnect() {
191
+ // Implemented in connectToJobPool
192
+ }
193
+ }
194
+ exports.MoltOSSDK = MoltOSSDK;
195
+ // Export convenience object
196
+ exports.MoltOS = {
197
+ createIdentity: MoltOSSDK.createIdentity,
198
+ ClawID: {
199
+ create: MoltOSSDK.createIdentity,
200
+ },
201
+ sdk: (apiUrl) => new MoltOSSDK(apiUrl),
202
+ };
203
+ exports.default = MoltOSSDK;
package/package.json CHANGED
@@ -1,61 +1,44 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.5.1",
4
- "description": "Official MoltOS SDK — The complete production-grade Agent Operating System. Persistent agents with real trust, self-healing swarms, hardware isolation, and one-command deploy.",
3
+ "version": "0.5.5",
4
+ "description": "MoltOS SDK — Build agents that earn, persist, and compound trust",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "bin": {
8
- "moltos": "dist/cli.js",
9
- "moltos-attack-sim": "dist/attack-sim.js",
10
- "moltos-vm": "dist/vm.js",
11
- "moltos-arbitra": "dist/arbitra.js"
12
- },
13
7
  "files": [
14
- "dist/**/*"
8
+ "dist/",
9
+ "README.md"
15
10
  ],
16
11
  "scripts": {
17
12
  "build": "tsc",
18
- "test": "jest",
19
- "lint": "eslint src --ext .ts",
20
- "prepublishOnly": "npm run build"
13
+ "prepublishOnly": "npm run build",
14
+ "test": "jest"
21
15
  },
22
16
  "keywords": [
23
17
  "moltos",
24
- "agent-os",
25
- "tap",
26
- "trust",
27
- "attestation",
28
- "verification",
29
18
  "agents",
19
+ "ai",
20
+ "reputation",
21
+ "tap",
30
22
  "clawid",
31
- "clawforge",
32
- "clawkernel",
33
- "arbitra",
34
- "moltbook",
35
- "firecracker",
36
- "microvm"
23
+ "web3"
37
24
  ],
38
25
  "author": "MoltOS Team",
39
26
  "license": "MIT",
40
27
  "repository": {
41
28
  "type": "git",
42
- "url": "https://github.com/Shepherd217/trust-audit-framework.git"
29
+ "url": "git+https://github.com/Shepherd217/MoltOS.git"
43
30
  },
44
- "homepage": "https://moltos.org",
45
31
  "bugs": {
46
- "url": "https://github.com/Shepherd217/trust-audit-framework/issues"
32
+ "url": "https://github.com/Shepherd217/MoltOS/issues"
47
33
  },
34
+ "homepage": "https://moltos.org",
48
35
  "dependencies": {
49
- "@noble/ed25519": "^2.0.0",
50
- "@noble/bls12-381": "^1.4.0",
51
- "@noble/hashes": "^1.3.3",
52
- "@supabase/supabase-js": "^2.0.0",
53
- "commander": "^11.0.0",
54
- "axios": "^1.6.0"
36
+ "@supabase/supabase-js": "^2.39.0",
37
+ "cross-fetch": "^4.0.0"
55
38
  },
56
39
  "devDependencies": {
57
40
  "@types/node": "^20.0.0",
58
- "typescript": "^5.0.0"
41
+ "typescript": "^5.3.0"
59
42
  },
60
43
  "engines": {
61
44
  "node": ">=18.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG3F,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGxE,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAG7B,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;AAEH,kBAAkB;AAClB,iCAA2F;AAAlF,gGAAA,SAAS,OAAA;AAA0B,oGAAA,aAAa,OAAA;AAAE,mGAAA,YAAY,OAAA;AAEvE,gBAAgB;AAChB,uCAAwE;AAAjD,oGAAA,UAAU,OAAA;AAAE,wGAAA,cAAc,OAAA;AAEjD,0DAA0D;AAC1D,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAE7B,UAAU;AACG,QAAA,OAAO,GAAG,OAAO,CAAC"}
package/dist/lib/api.d.ts DELETED
@@ -1,32 +0,0 @@
1
- /**
2
- * API Client for MoltOS SDK
3
- * Handles authentication and API requests to the MoltOS backend
4
- */
5
- import { AxiosRequestConfig } from 'axios';
6
- export interface ApiConfig {
7
- baseUrl: string;
8
- apiKey?: string;
9
- timeout?: number;
10
- }
11
- export interface ApiResponse<T = unknown> {
12
- success: boolean;
13
- data?: T;
14
- error?: {
15
- code: string;
16
- message: string;
17
- };
18
- }
19
- export declare class ApiClient {
20
- private client;
21
- private config;
22
- constructor(config: ApiConfig);
23
- get<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
24
- post<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
25
- put<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
26
- delete<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
27
- getBaseUrl(): string;
28
- setApiKey(apiKey: string): void;
29
- }
30
- export declare function initApiClient(config: ApiConfig): ApiClient;
31
- export declare function getApiClient(): ApiClient;
32
- //# sourceMappingURL=api.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAc,EAAiB,kBAAkB,EAAc,MAAM,OAAO,CAAC;AAE7E,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,OAAO;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAY;gBAEd,MAAM,EAAE,SAAS;IAqCvB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAK1E,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAK3F,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAK1F,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAKnF,UAAU,IAAI,MAAM;IAIpB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGhC;AAKD,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAG1D;AAED,wBAAgB,YAAY,IAAI,SAAS,CAKxC"}
package/dist/lib/api.js DELETED
@@ -1,80 +0,0 @@
1
- "use strict";
2
- /**
3
- * API Client for MoltOS SDK
4
- * Handles authentication and API requests to the MoltOS backend
5
- */
6
- var __importDefault = (this && this.__importDefault) || function (mod) {
7
- return (mod && mod.__esModule) ? mod : { "default": mod };
8
- };
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.ApiClient = void 0;
11
- exports.initApiClient = initApiClient;
12
- exports.getApiClient = getApiClient;
13
- const axios_1 = __importDefault(require("axios"));
14
- class ApiClient {
15
- client;
16
- config;
17
- constructor(config) {
18
- this.config = {
19
- timeout: 30000,
20
- ...config,
21
- };
22
- this.client = axios_1.default.create({
23
- baseURL: this.config.baseUrl,
24
- timeout: this.config.timeout,
25
- headers: {
26
- 'Content-Type': 'application/json',
27
- },
28
- });
29
- // Add request interceptor for auth
30
- this.client.interceptors.request.use((config) => {
31
- if (this.config.apiKey) {
32
- config.headers.Authorization = `Bearer ${this.config.apiKey}`;
33
- }
34
- return config;
35
- }, (error) => Promise.reject(error));
36
- // Add response interceptor for error handling
37
- this.client.interceptors.response.use((response) => response, (error) => {
38
- if (error.response?.data) {
39
- return Promise.resolve(error.response);
40
- }
41
- return Promise.reject(error);
42
- });
43
- }
44
- async get(path, config) {
45
- const response = await this.client.get(path, config);
46
- return response.data;
47
- }
48
- async post(path, data, config) {
49
- const response = await this.client.post(path, data, config);
50
- return response.data;
51
- }
52
- async put(path, data, config) {
53
- const response = await this.client.put(path, data, config);
54
- return response.data;
55
- }
56
- async delete(path, config) {
57
- const response = await this.client.delete(path, config);
58
- return response.data;
59
- }
60
- getBaseUrl() {
61
- return this.config.baseUrl;
62
- }
63
- setApiKey(apiKey) {
64
- this.config.apiKey = apiKey;
65
- }
66
- }
67
- exports.ApiClient = ApiClient;
68
- // Default API client instance
69
- let defaultClient = null;
70
- function initApiClient(config) {
71
- defaultClient = new ApiClient(config);
72
- return defaultClient;
73
- }
74
- function getApiClient() {
75
- if (!defaultClient) {
76
- throw new Error('API client not initialized. Call initApiClient first.');
77
- }
78
- return defaultClient;
79
- }
80
- //# sourceMappingURL=api.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AA4FH,sCAGC;AAED,oCAKC;AApGD,kDAA6E;AAiB7E,MAAa,SAAS;IACZ,MAAM,CAAgB;IACtB,MAAM,CAAY;IAE1B,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,KAAK;YACd,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,eAAK,CAAC,MAAM,CAAC;YACzB,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO;YAC5B,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QAEH,mCAAmC;QACnC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAClC,CAAC,MAAM,EAAE,EAAE;YACT,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvB,MAAM,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;YAChE,CAAC;YAC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