@swarm-tips/client 0.4.6 → 0.4.8

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/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.6",
6
- "documentNamespace": "https://swarm.tips/sbom/client/0.4.6",
5
+ "name": "@swarm-tips/client-0.4.8",
6
+ "documentNamespace": "https://swarm.tips/sbom/client/0.4.8",
7
7
  "creationInfo": {
8
- "created": "2026-11-17T04:19:23.433Z",
8
+ "created": "2026-11-24T09:53:19.118Z",
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.6",
19
- "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.6",
18
+ "versionInfo": "0.4.8",
19
+ "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.8",
20
20
  "filesAnalyzed": false,
21
21
  "licenseConcluded": "MIT",
22
22
  "licenseDeclared": "MIT"
package/dist/agent.d.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  import { Connection } from "@solana/web3.js";
2
2
  import { CoordinationGameApiClient } from "./coordination-game/api.js";
3
3
  import { type AckMessageResult, type InboxListOptions, type InboxListPage, type MessagePage, type MessageReference, type MuteReceipt, type OpenMessageResult, type PublishReceipt, type ReportReceipt, type SendReceipt, type TopicId, type TopicPage } from "./inbox/client.js";
4
- import { type CampaignListResponse, type PreparedTransactionResponse, type TaskListResponse } from "./shillbot/api.js";
4
+ import { type CampaignListResponse, type ListProofsOptions, type PreflightTaskResponse, type PreparedTransactionResponse, type ProofsResponse, type SubmitTaskRequest, type TaskListResponse } from "./shillbot/api.js";
5
5
  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
9
  /** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
10
10
  export declare const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
11
+ /** Recoupable SOL advance (`0.0031 SOL` = `3_100_000` lamports = `3_000_000` rent + `100_000` first-task gas budget) fronted by `/agent/onboard`. */
12
+ export declare const ONBOARD_ADVANCE_LAMPORTS = 3100000;
13
+ /** Minimum SOL balance (`0.003 SOL` = `3_000_000` lamports) required for self-paid `AgentState` initialization + lifecycle fees. */
14
+ export declare const MIN_SELF_PAID_SOLANA_BALANCE_LAMPORTS = 3000000;
11
15
  export interface SwarmAgentOptions {
12
16
  signer?: SwarmSigner;
13
17
  token?: string | (() => Promise<string | undefined>);
@@ -16,6 +20,8 @@ export interface SwarmAgentOptions {
16
20
  shillbotUrl?: string;
17
21
  gameUrl?: string;
18
22
  mcpUrl?: string;
23
+ /** Automatically call `onboard()` when a Solana wallet lacks SOL for self-paid claim/submit; default `true`. */
24
+ autoOnboard?: boolean;
19
25
  /** Maximum SOL escrow spend allowed per task creation; default `0n` (C9). */
20
26
  maxEscrowSpendLamports?: bigint;
21
27
  /** Maximum ETH/EVM escrow spend allowed per task creation; default `0n` (C9). */
@@ -37,11 +43,30 @@ export interface ExecutedTaskResult<TConfirm = unknown> {
37
43
  task_pda?: string;
38
44
  confirmation?: TConfirm;
39
45
  }
46
+ export interface PreflightTaskOptions {
47
+ proof_lean?: string;
48
+ proofLean?: string;
49
+ compile?: boolean;
50
+ content_id?: string;
51
+ contentId?: string;
52
+ agent_wallet?: string;
53
+ agentWallet?: string;
54
+ network?: SwarmNetwork;
55
+ token?: string | null;
56
+ }
40
57
  export interface ExecuteTaskOptions {
41
58
  sponsor?: "auto" | "true" | "none";
59
+ /** Automatically call `onboard()` if `?sponsor=auto` returns self-paid on an underfunded wallet; default `true`. */
60
+ autoOnboard?: boolean;
42
61
  connection?: Connection;
62
+ /** Optional explicit sponsor fee payer pubkey (base58). */
63
+ feePayer?: string;
43
64
  /** Explicit authorized payout destination pubkey (base58) when `set_payout_to` is expected. */
44
65
  payoutTo?: string;
66
+ /** Optional self-reported prover harness tag forwarded on `POST /tasks/:id/submit`. */
67
+ agentHarness?: string;
68
+ /** Optional self-reported model family tag forwarded on `POST /tasks/:id/submit`. */
69
+ modelFamily?: string;
45
70
  extra?: Record<string, unknown>;
46
71
  }
47
72
  /**
@@ -59,6 +84,7 @@ export declare class SwarmAgent {
59
84
  readonly shillbotUrl: string;
60
85
  readonly gameUrl: string;
61
86
  readonly mcpUrl: string;
87
+ readonly autoOnboard: boolean;
62
88
  readonly maxEscrowSpendLamports: bigint;
63
89
  readonly maxEscrowSpendWei: bigint;
64
90
  readonly maxNetworkFeeLamports: bigint;
@@ -70,6 +96,7 @@ export declare class SwarmAgent {
70
96
  private readonly swarmClient;
71
97
  private readonly inboxClient;
72
98
  private readonly gameClient;
99
+ private autoOnboardAttempted;
73
100
  readonly auth: {
74
101
  getToken: () => Promise<string | undefined>;
75
102
  authenticate: () => Promise<string>;
@@ -101,8 +128,8 @@ export declare class SwarmAgent {
101
128
  onboard: <TResponse = unknown>() => Promise<TResponse>;
102
129
  claim: (id: string, sponsor?: string) => Promise<PreparedTransactionResponse>;
103
130
  claimAndExecute: (id: string, opts?: ExecuteTaskOptions) => Promise<ExecutedTaskResult>;
104
- submit: (id: string, body: unknown) => Promise<PreparedTransactionResponse>;
105
- preflight: <TResponse = unknown>(id: string, body?: unknown) => Promise<TResponse>;
131
+ submit: (id: string, body: SubmitTaskRequest | Record<string, unknown>) => Promise<PreparedTransactionResponse>;
132
+ preflight: <TResponse = PreflightTaskResponse>(id: string, opts?: PreflightTaskOptions) => Promise<TResponse>;
106
133
  submitAndExecute: (id: string, contentId: string, opts?: ExecuteTaskOptions) => Promise<ExecutedTaskResult>;
107
134
  buildVerify: (id: string) => Promise<PreparedTransactionResponse>;
108
135
  verifyAndExecute: (id: string, opts?: {
@@ -127,11 +154,15 @@ export declare class SwarmAgent {
127
154
  allowLocalhostHttp?: boolean;
128
155
  }) => Promise<Verdict>;
129
156
  };
157
+ readonly proofs: {
158
+ list: (opts?: ListProofsOptions) => Promise<ProofsResponse>;
159
+ };
130
160
  readonly campaigns: {
131
161
  list: <TCampaign = unknown>() => Promise<CampaignListResponse<TCampaign> | TCampaign[]>;
132
162
  get: <TCampaign = unknown>(id: string) => Promise<TCampaign>;
133
163
  tasks: <TTask = unknown>(id: string) => Promise<TaskListResponse<TTask>>;
134
164
  metrics: <TMetrics = unknown>(id: string) => Promise<TMetrics>;
165
+ pendingApproval: <TTask = unknown>(network?: SwarmNetwork) => Promise<TaskListResponse<TTask> | TTask[]>;
135
166
  create: <TResponse = {
136
167
  campaign_id: string;
137
168
  }>(body: unknown) => Promise<TResponse>;
@@ -194,6 +225,12 @@ export declare class SwarmAgent {
194
225
  }) => Promise<T>;
195
226
  };
196
227
  constructor(options?: SwarmAgentOptions);
228
+ /** Bootstrap a zero-funds Solana agent wallet via recoupable Advance PDA fronting (`3_100_000` lamports). */
229
+ onboard<TResponse = unknown>(): Promise<TResponse>;
230
+ /** Claim a task and execute the prepared transaction (with automatic `$0` wallet onboarding when enabled). */
231
+ claimTask(id: string, opts?: ExecuteTaskOptions): Promise<ExecutedTaskResult>;
232
+ /** Submit work for a task and execute the prepared transaction (with automatic `$0` wallet onboarding when enabled). */
233
+ submitWork(id: string, contentId: string, opts?: ExecuteTaskOptions): Promise<ExecutedTaskResult>;
197
234
  private requireSigner;
198
235
  private executeClaimOrSubmit;
199
236
  /**
package/dist/agent.js CHANGED
@@ -10,6 +10,12 @@ import { SwarmClient, } from "./swarm/index.js";
10
10
  import { verifyVow } from "./vow/verify.js";
11
11
  /** Default EVM gas price ceiling (`maxFeePerGas` = 50 gwei). */
12
12
  export const DEFAULT_MAX_NETWORK_FEE_WEI = 50000000000n;
13
+ /** Recoupable SOL advance (`0.0031 SOL` = `3_100_000` lamports = `3_000_000` rent + `100_000` first-task gas budget) fronted by `/agent/onboard`. */
14
+ export const ONBOARD_ADVANCE_LAMPORTS = 3_100_000;
15
+ /** Minimum SOL balance (`0.003 SOL` = `3_000_000` lamports) required for self-paid `AgentState` initialization + lifecycle fees. */
16
+ export const MIN_SELF_PAID_SOLANA_BALANCE_LAMPORTS = 3_000_000;
17
+ /** Minimum SOL balance (`50_000` lamports) required for standalone post-claim `submit_work` fee payment. */
18
+ const MIN_POST_CLAIM_SUBMIT_SOLANA_BALANCE_LAMPORTS = 50_000;
13
19
  const DEFAULT_SOLANA_RPC = {
14
20
  mainnet: "https://api.mainnet-beta.solana.com",
15
21
  devnet: "https://api.devnet.solana.com",
@@ -95,6 +101,7 @@ export class SwarmAgent {
95
101
  shillbotUrl;
96
102
  gameUrl;
97
103
  mcpUrl;
104
+ autoOnboard;
98
105
  maxEscrowSpendLamports;
99
106
  maxEscrowSpendWei;
100
107
  maxNetworkFeeLamports;
@@ -106,9 +113,11 @@ export class SwarmAgent {
106
113
  swarmClient;
107
114
  inboxClient;
108
115
  gameClient;
116
+ autoOnboardAttempted = false;
109
117
  auth;
110
118
  discovery;
111
119
  tasks;
120
+ proofs;
112
121
  campaigns;
113
122
  inbox;
114
123
  topics;
@@ -119,6 +128,7 @@ export class SwarmAgent {
119
128
  this.shillbotUrl = (options.shillbotUrl ?? "https://api.shillbot.org").replace(/\/$/, "");
120
129
  this.gameUrl = (options.gameUrl ?? "https://api.coordination.game").replace(/\/$/, "");
121
130
  this.mcpUrl = (options.mcpUrl ?? "https://mcp.swarm.tips").replace(/\/$/, "");
131
+ this.autoOnboard = options.autoOnboard ?? true;
122
132
  this.maxEscrowSpendLamports = options.maxEscrowSpendLamports ?? 0n;
123
133
  this.maxEscrowSpendWei = options.maxEscrowSpendWei ?? 0n;
124
134
  this.maxNetworkFeeLamports = options.maxNetworkFeeLamports ?? 100000n;
@@ -203,11 +213,31 @@ export class SwarmAgent {
203
213
  return Array.isArray(res) ? res : (res.tasks ?? []);
204
214
  },
205
215
  earnings: () => self.shillbotClient.earnings(),
206
- onboard: () => self.shillbotClient.onboard(),
216
+ onboard: () => self.onboard(),
207
217
  claim: (id, sponsor = "auto") => self.shillbotClient.claimTask(id, sponsor),
208
218
  claimAndExecute: (id, opts) => self.executeClaimOrSubmit(id, "claim", undefined, opts),
209
219
  submit: (id, body) => self.shillbotClient.submitTask(id, body),
210
- preflight: (id, body) => self.shillbotClient.preflightTask(id, body),
220
+ preflight(id, opts) {
221
+ const body = {};
222
+ const proofLean = opts?.proof_lean ?? opts?.proofLean;
223
+ const contentId = opts?.content_id ?? opts?.contentId;
224
+ const agentWallet = opts?.agent_wallet ?? opts?.agentWallet;
225
+ if (proofLean !== undefined)
226
+ body.proof_lean = proofLean;
227
+ if (opts?.compile !== undefined)
228
+ body.compile = opts.compile;
229
+ if (contentId !== undefined)
230
+ body.content_id = contentId;
231
+ if (agentWallet !== undefined)
232
+ body.agent_wallet = agentWallet;
233
+ const callOpts = opts?.network !== undefined || opts?.token !== undefined
234
+ ? {
235
+ ...(opts.network !== undefined ? { network: opts.network } : {}),
236
+ ...(opts.token !== undefined ? { token: opts.token } : {}),
237
+ }
238
+ : undefined;
239
+ return self.shillbotClient.preflightTask(id, body, callOpts);
240
+ },
211
241
  submitAndExecute: (id, contentId, opts) => self.executeClaimOrSubmit(id, "submit", contentId, opts),
212
242
  buildVerify: (id) => self.shillbotClient.buildVerify(id, {
213
243
  payer: self.auth.walletAddress,
@@ -251,11 +281,15 @@ export class SwarmAgent {
251
281
  });
252
282
  },
253
283
  };
284
+ this.proofs = {
285
+ list: (opts) => self.shillbotClient.listProofs(opts),
286
+ };
254
287
  this.campaigns = {
255
288
  list: () => self.shillbotClient.listCampaigns(),
256
289
  get: (id) => self.shillbotClient.campaign(id),
257
290
  tasks: (id) => self.shillbotClient.campaignTasks(id),
258
291
  metrics: (id) => self.shillbotClient.campaignMetrics(id),
292
+ pendingApproval: (net) => self.shillbotClient.listPendingApproval(net),
259
293
  create: (body) => self.shillbotClient.createCampaign(body),
260
294
  fund: (id, body) => self.shillbotClient.fundCampaignTask(id, body),
261
295
  async fundAndExecute(id, body, opts) {
@@ -337,6 +371,18 @@ export class SwarmAgent {
337
371
  },
338
372
  };
339
373
  }
374
+ /** Bootstrap a zero-funds Solana agent wallet via recoupable Advance PDA fronting (`3_100_000` lamports). */
375
+ onboard() {
376
+ return this.shillbotClient.onboard();
377
+ }
378
+ /** Claim a task and execute the prepared transaction (with automatic `$0` wallet onboarding when enabled). */
379
+ claimTask(id, opts) {
380
+ return this.executeClaimOrSubmit(id, "claim", undefined, opts);
381
+ }
382
+ /** Submit work for a task and execute the prepared transaction (with automatic `$0` wallet onboarding when enabled). */
383
+ submitWork(id, contentId, opts) {
384
+ return this.executeClaimOrSubmit(id, "submit", contentId, opts);
385
+ }
340
386
  requireSigner() {
341
387
  if (!this.signer) {
342
388
  throw new SwarmClientError({
@@ -350,30 +396,40 @@ export class SwarmAgent {
350
396
  async executeClaimOrSubmit(id, action, contentId, opts) {
351
397
  const sponsorMode = opts?.sponsor ?? "auto";
352
398
  const sponsorQuery = sponsorMode === "none" ? "false" : sponsorMode === "true" ? "true" : "auto";
353
- let prepared;
354
- try {
399
+ const shouldAutoOnboard = (opts?.autoOnboard ?? this.autoOnboard) !== false;
400
+ const requestPrepared = (query) => {
355
401
  if (action === "claim") {
356
- prepared = await this.shillbotClient.claimTask(id, sponsorQuery);
402
+ return this.shillbotClient.claimTask(id, query);
357
403
  }
358
- else {
359
- const suffix = sponsorMode !== "none" ? `?sponsor=${encodeURIComponent(sponsorQuery)}` : "";
360
- prepared = await this.shillbotClient.post(`/tasks/${encodeURIComponent(id)}/submit${suffix}`, { content_id: contentId, ...(opts?.extra ?? {}) });
404
+ const suffix = sponsorMode !== "none" ? `?sponsor=${encodeURIComponent(query)}` : "";
405
+ const payload = {
406
+ content_id: contentId ?? "",
407
+ ...(opts?.extra ?? {}),
408
+ };
409
+ if (opts?.agentHarness && payload.agent_harness === undefined) {
410
+ payload.agent_harness = opts.agentHarness;
411
+ }
412
+ if (opts?.modelFamily && payload.model_family === undefined) {
413
+ payload.model_family = opts.modelFamily;
361
414
  }
415
+ return this.shillbotClient.post(`/tasks/${encodeURIComponent(id)}/submit${suffix}`, payload);
416
+ };
417
+ let prepared;
418
+ try {
419
+ prepared = await requestPrepared(sponsorQuery);
362
420
  }
363
421
  catch (err) {
364
422
  if ((action === "claim" || action === "submit") &&
365
423
  sponsorMode !== "none" &&
424
+ shouldAutoOnboard &&
425
+ !this.autoOnboardAttempted &&
366
426
  err instanceof SwarmClientError &&
367
427
  err.code === "HTTP_ERROR" &&
368
428
  (err.status === 400 || err.status === 403 || err.status === 412) &&
369
429
  /onboard|agent_state|bootstrap/i.test(err.message)) {
370
- await this.shillbotClient.onboard();
371
- if (action === "claim") {
372
- prepared = await this.shillbotClient.claimTask(id, sponsorQuery);
373
- }
374
- else {
375
- prepared = await this.shillbotClient.post(`/tasks/${encodeURIComponent(id)}/submit?sponsor=${encodeURIComponent(sponsorQuery)}`, { content_id: contentId, ...(opts?.extra ?? {}) });
376
- }
430
+ this.autoOnboardAttempted = true;
431
+ await this.onboard();
432
+ prepared = await requestPrepared(sponsorQuery);
377
433
  }
378
434
  else {
379
435
  throw err;
@@ -382,6 +438,48 @@ export class SwarmAgent {
382
438
  const connection = this.signer?.chain === "solana"
383
439
  ? (opts?.connection ?? new Connection(this.rpcUrl, "confirmed"))
384
440
  : opts?.connection;
441
+ // When a Solana wallet holds less than MIN_SELF_PAID_SOLANA_BALANCE_LAMPORTS (3_000_000 lamports
442
+ // for claim / atomic claim+submit) or MIN_POST_CLAIM_SUBMIT_SOLANA_BALANCE_LAMPORTS (50_000 lamports
443
+ // for standalone submit) and receives a self-paid HTTP 200 transaction, onboard once and re-request.
444
+ if (prepared.transaction &&
445
+ sponsorMode !== "none" &&
446
+ shouldAutoOnboard &&
447
+ !this.autoOnboardAttempted &&
448
+ connection &&
449
+ this.signer?.chain === "solana" &&
450
+ typeof connection.getBalance === "function") {
451
+ let initialFeePayer;
452
+ let bundlesClaim = action === "claim";
453
+ try {
454
+ const initialInspected = inspectTransaction(prepared.transaction);
455
+ initialFeePayer = initialInspected.fee_payer;
456
+ if (!bundlesClaim) {
457
+ const claimDisc = shillbotInstructionDiscriminator("claim_task");
458
+ const claimSessionDisc = shillbotInstructionDiscriminator("claim_task_session");
459
+ bundlesClaim = initialInspected.instructions.some((ix) => {
460
+ if (ix.program_id !== SHILLBOT_PROGRAM_ID_B58)
461
+ return false;
462
+ const d = Buffer.from(ix.data_base64, "base64");
463
+ return (d.length >= 8 &&
464
+ (d.subarray(0, 8).equals(claimDisc) || d.subarray(0, 8).equals(claimSessionDisc)));
465
+ });
466
+ }
467
+ }
468
+ catch {
469
+ // Malformed transaction will fail closed during validation below.
470
+ }
471
+ if (initialFeePayer === this.signer.address) {
472
+ const balanceLamports = await connection.getBalance(new PublicKey(this.signer.address));
473
+ const minRequiredLamports = bundlesClaim
474
+ ? MIN_SELF_PAID_SOLANA_BALANCE_LAMPORTS
475
+ : MIN_POST_CLAIM_SUBMIT_SOLANA_BALANCE_LAMPORTS;
476
+ if (balanceLamports < minRequiredLamports) {
477
+ this.autoOnboardAttempted = true;
478
+ await this.onboard();
479
+ prepared = await requestPrepared("auto");
480
+ }
481
+ }
482
+ }
385
483
  let resolvedPayoutTo = connection && this.signer?.chain === "solana"
386
484
  ? await SwarmAgent.resolveVerifiedAdvancePayoutTo(prepared, this.signer.address, connection, opts?.payoutTo)
387
485
  : opts?.payoutTo;
@@ -396,6 +494,7 @@ export class SwarmAgent {
396
494
  network: this.network,
397
495
  wallet: this.signer.address,
398
496
  taskPda: prepared.task_pda,
497
+ ...(opts?.feePayer !== undefined ? { feePayer: opts.feePayer } : {}),
399
498
  ...(resolvedPayoutTo !== undefined ? { payoutTo: resolvedPayoutTo } : {}),
400
499
  });
401
500
  if (inspected.fee_payer !== this.signer.address &&
@@ -418,6 +517,7 @@ export class SwarmAgent {
418
517
  }
419
518
  return this.executePreparedAction(id, action, prepared, {
420
519
  connection,
520
+ feePayer: opts?.feePayer,
421
521
  payoutTo: resolvedPayoutTo,
422
522
  payoutToResolved,
423
523
  });
@@ -593,6 +693,7 @@ export class SwarmAgent {
593
693
  network: this.network,
594
694
  wallet: signer.address,
595
695
  taskPda: prepared.task_pda,
696
+ ...(opts.feePayer !== undefined ? { feePayer: opts.feePayer } : {}),
596
697
  ...(resolvedPayoutTo !== undefined ? { payoutTo: resolvedPayoutTo } : {}),
597
698
  ...(action === "create" && opts.expectedEscrowLamports !== undefined
598
699
  ? { escrowLamports: opts.expectedEscrowLamports }
@@ -15,10 +15,11 @@ export declare function readSecureKeypairFile(filePath: string): string;
15
15
  export interface LoadCliSignerOptions {
16
16
  keypairFile?: string;
17
17
  env?: Record<string, string | undefined>;
18
- evmChainId?: number;
18
+ evmChainId?: number | string;
19
19
  evmRpcUrl?: string;
20
20
  }
21
21
  /**
22
- * Load a non-custodial `SwarmSigner` from `--keypair-file` or `SWARM_*` environment variables.
22
+ * Load a non-custodial `SwarmSigner` from `--keypair-file` (Solana JSON/base58 or
23
+ * `0x`-prefixed 32-byte hex EVM private key) or `SWARM_*` environment variables.
23
24
  */
24
25
  export declare function loadSignerFromCliOrEnv(options?: LoadCliSignerOptions): SwarmSigner | undefined;
@@ -57,13 +57,30 @@ export function readSecureKeypairFile(filePath) {
57
57
  }
58
58
  }
59
59
  /**
60
- * Load a non-custodial `SwarmSigner` from `--keypair-file` or `SWARM_*` environment variables.
60
+ * Load a non-custodial `SwarmSigner` from `--keypair-file` (Solana JSON/base58 or
61
+ * `0x`-prefixed 32-byte hex EVM private key) or `SWARM_*` environment variables.
61
62
  */
62
63
  export function loadSignerFromCliOrEnv(options = {}) {
63
64
  const env = options.env ?? process.env;
64
- const keyfilePath = options.keypairFile ?? env.SWARM_SOLANA_KEYPAIR_PATH;
65
+ const resolvedEvmChainId = options.evmChainId ?? env.SWARM_EVM_CHAIN_ID?.trim();
66
+ const resolvedEvmRpcUrl = options.evmRpcUrl ?? env.SWARM_EVM_RPC_URL?.trim();
67
+ const keyfilePath = options.keypairFile ?? env.SWARM_SOLANA_KEYPAIR_PATH ?? env.SWARM_EVM_KEYPAIR_PATH;
65
68
  if (keyfilePath) {
66
69
  const raw = readSecureKeypairFile(keyfilePath);
70
+ if (/^0x/i.test(raw)) {
71
+ if (!/^0x[0-9a-fA-F]{64}$/.test(raw)) {
72
+ throw new CliUsageError(`Invalid EVM private key in ${resolve(keyfilePath)}: Expected a 0x-prefixed 32-byte hex EVM private key`);
73
+ }
74
+ try {
75
+ return fromEvmPrivateKey(raw, {
76
+ chainId: resolvedEvmChainId,
77
+ rpcUrl: resolvedEvmRpcUrl,
78
+ });
79
+ }
80
+ catch (err) {
81
+ throw new CliUsageError(`Invalid EVM private key in ${resolve(keyfilePath)}: ${err instanceof Error ? err.message : String(err)}`);
82
+ }
83
+ }
67
84
  try {
68
85
  return fromSolanaSecretKey(raw);
69
86
  }
@@ -85,8 +102,8 @@ export function loadSignerFromCliOrEnv(options = {}) {
85
102
  const normalized = (evmPriv.startsWith("0x") ? evmPriv : `0x${evmPriv}`);
86
103
  try {
87
104
  return fromEvmPrivateKey(normalized, {
88
- chainId: options.evmChainId,
89
- rpcUrl: options.evmRpcUrl,
105
+ chainId: resolvedEvmChainId,
106
+ rpcUrl: resolvedEvmRpcUrl,
90
107
  });
91
108
  }
92
109
  catch (err) {
@@ -0,0 +1,39 @@
1
+ import type { ProofLimits } from "../shillbot/api.js";
2
+ export declare const DEFAULT_LEAN_TOOLCHAINS: Readonly<Record<number, string>>;
3
+ export declare const DEFAULT_MATHLIB_REV_V2_V3 = "c5ea00351c28e24afc9f0f84379aa41082b1188f";
4
+ export declare const DEFAULT_MATHLIB_REV_V4 = "51e6992efd06126df61a496bebf8f49482a4e129";
5
+ export declare const DEFAULT_ZETA23_REV_V4 = "3635e74826a4c1fcece7d1cd2b6fa75e43a00510";
6
+ export interface LeanWorkspaceSpec {
7
+ task_id: string;
8
+ statement_lean: string;
9
+ lean_policy: number;
10
+ lean_toolchain: string;
11
+ mode: string;
12
+ mathlib_rev?: string;
13
+ zeta23_rev?: string;
14
+ swarm_proofs_rev?: string;
15
+ import_allowlist: string[];
16
+ allows_disproof: boolean;
17
+ limits: ProofLimits;
18
+ }
19
+ export interface ScaffoldLeanWorkspaceResult {
20
+ ok: true;
21
+ task_id: string;
22
+ dir: string;
23
+ lean_policy: number;
24
+ lean_toolchain: string;
25
+ allows_disproof: boolean;
26
+ limits: ProofLimits;
27
+ files: string[];
28
+ }
29
+ export declare function extractLeanWorkspaceSpec(task: Record<string, unknown>, taskId: string): LeanWorkspaceSpec;
30
+ /**
31
+ * Pure helper generating the complete Lean 4 workspace file map for a
32
+ * `platform === 10` task without touching the filesystem.
33
+ */
34
+ export declare function buildLeanWorkspaceFiles(task: Record<string, unknown>, taskId: string): Record<string, string>;
35
+ /**
36
+ * Materialize a Lean 4 prover workspace on disk. Refuses to overwrite any
37
+ * existing non-empty target file unless `force === true`.
38
+ */
39
+ export declare function scaffoldLeanWorkspace(task: Record<string, unknown>, taskId: string, targetDir: string, force?: boolean): ScaffoldLeanWorkspaceResult;