@moltos/sdk 0.5.0 → 0.5.1
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 +12 -144
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -243
- package/dist/index.js.map +1 -1
- package/dist/lib/api.d.ts +32 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +80 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/arbitra.d.ts +302 -0
- package/dist/lib/arbitra.d.ts.map +1 -0
- package/dist/lib/arbitra.js +486 -0
- package/dist/lib/arbitra.js.map +1 -0
- package/dist/lib/clawfs.d.ts +277 -0
- package/dist/lib/clawfs.d.ts.map +1 -0
- package/dist/lib/clawfs.js +628 -0
- package/dist/lib/clawfs.js.map +1 -0
- package/dist/lib/clawid.d.ts +189 -0
- package/dist/lib/clawid.d.ts.map +1 -0
- package/dist/lib/clawid.js +455 -0
- package/dist/lib/clawid.js.map +1 -0
- package/dist/lib/config.d.ts +23 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +29 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/tap.d.ts +208 -0
- package/dist/lib/tap.d.ts.map +1 -0
- package/dist/lib/tap.js +549 -0
- package/dist/lib/tap.js.map +1 -0
- package/package.json +6 -2
- package/README.md +0 -67
- package/dist/arbitra.d.ts +0 -3
- package/dist/arbitra.d.ts.map +0 -1
- package/dist/arbitra.js +0 -198
- package/dist/arbitra.js.map +0 -1
- package/dist/attack-sim.d.ts +0 -3
- package/dist/attack-sim.d.ts.map +0 -1
- package/dist/attack-sim.js +0 -101
- package/dist/attack-sim.js.map +0 -1
- package/dist/cli.d.ts +0 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -379
- package/dist/cli.js.map +0 -1
- package/dist/protocols/arbitra/voting.d.ts +0 -43
- package/dist/protocols/arbitra/voting.d.ts.map +0 -1
- package/dist/protocols/arbitra/voting.js +0 -42
- package/dist/protocols/arbitra/voting.js.map +0 -1
- package/dist/protocols/clawforge/control-plane.d.ts +0 -4
- package/dist/protocols/clawforge/control-plane.d.ts.map +0 -1
- package/dist/protocols/clawforge/control-plane.js +0 -11
- package/dist/protocols/clawforge/control-plane.js.map +0 -1
- package/dist/protocols/clawid/clawid-token.d.ts +0 -9
- package/dist/protocols/clawid/clawid-token.d.ts.map +0 -1
- package/dist/protocols/clawid/clawid-token.js +0 -20
- package/dist/protocols/clawid/clawid-token.js.map +0 -1
- package/dist/protocols/clawkernel/kernel.d.ts +0 -4
- package/dist/protocols/clawkernel/kernel.d.ts.map +0 -1
- package/dist/protocols/clawkernel/kernel.js +0 -11
- package/dist/protocols/clawkernel/kernel.js.map +0 -1
- package/dist/protocols/clawlink/handoff.d.ts +0 -64
- package/dist/protocols/clawlink/handoff.d.ts.map +0 -1
- package/dist/protocols/clawlink/handoff.js +0 -31
- package/dist/protocols/clawlink/handoff.js.map +0 -1
- package/dist/types.d.ts +0 -65
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -27
- package/dist/types.js.map +0 -1
- package/dist/vm.d.ts +0 -3
- package/dist/vm.d.ts.map +0 -1
- package/dist/vm.js +0 -173
- package/dist/vm.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,149 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* MoltOS SDK - The Complete Agent Operating System
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and participate in the verified agent economy.
|
|
4
|
+
* This is the official SDK for MoltOS — the production-grade Agent Operating System
|
|
5
|
+
* with persistent agents, real trust, self-healing swarms, and hardware isolation.
|
|
7
6
|
*
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
* import { TAPClient } from '@tap-protocol/sdk';
|
|
11
|
-
*
|
|
12
|
-
* const client = new TAPClient({
|
|
13
|
-
* privateKey: process.env.TAP_PRIVATE_KEY,
|
|
14
|
-
* agentId: 'agent-007'
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* // Perform attestation
|
|
18
|
-
* const result = await client.attest({
|
|
19
|
-
* claimId: 'claim-123',
|
|
20
|
-
* targetAgent: 'agent-042'
|
|
21
|
-
* });
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export interface TAPConfig {
|
|
25
|
-
privateKey: string;
|
|
26
|
-
agentId: string;
|
|
27
|
-
apiUrl?: string;
|
|
28
|
-
stakeAmount?: number;
|
|
29
|
-
}
|
|
30
|
-
export interface AttestationClaim {
|
|
31
|
-
claimId: string;
|
|
32
|
-
statement: string;
|
|
33
|
-
metric: 'response_time_ms' | 'uptime_percent' | 'availability' | 'accuracy_percent' | 'custom';
|
|
34
|
-
threshold: number;
|
|
35
|
-
stakeAmount: number;
|
|
36
|
-
}
|
|
37
|
-
export interface AttestationResult {
|
|
38
|
-
claimId: string;
|
|
39
|
-
result: 'CONFIRMED' | 'REJECTED' | 'TIMEOUT';
|
|
40
|
-
measuredValue: number;
|
|
41
|
-
threshold: number;
|
|
42
|
-
timestamp: string;
|
|
43
|
-
signature: string;
|
|
44
|
-
}
|
|
45
|
-
export interface BootAudit {
|
|
46
|
-
agentId: string;
|
|
47
|
-
timestamp: string;
|
|
48
|
-
workspaceHash: string;
|
|
49
|
-
configFiles: Record<string, string>;
|
|
50
|
-
complianceStatus: 'FULL' | 'PARTIAL' | 'FAILED';
|
|
51
|
-
signature: string;
|
|
52
|
-
}
|
|
53
|
-
export declare class TAPClient {
|
|
54
|
-
privateKey: Uint8Array;
|
|
55
|
-
publicKey: Uint8Array;
|
|
56
|
-
agentId: string;
|
|
57
|
-
apiUrl: string;
|
|
58
|
-
private stakeAmount;
|
|
59
|
-
constructor(config: TAPConfig);
|
|
60
|
-
/**
|
|
61
|
-
* Generate a boot audit hash for workspace verification
|
|
62
|
-
*/
|
|
63
|
-
generateBootAudit(configFiles: Record<string, string>): Promise<BootAudit>;
|
|
64
|
-
/**
|
|
65
|
-
* Create a claim for the Trust Ledger
|
|
66
|
-
*/
|
|
67
|
-
createClaim(claim: Omit<AttestationClaim, 'stakeAmount'>): Promise<AttestationClaim>;
|
|
68
|
-
/**
|
|
69
|
-
* Perform attestation on another agent's claim
|
|
70
|
-
*/
|
|
71
|
-
attest(options: {
|
|
72
|
-
claimId: string;
|
|
73
|
-
targetAgent: string;
|
|
74
|
-
testRequests?: number;
|
|
75
|
-
}): Promise<AttestationResult>;
|
|
76
|
-
/**
|
|
77
|
-
* Batch attest multiple claims with BLS aggregation
|
|
78
|
-
*/
|
|
79
|
-
attestBatch(claims: Array<{
|
|
80
|
-
claimId: string;
|
|
81
|
-
targetAgent: string;
|
|
82
|
-
}>): Promise<{
|
|
83
|
-
aggregatedSignature: string;
|
|
84
|
-
results: AttestationResult[];
|
|
85
|
-
}>;
|
|
86
|
-
/**
|
|
87
|
-
* Verify another agent's attestation
|
|
88
|
-
*/
|
|
89
|
-
verifyAttestation(attestation: AttestationResult, attestorPublicKey: string): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Get agent's attestation history
|
|
92
|
-
*/
|
|
93
|
-
getAttestationHistory(agentId?: string): Promise<AttestationResult[]>;
|
|
94
|
-
/**
|
|
95
|
-
* Get live network stats
|
|
96
|
-
*/
|
|
97
|
-
getNetworkStats(): Promise<{
|
|
98
|
-
agents: number;
|
|
99
|
-
pairs: number;
|
|
100
|
-
alphaDistributed: number;
|
|
101
|
-
claimsToday: number;
|
|
102
|
-
}>;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* OpenClaw Skill Integration
|
|
106
|
-
*
|
|
107
|
-
* Usage: Drop this into ~/.openclaw/skills/tap/skill.js
|
|
108
|
-
*/
|
|
109
|
-
export declare const tapSkill: {
|
|
110
|
-
name: string;
|
|
111
|
-
description: string;
|
|
112
|
-
execute(input: {
|
|
113
|
-
privateKey: string;
|
|
114
|
-
agentId: string;
|
|
115
|
-
claimId: string;
|
|
116
|
-
targetAgent: string;
|
|
117
|
-
}): Promise<AttestationResult>;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* x402 + TAP Integration
|
|
121
|
-
*
|
|
122
|
-
* Combines payment settlement with pre-payment verification
|
|
7
|
+
* @module @moltos/sdk
|
|
8
|
+
* @version 0.5.1
|
|
123
9
|
*/
|
|
124
|
-
export
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
claimId: string;
|
|
132
|
-
x402Config: {
|
|
133
|
-
token: string;
|
|
134
|
-
network: string;
|
|
135
|
-
};
|
|
136
|
-
}): Promise<{
|
|
137
|
-
attestationHash: string;
|
|
138
|
-
paymentReceipt: any;
|
|
139
|
-
}>;
|
|
140
|
-
private resolveAgentFromEndpoint;
|
|
141
|
-
private executeX402Payment;
|
|
142
|
-
}
|
|
143
|
-
export * from './types';
|
|
144
|
-
export * from './protocols/arbitra/voting';
|
|
145
|
-
export * from './protocols/clawlink/handoff';
|
|
146
|
-
export * from './protocols/clawid/clawid-token';
|
|
147
|
-
export * from './protocols/clawforge/control-plane';
|
|
148
|
-
export * from './protocols/clawkernel/kernel';
|
|
10
|
+
export { ApiClient, ApiConfig, ApiResponse, initApiClient, getApiClient } from './lib/api';
|
|
11
|
+
export { MoltOSConfig, loadConfig, validateConfig } from './lib/config';
|
|
12
|
+
export * from './lib/tap';
|
|
13
|
+
export * from './lib/arbitra';
|
|
14
|
+
export * from './lib/clawid';
|
|
15
|
+
export * from './lib/clawfs';
|
|
16
|
+
export declare const VERSION = "0.5.1";
|
|
149
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAG3F,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGxE,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAG7B,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MoltOS SDK - The Complete Agent Operating System
|
|
4
|
+
*
|
|
5
|
+
* This is the official SDK for MoltOS — the production-grade Agent Operating System
|
|
6
|
+
* with persistent agents, real trust, self-healing swarms, and hardware isolation.
|
|
7
|
+
*
|
|
8
|
+
* @module @moltos/sdk
|
|
9
|
+
* @version 0.5.1
|
|
10
|
+
*/
|
|
2
11
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
12
|
if (k2 === undefined) k2 = k;
|
|
4
13
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,247 +23,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
23
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
24
|
};
|
|
16
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Generate a boot audit hash for workspace verification
|
|
37
|
-
*/
|
|
38
|
-
async generateBootAudit(configFiles) {
|
|
39
|
-
// Hash each config file
|
|
40
|
-
const fileHashes = {};
|
|
41
|
-
let combinedHash = '';
|
|
42
|
-
for (const [filename, content] of Object.entries(configFiles)) {
|
|
43
|
-
const hash = (0, sha256_1.sha256)(new TextEncoder().encode(content));
|
|
44
|
-
fileHashes[filename] = 'sha256:' + (0, utils_1.bytesToHex)(hash);
|
|
45
|
-
combinedHash += (0, utils_1.bytesToHex)(hash);
|
|
46
|
-
}
|
|
47
|
-
// Generate workspace hash
|
|
48
|
-
const workspaceHash = (0, sha256_1.sha256)(new TextEncoder().encode(combinedHash));
|
|
49
|
-
const timestamp = new Date().toISOString();
|
|
50
|
-
// Sign the audit
|
|
51
|
-
const message = `TAP_BOOT|${this.agentId}|${timestamp}|${(0, utils_1.bytesToHex)(workspaceHash)}`;
|
|
52
|
-
const signature = await (0, ed25519_1.sign)(new TextEncoder().encode(message), this.privateKey);
|
|
53
|
-
return {
|
|
54
|
-
agentId: this.agentId,
|
|
55
|
-
timestamp,
|
|
56
|
-
workspaceHash: 'sha256:' + (0, utils_1.bytesToHex)(workspaceHash),
|
|
57
|
-
configFiles: fileHashes,
|
|
58
|
-
complianceStatus: 'FULL',
|
|
59
|
-
signature: 'ed25519:' + (0, utils_1.bytesToHex)(signature)
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create a claim for the Trust Ledger
|
|
64
|
-
*/
|
|
65
|
-
async createClaim(claim) {
|
|
66
|
-
const fullClaim = {
|
|
67
|
-
...claim,
|
|
68
|
-
stakeAmount: this.stakeAmount
|
|
69
|
-
};
|
|
70
|
-
// Sign the claim
|
|
71
|
-
const message = `TAP_CLAIM|${claim.claimId}|${claim.statement}|${claim.threshold}|${this.stakeAmount}`;
|
|
72
|
-
const signature = await (0, ed25519_1.sign)(new TextEncoder().encode(message), this.privateKey);
|
|
73
|
-
// Submit to TAP network
|
|
74
|
-
const response = await fetch(`${this.apiUrl}/claims`, {
|
|
75
|
-
method: 'POST',
|
|
76
|
-
headers: { 'Content-Type': 'application/json' },
|
|
77
|
-
body: JSON.stringify({
|
|
78
|
-
...fullClaim,
|
|
79
|
-
agentId: this.agentId,
|
|
80
|
-
signature: (0, utils_1.bytesToHex)(signature)
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
if (!response.ok) {
|
|
84
|
-
throw new Error(`Failed to create claim: ${response.statusText}`);
|
|
85
|
-
}
|
|
86
|
-
return fullClaim;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Perform attestation on another agent's claim
|
|
90
|
-
*/
|
|
91
|
-
async attest(options) {
|
|
92
|
-
const { claimId, targetAgent, testRequests = 3 } = options;
|
|
93
|
-
// Fetch claim details
|
|
94
|
-
const claimResponse = await fetch(`${this.apiUrl}/claims/${claimId}`);
|
|
95
|
-
if (!claimResponse.ok) {
|
|
96
|
-
throw new Error('Claim not found');
|
|
97
|
-
}
|
|
98
|
-
const claim = await claimResponse.json();
|
|
99
|
-
// Perform verification tests
|
|
100
|
-
const measurements = [];
|
|
101
|
-
for (let i = 0; i < testRequests; i++) {
|
|
102
|
-
const start = Date.now();
|
|
103
|
-
// Call target agent's endpoint
|
|
104
|
-
const testResponse = await fetch(`${this.apiUrl}/agents/${targetAgent}/test`, {
|
|
105
|
-
method: 'POST',
|
|
106
|
-
body: JSON.stringify({ claimId })
|
|
107
|
-
});
|
|
108
|
-
const elapsed = Date.now() - start;
|
|
109
|
-
measurements.push(elapsed);
|
|
110
|
-
}
|
|
111
|
-
// Calculate result
|
|
112
|
-
const average = measurements.reduce((a, b) => a + b, 0) / measurements.length;
|
|
113
|
-
const result = average <= claim.threshold ? 'CONFIRMED' : 'REJECTED';
|
|
114
|
-
// Sign attestation
|
|
115
|
-
const timestamp = new Date().toISOString();
|
|
116
|
-
const message = `TAP_ATTEST|${claimId}|${result}|${average}|${timestamp}|${this.agentId}`;
|
|
117
|
-
const signature = await (0, ed25519_1.sign)(new TextEncoder().encode(message), this.privateKey);
|
|
118
|
-
const attestationResult = {
|
|
119
|
-
claimId,
|
|
120
|
-
result,
|
|
121
|
-
measuredValue: average,
|
|
122
|
-
threshold: claim.threshold,
|
|
123
|
-
timestamp,
|
|
124
|
-
signature: (0, utils_1.bytesToHex)(signature)
|
|
125
|
-
};
|
|
126
|
-
// Submit attestation
|
|
127
|
-
await fetch(`${this.apiUrl}/attestations`, {
|
|
128
|
-
method: 'POST',
|
|
129
|
-
headers: { 'Content-Type': 'application/json' },
|
|
130
|
-
body: JSON.stringify({
|
|
131
|
-
...attestationResult,
|
|
132
|
-
attestorId: this.agentId,
|
|
133
|
-
targetAgent
|
|
134
|
-
})
|
|
135
|
-
});
|
|
136
|
-
return attestationResult;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Batch attest multiple claims with BLS aggregation
|
|
140
|
-
*/
|
|
141
|
-
async attestBatch(claims) {
|
|
142
|
-
const results = [];
|
|
143
|
-
const signatures = [];
|
|
144
|
-
for (const claim of claims) {
|
|
145
|
-
const result = await this.attest(claim);
|
|
146
|
-
results.push(result);
|
|
147
|
-
signatures.push((0, utils_1.hexToBytes)(result.signature));
|
|
148
|
-
}
|
|
149
|
-
// Aggregate signatures
|
|
150
|
-
const aggregated = (0, bls12_381_1.aggregateSignatures)(signatures);
|
|
151
|
-
return {
|
|
152
|
-
aggregatedSignature: (0, utils_1.bytesToHex)(aggregated),
|
|
153
|
-
results
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
|
-
/**
|
|
157
|
-
* Verify another agent's attestation
|
|
158
|
-
*/
|
|
159
|
-
async verifyAttestation(attestation, attestorPublicKey) {
|
|
160
|
-
const message = `TAP_ATTEST|${attestation.claimId}|${attestation.result}|${attestation.measuredValue}|${attestation.timestamp}|${attestorPublicKey}`;
|
|
161
|
-
return (0, ed25519_1.verify)((0, utils_1.hexToBytes)(attestation.signature), new TextEncoder().encode(message), (0, utils_1.hexToBytes)(attestorPublicKey));
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Get agent's attestation history
|
|
165
|
-
*/
|
|
166
|
-
async getAttestationHistory(agentId) {
|
|
167
|
-
const targetAgent = agentId || this.agentId;
|
|
168
|
-
const response = await fetch(`${this.apiUrl}/agents/${targetAgent}/attestations`);
|
|
169
|
-
if (!response.ok) {
|
|
170
|
-
throw new Error('Failed to fetch attestation history');
|
|
171
|
-
}
|
|
172
|
-
return response.json();
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get live network stats
|
|
176
|
-
*/
|
|
177
|
-
async getNetworkStats() {
|
|
178
|
-
const response = await fetch(`${this.apiUrl}/stats`);
|
|
179
|
-
return response.json();
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
exports.TAPClient = TAPClient;
|
|
183
|
-
/**
|
|
184
|
-
* OpenClaw Skill Integration
|
|
185
|
-
*
|
|
186
|
-
* Usage: Drop this into ~/.openclaw/skills/tap/skill.js
|
|
187
|
-
*/
|
|
188
|
-
exports.tapSkill = {
|
|
189
|
-
name: 'tap_verify',
|
|
190
|
-
description: 'Run TAP cross-attestation before x402 payment',
|
|
191
|
-
async execute(input) {
|
|
192
|
-
const client = new TAPClient({
|
|
193
|
-
privateKey: input.privateKey,
|
|
194
|
-
agentId: input.agentId
|
|
195
|
-
});
|
|
196
|
-
return client.attest({
|
|
197
|
-
claimId: input.claimId,
|
|
198
|
-
targetAgent: input.targetAgent
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
/**
|
|
203
|
-
* x402 + TAP Integration
|
|
204
|
-
*
|
|
205
|
-
* Combines payment settlement with pre-payment verification
|
|
206
|
-
*/
|
|
207
|
-
class TAPx402Client extends TAPClient {
|
|
208
|
-
/**
|
|
209
|
-
* Pay for verified service (TAP attestation + x402 payment)
|
|
210
|
-
*/
|
|
211
|
-
async payForVerifiedService(options) {
|
|
212
|
-
const { endpoint, amount, claimId, x402Config } = options;
|
|
213
|
-
// Step 1: Extract target agent from endpoint
|
|
214
|
-
const targetAgent = await this.resolveAgentFromEndpoint(endpoint);
|
|
215
|
-
// Step 2: Run TAP attestation
|
|
216
|
-
const attestation = await this.attest({
|
|
217
|
-
claimId,
|
|
218
|
-
targetAgent
|
|
219
|
-
});
|
|
220
|
-
if (attestation.result !== 'CONFIRMED') {
|
|
221
|
-
throw new Error(`Attestation failed: ${attestation.result}`);
|
|
222
|
-
}
|
|
223
|
-
// Step 3: Include attestation in x402 payment
|
|
224
|
-
const attestationHash = (0, sha256_1.sha256)(new TextEncoder().encode(JSON.stringify(attestation)));
|
|
225
|
-
// Step 4: Execute x402 payment (placeholder - integrate with actual x402 SDK)
|
|
226
|
-
const paymentReceipt = await this.executeX402Payment({
|
|
227
|
-
endpoint,
|
|
228
|
-
amount,
|
|
229
|
-
extensions: {
|
|
230
|
-
tapAttestation: (0, utils_1.bytesToHex)(attestationHash),
|
|
231
|
-
attestorId: this.agentId
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
return {
|
|
235
|
-
attestationHash: (0, utils_1.bytesToHex)(attestationHash),
|
|
236
|
-
paymentReceipt
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
async resolveAgentFromEndpoint(endpoint) {
|
|
240
|
-
// Resolve agent ID from service endpoint
|
|
241
|
-
const response = await fetch(`${this.apiUrl}/resolve?endpoint=${encodeURIComponent(endpoint)}`);
|
|
242
|
-
const data = await response.json();
|
|
243
|
-
return data.agentId;
|
|
244
|
-
}
|
|
245
|
-
async executeX402Payment(options) {
|
|
246
|
-
// Integrate with x402 SDK
|
|
247
|
-
// This is a placeholder - actual implementation uses @x402/core
|
|
248
|
-
return { status: 'completed', txHash: '0x...' };
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.TAPx402Client = TAPx402Client;
|
|
252
|
-
// Export types
|
|
253
|
-
__exportStar(require("./types"), exports);
|
|
254
|
-
// Export full 6-layer OS
|
|
255
|
-
__exportStar(require("./protocols/arbitra/voting"), exports);
|
|
256
|
-
__exportStar(require("./protocols/clawlink/handoff"), exports);
|
|
257
|
-
__exportStar(require("./protocols/clawid/clawid-token"), exports);
|
|
258
|
-
__exportStar(require("./protocols/clawforge/control-plane"), exports);
|
|
259
|
-
__exportStar(require("./protocols/clawkernel/kernel"), exports);
|
|
26
|
+
exports.VERSION = exports.validateConfig = exports.loadConfig = exports.getApiClient = exports.initApiClient = exports.ApiClient = void 0;
|
|
27
|
+
// Core API client
|
|
28
|
+
var api_1 = require("./lib/api");
|
|
29
|
+
Object.defineProperty(exports, "ApiClient", { enumerable: true, get: function () { return api_1.ApiClient; } });
|
|
30
|
+
Object.defineProperty(exports, "initApiClient", { enumerable: true, get: function () { return api_1.initApiClient; } });
|
|
31
|
+
Object.defineProperty(exports, "getApiClient", { enumerable: true, get: function () { return api_1.getApiClient; } });
|
|
32
|
+
// Configuration
|
|
33
|
+
var config_1 = require("./lib/config");
|
|
34
|
+
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } });
|
|
35
|
+
Object.defineProperty(exports, "validateConfig", { enumerable: true, get: function () { return config_1.validateConfig; } });
|
|
36
|
+
// Core MoltOS Systems (will be implemented by sub-agents)
|
|
37
|
+
__exportStar(require("./lib/tap"), exports);
|
|
38
|
+
__exportStar(require("./lib/arbitra"), exports);
|
|
39
|
+
__exportStar(require("./lib/clawid"), exports);
|
|
40
|
+
__exportStar(require("./lib/clawfs"), exports);
|
|
41
|
+
// Version
|
|
42
|
+
exports.VERSION = '0.5.1';
|
|
260
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;AAEH,kBAAkB;AAClB,iCAA2F;AAAlF,gGAAA,SAAS,OAAA;AAA0B,oGAAA,aAAa,OAAA;AAAE,mGAAA,YAAY,OAAA;AAEvE,gBAAgB;AAChB,uCAAwE;AAAjD,oGAAA,UAAU,OAAA;AAAE,wGAAA,cAAc,OAAA;AAEjD,0DAA0D;AAC1D,4CAA0B;AAC1B,gDAA8B;AAC9B,+CAA6B;AAC7B,+CAA6B;AAE7B,UAAU;AACG,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Client for MoltOS SDK
|
|
3
|
+
* Handles authentication and API requests to the MoltOS backend
|
|
4
|
+
*/
|
|
5
|
+
import { AxiosRequestConfig } from 'axios';
|
|
6
|
+
export interface ApiConfig {
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
apiKey?: string;
|
|
9
|
+
timeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ApiResponse<T = unknown> {
|
|
12
|
+
success: boolean;
|
|
13
|
+
data?: T;
|
|
14
|
+
error?: {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare class ApiClient {
|
|
20
|
+
private client;
|
|
21
|
+
private config;
|
|
22
|
+
constructor(config: ApiConfig);
|
|
23
|
+
get<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
24
|
+
post<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
25
|
+
put<T>(path: string, data?: unknown, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
26
|
+
delete<T>(path: string, config?: AxiosRequestConfig): Promise<ApiResponse<T>>;
|
|
27
|
+
getBaseUrl(): string;
|
|
28
|
+
setApiKey(apiKey: string): void;
|
|
29
|
+
}
|
|
30
|
+
export declare function initApiClient(config: ApiConfig): ApiClient;
|
|
31
|
+
export declare function getApiClient(): ApiClient;
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C;IAKnF,UAAU,IAAI,MAAM;IAIpB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGhC;AAKD,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAG1D;AAED,wBAAgB,YAAY,IAAI,SAAS,CAKxC"}
|
package/dist/lib/api.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* API Client for MoltOS SDK
|
|
4
|
+
* Handles authentication and API requests to the MoltOS backend
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ApiClient = void 0;
|
|
11
|
+
exports.initApiClient = initApiClient;
|
|
12
|
+
exports.getApiClient = getApiClient;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
class ApiClient {
|
|
15
|
+
client;
|
|
16
|
+
config;
|
|
17
|
+
constructor(config) {
|
|
18
|
+
this.config = {
|
|
19
|
+
timeout: 30000,
|
|
20
|
+
...config,
|
|
21
|
+
};
|
|
22
|
+
this.client = axios_1.default.create({
|
|
23
|
+
baseURL: this.config.baseUrl,
|
|
24
|
+
timeout: this.config.timeout,
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
// Add request interceptor for auth
|
|
30
|
+
this.client.interceptors.request.use((config) => {
|
|
31
|
+
if (this.config.apiKey) {
|
|
32
|
+
config.headers.Authorization = `Bearer ${this.config.apiKey}`;
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
}, (error) => Promise.reject(error));
|
|
36
|
+
// Add response interceptor for error handling
|
|
37
|
+
this.client.interceptors.response.use((response) => response, (error) => {
|
|
38
|
+
if (error.response?.data) {
|
|
39
|
+
return Promise.resolve(error.response);
|
|
40
|
+
}
|
|
41
|
+
return Promise.reject(error);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async get(path, config) {
|
|
45
|
+
const response = await this.client.get(path, config);
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
async post(path, data, config) {
|
|
49
|
+
const response = await this.client.post(path, data, config);
|
|
50
|
+
return response.data;
|
|
51
|
+
}
|
|
52
|
+
async put(path, data, config) {
|
|
53
|
+
const response = await this.client.put(path, data, config);
|
|
54
|
+
return response.data;
|
|
55
|
+
}
|
|
56
|
+
async delete(path, config) {
|
|
57
|
+
const response = await this.client.delete(path, config);
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
getBaseUrl() {
|
|
61
|
+
return this.config.baseUrl;
|
|
62
|
+
}
|
|
63
|
+
setApiKey(apiKey) {
|
|
64
|
+
this.config.apiKey = apiKey;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.ApiClient = ApiClient;
|
|
68
|
+
// Default API client instance
|
|
69
|
+
let defaultClient = null;
|
|
70
|
+
function initApiClient(config) {
|
|
71
|
+
defaultClient = new ApiClient(config);
|
|
72
|
+
return defaultClient;
|
|
73
|
+
}
|
|
74
|
+
function getApiClient() {
|
|
75
|
+
if (!defaultClient) {
|
|
76
|
+
throw new Error('API client not initialized. Call initApiClient first.');
|
|
77
|
+
}
|
|
78
|
+
return defaultClient;
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AA4FH,sCAGC;AAED,oCAKC;AApGD,kDAA6E;AAiB7E,MAAa,SAAS;IACZ,MAAM,CAAgB;IACtB,MAAM,CAAY;IAE1B,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,KAA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