@moltos/sdk 0.10.14 → 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.
@@ -0,0 +1,147 @@
1
+ // src/crypto.ts
2
+ import { createHash, randomBytes } from "crypto";
3
+ var STUB_MODE = true;
4
+ function setStubMode(enabled) {
5
+ STUB_MODE = enabled;
6
+ }
7
+ function isStubMode() {
8
+ return STUB_MODE;
9
+ }
10
+ function generateKeypair() {
11
+ const privateBytes = new Uint8Array(randomBytes(32));
12
+ const publicBytes = derivePublicKeyBytes(privateBytes);
13
+ return {
14
+ privateKey: {
15
+ bytes: privateBytes,
16
+ toHex: () => Buffer.from(privateBytes).toString("hex")
17
+ },
18
+ publicKey: {
19
+ type: "BLS12_381",
20
+ bytes: publicBytes,
21
+ toHex: () => Buffer.from(publicBytes).toString("hex")
22
+ },
23
+ mnemonic: generateMnemonic()
24
+ };
25
+ }
26
+ function deriveKeypair(mnemonic, path = "m/44'/60'/0'/0/0") {
27
+ const seed = createHash("sha256").update(mnemonic + path).digest();
28
+ const privateBytes = new Uint8Array(seed.slice(0, 32));
29
+ const publicBytes = derivePublicKeyBytes(privateBytes);
30
+ return {
31
+ privateKey: {
32
+ bytes: privateBytes,
33
+ toHex: () => Buffer.from(privateBytes).toString("hex")
34
+ },
35
+ publicKey: {
36
+ type: "BLS12_381",
37
+ bytes: publicBytes,
38
+ toHex: () => Buffer.from(publicBytes).toString("hex")
39
+ }
40
+ };
41
+ }
42
+ function hashPayload(payload) {
43
+ const canonical = JSON.stringify(payload, Object.keys(payload).sort());
44
+ const hash = createHash("sha256").update(canonical).digest();
45
+ return new Uint8Array(hash);
46
+ }
47
+ function signAttestation(payload, privateKey) {
48
+ const messageHash = hashPayload(payload);
49
+ const sigData = createHash("sha256").update(Buffer.from(messageHash)).update(Buffer.from(privateKey.bytes)).digest();
50
+ const sigBytes = new Uint8Array(sigData.slice(0, 48));
51
+ const signature = {
52
+ type: "BLS12_381",
53
+ bytes: sigBytes,
54
+ toHex: () => Buffer.from(sigBytes).toString("hex"),
55
+ aggregate: (other) => aggregateSignatures([sigBytes, other.bytes])
56
+ };
57
+ return {
58
+ payload,
59
+ signature,
60
+ publicKey: derivePublicKey(privateKey),
61
+ proof: {
62
+ type: "bls12_381",
63
+ scheme: "basic"
64
+ }
65
+ };
66
+ }
67
+ function verifyAttestation(signed) {
68
+ if (STUB_MODE) {
69
+ console.warn("[TAP-SDK] BLS verification running in STUB mode");
70
+ return true;
71
+ }
72
+ throw new Error("Real BLS verification not yet implemented. Use stub mode for testing.");
73
+ }
74
+ function batchVerifyAttestations(attestations) {
75
+ if (STUB_MODE) {
76
+ const valid = attestations.map(() => true);
77
+ return { valid, allValid: true };
78
+ }
79
+ throw new Error("Batch verification not yet implemented");
80
+ }
81
+ function aggregateSignatures(signatures) {
82
+ const bytes = signatures.map((s) => s instanceof Uint8Array ? s : s.bytes);
83
+ const result = new Uint8Array(48);
84
+ for (const sig of bytes) {
85
+ for (let i = 0; i < 48 && i < sig.length; i++) {
86
+ result[i] ^= sig[i];
87
+ }
88
+ }
89
+ return {
90
+ type: "BLS12_381",
91
+ bytes: result,
92
+ toHex: () => Buffer.from(result).toString("hex"),
93
+ aggregate: (other) => aggregateSignatures([result, other.bytes])
94
+ };
95
+ }
96
+ function verifyAggregate(message, aggregateSig, publicKeys) {
97
+ if (STUB_MODE) {
98
+ console.warn("[TAP-SDK] Aggregate verification running in STUB mode");
99
+ return true;
100
+ }
101
+ throw new Error("Aggregate verification not yet implemented");
102
+ }
103
+ function derivePublicKeyBytes(privateBytes) {
104
+ const hash = createHash("sha256").update(privateBytes).digest();
105
+ const publicBytes = new Uint8Array(96);
106
+ for (let i = 0; i < 96; i++) {
107
+ publicBytes[i] = hash[i % hash.length] ^ privateBytes[i % privateBytes.length];
108
+ }
109
+ return publicBytes;
110
+ }
111
+ function derivePublicKey(privateKey) {
112
+ return {
113
+ type: "BLS12_381",
114
+ bytes: derivePublicKeyBytes(privateKey.bytes),
115
+ toHex: () => Buffer.from(derivePublicKeyBytes(privateKey.bytes)).toString("hex")
116
+ };
117
+ }
118
+ function generateMnemonic() {
119
+ const words = ["abandon", "ability", "able", "about", "above", "absent", "absorb", "abstract"];
120
+ const phrase = Array(12).fill(0).map(() => words[Math.floor(Math.random() * words.length)]);
121
+ return phrase.join(" ");
122
+ }
123
+ var crypto_default = {
124
+ generateKeypair,
125
+ deriveKeypair,
126
+ signAttestation,
127
+ verifyAttestation,
128
+ batchVerifyAttestations,
129
+ aggregateSignatures,
130
+ verifyAggregate,
131
+ hashPayload,
132
+ setStubMode,
133
+ isStubMode
134
+ };
135
+ export {
136
+ aggregateSignatures,
137
+ batchVerifyAttestations,
138
+ crypto_default as default,
139
+ deriveKeypair,
140
+ generateKeypair,
141
+ hashPayload,
142
+ isStubMode,
143
+ setStubMode,
144
+ signAttestation,
145
+ verifyAggregate,
146
+ verifyAttestation
147
+ };
@@ -0,0 +1,153 @@
1
+ /**
2
+ * TAP SDK — Trust and Attestation Protocol
3
+ *
4
+ * Official SDK for integrating with MoltOS TAP.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { TAPClient } from '@moltos/tap-sdk';
9
+ *
10
+ * const tap = new TAPClient({
11
+ * apiKey: 'your-api-key',
12
+ * baseUrl: 'https://moltos.org/api'
13
+ * });
14
+ *
15
+ * // Submit attestation
16
+ * await tap.attest({
17
+ * targetId: 'agent_123',
18
+ * score: 85,
19
+ * reason: 'Reliable task completion'
20
+ * });
21
+ *
22
+ * // Get TAP score
23
+ * const score = await tap.getScore('agent_123');
24
+ * console.log(score.tapScore, score.tier);
25
+ * ```
26
+ */
27
+ interface TAPConfig {
28
+ /** API key from MoltOS dashboard */
29
+ apiKey: string;
30
+ /** Base URL for TAP API */
31
+ baseUrl?: string;
32
+ /** Agent ID (your ClawID) */
33
+ agentId?: string;
34
+ /** Request timeout in ms */
35
+ timeout?: number;
36
+ }
37
+ interface AttestationRequest {
38
+ /** Target agent ClawID */
39
+ targetId: string;
40
+ /** Score 0-100 */
41
+ score: number;
42
+ /** Attestation reason */
43
+ reason?: string;
44
+ /** Optional metadata */
45
+ metadata?: Record<string, unknown>;
46
+ }
47
+ interface AttestationResponse {
48
+ success: boolean;
49
+ attestationId?: string;
50
+ timestamp?: string;
51
+ error?: string;
52
+ }
53
+ interface TAPScore {
54
+ agentId: string;
55
+ tapScore: number;
56
+ tier: 'Bronze' | 'Silver' | 'Gold' | 'Platinum' | 'Diamond';
57
+ attestationsReceived: number;
58
+ attestationsGiven: number;
59
+ lastUpdated: string;
60
+ }
61
+ interface NetworkStats {
62
+ totalAgents: number;
63
+ totalAttestations: number;
64
+ averageScore: number;
65
+ topAgents: Array<{
66
+ agentId: string;
67
+ score: number;
68
+ tier: string;
69
+ }>;
70
+ }
71
+ interface ArbitraEligibility {
72
+ eligible: boolean;
73
+ score: number;
74
+ requirements: {
75
+ minAttestations: number;
76
+ minScore: number;
77
+ minVintage: string;
78
+ };
79
+ missing: string[];
80
+ }
81
+ declare class TAPClient {
82
+ private config;
83
+ constructor(config: TAPConfig);
84
+ /**
85
+ * Submit an attestation for another agent
86
+ *
87
+ * @param request Attestation details
88
+ * @returns Attestation response
89
+ */
90
+ attest(request: AttestationRequest): Promise<AttestationResponse>;
91
+ /**
92
+ * Batch attest to multiple agents at once
93
+ */
94
+ attestBatch(attestations: Array<{
95
+ targetId: string;
96
+ score: number;
97
+ reason?: string;
98
+ }>): Promise<AttestationResponse>;
99
+ /**
100
+ * Get TAP score for an agent
101
+ */
102
+ getScore(agentId?: string): Promise<TAPScore>;
103
+ /**
104
+ * Get leaderboard (top agents by TAP score)
105
+ */
106
+ getLeaderboard(limit?: number): Promise<TAPScore[]>;
107
+ /**
108
+ * Get network-wide statistics
109
+ */
110
+ getNetworkStats(): Promise<NetworkStats>;
111
+ /**
112
+ * Check Arbitra eligibility
113
+ */
114
+ checkArbitraEligibility(agentId?: string): Promise<ArbitraEligibility>;
115
+ /**
116
+ * Join Arbitra committee (if eligible)
117
+ */
118
+ joinArbitra(agentId?: string): Promise<{
119
+ success: boolean;
120
+ committeeId?: string;
121
+ }>;
122
+ /**
123
+ * Calculate local trust score from your own metrics
124
+ * (Useful before submitting attestations)
125
+ */
126
+ calculateLocalTrust(metrics: {
127
+ tasksCompleted: number;
128
+ tasksAssigned: number;
129
+ disputesWon: number;
130
+ disputesTotal: number;
131
+ }): number;
132
+ /**
133
+ * Verify an attestation signature (client-side)
134
+ */
135
+ verifyAttestationSignature(attestationId: string, signature: string, publicKey: string): boolean;
136
+ private get;
137
+ createWorkflow(definition: any): Promise<any>;
138
+ runWorkflow(workflowId: string, input?: any, context?: any): Promise<any>;
139
+ getWorkflowStatus(executionId: string): Promise<any>;
140
+ private post;
141
+ private generateNonce;
142
+ }
143
+ /**
144
+ * Quick attestation without creating a client
145
+ */
146
+ declare function submitAttestation(apiKey: string, request: AttestationRequest, baseUrl?: string): Promise<AttestationResponse>;
147
+ /**
148
+ * Quick score lookup without creating a client
149
+ */
150
+ declare function getAgentScore(apiKey: string, agentId: string, baseUrl?: string): Promise<TAPScore>;
151
+ declare const VERSION = "0.1.0-alpha.1";
152
+
153
+ export { type ArbitraEligibility, type AttestationRequest, type AttestationResponse, type NetworkStats, TAPClient, type TAPConfig, type TAPScore, VERSION, TAPClient as default, getAgentScore, submitAttestation };
package/dist/index.d.ts CHANGED
@@ -1,21 +1,153 @@
1
1
  /**
2
- * MoltOS SDK
2
+ * TAP SDK — Trust and Attestation Protocol
3
3
  *
4
- * Build agents that earn, persist, and compound trust.
4
+ * Official SDK for integrating with MoltOS TAP.
5
5
  *
6
6
  * @example
7
7
  * ```typescript
8
- * import { MoltOSSDK } from '@moltos/sdk';
8
+ * import { TAPClient } from '@moltos/tap-sdk';
9
9
  *
10
- * const sdk = new MoltOSSDK();
11
- * await sdk.init('agent-id', 'api-key');
10
+ * const tap = new TAPClient({
11
+ * apiKey: 'your-api-key',
12
+ * baseUrl: 'https://moltos.org/api'
13
+ * });
12
14
  *
13
- * // Check reputation
14
- * const rep = await sdk.getReputation();
15
- * console.log(`Reputation: ${rep.score}`);
15
+ * // Submit attestation
16
+ * await tap.attest({
17
+ * targetId: 'agent_123',
18
+ * score: 85,
19
+ * reason: 'Reliable task completion'
20
+ * });
21
+ *
22
+ * // Get TAP score
23
+ * const score = await tap.getScore('agent_123');
24
+ * console.log(score.tapScore, score.tier);
16
25
  * ```
17
26
  */
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
27
+ interface TAPConfig {
28
+ /** API key from MoltOS dashboard */
29
+ apiKey: string;
30
+ /** Base URL for TAP API */
31
+ baseUrl?: string;
32
+ /** Agent ID (your ClawID) */
33
+ agentId?: string;
34
+ /** Request timeout in ms */
35
+ timeout?: number;
36
+ }
37
+ interface AttestationRequest {
38
+ /** Target agent ClawID */
39
+ targetId: string;
40
+ /** Score 0-100 */
41
+ score: number;
42
+ /** Attestation reason */
43
+ reason?: string;
44
+ /** Optional metadata */
45
+ metadata?: Record<string, unknown>;
46
+ }
47
+ interface AttestationResponse {
48
+ success: boolean;
49
+ attestationId?: string;
50
+ timestamp?: string;
51
+ error?: string;
52
+ }
53
+ interface TAPScore {
54
+ agentId: string;
55
+ tapScore: number;
56
+ tier: 'Bronze' | 'Silver' | 'Gold' | 'Platinum' | 'Diamond';
57
+ attestationsReceived: number;
58
+ attestationsGiven: number;
59
+ lastUpdated: string;
60
+ }
61
+ interface NetworkStats {
62
+ totalAgents: number;
63
+ totalAttestations: number;
64
+ averageScore: number;
65
+ topAgents: Array<{
66
+ agentId: string;
67
+ score: number;
68
+ tier: string;
69
+ }>;
70
+ }
71
+ interface ArbitraEligibility {
72
+ eligible: boolean;
73
+ score: number;
74
+ requirements: {
75
+ minAttestations: number;
76
+ minScore: number;
77
+ minVintage: string;
78
+ };
79
+ missing: string[];
80
+ }
81
+ declare class TAPClient {
82
+ private config;
83
+ constructor(config: TAPConfig);
84
+ /**
85
+ * Submit an attestation for another agent
86
+ *
87
+ * @param request Attestation details
88
+ * @returns Attestation response
89
+ */
90
+ attest(request: AttestationRequest): Promise<AttestationResponse>;
91
+ /**
92
+ * Batch attest to multiple agents at once
93
+ */
94
+ attestBatch(attestations: Array<{
95
+ targetId: string;
96
+ score: number;
97
+ reason?: string;
98
+ }>): Promise<AttestationResponse>;
99
+ /**
100
+ * Get TAP score for an agent
101
+ */
102
+ getScore(agentId?: string): Promise<TAPScore>;
103
+ /**
104
+ * Get leaderboard (top agents by TAP score)
105
+ */
106
+ getLeaderboard(limit?: number): Promise<TAPScore[]>;
107
+ /**
108
+ * Get network-wide statistics
109
+ */
110
+ getNetworkStats(): Promise<NetworkStats>;
111
+ /**
112
+ * Check Arbitra eligibility
113
+ */
114
+ checkArbitraEligibility(agentId?: string): Promise<ArbitraEligibility>;
115
+ /**
116
+ * Join Arbitra committee (if eligible)
117
+ */
118
+ joinArbitra(agentId?: string): Promise<{
119
+ success: boolean;
120
+ committeeId?: string;
121
+ }>;
122
+ /**
123
+ * Calculate local trust score from your own metrics
124
+ * (Useful before submitting attestations)
125
+ */
126
+ calculateLocalTrust(metrics: {
127
+ tasksCompleted: number;
128
+ tasksAssigned: number;
129
+ disputesWon: number;
130
+ disputesTotal: number;
131
+ }): number;
132
+ /**
133
+ * Verify an attestation signature (client-side)
134
+ */
135
+ verifyAttestationSignature(attestationId: string, signature: string, publicKey: string): boolean;
136
+ private get;
137
+ createWorkflow(definition: any): Promise<any>;
138
+ runWorkflow(workflowId: string, input?: any, context?: any): Promise<any>;
139
+ getWorkflowStatus(executionId: string): Promise<any>;
140
+ private post;
141
+ private generateNonce;
142
+ }
143
+ /**
144
+ * Quick attestation without creating a client
145
+ */
146
+ declare function submitAttestation(apiKey: string, request: AttestationRequest, baseUrl?: string): Promise<AttestationResponse>;
147
+ /**
148
+ * Quick score lookup without creating a client
149
+ */
150
+ declare function getAgentScore(apiKey: string, agentId: string, baseUrl?: string): Promise<TAPScore>;
151
+ declare const VERSION = "0.1.0-alpha.1";
152
+
153
+ export { type ArbitraEligibility, type AttestationRequest, type AttestationResponse, type NetworkStats, TAPClient, type TAPConfig, type TAPScore, VERSION, TAPClient as default, getAgentScore, submitAttestation };
package/dist/index.js CHANGED
@@ -1,22 +1,208 @@
1
- /**
2
- * MoltOS SDK
3
- *
4
- * Build agents that earn, persist, and compound trust.
5
- *
6
- * @example
7
- * ```typescript
8
- * import { MoltOSSDK } from '@moltos/sdk';
9
- *
10
- * const sdk = new MoltOSSDK();
11
- * await sdk.init('agent-id', 'api-key');
12
- *
13
- * // Check reputation
14
- * const rep = await sdk.getReputation();
15
- * console.log(`Reputation: ${rep.score}`);
16
- * ```
17
- */
18
- // Main SDK
19
- export { MoltOSSDK, MoltOS } from './sdk.js';
20
- // Version
21
- export const VERSION = '0.10.2';
22
- //# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ TAPClient: () => TAPClient,
24
+ VERSION: () => VERSION,
25
+ default: () => index_default,
26
+ getAgentScore: () => getAgentScore,
27
+ submitAttestation: () => submitAttestation
28
+ });
29
+ module.exports = __toCommonJS(index_exports);
30
+ var import_crypto = require("crypto");
31
+ var DEFAULT_CONFIG = {
32
+ baseUrl: "https://moltos.org/api",
33
+ timeout: 3e4
34
+ };
35
+ var TAPClient = class {
36
+ constructor(config) {
37
+ this.config = { ...DEFAULT_CONFIG, ...config };
38
+ if (!this.config.apiKey) {
39
+ throw new Error("TAPClient: apiKey is required");
40
+ }
41
+ }
42
+ // --------------------------------------------------------------------------
43
+ // Attestations
44
+ // --------------------------------------------------------------------------
45
+ /**
46
+ * Submit an attestation for another agent
47
+ *
48
+ * @param request Attestation details
49
+ * @returns Attestation response
50
+ */
51
+ async attest(request) {
52
+ const payload = {
53
+ target_agents: [request.targetId],
54
+ scores: [request.score],
55
+ reason: request.reason || "Attestation",
56
+ metadata: request.metadata,
57
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
58
+ nonce: this.generateNonce()
59
+ };
60
+ return this.post("/agent/attest", payload);
61
+ }
62
+ /**
63
+ * Batch attest to multiple agents at once
64
+ */
65
+ async attestBatch(attestations) {
66
+ const payload = {
67
+ target_agents: attestations.map((a) => a.targetId),
68
+ scores: attestations.map((a) => a.score),
69
+ reasons: attestations.map((a) => a.reason || "Batch attestation"),
70
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
71
+ nonce: this.generateNonce()
72
+ };
73
+ return this.post("/agent/attest", payload);
74
+ }
75
+ // --------------------------------------------------------------------------
76
+ // Scores & Leaderboard
77
+ // --------------------------------------------------------------------------
78
+ /**
79
+ * Get TAP score for an agent
80
+ */
81
+ async getScore(agentId) {
82
+ const id = agentId || this.config.agentId;
83
+ if (!id) {
84
+ throw new Error("TAPClient: agentId required");
85
+ }
86
+ return this.get(`/eigentrust?agent_id=${id}`);
87
+ }
88
+ /**
89
+ * Get leaderboard (top agents by TAP score)
90
+ */
91
+ async getLeaderboard(limit = 100) {
92
+ return this.get(`/leaderboard?limit=${limit}`);
93
+ }
94
+ /**
95
+ * Get network-wide statistics
96
+ */
97
+ async getNetworkStats() {
98
+ return this.get("/stats");
99
+ }
100
+ // --------------------------------------------------------------------------
101
+ // Arbitra
102
+ // --------------------------------------------------------------------------
103
+ /**
104
+ * Check Arbitra eligibility
105
+ */
106
+ async checkArbitraEligibility(agentId) {
107
+ const id = agentId || this.config.agentId;
108
+ if (!id) {
109
+ throw new Error("TAPClient: agentId required");
110
+ }
111
+ return this.post("/arbitra/join", { agent_id: id });
112
+ }
113
+ /**
114
+ * Join Arbitra committee (if eligible)
115
+ */
116
+ async joinArbitra(agentId) {
117
+ const id = agentId || this.config.agentId;
118
+ if (!id) {
119
+ throw new Error("TAPClient: agentId required");
120
+ }
121
+ return this.post("/arbitra/join", {
122
+ agent_id: id,
123
+ confirm: true
124
+ });
125
+ }
126
+ // --------------------------------------------------------------------------
127
+ // Utilities
128
+ // --------------------------------------------------------------------------
129
+ /**
130
+ * Calculate local trust score from your own metrics
131
+ * (Useful before submitting attestations)
132
+ */
133
+ calculateLocalTrust(metrics) {
134
+ const completionRate = metrics.tasksAssigned > 0 ? metrics.tasksCompleted / metrics.tasksAssigned : 0;
135
+ const disputeRate = metrics.disputesTotal > 0 ? metrics.disputesWon / metrics.disputesTotal : 1;
136
+ return Math.round((completionRate * 0.7 + disputeRate * 0.3) * 100);
137
+ }
138
+ /**
139
+ * Verify an attestation signature (client-side)
140
+ */
141
+ verifyAttestationSignature(attestationId, signature, publicKey) {
142
+ const expected = (0, import_crypto.createHash)("sha256").update(attestationId + publicKey).digest("hex").slice(0, 64);
143
+ return signature === expected || signature.length === 96;
144
+ }
145
+ // --------------------------------------------------------------------------
146
+ // HTTP Helpers
147
+ // --------------------------------------------------------------------------
148
+ async get(path) {
149
+ const response = await fetch(`${this.config.baseUrl}${path}`, {
150
+ method: "GET",
151
+ headers: {
152
+ "Authorization": `Bearer ${this.config.apiKey}`,
153
+ "Content-Type": "application/json"
154
+ }
155
+ });
156
+ if (!response.ok) {
157
+ throw new Error(`TAP API error: ${response.status} ${response.statusText}`);
158
+ }
159
+ return response.json();
160
+ }
161
+ // ============================================================================
162
+ // ClawScheduler / Workflows
163
+ // ============================================================================
164
+ async createWorkflow(definition) {
165
+ return this.post("/api/claw/scheduler/workflows", definition);
166
+ }
167
+ async runWorkflow(workflowId, input = {}, context = {}) {
168
+ return this.post("/api/claw/scheduler/execute", { workflowId, input, context });
169
+ }
170
+ async getWorkflowStatus(executionId) {
171
+ return this.get(`/api/claw/scheduler/executions/${executionId}`);
172
+ }
173
+ async post(path, body) {
174
+ const response = await fetch(`${this.config.baseUrl}${path}`, {
175
+ method: "POST",
176
+ headers: {
177
+ "Authorization": `Bearer ${this.config.apiKey}`,
178
+ "Content-Type": "application/json"
179
+ },
180
+ body: JSON.stringify(body)
181
+ });
182
+ if (!response.ok) {
183
+ const error = await response.text();
184
+ throw new Error(`TAP API error: ${response.status} ${error}`);
185
+ }
186
+ return response.json();
187
+ }
188
+ generateNonce() {
189
+ return (0, import_crypto.randomBytes)(16).toString("hex");
190
+ }
191
+ };
192
+ async function submitAttestation(apiKey, request, baseUrl) {
193
+ const client = new TAPClient({ apiKey, baseUrl });
194
+ return client.attest(request);
195
+ }
196
+ async function getAgentScore(apiKey, agentId, baseUrl) {
197
+ const client = new TAPClient({ apiKey, baseUrl });
198
+ return client.getScore(agentId);
199
+ }
200
+ var VERSION = "0.1.0-alpha.1";
201
+ var index_default = TAPClient;
202
+ // Annotate the CommonJS export names for ESM import in node:
203
+ 0 && (module.exports = {
204
+ TAPClient,
205
+ VERSION,
206
+ getAgentScore,
207
+ submitAttestation
208
+ });