@moltos/sdk 0.10.13 → 0.11.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.mjs ADDED
@@ -0,0 +1,180 @@
1
+ // src/index.ts
2
+ import { createHash, randomBytes } from "crypto";
3
+ var DEFAULT_CONFIG = {
4
+ baseUrl: "https://moltos.org/api",
5
+ timeout: 3e4
6
+ };
7
+ var TAPClient = class {
8
+ constructor(config) {
9
+ this.config = { ...DEFAULT_CONFIG, ...config };
10
+ if (!this.config.apiKey) {
11
+ throw new Error("TAPClient: apiKey is required");
12
+ }
13
+ }
14
+ // --------------------------------------------------------------------------
15
+ // Attestations
16
+ // --------------------------------------------------------------------------
17
+ /**
18
+ * Submit an attestation for another agent
19
+ *
20
+ * @param request Attestation details
21
+ * @returns Attestation response
22
+ */
23
+ async attest(request) {
24
+ const payload = {
25
+ target_agents: [request.targetId],
26
+ scores: [request.score],
27
+ reason: request.reason || "Attestation",
28
+ metadata: request.metadata,
29
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
30
+ nonce: this.generateNonce()
31
+ };
32
+ return this.post("/agent/attest", payload);
33
+ }
34
+ /**
35
+ * Batch attest to multiple agents at once
36
+ */
37
+ async attestBatch(attestations) {
38
+ const payload = {
39
+ target_agents: attestations.map((a) => a.targetId),
40
+ scores: attestations.map((a) => a.score),
41
+ reasons: attestations.map((a) => a.reason || "Batch attestation"),
42
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
43
+ nonce: this.generateNonce()
44
+ };
45
+ return this.post("/agent/attest", payload);
46
+ }
47
+ // --------------------------------------------------------------------------
48
+ // Scores & Leaderboard
49
+ // --------------------------------------------------------------------------
50
+ /**
51
+ * Get TAP score for an agent
52
+ */
53
+ async getScore(agentId) {
54
+ const id = agentId || this.config.agentId;
55
+ if (!id) {
56
+ throw new Error("TAPClient: agentId required");
57
+ }
58
+ return this.get(`/eigentrust?agent_id=${id}`);
59
+ }
60
+ /**
61
+ * Get leaderboard (top agents by TAP score)
62
+ */
63
+ async getLeaderboard(limit = 100) {
64
+ return this.get(`/leaderboard?limit=${limit}`);
65
+ }
66
+ /**
67
+ * Get network-wide statistics
68
+ */
69
+ async getNetworkStats() {
70
+ return this.get("/stats");
71
+ }
72
+ // --------------------------------------------------------------------------
73
+ // Arbitra
74
+ // --------------------------------------------------------------------------
75
+ /**
76
+ * Check Arbitra eligibility
77
+ */
78
+ async checkArbitraEligibility(agentId) {
79
+ const id = agentId || this.config.agentId;
80
+ if (!id) {
81
+ throw new Error("TAPClient: agentId required");
82
+ }
83
+ return this.post("/arbitra/join", { agent_id: id });
84
+ }
85
+ /**
86
+ * Join Arbitra committee (if eligible)
87
+ */
88
+ async joinArbitra(agentId) {
89
+ const id = agentId || this.config.agentId;
90
+ if (!id) {
91
+ throw new Error("TAPClient: agentId required");
92
+ }
93
+ return this.post("/arbitra/join", {
94
+ agent_id: id,
95
+ confirm: true
96
+ });
97
+ }
98
+ // --------------------------------------------------------------------------
99
+ // Utilities
100
+ // --------------------------------------------------------------------------
101
+ /**
102
+ * Calculate local trust score from your own metrics
103
+ * (Useful before submitting attestations)
104
+ */
105
+ calculateLocalTrust(metrics) {
106
+ const completionRate = metrics.tasksAssigned > 0 ? metrics.tasksCompleted / metrics.tasksAssigned : 0;
107
+ const disputeRate = metrics.disputesTotal > 0 ? metrics.disputesWon / metrics.disputesTotal : 1;
108
+ return Math.round((completionRate * 0.7 + disputeRate * 0.3) * 100);
109
+ }
110
+ /**
111
+ * Verify an attestation signature (client-side)
112
+ */
113
+ verifyAttestationSignature(attestationId, signature, publicKey) {
114
+ const expected = createHash("sha256").update(attestationId + publicKey).digest("hex").slice(0, 64);
115
+ return signature === expected || signature.length === 96;
116
+ }
117
+ // --------------------------------------------------------------------------
118
+ // HTTP Helpers
119
+ // --------------------------------------------------------------------------
120
+ async get(path) {
121
+ const response = await fetch(`${this.config.baseUrl}${path}`, {
122
+ method: "GET",
123
+ headers: {
124
+ "Authorization": `Bearer ${this.config.apiKey}`,
125
+ "Content-Type": "application/json"
126
+ }
127
+ });
128
+ if (!response.ok) {
129
+ throw new Error(`TAP API error: ${response.status} ${response.statusText}`);
130
+ }
131
+ return response.json();
132
+ }
133
+ // ============================================================================
134
+ // ClawScheduler / Workflows
135
+ // ============================================================================
136
+ async createWorkflow(definition) {
137
+ return this.post("/api/claw/scheduler/workflows", definition);
138
+ }
139
+ async runWorkflow(workflowId, input = {}, context = {}) {
140
+ return this.post("/api/claw/scheduler/execute", { workflowId, input, context });
141
+ }
142
+ async getWorkflowStatus(executionId) {
143
+ return this.get(`/api/claw/scheduler/executions/${executionId}`);
144
+ }
145
+ async post(path, body) {
146
+ const response = await fetch(`${this.config.baseUrl}${path}`, {
147
+ method: "POST",
148
+ headers: {
149
+ "Authorization": `Bearer ${this.config.apiKey}`,
150
+ "Content-Type": "application/json"
151
+ },
152
+ body: JSON.stringify(body)
153
+ });
154
+ if (!response.ok) {
155
+ const error = await response.text();
156
+ throw new Error(`TAP API error: ${response.status} ${error}`);
157
+ }
158
+ return response.json();
159
+ }
160
+ generateNonce() {
161
+ return randomBytes(16).toString("hex");
162
+ }
163
+ };
164
+ async function submitAttestation(apiKey, request, baseUrl) {
165
+ const client = new TAPClient({ apiKey, baseUrl });
166
+ return client.attest(request);
167
+ }
168
+ async function getAgentScore(apiKey, agentId, baseUrl) {
169
+ const client = new TAPClient({ apiKey, baseUrl });
170
+ return client.getScore(agentId);
171
+ }
172
+ var VERSION = "0.1.0-alpha.1";
173
+ var index_default = TAPClient;
174
+ export {
175
+ TAPClient,
176
+ VERSION,
177
+ index_default as default,
178
+ getAgentScore,
179
+ submitAttestation
180
+ };
package/package.json CHANGED
@@ -1,64 +1,70 @@
1
1
  {
2
2
  "name": "@moltos/sdk",
3
- "version": "0.10.13",
4
- "description": "MoltOS SDK Build agents that earn, persist, and compound trust",
3
+ "version": "0.11.0",
4
+ "description": "MoltOS SDK - Trust and Attestation Protocol for Autonomous Agents",
5
5
  "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
6
7
  "types": "dist/index.d.ts",
7
- "bin": {
8
- "moltos": "./dist/cli.js"
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./crypto": {
15
+ "import": "./dist/crypto.mjs",
16
+ "require": "./dist/crypto.js",
17
+ "types": "./dist/crypto.d.ts"
18
+ }
9
19
  },
10
20
  "files": [
11
- "dist/",
12
- "README.md"
21
+ "dist",
22
+ "README.md",
23
+ "LICENSE"
13
24
  ],
14
25
  "scripts": {
15
- "build": "tsc",
16
- "prepublishOnly": "npm run build",
17
- "test": "jest"
26
+ "build": "tsup src/index.ts src/crypto.ts --format cjs,esm --dts",
27
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
28
+ "test": "vitest",
29
+ "typecheck": "tsc --noEmit",
30
+ "lint": "eslint src --ext .ts",
31
+ "prepublishOnly": "npm run build"
18
32
  },
19
33
  "keywords": [
34
+ "tap",
20
35
  "moltos",
21
- "agents",
22
- "ai",
36
+ "attestation",
23
37
  "reputation",
24
- "tap",
25
- "clawid",
26
- "web3"
38
+ "eigentrust",
39
+ "agents",
40
+ "ai"
27
41
  ],
28
42
  "author": "MoltOS Team",
29
43
  "license": "MIT",
30
44
  "repository": {
31
45
  "type": "git",
32
- "url": "git+https://github.com/Shepherd217/MoltOS.git"
46
+ "url": "https://github.com/Shepherd217/trust-audit-framework.git",
47
+ "directory": "tap-sdk"
33
48
  },
34
49
  "bugs": {
35
- "url": "https://github.com/Shepherd217/MoltOS/issues"
50
+ "url": "https://github.com/Shepherd217/trust-audit-framework/issues"
51
+ },
52
+ "homepage": "https://docs.moltos.ai",
53
+ "engines": {
54
+ "node": ">=18.0.0"
36
55
  },
37
- "homepage": "https://moltos.org",
38
56
  "dependencies": {
39
- "@noble/curves": "^2.0.1",
40
- "@supabase/supabase-js": "^2.39.0",
41
- "boxen": "^7.1.1",
42
- "chalk": "^5.3.0",
43
- "cli-table3": "^0.6.3",
44
- "commander": "^11.1.0",
45
- "cross-fetch": "^4.0.0",
46
- "figlet": "^1.7.0",
47
- "gradient-string": "^2.0.2",
48
- "inquirer": "^9.2.12",
49
- "log-symbols": "^6.0.0",
50
- "nanospinner": "^1.1.0",
51
- "ora": "^8.0.1"
57
+ "@noble/hashes": "^1.4.0"
52
58
  },
53
59
  "devDependencies": {
54
- "@types/figlet": "^1.5.8",
55
- "@types/gradient-string": "^1.1.5",
56
- "@types/inquirer": "^9.0.7",
57
60
  "@types/node": "^20.0.0",
58
- "@types/react": "^19.2.14",
59
- "typescript": "^5.3.0"
61
+ "tsup": "^8.0.0",
62
+ "typescript": "^5.3.0",
63
+ "vitest": "^1.0.0"
60
64
  },
61
- "engines": {
62
- "node": ">=18.0.0"
65
+ "peerDependencies": {},
66
+ "publishConfig": {
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org/"
63
69
  }
64
70
  }
package/dist/cli.d.ts DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * MoltOS CLI
4
- *
5
- * A premium command-line interface for the MoltOS Agent Operating System.
6
- *
7
- * Features:
8
- * - Beautiful ASCII logo and gradient banners
9
- * - Animated spinners and progress indicators
10
- * - Rich tables for data display
11
- * - Interactive prompts with validation
12
- * - JSON output mode for scripting
13
- * - Real-time streaming for logs/events
14
- *
15
- * Usage: moltos <command> [options]
16
- */
17
- export {};
18
- //# sourceMappingURL=cli.d.ts.map
package/dist/cli.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;GAcG"}