lightnode-sdk 0.7.11 → 0.7.13

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/dist/auth.js CHANGED
@@ -152,10 +152,18 @@ export async function siweSignIn(walletClient, network, opts = {}) {
152
152
  throw new Error("siweSignIn: walletClient has no account; pass `address` explicitly");
153
153
  }
154
154
  const { message } = await siweChallenge(cfg, address, { signal: opts.signal, baseUrl: opts.baseUrl });
155
- // viem's signMessage requires `account` even when one is set on the
156
- // client; passing it explicitly works with both wagmi and bare viem.
155
+ // Pass the FULL account object when the walletClient has one (viem's
156
+ // privateKeyToAccount returns a "local" account whose signMessage signs
157
+ // off-RPC with the secret material). Passing only the address would make
158
+ // viem fall back to chain.personal_sign, which LightChain RPC does not
159
+ // expose -> -32601 MethodNotFoundRpcError.
160
+ //
161
+ // For wagmi-injected wallets the account is just `{ address }`; viem then
162
+ // dispatches to the provider (MetaMask / WalletConnect / etc.) which
163
+ // does its own personal_sign over the EIP-1193 channel.
164
+ const accountForSign = walletClient.account ?? address;
157
165
  const signature = await walletClient.signMessage({
158
- account: walletClient.account?.address ?? address,
166
+ account: accountForSign,
159
167
  message,
160
168
  });
161
169
  const verified = await siweVerify(cfg, { message, signature }, { signal: opts.signal, baseUrl: opts.baseUrl });
package/dist/gateway.d.ts CHANGED
@@ -35,6 +35,19 @@ export interface SelectSessionResult {
35
35
  disputerEncryptionKey?: string;
36
36
  nonce: number;
37
37
  expiry: number;
38
+ /**
39
+ * Opaque correlation token added by the dispatcher in May 2026
40
+ * (lcai-chat-v2 commit 33c70841, web-search epic / Story 16). The client
41
+ * MUST echo it back to `prepareSession` so a later capability-aware
42
+ * select cannot overwrite our pending slot. Optional for forward-compat
43
+ * with older dispatchers that predate the token.
44
+ *
45
+ * Without this, any concurrent activity for the same wallet produces a
46
+ * 409 selection_mismatch on prepare.
47
+ */
48
+ selectionId?: string;
49
+ /** Worker capabilities reported by the dispatcher (web-search etc.). */
50
+ workerCapabilities?: string[];
38
51
  }
39
52
  export interface PrepareSessionResult {
40
53
  worker: `0x${string}`;
@@ -95,6 +108,13 @@ export declare class GatewayClient {
95
108
  modelId: `0x${string}`;
96
109
  encWorkerKey: string;
97
110
  encDisputerKey: string;
111
+ /**
112
+ * Correlation token from {@link SelectSessionResult.selectionId}. Required
113
+ * by the May 2026 dispatcher to avoid 409 selection_mismatch when a newer
114
+ * select for the same wallet has overwritten the pending slot.
115
+ */
116
+ selectionId?: string;
117
+ requiredCapabilities?: string[];
98
118
  }): Promise<PrepareSessionResult>;
99
119
  /** Protected: upload an encrypted prompt blob; returns the EIP-4844 blob hash. */
100
120
  uploadBlob(base64Data: string): Promise<UploadBlobResult>;
package/dist/index.d.ts CHANGED
@@ -134,7 +134,7 @@ export declare class LightNode {
134
134
  * (especially in registry-proxy environments like StackBlitz where lockfiles
135
135
  * may pin an older minor than the local install command suggests).
136
136
  */
137
- export declare const SDK_VERSION = "0.7.11";
137
+ export declare const SDK_VERSION = "0.7.13";
138
138
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei, resolveJobTransactions, siweSignIn, siweChallenge, siweVerify, fetchWorkerModels, computeModelId as modelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost, GatewayClient, GatewayHttpError, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, crypto, runInference, runInferenceWithKey, runInferenceStream, Conversation, chat, runInferenceBatch, Agent, parseAgentOutput, workerPreflight, workerWatch, Bridge, BRIDGE_ROUTE, HYPERLANE_ROUTER_ABI, ERC20_ABI, addressToBytes32, quoteBridgeFee, bridgeableBalance, bridgeAllowance, approveBridge, bridgeTransfer, DAO, DAO_ADDRESSES, ProposalState, PROPOSAL_STATE_LABEL, VoteSupport, GOVERNOR_ABI, VOTES_ABI, OnchainModelRegistry, AIVM_MODEL_REGISTRY_ABI, BENCHMARK_REGISTRY_ABI, ModelStatus, MODEL_STATUS_LABEL, StalledWorkerError, OnChainRevertError, RelayTokenTimeoutError, GatewayAuthError, isStalledWorker, WorkerOperator, WORKER_REGISTRY_ABI, JOB_REGISTRY_OPERATOR_ABI, AI_CONFIG_ABI, JOB_STATE, decodeWorkerError, WorkerOpError, isWorkerOpError, };
139
139
  export type { BearerSource, GatewayClientOptions, SelectSessionResult, PrepareSessionResult, UploadBlobResult, SessionTokenResult } from "./gateway.js";
140
140
  export type { SessionPreparation, RunInferenceArgs, RunInferenceResult, RunInferenceWithKeyArgs, RunInferenceStreamResult } from "./inference.js";
package/dist/index.js CHANGED
@@ -213,7 +213,7 @@ export class LightNode {
213
213
  * (especially in registry-proxy environments like StackBlitz where lockfiles
214
214
  * may pin an older minor than the local install command suggests).
215
215
  */
216
- export const SDK_VERSION = "0.7.11";
216
+ export const SDK_VERSION = "0.7.13";
217
217
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei,
218
218
  // v0.7.3 per-job transaction-hash resolver (lifts the upstream
219
219
  // subgraph's "block-only" Job entity to a deep-linkable Job + tx pair).
package/dist/inference.js CHANGED
@@ -107,10 +107,18 @@ export async function prepareSession(gateway, modelTag) {
107
107
  const encDisputer = selected.disputerEncryptionKey
108
108
  ? await encryptSessionKey(sessionKey, await importPublicKey(decodePublicKey(selected.disputerEncryptionKey)))
109
109
  : new Uint8Array(0);
110
+ // ROOT-CAUSE FIX (lcai-chat-v2 commit 33c70841, May 2026): echo the
111
+ // dispatcher's selectionId from selectSession back into prepareSession.
112
+ // Without this, the dispatcher's pending-slot tracker matches against
113
+ // the LATEST select for our wallet, so any concurrent activity (other
114
+ // tab, other dApp signed into the same wallet) produces 409
115
+ // selection_mismatch. Threading it makes the prepare bind to the
116
+ // selection we actually got.
110
117
  const prepared = await gateway.prepareSession({
111
118
  modelId: id,
112
119
  encWorkerKey: bytesToBase64(encWorker),
113
120
  encDisputerKey: bytesToBase64(encDisputer),
121
+ ...(selected.selectionId ? { selectionId: selected.selectionId } : {}),
114
122
  });
115
123
  return {
116
124
  sessionKey,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightnode-sdk",
3
- "version": "0.7.11",
3
+ "version": "0.7.13",
4
4
  "description": "Read-only TypeScript client for LightChain AI: workers, jobs, models, on-chain registration, and per-model network analytics. Independent, community-built (not an official LightChain package).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",