openclaw-overlay-plugin 0.8.15 → 0.8.17
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.js +3037 -328
- package/dist/index.js.map +7 -0
- package/dist/src/cli.js +3820 -11
- package/dist/src/cli.js.map +7 -0
- package/index.ts +32 -27
- package/openclaw.plugin.json +1 -1
- package/package.json +8 -6
- package/src/scripts/messaging/handlers.ts +1 -1
- package/src/scripts/overlay/advertisement.ts +1 -1
- package/src/scripts/overlay/registration.ts +1 -1
- package/src/scripts/overlay/services.ts +1 -1
- package/src/scripts/overlay/transaction.ts +1 -1
- package/src/scripts/payment/build.ts +1 -1
- package/src/scripts/payment/commands.ts +1 -1
- package/src/scripts/wallet/balance.ts +1 -1
- package/src/scripts/wallet/setup.ts +1 -1
- package/src/scripts/x-verification/commands.ts +5 -0
- package/src/test/identity-consistency.test.ts +1 -1
- package/src/test/wallet.test.ts +1 -2
- package/dist/index.d.ts +0 -9
- package/dist/src/cli-main.d.ts +0 -7
- package/dist/src/cli-main.js +0 -202
- package/dist/src/cli.d.ts +0 -8
- package/dist/src/compatibility.test.d.ts +0 -4
- package/dist/src/compatibility.test.js +0 -41
- package/dist/src/core/config.d.ts +0 -11
- package/dist/src/core/config.js +0 -15
- package/dist/src/core/index.d.ts +0 -25
- package/dist/src/core/index.js +0 -26
- package/dist/src/core/payment.d.ts +0 -16
- package/dist/src/core/payment.js +0 -94
- package/dist/src/core/types.d.ts +0 -94
- package/dist/src/core/types.js +0 -4
- package/dist/src/core/verify.d.ts +0 -28
- package/dist/src/core/verify.js +0 -104
- package/dist/src/core/wallet.d.ts +0 -105
- package/dist/src/core/wallet.js +0 -256
- package/dist/src/scripts/baemail/commands.d.ts +0 -35
- package/dist/src/scripts/baemail/commands.js +0 -282
- package/dist/src/scripts/baemail/handler.d.ts +0 -36
- package/dist/src/scripts/baemail/handler.js +0 -284
- package/dist/src/scripts/baemail/index.d.ts +0 -5
- package/dist/src/scripts/baemail/index.js +0 -5
- package/dist/src/scripts/config.d.ts +0 -52
- package/dist/src/scripts/config.js +0 -75
- package/dist/src/scripts/index.d.ts +0 -7
- package/dist/src/scripts/index.js +0 -7
- package/dist/src/scripts/messaging/connect.d.ts +0 -8
- package/dist/src/scripts/messaging/connect.js +0 -168
- package/dist/src/scripts/messaging/handlers.d.ts +0 -21
- package/dist/src/scripts/messaging/handlers.js +0 -334
- package/dist/src/scripts/messaging/inbox.d.ts +0 -11
- package/dist/src/scripts/messaging/inbox.js +0 -51
- package/dist/src/scripts/messaging/index.d.ts +0 -8
- package/dist/src/scripts/messaging/index.js +0 -8
- package/dist/src/scripts/messaging/poll.d.ts +0 -7
- package/dist/src/scripts/messaging/poll.js +0 -52
- package/dist/src/scripts/messaging/send.d.ts +0 -7
- package/dist/src/scripts/messaging/send.js +0 -43
- package/dist/src/scripts/output.d.ts +0 -13
- package/dist/src/scripts/output.js +0 -28
- package/dist/src/scripts/overlay/advertisement.d.ts +0 -16
- package/dist/src/scripts/overlay/advertisement.js +0 -122
- package/dist/src/scripts/overlay/discover.d.ts +0 -7
- package/dist/src/scripts/overlay/discover.js +0 -74
- package/dist/src/scripts/overlay/index.d.ts +0 -7
- package/dist/src/scripts/overlay/index.js +0 -7
- package/dist/src/scripts/overlay/registration.d.ts +0 -19
- package/dist/src/scripts/overlay/registration.js +0 -176
- package/dist/src/scripts/overlay/services.d.ts +0 -29
- package/dist/src/scripts/overlay/services.js +0 -167
- package/dist/src/scripts/overlay/transaction.d.ts +0 -42
- package/dist/src/scripts/overlay/transaction.js +0 -103
- package/dist/src/scripts/payment/build.d.ts +0 -24
- package/dist/src/scripts/payment/build.js +0 -54
- package/dist/src/scripts/payment/commands.d.ts +0 -15
- package/dist/src/scripts/payment/commands.js +0 -73
- package/dist/src/scripts/payment/index.d.ts +0 -6
- package/dist/src/scripts/payment/index.js +0 -6
- package/dist/src/scripts/payment/types.d.ts +0 -56
- package/dist/src/scripts/payment/types.js +0 -4
- package/dist/src/scripts/services/index.d.ts +0 -6
- package/dist/src/scripts/services/index.js +0 -6
- package/dist/src/scripts/services/queue.d.ts +0 -11
- package/dist/src/scripts/services/queue.js +0 -28
- package/dist/src/scripts/services/request.d.ts +0 -7
- package/dist/src/scripts/services/request.js +0 -82
- package/dist/src/scripts/services/respond.d.ts +0 -11
- package/dist/src/scripts/services/respond.js +0 -132
- package/dist/src/scripts/types.d.ts +0 -107
- package/dist/src/scripts/types.js +0 -4
- package/dist/src/scripts/utils/index.d.ts +0 -6
- package/dist/src/scripts/utils/index.js +0 -6
- package/dist/src/scripts/utils/merkle.d.ts +0 -12
- package/dist/src/scripts/utils/merkle.js +0 -47
- package/dist/src/scripts/utils/storage.d.ts +0 -66
- package/dist/src/scripts/utils/storage.js +0 -211
- package/dist/src/scripts/utils/woc.d.ts +0 -26
- package/dist/src/scripts/utils/woc.js +0 -91
- package/dist/src/scripts/wallet/balance.d.ts +0 -22
- package/dist/src/scripts/wallet/balance.js +0 -240
- package/dist/src/scripts/wallet/identity.d.ts +0 -71
- package/dist/src/scripts/wallet/identity.js +0 -152
- package/dist/src/scripts/wallet/index.d.ts +0 -6
- package/dist/src/scripts/wallet/index.js +0 -6
- package/dist/src/scripts/wallet/setup.d.ts +0 -19
- package/dist/src/scripts/wallet/setup.js +0 -119
- package/dist/src/scripts/x-verification/commands.d.ts +0 -27
- package/dist/src/scripts/x-verification/commands.js +0 -222
- package/dist/src/scripts/x-verification/index.d.ts +0 -4
- package/dist/src/scripts/x-verification/index.js +0 -4
- package/dist/src/services/built-in/api-proxy/index.d.ts +0 -6
- package/dist/src/services/built-in/api-proxy/index.js +0 -23
- package/dist/src/services/built-in/code-develop/index.d.ts +0 -6
- package/dist/src/services/built-in/code-develop/index.js +0 -23
- package/dist/src/services/built-in/code-review/index.d.ts +0 -10
- package/dist/src/services/built-in/code-review/index.js +0 -51
- package/dist/src/services/built-in/image-analysis/index.d.ts +0 -6
- package/dist/src/services/built-in/image-analysis/index.js +0 -33
- package/dist/src/services/built-in/memory-store/index.d.ts +0 -6
- package/dist/src/services/built-in/memory-store/index.js +0 -22
- package/dist/src/services/built-in/roulette/index.d.ts +0 -6
- package/dist/src/services/built-in/roulette/index.js +0 -27
- package/dist/src/services/built-in/summarize/index.d.ts +0 -6
- package/dist/src/services/built-in/summarize/index.js +0 -21
- package/dist/src/services/built-in/tell-joke/handler.d.ts +0 -7
- package/dist/src/services/built-in/tell-joke/handler.js +0 -122
- package/dist/src/services/built-in/tell-joke/index.d.ts +0 -9
- package/dist/src/services/built-in/tell-joke/index.js +0 -31
- package/dist/src/services/built-in/translate/index.d.ts +0 -6
- package/dist/src/services/built-in/translate/index.js +0 -21
- package/dist/src/services/built-in/web-research/index.d.ts +0 -9
- package/dist/src/services/built-in/web-research/index.js +0 -51
- package/dist/src/services/index.d.ts +0 -13
- package/dist/src/services/index.js +0 -14
- package/dist/src/services/loader.d.ts +0 -77
- package/dist/src/services/loader.js +0 -292
- package/dist/src/services/manager.d.ts +0 -86
- package/dist/src/services/manager.js +0 -255
- package/dist/src/services/registry.d.ts +0 -98
- package/dist/src/services/registry.js +0 -204
- package/dist/src/services/types.d.ts +0 -230
- package/dist/src/services/types.js +0 -30
- package/dist/src/test/cli.test.d.ts +0 -7
- package/dist/src/test/cli.test.js +0 -330
- package/dist/src/test/comprehensive-overlay.test.d.ts +0 -13
- package/dist/src/test/comprehensive-overlay.test.js +0 -593
- package/dist/src/test/identity-consistency.test.d.ts +0 -6
- package/dist/src/test/identity-consistency.test.js +0 -60
- package/dist/src/test/key-derivation.test.d.ts +0 -12
- package/dist/src/test/key-derivation.test.js +0 -86
- package/dist/src/test/network-address.test.d.ts +0 -9
- package/dist/src/test/network-address.test.js +0 -37
- package/dist/src/test/overlay-submit.test.d.ts +0 -10
- package/dist/src/test/overlay-submit.test.js +0 -460
- package/dist/src/test/request-response-flow.test.d.ts +0 -5
- package/dist/src/test/request-response-flow.test.js +0 -210
- package/dist/src/test/service-system.test.d.ts +0 -5
- package/dist/src/test/service-system.test.js +0 -190
- package/dist/src/test/taskflow.test.d.ts +0 -7
- package/dist/src/test/taskflow.test.js +0 -82
- package/dist/src/test/utils/server-logic.d.ts +0 -98
- package/dist/src/test/utils/server-logic.js +0 -286
- package/dist/src/test/wallet.test.d.ts +0 -7
- package/dist/src/test/wallet.test.js +0 -146
- package/src/core/README.md +0 -246
- package/src/core/config.d.ts +0 -12
- package/src/core/config.d.ts.map +0 -1
- package/src/core/config.js +0 -14
- package/src/core/config.js.map +0 -1
- package/src/core/config.ts +0 -22
- package/src/core/index.ts +0 -42
- package/src/core/payment.d.ts +0 -17
- package/src/core/payment.d.ts.map +0 -1
- package/src/core/payment.js +0 -95
- package/src/core/payment.js.map +0 -1
- package/src/core/payment.ts +0 -111
- package/src/core/types.d.ts +0 -95
- package/src/core/types.d.ts.map +0 -1
- package/src/core/types.js +0 -5
- package/src/core/types.js.map +0 -1
- package/src/core/types.ts +0 -102
- package/src/core/verify.d.ts +0 -29
- package/src/core/verify.d.ts.map +0 -1
- package/src/core/verify.js +0 -105
- package/src/core/verify.js.map +0 -1
- package/src/core/verify.ts +0 -119
- package/src/core/wallet.d.ts +0 -100
- package/src/core/wallet.d.ts.map +0 -1
- package/src/core/wallet.js.map +0 -1
- package/src/core/wallet.ts +0 -323
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* X (Twitter) verification commands.
|
|
3
|
-
*/
|
|
4
|
-
import fs from 'node:fs';
|
|
5
|
-
import { PROTOCOL_ID, TOPICS, LOOKUP_SERVICES, PATHS } from '../config.js';
|
|
6
|
-
import { ok, fail } from '../output.js';
|
|
7
|
-
import { loadIdentity } from '../wallet/identity.js';
|
|
8
|
-
import { loadXVerifications, saveXVerifications, readJsonl, ensureStateDir } from '../utils/storage.js';
|
|
9
|
-
import { buildRealOverlayTransaction, lookupOverlay } from '../overlay/transaction.js';
|
|
10
|
-
// Dynamic import for @bsv/sdk
|
|
11
|
-
let _sdk = null;
|
|
12
|
-
async function getSdk() {
|
|
13
|
-
if (_sdk)
|
|
14
|
-
return _sdk;
|
|
15
|
-
try {
|
|
16
|
-
_sdk = await import('@bsv/sdk');
|
|
17
|
-
return _sdk;
|
|
18
|
-
}
|
|
19
|
-
catch {
|
|
20
|
-
const { fileURLToPath } = await import('node:url');
|
|
21
|
-
const path = await import('node:path');
|
|
22
|
-
const os = await import('node:os');
|
|
23
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
24
|
-
const candidates = [
|
|
25
|
-
path.resolve(__dirname, '..', '..', '..', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
26
|
-
path.resolve(__dirname, '..', '..', '..', '..', '..', 'a2a-bsv', 'packages', 'core', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
27
|
-
path.resolve(os.homedir(), 'a2a-bsv', 'packages', 'core', 'node_modules', '@bsv', 'sdk', 'dist', 'esm', 'mod.js'),
|
|
28
|
-
];
|
|
29
|
-
for (const p of candidates) {
|
|
30
|
-
try {
|
|
31
|
-
_sdk = await import(p);
|
|
32
|
-
return _sdk;
|
|
33
|
-
}
|
|
34
|
-
catch {
|
|
35
|
-
// Try next
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
throw new Error('Cannot find @bsv/sdk. Run setup.sh first.');
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Start X verification: generate a tweet with identity key and signature.
|
|
43
|
-
*/
|
|
44
|
-
export async function cmdXVerifyStart(handleArg) {
|
|
45
|
-
if (!handleArg) {
|
|
46
|
-
return fail('Usage: x-verify-start <@handle>');
|
|
47
|
-
}
|
|
48
|
-
const sdk = await getSdk();
|
|
49
|
-
const handle = handleArg.startsWith('@') ? handleArg : `@${handleArg}`;
|
|
50
|
-
const { identityKey, privKey } = await loadIdentity();
|
|
51
|
-
// Sign the verification message
|
|
52
|
-
const message = `Verify ${identityKey}`;
|
|
53
|
-
const msgHash = sdk.Hash.sha256(Array.from(new TextEncoder().encode(message)));
|
|
54
|
-
const sig = privKey.sign(msgHash);
|
|
55
|
-
const signatureHex = Array.from(sig.toDER()).map((b) => b.toString(16).padStart(2, '0')).join('');
|
|
56
|
-
// Save pending verification
|
|
57
|
-
const pending = {
|
|
58
|
-
identityKey,
|
|
59
|
-
handle,
|
|
60
|
-
signature: signatureHex,
|
|
61
|
-
message,
|
|
62
|
-
createdAt: new Date().toISOString(),
|
|
63
|
-
};
|
|
64
|
-
ensureStateDir();
|
|
65
|
-
fs.writeFileSync(PATHS.pendingXVerification, JSON.stringify(pending, null, 2));
|
|
66
|
-
// Build tweet text (under 280 chars)
|
|
67
|
-
// Use shortened signature (first 40 chars) to fit in tweet
|
|
68
|
-
const tweetText = `BSV Agent Verify: ${identityKey.slice(0, 10)}...${identityKey.slice(-10)} sig:${signatureHex.slice(0, 40)}`;
|
|
69
|
-
return ok({
|
|
70
|
-
tweetText,
|
|
71
|
-
handle,
|
|
72
|
-
identityKey,
|
|
73
|
-
signature: signatureHex,
|
|
74
|
-
note: `Post the tweet above from ${handle}, then run: x-verify-complete <tweet_url>`,
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Complete X verification by checking the posted tweet.
|
|
79
|
-
*/
|
|
80
|
-
export async function cmdXVerifyComplete(tweetUrl) {
|
|
81
|
-
if (!tweetUrl)
|
|
82
|
-
return fail('Usage: x-verify-complete <tweet-url>');
|
|
83
|
-
// Load pending verification
|
|
84
|
-
if (!fs.existsSync(PATHS.pendingXVerification)) {
|
|
85
|
-
return fail('No pending X verification. Run x-verify-start first.');
|
|
86
|
-
}
|
|
87
|
-
const pending = JSON.parse(fs.readFileSync(PATHS.pendingXVerification, 'utf-8'));
|
|
88
|
-
// Extract tweet ID from URL
|
|
89
|
-
const tweetIdMatch = tweetUrl.match(/status\/(\d+)/);
|
|
90
|
-
if (!tweetIdMatch)
|
|
91
|
-
return fail('Invalid tweet URL. Expected format: https://x.com/user/status/123456789');
|
|
92
|
-
const tweetId = tweetIdMatch[1];
|
|
93
|
-
// Fetch the tweet using bird CLI
|
|
94
|
-
let tweetData;
|
|
95
|
-
try {
|
|
96
|
-
const { execSync } = await import('child' + '_' + 'process');
|
|
97
|
-
const birdOutput = execSync(`bird read ${tweetUrl} --json 2>/dev/null`, {
|
|
98
|
-
encoding: 'utf-8',
|
|
99
|
-
timeout: 30000,
|
|
100
|
-
});
|
|
101
|
-
tweetData = JSON.parse(birdOutput);
|
|
102
|
-
}
|
|
103
|
-
catch (err) {
|
|
104
|
-
return fail(`Failed to fetch tweet: ${err.message}. Make sure bird CLI is configured.`);
|
|
105
|
-
}
|
|
106
|
-
// Verify the tweet contains our identity key and partial signature
|
|
107
|
-
const tweetText = tweetData.text || tweetData.full_text || '';
|
|
108
|
-
if (!tweetText.includes(pending.identityKey.slice(0, 10))) {
|
|
109
|
-
return fail('Tweet does not contain the expected identity key.');
|
|
110
|
-
}
|
|
111
|
-
// Check for partial signature (first 40 chars)
|
|
112
|
-
if (!tweetText.includes(pending.signature.slice(0, 40))) {
|
|
113
|
-
return fail('Tweet does not contain the expected verification signature prefix.');
|
|
114
|
-
}
|
|
115
|
-
// Get the X user info from the tweet
|
|
116
|
-
const xUserId = tweetData.user?.id_str || tweetData.authorId || tweetData.author?.id || tweetData.user_id;
|
|
117
|
-
const xHandle = tweetData.user?.screen_name || tweetData.author?.username || tweetData.author?.name || pending.handle.replace('@', '');
|
|
118
|
-
if (!xUserId) {
|
|
119
|
-
return fail('Could not extract X user ID from tweet data.');
|
|
120
|
-
}
|
|
121
|
-
// Build on-chain verification record
|
|
122
|
-
const verificationPayload = {
|
|
123
|
-
protocol: PROTOCOL_ID,
|
|
124
|
-
type: 'x-verification',
|
|
125
|
-
identityKey: pending.identityKey,
|
|
126
|
-
xHandle: `@${xHandle}`,
|
|
127
|
-
xUserId,
|
|
128
|
-
tweetId,
|
|
129
|
-
tweetUrl,
|
|
130
|
-
signature: pending.signature,
|
|
131
|
-
verifiedAt: new Date().toISOString(),
|
|
132
|
-
};
|
|
133
|
-
// Submit to overlay (may fail if topic manager not deployed yet)
|
|
134
|
-
let result = { txid: null, funded: 'pending-server-support' };
|
|
135
|
-
let onChainStored = false;
|
|
136
|
-
try {
|
|
137
|
-
result = await buildRealOverlayTransaction(verificationPayload, TOPICS.X_VERIFICATION);
|
|
138
|
-
onChainStored = true;
|
|
139
|
-
}
|
|
140
|
-
catch (err) {
|
|
141
|
-
console.error(`[x-verify] On-chain storage failed: ${err.message}`);
|
|
142
|
-
console.error('[x-verify] Storing verification locally.');
|
|
143
|
-
}
|
|
144
|
-
// Save verification locally
|
|
145
|
-
const verifications = loadXVerifications();
|
|
146
|
-
verifications.push({
|
|
147
|
-
...verificationPayload,
|
|
148
|
-
txid: result.txid,
|
|
149
|
-
});
|
|
150
|
-
saveXVerifications(verifications);
|
|
151
|
-
// Clean up pending
|
|
152
|
-
fs.unlinkSync(PATHS.pendingXVerification);
|
|
153
|
-
return ok({
|
|
154
|
-
verified: true,
|
|
155
|
-
identityKey: pending.identityKey,
|
|
156
|
-
xHandle: `@${xHandle}`,
|
|
157
|
-
xUserId,
|
|
158
|
-
tweetId,
|
|
159
|
-
txid: result.txid,
|
|
160
|
-
funded: result.funded,
|
|
161
|
-
onChainStored,
|
|
162
|
-
note: onChainStored ? undefined : 'Stored locally. On-chain anchoring pending server topic manager deployment.',
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* List verified X accounts (local cache).
|
|
167
|
-
*/
|
|
168
|
-
export async function cmdXVerifications() {
|
|
169
|
-
const verifications = loadXVerifications();
|
|
170
|
-
return ok({ verifications, count: verifications.length });
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Lookup X verifications from the overlay network.
|
|
174
|
-
*/
|
|
175
|
-
export async function cmdXLookup(query) {
|
|
176
|
-
try {
|
|
177
|
-
const lookupQuery = query
|
|
178
|
-
? (query.startsWith('@') ? { xHandle: query } : { identityKey: query })
|
|
179
|
-
: { type: 'list' };
|
|
180
|
-
const response = await lookupOverlay(LOOKUP_SERVICES.X_VERIFICATIONS, lookupQuery);
|
|
181
|
-
return ok({ verifications: response.outputs || response || [], query: lookupQuery });
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
return ok({ verifications: [], query, note: 'X verification lookup service may not be deployed yet.' });
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* List pending X engagement requests.
|
|
189
|
-
*/
|
|
190
|
-
export async function cmdXEngagementQueue() {
|
|
191
|
-
if (!fs.existsSync(PATHS.xEngagementQueue)) {
|
|
192
|
-
return ok({ queue: [], count: 0 });
|
|
193
|
-
}
|
|
194
|
-
const queue = readJsonl(PATHS.xEngagementQueue).filter(e => e.status === 'pending');
|
|
195
|
-
return ok({ queue, count: queue.length });
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Mark an X engagement request as fulfilled.
|
|
199
|
-
*/
|
|
200
|
-
export async function cmdXEngagementFulfill(requestId, proofUrl) {
|
|
201
|
-
if (!requestId)
|
|
202
|
-
return fail('Usage: x-engagement-fulfill <requestId> [proofUrl]');
|
|
203
|
-
if (!fs.existsSync(PATHS.xEngagementQueue)) {
|
|
204
|
-
return fail('No engagement queue found.');
|
|
205
|
-
}
|
|
206
|
-
const queue = readJsonl(PATHS.xEngagementQueue);
|
|
207
|
-
const entryIndex = queue.findIndex(e => e.requestId === requestId);
|
|
208
|
-
if (entryIndex === -1) {
|
|
209
|
-
return fail(`Request ${requestId} not found in queue.`);
|
|
210
|
-
}
|
|
211
|
-
// Mark as fulfilled
|
|
212
|
-
queue[entryIndex].status = 'fulfilled';
|
|
213
|
-
queue[entryIndex].fulfilledAt = new Date().toISOString();
|
|
214
|
-
queue[entryIndex].proofUrl = proofUrl || null;
|
|
215
|
-
// Rewrite queue file
|
|
216
|
-
fs.writeFileSync(PATHS.xEngagementQueue, queue.map(e => JSON.stringify(e)).join('\n') + '\n');
|
|
217
|
-
return ok({
|
|
218
|
-
fulfilled: true,
|
|
219
|
-
requestId,
|
|
220
|
-
entry: queue[entryIndex],
|
|
221
|
-
});
|
|
222
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* API Proxy service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const apiProxyService = {
|
|
6
|
-
id: 'api-proxy',
|
|
7
|
-
name: 'API Proxy',
|
|
8
|
-
description: 'Proxy HTTP requests to external APIs. Input: {url, method, headers, body}.',
|
|
9
|
-
defaultPrice: 15,
|
|
10
|
-
category: ServiceCategory.UTILITY,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
url: { type: 'string', description: 'Target API URL' },
|
|
15
|
-
method: { type: 'string', enum: ['GET', 'POST', 'PUT', 'DELETE'], description: 'HTTP method' },
|
|
16
|
-
headers: { type: 'object', description: 'Request headers' },
|
|
17
|
-
body: { description: 'Request body' },
|
|
18
|
-
timeout: { type: 'number', description: 'Request timeout in ms' }
|
|
19
|
-
},
|
|
20
|
-
required: ['url']
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export default apiProxyService;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code Development service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const codeDevelopService = {
|
|
6
|
-
id: 'code-develop',
|
|
7
|
-
name: 'Code Development',
|
|
8
|
-
description: 'Generate code from requirements. Specify language, task description, and constraints.',
|
|
9
|
-
defaultPrice: 100,
|
|
10
|
-
category: ServiceCategory.DEVELOPMENT,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
requirements: { type: 'string', description: 'Detailed description of what code to generate' },
|
|
15
|
-
language: { type: 'string', description: 'Programming language (e.g., JavaScript, Python, Java)' },
|
|
16
|
-
constraints: { type: 'string', description: 'Any specific constraints or requirements' },
|
|
17
|
-
style: { type: 'string', description: 'Code style preferences' },
|
|
18
|
-
includeTests: { type: 'boolean', description: 'Whether to include unit tests' }
|
|
19
|
-
},
|
|
20
|
-
required: ['requirements', 'language']
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export default codeDevelopService;
|
|
@@ -1,10 +0,0 @@
|
|
|
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
|
-
import { ServiceDefinition } from '../../types.js';
|
|
9
|
-
declare const codeReviewService: ServiceDefinition;
|
|
10
|
-
export default codeReviewService;
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
import { ServiceCategory } from '../../types.js';
|
|
9
|
-
const codeReviewService = {
|
|
10
|
-
id: 'code-review',
|
|
11
|
-
name: 'Code Review',
|
|
12
|
-
description: 'Thorough code review covering bugs, security issues, style, performance, and improvement suggestions.',
|
|
13
|
-
defaultPrice: 50,
|
|
14
|
-
category: ServiceCategory.DEVELOPMENT,
|
|
15
|
-
inputSchema: {
|
|
16
|
-
type: 'object',
|
|
17
|
-
properties: {
|
|
18
|
-
code: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
description: 'Code to review'
|
|
21
|
-
},
|
|
22
|
-
language: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
description: 'Programming language (auto-detected if not provided)'
|
|
25
|
-
},
|
|
26
|
-
prUrl: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
description: 'GitHub/GitLab PR URL to review instead of direct code'
|
|
29
|
-
},
|
|
30
|
-
focusAreas: {
|
|
31
|
-
type: 'array',
|
|
32
|
-
items: {
|
|
33
|
-
type: 'string',
|
|
34
|
-
enum: ['security', 'performance', 'style', 'bugs', 'maintainability', 'testing']
|
|
35
|
-
},
|
|
36
|
-
description: 'Specific areas to focus the review on'
|
|
37
|
-
},
|
|
38
|
-
severity: {
|
|
39
|
-
type: 'string',
|
|
40
|
-
enum: ['basic', 'detailed', 'comprehensive'],
|
|
41
|
-
description: 'Depth of review (default: detailed)'
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
anyOf: [
|
|
45
|
-
{ required: ['code'] },
|
|
46
|
-
{ required: ['prUrl'] }
|
|
47
|
-
]
|
|
48
|
-
}
|
|
49
|
-
// No handler - this service uses agent mode for full LLM capabilities
|
|
50
|
-
};
|
|
51
|
-
export default codeReviewService;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Image Analysis service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const imageAnalysisService = {
|
|
6
|
-
id: 'image-analysis',
|
|
7
|
-
name: 'Image Analysis',
|
|
8
|
-
description: 'Analyze and describe images. Identify objects, text, scenes, and more.',
|
|
9
|
-
defaultPrice: 30,
|
|
10
|
-
category: ServiceCategory.AI,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
imageUrl: { type: 'string', description: 'URL of the image to analyze' },
|
|
15
|
-
imageData: { type: 'string', description: 'Base64 encoded image data' },
|
|
16
|
-
analysisType: {
|
|
17
|
-
type: 'string',
|
|
18
|
-
enum: ['general', 'objects', 'text', 'faces', 'scenes'],
|
|
19
|
-
description: 'Type of analysis to perform'
|
|
20
|
-
},
|
|
21
|
-
detailLevel: {
|
|
22
|
-
type: 'string',
|
|
23
|
-
enum: ['brief', 'detailed', 'comprehensive'],
|
|
24
|
-
description: 'Level of detail in analysis'
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
oneOf: [
|
|
28
|
-
{ required: ['imageUrl'] },
|
|
29
|
-
{ required: ['imageData'] }
|
|
30
|
-
]
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
export default imageAnalysisService;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Store service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const memoryStoreService = {
|
|
6
|
-
id: 'memory-store',
|
|
7
|
-
name: 'Memory Store',
|
|
8
|
-
description: 'Persistent key-value storage for agents. Operations: set, get, delete, list.',
|
|
9
|
-
defaultPrice: 10,
|
|
10
|
-
category: ServiceCategory.UTILITY,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
operation: { type: 'string', enum: ['set', 'get', 'delete', 'list'], description: 'Storage operation' },
|
|
15
|
-
key: { type: 'string', description: 'Storage key (required for set, get, delete)' },
|
|
16
|
-
value: { description: 'Value to store (required for set operation)' },
|
|
17
|
-
namespace: { type: 'string', description: 'Optional namespace for keys' }
|
|
18
|
-
},
|
|
19
|
-
required: ['operation']
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
export default memoryStoreService;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Roulette service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const rouletteService = {
|
|
6
|
-
id: 'roulette',
|
|
7
|
-
name: 'Roulette',
|
|
8
|
-
description: 'European roulette (single zero). Bet on: number 0-36, red/black, odd/even, high/low.',
|
|
9
|
-
defaultPrice: 10,
|
|
10
|
-
category: ServiceCategory.ENTERTAINMENT,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
bet: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'Bet type: specific number (0-36), red, black, odd, even, high (19-36), low (1-18), or dozen (1st, 2nd, 3rd)'
|
|
17
|
-
},
|
|
18
|
-
amount: {
|
|
19
|
-
type: 'number',
|
|
20
|
-
description: 'Bet amount (optional, for display purposes)',
|
|
21
|
-
minimum: 1
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
required: ['bet']
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
export default rouletteService;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Summarize service definition.
|
|
3
|
-
*/
|
|
4
|
-
import { ServiceCategory } from '../../types.js';
|
|
5
|
-
const summarizeService = {
|
|
6
|
-
id: 'summarize',
|
|
7
|
-
name: 'Summarize',
|
|
8
|
-
description: 'Summarize long text, articles, or documents into concise bullet points.',
|
|
9
|
-
defaultPrice: 20,
|
|
10
|
-
category: ServiceCategory.AI,
|
|
11
|
-
inputSchema: {
|
|
12
|
-
type: 'object',
|
|
13
|
-
properties: {
|
|
14
|
-
text: { type: 'string', description: 'Text to summarize' },
|
|
15
|
-
maxLength: { type: 'number', description: 'Maximum length of summary' },
|
|
16
|
-
format: { type: 'string', enum: ['bullets', 'paragraph'], description: 'Output format' }
|
|
17
|
-
},
|
|
18
|
-
required: ['text']
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
export default summarizeService;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tell Joke service handler.
|
|
3
|
-
*
|
|
4
|
-
* Provides a simple legacy handler for joke telling when not in agent mode.
|
|
5
|
-
*/
|
|
6
|
-
// Simple joke database
|
|
7
|
-
const jokes = {
|
|
8
|
-
dad: [
|
|
9
|
-
"Why don't scientists trust atoms? Because they make up everything!",
|
|
10
|
-
"I told my wife she was drawing her eyebrows too high. She seemed surprised.",
|
|
11
|
-
"Why don't eggs tell jokes? They'd crack each other up!",
|
|
12
|
-
"I invented a new word: Plagiarism!",
|
|
13
|
-
"What do you call a fake noodle? An impasta!"
|
|
14
|
-
],
|
|
15
|
-
pun: [
|
|
16
|
-
"I wondered why the baseball was getting bigger. Then it hit me.",
|
|
17
|
-
"A bicycle can't stand on its own because it's two-tired.",
|
|
18
|
-
"What do you call a bear with no teeth? A gummy bear!",
|
|
19
|
-
"I used to be a banker, but I lost interest.",
|
|
20
|
-
"The math teacher called in sick with algebra."
|
|
21
|
-
],
|
|
22
|
-
tech: [
|
|
23
|
-
"Why do programmers prefer dark mode? Because light attracts bugs!",
|
|
24
|
-
"How many programmers does it take to change a light bulb? None, that's a hardware problem.",
|
|
25
|
-
"Why did the developer go broke? Because he used up all his cache!",
|
|
26
|
-
"There are only 10 types of people in the world: those who understand binary and those who don't.",
|
|
27
|
-
"A SQL query goes into a bar, walks up to two tables and asks... 'Can I join you?'"
|
|
28
|
-
],
|
|
29
|
-
general: [
|
|
30
|
-
"What do you get when you cross a snowman and a vampire? Frostbite!",
|
|
31
|
-
"Why did the scarecrow win an award? He was outstanding in his field!",
|
|
32
|
-
"What's orange and sounds like a parrot? A carrot!",
|
|
33
|
-
"Why don't some couples go to the gym? Because some relationships don't work out!",
|
|
34
|
-
"What did the ocean say to the beach? Nothing, it just waved!"
|
|
35
|
-
]
|
|
36
|
-
};
|
|
37
|
-
export const tellJokeHandler = {
|
|
38
|
-
/**
|
|
39
|
-
* Validate joke request input.
|
|
40
|
-
*/
|
|
41
|
-
validate(input) {
|
|
42
|
-
// Allow empty input for random jokes
|
|
43
|
-
if (!input) {
|
|
44
|
-
return { valid: true, sanitized: {} };
|
|
45
|
-
}
|
|
46
|
-
if (typeof input !== 'object') {
|
|
47
|
-
return { valid: false, error: 'Input must be an object or empty for random joke' };
|
|
48
|
-
}
|
|
49
|
-
const sanitized = {};
|
|
50
|
-
// Validate topic if provided
|
|
51
|
-
if (input.topic !== undefined) {
|
|
52
|
-
if (typeof input.topic !== 'string') {
|
|
53
|
-
return { valid: false, error: 'Topic must be a string' };
|
|
54
|
-
}
|
|
55
|
-
sanitized.topic = input.topic.toLowerCase().trim();
|
|
56
|
-
}
|
|
57
|
-
// Validate style if provided
|
|
58
|
-
if (input.style !== undefined) {
|
|
59
|
-
const validStyles = ['dad', 'pun', 'tech', 'general'];
|
|
60
|
-
if (typeof input.style !== 'string' || !validStyles.includes(input.style)) {
|
|
61
|
-
return {
|
|
62
|
-
valid: false,
|
|
63
|
-
error: `Style must be one of: ${validStyles.join(', ')}`
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
sanitized.style = input.style;
|
|
67
|
-
}
|
|
68
|
-
return { valid: true, sanitized };
|
|
69
|
-
},
|
|
70
|
-
/**
|
|
71
|
-
* Process the joke request.
|
|
72
|
-
*/
|
|
73
|
-
async process(input, context) {
|
|
74
|
-
try {
|
|
75
|
-
const startTime = Date.now();
|
|
76
|
-
// Determine joke style
|
|
77
|
-
let style = input.style || 'general';
|
|
78
|
-
// If topic is provided but no style, try to match topic to style
|
|
79
|
-
if (input.topic && !input.style) {
|
|
80
|
-
const topic = input.topic.toLowerCase();
|
|
81
|
-
if (topic.includes('dad') || topic.includes('father')) {
|
|
82
|
-
style = 'dad';
|
|
83
|
-
}
|
|
84
|
-
else if (topic.includes('pun') || topic.includes('wordplay')) {
|
|
85
|
-
style = 'pun';
|
|
86
|
-
}
|
|
87
|
-
else if (topic.includes('programming') || topic.includes('tech') || topic.includes('computer')) {
|
|
88
|
-
style = 'tech';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
// Get joke from the selected category
|
|
92
|
-
const jokeCategory = jokes[style] || jokes.general;
|
|
93
|
-
const joke = jokeCategory[Math.floor(Math.random() * jokeCategory.length)];
|
|
94
|
-
const processingTime = Date.now() - startTime;
|
|
95
|
-
return {
|
|
96
|
-
success: true,
|
|
97
|
-
data: {
|
|
98
|
-
joke,
|
|
99
|
-
style,
|
|
100
|
-
topic: input.topic || 'random',
|
|
101
|
-
timestamp: new Date().toISOString()
|
|
102
|
-
},
|
|
103
|
-
metadata: {
|
|
104
|
-
processingTime,
|
|
105
|
-
version: '1.0',
|
|
106
|
-
jokeCount: jokeCategory.length,
|
|
107
|
-
source: 'built-in-handler'
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
return {
|
|
113
|
-
success: false,
|
|
114
|
-
error: error instanceof Error ? error.message : String(error),
|
|
115
|
-
metadata: {
|
|
116
|
-
serviceId: 'tell-joke',
|
|
117
|
-
errorType: 'processing_error'
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tell Joke service definition.
|
|
3
|
-
*
|
|
4
|
-
* A simple service that tells random jokes. This demonstrates
|
|
5
|
-
* a basic service that works in both handler and agent modes.
|
|
6
|
-
*/
|
|
7
|
-
import { ServiceDefinition } from '../../types.js';
|
|
8
|
-
declare const tellJokeService: ServiceDefinition;
|
|
9
|
-
export default tellJokeService;
|