clawdentials-mcp 0.1.0 → 0.7.2
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/README.md +310 -58
- package/dist/index.d.ts +1 -1
- package/dist/index.js +225 -18
- package/dist/schemas/index.d.ts +141 -0
- package/dist/schemas/index.js +54 -0
- package/dist/services/firestore.d.ts +45 -2
- package/dist/services/firestore.js +410 -6
- package/dist/services/payments/alby.d.ts +104 -0
- package/dist/services/payments/alby.js +239 -0
- package/dist/services/payments/breez.d.ts +91 -0
- package/dist/services/payments/breez.js +267 -0
- package/dist/services/payments/cashu.d.ts +127 -0
- package/dist/services/payments/cashu.js +248 -0
- package/dist/services/payments/coinremitter.d.ts +84 -0
- package/dist/services/payments/coinremitter.js +176 -0
- package/dist/services/payments/index.d.ts +132 -0
- package/dist/services/payments/index.js +180 -0
- package/dist/services/payments/oxapay.d.ts +89 -0
- package/dist/services/payments/oxapay.js +221 -0
- package/dist/services/payments/x402.d.ts +61 -0
- package/dist/services/payments/x402.js +94 -0
- package/dist/services/payments/zbd.d.ts +88 -0
- package/dist/services/payments/zbd.js +221 -0
- package/dist/tools/admin.d.ts +195 -0
- package/dist/tools/admin.js +210 -0
- package/dist/tools/agent.d.ts +197 -0
- package/dist/tools/agent.js +200 -0
- package/dist/tools/escrow.d.ts +74 -16
- package/dist/tools/escrow.js +139 -28
- package/dist/tools/index.d.ts +3 -0
- package/dist/tools/index.js +3 -0
- package/dist/tools/payment.d.ts +144 -0
- package/dist/tools/payment.js +376 -0
- package/dist/types/index.d.ts +44 -1
- package/package.json +18 -2
package/dist/index.js
CHANGED
|
@@ -1,53 +1,260 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import 'dotenv/config';
|
|
2
3
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
5
|
import { z } from 'zod';
|
|
5
|
-
import { escrowTools } from './tools/index.js';
|
|
6
|
+
import { escrowTools, agentTools, adminTools, paymentTools } from './tools/index.js';
|
|
6
7
|
import { initFirestore } from './services/firestore.js';
|
|
7
|
-
//
|
|
8
|
+
// ============ CLI REGISTRATION GATEWAY ============
|
|
9
|
+
// Enables one-shot registration without MCP config:
|
|
10
|
+
// npx clawdentials-mcp --register "AgentName" --skills "coding,research" --description "What I do"
|
|
11
|
+
async function handleCliRegistration() {
|
|
12
|
+
const args = process.argv.slice(2);
|
|
13
|
+
// Check for --register flag
|
|
14
|
+
const registerIndex = args.indexOf('--register');
|
|
15
|
+
if (registerIndex === -1) {
|
|
16
|
+
return false; // No CLI registration, continue with MCP server
|
|
17
|
+
}
|
|
18
|
+
// Initialize Firestore for CLI mode
|
|
19
|
+
initFirestore();
|
|
20
|
+
// Parse arguments
|
|
21
|
+
const name = args[registerIndex + 1];
|
|
22
|
+
const skillsIndex = args.indexOf('--skills');
|
|
23
|
+
const descIndex = args.indexOf('--description');
|
|
24
|
+
if (!name) {
|
|
25
|
+
console.error('Error: --register requires an agent name');
|
|
26
|
+
console.error('Usage: npx clawdentials-mcp --register "AgentName" --skills "coding,research" --description "What I do"');
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
const skillsRaw = skillsIndex !== -1 ? args[skillsIndex + 1] : 'general';
|
|
30
|
+
const description = descIndex !== -1 ? args[descIndex + 1] : `Agent: ${name}`;
|
|
31
|
+
// Parse skills (comma-separated)
|
|
32
|
+
const skills = skillsRaw.split(',').map(s => s.trim()).filter(Boolean);
|
|
33
|
+
console.log('\n╔════════════════════════════════════════════════════════════╗');
|
|
34
|
+
console.log('║ CLAWDENTIALS AGENT REGISTRATION ║');
|
|
35
|
+
console.log('╚════════════════════════════════════════════════════════════╝\n');
|
|
36
|
+
console.log(`Registering agent: ${name}`);
|
|
37
|
+
console.log(`Skills: ${skills.join(', ')}`);
|
|
38
|
+
console.log(`Description: ${description}\n`);
|
|
39
|
+
try {
|
|
40
|
+
const result = await agentTools.agent_register.handler({
|
|
41
|
+
name,
|
|
42
|
+
description,
|
|
43
|
+
skills,
|
|
44
|
+
});
|
|
45
|
+
if (!result.success) {
|
|
46
|
+
console.error(`\n❌ Registration failed: ${result.error}`);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
console.log('✅ Registration successful!\n');
|
|
50
|
+
console.log('═'.repeat(60));
|
|
51
|
+
console.log('⚠️ SAVE THESE CREDENTIALS - THEY CANNOT BE RECOVERED!');
|
|
52
|
+
console.log('═'.repeat(60));
|
|
53
|
+
console.log('\n📋 AGENT DETAILS:');
|
|
54
|
+
console.log(` ID: ${result.agent?.id}`);
|
|
55
|
+
console.log(` Name: ${result.agent?.name}`);
|
|
56
|
+
console.log(` NIP-05: ${result.credentials?.nostr?.nip05}`);
|
|
57
|
+
console.log('\n🔑 API KEY (use this to authenticate):');
|
|
58
|
+
console.log(` ${result.credentials?.apiKey}`);
|
|
59
|
+
console.log('\n🔐 NOSTR IDENTITY:');
|
|
60
|
+
console.log(` npub: ${result.credentials?.nostr?.npub}`);
|
|
61
|
+
console.log(` nsec: ${result.credentials?.nostr?.nsec}`);
|
|
62
|
+
console.log('\n═'.repeat(60));
|
|
63
|
+
console.log('\n📖 NEXT STEPS:');
|
|
64
|
+
console.log(' 1. Save your API key and Nostr credentials securely');
|
|
65
|
+
console.log(' 2. Add MCP server to claude_desktop_config.json:');
|
|
66
|
+
console.log(' {');
|
|
67
|
+
console.log(' "mcpServers": {');
|
|
68
|
+
console.log(' "clawdentials": {');
|
|
69
|
+
console.log(' "command": "npx",');
|
|
70
|
+
console.log(' "args": ["clawdentials-mcp"]');
|
|
71
|
+
console.log(' }');
|
|
72
|
+
console.log(' }');
|
|
73
|
+
console.log(' }');
|
|
74
|
+
console.log(' 3. Restart Claude Desktop');
|
|
75
|
+
console.log(' 4. Start completing escrowed tasks to build reputation!');
|
|
76
|
+
// Output JSON for programmatic capture
|
|
77
|
+
if (args.includes('--json')) {
|
|
78
|
+
console.log('\n📄 JSON OUTPUT:');
|
|
79
|
+
console.log(JSON.stringify(result, null, 2));
|
|
80
|
+
}
|
|
81
|
+
process.exit(0);
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
console.error('\n❌ Registration error:', error);
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Check for CLI registration mode first
|
|
89
|
+
const isCli = await handleCliRegistration();
|
|
90
|
+
// Initialize Firestore for MCP server mode
|
|
8
91
|
initFirestore();
|
|
9
92
|
// Create MCP server
|
|
10
93
|
const server = new McpServer({
|
|
11
94
|
name: 'clawdentials',
|
|
12
|
-
version: '0.
|
|
95
|
+
version: '0.7.2',
|
|
13
96
|
});
|
|
14
|
-
//
|
|
97
|
+
// ============ ESCROW TOOLS ============
|
|
15
98
|
server.tool('escrow_create', escrowTools.escrow_create.description, {
|
|
16
99
|
taskDescription: z.string().describe('Description of the task to be completed'),
|
|
17
|
-
amount: z.number().positive().describe('Amount to escrow
|
|
18
|
-
currency: z.enum(['USD', 'USDC', 'BTC']).default('USD').describe('Currency
|
|
100
|
+
amount: z.number().positive().describe('Amount to escrow'),
|
|
101
|
+
currency: z.enum(['USD', 'USDC', 'USDT', 'BTC']).default('USD').describe('Currency'),
|
|
19
102
|
providerAgentId: z.string().describe('ID of the agent who will complete the task'),
|
|
20
103
|
clientAgentId: z.string().describe('ID of the agent creating the escrow'),
|
|
104
|
+
apiKey: z.string().describe('API key for the client agent'),
|
|
21
105
|
}, async (args) => {
|
|
22
106
|
const result = await escrowTools.escrow_create.handler(args);
|
|
23
|
-
return {
|
|
24
|
-
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
25
|
-
};
|
|
107
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
26
108
|
});
|
|
27
|
-
// Register escrow_complete tool
|
|
28
109
|
server.tool('escrow_complete', escrowTools.escrow_complete.description, {
|
|
29
110
|
escrowId: z.string().describe('ID of the escrow to complete'),
|
|
30
111
|
proofOfWork: z.string().describe('Proof that the task was completed'),
|
|
112
|
+
apiKey: z.string().describe('API key for the provider agent'),
|
|
31
113
|
}, async (args) => {
|
|
32
114
|
const result = await escrowTools.escrow_complete.handler(args);
|
|
33
|
-
return {
|
|
34
|
-
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
35
|
-
};
|
|
115
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
36
116
|
});
|
|
37
|
-
// Register escrow_status tool
|
|
38
117
|
server.tool('escrow_status', escrowTools.escrow_status.description, {
|
|
39
118
|
escrowId: z.string().describe('ID of the escrow to check'),
|
|
40
119
|
}, async (args) => {
|
|
41
120
|
const result = await escrowTools.escrow_status.handler(args);
|
|
42
|
-
return {
|
|
43
|
-
|
|
44
|
-
|
|
121
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
122
|
+
});
|
|
123
|
+
server.tool('escrow_dispute', escrowTools.escrow_dispute.description, {
|
|
124
|
+
escrowId: z.string().describe('ID of the escrow to dispute'),
|
|
125
|
+
reason: z.string().describe('Reason for the dispute'),
|
|
126
|
+
apiKey: z.string().describe('API key for the client agent'),
|
|
127
|
+
}, async (args) => {
|
|
128
|
+
const result = await escrowTools.escrow_dispute.handler(args);
|
|
129
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
130
|
+
});
|
|
131
|
+
// ============ AGENT TOOLS ============
|
|
132
|
+
server.tool('agent_register', agentTools.agent_register.description, {
|
|
133
|
+
name: z.string().describe('Unique name/identifier for the agent'),
|
|
134
|
+
description: z.string().describe('Brief description of what this agent does'),
|
|
135
|
+
skills: z.array(z.string()).describe('List of skills/capabilities'),
|
|
136
|
+
}, async (args) => {
|
|
137
|
+
const result = await agentTools.agent_register.handler(args);
|
|
138
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
139
|
+
});
|
|
140
|
+
server.tool('agent_score', agentTools.agent_score.description, {
|
|
141
|
+
agentId: z.string().describe('ID of the agent to get the reputation score for'),
|
|
142
|
+
}, async (args) => {
|
|
143
|
+
const result = await agentTools.agent_score.handler(args);
|
|
144
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
145
|
+
});
|
|
146
|
+
server.tool('agent_search', agentTools.agent_search.description, {
|
|
147
|
+
skill: z.string().optional().describe('Filter by skill (partial match)'),
|
|
148
|
+
verified: z.boolean().optional().describe('Filter by verified status'),
|
|
149
|
+
minTasksCompleted: z.number().optional().describe('Minimum completed tasks'),
|
|
150
|
+
limit: z.number().optional().default(20).describe('Max results'),
|
|
151
|
+
}, async (args) => {
|
|
152
|
+
const result = await agentTools.agent_search.handler(args);
|
|
153
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
154
|
+
});
|
|
155
|
+
server.tool('agent_balance', agentTools.agent_balance.description, {
|
|
156
|
+
agentId: z.string().describe('ID of the agent'),
|
|
157
|
+
apiKey: z.string().describe('API key for the agent'),
|
|
158
|
+
}, async (args) => {
|
|
159
|
+
const result = await agentTools.agent_balance.handler(args);
|
|
160
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
161
|
+
});
|
|
162
|
+
server.tool('withdraw_request', agentTools.withdraw_request.description, {
|
|
163
|
+
agentId: z.string().describe('ID of the agent'),
|
|
164
|
+
apiKey: z.string().describe('API key for the agent'),
|
|
165
|
+
amount: z.number().positive().describe('Amount to withdraw'),
|
|
166
|
+
currency: z.enum(['USD', 'USDC', 'USDT', 'BTC']).default('USD').describe('Currency'),
|
|
167
|
+
paymentMethod: z.string().describe('Payment method (e.g., "PayPal: email@example.com")'),
|
|
168
|
+
}, async (args) => {
|
|
169
|
+
const result = await agentTools.withdraw_request.handler(args);
|
|
170
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
171
|
+
});
|
|
172
|
+
// ============ ADMIN TOOLS ============
|
|
173
|
+
server.tool('admin_credit_balance', adminTools.admin_credit_balance.description, {
|
|
174
|
+
adminSecret: z.string().describe('Admin secret key'),
|
|
175
|
+
agentId: z.string().describe('ID of the agent to credit'),
|
|
176
|
+
amount: z.number().positive().describe('Amount to credit'),
|
|
177
|
+
currency: z.enum(['USD', 'USDC', 'USDT', 'BTC']).default('USD').describe('Currency'),
|
|
178
|
+
notes: z.string().optional().describe('Notes (e.g., "PayPal payment received")'),
|
|
179
|
+
}, async (args) => {
|
|
180
|
+
const result = await adminTools.admin_credit_balance.handler(args);
|
|
181
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
182
|
+
});
|
|
183
|
+
server.tool('admin_list_withdrawals', adminTools.admin_list_withdrawals.description, {
|
|
184
|
+
adminSecret: z.string().describe('Admin secret key'),
|
|
185
|
+
status: z.enum(['pending', 'processing', 'completed', 'rejected']).optional().describe('Filter by status'),
|
|
186
|
+
limit: z.number().optional().default(50).describe('Max results'),
|
|
187
|
+
}, async (args) => {
|
|
188
|
+
const result = await adminTools.admin_list_withdrawals.handler(args);
|
|
189
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
190
|
+
});
|
|
191
|
+
server.tool('admin_process_withdrawal', adminTools.admin_process_withdrawal.description, {
|
|
192
|
+
adminSecret: z.string().describe('Admin secret key'),
|
|
193
|
+
withdrawalId: z.string().describe('ID of the withdrawal'),
|
|
194
|
+
action: z.enum(['complete', 'reject']).describe('Action to take'),
|
|
195
|
+
notes: z.string().optional().describe('Notes'),
|
|
196
|
+
}, async (args) => {
|
|
197
|
+
const result = await adminTools.admin_process_withdrawal.handler(args);
|
|
198
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
199
|
+
});
|
|
200
|
+
server.tool('admin_refund_escrow', adminTools.admin_refund_escrow.description, {
|
|
201
|
+
adminSecret: z.string().describe('Admin secret key'),
|
|
202
|
+
escrowId: z.string().describe('ID of the disputed escrow to refund'),
|
|
203
|
+
}, async (args) => {
|
|
204
|
+
const result = await adminTools.admin_refund_escrow.handler(args);
|
|
205
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
206
|
+
});
|
|
207
|
+
server.tool('admin_nostr_json', adminTools.admin_nostr_json.description, {
|
|
208
|
+
adminSecret: z.string().describe('Admin secret key'),
|
|
209
|
+
}, async (args) => {
|
|
210
|
+
const result = await adminTools.admin_nostr_json.handler(args);
|
|
211
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
212
|
+
});
|
|
213
|
+
// ============ PAYMENT TOOLS ============
|
|
214
|
+
server.tool('deposit_create', paymentTools.deposit_create.description, {
|
|
215
|
+
agentId: z.string().describe('ID of the agent making the deposit'),
|
|
216
|
+
apiKey: z.string().describe('API key for the agent'),
|
|
217
|
+
amount: z.number().positive().describe('Amount to deposit in USD'),
|
|
218
|
+
currency: z.enum(['USDC', 'USDT', 'BTC']).describe('Cryptocurrency to deposit'),
|
|
219
|
+
}, async (args) => {
|
|
220
|
+
const result = await paymentTools.deposit_create.handler(args);
|
|
221
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
222
|
+
});
|
|
223
|
+
server.tool('deposit_status', paymentTools.deposit_status.description, {
|
|
224
|
+
depositId: z.string().describe('ID of the deposit to check'),
|
|
225
|
+
}, async (args) => {
|
|
226
|
+
const result = await paymentTools.deposit_status.handler(args);
|
|
227
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
228
|
+
});
|
|
229
|
+
server.tool('payment_config', paymentTools.payment_config.description, {}, async () => {
|
|
230
|
+
const result = await paymentTools.payment_config.handler();
|
|
231
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
232
|
+
});
|
|
233
|
+
server.tool('withdraw_crypto', paymentTools.withdraw_crypto.description, {
|
|
234
|
+
agentId: z.string().describe('ID of the agent'),
|
|
235
|
+
apiKey: z.string().describe('API key for the agent'),
|
|
236
|
+
amount: z.number().positive().describe('Amount to withdraw in USD'),
|
|
237
|
+
currency: z.enum(['USDC', 'USDT', 'BTC']).describe('Cryptocurrency for withdrawal'),
|
|
238
|
+
destination: z.string().describe('Wallet address (USDC/USDT) or Lightning invoice/address (BTC)'),
|
|
239
|
+
}, async (args) => {
|
|
240
|
+
const result = await paymentTools.withdraw_crypto.handler(args);
|
|
241
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
242
|
+
});
|
|
243
|
+
server.tool('agent_set_wallets', paymentTools.agent_set_wallets.description, {
|
|
244
|
+
agentId: z.string().describe('ID of the agent'),
|
|
245
|
+
apiKey: z.string().describe('API key for the agent'),
|
|
246
|
+
baseAddress: z.string().optional().describe('Base/EVM address for USDC (0x...)'),
|
|
247
|
+
trc20Address: z.string().optional().describe('TRC-20 address for USDT (T...)'),
|
|
248
|
+
lightningAddress: z.string().optional().describe('Lightning Address for BTC (user@domain)'),
|
|
249
|
+
}, async (args) => {
|
|
250
|
+
const result = await paymentTools.agent_set_wallets.handler(args);
|
|
251
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
45
252
|
});
|
|
46
253
|
// Start server
|
|
47
254
|
async function main() {
|
|
48
255
|
const transport = new StdioServerTransport();
|
|
49
256
|
await server.connect(transport);
|
|
50
|
-
console.error('Clawdentials MCP server running on stdio');
|
|
257
|
+
console.error('Clawdentials MCP server v0.7.2 running on stdio');
|
|
51
258
|
}
|
|
52
259
|
main().catch((error) => {
|
|
53
260
|
console.error('Fatal error:', error);
|
package/dist/schemas/index.d.ts
CHANGED
|
@@ -5,26 +5,32 @@ export declare const escrowCreateSchema: z.ZodObject<{
|
|
|
5
5
|
currency: z.ZodDefault<z.ZodEnum<["USD", "USDC", "BTC"]>>;
|
|
6
6
|
providerAgentId: z.ZodString;
|
|
7
7
|
clientAgentId: z.ZodString;
|
|
8
|
+
apiKey: z.ZodString;
|
|
8
9
|
}, "strip", z.ZodTypeAny, {
|
|
9
10
|
taskDescription: string;
|
|
10
11
|
amount: number;
|
|
11
12
|
currency: "USD" | "USDC" | "BTC";
|
|
12
13
|
providerAgentId: string;
|
|
13
14
|
clientAgentId: string;
|
|
15
|
+
apiKey: string;
|
|
14
16
|
}, {
|
|
15
17
|
taskDescription: string;
|
|
16
18
|
amount: number;
|
|
17
19
|
providerAgentId: string;
|
|
18
20
|
clientAgentId: string;
|
|
21
|
+
apiKey: string;
|
|
19
22
|
currency?: "USD" | "USDC" | "BTC" | undefined;
|
|
20
23
|
}>;
|
|
21
24
|
export declare const escrowCompleteSchema: z.ZodObject<{
|
|
22
25
|
escrowId: z.ZodString;
|
|
23
26
|
proofOfWork: z.ZodString;
|
|
27
|
+
apiKey: z.ZodString;
|
|
24
28
|
}, "strip", z.ZodTypeAny, {
|
|
29
|
+
apiKey: string;
|
|
25
30
|
escrowId: string;
|
|
26
31
|
proofOfWork: string;
|
|
27
32
|
}, {
|
|
33
|
+
apiKey: string;
|
|
28
34
|
escrowId: string;
|
|
29
35
|
proofOfWork: string;
|
|
30
36
|
}>;
|
|
@@ -35,6 +41,141 @@ export declare const escrowStatusSchema: z.ZodObject<{
|
|
|
35
41
|
}, {
|
|
36
42
|
escrowId: string;
|
|
37
43
|
}>;
|
|
44
|
+
export declare const escrowDisputeSchema: z.ZodObject<{
|
|
45
|
+
escrowId: z.ZodString;
|
|
46
|
+
reason: z.ZodString;
|
|
47
|
+
apiKey: z.ZodString;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
apiKey: string;
|
|
50
|
+
escrowId: string;
|
|
51
|
+
reason: string;
|
|
52
|
+
}, {
|
|
53
|
+
apiKey: string;
|
|
54
|
+
escrowId: string;
|
|
55
|
+
reason: string;
|
|
56
|
+
}>;
|
|
57
|
+
export declare const agentRegisterSchema: z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
description: z.ZodString;
|
|
60
|
+
skills: z.ZodArray<z.ZodString, "many">;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
name: string;
|
|
63
|
+
description: string;
|
|
64
|
+
skills: string[];
|
|
65
|
+
}, {
|
|
66
|
+
name: string;
|
|
67
|
+
description: string;
|
|
68
|
+
skills: string[];
|
|
69
|
+
}>;
|
|
70
|
+
export declare const agentScoreSchema: z.ZodObject<{
|
|
71
|
+
agentId: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
agentId: string;
|
|
74
|
+
}, {
|
|
75
|
+
agentId: string;
|
|
76
|
+
}>;
|
|
77
|
+
export declare const agentSearchSchema: z.ZodObject<{
|
|
78
|
+
skill: z.ZodOptional<z.ZodString>;
|
|
79
|
+
verified: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
minTasksCompleted: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
limit: number;
|
|
84
|
+
skill?: string | undefined;
|
|
85
|
+
verified?: boolean | undefined;
|
|
86
|
+
minTasksCompleted?: number | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
skill?: string | undefined;
|
|
89
|
+
verified?: boolean | undefined;
|
|
90
|
+
minTasksCompleted?: number | undefined;
|
|
91
|
+
limit?: number | undefined;
|
|
92
|
+
}>;
|
|
93
|
+
export declare const agentBalanceSchema: z.ZodObject<{
|
|
94
|
+
agentId: z.ZodString;
|
|
95
|
+
apiKey: z.ZodString;
|
|
96
|
+
}, "strip", z.ZodTypeAny, {
|
|
97
|
+
apiKey: string;
|
|
98
|
+
agentId: string;
|
|
99
|
+
}, {
|
|
100
|
+
apiKey: string;
|
|
101
|
+
agentId: string;
|
|
102
|
+
}>;
|
|
103
|
+
export declare const withdrawRequestSchema: z.ZodObject<{
|
|
104
|
+
agentId: z.ZodString;
|
|
105
|
+
apiKey: z.ZodString;
|
|
106
|
+
amount: z.ZodNumber;
|
|
107
|
+
currency: z.ZodDefault<z.ZodEnum<["USD", "USDC", "BTC"]>>;
|
|
108
|
+
paymentMethod: z.ZodString;
|
|
109
|
+
}, "strip", z.ZodTypeAny, {
|
|
110
|
+
amount: number;
|
|
111
|
+
currency: "USD" | "USDC" | "BTC";
|
|
112
|
+
apiKey: string;
|
|
113
|
+
agentId: string;
|
|
114
|
+
paymentMethod: string;
|
|
115
|
+
}, {
|
|
116
|
+
amount: number;
|
|
117
|
+
apiKey: string;
|
|
118
|
+
agentId: string;
|
|
119
|
+
paymentMethod: string;
|
|
120
|
+
currency?: "USD" | "USDC" | "BTC" | undefined;
|
|
121
|
+
}>;
|
|
122
|
+
export declare const adminCreditBalanceSchema: z.ZodObject<{
|
|
123
|
+
adminSecret: z.ZodString;
|
|
124
|
+
agentId: z.ZodString;
|
|
125
|
+
amount: z.ZodNumber;
|
|
126
|
+
currency: z.ZodDefault<z.ZodEnum<["USD", "USDC", "BTC"]>>;
|
|
127
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, "strip", z.ZodTypeAny, {
|
|
129
|
+
amount: number;
|
|
130
|
+
currency: "USD" | "USDC" | "BTC";
|
|
131
|
+
agentId: string;
|
|
132
|
+
adminSecret: string;
|
|
133
|
+
notes?: string | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
amount: number;
|
|
136
|
+
agentId: string;
|
|
137
|
+
adminSecret: string;
|
|
138
|
+
currency?: "USD" | "USDC" | "BTC" | undefined;
|
|
139
|
+
notes?: string | undefined;
|
|
140
|
+
}>;
|
|
141
|
+
export declare const adminProcessWithdrawalSchema: z.ZodObject<{
|
|
142
|
+
adminSecret: z.ZodString;
|
|
143
|
+
withdrawalId: z.ZodString;
|
|
144
|
+
action: z.ZodEnum<["complete", "reject"]>;
|
|
145
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
146
|
+
}, "strip", z.ZodTypeAny, {
|
|
147
|
+
adminSecret: string;
|
|
148
|
+
withdrawalId: string;
|
|
149
|
+
action: "complete" | "reject";
|
|
150
|
+
notes?: string | undefined;
|
|
151
|
+
}, {
|
|
152
|
+
adminSecret: string;
|
|
153
|
+
withdrawalId: string;
|
|
154
|
+
action: "complete" | "reject";
|
|
155
|
+
notes?: string | undefined;
|
|
156
|
+
}>;
|
|
157
|
+
export declare const adminListWithdrawalsSchema: z.ZodObject<{
|
|
158
|
+
adminSecret: z.ZodString;
|
|
159
|
+
status: z.ZodOptional<z.ZodEnum<["pending", "processing", "completed", "rejected"]>>;
|
|
160
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
161
|
+
}, "strip", z.ZodTypeAny, {
|
|
162
|
+
limit: number;
|
|
163
|
+
adminSecret: string;
|
|
164
|
+
status?: "pending" | "processing" | "completed" | "rejected" | undefined;
|
|
165
|
+
}, {
|
|
166
|
+
adminSecret: string;
|
|
167
|
+
status?: "pending" | "processing" | "completed" | "rejected" | undefined;
|
|
168
|
+
limit?: number | undefined;
|
|
169
|
+
}>;
|
|
38
170
|
export type EscrowCreateInput = z.infer<typeof escrowCreateSchema>;
|
|
39
171
|
export type EscrowCompleteInput = z.infer<typeof escrowCompleteSchema>;
|
|
40
172
|
export type EscrowStatusInput = z.infer<typeof escrowStatusSchema>;
|
|
173
|
+
export type EscrowDisputeInput = z.infer<typeof escrowDisputeSchema>;
|
|
174
|
+
export type AgentRegisterInput = z.infer<typeof agentRegisterSchema>;
|
|
175
|
+
export type AgentScoreInput = z.infer<typeof agentScoreSchema>;
|
|
176
|
+
export type AgentSearchInput = z.infer<typeof agentSearchSchema>;
|
|
177
|
+
export type AgentBalanceInput = z.infer<typeof agentBalanceSchema>;
|
|
178
|
+
export type WithdrawRequestInput = z.infer<typeof withdrawRequestSchema>;
|
|
179
|
+
export type AdminCreditBalanceInput = z.infer<typeof adminCreditBalanceSchema>;
|
|
180
|
+
export type AdminProcessWithdrawalInput = z.infer<typeof adminProcessWithdrawalSchema>;
|
|
181
|
+
export type AdminListWithdrawalsInput = z.infer<typeof adminListWithdrawalsSchema>;
|
package/dist/schemas/index.js
CHANGED
|
@@ -1,15 +1,69 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
// Escrow schemas
|
|
2
3
|
export const escrowCreateSchema = z.object({
|
|
3
4
|
taskDescription: z.string().min(1).describe('Description of the task to be completed'),
|
|
4
5
|
amount: z.number().positive().describe('Amount to escrow in the specified currency'),
|
|
5
6
|
currency: z.enum(['USD', 'USDC', 'BTC']).default('USD').describe('Currency for the escrow'),
|
|
6
7
|
providerAgentId: z.string().min(1).describe('ID of the agent who will complete the task'),
|
|
7
8
|
clientAgentId: z.string().min(1).describe('ID of the agent creating the escrow'),
|
|
9
|
+
apiKey: z.string().min(1).describe('API key for the client agent (from agent_register)'),
|
|
8
10
|
});
|
|
9
11
|
export const escrowCompleteSchema = z.object({
|
|
10
12
|
escrowId: z.string().min(1).describe('ID of the escrow to complete'),
|
|
11
13
|
proofOfWork: z.string().min(1).describe('Proof that the task was completed (e.g., result summary, link, hash)'),
|
|
14
|
+
apiKey: z.string().min(1).describe('API key for the provider agent'),
|
|
12
15
|
});
|
|
13
16
|
export const escrowStatusSchema = z.object({
|
|
14
17
|
escrowId: z.string().min(1).describe('ID of the escrow to check'),
|
|
15
18
|
});
|
|
19
|
+
export const escrowDisputeSchema = z.object({
|
|
20
|
+
escrowId: z.string().min(1).describe('ID of the escrow to dispute'),
|
|
21
|
+
reason: z.string().min(1).describe('Reason for the dispute'),
|
|
22
|
+
apiKey: z.string().min(1).describe('API key for the disputing agent (client)'),
|
|
23
|
+
});
|
|
24
|
+
// Agent schemas
|
|
25
|
+
export const agentRegisterSchema = z.object({
|
|
26
|
+
name: z.string().min(1).max(64).describe('Unique name/identifier for the agent'),
|
|
27
|
+
description: z.string().min(1).max(500).describe('Brief description of what this agent does'),
|
|
28
|
+
skills: z.array(z.string()).min(1).describe('List of skills/capabilities (e.g., ["research", "coding", "data-analysis"])'),
|
|
29
|
+
});
|
|
30
|
+
export const agentScoreSchema = z.object({
|
|
31
|
+
agentId: z.string().min(1).describe('ID of the agent to get the reputation score for'),
|
|
32
|
+
});
|
|
33
|
+
export const agentSearchSchema = z.object({
|
|
34
|
+
skill: z.string().optional().describe('Filter by skill (partial match)'),
|
|
35
|
+
verified: z.boolean().optional().describe('Filter by verified status'),
|
|
36
|
+
minTasksCompleted: z.number().int().min(0).optional().describe('Minimum number of completed tasks'),
|
|
37
|
+
limit: z.number().int().min(1).max(100).default(20).describe('Maximum number of results to return'),
|
|
38
|
+
});
|
|
39
|
+
// Balance schemas
|
|
40
|
+
export const agentBalanceSchema = z.object({
|
|
41
|
+
agentId: z.string().min(1).describe('ID of the agent'),
|
|
42
|
+
apiKey: z.string().min(1).describe('API key for the agent'),
|
|
43
|
+
});
|
|
44
|
+
export const withdrawRequestSchema = z.object({
|
|
45
|
+
agentId: z.string().min(1).describe('ID of the agent requesting withdrawal'),
|
|
46
|
+
apiKey: z.string().min(1).describe('API key for the agent'),
|
|
47
|
+
amount: z.number().positive().describe('Amount to withdraw'),
|
|
48
|
+
currency: z.enum(['USD', 'USDC', 'BTC']).default('USD').describe('Currency'),
|
|
49
|
+
paymentMethod: z.string().min(1).describe('Payment method details (e.g., "PayPal: email@example.com")'),
|
|
50
|
+
});
|
|
51
|
+
// Admin schemas (require admin secret)
|
|
52
|
+
export const adminCreditBalanceSchema = z.object({
|
|
53
|
+
adminSecret: z.string().min(1).describe('Admin secret key'),
|
|
54
|
+
agentId: z.string().min(1).describe('ID of the agent to credit'),
|
|
55
|
+
amount: z.number().positive().describe('Amount to credit'),
|
|
56
|
+
currency: z.enum(['USD', 'USDC', 'BTC']).default('USD').describe('Currency'),
|
|
57
|
+
notes: z.string().optional().describe('Notes (e.g., "PayPal payment received")'),
|
|
58
|
+
});
|
|
59
|
+
export const adminProcessWithdrawalSchema = z.object({
|
|
60
|
+
adminSecret: z.string().min(1).describe('Admin secret key'),
|
|
61
|
+
withdrawalId: z.string().min(1).describe('ID of the withdrawal to process'),
|
|
62
|
+
action: z.enum(['complete', 'reject']).describe('Action to take'),
|
|
63
|
+
notes: z.string().optional().describe('Notes about the processing'),
|
|
64
|
+
});
|
|
65
|
+
export const adminListWithdrawalsSchema = z.object({
|
|
66
|
+
adminSecret: z.string().min(1).describe('Admin secret key'),
|
|
67
|
+
status: z.enum(['pending', 'processing', 'completed', 'rejected']).optional().describe('Filter by status'),
|
|
68
|
+
limit: z.number().int().min(1).max(100).default(50).describe('Max results'),
|
|
69
|
+
});
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Firestore } from 'firebase-admin/firestore';
|
|
2
|
-
import type { Escrow } from '../types/index.js';
|
|
2
|
+
import type { Escrow, Agent, Withdrawal, Currency } from '../types/index.js';
|
|
3
|
+
export declare const FEE_RATE = 0.1;
|
|
4
|
+
export declare const ADMIN_SECRET: string;
|
|
5
|
+
export declare function generateApiKey(): string;
|
|
6
|
+
export declare function hashApiKey(apiKey: string): string;
|
|
7
|
+
export declare function generateNostrKeypair(): {
|
|
8
|
+
secretKey: Uint8Array;
|
|
9
|
+
publicKey: string;
|
|
10
|
+
nsec: string;
|
|
11
|
+
npub: string;
|
|
12
|
+
};
|
|
3
13
|
export declare function initFirestore(): Firestore;
|
|
4
14
|
export declare function getDb(): Firestore;
|
|
5
15
|
export declare const collections: {
|
|
@@ -7,7 +17,40 @@ export declare const collections: {
|
|
|
7
17
|
agents: () => FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>;
|
|
8
18
|
tasks: () => FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>;
|
|
9
19
|
subscriptions: () => FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>;
|
|
20
|
+
withdrawals: () => FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>;
|
|
21
|
+
deposits: () => FirebaseFirestore.CollectionReference<FirebaseFirestore.DocumentData, FirebaseFirestore.DocumentData>;
|
|
10
22
|
};
|
|
11
|
-
export declare function createEscrow(data: Omit<Escrow, 'id' | 'createdAt' | 'completedAt' | 'proofOfWork'>): Promise<Escrow>;
|
|
23
|
+
export declare function createEscrow(data: Omit<Escrow, 'id' | 'createdAt' | 'completedAt' | 'proofOfWork' | 'fee' | 'feeRate' | 'disputeReason'>): Promise<Escrow>;
|
|
12
24
|
export declare function getEscrow(escrowId: string): Promise<Escrow | null>;
|
|
13
25
|
export declare function completeEscrow(escrowId: string, proofOfWork: string): Promise<Escrow | null>;
|
|
26
|
+
export declare function createAgent(data: Omit<Agent, 'id' | 'createdAt' | 'stats' | 'apiKeyHash' | 'balance' | 'nostrPubkey' | 'nip05'>): Promise<{
|
|
27
|
+
agent: Agent;
|
|
28
|
+
apiKey: string;
|
|
29
|
+
nostr: {
|
|
30
|
+
nsec: string;
|
|
31
|
+
npub: string;
|
|
32
|
+
nip05: string;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export declare function getAgent(agentId: string): Promise<Agent | null>;
|
|
36
|
+
export declare function validateApiKey(agentId: string, apiKey: string): Promise<boolean>;
|
|
37
|
+
export declare function getOrCreateAgent(agentId: string): Promise<Agent>;
|
|
38
|
+
export declare function searchAgents(query: {
|
|
39
|
+
skill?: string;
|
|
40
|
+
verified?: boolean;
|
|
41
|
+
minTasksCompleted?: number;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}): Promise<Agent[]>;
|
|
44
|
+
export declare function incrementAgentDisputes(agentId: string): Promise<void>;
|
|
45
|
+
export declare function disputeEscrow(escrowId: string, reason: string): Promise<Escrow | null>;
|
|
46
|
+
export declare function calculateReputationScore(agent: Agent): number;
|
|
47
|
+
export declare function getBalance(agentId: string): Promise<number>;
|
|
48
|
+
export declare function creditBalance(agentId: string, amount: number, notes?: string): Promise<number>;
|
|
49
|
+
export declare function debitBalance(agentId: string, amount: number): Promise<number>;
|
|
50
|
+
export declare function createEscrowWithBalance(data: Omit<Escrow, 'id' | 'createdAt' | 'completedAt' | 'proofOfWork' | 'fee' | 'feeRate' | 'disputeReason'>): Promise<Escrow>;
|
|
51
|
+
export declare function completeEscrowWithBalance(escrowId: string, proofOfWork: string): Promise<Escrow | null>;
|
|
52
|
+
export declare function refundEscrow(escrowId: string): Promise<Escrow | null>;
|
|
53
|
+
export declare function createWithdrawal(agentId: string, amount: number, currency: Currency, paymentMethod: string): Promise<Withdrawal>;
|
|
54
|
+
export declare function getWithdrawal(withdrawalId: string): Promise<Withdrawal | null>;
|
|
55
|
+
export declare function listWithdrawals(status?: string, limit?: number): Promise<Withdrawal[]>;
|
|
56
|
+
export declare function processWithdrawal(withdrawalId: string, action: 'complete' | 'reject', notes?: string): Promise<Withdrawal | null>;
|