lightnode-sdk 0.7.3 → 0.7.4
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 +14 -5
- package/dist/index.js +17 -3
- package/dist/subgraph.d.ts +8 -1
- package/dist/subgraph.js +10 -0
- package/dist/types.d.ts +15 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS } from "./networks.js";
|
|
2
|
-
import { fromWei, resolveJobTransactions } from "./subgraph.js";
|
|
2
|
+
import { fetchWorkerModels, fromWei, resolveJobTransactions } from "./subgraph.js";
|
|
3
3
|
import { aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv } from "./analytics.js";
|
|
4
4
|
import { modelId as computeModelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, runInference, runInferenceWithKey, runInferenceStream } from "./inference.js";
|
|
5
5
|
import { Conversation, chat } from "./chat.js";
|
|
@@ -13,7 +13,7 @@ import { OnchainModelRegistry, AIVM_MODEL_REGISTRY_ABI, BENCHMARK_REGISTRY_ABI,
|
|
|
13
13
|
import { StalledWorkerError, OnChainRevertError, RelayTokenTimeoutError, GatewayAuthError, isStalledWorker } from "./errors.js";
|
|
14
14
|
import { GatewayClient, GatewayHttpError } from "./gateway.js";
|
|
15
15
|
import * as crypto from "./crypto.js";
|
|
16
|
-
import type { NetworkId, NetworkConfig, Worker, Job, JobTransactions, ModelInfo, NetworkStats, ModelStat, WorkerStat, NetworkAnalytics } from "./types.js";
|
|
16
|
+
import type { NetworkId, NetworkConfig, Worker, Job, JobTransactions, ModelInfo, WorkerModel, NetworkStats, ModelStat, WorkerStat, NetworkAnalytics } from "./types.js";
|
|
17
17
|
/**
|
|
18
18
|
* Read-only client for a LightChain AI network. Pure reads from the public indexer
|
|
19
19
|
* and the chain; no keys, no writes. Independent, community-built.
|
|
@@ -33,6 +33,15 @@ export declare class LightNode {
|
|
|
33
33
|
getWorker(address: string): Promise<Worker | null>;
|
|
34
34
|
/** Recent jobs for one worker, newest first. */
|
|
35
35
|
getWorkerJobs(address: string, first?: number): Promise<Job[]>;
|
|
36
|
+
/**
|
|
37
|
+
* The on-chain model whitelist for one worker (rows from WorkerRegistry
|
|
38
|
+
* events). Use this when you need to answer "what models is this worker
|
|
39
|
+
* offering" - it is the authoritative signal, not derived from past jobs.
|
|
40
|
+
* Rows can be `is_active: false` (operator removed the registration) or
|
|
41
|
+
* outlive deregister: combine with {@link getWorker}.status to decide
|
|
42
|
+
* whether the worker is currently serving them.
|
|
43
|
+
*/
|
|
44
|
+
getWorkerModels(address: string): Promise<WorkerModel[]>;
|
|
36
45
|
/** The network's registered models (name, fee, output limit, whitelist flags). */
|
|
37
46
|
getModels(): Promise<ModelInfo[]>;
|
|
38
47
|
/** Registered workers (default top 200). */
|
|
@@ -113,8 +122,8 @@ export declare class LightNode {
|
|
|
113
122
|
* (especially in registry-proxy environments like StackBlitz where lockfiles
|
|
114
123
|
* may pin an older minor than the local install command suggests).
|
|
115
124
|
*/
|
|
116
|
-
export declare const SDK_VERSION = "0.7.
|
|
117
|
-
export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei, resolveJobTransactions, 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, };
|
|
125
|
+
export declare const SDK_VERSION = "0.7.4";
|
|
126
|
+
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, };
|
|
118
127
|
export type { BearerSource, GatewayClientOptions, SelectSessionResult, PrepareSessionResult, UploadBlobResult, SessionTokenResult } from "./gateway.js";
|
|
119
128
|
export type { SessionPreparation, RunInferenceArgs, RunInferenceResult, RunInferenceWithKeyArgs, RunInferenceStreamResult } from "./inference.js";
|
|
120
129
|
export type { ChatRole, ChatMessage, ConversationOptions, ConversationSendResult } from "./chat.js";
|
|
@@ -125,4 +134,4 @@ export type { BridgeChain, BridgeEndpoints, BridgeTransferArgs } from "./bridge.
|
|
|
125
134
|
export type { DaoChain, DaoAddresses, ProposalSummary, ProposalRow, DaoConfig } from "./dao.js";
|
|
126
135
|
export type { BaseModel, ModelVariant, AccessTier, AccessPolicy, Benchmark, OnchainModelRegistryOptions } from "./onchain-models.js";
|
|
127
136
|
export type { MinimalWalletClient, MinimalPublicClient, WorkerOperatorOpts, WorkerProtocolConfig, WorkerStatus, DeregisterReadiness, StuckJob, EarningsBreakdown, OnchainJob, JobState, DecodedWorkerError, } from "./worker-operator.js";
|
|
128
|
-
export type { NetworkId, NetworkConfig, Worker, Job, JobTransactions, ModelInfo, NetworkStats, ModelStat, WorkerStat, NetworkAnalytics };
|
|
137
|
+
export type { NetworkId, NetworkConfig, Worker, Job, JobTransactions, ModelInfo, WorkerModel, NetworkStats, ModelStat, WorkerStat, NetworkAnalytics };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS } from "./networks.js";
|
|
2
|
-
import { fetchWorker, fetchWorkerJobs, fetchRecentJobs, fetchJob, fetchModels, fetchWorkers, summarize, fromWei, resolveJobTransactions, } from "./subgraph.js";
|
|
2
|
+
import { fetchWorker, fetchWorkerJobs, fetchWorkerModels, fetchRecentJobs, fetchJob, fetchModels, fetchWorkers, summarize, fromWei, resolveJobTransactions, } from "./subgraph.js";
|
|
3
3
|
import { isRegistered } from "./onchain.js";
|
|
4
4
|
import { aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, } from "./analytics.js";
|
|
5
5
|
import { modelId as computeModelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, runInference, runInferenceWithKey, runInferenceStream, } from "./inference.js";
|
|
@@ -40,6 +40,17 @@ export class LightNode {
|
|
|
40
40
|
getWorkerJobs(address, first = 20) {
|
|
41
41
|
return fetchWorkerJobs(this.network, address, first);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The on-chain model whitelist for one worker (rows from WorkerRegistry
|
|
45
|
+
* events). Use this when you need to answer "what models is this worker
|
|
46
|
+
* offering" - it is the authoritative signal, not derived from past jobs.
|
|
47
|
+
* Rows can be `is_active: false` (operator removed the registration) or
|
|
48
|
+
* outlive deregister: combine with {@link getWorker}.status to decide
|
|
49
|
+
* whether the worker is currently serving them.
|
|
50
|
+
*/
|
|
51
|
+
getWorkerModels(address) {
|
|
52
|
+
return fetchWorkerModels(this.network, address);
|
|
53
|
+
}
|
|
43
54
|
/** The network's registered models (name, fee, output limit, whitelist flags). */
|
|
44
55
|
getModels() {
|
|
45
56
|
return fetchModels(this.network);
|
|
@@ -170,11 +181,14 @@ export class LightNode {
|
|
|
170
181
|
* (especially in registry-proxy environments like StackBlitz where lockfiles
|
|
171
182
|
* may pin an older minor than the local install command suggests).
|
|
172
183
|
*/
|
|
173
|
-
export const SDK_VERSION = "0.7.
|
|
184
|
+
export const SDK_VERSION = "0.7.4";
|
|
174
185
|
export { NETWORKS, WORKER_REGISTRY, REGISTRY_TOPICS, aggregateModelStats, aggregateWorkerStats, networkAnalytics, modelStatsCsv, workerStatsCsv, workerJobsCsv, fromWei,
|
|
175
186
|
// v0.7.3 per-job transaction-hash resolver (lifts the upstream
|
|
176
187
|
// subgraph's "block-only" Job entity to a deep-linkable Job + tx pair).
|
|
177
|
-
resolveJobTransactions,
|
|
188
|
+
resolveJobTransactions,
|
|
189
|
+
// v0.7.4 per-worker model-registration list (the authoritative "what is
|
|
190
|
+
// this worker offering to serve" signal, not derived from past jobs).
|
|
191
|
+
fetchWorkerModels, computeModelId as modelId, estimateJobFee, JOB_REGISTRY_CONSUMER_ABI, consumerGatewayUrl, consumerGatewayHost,
|
|
178
192
|
// v0.3 inference-submit surface (BETA - see README "Submitting inference").
|
|
179
193
|
GatewayClient, GatewayHttpError, prepareSession, submitPrompt, decryptResponse, generateEcdhKeyPair, crypto,
|
|
180
194
|
// v0.4 high-level orchestrator: one call, full flow.
|
package/dist/subgraph.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PublicClient } from "viem";
|
|
2
|
-
import type { NetworkConfig, Worker, Job, JobTransactions, ModelInfo, NetworkStats } from "./types.js";
|
|
2
|
+
import type { NetworkConfig, Worker, Job, JobTransactions, ModelInfo, NetworkStats, WorkerModel } from "./types.js";
|
|
3
3
|
/** Convert a wei string to a number of whole tokens (18 decimals). */
|
|
4
4
|
export declare function fromWei(wei?: string): number;
|
|
5
5
|
export declare function fetchWorker(cfg: NetworkConfig, address: string): Promise<Worker | null>;
|
|
@@ -28,6 +28,13 @@ export declare function resolveJobTransactions(cfg: NetworkConfig, jobId: string
|
|
|
28
28
|
publicClient?: PublicClient;
|
|
29
29
|
job?: Job | null;
|
|
30
30
|
}): Promise<JobTransactions>;
|
|
31
|
+
/**
|
|
32
|
+
* The on-chain model registrations for one worker. The Graph entity name is
|
|
33
|
+
* `workermodels` (lowercase), and `is_active` flips when the operator
|
|
34
|
+
* removes a registration. Independent of `Worker.status`: a deregistered
|
|
35
|
+
* worker can still have rows here from when it was live.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fetchWorkerModels(cfg: NetworkConfig, address: string): Promise<WorkerModel[]>;
|
|
31
38
|
export declare function fetchModels(cfg: NetworkConfig): Promise<ModelInfo[]>;
|
|
32
39
|
export declare function fetchWorkers(cfg: NetworkConfig, first?: number): Promise<Worker[]>;
|
|
33
40
|
export declare function summarize(workers: Worker[], models: ModelInfo[]): NetworkStats;
|
package/dist/subgraph.js
CHANGED
|
@@ -142,6 +142,16 @@ async function fetchTxHashForJobEvent(client, address, eventTopic, jobTopic, blo
|
|
|
142
142
|
return null;
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* The on-chain model registrations for one worker. The Graph entity name is
|
|
147
|
+
* `workermodels` (lowercase), and `is_active` flips when the operator
|
|
148
|
+
* removes a registration. Independent of `Worker.status`: a deregistered
|
|
149
|
+
* worker can still have rows here from when it was live.
|
|
150
|
+
*/
|
|
151
|
+
export async function fetchWorkerModels(cfg, address) {
|
|
152
|
+
const data = await gql(cfg.subgraph, `{ workermodels(where:{worker:"${checksum(address)}"}) { id worker model_id is_active created_at updated_at } }`);
|
|
153
|
+
return data.workermodels ?? [];
|
|
154
|
+
}
|
|
145
155
|
export async function fetchModels(cfg) {
|
|
146
156
|
const data = await gql(cfg.subgraph, `{ modelinfos { id name fee max_output_tokens is_whitelisted is_enabled } }`);
|
|
147
157
|
return data.modelinfos ?? [];
|
package/dist/types.d.ts
CHANGED
|
@@ -63,6 +63,21 @@ export interface ModelInfo {
|
|
|
63
63
|
is_whitelisted: boolean;
|
|
64
64
|
is_enabled: boolean;
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Per-worker model registration row. The on-chain truth for "which models has
|
|
68
|
+
* this worker offered to serve" - indexed from WorkerRegistry events.
|
|
69
|
+
* `is_active` flips to false when the operator removes the registration; it
|
|
70
|
+
* is independent of whether the worker itself is currently registered in the
|
|
71
|
+
* protocol.
|
|
72
|
+
*/
|
|
73
|
+
export interface WorkerModel {
|
|
74
|
+
id: string;
|
|
75
|
+
worker: string;
|
|
76
|
+
model_id: string;
|
|
77
|
+
is_active: boolean;
|
|
78
|
+
created_at?: number;
|
|
79
|
+
updated_at?: number;
|
|
80
|
+
}
|
|
66
81
|
export interface NetworkStats {
|
|
67
82
|
total: number;
|
|
68
83
|
active: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lightnode-sdk",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
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",
|