@aibtc/mcp-server 1.40.0 → 1.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/services/credentials.d.ts +31 -0
  2. package/dist/services/credentials.d.ts.map +1 -0
  3. package/dist/services/credentials.js +162 -0
  4. package/dist/services/credentials.js.map +1 -0
  5. package/dist/services/erc8004.service.d.ts +28 -0
  6. package/dist/services/erc8004.service.d.ts.map +1 -1
  7. package/dist/services/erc8004.service.js +115 -0
  8. package/dist/services/erc8004.service.js.map +1 -1
  9. package/dist/services/unisat-indexer.d.ts +97 -0
  10. package/dist/services/unisat-indexer.d.ts.map +1 -0
  11. package/dist/services/unisat-indexer.js +178 -0
  12. package/dist/services/unisat-indexer.js.map +1 -0
  13. package/dist/tools/bounty-scanner.tools.d.ts +29 -0
  14. package/dist/tools/bounty-scanner.tools.d.ts.map +1 -0
  15. package/dist/tools/bounty-scanner.tools.js +405 -0
  16. package/dist/tools/bounty-scanner.tools.js.map +1 -0
  17. package/dist/tools/credentials.tools.d.ts +9 -0
  18. package/dist/tools/credentials.tools.d.ts.map +1 -0
  19. package/dist/tools/credentials.tools.js +151 -0
  20. package/dist/tools/credentials.tools.js.map +1 -0
  21. package/dist/tools/identity.tools.d.ts +22 -0
  22. package/dist/tools/identity.tools.d.ts.map +1 -0
  23. package/dist/tools/identity.tools.js +404 -0
  24. package/dist/tools/identity.tools.js.map +1 -0
  25. package/dist/tools/index.d.ts.map +1 -1
  26. package/dist/tools/index.js +15 -0
  27. package/dist/tools/index.js.map +1 -1
  28. package/dist/tools/runes.tools.d.ts +25 -0
  29. package/dist/tools/runes.tools.d.ts.map +1 -0
  30. package/dist/tools/runes.tools.js +464 -0
  31. package/dist/tools/runes.tools.js.map +1 -0
  32. package/dist/tools/skill-mappings.d.ts.map +1 -1
  33. package/dist/tools/skill-mappings.js +40 -0
  34. package/dist/tools/skill-mappings.js.map +1 -1
  35. package/dist/tools/souldinals.tools.d.ts +18 -0
  36. package/dist/tools/souldinals.tools.d.ts.map +1 -0
  37. package/dist/tools/souldinals.tools.js +551 -0
  38. package/dist/tools/souldinals.tools.js.map +1 -0
  39. package/dist/tools/stacking-lottery.tools.d.ts.map +1 -1
  40. package/dist/tools/stacking-lottery.tools.js +7 -4
  41. package/dist/tools/stacking-lottery.tools.js.map +1 -1
  42. package/dist/transactions/rune-transfer-builder.d.ts +46 -0
  43. package/dist/transactions/rune-transfer-builder.d.ts.map +1 -0
  44. package/dist/transactions/rune-transfer-builder.js +130 -0
  45. package/dist/transactions/rune-transfer-builder.js.map +1 -0
  46. package/dist/transactions/runestone-builder.d.ts +40 -0
  47. package/dist/transactions/runestone-builder.d.ts.map +1 -0
  48. package/dist/transactions/runestone-builder.js +76 -0
  49. package/dist/transactions/runestone-builder.js.map +1 -0
  50. package/package.json +1 -1
  51. package/skill/SKILL.md +1 -1
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Souldinals tools
3
+ *
4
+ * MCP tools for managing Souldinals — soul.md files inscribed as child ordinal
5
+ * inscriptions on Bitcoin L1. Provides:
6
+ *
7
+ * - souldinals_inscribe_soul: Step 1 — Broadcast commit tx for a soul child inscription
8
+ * - souldinals_reveal_soul: Step 2 — Broadcast reveal tx after commit confirms
9
+ * - souldinals_list_souls: List soul inscriptions (text/markdown) owned by a Taproot address
10
+ * - souldinals_load_soul: Load the oldest soul inscription content from a Taproot address
11
+ * - souldinals_display_soul: Fetch and parse soul traits from a specific inscription
12
+ *
13
+ * Uses child inscription builders for on-chain provenance (parent-child relationship)
14
+ * and Unisat Ordinals API for listing/loading inscriptions.
15
+ */
16
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
+ export declare function registerSouldinalsTools(server: McpServer): void;
18
+ //# sourceMappingURL=souldinals.tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"souldinals.tools.d.ts","sourceRoot":"","sources":["../../src/tools/souldinals.tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA2QpE,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAkf/D"}
@@ -0,0 +1,551 @@
1
+ /**
2
+ * Souldinals tools
3
+ *
4
+ * MCP tools for managing Souldinals — soul.md files inscribed as child ordinal
5
+ * inscriptions on Bitcoin L1. Provides:
6
+ *
7
+ * - souldinals_inscribe_soul: Step 1 — Broadcast commit tx for a soul child inscription
8
+ * - souldinals_reveal_soul: Step 2 — Broadcast reveal tx after commit confirms
9
+ * - souldinals_list_souls: List soul inscriptions (text/markdown) owned by a Taproot address
10
+ * - souldinals_load_soul: Load the oldest soul inscription content from a Taproot address
11
+ * - souldinals_display_soul: Fetch and parse soul traits from a specific inscription
12
+ *
13
+ * Uses child inscription builders for on-chain provenance (parent-child relationship)
14
+ * and Unisat Ordinals API for listing/loading inscriptions.
15
+ */
16
+ import { z } from "zod";
17
+ import { NETWORK } from "../config/networks.js";
18
+ import { createJsonResponse, createErrorResponse } from "../utils/index.js";
19
+ import { MempoolApi, getMempoolTxUrl } from "../services/mempool-api.js";
20
+ import { getWalletManager } from "../services/wallet-manager.js";
21
+ import { signBtcTransaction } from "../transactions/bitcoin-builder.js";
22
+ import { buildChildCommitTransaction, buildChildRevealTransaction, deriveChildRevealScript, lookupParentInscription, } from "../transactions/child-inscription-builder.js";
23
+ // ---------------------------------------------------------------------------
24
+ // Constants
25
+ // ---------------------------------------------------------------------------
26
+ const SOUL_CONTENT_TYPE = "text/markdown";
27
+ const UNISAT_API_BASE = "https://open-api.unisat.io";
28
+ // ---------------------------------------------------------------------------
29
+ // Unisat API helpers
30
+ // ---------------------------------------------------------------------------
31
+ function unisatHeaders() {
32
+ const headers = {
33
+ "Content-Type": "application/json",
34
+ };
35
+ if (process.env.UNISAT_API_KEY) {
36
+ headers["Authorization"] = `Bearer ${process.env.UNISAT_API_KEY}`;
37
+ }
38
+ return headers;
39
+ }
40
+ /**
41
+ * Fetch soul inscriptions (text/markdown) for a Taproot address from Unisat.
42
+ */
43
+ async function fetchSoulInscriptions(address) {
44
+ const url = `${UNISAT_API_BASE}/v1/indexer/address/${address}/inscription-data?cursor=0&size=60`;
45
+ const response = await fetch(url, { headers: unisatHeaders() });
46
+ if (!response.ok) {
47
+ throw new Error(`Unisat API error ${response.status}: ${await response.text()}`);
48
+ }
49
+ const data = (await response.json());
50
+ const items = data.data?.inscription ?? [];
51
+ return items
52
+ .filter((item) => item.contentType === SOUL_CONTENT_TYPE)
53
+ .map((item) => ({
54
+ id: item.inscriptionId,
55
+ number: item.inscriptionNumber,
56
+ contentType: item.contentType,
57
+ contentLength: item.contentLength,
58
+ timestamp: new Date(item.timestamp * 1000).toISOString(),
59
+ genesisBlockHeight: item.genesisBlockHeight,
60
+ }));
61
+ }
62
+ /**
63
+ * Fetch raw inscription content from Unisat.
64
+ */
65
+ async function fetchInscriptionContent(inscriptionId) {
66
+ const url = `${UNISAT_API_BASE}/v1/indexer/inscription/content/${encodeURIComponent(inscriptionId)}`;
67
+ const response = await fetch(url, { headers: unisatHeaders() });
68
+ if (!response.ok) {
69
+ throw new Error(`Failed to fetch inscription content (${response.status}): ${await response.text()}`);
70
+ }
71
+ return await response.text();
72
+ }
73
+ /**
74
+ * Fetch inscription metadata from Unisat.
75
+ */
76
+ async function fetchInscriptionMetadata(inscriptionId) {
77
+ const url = `${UNISAT_API_BASE}/v1/indexer/inscription/info/${encodeURIComponent(inscriptionId)}`;
78
+ const response = await fetch(url, { headers: unisatHeaders() });
79
+ if (!response.ok) {
80
+ throw new Error(`Failed to fetch inscription metadata (${response.status}): ${await response.text()}`);
81
+ }
82
+ const data = (await response.json());
83
+ const item = data.data;
84
+ return {
85
+ contentType: item.contentType,
86
+ contentLength: item.contentLength,
87
+ timestamp: new Date(item.timestamp * 1000).toISOString(),
88
+ genesisBlockHeight: item.genesisBlockHeight,
89
+ };
90
+ }
91
+ /**
92
+ * Parse soul traits from Markdown content.
93
+ * Extracts name (first H1), description (first paragraph after H1),
94
+ * values (list items under "Values" or "Core Values" heading),
95
+ * focus areas (list items under "Focus" or "Focus Areas" heading),
96
+ * and all named sections.
97
+ */
98
+ function parseSoulTraits(markdown) {
99
+ const lines = markdown.split("\n");
100
+ let name;
101
+ let description;
102
+ const sections = {};
103
+ const values = [];
104
+ const focusAreas = [];
105
+ let currentSection = null;
106
+ let sectionLines = [];
107
+ let afterFirstH1 = false;
108
+ const descriptionLines = [];
109
+ let inDescriptionBlock = false;
110
+ for (const line of lines) {
111
+ // H1 heading — treat as name
112
+ if (line.startsWith("# ")) {
113
+ if (currentSection !== null) {
114
+ sections[currentSection] = sectionLines.join("\n").trim();
115
+ sectionLines = [];
116
+ }
117
+ if (!name) {
118
+ name = line.replace(/^# /, "").trim();
119
+ afterFirstH1 = true;
120
+ inDescriptionBlock = true;
121
+ }
122
+ else {
123
+ currentSection = line.replace(/^# /, "").trim();
124
+ }
125
+ continue;
126
+ }
127
+ // H2/H3 headings — section boundaries
128
+ if (line.startsWith("## ") || line.startsWith("### ")) {
129
+ if (currentSection !== null) {
130
+ sections[currentSection] = sectionLines.join("\n").trim();
131
+ }
132
+ currentSection = line.replace(/^#{2,3} /, "").trim();
133
+ sectionLines = [];
134
+ inDescriptionBlock = false;
135
+ continue;
136
+ }
137
+ // Capture description (non-empty lines immediately after H1, before any heading)
138
+ if (afterFirstH1 && inDescriptionBlock && line.trim()) {
139
+ descriptionLines.push(line.trim());
140
+ }
141
+ else if (afterFirstH1 &&
142
+ inDescriptionBlock &&
143
+ !line.trim() &&
144
+ descriptionLines.length > 0) {
145
+ inDescriptionBlock = false;
146
+ }
147
+ // Accumulate section content
148
+ if (currentSection !== null) {
149
+ sectionLines.push(line);
150
+ const listMatch = line.match(/^[-*]\s+(.+)/);
151
+ if (listMatch) {
152
+ const item = listMatch[1].trim();
153
+ const sectionLower = currentSection.toLowerCase();
154
+ if (sectionLower.includes("value")) {
155
+ values.push(item);
156
+ }
157
+ else if (sectionLower.includes("focus")) {
158
+ focusAreas.push(item);
159
+ }
160
+ }
161
+ }
162
+ }
163
+ // Flush last section
164
+ if (currentSection !== null) {
165
+ sections[currentSection] = sectionLines.join("\n").trim();
166
+ }
167
+ if (descriptionLines.length > 0) {
168
+ description = descriptionLines.join(" ");
169
+ }
170
+ return { name, description, values, focusAreas, sections };
171
+ }
172
+ // ---------------------------------------------------------------------------
173
+ // Fee rate resolver
174
+ // ---------------------------------------------------------------------------
175
+ async function resolveFeeRate(feeRate, mempoolApi) {
176
+ if (typeof feeRate === "number")
177
+ return feeRate;
178
+ const fees = await mempoolApi.getFeeEstimates();
179
+ switch (feeRate) {
180
+ case "fast":
181
+ return fees.fastestFee;
182
+ case "slow":
183
+ return fees.hourFee;
184
+ default:
185
+ return fees.halfHourFee;
186
+ }
187
+ }
188
+ // ---------------------------------------------------------------------------
189
+ // Tool registration
190
+ // ---------------------------------------------------------------------------
191
+ export function registerSouldinalsTools(server) {
192
+ // --------------------------------------------------------------------------
193
+ // souldinals_inscribe_soul — Step 1: Broadcast commit tx
194
+ // --------------------------------------------------------------------------
195
+ server.registerTool("souldinals_inscribe_soul", {
196
+ description: "Inscribe a soul.md as a child inscription - STEP 1: Broadcast commit transaction.\n\n" +
197
+ "Creates a child inscription linked to a parent genesis inscription, establishing " +
198
+ "on-chain provenance per the Ordinals provenance spec. Content type is always text/markdown.\n\n" +
199
+ "You must own the parent inscription (it must be at your wallet's Taproot address).\n\n" +
200
+ "This broadcasts the commit tx and returns immediately. After it confirms " +
201
+ "(typically 10-60 min), use `souldinals_reveal_soul` to complete.\n\n" +
202
+ "Returns: commitTxid, revealAmount, contentBase64 (save all for souldinals_reveal_soul)",
203
+ inputSchema: {
204
+ parentInscriptionId: z
205
+ .string()
206
+ .describe("Genesis parent inscription ID (format: {txid}i{index}). You must own this inscription."),
207
+ soulContent: z
208
+ .string()
209
+ .describe("The soul.md content as a string (Markdown text). Will be inscribed as text/markdown."),
210
+ feeRate: z
211
+ .union([z.enum(["fast", "medium", "slow"]), z.number().positive()])
212
+ .optional()
213
+ .describe("Fee rate: 'fast' (~10 min), 'medium' (~30 min), 'slow' (~1 hr), or number in sat/vB (default: medium)"),
214
+ },
215
+ }, async ({ parentInscriptionId, soulContent, feeRate }) => {
216
+ try {
217
+ const walletManager = getWalletManager();
218
+ const sessionInfo = walletManager.getSessionInfo();
219
+ if (!sessionInfo) {
220
+ return createErrorResponse(new Error("Wallet not unlocked. Use wallet_unlock first."));
221
+ }
222
+ if (!sessionInfo.btcAddress || !sessionInfo.taprootAddress) {
223
+ return createErrorResponse(new Error("Wallet doesn't have Bitcoin addresses. Use a managed wallet."));
224
+ }
225
+ const account = walletManager.getAccount();
226
+ if (!account ||
227
+ !account.btcPrivateKey ||
228
+ !account.btcPublicKey ||
229
+ !account.taprootPrivateKey ||
230
+ !account.taprootPublicKey) {
231
+ return createErrorResponse(new Error("Bitcoin and Taproot keys not available. Wallet may not be unlocked."));
232
+ }
233
+ if (!soulContent.trim()) {
234
+ return createErrorResponse(new Error("Soul content cannot be empty."));
235
+ }
236
+ // Look up parent inscription and validate ownership
237
+ const parentInfo = await lookupParentInscription(parentInscriptionId);
238
+ if (parentInfo.address !== sessionInfo.taprootAddress) {
239
+ return createErrorResponse(new Error(`Parent inscription is owned by ${parentInfo.address}, but your Taproot address is ${sessionInfo.taprootAddress}. You must own the parent inscription.`));
240
+ }
241
+ // Encode soul content
242
+ const body = Buffer.from(soulContent, "utf-8");
243
+ const contentBase64 = body.toString("base64");
244
+ const inscription = {
245
+ contentType: SOUL_CONTENT_TYPE,
246
+ body,
247
+ };
248
+ const mempoolApi = new MempoolApi(NETWORK);
249
+ const actualFeeRate = await resolveFeeRate(feeRate, mempoolApi);
250
+ // Get UTXOs for funding
251
+ const utxos = await mempoolApi.getUtxos(sessionInfo.btcAddress);
252
+ if (utxos.length === 0) {
253
+ return createErrorResponse(new Error(`No UTXOs available for address ${sessionInfo.btcAddress}. Send some BTC first.`));
254
+ }
255
+ // Build and broadcast commit transaction
256
+ const commitResult = buildChildCommitTransaction({
257
+ utxos,
258
+ inscription,
259
+ parentInscriptionId,
260
+ feeRate: actualFeeRate,
261
+ senderPubKey: account.btcPublicKey,
262
+ senderAddress: sessionInfo.btcAddress,
263
+ network: NETWORK,
264
+ });
265
+ const commitSigned = signBtcTransaction(commitResult.tx, account.btcPrivateKey);
266
+ const commitTxid = await mempoolApi.broadcastTransaction(commitSigned.txHex);
267
+ const commitExplorerUrl = getMempoolTxUrl(commitTxid, NETWORK);
268
+ return createJsonResponse({
269
+ status: "commit_broadcast",
270
+ message: "Soul commit transaction broadcast successfully. " +
271
+ "Wait for confirmation (typically 10-60 min), then call souldinals_reveal_soul to complete.",
272
+ commitTxid,
273
+ commitExplorerUrl,
274
+ revealAddress: commitResult.revealAddress,
275
+ revealAmount: commitResult.revealAmount,
276
+ commitFee: commitResult.fee,
277
+ feeRate: actualFeeRate,
278
+ parentInscriptionId,
279
+ parentUtxo: {
280
+ txid: parentInfo.txid,
281
+ vout: parentInfo.vout,
282
+ value: parentInfo.value,
283
+ },
284
+ contentType: SOUL_CONTENT_TYPE,
285
+ contentSize: body.length,
286
+ contentBase64,
287
+ nextStep: "After commit confirms, call souldinals_reveal_soul with commitTxid, revealAmount, " +
288
+ "contentBase64, and parentInscriptionId from this response.",
289
+ });
290
+ }
291
+ catch (error) {
292
+ return createErrorResponse(error);
293
+ }
294
+ });
295
+ // --------------------------------------------------------------------------
296
+ // souldinals_reveal_soul — Step 2: Broadcast reveal tx
297
+ // --------------------------------------------------------------------------
298
+ server.registerTool("souldinals_reveal_soul", {
299
+ description: "Complete a soul inscription - STEP 2: Broadcast reveal transaction.\n\n" +
300
+ "Call this AFTER the commit transaction from `souldinals_inscribe_soul` has confirmed.\n" +
301
+ "Provide the commitTxid, revealAmount, contentBase64, and parentInscriptionId " +
302
+ "from the commit step response.\n\n" +
303
+ "The reveal tx spends both the commit output and the parent inscription UTXO, " +
304
+ "returning the parent to your address and creating the child soul inscription.\n\n" +
305
+ "Returns: inscriptionId ({revealTxid}i0) on success",
306
+ inputSchema: {
307
+ commitTxid: z
308
+ .string()
309
+ .length(64)
310
+ .describe("Transaction ID of the confirmed commit transaction (from souldinals_inscribe_soul)"),
311
+ revealAmount: z
312
+ .number()
313
+ .positive()
314
+ .describe("Amount in the commit output (from souldinals_inscribe_soul response)"),
315
+ contentBase64: z
316
+ .string()
317
+ .describe("Base64-encoded soul.md content (from souldinals_inscribe_soul response)"),
318
+ parentInscriptionId: z
319
+ .string()
320
+ .describe("Parent inscription ID (must match the commit step)"),
321
+ feeRate: z
322
+ .union([z.enum(["fast", "medium", "slow"]), z.number().positive()])
323
+ .optional()
324
+ .describe("Fee rate for reveal tx (default: medium)"),
325
+ },
326
+ }, async ({ commitTxid, revealAmount, contentBase64, parentInscriptionId, feeRate, }) => {
327
+ try {
328
+ const walletManager = getWalletManager();
329
+ const sessionInfo = walletManager.getSessionInfo();
330
+ if (!sessionInfo) {
331
+ return createErrorResponse(new Error("Wallet not unlocked. Use wallet_unlock first."));
332
+ }
333
+ if (!sessionInfo.taprootAddress) {
334
+ return createErrorResponse(new Error("Wallet doesn't have Taproot address. Use a managed wallet."));
335
+ }
336
+ const account = walletManager.getAccount();
337
+ if (!account ||
338
+ !account.btcPrivateKey ||
339
+ !account.btcPublicKey ||
340
+ !account.taprootPrivateKey ||
341
+ !account.taprootPublicKey) {
342
+ return createErrorResponse(new Error("Bitcoin and Taproot keys not available. Wallet may not be unlocked."));
343
+ }
344
+ // Verify parent ownership
345
+ const parentInfo = await lookupParentInscription(parentInscriptionId);
346
+ if (parentInfo.address !== sessionInfo.taprootAddress) {
347
+ return createErrorResponse(new Error(`Parent inscription is no longer owned by your wallet. Current owner: ${parentInfo.address}`));
348
+ }
349
+ // Reconstruct the inscription
350
+ const body = Buffer.from(contentBase64, "base64");
351
+ const inscription = {
352
+ contentType: SOUL_CONTENT_TYPE,
353
+ body,
354
+ };
355
+ const mempoolApi = new MempoolApi(NETWORK);
356
+ const actualFeeRate = await resolveFeeRate(feeRate, mempoolApi);
357
+ // Derive the child reveal script deterministically
358
+ const p2trReveal = deriveChildRevealScript({
359
+ inscription,
360
+ parentInscriptionId,
361
+ senderPubKey: account.btcPublicKey,
362
+ network: NETWORK,
363
+ });
364
+ // Build child reveal transaction
365
+ const revealResult = buildChildRevealTransaction({
366
+ commitTxid,
367
+ commitVout: 0,
368
+ commitAmount: revealAmount,
369
+ revealScript: p2trReveal,
370
+ parentUtxo: {
371
+ txid: parentInfo.txid,
372
+ vout: parentInfo.vout,
373
+ value: parentInfo.value,
374
+ },
375
+ parentOwnerTaprootInternalPubKey: account.taprootPublicKey,
376
+ recipientAddress: sessionInfo.taprootAddress,
377
+ feeRate: actualFeeRate,
378
+ network: NETWORK,
379
+ });
380
+ // Sign both inputs
381
+ revealResult.tx.sign(account.btcPrivateKey);
382
+ revealResult.tx.sign(account.taprootPrivateKey);
383
+ revealResult.tx.finalize();
384
+ const revealTxHex = revealResult.tx.hex;
385
+ const revealTxid = await mempoolApi.broadcastTransaction(revealTxHex);
386
+ const inscriptionId = `${revealTxid}i0`;
387
+ const revealExplorerUrl = getMempoolTxUrl(revealTxid, NETWORK);
388
+ const commitExplorerUrl = getMempoolTxUrl(commitTxid, NETWORK);
389
+ return createJsonResponse({
390
+ status: "success",
391
+ message: "Soul inscription created successfully!",
392
+ inscriptionId,
393
+ parentInscriptionId,
394
+ contentType: SOUL_CONTENT_TYPE,
395
+ contentSize: body.length,
396
+ commit: {
397
+ txid: commitTxid,
398
+ explorerUrl: commitExplorerUrl,
399
+ },
400
+ reveal: {
401
+ txid: revealTxid,
402
+ fee: revealResult.fee,
403
+ explorerUrl: revealExplorerUrl,
404
+ },
405
+ recipientAddress: sessionInfo.taprootAddress,
406
+ note: "Soul inscription will appear at the recipient address once the reveal transaction confirms. The parent inscription has been returned to your address.",
407
+ });
408
+ }
409
+ catch (error) {
410
+ return createErrorResponse(error);
411
+ }
412
+ });
413
+ // --------------------------------------------------------------------------
414
+ // souldinals_list_souls — List soul inscriptions for an address
415
+ // --------------------------------------------------------------------------
416
+ server.registerTool("souldinals_list_souls", {
417
+ description: "List all soul inscriptions (text/markdown) owned by a Taproot address.\n\n" +
418
+ "Queries the Unisat Ordinals API for inscriptions with content type text/markdown.\n" +
419
+ "If no address is provided, uses the current wallet's Taproot address.\n\n" +
420
+ "Returns: array of soul inscriptions with id, number, content type, size, and timestamp.",
421
+ inputSchema: {
422
+ address: z
423
+ .string()
424
+ .optional()
425
+ .describe("Taproot (bc1p...) address to query. Omit to use the current wallet's Taproot address."),
426
+ },
427
+ }, async ({ address }) => {
428
+ try {
429
+ let taprootAddress = address;
430
+ if (!taprootAddress) {
431
+ const walletManager = getWalletManager();
432
+ const sessionInfo = walletManager.getSessionInfo();
433
+ if (!sessionInfo?.taprootAddress) {
434
+ return createErrorResponse(new Error("Wallet not unlocked or doesn't have a Taproot address. " +
435
+ "Provide an address parameter or use wallet_unlock first."));
436
+ }
437
+ taprootAddress = sessionInfo.taprootAddress;
438
+ }
439
+ const inscriptions = await fetchSoulInscriptions(taprootAddress);
440
+ const souls = inscriptions.map((ins) => ({
441
+ id: ins.id,
442
+ number: ins.number,
443
+ contentType: ins.contentType,
444
+ contentLength: ins.contentLength,
445
+ timestamp: ins.timestamp,
446
+ genesisBlockHeight: ins.genesisBlockHeight,
447
+ }));
448
+ return createJsonResponse({
449
+ address: taprootAddress,
450
+ count: souls.length,
451
+ souls,
452
+ message: souls.length === 0
453
+ ? "No soul inscriptions found. Use souldinals_inscribe_soul to create one."
454
+ : `Found ${souls.length} soul inscription(s).`,
455
+ });
456
+ }
457
+ catch (error) {
458
+ return createErrorResponse(error);
459
+ }
460
+ });
461
+ // --------------------------------------------------------------------------
462
+ // souldinals_load_soul — Load oldest soul inscription content
463
+ // --------------------------------------------------------------------------
464
+ server.registerTool("souldinals_load_soul", {
465
+ description: "Load and display the full content of the oldest soul inscription from a Taproot address.\n\n" +
466
+ "Fetches the list of soul inscriptions (text/markdown) and returns the content of the " +
467
+ "oldest one. If no address is provided, uses the current wallet's Taproot address.\n\n" +
468
+ "Returns: inscription metadata and full Markdown content.",
469
+ inputSchema: {
470
+ address: z
471
+ .string()
472
+ .optional()
473
+ .describe("Taproot (bc1p...) address to query. Omit to use the current wallet's Taproot address."),
474
+ },
475
+ }, async ({ address }) => {
476
+ try {
477
+ let taprootAddress = address;
478
+ if (!taprootAddress) {
479
+ const walletManager = getWalletManager();
480
+ const sessionInfo = walletManager.getSessionInfo();
481
+ if (!sessionInfo?.taprootAddress) {
482
+ return createErrorResponse(new Error("Wallet not unlocked or doesn't have a Taproot address. " +
483
+ "Provide an address parameter or use wallet_unlock first."));
484
+ }
485
+ taprootAddress = sessionInfo.taprootAddress;
486
+ }
487
+ const inscriptions = await fetchSoulInscriptions(taprootAddress);
488
+ if (inscriptions.length === 0) {
489
+ return createJsonResponse({
490
+ address: taprootAddress,
491
+ found: false,
492
+ message: "No soul inscriptions found. Use souldinals_inscribe_soul to create one.",
493
+ });
494
+ }
495
+ // Oldest is first (sorted by genesis_block_height asc)
496
+ const oldest = inscriptions[0];
497
+ const content = await fetchInscriptionContent(oldest.id);
498
+ return createJsonResponse({
499
+ inscriptionId: oldest.id,
500
+ contentType: oldest.contentType,
501
+ contentSize: oldest.contentLength,
502
+ timestamp: oldest.timestamp,
503
+ genesisBlockHeight: oldest.genesisBlockHeight,
504
+ content,
505
+ });
506
+ }
507
+ catch (error) {
508
+ return createErrorResponse(error);
509
+ }
510
+ });
511
+ // --------------------------------------------------------------------------
512
+ // souldinals_display_soul — Parse and display soul traits
513
+ // --------------------------------------------------------------------------
514
+ server.registerTool("souldinals_display_soul", {
515
+ description: "Parse and display soul traits from a specific inscription.\n\n" +
516
+ "Fetches the inscription content from Unisat and extracts structured soul traits:\n" +
517
+ "- name: first H1 heading\n" +
518
+ "- description: first paragraph after H1\n" +
519
+ "- values: list items under 'Values' or 'Core Values' sections\n" +
520
+ "- focusAreas: list items under 'Focus' or 'Focus Areas' sections\n" +
521
+ "- sections: all named H2/H3 sections\n\n" +
522
+ "Also returns raw Markdown content.",
523
+ inputSchema: {
524
+ inscriptionId: z
525
+ .string()
526
+ .describe("Inscription ID (format: {txid}i{index})"),
527
+ },
528
+ }, async ({ inscriptionId }) => {
529
+ try {
530
+ // Fetch metadata and content in parallel
531
+ const [metadata, content] = await Promise.all([
532
+ fetchInscriptionMetadata(inscriptionId),
533
+ fetchInscriptionContent(inscriptionId),
534
+ ]);
535
+ const traits = parseSoulTraits(content);
536
+ return createJsonResponse({
537
+ inscriptionId,
538
+ contentType: metadata.contentType,
539
+ contentLength: metadata.contentLength,
540
+ timestamp: metadata.timestamp,
541
+ genesisBlockHeight: metadata.genesisBlockHeight,
542
+ traits,
543
+ rawContent: content,
544
+ });
545
+ }
546
+ catch (error) {
547
+ return createErrorResponse(error);
548
+ }
549
+ });
550
+ }
551
+ //# sourceMappingURL=souldinals.tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"souldinals.tools.js","sourceRoot":"","sources":["../../src/tools/souldinals.tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,8CAA8C,CAAC;AAEtD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,MAAM,iBAAiB,GAAG,eAAe,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C7B,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;gBAC/C,MAAM;gBACN,UAAU,EAAE,OAAO;aACpB,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"stacking-lottery.tools.d.ts","sourceRoot":"","sources":["../../src/tools/stacking-lottery.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+GpE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CA8ZpE"}
1
+ {"version":3,"file":"stacking-lottery.tools.d.ts","sourceRoot":"","sources":["../../src/tools/stacking-lottery.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+GpE,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAiapE"}
@@ -348,8 +348,10 @@ Note: Stackspot is only available on mainnet.`,
348
348
  contractName: parsed.contractName,
349
349
  functionName: "claim-pot-reward",
350
350
  functionArgs: [],
351
- // TODO: tighten to PostConditionMode.Deny once post-conditions are
352
- // defined; kept as Allow to match the upstream stackspot skill for now.
351
+ // PostConditionMode.Allow is intentional: the pot contract transfers
352
+ // STX back to each participant and sBTC to the winner. The exact amounts
353
+ // are not known client-side until the contract executes, so strict
354
+ // post-conditions cannot be set without an additional read-only query.
353
355
  postConditionMode: PostConditionMode.Allow,
354
356
  });
355
357
  return createJsonResponse({
@@ -400,8 +402,9 @@ Note: Stackspot is only available on mainnet.`,
400
402
  contractName: parsed.contractName,
401
403
  functionName: "cancel-pot",
402
404
  functionArgs: [],
403
- // TODO: tighten to PostConditionMode.Deny once post-conditions are
404
- // defined; kept as Allow to match the upstream stackspot skill for now.
405
+ // PostConditionMode.Allow is intentional: the pot contract returns STX
406
+ // to contributors on cancel. The amount is not known client-side without
407
+ // an additional read-only query, so strict post-conditions are deferred.
405
408
  postConditionMode: PostConditionMode.Allow,
406
409
  });
407
410
  return createJsonResponse({