lightnode-sdk 0.7.6 → 0.7.7

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/index.d.ts CHANGED
@@ -133,7 +133,7 @@ export declare class LightNode {
133
133
  * (especially in registry-proxy environments like StackBlitz where lockfiles
134
134
  * may pin an older minor than the local install command suggests).
135
135
  */
136
- export declare const SDK_VERSION = "0.7.6";
136
+ export declare const SDK_VERSION = "0.7.7";
137
137
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei, resolveJobTransactions, 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, };
138
138
  export type { BearerSource, GatewayClientOptions, SelectSessionResult, PrepareSessionResult, UploadBlobResult, SessionTokenResult } from "./gateway.js";
139
139
  export type { SessionPreparation, RunInferenceArgs, RunInferenceResult, RunInferenceWithKeyArgs, RunInferenceStreamResult } from "./inference.js";
package/dist/index.js CHANGED
@@ -212,7 +212,7 @@ export class LightNode {
212
212
  * (especially in registry-proxy environments like StackBlitz where lockfiles
213
213
  * may pin an older minor than the local install command suggests).
214
214
  */
215
- export const SDK_VERSION = "0.7.6";
215
+ export const SDK_VERSION = "0.7.7";
216
216
  export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei,
217
217
  // v0.7.3 per-job transaction-hash resolver (lifts the upstream
218
218
  // subgraph's "block-only" Job entity to a deep-linkable Job + tx pair).
@@ -210,9 +210,10 @@ export declare class WorkerOperator {
210
210
  readonly network: NetworkConfig;
211
211
  private readonly pub;
212
212
  private readonly wallet?;
213
- private readonly addr;
213
+ private readonly maybeAddr;
214
214
  private cfgCache?;
215
215
  constructor(network: NetworkId | NetworkConfig, opts: WorkerOperatorOpts);
216
+ private get addr();
216
217
  private requireWallet;
217
218
  private get jobReg();
218
219
  private get workerReg();
@@ -282,6 +283,17 @@ export declare class WorkerOperator {
282
283
  withdraw(): Promise<`0x${string}`>;
283
284
  /** Deregister - releases stake to the wallet. Reverts (ActiveJobsExist) if any in-flight job remains. */
284
285
  deregister(): Promise<`0x${string}`>;
286
+ /**
287
+ * Add a supported model to THIS (already-registered) worker on-chain. Accepts a
288
+ * model tag (e.g. "gemma4:e2b") or a raw bytes32 modelId.
289
+ *
290
+ * This is the gas-correct version of the step the worker daemon's one-shot
291
+ * register botches: the daemon sends addSupportedModel with an under-set gas
292
+ * limit, so it OutOfGas-reverts (and its rollback deregister can too). viem
293
+ * estimates the gas here, so it lands. Use it to finish a worker that staked but
294
+ * failed to add its model. No-op (returns null) if already serving the model.
295
+ */
296
+ addModel(modelTagOrId: string): Promise<`0x${string}` | null>;
285
297
  /**
286
298
  * The flagship rescue: clear stuck jobs then release any settled completed jobs +
287
299
  * withdraw earnings then deregister. The one flow no official tool provides.
@@ -287,9 +287,13 @@ export class WorkerOperator {
287
287
  const acct = opts.walletClient?.account;
288
288
  const fromWallet = typeof acct === "string" ? acct : acct?.address;
289
289
  const a = (opts.workerAddress ?? fromWallet);
290
- if (!a)
291
- throw new Error("WorkerOperator: provide workerAddress or a walletClient with an account");
292
- this.addr = a.toLowerCase();
290
+ this.maybeAddr = a ? a.toLowerCase() : undefined;
291
+ }
292
+ get addr() {
293
+ if (!this.maybeAddr) {
294
+ throw new Error("WorkerOperator: this method needs the worker address. Pass `workerAddress` (or a `walletClient` with an account) when constructing WorkerOperator.");
295
+ }
296
+ return this.maybeAddr;
293
297
  }
294
298
  requireWallet(op) {
295
299
  if (!this.wallet)
@@ -525,6 +529,25 @@ export class WorkerOperator {
525
529
  async deregister() {
526
530
  return this.send("deregister", this.workerReg, WORKER_REGISTRY_ABI_PARSED, "deregisterWorker", []);
527
531
  }
532
+ /**
533
+ * Add a supported model to THIS (already-registered) worker on-chain. Accepts a
534
+ * model tag (e.g. "gemma4:e2b") or a raw bytes32 modelId.
535
+ *
536
+ * This is the gas-correct version of the step the worker daemon's one-shot
537
+ * register botches: the daemon sends addSupportedModel with an under-set gas
538
+ * limit, so it OutOfGas-reverts (and its rollback deregister can too). viem
539
+ * estimates the gas here, so it lands. Use it to finish a worker that staked but
540
+ * failed to add its model. No-op (returns null) if already serving the model.
541
+ */
542
+ async addModel(modelTagOrId) {
543
+ const id = modelTagOrId.startsWith("0x") && modelTagOrId.length === 66
544
+ ? modelTagOrId.toLowerCase()
545
+ : (await import("./inference.js")).modelId(modelTagOrId);
546
+ const already = (await this.read(this.workerReg, WORKER_REGISTRY_ABI_PARSED, "isEligible", [this.addr, id]));
547
+ if (already)
548
+ return null;
549
+ return this.send("addModel", this.workerReg, WORKER_REGISTRY_ABI_PARSED, "addSupportedModel", [id]);
550
+ }
528
551
  /**
529
552
  * The flagship rescue: clear stuck jobs then release any settled completed jobs +
530
553
  * withdraw earnings then deregister. The one flow no official tool provides.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lightnode-sdk",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
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",