openclaw-overlay-plugin 0.8.14 → 0.8.16

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 (190) hide show
  1. package/dist/index.js +6705 -326
  2. package/dist/index.js.map +7 -0
  3. package/dist/src/cli.js +7498 -11
  4. package/dist/src/cli.js.map +7 -0
  5. package/index.ts +1 -1
  6. package/openclaw.plugin.json +1 -1
  7. package/package.json +8 -8
  8. package/src/scripts/messaging/handlers.ts +1 -1
  9. package/src/scripts/overlay/advertisement.ts +1 -1
  10. package/src/scripts/overlay/registration.ts +1 -1
  11. package/src/scripts/overlay/services.ts +1 -1
  12. package/src/scripts/overlay/transaction.ts +1 -1
  13. package/src/scripts/payment/build.ts +1 -1
  14. package/src/scripts/payment/commands.ts +1 -1
  15. package/src/scripts/wallet/balance.ts +1 -1
  16. package/src/scripts/wallet/setup.ts +1 -1
  17. package/src/test/identity-consistency.test.ts +1 -1
  18. package/src/test/wallet.test.ts +1 -2
  19. package/dist/index.d.ts +0 -9
  20. package/dist/src/cli-main.d.ts +0 -7
  21. package/dist/src/cli-main.js +0 -202
  22. package/dist/src/cli.d.ts +0 -8
  23. package/dist/src/compatibility.test.d.ts +0 -4
  24. package/dist/src/compatibility.test.js +0 -41
  25. package/dist/src/core/config.d.ts +0 -11
  26. package/dist/src/core/config.js +0 -15
  27. package/dist/src/core/index.d.ts +0 -25
  28. package/dist/src/core/index.js +0 -26
  29. package/dist/src/core/payment.d.ts +0 -16
  30. package/dist/src/core/payment.js +0 -94
  31. package/dist/src/core/types.d.ts +0 -94
  32. package/dist/src/core/types.js +0 -4
  33. package/dist/src/core/verify.d.ts +0 -28
  34. package/dist/src/core/verify.js +0 -104
  35. package/dist/src/core/wallet.d.ts +0 -105
  36. package/dist/src/core/wallet.js +0 -256
  37. package/dist/src/scripts/baemail/commands.d.ts +0 -35
  38. package/dist/src/scripts/baemail/commands.js +0 -282
  39. package/dist/src/scripts/baemail/handler.d.ts +0 -36
  40. package/dist/src/scripts/baemail/handler.js +0 -284
  41. package/dist/src/scripts/baemail/index.d.ts +0 -5
  42. package/dist/src/scripts/baemail/index.js +0 -5
  43. package/dist/src/scripts/config.d.ts +0 -52
  44. package/dist/src/scripts/config.js +0 -75
  45. package/dist/src/scripts/index.d.ts +0 -7
  46. package/dist/src/scripts/index.js +0 -7
  47. package/dist/src/scripts/messaging/connect.d.ts +0 -8
  48. package/dist/src/scripts/messaging/connect.js +0 -168
  49. package/dist/src/scripts/messaging/handlers.d.ts +0 -21
  50. package/dist/src/scripts/messaging/handlers.js +0 -334
  51. package/dist/src/scripts/messaging/inbox.d.ts +0 -11
  52. package/dist/src/scripts/messaging/inbox.js +0 -51
  53. package/dist/src/scripts/messaging/index.d.ts +0 -8
  54. package/dist/src/scripts/messaging/index.js +0 -8
  55. package/dist/src/scripts/messaging/poll.d.ts +0 -7
  56. package/dist/src/scripts/messaging/poll.js +0 -52
  57. package/dist/src/scripts/messaging/send.d.ts +0 -7
  58. package/dist/src/scripts/messaging/send.js +0 -43
  59. package/dist/src/scripts/output.d.ts +0 -13
  60. package/dist/src/scripts/output.js +0 -28
  61. package/dist/src/scripts/overlay/advertisement.d.ts +0 -16
  62. package/dist/src/scripts/overlay/advertisement.js +0 -122
  63. package/dist/src/scripts/overlay/discover.d.ts +0 -7
  64. package/dist/src/scripts/overlay/discover.js +0 -74
  65. package/dist/src/scripts/overlay/index.d.ts +0 -7
  66. package/dist/src/scripts/overlay/index.js +0 -7
  67. package/dist/src/scripts/overlay/registration.d.ts +0 -19
  68. package/dist/src/scripts/overlay/registration.js +0 -176
  69. package/dist/src/scripts/overlay/services.d.ts +0 -29
  70. package/dist/src/scripts/overlay/services.js +0 -167
  71. package/dist/src/scripts/overlay/transaction.d.ts +0 -42
  72. package/dist/src/scripts/overlay/transaction.js +0 -103
  73. package/dist/src/scripts/payment/build.d.ts +0 -24
  74. package/dist/src/scripts/payment/build.js +0 -54
  75. package/dist/src/scripts/payment/commands.d.ts +0 -15
  76. package/dist/src/scripts/payment/commands.js +0 -73
  77. package/dist/src/scripts/payment/index.d.ts +0 -6
  78. package/dist/src/scripts/payment/index.js +0 -6
  79. package/dist/src/scripts/payment/types.d.ts +0 -56
  80. package/dist/src/scripts/payment/types.js +0 -4
  81. package/dist/src/scripts/services/index.d.ts +0 -6
  82. package/dist/src/scripts/services/index.js +0 -6
  83. package/dist/src/scripts/services/queue.d.ts +0 -11
  84. package/dist/src/scripts/services/queue.js +0 -28
  85. package/dist/src/scripts/services/request.d.ts +0 -7
  86. package/dist/src/scripts/services/request.js +0 -82
  87. package/dist/src/scripts/services/respond.d.ts +0 -11
  88. package/dist/src/scripts/services/respond.js +0 -132
  89. package/dist/src/scripts/types.d.ts +0 -107
  90. package/dist/src/scripts/types.js +0 -4
  91. package/dist/src/scripts/utils/index.d.ts +0 -6
  92. package/dist/src/scripts/utils/index.js +0 -6
  93. package/dist/src/scripts/utils/merkle.d.ts +0 -12
  94. package/dist/src/scripts/utils/merkle.js +0 -47
  95. package/dist/src/scripts/utils/storage.d.ts +0 -66
  96. package/dist/src/scripts/utils/storage.js +0 -211
  97. package/dist/src/scripts/utils/woc.d.ts +0 -26
  98. package/dist/src/scripts/utils/woc.js +0 -91
  99. package/dist/src/scripts/wallet/balance.d.ts +0 -22
  100. package/dist/src/scripts/wallet/balance.js +0 -240
  101. package/dist/src/scripts/wallet/identity.d.ts +0 -71
  102. package/dist/src/scripts/wallet/identity.js +0 -152
  103. package/dist/src/scripts/wallet/index.d.ts +0 -6
  104. package/dist/src/scripts/wallet/index.js +0 -6
  105. package/dist/src/scripts/wallet/setup.d.ts +0 -19
  106. package/dist/src/scripts/wallet/setup.js +0 -119
  107. package/dist/src/scripts/x-verification/commands.d.ts +0 -27
  108. package/dist/src/scripts/x-verification/commands.js +0 -222
  109. package/dist/src/scripts/x-verification/index.d.ts +0 -4
  110. package/dist/src/scripts/x-verification/index.js +0 -4
  111. package/dist/src/services/built-in/api-proxy/index.d.ts +0 -6
  112. package/dist/src/services/built-in/api-proxy/index.js +0 -23
  113. package/dist/src/services/built-in/code-develop/index.d.ts +0 -6
  114. package/dist/src/services/built-in/code-develop/index.js +0 -23
  115. package/dist/src/services/built-in/code-review/index.d.ts +0 -10
  116. package/dist/src/services/built-in/code-review/index.js +0 -51
  117. package/dist/src/services/built-in/image-analysis/index.d.ts +0 -6
  118. package/dist/src/services/built-in/image-analysis/index.js +0 -33
  119. package/dist/src/services/built-in/memory-store/index.d.ts +0 -6
  120. package/dist/src/services/built-in/memory-store/index.js +0 -22
  121. package/dist/src/services/built-in/roulette/index.d.ts +0 -6
  122. package/dist/src/services/built-in/roulette/index.js +0 -27
  123. package/dist/src/services/built-in/summarize/index.d.ts +0 -6
  124. package/dist/src/services/built-in/summarize/index.js +0 -21
  125. package/dist/src/services/built-in/tell-joke/handler.d.ts +0 -7
  126. package/dist/src/services/built-in/tell-joke/handler.js +0 -122
  127. package/dist/src/services/built-in/tell-joke/index.d.ts +0 -9
  128. package/dist/src/services/built-in/tell-joke/index.js +0 -31
  129. package/dist/src/services/built-in/translate/index.d.ts +0 -6
  130. package/dist/src/services/built-in/translate/index.js +0 -21
  131. package/dist/src/services/built-in/web-research/index.d.ts +0 -9
  132. package/dist/src/services/built-in/web-research/index.js +0 -51
  133. package/dist/src/services/index.d.ts +0 -13
  134. package/dist/src/services/index.js +0 -14
  135. package/dist/src/services/loader.d.ts +0 -77
  136. package/dist/src/services/loader.js +0 -292
  137. package/dist/src/services/manager.d.ts +0 -86
  138. package/dist/src/services/manager.js +0 -255
  139. package/dist/src/services/registry.d.ts +0 -98
  140. package/dist/src/services/registry.js +0 -204
  141. package/dist/src/services/types.d.ts +0 -230
  142. package/dist/src/services/types.js +0 -30
  143. package/dist/src/test/cli.test.d.ts +0 -7
  144. package/dist/src/test/cli.test.js +0 -330
  145. package/dist/src/test/comprehensive-overlay.test.d.ts +0 -13
  146. package/dist/src/test/comprehensive-overlay.test.js +0 -593
  147. package/dist/src/test/identity-consistency.test.d.ts +0 -6
  148. package/dist/src/test/identity-consistency.test.js +0 -60
  149. package/dist/src/test/key-derivation.test.d.ts +0 -12
  150. package/dist/src/test/key-derivation.test.js +0 -86
  151. package/dist/src/test/network-address.test.d.ts +0 -9
  152. package/dist/src/test/network-address.test.js +0 -37
  153. package/dist/src/test/overlay-submit.test.d.ts +0 -10
  154. package/dist/src/test/overlay-submit.test.js +0 -460
  155. package/dist/src/test/request-response-flow.test.d.ts +0 -5
  156. package/dist/src/test/request-response-flow.test.js +0 -210
  157. package/dist/src/test/service-system.test.d.ts +0 -5
  158. package/dist/src/test/service-system.test.js +0 -190
  159. package/dist/src/test/taskflow.test.d.ts +0 -7
  160. package/dist/src/test/taskflow.test.js +0 -82
  161. package/dist/src/test/utils/server-logic.d.ts +0 -98
  162. package/dist/src/test/utils/server-logic.js +0 -286
  163. package/dist/src/test/wallet.test.d.ts +0 -7
  164. package/dist/src/test/wallet.test.js +0 -146
  165. package/src/core/README.md +0 -246
  166. package/src/core/config.d.ts +0 -12
  167. package/src/core/config.d.ts.map +0 -1
  168. package/src/core/config.js +0 -14
  169. package/src/core/config.js.map +0 -1
  170. package/src/core/config.ts +0 -22
  171. package/src/core/index.ts +0 -42
  172. package/src/core/payment.d.ts +0 -17
  173. package/src/core/payment.d.ts.map +0 -1
  174. package/src/core/payment.js +0 -95
  175. package/src/core/payment.js.map +0 -1
  176. package/src/core/payment.ts +0 -111
  177. package/src/core/types.d.ts +0 -95
  178. package/src/core/types.d.ts.map +0 -1
  179. package/src/core/types.js +0 -5
  180. package/src/core/types.js.map +0 -1
  181. package/src/core/types.ts +0 -102
  182. package/src/core/verify.d.ts +0 -29
  183. package/src/core/verify.d.ts.map +0 -1
  184. package/src/core/verify.js +0 -105
  185. package/src/core/verify.js.map +0 -1
  186. package/src/core/verify.ts +0 -119
  187. package/src/core/wallet.d.ts +0 -100
  188. package/src/core/wallet.d.ts.map +0 -1
  189. package/src/core/wallet.js.map +0 -1
  190. package/src/core/wallet.ts +0 -323
@@ -1,29 +0,0 @@
1
- /**
2
- * Overlay service commands: services, advertise, remove, readvertise.
3
- *
4
- * Service payloads match the openclaw-overlay server schema:
5
- * - protocol: "clawdbot-overlay-v1"
6
- * - type: "service"
7
- * - identityKey: provider's compressed public key
8
- * - serviceId: unique service identifier
9
- * - name: human-readable name
10
- * - description: what the service does
11
- * - pricing: { model: "per-task", amountSats: number }
12
- * - timestamp: ISO 8601 time
13
- */
14
- /**
15
- * Services command: list currently advertised services.
16
- */
17
- export declare function cmdServices(): Promise<any>;
18
- /**
19
- * Advertise command: add a new service advertisement.
20
- */
21
- export declare function cmdAdvertise(serviceId: string | undefined, name: string | undefined, priceSatsStr: string | undefined, description?: string): Promise<any>;
22
- /**
23
- * Remove command: remove a service from local registry.
24
- */
25
- export declare function cmdRemove(serviceId: string | undefined): Promise<any>;
26
- /**
27
- * Readvertise command: update an existing service advertisement.
28
- */
29
- export declare function cmdReadvertise(serviceId: string | undefined, name?: string, priceSatsStr?: string, description?: string): Promise<any>;
@@ -1,167 +0,0 @@
1
- /**
2
- * Overlay service commands: services, advertise, remove, readvertise.
3
- *
4
- * Service payloads match the openclaw-overlay server schema:
5
- * - protocol: "clawdbot-overlay-v1"
6
- * - type: "service"
7
- * - identityKey: provider's compressed public key
8
- * - serviceId: unique service identifier
9
- * - name: human-readable name
10
- * - description: what the service does
11
- * - pricing: { model: "per-task", amountSats: number }
12
- * - timestamp: ISO 8601 time
13
- */
14
- import { NETWORK, WALLET_DIR, PROTOCOL_ID, TOPICS } from '../config.js';
15
- import { ok, fail } from '../output.js';
16
- import { loadServices, saveServices } from '../utils/storage.js';
17
- import { buildRealOverlayTransaction } from './transaction.js';
18
- import { BSVAgentWallet } from '../../core/index.js';
19
- async function getBSVAgentWallet() {
20
- return BSVAgentWallet;
21
- }
22
- /**
23
- * Services command: list currently advertised services.
24
- */
25
- export async function cmdServices() {
26
- const services = loadServices();
27
- return ok({ services, count: services.length });
28
- }
29
- /**
30
- * Advertise command: add a new service advertisement.
31
- */
32
- export async function cmdAdvertise(serviceId, name, priceSatsStr, description) {
33
- if (!serviceId || !name || !priceSatsStr) {
34
- return fail('Usage: advertise <serviceId> <name> <priceSats> [description]');
35
- }
36
- const priceSats = parseInt(priceSatsStr, 10);
37
- if (isNaN(priceSats) || priceSats < 0) {
38
- return fail('priceSats must be a non-negative integer');
39
- }
40
- const BSVAgentWallet = await getBSVAgentWallet();
41
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
42
- const identityKey = await wallet.getIdentityKey();
43
- await wallet.destroy();
44
- // Load existing services
45
- const services = loadServices();
46
- const existing = services.find(s => s.serviceId === serviceId);
47
- if (existing) {
48
- return fail(`Service '${serviceId}' already exists. Use 'readvertise' to update.`);
49
- }
50
- // Create service record (local storage format)
51
- const newService = {
52
- serviceId,
53
- name,
54
- description: description || `${name} service`,
55
- priceSats,
56
- registeredAt: new Date().toISOString(),
57
- };
58
- // Publish on-chain (matches openclaw-overlay server schema)
59
- const servicePayload = {
60
- protocol: PROTOCOL_ID,
61
- type: 'service',
62
- identityKey,
63
- serviceId,
64
- name,
65
- description: newService.description,
66
- pricing: {
67
- model: 'per-task',
68
- amountSats: priceSats,
69
- },
70
- timestamp: new Date().toISOString(),
71
- };
72
- try {
73
- const result = await buildRealOverlayTransaction(servicePayload, TOPICS.SERVICES);
74
- newService.txid = result.txid;
75
- // Save locally
76
- services.push(newService);
77
- saveServices(services);
78
- return ok({
79
- advertised: true,
80
- service: newService,
81
- txid: result.txid,
82
- funded: result.funded,
83
- });
84
- }
85
- catch (err) {
86
- return fail(`Failed to advertise service: ${err.message}`);
87
- }
88
- }
89
- /**
90
- * Remove command: remove a service from local registry.
91
- */
92
- export async function cmdRemove(serviceId) {
93
- if (!serviceId) {
94
- return fail('Usage: remove <serviceId>');
95
- }
96
- const services = loadServices();
97
- const idx = services.findIndex(s => s.serviceId === serviceId);
98
- if (idx === -1) {
99
- return fail(`Service '${serviceId}' not found`);
100
- }
101
- const removed = services.splice(idx, 1)[0];
102
- saveServices(services);
103
- return ok({
104
- removed: true,
105
- service: removed,
106
- note: 'Removed from local registry. On-chain record remains (blockchain is immutable).',
107
- });
108
- }
109
- /**
110
- * Readvertise command: update an existing service advertisement.
111
- */
112
- export async function cmdReadvertise(serviceId, name, priceSatsStr, description) {
113
- if (!serviceId) {
114
- return fail('Usage: readvertise <serviceId> [name] [priceSats] [description]');
115
- }
116
- const services = loadServices();
117
- const existing = services.find(s => s.serviceId === serviceId);
118
- if (!existing) {
119
- return fail(`Service '${serviceId}' not found. Use 'advertise' to create.`);
120
- }
121
- const BSVAgentWallet = await getBSVAgentWallet();
122
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
123
- const identityKey = await wallet.getIdentityKey();
124
- await wallet.destroy();
125
- // Update fields if provided
126
- if (name)
127
- existing.name = name;
128
- if (priceSatsStr) {
129
- const priceSats = parseInt(priceSatsStr, 10);
130
- if (isNaN(priceSats) || priceSats < 0) {
131
- return fail('priceSats must be a non-negative integer');
132
- }
133
- existing.priceSats = priceSats;
134
- }
135
- if (description)
136
- existing.description = description;
137
- existing.registeredAt = new Date().toISOString();
138
- // Publish update on-chain (matches openclaw-overlay server schema)
139
- const servicePayload = {
140
- protocol: PROTOCOL_ID,
141
- type: 'service',
142
- identityKey,
143
- serviceId,
144
- name: existing.name,
145
- description: existing.description,
146
- pricing: {
147
- model: 'per-task',
148
- amountSats: existing.priceSats,
149
- },
150
- timestamp: existing.registeredAt,
151
- };
152
- try {
153
- const result = await buildRealOverlayTransaction(servicePayload, TOPICS.SERVICES);
154
- existing.txid = result.txid;
155
- // Save locally
156
- saveServices(services);
157
- return ok({
158
- readvertised: true,
159
- service: existing,
160
- txid: result.txid,
161
- funded: result.funded,
162
- });
163
- }
164
- catch (err) {
165
- return fail(`Failed to readvertise service: ${err.message}`);
166
- }
167
- }
@@ -1,42 +0,0 @@
1
- /**
2
- * Overlay transaction building utilities.
3
- *
4
- * Follows the openclaw-overlay server API:
5
- * - Submit: POST /submit with binary BEEF and X-Topics header
6
- * - OP_RETURN format: OP_FALSE OP_RETURN <"clawdbot-overlay-v1"> <JSON>
7
- */
8
- import type { OverlayPayload } from '../types.js';
9
- import { BSVAgentWallet } from '../../core/wallet.js';
10
- /**
11
- * Build an PushDrop locking script with JSON payload using SDK's Script class.
12
- *
13
- * @param payload - The data to embed in the OP_RETURN
14
- * @returns A proper Script object that the SDK can serialize
15
- */
16
- export declare function buildPushDropScript(wallet: BSVAgentWallet, payload: OverlayPayload): Promise<string>;
17
- /**
18
- * Build and submit an overlay transaction.
19
- * @param payload - JSON data to store in OP_RETURN
20
- * @param topic - Topic manager for submission
21
- * @returns Transaction result with txid and funding info
22
- */
23
- export declare function buildRealOverlayTransaction(payload: OverlayPayload, topic: string): Promise<{
24
- txid: string;
25
- funded: string;
26
- explorer: string;
27
- }>;
28
- /**
29
- * Lookup data from an overlay lookup service.
30
- */
31
- export declare function lookupOverlay(service: string, query: Record<string, unknown>): Promise<any>;
32
- /**
33
- * Parse an overlay output from BEEF data.
34
- *
35
- * Handles both formats:
36
- * - OP_FALSE OP_RETURN <protocol> <json> (standard)
37
- * - OP_RETURN <protocol> <json> (legacy)
38
- */
39
- export declare function parseOverlayOutput(beefData: string | Uint8Array | number[], outputIndex: number): Promise<{
40
- data: OverlayPayload | null;
41
- txid: string | null;
42
- }>;
@@ -1,103 +0,0 @@
1
- /**
2
- * Overlay transaction building utilities.
3
- *
4
- * Follows the openclaw-overlay server API:
5
- * - Submit: POST /submit with binary BEEF and X-Topics header
6
- * - OP_RETURN format: OP_FALSE OP_RETURN <"clawdbot-overlay-v1"> <JSON>
7
- */
8
- import { NETWORK, OVERLAY_URL, PROTOCOL_ID, WALLET_DIR } from '../config.js';
9
- import { Utils, PushDrop, Transaction } from '@bsv/sdk';
10
- import { BSVAgentWallet } from '../../core/wallet.js';
11
- /**
12
- * Build an PushDrop locking script with JSON payload using SDK's Script class.
13
- *
14
- * @param payload - The data to embed in the OP_RETURN
15
- * @returns A proper Script object that the SDK can serialize
16
- */
17
- export async function buildPushDropScript(wallet, payload) {
18
- const jsonBytes = Utils.toArray(JSON.stringify(payload), 'utf8');
19
- const fields = [jsonBytes];
20
- const token = new PushDrop(wallet._setup.wallet);
21
- const script = await token.lock(fields, [0, PROTOCOL_ID], '1', 'self', true, true);
22
- return script.toHex();
23
- }
24
- /**
25
- * Build and submit an overlay transaction.
26
- * @param payload - JSON data to store in OP_RETURN
27
- * @param topic - Topic manager for submission
28
- * @returns Transaction result with txid and funding info
29
- */
30
- export async function buildRealOverlayTransaction(payload, topic) {
31
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
32
- const lockingScript = await buildPushDropScript(wallet, payload);
33
- const response = await wallet._setup.wallet.createAction({
34
- description: 'topic manager submission',
35
- outputs: [
36
- {
37
- lockingScript,
38
- satoshis: 1,
39
- outputDescription: 'overlay',
40
- basket: topic, // basket is the topic manager
41
- }
42
- ],
43
- options: {
44
- acceptDelayedBroadcast: false,
45
- }
46
- });
47
- // --- Submit to overlay ---
48
- // Use binary BEEF with X-Topics header (matches openclaw-overlay server API)
49
- const submitResp = await fetch(`${OVERLAY_URL}/submit`, {
50
- method: 'POST',
51
- headers: {
52
- 'Content-Type': 'application/octet-stream',
53
- 'X-Topics': JSON.stringify([topic]),
54
- },
55
- body: new Uint8Array(response.tx),
56
- });
57
- if (!submitResp.ok) {
58
- const errText = await submitResp.text();
59
- throw new Error(`Overlay submission failed: ${submitResp.status} — ${errText}`);
60
- }
61
- const wocNet = NETWORK === 'mainnet' ? '' : 'test.';
62
- return {
63
- txid: response.txid,
64
- funded: 'stored-beef',
65
- explorer: `https://${wocNet}whatsonchain.com/tx/${response.txid}`,
66
- };
67
- }
68
- /**
69
- * Lookup data from an overlay lookup service.
70
- */
71
- export async function lookupOverlay(service, query) {
72
- const resp = await fetch(`${OVERLAY_URL}/lookup`, {
73
- method: 'POST',
74
- headers: { 'Content-Type': 'application/json' },
75
- body: JSON.stringify({ service, query }),
76
- });
77
- if (!resp.ok) {
78
- const errText = await resp.text();
79
- throw new Error(`Lookup failed: ${resp.status} — ${errText}`);
80
- }
81
- return resp.json();
82
- }
83
- /**
84
- * Parse an overlay output from BEEF data.
85
- *
86
- * Handles both formats:
87
- * - OP_FALSE OP_RETURN <protocol> <json> (standard)
88
- * - OP_RETURN <protocol> <json> (legacy)
89
- */
90
- export async function parseOverlayOutput(beefData, outputIndex) {
91
- try {
92
- const tx = Transaction.fromBEEF(beefData);
93
- const txid = tx.id('hex');
94
- const output = tx.outputs[outputIndex];
95
- if (!output)
96
- return { data: null, txid: null };
97
- const { fields } = PushDrop.decode(output.lockingScript);
98
- return { data: JSON.parse(Utils.toUTF8(fields[0])), txid };
99
- }
100
- catch {
101
- return { data: null, txid: null };
102
- }
103
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Payment building using a2a-bsv wallet.createPayment().
3
- *
4
- * This replaces the old buildDirectPayment() which used plain P2PKH scripts
5
- * and manual UTXO management. The new implementation:
6
- * - Uses proper BRC-29 locking scripts via wallet.createPayment()
7
- * - Relies on wallet's createAction() for UTXO management
8
- * - Uses noSend: true (recipient broadcasts via acceptPayment())
9
- */
10
- import type { PaymentResult } from './types.js';
11
- /**
12
- * Build a BRC-29 payment using the a2a-bsv wallet.
13
- *
14
- * This creates a payment transaction using proper BRC-29 locking scripts.
15
- * The transaction uses noSend: true, meaning:
16
- * - The sender does NOT broadcast the transaction
17
- * - The recipient broadcasts it when they call acceptPayment()
18
- *
19
- * @param recipientPubKey - Recipient's compressed public key (66 hex chars, 02/03 prefix)
20
- * @param sats - Amount to send in satoshis
21
- * @param desc - Optional description for the payment
22
- * @returns PaymentResult with BEEF and derivation metadata for the recipient
23
- */
24
- export declare function buildDirectPayment(recipientPubKey: string, sats: number, desc?: string): Promise<PaymentResult>;
@@ -1,54 +0,0 @@
1
- /**
2
- * Payment building using a2a-bsv wallet.createPayment().
3
- *
4
- * This replaces the old buildDirectPayment() which used plain P2PKH scripts
5
- * and manual UTXO management. The new implementation:
6
- * - Uses proper BRC-29 locking scripts via wallet.createPayment()
7
- * - Relies on wallet's createAction() for UTXO management
8
- * - Uses noSend: true (recipient broadcasts via acceptPayment())
9
- */
10
- import { NETWORK, WALLET_DIR } from '../config.js';
11
- import { BSVAgentWallet } from '../../core/index.js';
12
- async function getBSVAgentWallet() {
13
- return BSVAgentWallet;
14
- }
15
- /**
16
- * Build a BRC-29 payment using the a2a-bsv wallet.
17
- *
18
- * This creates a payment transaction using proper BRC-29 locking scripts.
19
- * The transaction uses noSend: true, meaning:
20
- * - The sender does NOT broadcast the transaction
21
- * - The recipient broadcasts it when they call acceptPayment()
22
- *
23
- * @param recipientPubKey - Recipient's compressed public key (66 hex chars, 02/03 prefix)
24
- * @param sats - Amount to send in satoshis
25
- * @param desc - Optional description for the payment
26
- * @returns PaymentResult with BEEF and derivation metadata for the recipient
27
- */
28
- export async function buildDirectPayment(recipientPubKey, sats, desc) {
29
- // Validate recipient pubkey format
30
- if (!/^0[23][0-9a-fA-F]{64}$/.test(recipientPubKey)) {
31
- throw new Error('Recipient must be a compressed public key (66 hex chars starting with 02 or 03)');
32
- }
33
- const BSVAgentWallet = await getBSVAgentWallet();
34
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
35
- try {
36
- const result = await wallet.createPayment({
37
- to: recipientPubKey,
38
- satoshis: sats,
39
- description: desc || 'agent payment',
40
- });
41
- // Return format compatible with existing code
42
- return {
43
- beef: result.beef,
44
- txid: result.txid,
45
- satoshis: result.satoshis,
46
- derivationPrefix: result.derivationPrefix,
47
- derivationSuffix: result.derivationSuffix,
48
- senderIdentityKey: result.senderIdentityKey,
49
- };
50
- }
51
- finally {
52
- await wallet.destroy();
53
- }
54
- }
@@ -1,15 +0,0 @@
1
- /**
2
- * Payment CLI commands: pay, verify, accept.
3
- */
4
- /**
5
- * Pay command: send satoshis to another agent.
6
- */
7
- export declare function cmdPay(pubkey: string | undefined, satoshis: string | undefined, description?: string): Promise<any>;
8
- /**
9
- * Verify command: verify an incoming payment BEEF.
10
- */
11
- export declare function cmdVerify(beefBase64: string | undefined): Promise<any>;
12
- /**
13
- * Accept command: accept and internalize a payment.
14
- */
15
- export declare function cmdAccept(beef: string | undefined, derivationPrefix: string | undefined, derivationSuffix: string | undefined, senderIdentityKey: string | undefined, description?: string): Promise<any>;
@@ -1,73 +0,0 @@
1
- /**
2
- * Payment CLI commands: pay, verify, accept.
3
- */
4
- import { NETWORK, WALLET_DIR } from '../config.js';
5
- import { ok, fail } from '../output.js';
6
- import { buildDirectPayment } from './build.js';
7
- import { BSVAgentWallet } from '../../core/index.js';
8
- async function getBSVAgentWallet() {
9
- return BSVAgentWallet;
10
- }
11
- /**
12
- * Pay command: send satoshis to another agent.
13
- */
14
- export async function cmdPay(pubkey, satoshis, description) {
15
- if (!pubkey || !satoshis) {
16
- return fail('Usage: pay <pubkey> <satoshis> [description]');
17
- }
18
- const sats = parseInt(satoshis, 10);
19
- if (isNaN(sats) || sats <= 0) {
20
- return fail('satoshis must be a positive integer');
21
- }
22
- try {
23
- const payment = await buildDirectPayment(pubkey, sats, description || 'agent payment');
24
- return ok(payment);
25
- }
26
- catch (err) {
27
- return fail(err instanceof Error ? err.message : String(err));
28
- }
29
- }
30
- /**
31
- * Verify command: verify an incoming payment BEEF.
32
- */
33
- export async function cmdVerify(beefBase64) {
34
- if (!beefBase64) {
35
- return fail('Usage: verify <beef_base64>');
36
- }
37
- const BSVAgentWallet = await getBSVAgentWallet();
38
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
39
- try {
40
- const result = wallet.verifyPayment({ beef: beefBase64 });
41
- await wallet.destroy();
42
- return ok(result);
43
- }
44
- catch (err) {
45
- await wallet.destroy();
46
- return fail(err instanceof Error ? err.message : String(err));
47
- }
48
- }
49
- /**
50
- * Accept command: accept and internalize a payment.
51
- */
52
- export async function cmdAccept(beef, derivationPrefix, derivationSuffix, senderIdentityKey, description) {
53
- if (!beef || !derivationPrefix || !derivationSuffix || !senderIdentityKey) {
54
- return fail('Usage: accept <beef> <prefix> <suffix> <senderKey> [description]');
55
- }
56
- const BSVAgentWallet = await getBSVAgentWallet();
57
- const wallet = await BSVAgentWallet.load({ network: NETWORK, storageDir: WALLET_DIR });
58
- try {
59
- const receipt = await wallet.acceptPayment({
60
- beef,
61
- derivationPrefix,
62
- derivationSuffix,
63
- senderIdentityKey,
64
- description: description || undefined,
65
- });
66
- await wallet.destroy();
67
- return ok(receipt);
68
- }
69
- catch (err) {
70
- await wallet.destroy();
71
- return fail(err instanceof Error ? err.message : String(err));
72
- }
73
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Payment module exports.
3
- */
4
- export * from './types.js';
5
- export * from './build.js';
6
- export * from './commands.js';
@@ -1,6 +0,0 @@
1
- /**
2
- * Payment module exports.
3
- */
4
- export * from './types.js';
5
- export * from './build.js';
6
- export * from './commands.js';
@@ -1,56 +0,0 @@
1
- /**
2
- * Payment-specific type definitions.
3
- */
4
- export interface PaymentResult {
5
- /** Base64-encoded Atomic BEEF transaction data */
6
- beef: string;
7
- /** Transaction ID (hex) */
8
- txid: string;
9
- /** Amount paid in satoshis */
10
- satoshis: number;
11
- /** BRC-29 derivation prefix (base64) - needed by recipient */
12
- derivationPrefix: string;
13
- /** BRC-29 derivation suffix (base64) - needed by recipient */
14
- derivationSuffix: string;
15
- /** Sender's identity key (compressed hex) - needed by recipient */
16
- senderIdentityKey: string;
17
- }
18
- export interface PaymentParams {
19
- /** Recipient's compressed public key (hex, 66 chars starting with 02/03) */
20
- to: string;
21
- /** Amount to pay in satoshis */
22
- satoshis: number;
23
- /** Optional human-readable description */
24
- description?: string;
25
- }
26
- export interface VerifyParams {
27
- /** Base64-encoded BEEF */
28
- beef: string;
29
- /** Expected amount (optional) */
30
- expectedAmount?: number;
31
- /** Expected sender identity key (optional) */
32
- expectedSender?: string;
33
- }
34
- export interface VerifyResult {
35
- valid: boolean;
36
- txid: string;
37
- outputCount: number;
38
- errors: string[];
39
- }
40
- export interface AcceptParams {
41
- /** Base64-encoded Atomic BEEF */
42
- beef: string;
43
- /** Output index (default: 0) */
44
- vout?: number;
45
- /** BRC-29 derivation prefix from PaymentResult */
46
- derivationPrefix: string;
47
- /** BRC-29 derivation suffix from PaymentResult */
48
- derivationSuffix: string;
49
- /** Sender's identity key from PaymentResult */
50
- senderIdentityKey: string;
51
- /** Optional description */
52
- description?: string;
53
- }
54
- export interface AcceptResult {
55
- accepted: boolean;
56
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Payment-specific type definitions.
3
- */
4
- export {};
@@ -1,6 +0,0 @@
1
- /**
2
- * Services module exports.
3
- */
4
- export * from './request.js';
5
- export * from './respond.js';
6
- export * from './queue.js';
@@ -1,6 +0,0 @@
1
- /**
2
- * Services module exports.
3
- */
4
- export * from './request.js';
5
- export * from './respond.js';
6
- export * from './queue.js';
@@ -1,11 +0,0 @@
1
- /**
2
- * Service queue commands.
3
- */
4
- /**
5
- * Service queue command: list pending service requests.
6
- */
7
- export declare function cmdServiceQueue(): Promise<any>;
8
- /**
9
- * Research queue command: list pending research requests.
10
- */
11
- export declare function cmdResearchQueue(): Promise<any>;
@@ -1,28 +0,0 @@
1
- /**
2
- * Service queue commands.
3
- */
4
- import fs from 'node:fs';
5
- import { PATHS } from '../config.js';
6
- import { ok } from '../output.js';
7
- import { readJsonl } from '../utils/storage.js';
8
- /**
9
- * Service queue command: list pending service requests.
10
- */
11
- export async function cmdServiceQueue() {
12
- if (!fs.existsSync(PATHS.serviceQueue)) {
13
- return ok({ pending: [], count: 0 });
14
- }
15
- const entries = readJsonl(PATHS.serviceQueue);
16
- const pending = entries.filter(e => e.status === 'pending');
17
- return ok({ pending, count: pending.length, total: entries.length });
18
- }
19
- /**
20
- * Research queue command: list pending research requests.
21
- */
22
- export async function cmdResearchQueue() {
23
- if (!fs.existsSync(PATHS.researchQueue)) {
24
- return ok({ pending: [] });
25
- }
26
- const entries = readJsonl(PATHS.researchQueue);
27
- return ok({ pending: entries, count: entries.length });
28
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Service request command.
3
- */
4
- /**
5
- * Request service command: send a service request with optional payment.
6
- */
7
- export declare function cmdRequestService(targetKey: string | undefined, serviceId: string | undefined, satsStr?: string, inputJsonStr?: string): Promise<any>;