Skip to content

feat(sdk): 0.19.0 - Conversation session reuse, viem-native client types, register()#112

Merged
marinom2 merged 1 commit into
mainfrom
feat/sdk-0.19.0
Jun 11, 2026
Merged

feat(sdk): 0.19.0 - Conversation session reuse, viem-native client types, register()#112
marinom2 merged 1 commit into
mainfrom
feat/sdk-0.19.0

Conversation

@marinom2

Copy link
Copy Markdown
Owner

Second of three PRs from the full-repo review. Fixes the three confirmed SDK findings and ships them as 0.19.0.

Conversation actually reuses its session now

The README claimed multi-turn chat "reuses one session across turns (one tx per turn, not two)" while the implementation ran a full SIWE + createSession + submitJob on EVERY send. Conversation is rebuilt on openSession/runJobOnSession: first send opens the session, follow-ups submit straight onto it, near-expiry windows and dead workers trigger a transparent reopen + one retry of the same serialized turn. currentSession() exposes the handle. 21 unit tests cover reuse, expiry-reopen, retry, and the existing serialization behavior.

viem clients pass in without casts

README examples like new Bridge(publicClient, walletClient) did not compile: the Minimal* interfaces used function-property members (contravariant params), rejecting real viem clients. All Minimal* interfaces (bridge, dao, worker-operator, onchain-models, inference) are method-typed, with a few member shapes widened to viem's parameter unions. cli.ts loses its 'as any' boundary casts. A compile-level regression test constructs real viem clients and passes them into Bridge/DAO/WorkerOperator/OnchainModelRegistry with zero casts; root tsc fails if assignability regresses.

New surface

  • connectWithKey(args) -> KeyConnection: the setup half of runInferenceWithKey (key validation, viem clients, SIWE handshake, WebSocket resolution) as a reusable public API.
  • WorkerOperator.register(encryptionPubKey, opts?): completes the operator lifecycle (stake defaults to the live AIConfig minimum, simulate pre-flight, decoded reverts).

Packaging + docs

  • 0.19.0; typescript in devDependencies (standalone sdk/ checkout now builds); viem bounded ^2; honest description.
  • create-lightnode-app 0.2.3 pins lightnode-sdk ^0.19.0.
  • sdk/README rewritten against the real surface: package-qualified npx lightnode-sdk commands (npm's bare 'lightnode' name is an unrelated squatted package), BOTH governors documented with the full address table, thirteen add targets including batch and bridge, absolute links that work on npmjs.com, and every example extracted and compiled verbatim against the built dist under strict TypeScript (tsc exit 0).

Publish

NOT publishable from CI yet: the repo has no NPM_TOKEN secret and no local npm login. Once the token is added (see .github/workflows/publish-sdk.yml header), publishing is: git tag sdk-v0.19.0 && git push origin sdk-v0.19.0, then create-lightnode-app after it.

Verification

sdk build clean, root typecheck clean, 507 root tests + 5 new compat tests green.

…pes, register()

Conversation now keeps one on-chain session open across turns: the first send
runs the SIWE handshake and the single createSession tx, every follow-up is
one submitJob on the open session, and an expired window or a dead worker
triggers a transparent reopen with one retry of the same turn. The README's
session-reuse claim is finally true in code. currentSession() exposes the
handle; reset() keeps it (sessions are prompt-agnostic).

New connectWithKey() extracts the setup half of runInferenceWithKey
(key validation, viem clients, SIWE, WebSocket resolution) as a public API
returning KeyConnection, which Conversation reuses.

The Minimal* client interfaces across bridge, dao, worker-operator,
onchain-models, and inference are method-typed (bivariant) with a few member
shapes widened to viem's unions, so real viem PublicClient/WalletClient
instances pass into Bridge, DAO, WorkerOperator, and OnchainModelRegistry
with zero casts. cli.ts drops its 'as any' boundary casts. A compile-level
regression test (tests/unit/sdk-viem-compat.test.ts) locks this in, and the
Conversation suite grows session-reuse, expiry-reopen, and retry coverage
(21 tests).

WorkerOperator.register(encryptionPubKey, opts?) completes the lifecycle
(stake defaults to the live AIConfig minimum, simulate pre-flight, decoded
reverts). BridgeTransferArgs.recipient JSDoc no longer claims a default
that never existed.

Packaging: version 0.19.0, typescript added to devDependencies so a
standalone sdk/ checkout builds, viem bounded to ^2, description wording
matches reality. create-lightnode-app 0.2.3 pins lightnode-sdk ^0.19.0.
sdk/README rewritten against the real surface: package-qualified npx
commands (the bare npm name is squatted), both governors documented with
the full address table, thirteen add targets, and every example verified
to compile against the built dist under strict TypeScript.
@marinom2 marinom2 merged commit 4076140 into main Jun 11, 2026
1 of 2 checks passed
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lightnode Building Building Preview, Comment Jun 11, 2026 9:09pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant