lightnode-sdk 0.3.2 → 0.4.1

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/README.md CHANGED
@@ -81,8 +81,12 @@ npx lightnode fee llama3-8b # on-chain job fee
81
81
  npx lightnode analytics --csv # per-model performance (CSV)
82
82
  npx lightnode reliability --csv # per-worker reliability (CSV)
83
83
 
84
- # Scaffold inference into an existing project (auto-detects Next.js, Hono, or Node):
85
- npx lightnode add inference [--template auto|nextjs-api|hono|node] [--net testnet|mainnet] [--force]
84
+ # Patch an existing project (auto-detects Next.js, Hono, or Node):
85
+ npx lightnode add inference # encrypted inference route/script
86
+ npx lightnode add chat # chat-style UI with conversation history
87
+ npx lightnode add analytics-dashboard # read-only network + worker analytics page
88
+ npx lightnode add nft-mint-with-inference # AI-generated NFT metadata with on-chain provenance
89
+ # All `add` commands accept [--template auto|nextjs-api|hono|node] [--net testnet|mainnet] [--force]
86
90
 
87
91
  # Or scaffold a brand-new project:
88
92
  npm create lightnode-app my-app
@@ -90,6 +94,34 @@ npm create lightnode-app my-app
90
94
 
91
95
  ## Submitting inference
92
96
 
97
+ **Easy mode (`runInference` — v0.4+):** one async call drives the whole protocol —
98
+ SIWE → prepareSession → on-chain createSession → relay WS → encrypt + upload prompt
99
+ → on-chain submitJob → decrypt streamed chunks → wait for `JobCompleted` →
100
+ return the assembled answer + three tx hashes. Built-in retry on `StalledWorkerError`.
101
+
102
+ ```ts
103
+ import { LightNode, GatewayClient, runInference } from "lightnode-sdk";
104
+ import WS from "ws"; // omit in the browser
105
+
106
+ const ln = new LightNode("testnet");
107
+ const gateway = new GatewayClient({ network: "testnet", bearer: await getJwt() });
108
+ const { answer, txs } = await runInference({
109
+ prompt: "Reply with a one-sentence fun fact about the ocean.",
110
+ gateway, wallet, publicClient, network: ln.network,
111
+ WebSocket: WS,
112
+ onChunk: (chunk) => process.stdout.write(chunk), // live streaming
113
+ maxRetries: 2, // auto-retry on stall
114
+ });
115
+ console.log("\n", txs); // { createSession, submitJob, jobCompleted }
116
+ ```
117
+
118
+ The lower-level helpers (`prepareSession`, `submitPrompt`, `decryptResponse`,
119
+ the typed errors `StalledWorkerError` / `OnChainRevertError` / `GatewayAuthError`
120
+ / `RelayTokenTimeoutError`) stay exported for builders who want a different
121
+ retry policy or to reuse a session across prompts.
122
+
123
+ ### Manual mode (the full surface)
124
+
93
125
  `v0.3+` ships the encrypted inference-submit flow end to end. Wire-compatible with
94
126
  the reference client [`lcai-chat-v2`](https://github.com/lightchain-protocol/lcai-chat-v2)
95
127
  (same ECDH-P256 + AES-256-GCM, same gateway endpoints, same `JobRegistry` calls).
package/dist/add.d.ts CHANGED
@@ -30,4 +30,28 @@ export declare function addInference(opts?: AddOpts): {
30
30
  template: Template;
31
31
  network: Network;
32
32
  };
33
+ export declare function addAnalyticsDashboard(opts?: AddOpts): {
34
+ written: WrittenFile[];
35
+ install: string;
36
+ template: Template;
37
+ network: Network;
38
+ };
39
+ export declare function addAgent(opts?: AddOpts): {
40
+ written: WrittenFile[];
41
+ install: string;
42
+ template: Template;
43
+ network: Network;
44
+ };
45
+ export declare function addChat(opts?: AddOpts): {
46
+ written: WrittenFile[];
47
+ install: string;
48
+ template: Template;
49
+ network: Network;
50
+ };
51
+ export declare function addNftMint(opts?: AddOpts): {
52
+ written: WrittenFile[];
53
+ install: string;
54
+ template: Template;
55
+ network: Network;
56
+ };
33
57
  export {};