@swarm-tips/client 0.4.2 → 0.4.4

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 (40) hide show
  1. package/README.md +3 -2
  2. package/SBOM.spdx.json +5 -5
  3. package/dist/agent.d.ts +17 -1
  4. package/dist/agent.js +71 -54
  5. package/dist/cli/swarm.d.ts +5 -0
  6. package/dist/cli/swarm.js +48 -21
  7. package/dist/contracts/generated/coordination_game.d.ts +179 -1
  8. package/dist/contracts/generated/shillbot.d.ts +119 -12
  9. package/dist/contracts/idl/coordination_game.json +180 -2
  10. package/dist/contracts/idl/shillbot.json +119 -12
  11. package/dist/generated/openapi.d.ts +17 -2
  12. package/dist/generated/openapi.js +1 -1
  13. package/dist/http.js +1 -1
  14. package/dist/inbox/client.d.ts +2 -4
  15. package/dist/inbox/client.js +11 -6
  16. package/dist/inbox/index.d.ts +1 -1
  17. package/dist/inbox/index.js +1 -1
  18. package/dist/inbox/types.d.ts +9 -0
  19. package/dist/inbox/types.js +10 -0
  20. package/dist/index.d.ts +5 -3
  21. package/dist/index.js +4 -2
  22. package/dist/shillbot/api.d.ts +8 -1
  23. package/dist/shillbot/api.js +53 -133
  24. package/dist/shillbot/index.d.ts +1 -0
  25. package/dist/shillbot/index.js +3 -0
  26. package/dist/shillbot/verify-tx.d.ts +62 -0
  27. package/dist/shillbot/verify-tx.js +643 -0
  28. package/dist/signer/evm.d.ts +1 -1
  29. package/dist/signer/evm.js +72 -2
  30. package/dist/signer/index.d.ts +1 -1
  31. package/dist/signer/solana.d.ts +3 -2
  32. package/dist/signer/solana.js +36 -9
  33. package/dist/signer/types.d.ts +4 -1
  34. package/dist/version.d.ts +1 -1
  35. package/dist/version.js +1 -1
  36. package/dist/vow/index.d.ts +1 -1
  37. package/dist/vow/index.js +1 -1
  38. package/dist/vow/verify.d.ts +36 -0
  39. package/dist/vow/verify.js +458 -1
  40. package/package.json +1 -1
package/README.md CHANGED
@@ -27,7 +27,7 @@ const inbox = await agent.inbox.list({ status: "pending" });
27
27
 
28
28
  All signers keep private key material strictly in closure scope (redacted from `JSON.stringify`, `String()`, and `util.inspect`) and work in both browser and Node runtimes without Node built-ins:
29
29
 
30
- - `fromSolanaKeypair(keypair)` / `fromSolanaSecretKey(secret)` (`Uint8Array`, base58, or JSON byte array) / `fromSolanaWalletAdapter(adapter)`
30
+ - `fromSolanaKeypair(keypairOrSecretBytes)` (`Keypair` or 64-byte `Uint8Array`) / `fromSolanaSecretKey(secret)` (`Uint8Array`, base58, or JSON byte array) / `fromSolanaWalletAdapter(adapter)`
31
31
  - `fromEvmPrivateKey(hex, { chainId, rpcUrl })` / `fromEvmWalletClient(walletClient)`
32
32
 
33
33
  ### Local Safety Guarantees (C1, C6, C9, C10)
@@ -44,9 +44,10 @@ The package installs `swarm` (plus `npx -y @swarm-tips/client`, `swarm-tx`, and
44
44
  # Inspect wallet identity (keypair file must be chmod 600 on POSIX; raw --private-key flags are rejected)
45
45
  swarm auth whoami --keypair-file ~/.config/solana/id.json
46
46
 
47
- # Discover listings, tasks, and inbox messages (JSON auto-enabled when piped)
47
+ # Discover listings, tasks, task details, and inbox messages (JSON auto-enabled when piped)
48
48
  swarm listings --limit 10
49
49
  swarm tasks list --limit 20
50
+ swarm tasks get <task_id> --json
50
51
  swarm inbox list --status pending
51
52
 
52
53
  # Verify an unsigned Shillbot base64 transaction locally before signing (exit 0 = safe, exit 1 = rejected)
package/SBOM.spdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "spdxVersion": "SPDX-2.3",
3
3
  "dataLicense": "CC0-1.0",
4
4
  "SPDXID": "SPDXRef-DOCUMENT",
5
- "name": "@swarm-tips/client-0.4.2",
6
- "documentNamespace": "https://swarm.tips/sbom/client/0.4.2",
5
+ "name": "@swarm-tips/client-0.4.4",
6
+ "documentNamespace": "https://swarm.tips/sbom/client/0.4.4",
7
7
  "creationInfo": {
8
- "created": "2026-11-12T07:46:22.352Z",
8
+ "created": "2026-11-14T20:49:11.555Z",
9
9
  "creators": [
10
10
  "Tool: sdk/client/scripts/generate-sbom.mjs",
11
11
  "Organization: Swarm Tips"
@@ -15,8 +15,8 @@
15
15
  {
16
16
  "name": "@swarm-tips/client",
17
17
  "SPDXID": "SPDXRef-Package",
18
- "versionInfo": "0.4.2",
19
- "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.2",
18
+ "versionInfo": "0.4.4",
19
+ "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.4",
20
20
  "filesAnalyzed": false,
21
21
  "licenseConcluded": "MIT",
22
22
  "licenseDeclared": "MIT"
package/dist/agent.d.ts CHANGED
@@ -6,6 +6,8 @@ import type { SwarmSigner } from "./signer/types.js";
6
6
  import { type AgentJob, type AgentReputation, type EigenTrustRecord, type SearchHit } from "./swarm/index.js";
7
7
  import type { Verdict } from "./vow/types.js";
8
8
  export type SwarmNetwork = "mainnet" | "devnet";
9
+ /** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
10
+ export declare const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
9
11
  export interface SwarmAgentOptions {
10
12
  signer?: SwarmSigner;
11
13
  token?: string | (() => Promise<string | undefined>);
@@ -20,6 +22,8 @@ export interface SwarmAgentOptions {
20
22
  maxEscrowSpendWei?: bigint;
21
23
  /** Maximum Solana network fee (base + priority) allowed when wallet is fee payer; default `100_000n` = 0.0001 SOL (C9). */
22
24
  maxNetworkFeeLamports?: bigint;
25
+ /** Maximum EVM gas price ceiling (`maxFeePerGas`) in wei; default `50_000_000_000n` = 50 gwei (C9). */
26
+ maxNetworkFeeWei?: bigint;
23
27
  fetch?: typeof fetch;
24
28
  }
25
29
  export type TaskLifecycleStep = "claim" | "submit" | "wait_attestation" | "verify" | "wait_challenge" | "finalize" | "done";
@@ -36,8 +40,16 @@ export interface ExecutedTaskResult<TConfirm = unknown> {
36
40
  export interface ExecuteTaskOptions {
37
41
  sponsor?: "auto" | "true" | "none";
38
42
  connection?: Connection;
43
+ /** Explicit authorized payout destination pubkey (base58) when `set_payout_to` is expected. */
44
+ payoutTo?: string;
39
45
  extra?: Record<string, unknown>;
40
46
  }
47
+ /**
48
+ * Extract `escrow_lamports` (`u64` at bytes `[16..24]`) strictly from a Shillbot
49
+ * `create_task` instruction (`program_id === SHILLBOT_PROGRAM_ID` AND
50
+ * `data[0..8] === sha256("global:create_task")[0..8]`).
51
+ */
52
+ export declare function extractCreateEscrowLamports(encodedTx: string): bigint | undefined;
41
53
  /**
42
54
  * Unified non-custodial client for Swarm Tips, Shillbot, Inbox/Topics, and Coordination Game.
43
55
  */
@@ -50,6 +62,7 @@ export declare class SwarmAgent {
50
62
  readonly maxEscrowSpendLamports: bigint;
51
63
  readonly maxEscrowSpendWei: bigint;
52
64
  readonly maxNetworkFeeLamports: bigint;
65
+ readonly maxNetworkFeeWei: bigint;
53
66
  private readonly signer?;
54
67
  private readonly fetchImpl;
55
68
  private readonly tokenManager;
@@ -82,7 +95,7 @@ export declare class SwarmAgent {
82
95
  };
83
96
  readonly tasks: {
84
97
  listAvailable: <TTask = unknown>(limit?: number) => Promise<TaskListResponse<TTask>>;
85
- get: <TTask = unknown>(id: string) => Promise<TTask>;
98
+ get: <TTask = unknown>(id: string, network?: SwarmNetwork) => Promise<TTask>;
86
99
  mine: <TTask = unknown>() => Promise<TTask[]>;
87
100
  earnings: <TResponse = unknown>() => Promise<TResponse>;
88
101
  onboard: <TResponse = unknown>() => Promise<TResponse>;
@@ -98,11 +111,14 @@ export declare class SwarmAgent {
98
111
  buildFinalize: (id: string) => Promise<PreparedTransactionResponse>;
99
112
  finalizeAndExecute: (id: string, opts?: {
100
113
  connection?: Connection;
114
+ payoutTo?: string;
101
115
  }) => Promise<ExecutedTaskResult>;
102
116
  nextAction: (task: Record<string, unknown>) => NextTaskAction;
103
117
  verifyVow: (urlOrJson: string | Record<string, unknown>, opts?: {
104
118
  rpcUrl?: string;
105
119
  connection?: Connection;
120
+ maxBytes?: number;
121
+ allowLocalhostHttp?: boolean;
106
122
  }) => Promise<Verdict>;
107
123
  };
108
124
  readonly campaigns: {
package/dist/agent.js CHANGED
@@ -4,11 +4,12 @@ import { WalletTokenManager } from "./auth/token-manager.js";
4
4
  import { CoordinationGameApiClient } from "./coordination-game/api.js";
5
5
  import { SwarmClientError } from "./errors.js";
6
6
  import { InboxClient, } from "./inbox/client.js";
7
- import { ShillbotApiClient, estimateSolanaNetworkFeeLamports, signBroadcastPreparedTransaction, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
8
- import { inspectTransaction } from "./shillbot/index.js";
7
+ import { ShillbotApiClient, estimateSolanaNetworkFeeLamports, normalizeEvmChainId, signBroadcastPreparedTransaction, validatePreparedEvmCall, validatePreparedTransaction, } from "./shillbot/api.js";
8
+ import { SHILLBOT_PROGRAM_ID, inspectTransaction, shillbotInstructionDiscriminator, } from "./shillbot/index.js";
9
9
  import { SwarmClient, } from "./swarm/index.js";
10
- import { shillbotProtocol } from "./vow/decoders/shillbot.js";
11
- import { verifyV1 } from "./vow/verify.js";
10
+ import { verifyVow } from "./vow/verify.js";
11
+ /** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
12
+ export const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
12
13
  const DEFAULT_SOLANA_RPC = {
13
14
  mainnet: "https://api.mainnet-beta.solana.com",
14
15
  devnet: "https://api.devnet.solana.com",
@@ -60,12 +61,21 @@ function extractBodyBigInt(body, keys) {
60
61
  }
61
62
  return undefined;
62
63
  }
63
- function extractCreateEscrowLamports(encodedTx) {
64
+ const SHILLBOT_PROGRAM_ID_B58 = SHILLBOT_PROGRAM_ID.toBase58();
65
+ const CREATE_TASK_DISCRIMINATOR = shillbotInstructionDiscriminator("create_task");
66
+ /**
67
+ * Extract `escrow_lamports` (`u64` at bytes `[16..24]`) strictly from a Shillbot
68
+ * `create_task` instruction (`program_id === SHILLBOT_PROGRAM_ID` AND
69
+ * `data[0..8] === sha256("global:create_task")[0..8]`).
70
+ */
71
+ export function extractCreateEscrowLamports(encodedTx) {
64
72
  try {
65
73
  const inspected = inspectTransaction(encodedTx);
66
74
  for (const ix of inspected.instructions) {
75
+ if (ix.program_id !== SHILLBOT_PROGRAM_ID_B58)
76
+ continue;
67
77
  const data = Buffer.from(ix.data_base64, "base64");
68
- if (data.length >= 24) {
78
+ if (data.length >= 24 && data.subarray(0, 8).equals(CREATE_TASK_DISCRIMINATOR)) {
69
79
  const view = new DataView(data.buffer, data.byteOffset + 16, 8);
70
80
  return view.getBigUint64(0, true);
71
81
  }
@@ -88,6 +98,7 @@ export class SwarmAgent {
88
98
  maxEscrowSpendLamports;
89
99
  maxEscrowSpendWei;
90
100
  maxNetworkFeeLamports;
101
+ maxNetworkFeeWei;
91
102
  signer;
92
103
  fetchImpl;
93
104
  tokenManager;
@@ -111,6 +122,7 @@ export class SwarmAgent {
111
122
  this.maxEscrowSpendLamports = options.maxEscrowSpendLamports ?? 0n;
112
123
  this.maxEscrowSpendWei = options.maxEscrowSpendWei ?? 0n;
113
124
  this.maxNetworkFeeLamports = options.maxNetworkFeeLamports ?? 100000n;
125
+ this.maxNetworkFeeWei = options.maxNetworkFeeWei ?? DEFAULT_MAX_NETWORK_FEE_WEI;
114
126
  this.signer = options.signer;
115
127
  const rawFetch = options.fetch ?? globalThis.fetch;
116
128
  if (!rawFetch) {
@@ -185,7 +197,7 @@ export class SwarmAgent {
185
197
  };
186
198
  this.tasks = {
187
199
  listAvailable: (limit = 50) => self.shillbotClient.listTasks(limit),
188
- get: (id) => self.shillbotClient.getTask(id),
200
+ get: (id, net) => self.shillbotClient.getTask(id, net),
189
201
  async mine() {
190
202
  const res = await self.shillbotClient.listAgentTasks();
191
203
  return Array.isArray(res) ? res : (res.tasks ?? []);
@@ -213,47 +225,21 @@ export class SwarmAgent {
213
225
  const prepared = await self.tasks.buildFinalize(id);
214
226
  return self.executePreparedAction(id, "finalize", prepared, {
215
227
  connection: opts?.connection,
228
+ payoutTo: opts?.payoutTo,
216
229
  });
217
230
  },
218
231
  nextAction: (task) => SwarmAgent.adviseNextAction(task),
219
232
  async verifyVow(urlOrJson, opts) {
220
- let attestation = urlOrJson;
221
- if (typeof urlOrJson === "string") {
222
- const trimmed = urlOrJson.trim();
223
- if (/^https?:\/\//i.test(trimmed)) {
224
- const resp = await self.fetchImpl(trimmed, { method: "GET" });
225
- if (!resp.ok) {
226
- throw new SwarmClientError({
227
- code: "HTTP_ERROR",
228
- operation: "tasks.verifyVow",
229
- message: `Failed to fetch VOW attestation: HTTP ${resp.status}`,
230
- status: resp.status,
231
- });
232
- }
233
- attestation = await resp.json();
234
- }
235
- else {
236
- try {
237
- attestation = JSON.parse(trimmed);
238
- }
239
- catch (cause) {
240
- throw new SwarmClientError({
241
- code: "INVALID_ARGUMENT",
242
- operation: "tasks.verifyVow",
243
- message: "Expected VOW URL, JSON string, or object",
244
- cause,
245
- });
246
- }
247
- }
248
- }
249
- const net = attestation &&
250
- typeof attestation === "object" &&
251
- attestation.network === "devnet"
252
- ? "devnet"
253
- : self.network;
254
- const conn = opts?.connection ??
255
- new Connection(opts?.rpcUrl ?? DEFAULT_SOLANA_RPC[net], "confirmed");
256
- return verifyV1(attestation, shillbotProtocol, conn);
233
+ const customAgentRpc = self.rpcUrl !== DEFAULT_SOLANA_RPC[self.network] ? self.rpcUrl : undefined;
234
+ return verifyVow(urlOrJson, {
235
+ fetch: self.fetchImpl,
236
+ network: self.network,
237
+ rpcUrl: opts?.rpcUrl ?? customAgentRpc,
238
+ connection: opts?.connection,
239
+ maxBytes: opts?.maxBytes,
240
+ allowLocalhostHttp: opts?.allowLocalhostHttp,
241
+ operation: "tasks.verifyVow",
242
+ });
257
243
  },
258
244
  };
259
245
  this.campaigns = {
@@ -386,6 +372,7 @@ export class SwarmAgent {
386
372
  network: this.network,
387
373
  wallet: this.signer.address,
388
374
  taskPda: prepared.task_pda,
375
+ ...(opts?.payoutTo !== undefined ? { payoutTo: opts.payoutTo } : {}),
389
376
  });
390
377
  if (inspected.fee_payer !== this.signer.address &&
391
378
  !isFeePayerAlreadySigned(prepared.transaction)) {
@@ -402,6 +389,7 @@ export class SwarmAgent {
402
389
  }
403
390
  return this.executePreparedAction(id, action, prepared, {
404
391
  connection: opts?.connection,
392
+ payoutTo: opts?.payoutTo,
405
393
  });
406
394
  }
407
395
  async executePreparedAction(id, action, prepared, opts) {
@@ -443,10 +431,27 @@ export class SwarmAgent {
443
431
  chain,
444
432
  maxValueWei: action === "create" ? this.maxEscrowSpendWei : 0n,
445
433
  });
434
+ if (signer.chainId !== undefined) {
435
+ const normalizedSignerChain = normalizeEvmChainId(signer.chainId);
436
+ if (normalizedSignerChain !== validated.chain) {
437
+ throw new SwarmClientError({
438
+ code: "TRANSACTION_MISMATCH",
439
+ operation: `tasks.${action}AndExecute`,
440
+ message: `EVM signer chain ${normalizedSignerChain} differs from validated call chain ${validated.chain}`,
441
+ });
442
+ }
443
+ }
444
+ const caipMatch = /^eip155:(\d+)$/.exec(validated.chain);
445
+ const numericChainId = caipMatch ? Number(caipMatch[1]) : undefined;
446
446
  const txHash = await signer.sendTransaction({
447
447
  to: validated.to,
448
448
  data: validated.data,
449
449
  value: validated.value,
450
+ chain: validated.chain,
451
+ ...(numericChainId !== undefined && Number.isSafeInteger(numericChainId)
452
+ ? { chainId: numericChainId }
453
+ : {}),
454
+ maxFeePerGas: this.maxNetworkFeeWei,
450
455
  });
451
456
  const confirmation = await this.shillbotClient.confirmTask(id, {
452
457
  tx_signature: txHash,
@@ -478,25 +483,37 @@ export class SwarmAgent {
478
483
  });
479
484
  }
480
485
  }
486
+ // C9 Network Fee Cap check first so fee cap breaches report SPEND_CAP_EXCEEDED
487
+ let preInspected;
488
+ try {
489
+ preInspected = inspectTransaction(prepared.transaction);
490
+ }
491
+ catch (err) {
492
+ throw new SwarmClientError({
493
+ code: "TRANSACTION_MISMATCH",
494
+ operation: `tasks.${action}AndExecute`,
495
+ message: err instanceof Error ? err.message : `Malformed transaction: ${String(err)}`,
496
+ });
497
+ }
498
+ const estimatedFeeLamports = estimateSolanaNetworkFeeLamports(preInspected, signer.address);
499
+ if (estimatedFeeLamports > this.maxNetworkFeeLamports) {
500
+ throw new SwarmClientError({
501
+ code: "SPEND_CAP_EXCEEDED",
502
+ operation: `tasks.${action}AndExecute`,
503
+ message: `Estimated Solana network fee ${estimatedFeeLamports} lamports exceeds maxNetworkFeeLamports (${this.maxNetworkFeeLamports})`,
504
+ });
505
+ }
481
506
  const expected = {
482
507
  action,
483
508
  network: this.network,
484
509
  wallet: signer.address,
485
510
  taskPda: prepared.task_pda,
511
+ ...(opts.payoutTo !== undefined ? { payoutTo: opts.payoutTo } : {}),
486
512
  ...(action === "create" && opts.expectedEscrowLamports !== undefined
487
513
  ? { escrowLamports: opts.expectedEscrowLamports }
488
514
  : {}),
489
515
  };
490
- const inspected = validatePreparedTransaction(prepared.transaction, expected);
491
- // C9 Network Fee Cap check whenever the agent's wallet pays transaction fees
492
- const estimatedFeeLamports = estimateSolanaNetworkFeeLamports(inspected, signer.address);
493
- if (estimatedFeeLamports > this.maxNetworkFeeLamports) {
494
- throw new SwarmClientError({
495
- code: "SPEND_CAP_EXCEEDED",
496
- operation: `tasks.${action}AndExecute`,
497
- message: `Estimated Solana network fee ${estimatedFeeLamports} lamports exceeds maxNetworkFeeLamports (${this.maxNetworkFeeLamports})`,
498
- });
499
- }
516
+ validatePreparedTransaction(prepared.transaction, expected);
500
517
  const connection = opts.connection ?? new Connection(this.rpcUrl, "confirmed");
501
518
  const signature = await signBroadcastPreparedTransaction({
502
519
  connection,
@@ -11,4 +11,9 @@ export interface CliIo {
11
11
  env?: Record<string, string | undefined>;
12
12
  fetch?: typeof fetch;
13
13
  }
14
+ export interface ParsedCliArgs {
15
+ positionals: string[];
16
+ flags: Map<string, string | boolean>;
17
+ }
18
+ export declare function parseCliArgs(argv: readonly string[]): ParsedCliArgs;
14
19
  export declare function runSwarmCli(argv: readonly string[], io?: CliIo): Promise<number>;
package/dist/cli/swarm.js CHANGED
@@ -3,6 +3,7 @@ import { readFileSync, realpathSync } from "node:fs";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { SwarmAgent } from "../agent.js";
5
5
  import { SwarmClientError } from "../errors.js";
6
+ import { VALID_TOPICS, isValidTopicId } from "../inbox/types.js";
6
7
  import { validatePreparedTransaction } from "../shillbot/api.js";
7
8
  import { inspectTransaction } from "../shillbot/index.js";
8
9
  import { CLIENT_VERSION } from "../version.js";
@@ -17,13 +18,19 @@ const BOOLEAN_FLAGS = new Set([
17
18
  "--no-exec",
18
19
  "--unmute",
19
20
  "--cursor",
21
+ "--allow-localhost-http",
20
22
  ]);
21
- function parseCliArgs(argv) {
23
+ export function parseCliArgs(argv) {
22
24
  assertNoSecretCliFlags(argv);
25
+ const effectiveArgv = argv[0] === "--" ? argv.slice(1) : argv;
23
26
  const positionals = [];
24
27
  const flags = new Map();
25
- for (let i = 0; i < argv.length; i += 1) {
26
- const token = argv[i];
28
+ for (let i = 0; i < effectiveArgv.length; i += 1) {
29
+ const token = effectiveArgv[i];
30
+ if (token === "--") {
31
+ positionals.push(...effectiveArgv.slice(i + 1));
32
+ break;
33
+ }
27
34
  if (!token.startsWith("-") || token === "-") {
28
35
  positionals.push(token);
29
36
  continue;
@@ -39,7 +46,7 @@ function parseCliArgs(argv) {
39
46
  flags.set(token, true);
40
47
  continue;
41
48
  }
42
- const next = argv[i + 1];
49
+ const next = effectiveArgv[i + 1];
43
50
  if (next === undefined || (next.startsWith("--") && next.length > 2)) {
44
51
  throw new CliUsageError(`Flag ${token} requires a value.`);
45
52
  }
@@ -94,9 +101,9 @@ Commands:
94
101
  auth whoami | token
95
102
  listings [--limit N] [--category CAT] [--chain CHAIN]
96
103
  reputation <wallet>
97
- tasks list [--limit N] | mine | earnings | next <task-json-or-id>
98
- tasks claim <id> [--no-exec]
99
- tasks submit <id> --content <str> [--no-exec]
104
+ tasks list [--limit N] | get <id> | mine | earnings | next <task-json-or-id>
105
+ tasks claim <id> [--payout-to <pubkey>] [--no-exec]
106
+ tasks submit <id> --content <str> [--payout-to <pubkey>] [--no-exec]
100
107
  tasks verify <id> [--no-exec]
101
108
  tasks finalize <id> [--no-exec]
102
109
  inbox list [--status pending|all] [--limit N]
@@ -104,10 +111,10 @@ Commands:
104
111
  inbox send <to_wallet> <body> [--thread <id>] [--intent <intent>]
105
112
  inbox ack <msg_id> [--cursor]
106
113
  inbox mute <thread_id> [--unmute]
107
- topics read <open-challenge|subcontract> [--limit N]
108
- topics publish <topic> <body> [--ref <id>] [--reply-to <id>] [--intent <intent>]
114
+ topics read <open-challenge|subcontract|town-square> [--limit N]
115
+ topics publish <open-challenge|subcontract|town-square> <body> [--ref <id>] [--reply-to <id>] [--intent <intent>]
109
116
  tx inspect [--tx <base64>]
110
- tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--tx <base64>]
117
+ tx verify --action <claim|submit|verify|finalize|approve|create> --wallet <pubkey> [--task-pda <pda>] [--payout-to <pubkey>] [--tx <base64>]
111
118
  vow-verify <file-or-url> [--rpc <url>]
112
119
 
113
120
  Global Options:
@@ -220,6 +227,8 @@ export async function runSwarmCli(argv, io = {}) {
220
227
  }
221
228
  const taskPda = getStringFlag(flags, "--task-pda");
222
229
  const feePayer = getStringFlag(flags, "--fee-payer");
230
+ const payoutTo = getStringFlag(flags, "--payout-to");
231
+ const oracleAuthority = getStringFlag(flags, "--oracle-authority");
223
232
  const escrowLamports = getBigIntFlag(flags, "--escrow-lamports");
224
233
  try {
225
234
  const inspection = validatePreparedTransaction(txB64, {
@@ -228,6 +237,8 @@ export async function runSwarmCli(argv, io = {}) {
228
237
  wallet,
229
238
  ...(taskPda ? { taskPda } : {}),
230
239
  ...(feePayer ? { feePayer } : {}),
240
+ ...(payoutTo ? { payoutTo } : {}),
241
+ ...(oracleAuthority ? { oracleAuthority } : {}),
231
242
  ...(escrowLamports !== undefined ? { escrowLamports } : {}),
232
243
  });
233
244
  writeOutput(stdout, jsonMode, { ok: true, inspection });
@@ -306,6 +317,15 @@ export async function runSwarmCli(argv, io = {}) {
306
317
  writeOutput(stdout, jsonMode, res);
307
318
  return 0;
308
319
  }
320
+ if (sub === "get") {
321
+ const id = rest[0]?.trim();
322
+ if (!id) {
323
+ throw new CliUsageError("Usage: swarm tasks get <task_id>");
324
+ }
325
+ const res = await agent.tasks.get(id);
326
+ writeOutput(stdout, jsonMode, res);
327
+ return 0;
328
+ }
309
329
  if (sub === "mine") {
310
330
  const tasks = await agent.tasks.mine();
311
331
  writeOutput(stdout, jsonMode, { tasks });
@@ -330,8 +350,11 @@ export async function runSwarmCli(argv, io = {}) {
330
350
  if (sub === "claim") {
331
351
  const id = rest[0];
332
352
  if (!id)
333
- throw new CliUsageError("Usage: swarm tasks claim <task_id> [--no-exec]");
334
- const res = noExec ? await agent.tasks.claim(id) : await agent.tasks.claimAndExecute(id);
353
+ throw new CliUsageError("Usage: swarm tasks claim <task_id> [--payout-to <pubkey>] [--no-exec]");
354
+ const payoutTo = getStringFlag(flags, "--payout-to");
355
+ const res = noExec
356
+ ? await agent.tasks.claim(id)
357
+ : await agent.tasks.claimAndExecute(id, payoutTo ? { payoutTo } : undefined);
335
358
  writeOutput(stdout, jsonMode, res);
336
359
  return 0;
337
360
  }
@@ -339,11 +362,12 @@ export async function runSwarmCli(argv, io = {}) {
339
362
  const id = rest[0];
340
363
  const content = getStringFlag(flags, "--content");
341
364
  if (!id || !content) {
342
- throw new CliUsageError("Usage: swarm tasks submit <task_id> --content <str> [--no-exec]");
365
+ throw new CliUsageError("Usage: swarm tasks submit <task_id> --content <str> [--payout-to <pubkey>] [--no-exec]");
343
366
  }
367
+ const payoutTo = getStringFlag(flags, "--payout-to");
344
368
  const res = noExec
345
369
  ? await agent.tasks.submit(id, { content_id: content })
346
- : await agent.tasks.submitAndExecute(id, content);
370
+ : await agent.tasks.submitAndExecute(id, content, payoutTo ? { payoutTo } : undefined);
347
371
  writeOutput(stdout, jsonMode, res);
348
372
  return 0;
349
373
  }
@@ -367,7 +391,7 @@ export async function runSwarmCli(argv, io = {}) {
367
391
  writeOutput(stdout, jsonMode, res);
368
392
  return 0;
369
393
  }
370
- throw new CliUsageError("Usage: swarm tasks <list|mine|earnings|next|claim|submit|verify|finalize> ...");
394
+ throw new CliUsageError("Usage: swarm tasks <list|get|mine|earnings|next|claim|submit|verify|finalize> ...");
371
395
  }
372
396
  if (cmd === "inbox") {
373
397
  if (sub === "list") {
@@ -430,8 +454,8 @@ export async function runSwarmCli(argv, io = {}) {
430
454
  if (cmd === "topics") {
431
455
  if (sub === "read") {
432
456
  const topic = rest[0];
433
- if (topic !== "open-challenge" && topic !== "subcontract") {
434
- throw new CliUsageError("Usage: swarm topics read <open-challenge|subcontract>");
457
+ if (!isValidTopicId(topic)) {
458
+ throw new CliUsageError(`Usage: swarm topics read <${VALID_TOPICS.join("|")}>`);
435
459
  }
436
460
  const res = await agent.topics.read(topic, {
437
461
  limit: getIntFlag(flags, "--limit"),
@@ -441,8 +465,8 @@ export async function runSwarmCli(argv, io = {}) {
441
465
  }
442
466
  if (sub === "publish") {
443
467
  const [topic, body] = rest;
444
- if ((topic !== "open-challenge" && topic !== "subcontract") || !body) {
445
- throw new CliUsageError("Usage: swarm topics publish <open-challenge|subcontract> <body> [--ref <id>]");
468
+ if (!isValidTopicId(topic) || !body) {
469
+ throw new CliUsageError(`Usage: swarm topics publish <${VALID_TOPICS.join("|")}> <body> [--ref <id>]`);
446
470
  }
447
471
  const res = await agent.topics.publish(topic, body, {
448
472
  refId: getStringFlag(flags, "--ref"),
@@ -463,7 +487,7 @@ export async function runSwarmCli(argv, io = {}) {
463
487
  if (target === "-") {
464
488
  payload = await readStdinText(io);
465
489
  }
466
- else if (/^https?:\/\//i.test(target)) {
490
+ else if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(target)) {
467
491
  payload = target;
468
492
  }
469
493
  else {
@@ -474,7 +498,10 @@ export async function runSwarmCli(argv, io = {}) {
474
498
  throw new CliUsageError(`Failed to read VOW JSON file ${target}: ${err instanceof Error ? err.message : String(err)}`);
475
499
  }
476
500
  }
477
- const verdict = await agent.tasks.verifyVow(payload, { rpcUrl });
501
+ const verdict = await agent.tasks.verifyVow(payload, {
502
+ rpcUrl,
503
+ allowLocalhostHttp: Boolean(flags.get("--allow-localhost-http")),
504
+ });
478
505
  writeOutput(stdout, jsonMode, verdict);
479
506
  return verdict.valid ? 0 : 1;
480
507
  }