@sogni-ai/sogni-client 5.1.0-alpha.2 → 5.1.0-alpha.20

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.
Files changed (141) hide show
  1. package/AGENTS.md +11 -1
  2. package/CHANGELOG.md +147 -0
  3. package/README.md +52 -10
  4. package/dist/Account/CurrentAccount.d.ts +8 -6
  5. package/dist/Account/CurrentAccount.js +5 -4
  6. package/dist/Account/CurrentAccount.js.map +1 -1
  7. package/dist/Account/index.d.ts +32 -0
  8. package/dist/Account/index.js +184 -3
  9. package/dist/Account/index.js.map +1 -1
  10. package/dist/Account/subscription.types.d.ts +82 -3
  11. package/dist/Account/types.d.ts +12 -0
  12. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +2 -0
  13. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +31 -0
  14. package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
  15. package/dist/ApiClient/WebSocketClient/events.d.ts +80 -0
  16. package/dist/Chat/ChatJobError.d.ts +111 -0
  17. package/dist/Chat/ChatJobError.js +116 -0
  18. package/dist/Chat/ChatJobError.js.map +1 -0
  19. package/dist/Chat/ChatTools.js +7 -10
  20. package/dist/Chat/ChatTools.js.map +1 -1
  21. package/dist/Chat/_hostedToolsManifest.generated.js +25 -17
  22. package/dist/Chat/_hostedToolsManifest.generated.js.map +1 -1
  23. package/dist/Chat/hostedToolValidator.js +4 -3
  24. package/dist/Chat/hostedToolValidator.js.map +1 -1
  25. package/dist/Chat/index.d.ts +8 -1
  26. package/dist/Chat/index.js +114 -15
  27. package/dist/Chat/index.js.map +1 -1
  28. package/dist/Chat/modelRouting.d.ts +13 -3
  29. package/dist/Chat/modelRouting.js +37 -17
  30. package/dist/Chat/modelRouting.js.map +1 -1
  31. package/dist/Chat/tools.d.ts +14 -11
  32. package/dist/Chat/tools.js +15 -13
  33. package/dist/Chat/tools.js.map +1 -1
  34. package/dist/Chat/types.d.ts +58 -0
  35. package/dist/CreativeWorkflows/Templates/index.js +4 -2
  36. package/dist/CreativeWorkflows/Templates/index.js.map +1 -1
  37. package/dist/CreativeWorkflows/index.js +20 -11
  38. package/dist/CreativeWorkflows/index.js.map +1 -1
  39. package/dist/CreativeWorkflows/types.d.ts +17 -0
  40. package/dist/Projects/createJobRequestMessage.js +93 -9
  41. package/dist/Projects/createJobRequestMessage.js.map +1 -1
  42. package/dist/Projects/index.d.ts +6 -1
  43. package/dist/Projects/index.js +48 -1
  44. package/dist/Projects/index.js.map +1 -1
  45. package/dist/Projects/types/ControlNetParams.d.ts +4 -1
  46. package/dist/Projects/types/index.d.ts +46 -9
  47. package/dist/Projects/types/index.js.map +1 -1
  48. package/dist/Projects/utils/index.d.ts +29 -1
  49. package/dist/Projects/utils/index.js +80 -10
  50. package/dist/Projects/utils/index.js.map +1 -1
  51. package/dist/Replay/index.js +5 -4
  52. package/dist/Replay/index.js.map +1 -1
  53. package/dist/index.d.ts +9 -6
  54. package/dist/index.js +8 -1
  55. package/dist/index.js.map +1 -1
  56. package/dist/lib/isSubscriptionLimitError.d.ts +16 -0
  57. package/dist/lib/isSubscriptionLimitError.js +36 -0
  58. package/dist/lib/isSubscriptionLimitError.js.map +1 -0
  59. package/dist/lib/validation.d.ts +1 -0
  60. package/dist/lib/validation.js +15 -1
  61. package/dist/lib/validation.js.map +1 -1
  62. package/dist/types/ErrorData.d.ts +53 -0
  63. package/dist/types/ErrorData.js +25 -0
  64. package/dist/types/ErrorData.js.map +1 -1
  65. package/dist/version.d.ts +1 -1
  66. package/dist/version.js +1 -1
  67. package/dist/version.js.map +1 -1
  68. package/dist-esm/Account/CurrentAccount.js +5 -4
  69. package/dist-esm/Account/CurrentAccount.js.map +1 -1
  70. package/dist-esm/Account/index.js +184 -3
  71. package/dist-esm/Account/index.js.map +1 -1
  72. package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +31 -0
  73. package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
  74. package/dist-esm/Chat/ChatJobError.js +111 -0
  75. package/dist-esm/Chat/ChatJobError.js.map +1 -0
  76. package/dist-esm/Chat/ChatTools.js +8 -11
  77. package/dist-esm/Chat/ChatTools.js.map +1 -1
  78. package/dist-esm/Chat/_hostedToolsManifest.generated.js +25 -17
  79. package/dist-esm/Chat/_hostedToolsManifest.generated.js.map +1 -1
  80. package/dist-esm/Chat/hostedToolValidator.js +4 -3
  81. package/dist-esm/Chat/hostedToolValidator.js.map +1 -1
  82. package/dist-esm/Chat/index.js +81 -15
  83. package/dist-esm/Chat/index.js.map +1 -1
  84. package/dist-esm/Chat/modelRouting.js +36 -18
  85. package/dist-esm/Chat/modelRouting.js.map +1 -1
  86. package/dist-esm/Chat/tools.js +15 -13
  87. package/dist-esm/Chat/tools.js.map +1 -1
  88. package/dist-esm/CreativeWorkflows/Templates/index.js +4 -2
  89. package/dist-esm/CreativeWorkflows/Templates/index.js.map +1 -1
  90. package/dist-esm/CreativeWorkflows/index.js +20 -11
  91. package/dist-esm/CreativeWorkflows/index.js.map +1 -1
  92. package/dist-esm/Projects/createJobRequestMessage.js +94 -10
  93. package/dist-esm/Projects/createJobRequestMessage.js.map +1 -1
  94. package/dist-esm/Projects/index.js +49 -2
  95. package/dist-esm/Projects/index.js.map +1 -1
  96. package/dist-esm/Projects/types/index.js.map +1 -1
  97. package/dist-esm/Projects/utils/index.js +77 -10
  98. package/dist-esm/Projects/utils/index.js.map +1 -1
  99. package/dist-esm/Replay/index.js +5 -4
  100. package/dist-esm/Replay/index.js.map +1 -1
  101. package/dist-esm/index.js +5 -1
  102. package/dist-esm/index.js.map +1 -1
  103. package/dist-esm/lib/isSubscriptionLimitError.js +33 -0
  104. package/dist-esm/lib/isSubscriptionLimitError.js.map +1 -0
  105. package/dist-esm/lib/validation.js +15 -1
  106. package/dist-esm/lib/validation.js.map +1 -1
  107. package/dist-esm/types/ErrorData.js +24 -1
  108. package/dist-esm/types/ErrorData.js.map +1 -1
  109. package/dist-esm/version.js +1 -1
  110. package/dist-esm/version.js.map +1 -1
  111. package/llms-full.txt +119 -21
  112. package/llms.txt +85 -14
  113. package/package.json +5 -3
  114. package/src/Account/CurrentAccount.ts +8 -6
  115. package/src/Account/index.ts +236 -7
  116. package/src/Account/subscription.types.ts +80 -3
  117. package/src/Account/types.ts +18 -0
  118. package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +29 -0
  119. package/src/ApiClient/WebSocketClient/events.ts +81 -0
  120. package/src/Chat/ChatJobError.ts +188 -0
  121. package/src/Chat/ChatTools.ts +8 -10
  122. package/src/Chat/_hostedToolsManifest.generated.ts +25 -17
  123. package/src/Chat/hostedToolValidator.ts +7 -4
  124. package/src/Chat/index.ts +133 -30
  125. package/src/Chat/modelRouting.ts +60 -18
  126. package/src/Chat/tools.ts +22 -17
  127. package/src/Chat/types.ts +68 -0
  128. package/src/CreativeWorkflows/Templates/index.ts +6 -2
  129. package/src/CreativeWorkflows/index.ts +6 -0
  130. package/src/CreativeWorkflows/types.ts +17 -0
  131. package/src/Projects/createJobRequestMessage.ts +105 -9
  132. package/src/Projects/index.ts +44 -1
  133. package/src/Projects/types/ControlNetParams.ts +4 -1
  134. package/src/Projects/types/index.ts +48 -8
  135. package/src/Projects/utils/index.ts +78 -10
  136. package/src/Replay/index.ts +9 -21
  137. package/src/index.ts +22 -2
  138. package/src/lib/isSubscriptionLimitError.ts +36 -0
  139. package/src/lib/validation.ts +15 -1
  140. package/src/types/ErrorData.ts +57 -0
  141. package/src/version.ts +1 -1
package/AGENTS.md CHANGED
@@ -36,6 +36,7 @@ The SDK wraps the public Sogni Intelligence endpoints used for text chat, hosted
36
36
 
37
37
  - `sogni.chat.completions.create()` maps to socket-native chat completions and supports text, streaming, vision input, custom function tools, Sogni tool injection, structured outputs, and `think` / `taskProfile` controls.
38
38
  - `sogni.chat.hosted.create()` maps to `POST /v1/chat/completions`, the OpenAI-compatible REST chat endpoint. It can execute Sogni media-generation and composition tools server-side.
39
+ - `sogni.chat.hosted.executeTool()` maps to `POST /v1/creative-agent/tools/execute` for direct execution of known synchronous composition/planning tools (`enhance_prompt`, `compose_script`, `compose_lyrics`, `compose_instrumental`, `compose_workflow`, `compose_workflow_template`) without an LLM dispatcher round.
39
40
  - `sogni.chat.runs` maps to `/v1/chat/runs`, a durable hosted-chat turn with persisted state, event replay, cancellation, and recovery across client disconnects.
40
41
  - `sogni.workflows` maps to `/v1/creative-agent/workflows`, where callers submit exact multi-step creative plans and observe durable execution through snapshots, event logs, or SSE.
41
42
  - `sogni.workflows.templates` maps to `/v1/creative-agent/workflows/templates`, the CRUD and fork API for saved, parameterized workflow recipes.
@@ -49,7 +50,7 @@ Public chat and workflow media rules:
49
50
 
50
51
  ## Overview
51
52
 
52
- This is the **Sogni SDK for JavaScript/Node.js** - a TypeScript client library for the Sogni Supernet, a DePIN protocol for creative AI inference. The SDK supports image generation (Stable Diffusion, Flux, Z-Image, Qwen image-edit models, GPT Image 2), video generation (WAN 2.2, LTX-2.3, Seedance 2.0), audio generation (ACE-Step 1.5), LLM chat with tool calling, hosted creative tools, durable creative workflows, replay records, and multimodal vision chat (Qwen3.6 35B VLM, default `qwen3.6-35b-a3b-gguf-iq4xs`).
53
+ This is the **Sogni SDK for JavaScript/Node.js** - a TypeScript client library for the Sogni Supernet, a DePIN protocol for creative AI inference. The SDK supports image generation (Stable Diffusion, Flux, Flux.2, Z-Image / Z-Image Turbo, Krea 2 Turbo, Krea 2 Identity Edit, Chroma v.46 Flash / v.48 Detail / Chroma1-HD, Qwen image-edit models, GPT Image 2, plus community fine-tunes such as Dark Beast Z-Image Turbo v9, Dark Beast KREA 2, Dark Beast Krea 2 Identity Edit, and One Obsession v22), video generation (WAN 2.2, LTX-2.3, Seedance 2.0, HappyHorse 1.1), audio generation (ACE-Step 1.5), LLM chat with tool calling, hosted creative tools, durable creative workflows, replay records, and multimodal vision chat (Qwen3.6 35B VLM, default `qwen3.6-35b-a3b-gguf-iq4xs`). The model catalog is discovered dynamically at runtime (`sogni.projects.getAvailableModels()`); model ids listed here are illustrative.
53
54
 
54
55
  Runtime and packaging:
55
56
 
@@ -201,6 +202,14 @@ The SDK supports two families of video models with **fundamentally different FPS
201
202
  - **Frame calculation**: `duration * 16 + 1` (always uses 16, ignores fps)
202
203
  - Example: 5 seconds at 32fps = 81 frames generated → interpolated to 161 output frames
203
204
 
205
+ ### External-API Partner Models (Seedance 2.0, Happy Horse 1.1)
206
+
207
+ **Seedance 2.0** (`seedance-2-0` / `-mini` / `-fast`) and **Happy Horse 1.1** (`happyhorse-1.1-t2v` / `-i2v` / `-r2v`) run on partner external APIs, not Sogni GPU workers:
208
+ - **Spark-only** billing, **fixed 24fps**, and **native audio** (no separate audio params to set).
209
+ - No local diffusion steps — progress is provider/ETA-derived (still a finite 0-100). Results can arrive as direct hosted URLs, preserved on `job.resultUrl` / `job.getResultUrl()`.
210
+ - **Seedance** accepts image + video + audio references (up to 9 / 3 / 3, 12 total) via `referenceImage*` / `referenceImageUrls` / `referenceVideoUrls` / `referenceAudioUrls`. **Happy Horse** accepts **image-only** references (r2v takes 1-9 images via `referenceImage` / `referenceImageUrls`).
211
+ - Family predicates: `isSeedanceModel()`, `isHappyhorseModel()`, `isExternalApiVideoModel()` in `src/Projects/utils/index.ts`.
212
+
204
213
  ### Key Files
205
214
  - `src/Projects/utils/index.ts` - `isWanModel()`, `isLtx2Model()`, `calculateVideoFrames()`
206
215
  - `src/Projects/createJobRequestMessage.ts` - Uses `calculateVideoFrames()` for duration→frames conversion
@@ -290,6 +299,7 @@ const urls = await project.waitForCompletion();
290
299
  |----------|---------------|-----------------|
291
300
  | Text-to-Video | `*_t2v*` | None |
292
301
  | Image-to-Video | `*_i2v*` | `referenceImage` (and/or `referenceImageEnd`) |
302
+ | Reference-to-Video | `*_r2v*` (Happy Horse) | 1-9 images via `referenceImage`/`referenceImageUrls` |
293
303
  | Video-to-Video | `*_v2v*` (LTX-2.3) | `referenceVideo` + `controlNet` |
294
304
  | Sound-to-Video | `*_s2v*` (WAN only) | `referenceImage` + `referenceAudio` |
295
305
  | Image+Audio-to-Video | `*_ia2v*` (LTX-2.3) | `referenceImage` + `referenceAudio` |
package/CHANGELOG.md CHANGED
@@ -1,3 +1,150 @@
1
+ # [5.1.0-alpha.20](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.19...v5.1.0-alpha.20) (2026-07-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * add Krea identity edit awareness ([bcb7cc3](https://github.com/Sogni-AI/sogni-client/commit/bcb7cc3068f30233ded5f1f546ed9604c2d98743))
7
+
8
+ # [5.1.0-alpha.19](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.18...v5.1.0-alpha.19) (2026-07-11)
9
+
10
+
11
+ ### Features
12
+
13
+ * add chat safe-content routing flag ([822a863](https://github.com/Sogni-AI/sogni-client/commit/822a863c7a6888defd67ce79b63751bc92c23b7c))
14
+
15
+ # [5.1.0-alpha.18](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.17...v5.1.0-alpha.18) (2026-07-11)
16
+
17
+
18
+ ### Features
19
+
20
+ * **chat:** add direct hosted tool execution ([d5c182a](https://github.com/Sogni-AI/sogni-client/commit/d5c182a14d31a8fdb661c67682fa6cc2401188d3))
21
+
22
+ # [5.1.0-alpha.17](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.16...v5.1.0-alpha.17) (2026-07-10)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **workflows:** pass billing mode through durable workflows ([70ad0ad](https://github.com/Sogni-AI/sogni-client/commit/70ad0ad45c36810397f7c7e83925c94150d909ba))
28
+
29
+ # [5.1.0-alpha.16](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.15...v5.1.0-alpha.16) (2026-06-30)
30
+
31
+
32
+ ### Features
33
+
34
+ * **examples:** expose Krea 2 style LoRA in text-to-image example ([62aa174](https://github.com/Sogni-AI/sogni-client/commit/62aa17416bd1868e2a62b02993a169a06cd8e9a7))
35
+
36
+ # [5.1.0-alpha.15](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.14...v5.1.0-alpha.15) (2026-06-28)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * **deps:** bump @sogni-ai/sogni-protocol to 1.0.0-alpha.9 ([05008b9](https://github.com/Sogni-AI/sogni-client/commit/05008b9fc62f326f52c72d43a1b71e8b9cd3f1f3))
42
+
43
+
44
+ ### Features
45
+
46
+ * **models:** add Krea 2 Turbo image model support ([19572e2](https://github.com/Sogni-AI/sogni-client/commit/19572e214390b79af0138a687c45ec37b26eb4ac))
47
+ * **video:** add HappyHorse 1.1 video model routing ([75f2ebe](https://github.com/Sogni-AI/sogni-client/commit/75f2ebea4be8a65d2a055e22d6625c3c1cfcd053))
48
+
49
+ # [5.1.0-alpha.14](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.13...v5.1.0-alpha.14) (2026-06-25)
50
+
51
+
52
+ ### Bug Fixes
53
+
54
+ * **deps:** bump sogni protocol alpha ([e2f9a4b](https://github.com/Sogni-AI/sogni-client/commit/e2f9a4b012340a4501145dcb33db9227c4347ff7))
55
+
56
+ # [5.1.0-alpha.13](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.12...v5.1.0-alpha.13) (2026-06-25)
57
+
58
+
59
+ ### Features
60
+
61
+ * add Seedance Mini routing ([11c2855](https://github.com/Sogni-AI/sogni-client/commit/11c28552ed4834a0861201b305420c9e930f5daf))
62
+
63
+ # [5.1.0-alpha.12](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.11...v5.1.0-alpha.12) (2026-06-25)
64
+
65
+
66
+ ### Features
67
+
68
+ * **subscription:** add paymentPending to entitlement snapshot ([#17](https://github.com/Sogni-AI/sogni-client/issues/17)) ([792d959](https://github.com/Sogni-AI/sogni-client/commit/792d959710fac8daaf5ea358c2746de916e650e2))
69
+
70
+ # [5.1.0-alpha.11](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.10...v5.1.0-alpha.11) (2026-06-25)
71
+
72
+
73
+ ### Features
74
+
75
+ * **video:** expose Seedance 4K client metadata ([19e1dd5](https://github.com/Sogni-AI/sogni-client/commit/19e1dd5319bd0a859cbae8fb8ff6672ef068fddc))
76
+
77
+ # [5.1.0-alpha.10](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.9...v5.1.0-alpha.10) (2026-06-18)
78
+
79
+
80
+ ### Features
81
+
82
+ * **audio:** prefer ACE-Step XL music models ([ec5a715](https://github.com/Sogni-AI/sogni-client/commit/ec5a71579d04b42863ce9627c8ea4935b0190f70))
83
+ * **projects:** expose LTX-2.3 v2v outpaint and inpaint controls ([1a60576](https://github.com/Sogni-AI/sogni-client/commit/1a605766e42b6fa5cdedf0a64425deb51cbf81b1))
84
+
85
+ # [5.1.0-alpha.9](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.8...v5.1.0-alpha.9) (2026-06-16)
86
+
87
+
88
+ ### Features
89
+
90
+ * **subscription:** expose frontier vendor discount in types ([1e06f99](https://github.com/Sogni-AI/sogni-client/commit/1e06f99e54e39c2d09d65263c0ed6a5f52dbac18))
91
+
92
+ # [5.1.0-alpha.8](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.7...v5.1.0-alpha.8) (2026-06-16)
93
+
94
+
95
+ ### Features
96
+
97
+ * **chat:** carry subscription-limit fields on ChatJobError ([33c7ecd](https://github.com/Sogni-AI/sogni-client/commit/33c7ecdab22c571f6983fbb479bdbb5eb885a672))
98
+ * **chat:** forward 4081 limit fields at error call sites ([ef5b66a](https://github.com/Sogni-AI/sogni-client/commit/ef5b66a8b28dd52755f22cf76609258ecf2fe6dc))
99
+ * **projects:** surface 4081 limit fields on render errors ([13fa158](https://github.com/Sogni-AI/sogni-client/commit/13fa158f00c4e4415bb4d0f3c7eaf9979f1f7d40))
100
+ * **socket:** type 4081 limit fields on job error events ([0026438](https://github.com/Sogni-AI/sogni-client/commit/0026438ccbfb1cefe5be38861372d1430ade0eb2))
101
+ * **subscription:** add isSubscriptionLimitError helper ([139953b](https://github.com/Sogni-AI/sogni-client/commit/139953bc003aefc2f3ba09f8e4000982a071f7e8))
102
+ * **subscription:** recognize 4081 feature-gate denial code ([c513fe6](https://github.com/Sogni-AI/sogni-client/commit/c513fe67243c91e0ca8ccb5d301a3be20dcf1486))
103
+
104
+ # [5.1.0-alpha.7](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.6...v5.1.0-alpha.7) (2026-06-12)
105
+
106
+
107
+ ### Bug Fixes
108
+
109
+ * **account:** map real socket entitlement status domain without dropping fields ([c2e7499](https://github.com/Sogni-AI/sogni-client/commit/c2e7499c5d254e8ce61da257b44307bca97ea56c))
110
+
111
+
112
+ ### Features
113
+
114
+ * **account:** accept chat checkout redirect target ([3900336](https://github.com/Sogni-AI/sogni-client/commit/390033692aaa46eff521030d80ba712f15bd3302))
115
+ * **account:** guard subscription writes against stale transports ([c60af1f](https://github.com/Sogni-AI/sogni-client/commit/c60af1ff4e4a9a8af1a8e2393899026f176a3f53))
116
+ * **chat:** preserve job error codes via typed ChatJobError ([dd5ad1d](https://github.com/Sogni-AI/sogni-client/commit/dd5ad1d585c709382547bfa4cff2aa98d734414c))
117
+ * **chat:** serialize billingMode on all three chat transports ([787dd43](https://github.com/Sogni-AI/sogni-client/commit/787dd4391dee1735a6d3d3a7953f25ec6c722a4d))
118
+ * **types:** export subscription billing socket error-code constants ([2fd5af4](https://github.com/Sogni-AI/sogni-client/commit/2fd5af49ffa76d6f1a304c6a06577468f5865c2e))
119
+
120
+ # [5.1.0-alpha.6](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.5...v5.1.0-alpha.6) (2026-06-12)
121
+
122
+
123
+ ### Features
124
+
125
+ * sync socket subscription entitlement ([fa5d24d](https://github.com/Sogni-AI/sogni-client/commit/fa5d24d307992993ac312c3b1e8ab94277529aa4))
126
+
127
+ # [5.1.0-alpha.5](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.4...v5.1.0-alpha.5) (2026-06-11)
128
+
129
+
130
+ ### Features
131
+
132
+ * **subscription:** pending plan-change snapshot fields and grace-period doc fix ([596e4a0](https://github.com/Sogni-AI/sogni-client/commit/596e4a030dc1114e5fdd90d3dce3dd799c5f1ede))
133
+
134
+ # [5.1.0-alpha.4](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.3...v5.1.0-alpha.4) (2026-06-11)
135
+
136
+
137
+ ### Bug Fixes
138
+
139
+ * **projects:** forward billing mode metadata ([975fdb0](https://github.com/Sogni-AI/sogni-client/commit/975fdb09adcbd74c11fa6786edb6f1d2392583eb))
140
+
141
+ # [5.1.0-alpha.3](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.2...v5.1.0-alpha.3) (2026-06-10)
142
+
143
+
144
+ ### Features
145
+
146
+ * **subscription:** mirror term, google productId, and manual provider ([78b3114](https://github.com/Sogni-AI/sogni-client/commit/78b311457c71448578b8f561cc7865e7bcaf9f20))
147
+
1
148
  # [5.1.0-alpha.2](https://github.com/Sogni-AI/sogni-client/compare/v5.1.0-alpha.1...v5.1.0-alpha.2) (2026-06-10)
2
149
 
3
150
 
package/README.md CHANGED
@@ -189,7 +189,19 @@ if (sogni.account.currentAccount.isUnlimited) {
189
189
  }
190
190
  ```
191
191
 
192
- `currentAccount.isUnlimited` is `true` when the latest entitlement snapshot has `active: true` and `tier` is either `unlimited` or `unlimited_pro`. The server keeps `active` true for entitled states such as trials, grace periods, and cancel-at-period-end windows until access actually ends. Period dates are ISO timestamp strings.
192
+ `currentAccount.isUnlimited` is `true` when the latest entitlement snapshot has `active: true` and `tier` is either `unlimited` or `unlimited_pro`. The server keeps `active` true for entitled states until access actually ends: trials and cancel-at-period-end windows remain entitled, with `currentPeriodEnd` reflecting the paid-through date. Canceling during a free trial is the exception: it ends Unlimited access immediately by default, so the next snapshot reports `active: false`. A `grace_period` snapshot is never entitled and returns `active: false`: it means the provider (Apple billing grace / Google Play grace / Stripe retries) is retrying the renewal payment, and unlimited render access is paused while the retry is in progress — render submissions under the plan return a specific error from the platform explaining that the renewal payment is being retried and that unlimited access resumes once it succeeds. Renders can still be paid with Spark/SOGNI in the meantime, and unlimited access resumes automatically when the renewal succeeds. During grace the snapshot's effective period end indicates the payment-retry window, not access. Period dates are ISO timestamp strings.
193
+
194
+ A canceled-but-still-paid subscription carries `cancelAtPeriodEnd: true` and keeps access until `currentPeriodEnd`. When a downgrade or plan switch is scheduled for the next renewal, the snapshot may also carry `scheduledTier`, `scheduledTerm`, and `scheduledChangeAt` (ISO timestamp) — absent when no change is pending — so UIs can render "Your plan will change to X on date" messaging while the current tier keeps its benefits.
195
+
196
+ When a job is explicitly submitted with `billingMode: 'subscription'` and the subscription cannot cover it, the platform rejects the job with a subscription-specific error code, exported as `SUBSCRIPTION_ERROR_CODES` from the package root:
197
+
198
+ - `4078` (`NOT_ENTITLED`) — no active subscription entitlement covers the job.
199
+ - `4079` (`QUEUE_CAP`) — the subscription's concurrent job queue cap was reached.
200
+ - `4080` (`GRACE_RETRY`) — the subscription is in its billing-grace window: the renewal payment is being retried and unlimited access is paused until it succeeds. On `4080`, offer the user a "pay with Spark/SOGNI" fallback (token billing) instead of auto-retrying the subscription job in a loop — it will keep failing until the renewal succeeds.
201
+
202
+ `billingMode` (`'auto' | 'subscription' | 'tokens'`, exported as `BillingMode`) is accepted by project params, creative workflows (`sogni.workflows.start()`, `resume()`, and `reseed()`, where it serializes as `billing_mode`), and all three chat transports: `sogni.chat.completions.create()` (socket), `sogni.chat.hosted.create()` (REST `/v1/chat/completions`), and `sogni.chat.runs.create()` (durable runs, where it serializes as `billing_mode`).
203
+
204
+ Chat job failures preserve this error contract. Streamed and non-streaming chat completions, hosted REST chat, and durable chat runs fail with a `ChatJobError` (exported from the package root): `.message` stays the human-readable server message, while `code`/`errorCode` carry the wire code string (e.g. `'4080'`), `errorType` carries the server's tag (e.g. `'subscription_unavailable'`), and the `subscriptionErrorCode` getter maps the code back to the numeric `SUBSCRIPTION_ERROR_CODES` value when applicable — so apps can branch without string-matching.
193
205
 
194
206
  Unlimited fair-use accounting and enforcement are handled dynamically by the Sogni socket service. The SDK does not expose per-period usage counters or plan limit tables for clients to store or display as durable user-facing limits.
195
207
 
@@ -613,7 +625,7 @@ export interface ControlNetParams {
613
625
  }
614
626
  ```
615
627
 
616
- ## Video Generation with Wan 2.2 Models
628
+ ## Video Generation (WAN 2.2, LTX-2.3, Seedance 2.0 & Happy Horse 1.1)
617
629
 
618
630
  The Sogni SDK supports advanced video generation workflows powered by **Wan 2.2 14B FP8** models. These models are available on the `fast` network and support various video generation workflows.
619
631
 
@@ -634,7 +646,7 @@ WAN workflows have two model variants optimized for different use cases:
634
646
  - **Speed variant** (with `_lightx2v` suffix) - Faster inference (4-step), good quality
635
647
  - **Quality variant** (without `_lightx2v`) - Slower inference, best quality
636
648
 
637
- LTX-2.3 models use `distilled` and `dev` variants for fast/high-quality generation with native audio. Seedance 2.0 models use the external API path and are available through two canonical multimodal model IDs: `seedance-2-0` and `seedance-2-0-fast`. Both accept optional image, video, and audio references, run at fixed 24fps, and require Spark billing; the Fast model caps output at 720p.
649
+ LTX-2.3 models use `distilled` and `dev` variants for fast/high-quality generation with native audio. Seedance 2.0 models use the external API path and are available through three canonical multimodal model IDs: `seedance-2-0`, `seedance-2-0-mini`, and `seedance-2-0-fast`. All accept optional image, video, and audio references, run at fixed 24fps, and require Spark billing; the full model supports up to 4K, while Mini and Fast cap output at 720p. Happy Horse 1.1 is an external-API video model with text-to-video, image-to-video, and reference-to-video modes (`happyhorse-1.1-t2v` / `-i2v` / `-r2v`); it accepts image-only references (no video or audio reference assets), and is Spark-only.
638
650
 
639
651
  Example model IDs:
640
652
 
@@ -649,8 +661,12 @@ Example model IDs:
649
661
  - `ltx23-22b-fp8_t2v_distilled` (LTX-2.3 Text-to-Video, fast)
650
662
  - `ltx23-22b-fp8_i2v_distilled` (LTX-2.3 Image-to-Video, fast)
651
663
  - `ltx23-22b-fp8_v2v_distilled` (LTX-2.3 Video-to-Video ControlNet, fast)
652
- - `seedance-2-0` (Seedance 2.0 multimodal video, external API)
664
+ - `seedance-2-0` (Seedance 2.0 multimodal video, external API, 4K capable)
665
+ - `seedance-2-0-mini` (Seedance 2.0 Mini multimodal video, external API, 720p cap)
653
666
  - `seedance-2-0-fast` (Seedance 2.0 Fast multimodal video, external API, 720p cap)
667
+ - `happyhorse-1.1-t2v` (Happy Horse 1.1 Text-to-Video, external API, image-only references)
668
+ - `happyhorse-1.1-i2v` (Happy Horse 1.1 Image-to-Video, external API, one first-frame image)
669
+ - `happyhorse-1.1-r2v` (Happy Horse 1.1 Reference-to-Video, external API, 1-9 reference images)
654
670
 
655
671
  ### Video Parameters
656
672
 
@@ -666,7 +682,7 @@ When creating video projects, you can specify:
666
682
  - `referenceImage` - Reference image for workflows that require it (i2v, s2v, animate-move, animate-replace)
667
683
  - `referenceVideo` - Reference video for animate and v2v workflows
668
684
  - `referenceAudio` - Reference audio for sound-to-video workflow
669
- - `referenceImageUrls` - Seedance-only loose image context URLs; combined with `referenceImage`/`referenceImageEnd`, max 9 image assets
685
+ - `referenceImageUrls` - Loose image context URLs for Seedance and Happy Horse (Happy Horse r2v takes 1-9 reference images here); combined with `referenceImage`/`referenceImageEnd`, max 9 image assets
670
686
  - `referenceVideoUrls` - Seedance-only video context URLs; combined with `referenceVideo`, max 3 video assets
671
687
  - `referenceAudioUrls` - Seedance-only audio context URLs; combined with `referenceAudio`/`referenceAudioIdentity`, max 3 audio assets
672
688
  - `hasVideoInput` - Estimate-only flag for `estimateVideoCost`; set this when estimating a canonical Seedance video-input job without passing `referenceVideo`/`referenceVideoUrls`
@@ -702,7 +718,7 @@ const project = await sogni.projects.create({
702
718
  duration: 5,
703
719
  fps: 24,
704
720
  width: 1920,
705
- height: 1088,
721
+ height: 1080,
706
722
  tokenType: 'spark'
707
723
  });
708
724
 
@@ -721,7 +737,7 @@ const project = await sogni.projects.create({
721
737
  duration: 8,
722
738
  fps: 24,
723
739
  width: 1920,
724
- height: 1088,
740
+ height: 1080,
725
741
  referenceImageUrls: [
726
742
  'https://cdn.example.com/product-front.png',
727
743
  'https://cdn.example.com/product-detail.png'
@@ -890,9 +906,24 @@ Combine LLM intelligence with Sogni's media generation capabilities. The SDK exp
890
906
 
891
907
  Pass `SogniTools.all` (or individual definitions like `generateImageTool`, `animatePhotoTool`, `composeScriptTool`) to an LLM via the `tools` parameter, then route tool calls through `sogni.chat.hosted.create()` / `sogni.chat.runs.create()` for server-side execution. Generated artifacts are threaded through a per-request media context so later rounds can reference earlier outputs by index (`sourceImageIndex`, `videoIndices`, `audioIndex`, etc.).
892
908
 
909
+ When your app already knows the exact synchronous composition/planning tool and JSON arguments, skip the dispatcher round and call `sogni.chat.hosted.executeTool()` directly. Direct execution supports `enhance_prompt`, `compose_script`, `compose_lyrics`, `compose_instrumental`, `compose_workflow`, and `compose_workflow_template`; long-running media generation still belongs on hosted chat/runs or `sogni.workflows`.
910
+
911
+ ```javascript
912
+ const direct = await sogni.chat.hosted.executeTool({
913
+ tool: 'enhance_prompt',
914
+ arguments: {
915
+ prompt: 'A cinematic portrait of a glass robot',
916
+ destination_tool: 'generate_image'
917
+ },
918
+ tokenType: 'spark'
919
+ });
920
+
921
+ console.log(direct.data.message);
922
+ ```
923
+
893
924
  For direct `/v1/chat/completions` hosted-tool execution, media-bearing tool arguments use inline `data:` URIs. For user-uploaded image/audio/video inputs, use the SDK video project examples or the `sogni.workflows` wrapper for `/v1/creative-agent/workflows`; these can consume HTTPS artifact URLs produced by Sogni's upload endpoints. Durable workflows validate explicit steps before the workflow starts and can bind SDK request-level `mediaReferences` into tool arguments with `sourceStepId: "$input_media"`.
894
925
 
895
- The `workflow_text_chat_sogni_tools.mjs` example demonstrates the core text-to-image, text-to-video, and text-to-music composition flows. Dedicated workflow examples like `workflow_image_edit.mjs`, `workflow_sound_to_video.mjs`, and `workflow_video_to_video.mjs` cover the asset-backed workflows directly.
926
+ The `workflow_text_chat_sogni_tools.mjs` example demonstrates the core text-to-image, text-to-video, and text-to-music composition flows. `workflow_direct_creative_tool.mjs` demonstrates direct one-call execution for known synchronous tools. Dedicated workflow examples like `workflow_image_edit.mjs`, `workflow_sound_to_video.mjs`, and `workflow_video_to_video.mjs` cover the asset-backed workflows directly.
896
927
 
897
928
  ### Hosted Tool Surfaces — `sogni_tools` parameter
898
929
 
@@ -938,6 +969,8 @@ const result = await sogni.chat.hosted.create({
938
969
 
939
970
  See `examples/workflow_creative_agent_tools.mjs` for a runnable REST API-key example that can toggle tool surface and server-side execution.
940
971
 
972
+ See `examples/workflow_direct_creative_tool.mjs` when you already know the hosted synchronous tool to run and want to call it without asking the LLM to select a tool first.
973
+
941
974
  For focused partner Seedance video tests, `examples/workflow_partner_seedance_video.mjs` starts with a guided workflow picker when run with no arguments. The guided path covers T2V, I2V, IA2V, V2V, the full and fast Seedance tiers where available, hosted workflow execution, native audio, keyframe interpolation, multimodal context, and cost estimation. The command-line path still supports direct scripted calls:
942
975
 
943
976
  ```bash
@@ -1058,11 +1091,20 @@ The workflow examples showcase a few powerful open-source frontier models suppor
1058
1091
  | ------------------------------------ | ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
1059
1092
  | `z_image_turbo_bf16` | **Z-Image Turbo** - Ultra-fast 8-step generation | Quick text-to-image prototyping and iteration |
1060
1093
  | `z_image_bf16` | **Z-Image** - High quality 20-step generation | Detailed, high quality image output |
1094
+ | `krea2_turbo_fp8_scaled` | **Krea 2 Turbo** - Fast 8-step, strong in-image text | Text-heavy images and fast iteration, up to 2K |
1095
+ | `krea2_identity_edit_v1_2` | **Krea 2 Identity Edit LoRA v1.2** - Identity editing | Preserve a subject across edits with 1-2 reference images |
1096
+ | `chroma1-hd_fp8_scaled` | **Chroma1-HD** - Final high-res Chroma (uncensored) | Highest-fidelity Chroma output, LoRA-capable |
1097
+ | `flux2_dev_fp8` | **Flux.2 \[dev\]** - Pro quality, context images | Professional images and reference-guided editing (up to 6 context images) |
1061
1098
  | `qwen_image_edit_2511_fp8_lightning` | **Qwen Image Edit Lightning** - Fast 4-step editing | Rapid reference-based image generation |
1062
1099
  | `qwen_image_edit_2511_fp8` | **Qwen Image Edit** - High quality 20-step editing | Professional image editing with context awareness |
1063
1100
  | `wan_v2.2-14b-fp8_t2v_lightx2v` | **Wan 2.2 T2V** - Text-to-video | Generate videos from text prompts |
1064
- | `seedance-2-0` | **Seedance 2.0** - External API multimodal video | Full Seedance 2.0 24fps video generation with optional image, video, and audio context |
1065
- | `seedance-2-0-fast` | **Seedance 2.0 Fast** - 720p external API video | Faster 24fps video generation where fast tiers are enabled |
1101
+ | `seedance-2-0` | **Seedance 2.0** - 4K external API multimodal video | Full Seedance 2.0 24fps video generation with optional image, video, and audio context |
1102
+ | `seedance-2-0-mini` | **Seedance 2.0 Mini** - 720p external API video | Fastest, lower-cost 24fps Seedance video generation |
1103
+ | `seedance-2-0-fast` | **Seedance 2.0 Fast** - 720p external API video | Legacy faster 24fps video generation where fast tiers are enabled |
1104
+ | `dark_beast_z_image_turbo_v9_bf16` | **Dark Beast Z-Image Turbo v9** - Community (uncensored) | Uncensored, fast Z-Image fine-tune (2K output needs a 24GB+ VRAM worker) |
1105
+ | `dark_beast_krea2_fp8` | **Dark Beast KREA 2** - Community (uncensored) | Uncensored Krea 2 fine-tune (2K output needs a 24GB+ VRAM worker) |
1106
+ | `dark_beast_krea2_identity_edit_v1_2` | **Dark Beast Krea 2 Identity Edit** - Community | Uncensored identity-preserving Krea 2 edit LoRA with 1-2 reference images |
1107
+ | `one_obsession_v22_fp16` | **One Obsession v22** - Community (Illustrious/anime) | Anime/illustration checkpoint, LoRA-capable |
1066
1108
  | `qwen3.6-35b-a3b-gguf-iq4xs` | **Qwen3.6 35B VLM** - LLM chat, tool calling & vision | Latest model with 262,144 native context length, reasoning, tool calling, and multimodal image understanding |
1067
1109
 
1068
1110
  All workflow examples include:
@@ -23,8 +23,9 @@ export interface AccountData {
23
23
  email?: string;
24
24
  /**
25
25
  * The most recently fetched subscription entitlement snapshot.
26
- * `undefined` until {@link AccountApi.getSubscriptionStatus} or
27
- * {@link AccountApi.refreshSubscription} has been called.
26
+ * `undefined` until the account receives a socket entitlement snapshot or
27
+ * {@link AccountApi.getSubscriptionStatus} / {@link AccountApi.refreshSubscription}
28
+ * has been called.
28
29
  *
29
30
  * Subscribe to the `'updated'` event (inherited from `DataEntity`) to react
30
31
  * to changes; the `changedKeys` array will include `'subscription'` when
@@ -48,8 +49,9 @@ declare class CurrentAccount extends DataEntity<AccountData> {
48
49
  get email(): string | undefined;
49
50
  /**
50
51
  * The most recently cached subscription entitlement snapshot.
51
- * `undefined` until {@link AccountApi.getSubscriptionStatus} or
52
- * {@link AccountApi.refreshSubscription} has been called.
52
+ * `undefined` until the account receives a socket entitlement snapshot or
53
+ * {@link AccountApi.getSubscriptionStatus} / {@link AccountApi.refreshSubscription}
54
+ * has been called.
53
55
  */
54
56
  get subscription(): SubscriptionEntitlementSnapshot | undefined;
55
57
  /**
@@ -59,8 +61,8 @@ declare class CurrentAccount extends DataEntity<AccountData> {
59
61
  *
60
62
  * Returns `false` when no entitlement snapshot has been fetched yet, when
61
63
  * the server reports no active entitlement, or when the tier is not an
62
- * Unlimited tier. Call {@link AccountApi.refreshSubscription} to populate the
63
- * snapshot first.
64
+ * Unlimited tier. Call {@link AccountApi.refreshSubscription} to force a REST
65
+ * refresh when no socket entitlement snapshot has been received yet.
64
66
  */
65
67
  get isUnlimited(): boolean;
66
68
  }
@@ -62,8 +62,9 @@ class CurrentAccount extends DataEntity_js_1.default {
62
62
  }
63
63
  /**
64
64
  * The most recently cached subscription entitlement snapshot.
65
- * `undefined` until {@link AccountApi.getSubscriptionStatus} or
66
- * {@link AccountApi.refreshSubscription} has been called.
65
+ * `undefined` until the account receives a socket entitlement snapshot or
66
+ * {@link AccountApi.getSubscriptionStatus} / {@link AccountApi.refreshSubscription}
67
+ * has been called.
67
68
  */
68
69
  get subscription() {
69
70
  return this.data.subscription;
@@ -75,8 +76,8 @@ class CurrentAccount extends DataEntity_js_1.default {
75
76
  *
76
77
  * Returns `false` when no entitlement snapshot has been fetched yet, when
77
78
  * the server reports no active entitlement, or when the tier is not an
78
- * Unlimited tier. Call {@link AccountApi.refreshSubscription} to populate the
79
- * snapshot first.
79
+ * Unlimited tier. Call {@link AccountApi.refreshSubscription} to force a REST
80
+ * refresh when no socket entitlement snapshot has been received yet.
80
81
  */
81
82
  get isUnlimited() {
82
83
  const sub = this.data.subscription;
@@ -1 +1 @@
1
- {"version":3,"file":"CurrentAccount.js","sourceRoot":"","sources":["../../src/Account/CurrentAccount.ts"],"names":[],"mappings":";;;;;AAAA,yEAA8C;AAmC9C,SAAS,WAAW;IAClB,OAAO;QACL,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,GAAG;aACb;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,GAAG;gBACZ,aAAa,EAAE,GAAG;aACnB;SACF;QACD,aAAa,EAAE,SAAS;QACxB,QAAQ,EAAE,SAAS;QACnB,YAAY,EAAE,SAAS;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,uBAAuB;IAClD,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IAChC,CAAC;IAED;;;;;;;;;OASG;IACH,IAAI,WAAW;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QACnC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QACtC,OAAO,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,CAAC;IAClE,CAAC;CACF;AAED,kBAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"CurrentAccount.js","sourceRoot":"","sources":["../../src/Account/CurrentAccount.ts"],"names":[],"mappings":";;;;;AAAA,yEAA8C;AAoC9C,SAAS,WAAW;IAClB,OAAO;QACL,aAAa,EAAE,cAAc;QAC7B,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP,KAAK,EAAE;gBACL,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,GAAG;aACb;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,GAAG;gBACX,KAAK,EAAE,GAAG;gBACV,GAAG,EAAE,GAAG;gBACR,OAAO,EAAE,GAAG;gBACZ,aAAa,EAAE,GAAG;aACnB;SACF;QACD,aAAa,EAAE,SAAS;QACxB,QAAQ,EAAE,SAAS;QACnB,YAAY,EAAE,SAAS;KACxB,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,cAAe,SAAQ,uBAAuB;IAClD,YAAY,IAAkB;QAC5B,KAAK,CAAC,IAAI,IAAI,WAAW,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACnC,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;IAC3B,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC;IACjC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;IACzB,CAAC;IAED;;;;;OAKG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;IAChC,CAAC;IAED;;;;;;;;;OASG;IACH,IAAI,WAAW;QACb,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;QACnC,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QACtC,OAAO,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,CAAC;IAClE,CAAC;CACF;AAED,kBAAe,cAAc,CAAC"}
@@ -18,12 +18,44 @@ import { SupernetType } from '../ApiClient/WebSocketClient/types.js';
18
18
  */
19
19
  declare class AccountApi extends ApiGroup {
20
20
  readonly currentAccount: CurrentAccount;
21
+ /**
22
+ * Highest entitlement `version` applied to `currentAccount.subscription`.
23
+ * Socket payloads carry a monotonically increasing version; writes that
24
+ * carry an older version than the one already applied are discarded instead
25
+ * of overwriting fresher data.
26
+ */
27
+ private lastAppliedSubscriptionVersion;
28
+ /**
29
+ * Logical clock counting applied socket entitlement writes. A REST refresh
30
+ * captures this counter before its request goes on the wire; if it advanced
31
+ * by the time the response arrives, a fresher socket push landed mid-flight
32
+ * and the REST snapshot is discarded as stale.
33
+ */
34
+ private appliedSubscriptionSocketWrites;
21
35
  constructor(config: ApiConfig);
22
36
  private handleBalanceUpdate;
23
37
  private handleChangeNetwork;
24
38
  private handleServerConnected;
25
39
  private handleServerConnecting;
26
40
  private handleServerDisconnected;
41
+ private mapSocketSubscriptionEntitlement;
42
+ /**
43
+ * Single chokepoint through which every subscription entitlement writer
44
+ * (REST refresh, socket entitlement push, socket authenticated seeding)
45
+ * must route.
46
+ *
47
+ * Guards against last-writer-wins races between the two transports: writes
48
+ * carrying an older `version` than the one already applied are discarded,
49
+ * and an unversioned REST snapshot whose request started before a socket
50
+ * push was applied is discarded as stale. Snapshots deep-equal to the
51
+ * current one are accepted without re-applying, so reconnect re-seeds and
52
+ * tab replays do not emit redundant 'updated' events.
53
+ *
54
+ * @returns `true` when the snapshot was accepted (even if identical to the
55
+ * current one), `false` when it was discarded as stale.
56
+ */
57
+ private applySubscriptionSnapshot;
58
+ private handleSubscriptionEntitlementUpdated;
27
59
  private handleSocketAuthenticated;
28
60
  private handleAuthUpdated;
29
61
  /**