openclaw-overlay-plugin 0.7.22
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 +406 -0
- package/SKILL.md +78 -0
- package/clawdbot.plugin.json +106 -0
- package/dist/cli-main.d.ts +7 -0
- package/dist/cli-main.js +192 -0
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +14 -0
- package/dist/core/config.d.ts +11 -0
- package/dist/core/config.js +13 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/index.js +26 -0
- package/dist/core/payment.d.ts +16 -0
- package/dist/core/payment.js +94 -0
- package/dist/core/types.d.ts +94 -0
- package/dist/core/types.js +4 -0
- package/dist/core/verify.d.ts +28 -0
- package/dist/core/verify.js +104 -0
- package/dist/core/wallet.d.ts +99 -0
- package/dist/core/wallet.js +219 -0
- package/dist/scripts/baemail/commands.d.ts +64 -0
- package/dist/scripts/baemail/commands.js +258 -0
- package/dist/scripts/baemail/handler.d.ts +36 -0
- package/dist/scripts/baemail/handler.js +284 -0
- package/dist/scripts/baemail/index.d.ts +5 -0
- package/dist/scripts/baemail/index.js +5 -0
- package/dist/scripts/config.d.ts +48 -0
- package/dist/scripts/config.js +68 -0
- package/dist/scripts/index.d.ts +7 -0
- package/dist/scripts/index.js +7 -0
- package/dist/scripts/messaging/connect.d.ts +8 -0
- package/dist/scripts/messaging/connect.js +114 -0
- package/dist/scripts/messaging/handlers.d.ts +21 -0
- package/dist/scripts/messaging/handlers.js +334 -0
- package/dist/scripts/messaging/inbox.d.ts +11 -0
- package/dist/scripts/messaging/inbox.js +51 -0
- package/dist/scripts/messaging/index.d.ts +8 -0
- package/dist/scripts/messaging/index.js +8 -0
- package/dist/scripts/messaging/poll.d.ts +7 -0
- package/dist/scripts/messaging/poll.js +52 -0
- package/dist/scripts/messaging/send.d.ts +7 -0
- package/dist/scripts/messaging/send.js +43 -0
- package/dist/scripts/output.d.ts +12 -0
- package/dist/scripts/output.js +19 -0
- package/dist/scripts/overlay/discover.d.ts +7 -0
- package/dist/scripts/overlay/discover.js +72 -0
- package/dist/scripts/overlay/index.d.ts +7 -0
- package/dist/scripts/overlay/index.js +7 -0
- package/dist/scripts/overlay/registration.d.ts +19 -0
- package/dist/scripts/overlay/registration.js +176 -0
- package/dist/scripts/overlay/services.d.ts +29 -0
- package/dist/scripts/overlay/services.js +167 -0
- package/dist/scripts/overlay/transaction.d.ts +42 -0
- package/dist/scripts/overlay/transaction.js +103 -0
- package/dist/scripts/payment/build.d.ts +24 -0
- package/dist/scripts/payment/build.js +54 -0
- package/dist/scripts/payment/commands.d.ts +15 -0
- package/dist/scripts/payment/commands.js +73 -0
- package/dist/scripts/payment/index.d.ts +6 -0
- package/dist/scripts/payment/index.js +6 -0
- package/dist/scripts/payment/types.d.ts +56 -0
- package/dist/scripts/payment/types.js +4 -0
- package/dist/scripts/services/index.d.ts +6 -0
- package/dist/scripts/services/index.js +6 -0
- package/dist/scripts/services/queue.d.ts +11 -0
- package/dist/scripts/services/queue.js +28 -0
- package/dist/scripts/services/request.d.ts +7 -0
- package/dist/scripts/services/request.js +82 -0
- package/dist/scripts/services/respond.d.ts +11 -0
- package/dist/scripts/services/respond.js +132 -0
- package/dist/scripts/types.d.ts +107 -0
- package/dist/scripts/types.js +4 -0
- package/dist/scripts/utils/index.d.ts +6 -0
- package/dist/scripts/utils/index.js +6 -0
- package/dist/scripts/utils/merkle.d.ts +12 -0
- package/dist/scripts/utils/merkle.js +47 -0
- package/dist/scripts/utils/storage.d.ts +66 -0
- package/dist/scripts/utils/storage.js +211 -0
- package/dist/scripts/utils/woc.d.ts +26 -0
- package/dist/scripts/utils/woc.js +91 -0
- package/dist/scripts/wallet/balance.d.ts +22 -0
- package/dist/scripts/wallet/balance.js +240 -0
- package/dist/scripts/wallet/identity.d.ts +70 -0
- package/dist/scripts/wallet/identity.js +151 -0
- package/dist/scripts/wallet/index.d.ts +6 -0
- package/dist/scripts/wallet/index.js +6 -0
- package/dist/scripts/wallet/setup.d.ts +15 -0
- package/dist/scripts/wallet/setup.js +105 -0
- package/dist/scripts/x-verification/commands.d.ts +27 -0
- package/dist/scripts/x-verification/commands.js +222 -0
- package/dist/scripts/x-verification/index.d.ts +4 -0
- package/dist/scripts/x-verification/index.js +4 -0
- package/dist/services/built-in/api-proxy/index.d.ts +6 -0
- package/dist/services/built-in/api-proxy/index.js +23 -0
- package/dist/services/built-in/code-develop/index.d.ts +6 -0
- package/dist/services/built-in/code-develop/index.js +23 -0
- package/dist/services/built-in/code-review/index.d.ts +10 -0
- package/dist/services/built-in/code-review/index.js +51 -0
- package/dist/services/built-in/image-analysis/index.d.ts +6 -0
- package/dist/services/built-in/image-analysis/index.js +33 -0
- package/dist/services/built-in/memory-store/index.d.ts +6 -0
- package/dist/services/built-in/memory-store/index.js +22 -0
- package/dist/services/built-in/roulette/index.d.ts +6 -0
- package/dist/services/built-in/roulette/index.js +27 -0
- package/dist/services/built-in/summarize/index.d.ts +6 -0
- package/dist/services/built-in/summarize/index.js +21 -0
- package/dist/services/built-in/tell-joke/handler.d.ts +7 -0
- package/dist/services/built-in/tell-joke/handler.js +122 -0
- package/dist/services/built-in/tell-joke/index.d.ts +9 -0
- package/dist/services/built-in/tell-joke/index.js +31 -0
- package/dist/services/built-in/translate/index.d.ts +6 -0
- package/dist/services/built-in/translate/index.js +21 -0
- package/dist/services/built-in/web-research/index.d.ts +9 -0
- package/dist/services/built-in/web-research/index.js +51 -0
- package/dist/services/index.d.ts +13 -0
- package/dist/services/index.js +14 -0
- package/dist/services/loader.d.ts +77 -0
- package/dist/services/loader.js +292 -0
- package/dist/services/manager.d.ts +86 -0
- package/dist/services/manager.js +255 -0
- package/dist/services/registry.d.ts +98 -0
- package/dist/services/registry.js +204 -0
- package/dist/services/types.d.ts +230 -0
- package/dist/services/types.js +30 -0
- package/dist/test/cli.test.d.ts +7 -0
- package/dist/test/cli.test.js +329 -0
- package/dist/test/comprehensive-overlay.test.d.ts +13 -0
- package/dist/test/comprehensive-overlay.test.js +593 -0
- package/dist/test/key-derivation.test.d.ts +12 -0
- package/dist/test/key-derivation.test.js +86 -0
- package/dist/test/overlay-submit.test.d.ts +10 -0
- package/dist/test/overlay-submit.test.js +460 -0
- package/dist/test/request-response-flow.test.d.ts +5 -0
- package/dist/test/request-response-flow.test.js +209 -0
- package/dist/test/service-system.test.d.ts +5 -0
- package/dist/test/service-system.test.js +190 -0
- package/dist/test/utils/server-logic.d.ts +98 -0
- package/dist/test/utils/server-logic.js +286 -0
- package/dist/test/wallet.test.d.ts +7 -0
- package/dist/test/wallet.test.js +146 -0
- package/index.ts +1965 -0
- package/openclaw.plugin.json +106 -0
- package/package.json +73 -0
- package/src/cli-main.ts +230 -0
- package/src/cli.ts +16 -0
- package/src/core/README.md +246 -0
- package/src/core/config.ts +21 -0
- package/src/core/index.ts +42 -0
- package/src/core/payment.ts +111 -0
- package/src/core/types.ts +102 -0
- package/src/core/verify.ts +119 -0
- package/src/core/wallet.ts +282 -0
- package/src/scripts/baemail/commands.ts +326 -0
- package/src/scripts/baemail/handler.ts +338 -0
- package/src/scripts/baemail/index.ts +6 -0
- package/src/scripts/config.ts +81 -0
- package/src/scripts/index.ts +8 -0
- package/src/scripts/messaging/connect.ts +121 -0
- package/src/scripts/messaging/handlers.ts +394 -0
- package/src/scripts/messaging/inbox.ts +64 -0
- package/src/scripts/messaging/index.ts +9 -0
- package/src/scripts/messaging/poll.ts +59 -0
- package/src/scripts/messaging/send.ts +54 -0
- package/src/scripts/output.ts +21 -0
- package/src/scripts/overlay/discover.ts +81 -0
- package/src/scripts/overlay/index.ts +8 -0
- package/src/scripts/overlay/registration.ts +199 -0
- package/src/scripts/overlay/services.ts +199 -0
- package/src/scripts/overlay/transaction.ts +124 -0
- package/src/scripts/payment/build.ts +65 -0
- package/src/scripts/payment/commands.ts +92 -0
- package/src/scripts/payment/index.ts +7 -0
- package/src/scripts/payment/types.ts +62 -0
- package/src/scripts/services/index.ts +7 -0
- package/src/scripts/services/queue.ts +35 -0
- package/src/scripts/services/request.ts +98 -0
- package/src/scripts/services/respond.ts +149 -0
- package/src/scripts/types.ts +121 -0
- package/src/scripts/utils/index.ts +7 -0
- package/src/scripts/utils/merkle.ts +57 -0
- package/src/scripts/utils/storage.ts +231 -0
- package/src/scripts/utils/woc.ts +106 -0
- package/src/scripts/wallet/balance.ts +277 -0
- package/src/scripts/wallet/identity.ts +203 -0
- package/src/scripts/wallet/index.ts +7 -0
- package/src/scripts/wallet/setup.ts +121 -0
- package/src/scripts/x-verification/commands.ts +256 -0
- package/src/scripts/x-verification/index.ts +5 -0
- package/src/services/built-in/api-proxy/index.ts +26 -0
- package/src/services/built-in/api-proxy/prompt.md +26 -0
- package/src/services/built-in/code-develop/index.ts +26 -0
- package/src/services/built-in/code-develop/prompt.md +35 -0
- package/src/services/built-in/code-review/index.ts +54 -0
- package/src/services/built-in/code-review/prompt.md +105 -0
- package/src/services/built-in/image-analysis/index.ts +36 -0
- package/src/services/built-in/image-analysis/prompt.md +42 -0
- package/src/services/built-in/memory-store/index.ts +25 -0
- package/src/services/built-in/memory-store/prompt.md +45 -0
- package/src/services/built-in/roulette/index.ts +30 -0
- package/src/services/built-in/roulette/prompt.md +35 -0
- package/src/services/built-in/summarize/index.ts +24 -0
- package/src/services/built-in/summarize/prompt.md +27 -0
- package/src/services/built-in/tell-joke/handler.ts +134 -0
- package/src/services/built-in/tell-joke/index.ts +34 -0
- package/src/services/built-in/tell-joke/prompt.md +59 -0
- package/src/services/built-in/translate/index.ts +24 -0
- package/src/services/built-in/translate/prompt.md +23 -0
- package/src/services/built-in/web-research/index.ts +54 -0
- package/src/services/built-in/web-research/prompt.md +110 -0
- package/src/services/index.ts +16 -0
- package/src/services/loader.ts +344 -0
- package/src/services/manager.ts +304 -0
- package/src/services/registry.ts +246 -0
- package/src/services/types.ts +259 -0
- package/src/test/cli.test.ts +352 -0
- package/src/test/comprehensive-overlay.test.ts +729 -0
- package/src/test/key-derivation.test.ts +102 -0
- package/src/test/overlay-submit.test.ts +570 -0
- package/src/test/request-response-flow.test.ts +252 -0
- package/src/test/service-system.test.ts +241 -0
- package/src/test/utils/server-logic.ts +368 -0
- package/src/test/wallet.test.ts +166 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* X (Twitter) verification commands.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import fs from 'node:fs';
|
|
6
|
+
import { OVERLAY_URL, PROTOCOL_ID, TOPICS, LOOKUP_SERVICES, OVERLAY_STATE_DIR, PATHS } from '../config.js';
|
|
7
|
+
import { ok, fail } from '../output.js';
|
|
8
|
+
import { loadIdentity, signRelayMessage } from '../wallet/identity.js';
|
|
9
|
+
import { loadXVerifications, saveXVerifications, readJsonl, appendToJsonl, loadServices, ensureStateDir } from '../utils/storage.js';
|
|
10
|
+
import { buildRealOverlayTransaction, lookupOverlay } from '../overlay/transaction.js';
|
|
11
|
+
import { verifyAndAcceptPayment } from '../messaging/handlers.js';
|
|
12
|
+
import { fetchWithTimeout } from '../utils/woc.js';
|
|
13
|
+
|
|
14
|
+
// Dynamic import for @bsv/sdk
|
|
15
|
+
let _sdk: any = null;
|
|
16
|
+
|
|
17
|
+
async function getSdk(): Promise<any> {
|
|
18
|
+
if (_sdk) return _sdk;
|
|
19
|
+
|
|
20
|
+
try {
|
|
21
|
+
_sdk = await import('@bsv/sdk');
|
|
22
|
+
return _sdk;
|
|
23
|
+
} catch {
|
|
24
|
+
const { fileURLToPath } = await import('node:url');
|
|
25
|
+
const path = await import('node:path');
|
|
26
|
+
const os = await import('node:os');
|
|
27
|
+
|
|
28
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
29
|
+
const candidates = [
|
|
30
|
+
path.resolve(__dirname, '..', '..', '..', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
31
|
+
path.resolve(__dirname, '..', '..', '..', '..', '..', 'a2a-bsv', 'packages', 'core', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
32
|
+
path.resolve(os.homedir(), 'a2a-bsv', 'packages', 'core', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
for (const p of candidates) {
|
|
36
|
+
try {
|
|
37
|
+
_sdk = await import(p);
|
|
38
|
+
return _sdk;
|
|
39
|
+
} catch {
|
|
40
|
+
// Try next
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
throw new Error('Cannot find @bsv/sdk. Run setup.sh first.');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Start X verification: generate a tweet with identity key and signature.
|
|
49
|
+
*/
|
|
50
|
+
export async function cmdXVerifyStart(handleArg: string | undefined): Promise<never> {
|
|
51
|
+
if (!handleArg) {
|
|
52
|
+
return fail('Usage: x-verify-start <@handle>');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const sdk = await getSdk();
|
|
56
|
+
const handle = handleArg.startsWith('@') ? handleArg : `@${handleArg}`;
|
|
57
|
+
const { identityKey, privKey } = await loadIdentity();
|
|
58
|
+
|
|
59
|
+
// Sign the verification message
|
|
60
|
+
const message = `Verify ${identityKey}`;
|
|
61
|
+
const msgHash = sdk.Hash.sha256(Array.from(new TextEncoder().encode(message)));
|
|
62
|
+
const sig = privKey.sign(msgHash);
|
|
63
|
+
const signatureHex = (Array.from(sig.toDER()) as number[]).map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
64
|
+
|
|
65
|
+
// Save pending verification
|
|
66
|
+
const pending = {
|
|
67
|
+
identityKey,
|
|
68
|
+
handle,
|
|
69
|
+
signature: signatureHex,
|
|
70
|
+
message,
|
|
71
|
+
createdAt: new Date().toISOString(),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
ensureStateDir();
|
|
75
|
+
fs.writeFileSync(PATHS.pendingXVerification, JSON.stringify(pending, null, 2));
|
|
76
|
+
|
|
77
|
+
// Build tweet text (under 280 chars)
|
|
78
|
+
// Use shortened signature (first 40 chars) to fit in tweet
|
|
79
|
+
const tweetText = `BSV Agent Verify: ${identityKey.slice(0, 10)}...${identityKey.slice(-10)} sig:${signatureHex.slice(0, 40)}`;
|
|
80
|
+
|
|
81
|
+
return ok({
|
|
82
|
+
tweetText,
|
|
83
|
+
handle,
|
|
84
|
+
identityKey,
|
|
85
|
+
signature: signatureHex,
|
|
86
|
+
note: `Post the tweet above from ${handle}, then run: x-verify-complete <tweet_url>`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Complete X verification by checking the posted tweet.
|
|
92
|
+
*/
|
|
93
|
+
export async function cmdXVerifyComplete(tweetUrl: string | undefined): Promise<never> {
|
|
94
|
+
if (!tweetUrl) return fail('Usage: x-verify-complete <tweet-url>');
|
|
95
|
+
|
|
96
|
+
// Load pending verification
|
|
97
|
+
if (!fs.existsSync(PATHS.pendingXVerification)) {
|
|
98
|
+
return fail('No pending X verification. Run x-verify-start first.');
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const pending = JSON.parse(fs.readFileSync(PATHS.pendingXVerification, 'utf-8'));
|
|
102
|
+
|
|
103
|
+
// Extract tweet ID from URL
|
|
104
|
+
const tweetIdMatch = tweetUrl.match(/status\/(\d+)/);
|
|
105
|
+
if (!tweetIdMatch) return fail('Invalid tweet URL. Expected format: https://x.com/user/status/123456789');
|
|
106
|
+
const tweetId = tweetIdMatch[1];
|
|
107
|
+
|
|
108
|
+
// Fetch the tweet using bird CLI
|
|
109
|
+
let tweetData: any;
|
|
110
|
+
try {
|
|
111
|
+
const { execSync } = await import('child_process');
|
|
112
|
+
const birdOutput = execSync(`bird read ${tweetUrl} --json 2>/dev/null`, {
|
|
113
|
+
encoding: 'utf-8',
|
|
114
|
+
timeout: 30000,
|
|
115
|
+
});
|
|
116
|
+
tweetData = JSON.parse(birdOutput);
|
|
117
|
+
} catch (err: any) {
|
|
118
|
+
return fail(`Failed to fetch tweet: ${err.message}. Make sure bird CLI is configured.`);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Verify the tweet contains our identity key and partial signature
|
|
122
|
+
const tweetText = tweetData.text || tweetData.full_text || '';
|
|
123
|
+
if (!tweetText.includes(pending.identityKey.slice(0, 10))) {
|
|
124
|
+
return fail('Tweet does not contain the expected identity key.');
|
|
125
|
+
}
|
|
126
|
+
// Check for partial signature (first 40 chars)
|
|
127
|
+
if (!tweetText.includes(pending.signature.slice(0, 40))) {
|
|
128
|
+
return fail('Tweet does not contain the expected verification signature prefix.');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Get the X user info from the tweet
|
|
132
|
+
const xUserId = tweetData.user?.id_str || tweetData.authorId || tweetData.author?.id || tweetData.user_id;
|
|
133
|
+
const xHandle = tweetData.user?.screen_name || tweetData.author?.username || tweetData.author?.name || pending.handle.replace('@', '');
|
|
134
|
+
|
|
135
|
+
if (!xUserId) {
|
|
136
|
+
return fail('Could not extract X user ID from tweet data.');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Build on-chain verification record
|
|
140
|
+
const verificationPayload = {
|
|
141
|
+
protocol: PROTOCOL_ID,
|
|
142
|
+
type: 'x-verification',
|
|
143
|
+
identityKey: pending.identityKey,
|
|
144
|
+
xHandle: `@${xHandle}`,
|
|
145
|
+
xUserId,
|
|
146
|
+
tweetId,
|
|
147
|
+
tweetUrl,
|
|
148
|
+
signature: pending.signature,
|
|
149
|
+
verifiedAt: new Date().toISOString(),
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// Submit to overlay (may fail if topic manager not deployed yet)
|
|
153
|
+
let result = { txid: null as string | null, funded: 'pending-server-support' };
|
|
154
|
+
let onChainStored = false;
|
|
155
|
+
try {
|
|
156
|
+
result = await buildRealOverlayTransaction(verificationPayload, TOPICS.X_VERIFICATION);
|
|
157
|
+
onChainStored = true;
|
|
158
|
+
} catch (err: any) {
|
|
159
|
+
console.error(`[x-verify] On-chain storage failed: ${err.message}`);
|
|
160
|
+
console.error('[x-verify] Storing verification locally.');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Save verification locally
|
|
164
|
+
const verifications = loadXVerifications();
|
|
165
|
+
verifications.push({
|
|
166
|
+
...verificationPayload,
|
|
167
|
+
txid: result.txid,
|
|
168
|
+
});
|
|
169
|
+
saveXVerifications(verifications);
|
|
170
|
+
|
|
171
|
+
// Clean up pending
|
|
172
|
+
fs.unlinkSync(PATHS.pendingXVerification);
|
|
173
|
+
|
|
174
|
+
return ok({
|
|
175
|
+
verified: true,
|
|
176
|
+
identityKey: pending.identityKey,
|
|
177
|
+
xHandle: `@${xHandle}`,
|
|
178
|
+
xUserId,
|
|
179
|
+
tweetId,
|
|
180
|
+
txid: result.txid,
|
|
181
|
+
funded: result.funded,
|
|
182
|
+
onChainStored,
|
|
183
|
+
note: onChainStored ? undefined : 'Stored locally. On-chain anchoring pending server topic manager deployment.',
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* List verified X accounts (local cache).
|
|
189
|
+
*/
|
|
190
|
+
export async function cmdXVerifications(): Promise<never> {
|
|
191
|
+
const verifications = loadXVerifications();
|
|
192
|
+
return ok({ verifications, count: verifications.length });
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Lookup X verifications from the overlay network.
|
|
197
|
+
*/
|
|
198
|
+
export async function cmdXLookup(query: string | undefined): Promise<never> {
|
|
199
|
+
try {
|
|
200
|
+
const lookupQuery = query
|
|
201
|
+
? (query.startsWith('@') ? { xHandle: query } : { identityKey: query })
|
|
202
|
+
: { type: 'list' };
|
|
203
|
+
|
|
204
|
+
const response = await lookupOverlay(LOOKUP_SERVICES.X_VERIFICATIONS, lookupQuery);
|
|
205
|
+
return ok({ verifications: response.outputs || response || [], query: lookupQuery });
|
|
206
|
+
} catch {
|
|
207
|
+
return ok({ verifications: [], query, note: 'X verification lookup service may not be deployed yet.' });
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* List pending X engagement requests.
|
|
213
|
+
*/
|
|
214
|
+
export async function cmdXEngagementQueue(): Promise<never> {
|
|
215
|
+
if (!fs.existsSync(PATHS.xEngagementQueue)) {
|
|
216
|
+
return ok({ queue: [], count: 0 });
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const queue = readJsonl<any>(PATHS.xEngagementQueue).filter(e => e.status === 'pending');
|
|
220
|
+
|
|
221
|
+
return ok({ queue, count: queue.length });
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Mark an X engagement request as fulfilled.
|
|
226
|
+
*/
|
|
227
|
+
export async function cmdXEngagementFulfill(
|
|
228
|
+
requestId: string | undefined,
|
|
229
|
+
proofUrl?: string
|
|
230
|
+
): Promise<never> {
|
|
231
|
+
if (!requestId) return fail('Usage: x-engagement-fulfill <requestId> [proofUrl]');
|
|
232
|
+
|
|
233
|
+
if (!fs.existsSync(PATHS.xEngagementQueue)) {
|
|
234
|
+
return fail('No engagement queue found.');
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
const queue = readJsonl<any>(PATHS.xEngagementQueue);
|
|
238
|
+
const entryIndex = queue.findIndex(e => e.requestId === requestId);
|
|
239
|
+
if (entryIndex === -1) {
|
|
240
|
+
return fail(`Request ${requestId} not found in queue.`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// Mark as fulfilled
|
|
244
|
+
queue[entryIndex].status = 'fulfilled';
|
|
245
|
+
queue[entryIndex].fulfilledAt = new Date().toISOString();
|
|
246
|
+
queue[entryIndex].proofUrl = proofUrl || null;
|
|
247
|
+
|
|
248
|
+
// Rewrite queue file
|
|
249
|
+
fs.writeFileSync(PATHS.xEngagementQueue, queue.map(e => JSON.stringify(e)).join('\n') + '\n');
|
|
250
|
+
|
|
251
|
+
return ok({
|
|
252
|
+
fulfilled: true,
|
|
253
|
+
requestId,
|
|
254
|
+
entry: queue[entryIndex],
|
|
255
|
+
});
|
|
256
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Proxy service definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ServiceDefinition, ServiceCategory } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
const apiProxyService: ServiceDefinition = {
|
|
8
|
+
id: 'api-proxy',
|
|
9
|
+
name: 'API Proxy',
|
|
10
|
+
description: 'Proxy HTTP requests to external APIs. Input: {url, method, headers, body}.',
|
|
11
|
+
defaultPrice: 15,
|
|
12
|
+
category: ServiceCategory.UTILITY,
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
url: { type: 'string', description: 'Target API URL' },
|
|
17
|
+
method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE'], description: 'HTTP method' },
|
|
18
|
+
headers: { type: 'object', description: 'Request headers' },
|
|
19
|
+
body: { description: 'Request body' },
|
|
20
|
+
timeout: { type: 'number', description: 'Request timeout in ms' }
|
|
21
|
+
},
|
|
22
|
+
required: ['url']
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default apiProxyService;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# API Proxy Service
|
|
2
|
+
|
|
3
|
+
You are processing a request for the "api-proxy" service. You help users make HTTP requests to external APIs safely.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
```json
|
|
7
|
+
{{input}}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
1. Make the HTTP request to the specified URL with the given parameters
|
|
12
|
+
2. Handle errors gracefully
|
|
13
|
+
3. Return the API response along with metadata
|
|
14
|
+
|
|
15
|
+
## Response Format
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"success": true,
|
|
19
|
+
"data": "API response data",
|
|
20
|
+
"metadata": {
|
|
21
|
+
"statusCode": 200,
|
|
22
|
+
"responseTime": "123ms",
|
|
23
|
+
"headers": {"content-type": "application/json"}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Development service definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ServiceDefinition, ServiceCategory } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
const codeDevelopService: ServiceDefinition = {
|
|
8
|
+
id: 'code-develop',
|
|
9
|
+
name: 'Code Development',
|
|
10
|
+
description: 'Generate code from requirements. Specify language, task description, and constraints.',
|
|
11
|
+
defaultPrice: 100,
|
|
12
|
+
category: ServiceCategory.DEVELOPMENT,
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
requirements: { type: 'string', description: 'Detailed description of what code to generate' },
|
|
17
|
+
language: { type: 'string', description: 'Programming language (e.g., JavaScript, Python, Java)' },
|
|
18
|
+
constraints: { type: 'string', description: 'Any specific constraints or requirements' },
|
|
19
|
+
style: { type: 'string', description: 'Code style preferences' },
|
|
20
|
+
includeTests: { type: 'boolean', description: 'Whether to include unit tests' }
|
|
21
|
+
},
|
|
22
|
+
required: ['requirements', 'language']
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default codeDevelopService;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Code Development Service
|
|
2
|
+
|
|
3
|
+
You are processing a request for the "code-develop" service. You generate high-quality code based on user requirements.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
```json
|
|
7
|
+
{{input}}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
1. Analyze the requirements thoroughly
|
|
12
|
+
2. Choose appropriate patterns and libraries for the target language
|
|
13
|
+
3. Write clean, well-documented code
|
|
14
|
+
4. Follow language-specific best practices
|
|
15
|
+
5. Include error handling and edge cases
|
|
16
|
+
6. Generate unit tests if requested
|
|
17
|
+
|
|
18
|
+
## Development Guidelines
|
|
19
|
+
- **Code Quality**: Write production-ready code with proper error handling
|
|
20
|
+
- **Documentation**: Include clear comments and docstrings
|
|
21
|
+
- **Security**: Follow secure coding practices
|
|
22
|
+
- **Performance**: Consider performance implications
|
|
23
|
+
- **Maintainability**: Use clear variable names and modular structure
|
|
24
|
+
|
|
25
|
+
## Response Format
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"success": true,
|
|
29
|
+
"language": "JavaScript",
|
|
30
|
+
"code": "// Your generated code here\nfunction example() {\n return 'Hello World';\n}",
|
|
31
|
+
"tests": "// Unit tests if requested\ntest('example function', () => {\n expect(example()).toBe('Hello World');\n});",
|
|
32
|
+
"explanation": "Brief explanation of the code structure and approach",
|
|
33
|
+
"dependencies": ["package1", "package2"]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code Review service definition.
|
|
3
|
+
*
|
|
4
|
+
* Provides thorough code review covering bugs, security issues, style,
|
|
5
|
+
* performance, and improvement suggestions. This is an agent-mode service
|
|
6
|
+
* that leverages the LLM's capabilities.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { ServiceDefinition, ServiceCategory } from '../../types.js';
|
|
10
|
+
|
|
11
|
+
const codeReviewService: ServiceDefinition = {
|
|
12
|
+
id: 'code-review',
|
|
13
|
+
name: 'Code Review',
|
|
14
|
+
description: 'Thorough code review covering bugs, security issues, style, performance, and improvement suggestions.',
|
|
15
|
+
defaultPrice: 50,
|
|
16
|
+
category: ServiceCategory.DEVELOPMENT,
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
code: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
description: 'Code to review'
|
|
23
|
+
},
|
|
24
|
+
language: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'Programming language (auto-detected if not provided)'
|
|
27
|
+
},
|
|
28
|
+
prUrl: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: 'GitHub/GitLab PR URL to review instead of direct code'
|
|
31
|
+
},
|
|
32
|
+
focusAreas: {
|
|
33
|
+
type: 'array',
|
|
34
|
+
items: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: ['security', 'performance', 'style', 'bugs', 'maintainability', 'testing']
|
|
37
|
+
},
|
|
38
|
+
description: 'Specific areas to focus the review on'
|
|
39
|
+
},
|
|
40
|
+
severity: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
enum: ['basic', 'detailed', 'comprehensive'],
|
|
43
|
+
description: 'Depth of review (default: detailed)'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
anyOf: [
|
|
47
|
+
{ required: ['code'] },
|
|
48
|
+
{ required: ['prUrl'] }
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
// No handler - this service uses agent mode for full LLM capabilities
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default codeReviewService;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Code Review Service
|
|
2
|
+
|
|
3
|
+
You are processing a request for the "code-review" service. You are an expert code reviewer with deep knowledge across multiple programming languages.
|
|
4
|
+
|
|
5
|
+
## Service Description
|
|
6
|
+
Provide thorough code review covering bugs, security issues, style, performance, and improvement suggestions.
|
|
7
|
+
|
|
8
|
+
## Input
|
|
9
|
+
The user has provided the following input:
|
|
10
|
+
```json
|
|
11
|
+
{{input}}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Instructions
|
|
15
|
+
|
|
16
|
+
### If code is provided directly:
|
|
17
|
+
1. **Identify the language** (if not specified)
|
|
18
|
+
2. **Analyze the code** for:
|
|
19
|
+
- **Bugs**: Logic errors, edge cases, potential crashes
|
|
20
|
+
- **Security**: Vulnerabilities, input validation, data exposure
|
|
21
|
+
- **Performance**: Efficiency issues, bottlenecks, optimizations
|
|
22
|
+
- **Style**: Code organization, naming, best practices
|
|
23
|
+
- **Maintainability**: Code clarity, documentation, refactoring needs
|
|
24
|
+
- **Testing**: Missing tests, test coverage suggestions
|
|
25
|
+
|
|
26
|
+
### If a PR URL is provided:
|
|
27
|
+
1. Fetch the PR content if possible
|
|
28
|
+
2. Review the changes in context
|
|
29
|
+
3. Consider the diff and impact on the codebase
|
|
30
|
+
|
|
31
|
+
### Focus Areas
|
|
32
|
+
If the user specified `focusAreas`, prioritize those aspects while still providing a comprehensive review.
|
|
33
|
+
|
|
34
|
+
### Severity Levels
|
|
35
|
+
- **Basic**: High-level overview with major issues only
|
|
36
|
+
- **Detailed**: Thorough analysis with specific recommendations (default)
|
|
37
|
+
- **Comprehensive**: Deep dive with extensive examples and alternatives
|
|
38
|
+
|
|
39
|
+
## Response Format
|
|
40
|
+
Provide your response in this structured format:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"summary": {
|
|
45
|
+
"language": "detected/provided language",
|
|
46
|
+
"linesOfCode": "approximate count",
|
|
47
|
+
"overallScore": "1-10 rating",
|
|
48
|
+
"criticalIssues": "number of critical issues found"
|
|
49
|
+
},
|
|
50
|
+
"issues": [
|
|
51
|
+
{
|
|
52
|
+
"severity": "critical|high|medium|low",
|
|
53
|
+
"category": "bug|security|performance|style|maintainability|testing",
|
|
54
|
+
"title": "Brief issue description",
|
|
55
|
+
"description": "Detailed explanation",
|
|
56
|
+
"location": "line numbers or function names",
|
|
57
|
+
"suggestion": "How to fix it",
|
|
58
|
+
"example": "Code example if helpful"
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"recommendations": {
|
|
62
|
+
"security": ["Security improvements"],
|
|
63
|
+
"performance": ["Performance optimizations"],
|
|
64
|
+
"style": ["Style improvements"],
|
|
65
|
+
"testing": ["Testing suggestions"],
|
|
66
|
+
"general": ["General recommendations"]
|
|
67
|
+
},
|
|
68
|
+
"positives": [
|
|
69
|
+
"Things the code does well"
|
|
70
|
+
],
|
|
71
|
+
"refactoringOpportunities": [
|
|
72
|
+
"Areas that could benefit from refactoring"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Example Response
|
|
78
|
+
For code with a potential SQL injection:
|
|
79
|
+
|
|
80
|
+
```json
|
|
81
|
+
{
|
|
82
|
+
"summary": {
|
|
83
|
+
"language": "JavaScript",
|
|
84
|
+
"linesOfCode": 45,
|
|
85
|
+
"overallScore": 6,
|
|
86
|
+
"criticalIssues": 1
|
|
87
|
+
},
|
|
88
|
+
"issues": [
|
|
89
|
+
{
|
|
90
|
+
"severity": "critical",
|
|
91
|
+
"category": "security",
|
|
92
|
+
"title": "SQL Injection Vulnerability",
|
|
93
|
+
"description": "User input is directly concatenated into SQL query without sanitization",
|
|
94
|
+
"location": "line 23-25",
|
|
95
|
+
"suggestion": "Use parameterized queries or prepared statements",
|
|
96
|
+
"example": "const query = 'SELECT * FROM users WHERE id = ?'; db.query(query, [userId])"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"recommendations": {
|
|
100
|
+
"security": ["Implement input validation", "Use parameterized queries"],
|
|
101
|
+
"testing": ["Add unit tests for edge cases"],
|
|
102
|
+
"general": ["Add error handling for database operations"]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image Analysis service definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ServiceDefinition, ServiceCategory } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
const imageAnalysisService: ServiceDefinition = {
|
|
8
|
+
id: 'image-analysis',
|
|
9
|
+
name: 'Image Analysis',
|
|
10
|
+
description: 'Analyze and describe images. Identify objects, text, scenes, and more.',
|
|
11
|
+
defaultPrice: 30,
|
|
12
|
+
category: ServiceCategory.AI,
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
imageUrl: { type: 'string', description: 'URL of the image to analyze' },
|
|
17
|
+
imageData: { type: 'string', description: 'Base64 encoded image data' },
|
|
18
|
+
analysisType: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
enum: ['general', 'objects', 'text', 'faces', 'scenes'],
|
|
21
|
+
description: 'Type of analysis to perform'
|
|
22
|
+
},
|
|
23
|
+
detailLevel: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
enum: ['brief', 'detailed', 'comprehensive'],
|
|
26
|
+
description: 'Level of detail in analysis'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
oneOf: [
|
|
30
|
+
{ required: ['imageUrl'] },
|
|
31
|
+
{ required: ['imageData'] }
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default imageAnalysisService;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Image Analysis Service
|
|
2
|
+
|
|
3
|
+
You are processing a request for the "image-analysis" service. You analyze images and provide detailed descriptions of their contents.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
```json
|
|
7
|
+
{{input}}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
1. Load and examine the provided image (via URL or base64 data)
|
|
12
|
+
2. Perform the requested type of analysis
|
|
13
|
+
3. Provide detailed, accurate descriptions
|
|
14
|
+
4. Include confidence levels where appropriate
|
|
15
|
+
5. Structure the response according to the analysis type
|
|
16
|
+
|
|
17
|
+
## Analysis Types
|
|
18
|
+
- **General**: Overall description of the image content
|
|
19
|
+
- **Objects**: Identify and locate specific objects in the image
|
|
20
|
+
- **Text**: Extract and transcribe any visible text (OCR)
|
|
21
|
+
- **Faces**: Detect and describe faces (no identification, just descriptions)
|
|
22
|
+
- **Scenes**: Analyze the setting, mood, and context of the scene
|
|
23
|
+
|
|
24
|
+
## Response Format
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"success": true,
|
|
28
|
+
"analysisType": "general",
|
|
29
|
+
"description": "A detailed description of the image contents",
|
|
30
|
+
"objects": [
|
|
31
|
+
{"name": "car", "confidence": 0.95, "location": "center-left"},
|
|
32
|
+
{"name": "tree", "confidence": 0.87, "location": "background"}
|
|
33
|
+
],
|
|
34
|
+
"text": "Any extracted text from the image",
|
|
35
|
+
"colors": ["red", "blue", "green"],
|
|
36
|
+
"mood": "cheerful",
|
|
37
|
+
"metadata": {
|
|
38
|
+
"resolution": "1920x1080",
|
|
39
|
+
"format": "JPEG"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Memory Store service definition.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ServiceDefinition, ServiceCategory } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
const memoryStoreService: ServiceDefinition = {
|
|
8
|
+
id: 'memory-store',
|
|
9
|
+
name: 'Memory Store',
|
|
10
|
+
description: 'Persistent key-value storage for agents. Operations: set, get, delete, list.',
|
|
11
|
+
defaultPrice: 10,
|
|
12
|
+
category: ServiceCategory.UTILITY,
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: 'object',
|
|
15
|
+
properties: {
|
|
16
|
+
operation: { type: 'string', enum: ['set', 'get', 'delete', 'list'], description: 'Storage operation' },
|
|
17
|
+
key: { type: 'string', description: 'Storage key (required for set, get, delete)' },
|
|
18
|
+
value: { description: 'Value to store (required for set operation)' },
|
|
19
|
+
namespace: { type: 'string', description: 'Optional namespace for keys' }
|
|
20
|
+
},
|
|
21
|
+
required: ['operation']
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default memoryStoreService;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Memory Store Service
|
|
2
|
+
|
|
3
|
+
You are processing a request for the "memory-store" service. You provide persistent key-value storage for AI agents.
|
|
4
|
+
|
|
5
|
+
## Input
|
|
6
|
+
```json
|
|
7
|
+
{{input}}
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Instructions
|
|
11
|
+
Based on the operation type:
|
|
12
|
+
|
|
13
|
+
### SET Operation
|
|
14
|
+
- Store the provided value under the given key
|
|
15
|
+
- Create namespace directory if needed
|
|
16
|
+
- Return confirmation of storage
|
|
17
|
+
|
|
18
|
+
### GET Operation
|
|
19
|
+
- Retrieve the value for the given key
|
|
20
|
+
- Return null if key doesn't exist
|
|
21
|
+
- Include metadata like creation time if available
|
|
22
|
+
|
|
23
|
+
### DELETE Operation
|
|
24
|
+
- Remove the key-value pair
|
|
25
|
+
- Return confirmation of deletion
|
|
26
|
+
- Handle case where key doesn't exist gracefully
|
|
27
|
+
|
|
28
|
+
### LIST Operation
|
|
29
|
+
- Return all keys in the namespace
|
|
30
|
+
- Include basic metadata for each key
|
|
31
|
+
- Support pagination if many keys exist
|
|
32
|
+
|
|
33
|
+
## Response Format
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"success": true,
|
|
37
|
+
"operation": "get",
|
|
38
|
+
"key": "example-key",
|
|
39
|
+
"value": "stored value or null",
|
|
40
|
+
"metadata": {
|
|
41
|
+
"created": "2024-01-01T12:00:00Z",
|
|
42
|
+
"namespace": "default"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|