@moltos/sdk 0.7.2 → 0.10.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.
Files changed (114) hide show
  1. package/README.md +48 -146
  2. package/dist/cli.d.ts +11 -14
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +504 -487
  5. package/dist/cli.js.map +1 -1
  6. package/dist/index.d.ts +18 -12
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +18 -37
  9. package/dist/index.js.map +1 -1
  10. package/dist/react.d.ts +138 -0
  11. package/dist/react.d.ts.map +1 -0
  12. package/dist/react.js +335 -0
  13. package/dist/react.js.map +1 -0
  14. package/dist/sdk.d.ts +217 -0
  15. package/dist/sdk.d.ts.map +1 -0
  16. package/dist/sdk.js +325 -0
  17. package/dist/sdk.js.map +1 -0
  18. package/dist/types.d.ts +91 -0
  19. package/dist/types.d.ts.map +1 -0
  20. package/dist/types.js +5 -0
  21. package/dist/types.js.map +1 -0
  22. package/package.json +32 -53
  23. package/dist/adapters/langchain.d.ts +0 -84
  24. package/dist/adapters/langchain.d.ts.map +0 -1
  25. package/dist/adapters/langchain.js +0 -145
  26. package/dist/adapters/langchain.js.map +0 -1
  27. package/dist/adapters/openclaw.d.ts +0 -83
  28. package/dist/adapters/openclaw.d.ts.map +0 -1
  29. package/dist/adapters/openclaw.js +0 -207
  30. package/dist/adapters/openclaw.js.map +0 -1
  31. package/dist/clawfs.d.ts +0 -95
  32. package/dist/clawfs.d.ts.map +0 -1
  33. package/dist/clawfs.js +0 -546
  34. package/dist/clawfs.js.map +0 -1
  35. package/dist/commands/agent.d.ts +0 -15
  36. package/dist/commands/agent.d.ts.map +0 -1
  37. package/dist/commands/agent.js +0 -327
  38. package/dist/commands/agent.js.map +0 -1
  39. package/dist/commands/cloud.d.ts +0 -37
  40. package/dist/commands/cloud.d.ts.map +0 -1
  41. package/dist/commands/cloud.js +0 -390
  42. package/dist/commands/cloud.js.map +0 -1
  43. package/dist/commands/complete.d.ts +0 -11
  44. package/dist/commands/complete.d.ts.map +0 -1
  45. package/dist/commands/complete.js +0 -154
  46. package/dist/commands/complete.js.map +0 -1
  47. package/dist/commands/fs.d.ts +0 -5
  48. package/dist/commands/fs.d.ts.map +0 -1
  49. package/dist/commands/fs.js +0 -139
  50. package/dist/commands/fs.js.map +0 -1
  51. package/dist/commands/hire.d.ts +0 -29
  52. package/dist/commands/hire.d.ts.map +0 -1
  53. package/dist/commands/hire.js +0 -411
  54. package/dist/commands/hire.js.map +0 -1
  55. package/dist/commands/init.d.ts +0 -23
  56. package/dist/commands/init.d.ts.map +0 -1
  57. package/dist/commands/init.js +0 -488
  58. package/dist/commands/init.js.map +0 -1
  59. package/dist/commands/marketplace.d.ts +0 -14
  60. package/dist/commands/marketplace.d.ts.map +0 -1
  61. package/dist/commands/marketplace.js +0 -183
  62. package/dist/commands/marketplace.js.map +0 -1
  63. package/dist/commands/register.d.ts +0 -8
  64. package/dist/commands/register.d.ts.map +0 -1
  65. package/dist/commands/register.js +0 -152
  66. package/dist/commands/register.js.map +0 -1
  67. package/dist/commands/status.d.ts +0 -17
  68. package/dist/commands/status.d.ts.map +0 -1
  69. package/dist/commands/status.js +0 -388
  70. package/dist/commands/status.js.map +0 -1
  71. package/dist/commands/tap.d.ts +0 -5
  72. package/dist/commands/tap.d.ts.map +0 -1
  73. package/dist/commands/tap.js +0 -31
  74. package/dist/commands/tap.js.map +0 -1
  75. package/dist/lib/api.d.ts +0 -32
  76. package/dist/lib/api.d.ts.map +0 -1
  77. package/dist/lib/api.js +0 -80
  78. package/dist/lib/api.js.map +0 -1
  79. package/dist/lib/arbitra.d.ts +0 -302
  80. package/dist/lib/arbitra.d.ts.map +0 -1
  81. package/dist/lib/arbitra.js +0 -486
  82. package/dist/lib/arbitra.js.map +0 -1
  83. package/dist/lib/clawfs.d.ts +0 -277
  84. package/dist/lib/clawfs.d.ts.map +0 -1
  85. package/dist/lib/clawfs.js +0 -628
  86. package/dist/lib/clawfs.js.map +0 -1
  87. package/dist/lib/clawid.d.ts +0 -189
  88. package/dist/lib/clawid.d.ts.map +0 -1
  89. package/dist/lib/clawid.js +0 -455
  90. package/dist/lib/clawid.js.map +0 -1
  91. package/dist/lib/config.d.ts +0 -23
  92. package/dist/lib/config.d.ts.map +0 -1
  93. package/dist/lib/config.js +0 -29
  94. package/dist/lib/config.js.map +0 -1
  95. package/dist/lib/forge.d.ts +0 -139
  96. package/dist/lib/forge.d.ts.map +0 -1
  97. package/dist/lib/forge.js +0 -461
  98. package/dist/lib/forge.js.map +0 -1
  99. package/dist/lib/scheduler.d.ts +0 -138
  100. package/dist/lib/scheduler.d.ts.map +0 -1
  101. package/dist/lib/scheduler.js +0 -597
  102. package/dist/lib/scheduler.js.map +0 -1
  103. package/dist/lib/supabase.d.ts +0 -41
  104. package/dist/lib/supabase.d.ts.map +0 -1
  105. package/dist/lib/supabase.js +0 -125
  106. package/dist/lib/supabase.js.map +0 -1
  107. package/dist/lib/tap.d.ts +0 -208
  108. package/dist/lib/tap.d.ts.map +0 -1
  109. package/dist/lib/tap.js +0 -549
  110. package/dist/lib/tap.js.map +0 -1
  111. package/dist/tap.d.ts +0 -66
  112. package/dist/tap.d.ts.map +0 -1
  113. package/dist/tap.js +0 -302
  114. package/dist/tap.js.map +0 -1
package/dist/lib/tap.js DELETED
@@ -1,549 +0,0 @@
1
- "use strict";
2
- /**
3
- * TAP (Trust Attestation Protocol) - EigenTrust-style reputation system
4
- *
5
- * Every action produces a signed attestation.
6
- * Attestations are weighted by sender's reputation and chained into a Merkle tree.
7
- * Reputation compounds forever through transitive trust calculations.
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || (function () {
26
- var ownKeys = function(o) {
27
- ownKeys = Object.getOwnPropertyNames || function (o) {
28
- var ar = [];
29
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
- return ar;
31
- };
32
- return ownKeys(o);
33
- };
34
- return function (mod) {
35
- if (mod && mod.__esModule) return mod;
36
- var result = {};
37
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
- __setModuleDefault(result, mod);
39
- return result;
40
- };
41
- })();
42
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.TAPClient = void 0;
44
- exports.generateKeypair = generateKeypair;
45
- exports.verifyBatch = verifyBatch;
46
- const ed25519_1 = require("@noble/ed25519");
47
- const sha256_1 = require("@noble/hashes/sha256");
48
- const utils_1 = require("@noble/hashes/utils");
49
- // ============================================================================
50
- // Utility Functions
51
- // ============================================================================
52
- /**
53
- * Serialize data for hashing (deterministic)
54
- */
55
- function serializeForHash(data) {
56
- return JSON.stringify(data, Object.keys(data).sort());
57
- }
58
- /**
59
- * Compute SHA256 hash of data
60
- */
61
- function computeHash(data) {
62
- const serialized = serializeForHash(data);
63
- return (0, utils_1.bytesToHex)((0, sha256_1.sha256)(new TextEncoder().encode(serialized)));
64
- }
65
- /**
66
- * Compute Merkle root from a list of hashes
67
- */
68
- function computeMerkleRoot(hashes) {
69
- if (hashes.length === 0) {
70
- return (0, utils_1.bytesToHex)((0, sha256_1.sha256)(new Uint8Array(0)));
71
- }
72
- if (hashes.length === 1) {
73
- return hashes[0];
74
- }
75
- const nextLevel = [];
76
- for (let i = 0; i < hashes.length; i += 2) {
77
- const left = hashes[i];
78
- const right = hashes[i + 1] || left; // Duplicate last if odd
79
- const combined = left + right;
80
- nextLevel.push((0, utils_1.bytesToHex)((0, sha256_1.sha256)(new TextEncoder().encode(combined))));
81
- }
82
- return computeMerkleRoot(nextLevel);
83
- }
84
- // ============================================================================
85
- // TAPClient Class
86
- // ============================================================================
87
- /**
88
- * TAP Client for creating and verifying attestations,
89
- * computing reputation scores, and managing the trust graph.
90
- */
91
- class TAPClient {
92
- privateKey;
93
- publicKey;
94
- agentId;
95
- config;
96
- // In-memory storage (in production, use persistent storage)
97
- attestations = new Map();
98
- reputationScores = new Map();
99
- trustGraph;
100
- attestationChain = []; // Ordered list of attestation IDs
101
- /**
102
- * Create a new TAP client
103
- * @param privateKeyHex - Ed25519 private key as hex string
104
- * @param agentId - Unique identifier for this agent
105
- * @param config - Optional configuration
106
- */
107
- constructor(privateKeyHex, agentId, config = {}) {
108
- this.privateKey = (0, utils_1.hexToBytes)(privateKeyHex);
109
- this.publicKey = (0, ed25519_1.getPublicKey)(this.privateKey);
110
- this.agentId = agentId;
111
- // Default configuration
112
- this.config = {
113
- dampingFactor: config.dampingFactor ?? 0.85,
114
- iterations: config.iterations ?? 100,
115
- convergenceThreshold: config.convergenceThreshold ?? 1e-10,
116
- preTrustedAgents: config.preTrustedAgents ?? [],
117
- preTrustedWeight: config.preTrustedWeight ?? 0.1,
118
- };
119
- // Initialize trust graph
120
- this.trustGraph = {
121
- agents: new Set([agentId]),
122
- edges: [],
123
- adjacency: new Map(),
124
- reverseAdjacency: new Map(),
125
- merkleRoot: (0, utils_1.bytesToHex)((0, sha256_1.sha256)(new Uint8Array(0))),
126
- sequence: 0,
127
- };
128
- // Initialize adjacency lists for this agent
129
- this.trustGraph.adjacency.set(agentId, []);
130
- this.trustGraph.reverseAdjacency.set(agentId, []);
131
- // Initialize own reputation
132
- this.reputationScores.set(agentId, {
133
- agentId,
134
- globalScore: this.config.preTrustedAgents.includes(agentId)
135
- ? this.config.preTrustedWeight
136
- : 0.5, // Neutral starting score
137
- directTrust: 0,
138
- transitiveTrust: 0,
139
- attestationCount: 0,
140
- givenCount: 0,
141
- lastUpdated: Date.now(),
142
- });
143
- }
144
- // ============================================================================
145
- // Core Attestation Methods
146
- // ============================================================================
147
- /**
148
- * Create a signed attestation for an action
149
- * @param action - The action data to attest (must be JSON-serializable)
150
- * @param targetAgentId - The agent being attested about (optional, defaults to self)
151
- * @param options - Additional options for attestation creation
152
- * @returns The signed attestation
153
- */
154
- async attest(action, targetAgentId, options = {}) {
155
- const timestamp = Date.now();
156
- const target = targetAgentId || this.agentId;
157
- // Get previous hash for chaining
158
- const previousHash = options.previousHash ??
159
- (this.attestationChain.length > 0
160
- ? computeHash(this.attestations.get(this.attestationChain[this.attestationChain.length - 1]))
161
- : null);
162
- // Compute new Merkle root including this attestation
163
- const allHashes = this.attestationChain.map(id => computeHash(this.attestations.get(id)));
164
- // Create attestation data (without signature for now)
165
- const attestationData = {
166
- agentId: this.agentId,
167
- publicKey: (0, utils_1.bytesToHex)(this.publicKey),
168
- action: {
169
- ...action,
170
- ...(options.metadata || {}),
171
- _targetAgent: target,
172
- },
173
- timestamp,
174
- previousHash,
175
- };
176
- // Compute attestation ID
177
- const id = computeHash(attestationData);
178
- // Compute new Merkle root
179
- const newMerkleRoot = computeMerkleRoot([...allHashes, id]);
180
- // Create full attestation with ID and merkle root
181
- const attestationWithId = {
182
- ...attestationData,
183
- id,
184
- merkleRoot: newMerkleRoot,
185
- signature: '', // Placeholder
186
- };
187
- // Sign the attestation
188
- const message = new TextEncoder().encode(serializeForHash(attestationWithId));
189
- const signature = await (0, ed25519_1.sign)(message, this.privateKey);
190
- const signatureHex = (0, utils_1.bytesToHex)(signature);
191
- // Final attestation
192
- const attestation = {
193
- ...attestationWithId,
194
- signature: signatureHex,
195
- };
196
- // Store attestation
197
- this.attestations.set(id, attestation);
198
- this.attestationChain.push(id);
199
- // Update trust graph
200
- this.updateTrustGraph(attestation, target);
201
- // Update Merkle root
202
- this.trustGraph.merkleRoot = newMerkleRoot;
203
- this.trustGraph.sequence++;
204
- // Update reputation (reputation compounds!)
205
- await this.updateReputation(target);
206
- return attestation;
207
- }
208
- /**
209
- * Verify an attestation's signature
210
- * @param attestation - The attestation to verify
211
- * @returns True if signature is valid
212
- */
213
- async verify(attestation) {
214
- try {
215
- // Reconstruct the signed data (without signature)
216
- const { signature, ...attestationData } = attestation;
217
- const message = new TextEncoder().encode(serializeForHash(attestationData));
218
- // Verify signature
219
- const publicKey = (0, utils_1.hexToBytes)(attestation.publicKey);
220
- const signatureBytes = (0, utils_1.hexToBytes)(signature);
221
- return await (0, ed25519_1.verify)(signatureBytes, message, publicKey);
222
- }
223
- catch {
224
- return false;
225
- }
226
- }
227
- // ============================================================================
228
- // Reputation Methods
229
- // ============================================================================
230
- /**
231
- * Get the current reputation score for an agent
232
- * @param agentId - The agent to get reputation for (defaults to self)
233
- * @returns The reputation score
234
- */
235
- getReputation(agentId) {
236
- const targetId = agentId || this.agentId;
237
- // Return existing score or create default
238
- const existing = this.reputationScores.get(targetId);
239
- if (existing) {
240
- return { ...existing };
241
- }
242
- // Default score for unknown agents
243
- return {
244
- agentId: targetId,
245
- globalScore: 0.5, // Neutral
246
- directTrust: 0,
247
- transitiveTrust: 0,
248
- attestationCount: 0,
249
- givenCount: 0,
250
- lastUpdated: Date.now(),
251
- };
252
- }
253
- /**
254
- * Compute EigenTrust-style transitive trust scores for all agents
255
- * Uses power iteration to converge on global trust scores
256
- * @returns Map of agent IDs to their trust scores
257
- */
258
- computeTrustScore() {
259
- const agents = Array.from(this.trustGraph.agents);
260
- const n = agents.length;
261
- if (n === 0) {
262
- return new Map();
263
- }
264
- // Build normalized trust matrix
265
- const trustMatrix = new Map();
266
- for (const agent of agents) {
267
- const outgoing = this.trustGraph.adjacency.get(agent) || [];
268
- const totalWeight = outgoing.reduce((sum, e) => sum + e.weight, 0);
269
- const normalizedWeights = new Map();
270
- if (totalWeight > 0) {
271
- for (const edge of outgoing) {
272
- normalizedWeights.set(edge.to, edge.weight / totalWeight);
273
- }
274
- }
275
- // Self-loop if no outgoing edges (prevents dead ends)
276
- if (normalizedWeights.size === 0) {
277
- normalizedWeights.set(agent, 1.0);
278
- }
279
- trustMatrix.set(agent, normalizedWeights);
280
- }
281
- // Initialize trust vector with pre-trusted agents or uniform distribution
282
- let trustVector = new Map();
283
- const preTrusted = this.config.preTrustedAgents.filter(a => agents.includes(a));
284
- if (preTrusted.length > 0) {
285
- const preTrustedWeight = this.config.preTrustedWeight / preTrusted.length;
286
- for (const agent of agents) {
287
- trustVector.set(agent, preTrusted.includes(agent) ? preTrustedWeight : 0);
288
- }
289
- }
290
- else {
291
- const uniformWeight = 1.0 / n;
292
- for (const agent of agents) {
293
- trustVector.set(agent, uniformWeight);
294
- }
295
- }
296
- // Power iteration
297
- const dampingFactor = this.config.dampingFactor;
298
- const teleportProb = preTrusted.length > 0
299
- ? (1 - dampingFactor) / preTrusted.length
300
- : (1 - dampingFactor) / n;
301
- for (let iter = 0; iter < this.config.iterations; iter++) {
302
- const newTrustVector = new Map();
303
- let maxDiff = 0;
304
- for (const agent of agents) {
305
- let score = 0;
306
- // Sum incoming trust
307
- for (const other of agents) {
308
- const weights = trustMatrix.get(other);
309
- const weightToThis = weights.get(agent) || 0;
310
- const otherTrust = trustVector.get(other);
311
- score += dampingFactor * weightToThis * otherTrust;
312
- }
313
- // Teleport / pre-trusted jump
314
- if (preTrusted.length > 0) {
315
- if (preTrusted.includes(agent)) {
316
- score += (1 - dampingFactor) / preTrusted.length;
317
- }
318
- }
319
- else {
320
- score += (1 - dampingFactor) / n;
321
- }
322
- newTrustVector.set(agent, score);
323
- const diff = Math.abs(score - (trustVector.get(agent) || 0));
324
- maxDiff = Math.max(maxDiff, diff);
325
- }
326
- trustVector = newTrustVector;
327
- // Check convergence
328
- if (maxDiff < this.config.convergenceThreshold) {
329
- break;
330
- }
331
- }
332
- // Normalize to ensure scores sum to 1
333
- const totalTrust = Array.from(trustVector.values()).reduce((a, b) => a + b, 0);
334
- if (totalTrust > 0) {
335
- for (const [agent, score] of trustVector) {
336
- trustVector.set(agent, score / totalTrust);
337
- }
338
- }
339
- return trustVector;
340
- }
341
- // ============================================================================
342
- // Trust Graph Management
343
- // ============================================================================
344
- /**
345
- * Add an external attestation to the trust graph
346
- * @param attestation - The attestation to add
347
- * @param targetAgentId - The target agent (if different from action target)
348
- * @returns True if successfully added
349
- */
350
- async addAttestation(attestation, targetAgentId) {
351
- // Verify first
352
- const isValid = await this.verify(attestation);
353
- if (!isValid) {
354
- return false;
355
- }
356
- // Check for duplicates
357
- if (this.attestations.has(attestation.id)) {
358
- return true; // Already have it
359
- }
360
- // Store attestation
361
- this.attestations.set(attestation.id, attestation);
362
- this.attestationChain.push(attestation.id);
363
- // Determine target
364
- const target = targetAgentId ||
365
- attestation.action._targetAgent ||
366
- attestation.agentId;
367
- // Update trust graph
368
- this.updateTrustGraph(attestation, target);
369
- // Update Merkle root
370
- const allHashes = this.attestationChain.map(id => computeHash(this.attestations.get(id)));
371
- this.trustGraph.merkleRoot = computeMerkleRoot(allHashes);
372
- this.trustGraph.sequence++;
373
- // Update reputation
374
- await this.updateReputation(target);
375
- return true;
376
- }
377
- /**
378
- * Get the current trust graph
379
- */
380
- getTrustGraph() {
381
- return {
382
- agents: new Set(this.trustGraph.agents),
383
- edges: [...this.trustGraph.edges],
384
- adjacency: new Map(this.trustGraph.adjacency),
385
- reverseAdjacency: new Map(this.trustGraph.reverseAdjacency),
386
- merkleRoot: this.trustGraph.merkleRoot,
387
- sequence: this.trustGraph.sequence,
388
- };
389
- }
390
- /**
391
- * Get all attestations for an agent (received)
392
- * @param agentId - The agent to get attestations for
393
- */
394
- getAttestationsForAgent(agentId) {
395
- const incoming = this.trustGraph.reverseAdjacency.get(agentId) || [];
396
- return incoming
397
- .map(edge => this.attestations.get(edge.attestationId))
398
- .filter((a) => a !== undefined);
399
- }
400
- /**
401
- * Get all attestations by an agent (given)
402
- * @param agentId - The agent who gave attestations
403
- */
404
- getAttestationsByAgent(agentId) {
405
- const outgoing = this.trustGraph.adjacency.get(agentId) || [];
406
- return outgoing
407
- .map(edge => this.attestations.get(edge.attestationId))
408
- .filter((a) => a !== undefined);
409
- }
410
- /**
411
- * Get the current Merkle root
412
- */
413
- getMerkleRoot() {
414
- return this.trustGraph.merkleRoot;
415
- }
416
- /**
417
- * Get this client's public key
418
- */
419
- getPublicKey() {
420
- return (0, utils_1.bytesToHex)(this.publicKey);
421
- }
422
- /**
423
- * Get this client's agent ID
424
- */
425
- getAgentId() {
426
- return this.agentId;
427
- }
428
- // ============================================================================
429
- // Private Helper Methods
430
- // ============================================================================
431
- /**
432
- * Update the trust graph with a new attestation
433
- */
434
- updateTrustGraph(attestation, target) {
435
- const source = attestation.agentId;
436
- // Add agents to set
437
- this.trustGraph.agents.add(source);
438
- this.trustGraph.agents.add(target);
439
- // Ensure adjacency lists exist
440
- if (!this.trustGraph.adjacency.has(source)) {
441
- this.trustGraph.adjacency.set(source, []);
442
- }
443
- if (!this.trustGraph.adjacency.has(target)) {
444
- this.trustGraph.adjacency.set(target, []);
445
- }
446
- if (!this.trustGraph.reverseAdjacency.has(source)) {
447
- this.trustGraph.reverseAdjacency.set(source, []);
448
- }
449
- if (!this.trustGraph.reverseAdjacency.has(target)) {
450
- this.trustGraph.reverseAdjacency.set(target, []);
451
- }
452
- // Get source reputation for weighting
453
- const sourceRep = this.reputationScores.get(source);
454
- const weight = sourceRep?.globalScore ?? 0.5;
455
- // Create trust edge
456
- const edge = {
457
- from: source,
458
- to: target,
459
- weight,
460
- timestamp: attestation.timestamp,
461
- attestationId: attestation.id,
462
- };
463
- // Add to edges list
464
- this.trustGraph.edges.push(edge);
465
- // Add to adjacency lists
466
- this.trustGraph.adjacency.get(source).push(edge);
467
- this.trustGraph.reverseAdjacency.get(target).push(edge);
468
- }
469
- /**
470
- * Update reputation scores after a new attestation
471
- * Reputation compounds forever through transitive trust
472
- */
473
- async updateReputation(targetAgentId) {
474
- // Compute global trust scores using EigenTrust
475
- const globalScores = this.computeTrustScore();
476
- // Update all agent scores
477
- for (const agentId of this.trustGraph.agents) {
478
- const incoming = this.trustGraph.reverseAdjacency.get(agentId) || [];
479
- const outgoing = this.trustGraph.adjacency.get(agentId) || [];
480
- const directTrust = incoming.reduce((sum, e) => sum + e.weight, 0);
481
- const globalScore = globalScores.get(agentId) || 0.5;
482
- // Transitive trust is the difference between global and direct
483
- const transitiveTrust = Math.max(0, globalScore - directTrust / (incoming.length || 1));
484
- this.reputationScores.set(agentId, {
485
- agentId,
486
- globalScore,
487
- directTrust,
488
- transitiveTrust,
489
- attestationCount: incoming.length,
490
- givenCount: outgoing.length,
491
- lastUpdated: Date.now(),
492
- });
493
- }
494
- // Ensure target agent has a score even if no attestations yet
495
- if (!this.reputationScores.has(targetAgentId)) {
496
- this.reputationScores.set(targetAgentId, {
497
- agentId: targetAgentId,
498
- globalScore: globalScores.get(targetAgentId) || 0.5,
499
- directTrust: 0,
500
- transitiveTrust: 0,
501
- attestationCount: 0,
502
- givenCount: 0,
503
- lastUpdated: Date.now(),
504
- });
505
- }
506
- }
507
- }
508
- exports.TAPClient = TAPClient;
509
- // ============================================================================
510
- // Export additional utilities
511
- // ============================================================================
512
- /**
513
- * Generate a new Ed25519 keypair for TAP
514
- * @returns Object with privateKey and publicKey as hex strings
515
- */
516
- async function generateKeypair() {
517
- const privateKey = ed25519.utils.randomPrivateKey();
518
- const publicKey = await (0, ed25519_1.getPublicKey)(privateKey);
519
- return {
520
- privateKey: (0, utils_1.bytesToHex)(privateKey),
521
- publicKey: (0, utils_1.bytesToHex)(publicKey),
522
- };
523
- }
524
- /**
525
- * Utility to verify a batch of attestations
526
- * @param attestations - Array of attestations to verify
527
- * @returns Map of attestation IDs to verification results
528
- */
529
- async function verifyBatch(attestations) {
530
- const results = new Map();
531
- await Promise.all(attestations.map(async (att) => {
532
- const { signature, ...attestationData } = att;
533
- const message = new TextEncoder().encode(serializeForHash(attestationData));
534
- try {
535
- const publicKey = (0, utils_1.hexToBytes)(att.publicKey);
536
- const signatureBytes = (0, utils_1.hexToBytes)(signature);
537
- const valid = await (0, ed25519_1.verify)(signatureBytes, message, publicKey);
538
- results.set(att.id, valid);
539
- }
540
- catch {
541
- results.set(att.id, false);
542
- }
543
- }));
544
- return results;
545
- }
546
- // Import ed25519 utils for key generation
547
- const ed25519 = __importStar(require("@noble/ed25519"));
548
- exports.default = TAPClient;
549
- //# sourceMappingURL=tap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tap.js","sourceRoot":"","sources":["../../src/lib/tap.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqqBH,0CAQC;AAOD,kCAsBC;AAxsBD,4CAA4D;AAC5D,iDAA8C;AAC9C,+CAA6D;AA4G7D,+EAA+E;AAC/E,oBAAoB;AACpB,+EAA+E;AAE/E;;GAEG;AACH,SAAS,gBAAgB,CAAC,IAAa;IACrC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,IAAc,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,IAAa;IAChC,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAC1C,OAAO,IAAA,kBAAU,EAAC,IAAA,eAAM,EAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED;;GAEG;AACH,SAAS,iBAAiB,CAAC,MAAgB;IACzC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,IAAA,kBAAU,EAAC,IAAA,eAAM,EAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,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C/B,YAA2B;IAE3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE3C,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,EAAE,SAAS,EAAE,GAAG,eAAe,EAAE,GAAG,GAAG,CAAC;QAC9C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC,CAAC;QAE5E,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC5C,MAAM,cAAc,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,KAAK,GAAG,MAAM,IAAA,gBAAM,EAAC,cAAc,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;YAC/D,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,0CAA0C;AAC1C,wDAA0C;AAE1C,kBAAe,SAAS,CAAC"}
package/dist/tap.d.ts DELETED
@@ -1,66 +0,0 @@
1
- /**
2
- * TAP - Trust and Attestation Protocol (Real Implementation)
3
- *
4
- * Local reputation system that works now.
5
- * Network sync will be added in v0.6.
6
- */
7
- interface Attestation {
8
- id: string;
9
- jobId: string;
10
- clientClawId: string;
11
- agentClawId: string;
12
- rating: number;
13
- outcome: 'success' | 'failure' | 'disputed';
14
- timestamp: string;
15
- signature?: string;
16
- }
17
- interface ReputationScore {
18
- clawId: string;
19
- score: number;
20
- attestationsReceived: number;
21
- attestationsGiven: number;
22
- jobsCompleted: number;
23
- jobsFailed: number;
24
- disputesWon: number;
25
- disputesLost: number;
26
- lastUpdated: string;
27
- tier: 'genesis' | 'verified' | 'established' | 'trusted';
28
- }
29
- /**
30
- * Initialize TAP cache for a project
31
- */
32
- export declare function initializeTAP(baseDir: string): void;
33
- /**
34
- * Initialize reputation for a new ClawID
35
- */
36
- export declare function initializeReputation(baseDir: string, clawId: string): ReputationScore;
37
- /**
38
- * Get reputation for a ClawID
39
- */
40
- export declare function getReputation(baseDir: string, clawId: string): ReputationScore | null;
41
- /**
42
- * Record an attestation (client rates agent after job)
43
- */
44
- export declare function recordAttestation(baseDir: string, attestation: Omit<Attestation, 'id' | 'timestamp'>): Attestation;
45
- /**
46
- * List all attestations for an agent
47
- */
48
- export declare function getAgentAttestations(baseDir: string, agentClawId: string): Attestation[];
49
- /**
50
- * Get top agents by reputation
51
- */
52
- export declare function getTopAgents(baseDir: string, limit?: number): ReputationScore[];
53
- /**
54
- * Format score for display (1000 -> "10.00")
55
- */
56
- export declare function formatScore(score: number): string;
57
- /**
58
- * Get tier badge color
59
- */
60
- export declare function getTierColor(tier: ReputationScore['tier']): string;
61
- /**
62
- * CLI command handler for TAP operations
63
- */
64
- export declare function tapCommand(action: 'status' | 'attest' | 'verify', options: any): Promise<void>;
65
- export {};
66
- //# sourceMappingURL=tap.d.ts.map
package/dist/tap.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../src/tap.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,UAAU,WAAW;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,UAAU,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CAC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