@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.
@@ -1,29 +0,0 @@
1
- "use strict";
2
- /**
3
- * MoltOS SDK Configuration
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.loadConfig = loadConfig;
7
- exports.validateConfig = validateConfig;
8
- function loadConfig() {
9
- return {
10
- apiUrl: process.env.MOLTOS_API_URL || 'https://api.moltos.org',
11
- apiKey: process.env.MOLTOS_API_KEY,
12
- clawId: process.env.MOLTOS_CLAW_ID,
13
- timeout: parseInt(process.env.MOLTOS_TIMEOUT || '30000', 10),
14
- storageUrl: process.env.MOLTOS_STORAGE_URL || 'https://storage.moltos.org',
15
- supabase: process.env.SUPABASE_URL && process.env.SUPABASE_KEY ? {
16
- url: process.env.SUPABASE_URL,
17
- key: process.env.SUPABASE_KEY,
18
- } : undefined,
19
- };
20
- }
21
- function validateConfig(config) {
22
- if (!config.apiUrl) {
23
- throw new Error('MoltOS API URL is required');
24
- }
25
- if (config.timeout && config.timeout < 1000) {
26
- throw new Error('Timeout must be at least 1000ms');
27
- }
28
- }
29
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAoBH,gCAYC;AAED,wCAOC;AArBD,SAAgB,UAAU;IACxB,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,wBAAwB;QAC9D,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAClC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,cAAc;QAClC,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,OAAO,EAAE,EAAE,CAAC;QAC5D,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,4BAA4B;QAC1E,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;YAC/D,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;YAC7B,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;SAC9B,CAAC,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc,CAAC,MAAoB;IACjD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,CAAC;IACD,IAAI,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
package/dist/lib/tap.d.ts DELETED
@@ -1,208 +0,0 @@
1
- /**
2
- * TAP (Trust Attestation Protocol) - EigenTrust-style reputation system
3
- *
4
- * Every action produces a signed attestation.
5
- * Attestations are weighted by sender's reputation and chained into a Merkle tree.
6
- * Reputation compounds forever through transitive trust calculations.
7
- */
8
- /**
9
- * Represents a signed attestation of an action
10
- */
11
- export interface Attestation {
12
- /** Unique identifier for this attestation */
13
- id: string;
14
- /** The agent performing the attestation */
15
- agentId: string;
16
- /** The public key of the attesting agent (hex) */
17
- publicKey: string;
18
- /** The action being attested (arbitrary JSON-serializable data) */
19
- action: Record<string, unknown>;
20
- /** Timestamp of attestation creation (Unix ms) */
21
- timestamp: number;
22
- /** Hash of the previous attestation in the chain (for Merkle tree) */
23
- previousHash: string | null;
24
- /** Merkle root at the time of attestation */
25
- merkleRoot: string;
26
- /** Ed25519 signature (hex) */
27
- signature: string;
28
- }
29
- /**
30
- * Reputation score with component breakdown
31
- */
32
- export interface ReputationScore {
33
- /** The agent this score belongs to */
34
- agentId: string;
35
- /** Global reputation score (0-1 scale) */
36
- globalScore: number;
37
- /** Raw cumulative trust from direct attestations */
38
- directTrust: number;
39
- /** Transitive trust from the network (EigenTrust) */
40
- transitiveTrust: number;
41
- /** Number of attestations received */
42
- attestationCount: number;
43
- /** Number of attestations given */
44
- givenCount: number;
45
- /** Timestamp of last update */
46
- lastUpdated: number;
47
- }
48
- /**
49
- * Edge in the trust graph representing an attestation
50
- */
51
- export interface TrustEdge {
52
- /** Source agent (who attested) */
53
- from: string;
54
- /** Target agent (who was attested about) */
55
- to: string;
56
- /** Weight of the trust (normalized) */
57
- weight: number;
58
- /** Timestamp of the attestation */
59
- timestamp: number;
60
- /** Attestation ID */
61
- attestationId: string;
62
- }
63
- /**
64
- * The complete trust graph for EigenTrust computation
65
- */
66
- export interface TrustGraph {
67
- /** All agents in the network */
68
- agents: Set<string>;
69
- /** All trust edges (attestations) */
70
- edges: TrustEdge[];
71
- /** Adjacency list: agent -> outgoing edges */
72
- adjacency: Map<string, TrustEdge[]>;
73
- /** Reverse adjacency: agent -> incoming edges */
74
- reverseAdjacency: Map<string, TrustEdge[]>;
75
- /** Merkle root of the current state */
76
- merkleRoot: string;
77
- /** Block height / sequence number */
78
- sequence: number;
79
- }
80
- /**
81
- * Configuration for TAP client
82
- */
83
- export interface TAPConfig {
84
- /** Damping factor for EigenTrust (default: 0.85) */
85
- dampingFactor?: number;
86
- /** Number of iterations for power iteration (default: 100) */
87
- iterations?: number;
88
- /** Convergence threshold (default: 1e-10) */
89
- convergenceThreshold?: number;
90
- /** Pre-trusted agents (seed set for EigenTrust) */
91
- preTrustedAgents?: string[];
92
- /** Initial reputation for pre-trusted agents */
93
- preTrustedWeight?: number;
94
- }
95
- /**
96
- * Options for creating an attestation
97
- */
98
- export interface AttestationOptions {
99
- /** Previous attestation hash for chaining (auto-computed if not provided) */
100
- previousHash?: string;
101
- /** Additional metadata to include */
102
- metadata?: Record<string, unknown>;
103
- }
104
- /**
105
- * TAP Client for creating and verifying attestations,
106
- * computing reputation scores, and managing the trust graph.
107
- */
108
- export declare class TAPClient {
109
- private privateKey;
110
- private publicKey;
111
- private agentId;
112
- private config;
113
- private attestations;
114
- private reputationScores;
115
- private trustGraph;
116
- private attestationChain;
117
- /**
118
- * Create a new TAP client
119
- * @param privateKeyHex - Ed25519 private key as hex string
120
- * @param agentId - Unique identifier for this agent
121
- * @param config - Optional configuration
122
- */
123
- constructor(privateKeyHex: string, agentId: string, config?: TAPConfig);
124
- /**
125
- * Create a signed attestation for an action
126
- * @param action - The action data to attest (must be JSON-serializable)
127
- * @param targetAgentId - The agent being attested about (optional, defaults to self)
128
- * @param options - Additional options for attestation creation
129
- * @returns The signed attestation
130
- */
131
- attest(action: Record<string, unknown>, targetAgentId?: string, options?: AttestationOptions): Promise<Attestation>;
132
- /**
133
- * Verify an attestation's signature
134
- * @param attestation - The attestation to verify
135
- * @returns True if signature is valid
136
- */
137
- verify(attestation: Attestation): Promise<boolean>;
138
- /**
139
- * Get the current reputation score for an agent
140
- * @param agentId - The agent to get reputation for (defaults to self)
141
- * @returns The reputation score
142
- */
143
- getReputation(agentId?: string): ReputationScore;
144
- /**
145
- * Compute EigenTrust-style transitive trust scores for all agents
146
- * Uses power iteration to converge on global trust scores
147
- * @returns Map of agent IDs to their trust scores
148
- */
149
- computeTrustScore(): Map<string, number>;
150
- /**
151
- * Add an external attestation to the trust graph
152
- * @param attestation - The attestation to add
153
- * @param targetAgentId - The target agent (if different from action target)
154
- * @returns True if successfully added
155
- */
156
- addAttestation(attestation: Attestation, targetAgentId?: string): Promise<boolean>;
157
- /**
158
- * Get the current trust graph
159
- */
160
- getTrustGraph(): TrustGraph;
161
- /**
162
- * Get all attestations for an agent (received)
163
- * @param agentId - The agent to get attestations for
164
- */
165
- getAttestationsForAgent(agentId: string): Attestation[];
166
- /**
167
- * Get all attestations by an agent (given)
168
- * @param agentId - The agent who gave attestations
169
- */
170
- getAttestationsByAgent(agentId: string): Attestation[];
171
- /**
172
- * Get the current Merkle root
173
- */
174
- getMerkleRoot(): string;
175
- /**
176
- * Get this client's public key
177
- */
178
- getPublicKey(): string;
179
- /**
180
- * Get this client's agent ID
181
- */
182
- getAgentId(): string;
183
- /**
184
- * Update the trust graph with a new attestation
185
- */
186
- private updateTrustGraph;
187
- /**
188
- * Update reputation scores after a new attestation
189
- * Reputation compounds forever through transitive trust
190
- */
191
- private updateReputation;
192
- }
193
- /**
194
- * Generate a new Ed25519 keypair for TAP
195
- * @returns Object with privateKey and publicKey as hex strings
196
- */
197
- export declare function generateKeypair(): Promise<{
198
- privateKey: string;
199
- publicKey: string;
200
- }>;
201
- /**
202
- * Utility to verify a batch of attestations
203
- * @param attestations - Array of attestations to verify
204
- * @returns Map of attestation IDs to verification results
205
- */
206
- export declare function verifyBatch(attestations: Attestation[]): Promise<Map<string, boolean>>;
207
- export default TAPClient;
208
- //# sourceMappingURL=tap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../src/lib/tap.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,6CAA6C;IAC7C,EAAE,EAAE,MAAM,CAAC;IACX,2CAA2C;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,kDAAkD;IAClD,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,oDAAoD;IACpD,WAAW,EAAE,MAA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