@swarm-tips/client 0.4.10 → 0.4.12

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.10",
6
- "documentNamespace": "https://swarm.tips/sbom/client/0.4.10",
5
+ "name": "@swarm-tips/client-0.4.12",
6
+ "documentNamespace": "https://swarm.tips/sbom/client/0.4.12",
7
7
  "creationInfo": {
8
- "created": "2026-11-27T09:27:26.689Z",
8
+ "created": "2026-11-28T08:02:11.672Z",
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.10",
19
- "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.10",
18
+ "versionInfo": "0.4.12",
19
+ "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.12",
20
20
  "filesAnalyzed": false,
21
21
  "licenseConcluded": "MIT",
22
22
  "licenseDeclared": "MIT"
package/dist/agent.js CHANGED
@@ -207,7 +207,10 @@ export class SwarmAgent {
207
207
  };
208
208
  this.tasks = {
209
209
  listAvailable: (limit = 50) => self.shillbotClient.listTasks(limit),
210
- get: (id, net) => self.shillbotClient.getTask(id, net),
210
+ get: (id, net) => self.shillbotClient.getTask(id, {
211
+ network: net,
212
+ token: self.tokenManager.getCachedToken() ?? null,
213
+ }),
211
214
  async mine() {
212
215
  const res = await self.shillbotClient.listAgentTasks();
213
216
  return Array.isArray(res) ? res : (res.tasks ?? []);
@@ -37,6 +37,9 @@ export declare class WalletTokenManager {
37
37
  constructor(options?: WalletTokenManagerOptions);
38
38
  get walletAddress(): string | undefined;
39
39
  invalidate(): void;
40
+ /** Return an already-available bearer token (static or unexpired cached JWT)
41
+ * without triggering an `/auth/challenge` handshake. */
42
+ getCachedToken(): string | undefined;
40
43
  getToken(): Promise<string | undefined>;
41
44
  authenticate(): Promise<string>;
42
45
  }
@@ -86,6 +86,17 @@ export class WalletTokenManager {
86
86
  this.cachedToken = null;
87
87
  this.expiresAtMs = 0;
88
88
  }
89
+ /** Return an already-available bearer token (static or unexpired cached JWT)
90
+ * without triggering an `/auth/challenge` handshake. */
91
+ getCachedToken() {
92
+ if (this.staticToken !== undefined) {
93
+ return this.staticToken;
94
+ }
95
+ if (this.cachedToken && this.now() < this.expiresAtMs) {
96
+ return this.cachedToken;
97
+ }
98
+ return undefined;
99
+ }
89
100
  async getToken() {
90
101
  if (this.staticToken !== undefined) {
91
102
  return this.staticToken;
package/dist/cli/swarm.js CHANGED
@@ -482,9 +482,16 @@ export async function runSwarmCli(argv, io = {}) {
482
482
  if (!arg) {
483
483
  throw new CliUsageError("Usage: swarm tasks next <task-json-or-id>");
484
484
  }
485
- const taskObj = arg.trim().startsWith("{")
486
- ? JSON.parse(arg)
487
- : await agent.tasks.get(arg.trim());
485
+ let taskObj;
486
+ if (arg.trim().startsWith("{")) {
487
+ taskObj = JSON.parse(arg);
488
+ }
489
+ else {
490
+ if (agent.auth.walletAddress) {
491
+ await agent.auth.authenticate().catch(() => undefined);
492
+ }
493
+ taskObj = await agent.tasks.get(arg.trim());
494
+ }
488
495
  writeOutput(stdout, jsonMode, agent.tasks.nextAction(taskObj));
489
496
  return 0;
490
497
  }
@@ -63,6 +63,7 @@ export declare function sendConfirmedTx(wallet: TxSender, pinned: PinnedReader,
63
63
  to: Hex;
64
64
  data: Hex;
65
65
  value: bigint;
66
+ gas?: bigint;
66
67
  }, label: string, { attempts, confirmMs, pollMs, }?: {
67
68
  attempts?: number;
68
69
  confirmMs?: number;
@@ -74,6 +75,7 @@ export declare function sendConfirmedGameTx(sessionKey: Hex, chain: Chain, rpcUr
74
75
  to: Hex;
75
76
  data: Hex;
76
77
  value: bigint;
78
+ gas?: bigint;
77
79
  }, label: string): Promise<TransactionReceipt>;
78
80
  /** CoordinationGame.sol Status enum: None=0, Pending=1, Active=2, Committing=3,
79
81
  * Revealing=4, Resolved=5. Any value >= 1 means the game EXISTS on-chain. */
@@ -123,6 +125,17 @@ export declare function gameExistsOnChain(contract: Hex, gameId: Hex, chain: Cha
123
125
  * anyway); re-throws only when the send threw AND the game is not on-chain.
124
126
  */
125
127
  export declare function sendCreateGameConfirmingEffect(send: () => Promise<unknown>, gameExists: () => Promise<boolean>): Promise<"sent" | "recovered">;
128
+ /**
129
+ * Gas limit floor for `revealGuess`.
130
+ *
131
+ * When both players reveal concurrently, `eth_estimateGas` simulates the cheap
132
+ * 1st-revealer path (~53k gas, storing one guess). Whichever transaction mines
133
+ * 2nd enters `_resolve()` (payouts, season accounting, and two ETH transfers,
134
+ * ~180k–250k gas) and reverts `OutOfGas` if capped at ~53k. EVM only bills
135
+ * `gasUsed`, so a 350k floor costs nothing extra for the 1st revealer while
136
+ * preventing concurrent 2nd-revealer `OutOfGas` reverts.
137
+ */
138
+ export declare const EVM_REVEAL_GUESS_MIN_GAS = 350000n;
126
139
  /**
127
140
  * Send a game CONTRACT call (session-key signed) and CONFIRM it. Encodes the call
128
141
  * and routes through sendConfirmedTx, so every game tx — createGame, joinGame,
@@ -134,4 +147,5 @@ export declare function sendAndConfirm(sessionKey: Hex, chain: Chain, rpcUrls: s
134
147
  functionName: string;
135
148
  args: readonly unknown[];
136
149
  to: Hex;
150
+ gas?: bigint;
137
151
  }, label: string): Promise<void>;
@@ -195,6 +195,17 @@ export async function sendCreateGameConfirmingEffect(send, gameExists) {
195
195
  throw e;
196
196
  }
197
197
  }
198
+ /**
199
+ * Gas limit floor for `revealGuess`.
200
+ *
201
+ * When both players reveal concurrently, `eth_estimateGas` simulates the cheap
202
+ * 1st-revealer path (~53k gas, storing one guess). Whichever transaction mines
203
+ * 2nd enters `_resolve()` (payouts, season accounting, and two ETH transfers,
204
+ * ~180k–250k gas) and reverts `OutOfGas` if capped at ~53k. EVM only bills
205
+ * `gasUsed`, so a 350k floor costs nothing extra for the 1st revealer while
206
+ * preventing concurrent 2nd-revealer `OutOfGas` reverts.
207
+ */
208
+ export const EVM_REVEAL_GUESS_MIN_GAS = 350000n;
198
209
  /**
199
210
  * Send a game CONTRACT call (session-key signed) and CONFIRM it. Encodes the call
200
211
  * and routes through sendConfirmedTx, so every game tx — createGame, joinGame,
@@ -207,5 +218,6 @@ export async function sendAndConfirm(sessionKey, chain, rpcUrls, call, label) {
207
218
  functionName: call.functionName,
208
219
  args: call.args,
209
220
  });
210
- await sendConfirmedGameTx(sessionKey, chain, rpcUrls, { to: call.to, data, value: 0n }, label);
221
+ const gas = call.gas ?? (call.functionName === "revealGuess" ? EVM_REVEAL_GUESS_MIN_GAS : undefined);
222
+ await sendConfirmedGameTx(sessionKey, chain, rpcUrls, { to: call.to, data, value: 0n, ...(gas !== undefined ? { gas } : {}) }, label);
211
223
  }
@@ -216,7 +216,10 @@ export declare class ShillbotApiClient {
216
216
  post<T>(path: string, body?: unknown): Promise<T>;
217
217
  patch<T>(path: string, body?: unknown): Promise<T>;
218
218
  listTasks<TTask = unknown>(limit?: number): Promise<TaskListResponse<TTask>>;
219
- getTask<TTask = unknown>(id: string, network?: "mainnet" | "devnet"): Promise<TTask>;
219
+ getTask<TTask = unknown>(id: string, networkOrOpts?: "mainnet" | "devnet" | {
220
+ network?: "mainnet" | "devnet";
221
+ token?: string | null;
222
+ }): Promise<TTask>;
220
223
  listAgentTasks<TTask = unknown>(): Promise<TTask[] | TaskListResponse<TTask>>;
221
224
  listPendingApproval<TTask = unknown>(networkOrOpts?: "mainnet" | "devnet" | {
222
225
  network?: "mainnet" | "devnet";
@@ -40,7 +40,7 @@ export class ShillbotApiClient {
40
40
  listTasks(limit = 50) {
41
41
  return this.http.get(`/tasks?limit=${encodeURIComponent(String(limit))}`, null);
42
42
  }
43
- async getTask(id, network) {
43
+ async getTask(id, networkOrOpts) {
44
44
  const trimmed = id.trim();
45
45
  if (!trimmed) {
46
46
  throw new SwarmClientError({
@@ -49,8 +49,12 @@ export class ShillbotApiClient {
49
49
  message: "Task id is required",
50
50
  });
51
51
  }
52
+ const network = typeof networkOrOpts === "string" ? networkOrOpts : networkOrOpts?.network;
53
+ const token = typeof networkOrOpts === "object" && networkOrOpts !== null && "token" in networkOrOpts
54
+ ? networkOrOpts.token
55
+ : null;
52
56
  const suffix = network ? `?network=${encodeURIComponent(network)}` : "";
53
- return this.http.get(`/tasks/${encodeURIComponent(trimmed)}${suffix}`, null);
57
+ return this.http.get(`/tasks/${encodeURIComponent(trimmed)}${suffix}`, token);
54
58
  }
55
59
  listAgentTasks() {
56
60
  return this.get("/agent/tasks");
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const CLIENT_VERSION = "0.4.10";
1
+ export declare const CLIENT_VERSION = "0.4.12";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLIENT_VERSION = "0.4.10";
1
+ export const CLIENT_VERSION = "0.4.12";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swarm-tips/client",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "mcpName": "io.github.corsur/swarm-tips",
5
5
  "description": "Typed browser and Node.js clients for Swarm Tips, Shillbot, and Coordination Game",
6
6
  "type": "module",