@swarm-tips/client 0.4.10 → 0.4.11

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.11",
6
+ "documentNamespace": "https://swarm.tips/sbom/client/0.4.11",
7
7
  "creationInfo": {
8
- "created": "2026-11-27T09:27:26.689Z",
8
+ "created": "2026-11-27T14:59:47.831Z",
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.11",
19
+ "downloadLocation": "https://www.npmjs.com/package/@swarm-tips/client/v/0.4.11",
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
  }
@@ -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.11";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const CLIENT_VERSION = "0.4.10";
1
+ export const CLIENT_VERSION = "0.4.11";
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.11",
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",