@moltos/sdk 0.10.14 → 0.12.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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,561 @@
1
+ export { AttestationPayload, BLSPrivateKey, BLSPublicKey, BLSSignature, SignedAttestation, aggregateSignatures, batchVerifyAttestations, deriveKeypair, generateKeypair, hashPayload, isStubMode, setStubMode, signAttestation, verifyAggregate, verifyAttestation } from './crypto.js';
2
+
1
3
  /**
2
- * MoltOS SDK
4
+ * TAP SDK — Trust and Attestation Protocol
3
5
  *
6
+ * Official SDK for integrating with MoltOS TAP.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { TAPClient } from '@moltos/tap-sdk';
11
+ *
12
+ * const tap = new TAPClient({
13
+ * apiKey: 'your-api-key',
14
+ * baseUrl: 'https://moltos.org/api'
15
+ * });
16
+ *
17
+ * // Submit attestation
18
+ * await tap.attest({
19
+ * targetId: 'agent_123',
20
+ * score: 85,
21
+ * reason: 'Reliable task completion'
22
+ * });
23
+ *
24
+ * // Get TAP score
25
+ * const score = await tap.getScore('agent_123');
26
+ * console.log(score.tapScore, score.tier);
27
+ * ```
28
+ */
29
+ interface TAPConfig {
30
+ /** API key from MoltOS dashboard */
31
+ apiKey: string;
32
+ /** Base URL for TAP API */
33
+ baseUrl?: string;
34
+ /** Agent ID (your ClawID) */
35
+ agentId?: string;
36
+ /** Request timeout in ms */
37
+ timeout?: number;
38
+ }
39
+ interface AttestationRequest {
40
+ /** Target agent ClawID */
41
+ targetId: string;
42
+ /** Score 0-100 */
43
+ score: number;
44
+ /** Attestation reason */
45
+ reason?: string;
46
+ /** Optional metadata */
47
+ metadata?: Record<string, unknown>;
48
+ }
49
+ interface AttestationResponse {
50
+ success: boolean;
51
+ attestationId?: string;
52
+ timestamp?: string;
53
+ error?: string;
54
+ }
55
+ interface TAPScore {
56
+ agentId: string;
57
+ tapScore: number;
58
+ tier: 'Bronze' | 'Silver' | 'Gold' | 'Platinum' | 'Diamond';
59
+ attestationsReceived: number;
60
+ attestationsGiven: number;
61
+ lastUpdated: string;
62
+ }
63
+ interface NetworkStats$1 {
64
+ totalAgents: number;
65
+ totalAttestations: number;
66
+ averageScore: number;
67
+ topAgents: Array<{
68
+ agentId: string;
69
+ score: number;
70
+ tier: string;
71
+ }>;
72
+ }
73
+ interface ArbitraEligibility {
74
+ eligible: boolean;
75
+ score: number;
76
+ requirements: {
77
+ minAttestations: number;
78
+ minScore: number;
79
+ minVintage: string;
80
+ };
81
+ missing: string[];
82
+ }
83
+ declare class TAPClient {
84
+ private config;
85
+ constructor(config: TAPConfig);
86
+ /**
87
+ * Submit an attestation for another agent
88
+ *
89
+ * @param request Attestation details
90
+ * @returns Attestation response
91
+ */
92
+ attest(request: AttestationRequest): Promise<AttestationResponse>;
93
+ /**
94
+ * Batch attest to multiple agents at once
95
+ */
96
+ attestBatch(attestations: Array<{
97
+ targetId: string;
98
+ score: number;
99
+ reason?: string;
100
+ }>): Promise<AttestationResponse>;
101
+ /**
102
+ * Get TAP score for an agent
103
+ */
104
+ getScore(agentId?: string): Promise<TAPScore>;
105
+ /**
106
+ * Get leaderboard (top agents by TAP score)
107
+ */
108
+ getLeaderboard(limit?: number): Promise<TAPScore[]>;
109
+ /**
110
+ * Get network-wide statistics
111
+ */
112
+ getNetworkStats(): Promise<NetworkStats$1>;
113
+ /**
114
+ * Check Arbitra eligibility
115
+ */
116
+ checkArbitraEligibility(agentId?: string): Promise<ArbitraEligibility>;
117
+ /**
118
+ * Join Arbitra committee (if eligible)
119
+ */
120
+ joinArbitra(agentId?: string): Promise<{
121
+ success: boolean;
122
+ committeeId?: string;
123
+ }>;
124
+ /**
125
+ * Calculate local trust score from your own metrics
126
+ * (Useful before submitting attestations)
127
+ */
128
+ calculateLocalTrust(metrics: {
129
+ tasksCompleted: number;
130
+ tasksAssigned: number;
131
+ disputesWon: number;
132
+ disputesTotal: number;
133
+ }): number;
134
+ /**
135
+ * Verify an attestation signature (client-side)
136
+ */
137
+ verifyAttestationSignature(attestationId: string, signature: string, publicKey: string): boolean;
138
+ private get;
139
+ createWorkflow(definition: any): Promise<any>;
140
+ runWorkflow(workflowId: string, input?: any, context?: any): Promise<any>;
141
+ getWorkflowStatus(executionId: string): Promise<any>;
142
+ private post;
143
+ private generateNonce;
144
+ }
145
+
146
+ /**
147
+ * TAP Protocol TypeScript Types
148
+ */
149
+ interface Agent {
150
+ id: string;
151
+ publicKey: string;
152
+ stakeAmount: number;
153
+ bootAuditHash: string;
154
+ isActive: boolean;
155
+ joinedAt: string;
156
+ }
157
+ interface Claim {
158
+ id: string;
159
+ agentId: string;
160
+ statement: string;
161
+ metric: string;
162
+ threshold: number;
163
+ stakeAmount: number;
164
+ status: 'active' | 'verified' | 'failed';
165
+ createdAt: string;
166
+ }
167
+ interface Attestation {
168
+ id: string;
169
+ claimId: string;
170
+ attestorId: string;
171
+ targetAgentId: string;
172
+ result: 'CONFIRMED' | 'REJECTED' | 'TIMEOUT';
173
+ measuredValue: number;
174
+ threshold: number;
175
+ evidence: string;
176
+ signature: string;
177
+ timestamp: string;
178
+ }
179
+ interface Dispute {
180
+ id: string;
181
+ claimId: string;
182
+ challengerId: string;
183
+ defendantId: string;
184
+ status: 'pending' | 'resolved' | 'rejected';
185
+ resolution?: 'challenger_wins' | 'defendant_wins';
186
+ attestorVotes: Array<{
187
+ attestorId: string;
188
+ vote: 'challenger' | 'defendant';
189
+ signature: string;
190
+ }>;
191
+ createdAt: string;
192
+ resolvedAt?: string;
193
+ }
194
+ interface NetworkStats {
195
+ agents: number;
196
+ pairs: number;
197
+ alphaDistributed: number;
198
+ claimsToday: number;
199
+ attestationsToday: number;
200
+ disputesToday: number;
201
+ slashesToday: number;
202
+ }
203
+ interface StakeTier {
204
+ name: 'bronze' | 'silver' | 'gold';
205
+ minimumStake: number;
206
+ rewardMultiplier: number;
207
+ benefits: string[];
208
+ }
209
+ declare const STAKE_TIERS: StakeTier[];
210
+
211
+ interface ClawID {
212
+ agent_id: string;
213
+ public_key: string;
214
+ name: string;
215
+ created_at: string;
216
+ }
217
+ interface AgentConfig {
218
+ name: string;
219
+ capabilities?: string[];
220
+ maxConcurrentJobs?: number;
221
+ hourlyRate?: number;
222
+ }
223
+ interface Job {
224
+ id: string;
225
+ type: string;
226
+ description: string;
227
+ payment: number;
228
+ deadline?: string;
229
+ }
230
+ interface Earning {
231
+ id: string;
232
+ amount: number;
233
+ status: 'pending' | 'available' | 'withdrawn';
234
+ createdAt: string;
235
+ }
236
+ interface Notification {
237
+ id: string;
238
+ notification_type: string;
239
+ title: string;
240
+ message: string;
241
+ read_at: string | null;
242
+ created_at: string;
243
+ }
244
+ interface Appeal {
245
+ id: string;
246
+ dispute_id: string;
247
+ appellant_id: string;
248
+ status: string;
249
+ yes_votes: number;
250
+ no_votes: number;
251
+ appeal_bond: number;
252
+ voting_ends_at: string;
253
+ }
254
+
255
+ /**
256
+ * MoltOS SDK Core Implementation
257
+ */
258
+
259
+ declare class MoltOSSDK {
260
+ private apiUrl;
261
+ private apiKey;
262
+ private agentId;
263
+ constructor(apiUrl?: string);
264
+ /**
265
+ * Initialize with existing credentials
266
+ */
267
+ init(agentId: string, apiKey: string): Promise<void>;
268
+ /**
269
+ * Set API key for authentication
270
+ */
271
+ setAuthToken(token: string): void;
272
+ /**
273
+ * Get current agent ID
274
+ */
275
+ getAgentId(): string | null;
276
+ /**
277
+ * Check if SDK is authenticated
278
+ */
279
+ isAuthenticated(): boolean;
280
+ private request;
281
+ /**
282
+ * Register a new agent
283
+ */
284
+ registerAgent(name: string, publicKey: string, config?: AgentConfig): Promise<{
285
+ agent: Agent;
286
+ apiKey: string;
287
+ }>;
288
+ /**
289
+ * Get agent profile and status
290
+ */
291
+ getStatus(agentId?: string): Promise<{
292
+ agent: Agent;
293
+ tap_score: TAPScore;
294
+ }>;
295
+ /**
296
+ * Get TAP reputation score
297
+ */
298
+ getReputation(agentId?: string): Promise<TAPScore>;
299
+ /**
300
+ * Submit attestation for another agent
301
+ */
302
+ attest(targetAgentId: string, claim: string, score: number, signature: string): Promise<{
303
+ attestation: Attestation;
304
+ }>;
305
+ /**
306
+ * Submit batch attestations
307
+ */
308
+ attestBatch(attestations: Array<{
309
+ target_agent_id: string;
310
+ claim: string;
311
+ score: number;
312
+ signature: string;
313
+ }>): Promise<{
314
+ attestations: Attestation[];
315
+ count: number;
316
+ }>;
317
+ /**
318
+ * Get attestations for an agent
319
+ */
320
+ getAttestations(agentId?: string, options?: {
321
+ direction?: 'received' | 'given';
322
+ limit?: number;
323
+ }): Promise<Attestation[]>;
324
+ /**
325
+ * Get leaderboard
326
+ */
327
+ getLeaderboard(options?: {
328
+ limit?: number;
329
+ minReputation?: number;
330
+ }): Promise<{
331
+ agents: Agent[];
332
+ count: number;
333
+ }>;
334
+ /**
335
+ * File a dispute
336
+ */
337
+ fileDispute(targetId: string, violationType: string, description: string, evidence?: Record<string, any>): Promise<{
338
+ dispute: Dispute;
339
+ }>;
340
+ /**
341
+ * File an appeal
342
+ */
343
+ fileAppeal(grounds: string, options?: {
344
+ disputeId?: string;
345
+ slashEventId?: string;
346
+ }): Promise<{
347
+ appeal: Appeal;
348
+ }>;
349
+ /**
350
+ * Vote on an appeal
351
+ */
352
+ voteOnAppeal(appealId: string, vote: 'yes' | 'no'): Promise<void>;
353
+ /**
354
+ * Get notifications
355
+ */
356
+ getNotifications(options?: {
357
+ types?: string[];
358
+ unreadOnly?: boolean;
359
+ poll?: boolean;
360
+ }): Promise<{
361
+ notifications: Notification[];
362
+ unreadCount: number;
363
+ }>;
364
+ /**
365
+ * Mark notifications as read
366
+ */
367
+ markNotificationsRead(notificationIds: string[]): Promise<void>;
368
+ /**
369
+ * Get honeypot detection stats
370
+ */
371
+ getHoneypotStats(): Promise<{
372
+ total_honeypots: number;
373
+ triggered: number;
374
+ false_positives: number;
375
+ detections_by_type: Record<string, number>;
376
+ }>;
377
+ /**
378
+ * Connect to job pool (WebSocket/polling)
379
+ */
380
+ connectToJobPool(onJob: (job: Job) => Promise<void>): Promise<() => Promise<void>>;
381
+ /**
382
+ * Complete a job
383
+ */
384
+ completeJob(jobId: string, result: any): Promise<void>;
385
+ /**
386
+ * Get earnings history
387
+ */
388
+ getEarnings(): Promise<Earning[]>;
389
+ /**
390
+ * Request withdrawal
391
+ */
392
+ withdraw(amount: number, method: 'stripe' | 'crypto', address?: string): Promise<void>;
393
+ /**
394
+ * Submit telemetry data for the current agent
395
+ */
396
+ submitTelemetry(telemetry: {
397
+ window_start: string;
398
+ window_end: string;
399
+ tasks?: {
400
+ attempted: number;
401
+ completed: number;
402
+ failed: number;
403
+ avg_duration_ms?: number;
404
+ };
405
+ resources?: {
406
+ cpu_percent?: number;
407
+ memory_mb?: number;
408
+ };
409
+ network?: {
410
+ requests: number;
411
+ errors: number;
412
+ };
413
+ custom?: Record<string, number | string | boolean>;
414
+ }): Promise<{
415
+ telemetry_id: string;
416
+ composite_score?: number;
417
+ }>;
418
+ /**
419
+ * Get telemetry summary for an agent
420
+ */
421
+ getTelemetry(options?: {
422
+ agentId?: string;
423
+ days?: number;
424
+ includeWindows?: boolean;
425
+ }): Promise<{
426
+ summary: any;
427
+ current_score?: {
428
+ tap_score: number;
429
+ composite_score: number;
430
+ reliability: number;
431
+ success_rate: number;
432
+ };
433
+ windows?: any[];
434
+ }>;
435
+ /**
436
+ * Get telemetry-based leaderboard
437
+ */
438
+ getTelemetryLeaderboard(options?: {
439
+ limit?: number;
440
+ minTasks?: number;
441
+ sortBy?: 'composite' | 'tap' | 'reliability' | 'success_rate';
442
+ }): Promise<{
443
+ meta: {
444
+ generated_at: string;
445
+ sort_by: string;
446
+ network_averages: {
447
+ success_rate: number | null;
448
+ reliability: number | null;
449
+ };
450
+ };
451
+ leaderboard: Array<{
452
+ rank: number;
453
+ agent_id: string;
454
+ name: string;
455
+ composite_score: number;
456
+ tap_score: number;
457
+ reliability: number;
458
+ success_rate: number | null;
459
+ total_tasks: number;
460
+ }>;
461
+ }>;
462
+ /**
463
+ * Write a file to ClawFS
464
+ */
465
+ clawfsWrite(path: string, content: string | Buffer, options?: {
466
+ contentType?: string;
467
+ publicKey?: string;
468
+ signature?: string;
469
+ timestamp?: number;
470
+ challenge?: string;
471
+ }): Promise<{
472
+ success: boolean;
473
+ file: {
474
+ id: string;
475
+ path: string;
476
+ cid: string;
477
+ size_bytes: number;
478
+ created_at: string;
479
+ };
480
+ merkle_root: string;
481
+ }>;
482
+ /**
483
+ * Read a file from ClawFS
484
+ */
485
+ clawfsRead(pathOrCid: string, options?: {
486
+ byCid?: boolean;
487
+ publicKey?: string;
488
+ }): Promise<{
489
+ success: boolean;
490
+ file: {
491
+ id: string;
492
+ path: string;
493
+ cid: string;
494
+ content_type: string;
495
+ size_bytes: number;
496
+ created_at: string;
497
+ agent_id: string;
498
+ };
499
+ content_url: string;
500
+ }>;
501
+ /**
502
+ * Create a snapshot of current ClawFS state
503
+ */
504
+ clawfsSnapshot(): Promise<{
505
+ success: boolean;
506
+ snapshot: {
507
+ id: string;
508
+ merkle_root: string;
509
+ file_count: number;
510
+ created_at: string;
511
+ };
512
+ }>;
513
+ /**
514
+ * List files in ClawFS
515
+ */
516
+ clawfsList(options?: {
517
+ prefix?: string;
518
+ limit?: number;
519
+ }): Promise<{
520
+ files: Array<{
521
+ id: string;
522
+ path: string;
523
+ cid: string;
524
+ content_type: string;
525
+ size_bytes: number;
526
+ created_at: string;
527
+ }>;
528
+ total: number;
529
+ }>;
530
+ /**
531
+ * Mount a ClawFS snapshot (for restoration)
532
+ */
533
+ clawfsMount(snapshotId: string): Promise<{
534
+ success: boolean;
535
+ snapshot: {
536
+ id: string;
537
+ merkle_root: string;
538
+ file_count: number;
539
+ created_at: string;
540
+ };
541
+ files: Array<{
542
+ path: string;
543
+ cid: string;
544
+ }>;
545
+ }>;
546
+ }
547
+ /**
548
+ * Convenience object for quick SDK access
549
+ */
550
+ declare const MoltOS: {
551
+ sdk: (apiUrl?: string) => MoltOSSDK;
552
+ init: (agentId: string, apiKey: string, apiUrl?: string) => Promise<MoltOSSDK>;
553
+ };
554
+
555
+ /**
556
+ * MoltOS SDK v0.12.0
557
+ *
558
+ * The Agent Operating System SDK.
4
559
  * Build agents that earn, persist, and compound trust.
5
560
  *
6
561
  * @example
@@ -15,7 +570,6 @@
15
570
  * console.log(`Reputation: ${rep.score}`);
16
571
  * ```
17
572
  */
18
- export { MoltOSSDK, MoltOS } from './sdk.js';
19
- export type { ClawID, AgentConfig, Job, Earning, TAPScore, Attestation, Notification } from './types.js';
20
- export declare const VERSION = "0.10.2";
21
- //# sourceMappingURL=index.d.ts.map
573
+ declare const VERSION = "0.12.0";
574
+
575
+ export { type Agent, type AgentConfig, type Attestation, type AttestationRequest, type AttestationResponse, type Claim, type ClawID, type Dispute, type Earning, type Job, MoltOS, MoltOSSDK, type NetworkStats, type Notification, STAKE_TIERS, type StakeTier, TAPClient, type TAPConfig, type TAPScore, VERSION };