feat(sdk): 0.19.0 - Conversation session reuse, viem-native client types, register()#112
Merged
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Packaging + docs
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.