@sogni-ai/sogni-intelligence-client 3.0.0-alpha.0 → 3.0.0-alpha.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.
Files changed (201) hide show
  1. package/README.md +163 -729
  2. package/chatRun/index.d.ts +1 -0
  3. package/chatRun/index.js +2 -0
  4. package/context/index.d.ts +1 -0
  5. package/context/index.js +2 -0
  6. package/dist/chatRun/costApproval.d.ts +10 -0
  7. package/dist/chatRun/costApproval.d.ts.map +1 -0
  8. package/dist/chatRun/costApproval.js +70 -0
  9. package/dist/chatRun/costApproval.js.map +1 -0
  10. package/dist/chatRun/index.d.ts +207 -0
  11. package/dist/chatRun/index.d.ts.map +1 -0
  12. package/dist/chatRun/index.js +350 -0
  13. package/dist/chatRun/index.js.map +1 -0
  14. package/dist/client/SogniClientWrapper.d.ts +2 -2
  15. package/dist/client/SogniClientWrapper.d.ts.map +1 -1
  16. package/dist/client/SogniClientWrapper.js +55 -55
  17. package/dist/client/SogniClientWrapper.js.map +1 -1
  18. package/dist/context/index.d.ts +56 -0
  19. package/dist/context/index.d.ts.map +1 -0
  20. package/dist/context/index.js +460 -0
  21. package/dist/context/index.js.map +1 -0
  22. package/dist/contracts/storyboard.d.ts +1 -0
  23. package/dist/contracts/storyboard.d.ts.map +1 -1
  24. package/dist/contracts/storyboard.js.map +1 -1
  25. package/dist/index.d.ts +6 -6
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +34 -34
  28. package/dist/index.js.map +1 -1
  29. package/dist/openai-tools/_manifests.generated.d.ts +4 -0
  30. package/dist/openai-tools/_manifests.generated.d.ts.map +1 -0
  31. package/dist/openai-tools/_manifests.generated.js +1792 -0
  32. package/dist/openai-tools/_manifests.generated.js.map +1 -0
  33. package/dist/openai-tools/app-tools.json +297 -0
  34. package/dist/openai-tools/composition-tools.json +228 -0
  35. package/dist/openai-tools/generation-tools.json +1263 -0
  36. package/dist/openai-tools/index.d.ts +17 -0
  37. package/dist/openai-tools/index.d.ts.map +1 -0
  38. package/dist/openai-tools/index.js +32 -0
  39. package/dist/openai-tools/index.js.map +1 -0
  40. package/dist/public-skill-runtime/index.d.ts +1 -0
  41. package/dist/public-skill-runtime/index.d.ts.map +1 -1
  42. package/dist/public-skill-runtime/index.js +85 -8
  43. package/dist/public-skill-runtime/index.js.map +1 -1
  44. package/dist/schemas/errors/error.schema.json +21 -0
  45. package/dist/schemas/errors/repair-control.schema.json +40 -0
  46. package/dist/schemas/events/artifact-reference.schema.json +22 -0
  47. package/dist/schemas/events/progress-event.schema.json +28 -0
  48. package/dist/schemas/events/workflow-event.schema.json +22 -0
  49. package/dist/schemas/storyboards/storyboard-planning-contract.schema.json +108 -0
  50. package/dist/schemas/tools/add_subtitles.schema.json +77 -0
  51. package/dist/schemas/tools/animate_photo.schema.json +104 -0
  52. package/dist/schemas/tools/apply_style.schema.json +37 -0
  53. package/dist/schemas/tools/change_angle.schema.json +30 -0
  54. package/dist/schemas/tools/compose_instrumental.schema.json +24 -0
  55. package/dist/schemas/tools/compose_lyrics.schema.json +28 -0
  56. package/dist/schemas/tools/compose_script.schema.json +68 -0
  57. package/dist/schemas/tools/compose_workflow.schema.json +67 -0
  58. package/dist/schemas/tools/compose_workflow_template.schema.json +156 -0
  59. package/dist/schemas/tools/dance_montage.schema.json +47 -0
  60. package/dist/schemas/tools/edit_image.schema.json +74 -0
  61. package/dist/schemas/tools/enhance_prompt.schema.json +76 -0
  62. package/dist/schemas/tools/extend_video.schema.json +42 -0
  63. package/dist/schemas/tools/generate_image.schema.json +104 -0
  64. package/dist/schemas/tools/generate_music.schema.json +62 -0
  65. package/dist/schemas/tools/generate_video.schema.json +97 -0
  66. package/dist/schemas/tools/orbit_video.schema.json +70 -0
  67. package/dist/schemas/tools/overlay_video.schema.json +126 -0
  68. package/dist/schemas/tools/refine_result.schema.json +43 -0
  69. package/dist/schemas/tools/replace_video_segment.schema.json +60 -0
  70. package/dist/schemas/tools/restore_photo.schema.json +47 -0
  71. package/dist/schemas/tools/sound_to_video.schema.json +70 -0
  72. package/dist/schemas/tools/stitch_video.schema.json +52 -0
  73. package/dist/schemas/tools/video_to_video.schema.json +77 -0
  74. package/dist/schemas/workflows/durable-workflow-run.schema.json +165 -0
  75. package/dist/schemas/workflows/durable-workflow-step.schema.json +141 -0
  76. package/dist/skill-runtime-source/crossSurfaceParity.d.ts +23 -0
  77. package/dist/skill-runtime-source/crossSurfaceParity.d.ts.map +1 -0
  78. package/dist/skill-runtime-source/crossSurfaceParity.js +472 -0
  79. package/dist/skill-runtime-source/crossSurfaceParity.js.map +1 -0
  80. package/dist/skill-runtime-source/index.d.ts +4 -0
  81. package/dist/skill-runtime-source/index.d.ts.map +1 -0
  82. package/dist/skill-runtime-source/index.js +20 -0
  83. package/dist/skill-runtime-source/index.js.map +1 -0
  84. package/dist/skill-runtime-source/seedanceAudioWindow.d.ts +8 -0
  85. package/dist/skill-runtime-source/seedanceAudioWindow.d.ts.map +1 -0
  86. package/dist/skill-runtime-source/seedanceAudioWindow.js +52 -0
  87. package/dist/skill-runtime-source/seedanceAudioWindow.js.map +1 -0
  88. package/dist/skill-runtime-source/workflowStatus.d.ts +17 -0
  89. package/dist/skill-runtime-source/workflowStatus.d.ts.map +1 -0
  90. package/dist/skill-runtime-source/workflowStatus.js +353 -0
  91. package/dist/skill-runtime-source/workflowStatus.js.map +1 -0
  92. package/dist/utils/errors.d.ts +1 -1
  93. package/dist/utils/errors.d.ts.map +1 -1
  94. package/dist/utils/helpers.d.ts +1 -1
  95. package/dist/utils/helpers.d.ts.map +1 -1
  96. package/dist/utils/helpers.js +55 -55
  97. package/dist/utils/helpers.js.map +1 -1
  98. package/dist/workflows/bindings.d.ts.map +1 -1
  99. package/dist/workflows/bindings.js +32 -2
  100. package/dist/workflows/bindings.js.map +1 -1
  101. package/dist/workflows/index.d.ts +3 -0
  102. package/dist/workflows/index.d.ts.map +1 -1
  103. package/dist/workflows/index.js +24 -1
  104. package/dist/workflows/index.js.map +1 -1
  105. package/dist/workflows/primitives/index.d.ts +3 -0
  106. package/dist/workflows/primitives/index.d.ts.map +1 -0
  107. package/dist/workflows/primitives/index.js +19 -0
  108. package/dist/workflows/primitives/index.js.map +1 -0
  109. package/dist/workflows/primitives/retryUntilCondition.d.ts +39 -0
  110. package/dist/workflows/primitives/retryUntilCondition.d.ts.map +1 -0
  111. package/dist/workflows/primitives/retryUntilCondition.js +102 -0
  112. package/dist/workflows/primitives/retryUntilCondition.js.map +1 -0
  113. package/dist/workflows/primitives/validateWithRubric.d.ts +28 -0
  114. package/dist/workflows/primitives/validateWithRubric.d.ts.map +1 -0
  115. package/dist/workflows/primitives/validateWithRubric.js +148 -0
  116. package/dist/workflows/primitives/validateWithRubric.js.map +1 -0
  117. package/dist-esm/chatRun/costApproval.js +64 -0
  118. package/dist-esm/chatRun/costApproval.js.map +1 -0
  119. package/dist-esm/chatRun/index.js +327 -0
  120. package/dist-esm/chatRun/index.js.map +1 -0
  121. package/dist-esm/client/SogniClientWrapper.js +3 -3
  122. package/dist-esm/client/SogniClientWrapper.js.map +1 -1
  123. package/dist-esm/context/index.js +453 -0
  124. package/dist-esm/context/index.js.map +1 -0
  125. package/dist-esm/contracts/storyboard.js.map +1 -1
  126. package/dist-esm/index.js +5 -5
  127. package/dist-esm/index.js.map +1 -1
  128. package/dist-esm/openai-tools/_manifests.generated.js +1789 -0
  129. package/dist-esm/openai-tools/_manifests.generated.js.map +1 -0
  130. package/dist-esm/openai-tools/app-tools.json +297 -0
  131. package/dist-esm/openai-tools/composition-tools.json +228 -0
  132. package/dist-esm/openai-tools/generation-tools.json +1263 -0
  133. package/dist-esm/openai-tools/index.js +27 -0
  134. package/dist-esm/openai-tools/index.js.map +1 -0
  135. package/dist-esm/public-skill-runtime/index.js +85 -8
  136. package/dist-esm/public-skill-runtime/index.js.map +1 -1
  137. package/dist-esm/schemas/errors/error.schema.json +21 -0
  138. package/dist-esm/schemas/errors/repair-control.schema.json +40 -0
  139. package/dist-esm/schemas/events/artifact-reference.schema.json +22 -0
  140. package/dist-esm/schemas/events/progress-event.schema.json +28 -0
  141. package/dist-esm/schemas/events/workflow-event.schema.json +22 -0
  142. package/dist-esm/schemas/storyboards/storyboard-planning-contract.schema.json +108 -0
  143. package/dist-esm/schemas/tools/add_subtitles.schema.json +77 -0
  144. package/dist-esm/schemas/tools/animate_photo.schema.json +104 -0
  145. package/dist-esm/schemas/tools/apply_style.schema.json +37 -0
  146. package/dist-esm/schemas/tools/change_angle.schema.json +30 -0
  147. package/dist-esm/schemas/tools/compose_instrumental.schema.json +24 -0
  148. package/dist-esm/schemas/tools/compose_lyrics.schema.json +28 -0
  149. package/dist-esm/schemas/tools/compose_script.schema.json +68 -0
  150. package/dist-esm/schemas/tools/compose_workflow.schema.json +67 -0
  151. package/dist-esm/schemas/tools/compose_workflow_template.schema.json +156 -0
  152. package/dist-esm/schemas/tools/dance_montage.schema.json +47 -0
  153. package/dist-esm/schemas/tools/edit_image.schema.json +74 -0
  154. package/dist-esm/schemas/tools/enhance_prompt.schema.json +76 -0
  155. package/dist-esm/schemas/tools/extend_video.schema.json +42 -0
  156. package/dist-esm/schemas/tools/generate_image.schema.json +104 -0
  157. package/dist-esm/schemas/tools/generate_music.schema.json +62 -0
  158. package/dist-esm/schemas/tools/generate_video.schema.json +97 -0
  159. package/dist-esm/schemas/tools/orbit_video.schema.json +70 -0
  160. package/dist-esm/schemas/tools/overlay_video.schema.json +126 -0
  161. package/dist-esm/schemas/tools/refine_result.schema.json +43 -0
  162. package/dist-esm/schemas/tools/replace_video_segment.schema.json +60 -0
  163. package/dist-esm/schemas/tools/restore_photo.schema.json +47 -0
  164. package/dist-esm/schemas/tools/sound_to_video.schema.json +70 -0
  165. package/dist-esm/schemas/tools/stitch_video.schema.json +52 -0
  166. package/dist-esm/schemas/tools/video_to_video.schema.json +77 -0
  167. package/dist-esm/schemas/workflows/durable-workflow-run.schema.json +165 -0
  168. package/dist-esm/schemas/workflows/durable-workflow-step.schema.json +141 -0
  169. package/dist-esm/skill-runtime-source/crossSurfaceParity.js +469 -0
  170. package/dist-esm/skill-runtime-source/crossSurfaceParity.js.map +1 -0
  171. package/dist-esm/skill-runtime-source/index.js +4 -0
  172. package/dist-esm/skill-runtime-source/index.js.map +1 -0
  173. package/dist-esm/skill-runtime-source/seedanceAudioWindow.js +47 -0
  174. package/dist-esm/skill-runtime-source/seedanceAudioWindow.js.map +1 -0
  175. package/dist-esm/skill-runtime-source/workflowStatus.js +348 -0
  176. package/dist-esm/skill-runtime-source/workflowStatus.js.map +1 -0
  177. package/dist-esm/utils/helpers.js +1 -1
  178. package/dist-esm/utils/helpers.js.map +1 -1
  179. package/dist-esm/workflows/bindings.js +32 -2
  180. package/dist-esm/workflows/bindings.js.map +1 -1
  181. package/dist-esm/workflows/index.js +1 -0
  182. package/dist-esm/workflows/index.js.map +1 -1
  183. package/dist-esm/workflows/primitives/index.js +3 -0
  184. package/dist-esm/workflows/primitives/index.js.map +1 -0
  185. package/dist-esm/workflows/primitives/retryUntilCondition.js +95 -0
  186. package/dist-esm/workflows/primitives/retryUntilCondition.js.map +1 -0
  187. package/dist-esm/workflows/primitives/validateWithRubric.js +141 -0
  188. package/dist-esm/workflows/primitives/validateWithRubric.js.map +1 -0
  189. package/package.json +51 -3
  190. package/src/skill-runtime-source/crossSurfaceParity.ts +525 -0
  191. package/src/skill-runtime-source/index.ts +10 -0
  192. package/src/skill-runtime-source/seedanceAudioWindow.ts +61 -0
  193. package/src/skill-runtime-source/workflowStatus.ts +375 -0
  194. package/dist/contracts/index.mjs +0 -102
  195. package/dist/media/index.mjs +0 -116
  196. package/dist/public-skill-runtime/index.mjs +0 -141
  197. package/dist/replay/index.mjs +0 -12
  198. package/dist/runtime/index.mjs +0 -21
  199. package/dist/skills/asset_reference_management/index.mjs +0 -18
  200. package/dist/tools/index.mjs +0 -86
  201. package/dist/workflows/index.mjs +0 -22
package/README.md CHANGED
@@ -1,823 +1,257 @@
1
- # Sogni Client Wrapper
1
+ # @sogni-ai/sogni-intelligence-client
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/@sogni-ai/sogni-intelligence-client.svg)](https://www.npmjs.com/package/@sogni-ai/sogni-intelligence-client) [![License](https://img.shields.io/npm/l/@sogni-ai/sogni-intelligence-client.svg)](https://www.npmjs.com/package/@sogni-ai/sogni-intelligence-client)
4
4
 
5
- An enhanced Node.js wrapper for the [`@sogni-ai/sogni-client`](https://sdk-docs.sogni.ai/) library, designed for robustness, ease of use, and seamless integration with platforms like [n8n](https://n8n.io/).
5
+ The public, mid‑tier Node.js client for the [Sogni Supernet](https://sogni.ai/) — Sogni's OpenAI‑compatible LLM and agent API for image, video, music, and chat generation. Bundles a hardened wrapper over the [`@sogni-ai/sogni-client`](https://sdk-docs.sogni.ai/) SDK with the public‑safe subset of Sogni's creative‑agent platform: hosted tool definitions, the contract registry, asset manifests, `RunRecord` types with redaction, skill‑runtime helpers, and JSON Schema artifacts for cross‑language codegen.
6
6
 
7
- This library simplifies interaction with the Sogni AI Supernet by providing a promise-based API, automatic connection management, enhanced error handling, and a more developer-friendly interface.
7
+ For most agent builders this is the recommended starting point. Designed for third‑party integrations, downstream SDKs, and orchestration frameworks (n8n, LangChain, Anthropic skills, custom runtimes). Drives the same contracts and tool surface that the hosted `POST https://api.sogni.ai/v1/chat/completions`, `/v1/chat/runs`, and `/v1/creative-agent/workflows` endpoints use, so a client‑side agent loop stays shape‑locked with the server.
8
8
 
9
- ## Features
9
+ ## Which package should I install?
10
10
 
11
- - **Promise-Based API**: Modern `async/await` support for all core operations.
12
- - **Connection Management**: Automatic connection and reconnection handling.
13
- - **Video Rendering Support**: Generate videos using WAN and LTX-2 models (t2v, i2v, s2v, ia2v, a2v, v2v, animate workflows).
14
- - **Audio Generation Support**: Generate music/audio tracks with audio models and estimate audio costs.
15
- - **Image Editing Support**: Edit images using Qwen models with context images for multi-reference editing.
16
- - **LLM Chat + Tool Calling Support**: Use chat completions through Sogni's LLM worker network, including streaming and function/tool calling.
17
- - **Vision Chat + Thinking Controls**: Send OpenAI-style multimodal `image_url` messages and toggle reasoning with `think`.
18
- - **Chat Tool Execution Helpers**: Execute Sogni platform tool calls manually from the wrapper, including streaming follow-up loops.
19
- - **Flexible Authentication**: Token, cookies, or API key authentication.
20
- - **Wallet + Tracking Utilities**: Query Base/Etherlink wallet balances and inspect SDK-tracked projects/current account state.
21
- - **Simplified Configuration**: Sensible defaults and clear configuration options.
22
- - **Enhanced Error Handling**: Custom error classes for better error diagnosis.
23
- - **Type-Safe**: Written entirely in TypeScript with full type definitions.
24
- - **n8n-Ready**: Built with n8n integration in mind, managing connection lifecycles effectively.
25
- - **Utility Helpers**: Includes helpers for validation, retries, and formatting.
11
+ | You're building… | Install |
12
+ |---|---|
13
+ | Custom AI agent that calls Sogni tools, validates LLM tool arguments, manages asset references | **`@sogni-ai/sogni-intelligence-client`** (recommended) |
14
+ | Thin wrapper that only generates an image/video/audio from a single direct call | [`@sogni-ai/sogni-client`](https://www.npmjs.com/package/@sogni-ai/sogni-client) (raw SDK) |
15
+ | n8n workflow node | **`@sogni-ai/sogni-intelligence-client`** (n8n compat helpers preserved) |
16
+ | Anthropic‑style Claude Skill, OpenClaw plugin, Hermes / Manus agent | [`@sogni-ai/sogni-creative-agent-skill`](https://github.com/Sogni-AI/sogni-creative-agent-skill) (consumes intelligence‑client under the hood) |
26
17
 
27
18
  ## Installation
28
19
 
29
20
  ```bash
30
- npm install @sogni-ai/sogni-intelligence-client
21
+ npm install @sogni-ai/sogni-intelligence-client@alpha
31
22
  ```
32
23
 
33
- Or with Yarn:
24
+ > **Pre‑release.** The current published version is `3.0.0-alpha.0` on the `alpha` dist‑tag. Pin with `@^3.0.0-alpha.0` until `3.0.0` stable is cut.
34
25
 
35
- ```bash
36
- yarn add @sogni-ai/sogni-intelligence-client
37
- ```
38
-
39
- ## Quick Start
40
-
41
- ### 1. Setup Environment Variables
42
-
43
- First, create a `.env` file in your project root to securely store your credentials:
44
-
45
- ```bash
46
- # Copy the example file
47
- cp node_modules/@sogni-ai/sogni-intelligence-client/.env.example .env
48
- ```
49
-
50
- ### 2. Install Dependencies
51
-
52
- ```bash
53
- npm install dotenv
54
- ```
55
-
56
- ### 3. Create Your Script
57
-
58
- ```typescript
59
- import { config } from 'dotenv';
60
- import { SogniClientWrapper } from '@sogni-ai/sogni-intelligence-client';
61
-
62
- // Load environment variables from .env file
63
- config();
64
-
65
- async function main() {
66
- // 1. Create and connect the client with credentials from .env
67
- const client = new SogniClientWrapper({
68
- username: process.env.SOGNI_USERNAME!,
69
- password: process.env.SOGNI_PASSWORD!,
70
- });
71
-
72
- try {
73
- // The client connects automatically on the first operation
74
- console.log('Client connected!');
75
-
76
- // 2. Find the most popular model
77
- const model = await client.getMostPopularModel();
78
- console.log(`Using model: ${model.id} (${model.workerCount} workers)`);
79
-
80
- // 3. Generate an image
81
- console.log('Generating image...');
82
- const result = await client.createProject({
83
- type: 'image',
84
- modelId: model.id,
85
- positivePrompt: 'A photorealistic portrait of a majestic lion in the savanna at sunset',
86
- negativePrompt: 'blurry, cartoon, low quality',
87
- stylePrompt: 'cinematic',
88
- numberOfMedia: 1,
89
- steps: 30,
90
- guidance: 8,
91
- });
92
-
93
- if (result.completed && result.imageUrls) {
94
- console.log('Image generation successful!');
95
- console.log('Image URLs:', result.imageUrls);
96
- } else {
97
- console.error('Image generation did not complete.');
98
- }
99
-
100
- } catch (error) {
101
- console.error('An error occurred:', error);
102
- } finally {
103
- // 4. Disconnect the client
104
- await client.disconnect();
105
- console.log('Client disconnected.');
106
- }
107
- }
26
+ Requires Node.js ≥ 18.
108
27
 
109
- main();
110
- ```
111
-
112
- ### 4. Run the Script
28
+ ## Package structure
113
29
 
114
- ```bash
115
- # If using TypeScript
116
- npx tsx your-script.ts
117
-
118
- # If using compiled JavaScript
119
- node your-script.js
120
- ```
30
+ The package exposes nine subpath entry points so consumers import only what they need:
121
31
 
122
- ## Video Rendering Support
32
+ | Subpath | Purpose |
33
+ |---|---|
34
+ | `@sogni-ai/sogni-intelligence-client` | `SogniClientWrapper` connection class + helpers + re‑exports from the underlying SDK |
35
+ | `…/contracts` | Public contracts, default policies, repair recipes, prompt contracts, schema registry |
36
+ | `…/tools` | Sogni‑hosted tool definitions and argument validators (image, video, audio, editing, analysis) |
37
+ | `…/replay` | `RunRecord` types + redaction utilities (signed URLs, JWTs, bearer tokens scrubbed) |
38
+ | `…/runtime` | Contract runtime — apply policies, recipes, and prompt contracts at call sites |
39
+ | `…/public-skill-runtime` | Skill‑side helpers: classify turns, compile tool surface, dispatch tool calls |
40
+ | `…/skills/asset_reference_management` | Asset‑reference resolution helpers for hosted media |
41
+ | `…/workflows` | Creative‑workflow type definitions, bindings with embedded‑interpolation support, and a `primitives` namespace of pure helpers for `wf:*` stage tools (LLM judge + `__PASS__`/`__FAIL__` parser, bounded retry‑until‑predicate, storyboard script expander, dialogue duration fitter, SSRF allow‑list for fetched artifact URLs) |
42
+ | `…/media` | Media reference helpers (upload / download URL flows) |
43
+ | `…/schemas/*` | Raw JSON Schema artifacts for cross‑language codegen (Swift, Kotlin, Python, etc.) |
123
44
 
124
- The wrapper supports video generation with Sogni WAN and LTX-2 models. Generate videos from text prompts, images, audio, or other videos.
125
-
126
- ### Video Generation Example
127
-
128
- ```typescript
129
- // Text-to-Video (t2v) using speed variant for reliability
130
- const videoResult = await client.createVideoProject({
131
- modelId: 'wan_v2.2-14b-fp8_t2v_lightx2v', // Speed variant (4 steps)
132
- positivePrompt: 'A serene waterfall flowing through a lush green forest',
133
- numberOfMedia: 1,
134
- frames: 81, // Generate 81 frames (5 seconds at 16fps)
135
- fps: 16, // 16 frames per second
136
- width: 640, // 640x640 resolution
137
- height: 640,
138
- steps: 4, // Optimized for speed variant
139
- outputFormat: 'mp4',
140
- waitForCompletion: true,
141
- timeout: 300000, // 5 minute timeout for video generation
142
- });
45
+ Each subpath ships dual CJS + ESM with TypeScript declarations.
143
46
 
144
- console.log('Video URLs:', videoResult.videoUrls);
145
- ```
47
+ ## Quick start
146
48
 
147
- ### Video Cost Estimate
49
+ ### 1. Configure credentials
148
50
 
149
- ```typescript
150
- const estimate = await client.estimateVideoCost({
151
- modelId: 'wan_v2.2-14b-fp8_i2v_lightx2v',
152
- width: 512,
153
- height: 512,
154
- frames: 81,
155
- fps: 16,
156
- steps: 4,
157
- tokenType: 'spark',
158
- });
51
+ Create a `.env` in your project root:
159
52
 
160
- console.log('Estimated USD cost:', estimate.usd);
53
+ ```env
54
+ SOGNI_USERNAME=your-username
55
+ SOGNI_PASSWORD=your-password
56
+ SOGNI_APP_ID=your-app-id # optional; auto‑generated if omitted
57
+ SOGNI_NETWORK=fast # or "relaxed"
161
58
  ```
162
59
 
163
- ### Video Workflows
164
-
165
- The wrapper supports multiple video generation workflows:
166
-
167
- 1. **Text-to-Video (t2v)**: Generate videos from text prompts
168
- 2. **Image-to-Video (i2v)**: Animate static images or interpolate between two images
169
- 3. **Sound-to-Video (s2v / ia2v / a2v)**: Drive generation with audio references
170
- 4. **Video-to-Video (v2v)**: Control motion/style from a reference video
171
- 5. **Animate Workflows**: Create character animations or motion transfers
172
-
173
- ### Advanced Video Examples
60
+ ### 2. Image generation
174
61
 
175
62
  ```typescript
176
- // Image-to-Video with interpolation
177
- const i2vResult = await client.createVideoProject({
178
- modelId: 'wan_v2.2-14b-fp8_i2v_lightx2v',
179
- positivePrompt: 'Smooth camera movement',
180
- referenceImage: startImageBuffer, // Starting image
181
- referenceImageEnd: endImageBuffer, // Optional: end image for interpolation
182
- width: 512,
183
- height: 512,
184
- frames: 81,
185
- fps: 16,
186
- steps: 4,
187
- autoResizeVideoAssets: true, // Auto-resize reference images (default: true)
188
- });
189
-
190
- // Animate with motion transfer
191
- const animateResult = await client.createVideoProject({
192
- modelId: 'wan_v2.2-14b-fp8_animate',
193
- positivePrompt: 'Character animation',
194
- referenceImage: characterImage, // Character to animate
195
- referenceVideo: motionVideo, // Video with motion to transfer
196
- frames: 90,
197
- fps: 30,
198
- });
199
-
200
- // LTX image+audio-to-video (ia2v)
201
- const ia2vResult = await client.createVideoProject({
202
- modelId: 'ltx2-13b-fp8_ia2v_distilled',
203
- positivePrompt: 'A cinematic portrait delivering the spoken line naturally',
204
- referenceImage: portraitBuffer,
205
- referenceAudio: speechBuffer,
206
- audioStart: 0,
207
- audioDuration: 5,
208
- fps: 24,
209
- duration: 5,
210
- numberOfMedia: 1,
211
- });
212
-
213
- // LTX audio-to-video (a2v)
214
- const a2vResult = await client.createVideoProject({
215
- modelId: 'ltx23-22b-fp8_a2v_distilled',
216
- positivePrompt: 'Abstract visuals that pulse with the soundtrack',
217
- referenceAudio: soundtrackBuffer,
218
- audioStart: 2,
219
- audioDuration: 6,
220
- fps: 24,
221
- duration: 6,
222
- numberOfMedia: 1,
223
- });
224
- ```
225
-
226
- ### Convenience Methods
227
-
228
- For cleaner code, use the dedicated convenience methods:
63
+ import 'dotenv/config';
64
+ import { SogniClientWrapper } from '@sogni-ai/sogni-intelligence-client';
229
65
 
230
- ```typescript
231
- // For images
232
- const imageResult = await client.createImageProject({
233
- modelId: 'flux1-schnell-fp8',
234
- positivePrompt: 'A beautiful sunset',
235
- numberOfMedia: 1,
66
+ const client = new SogniClientWrapper({
67
+ username: process.env.SOGNI_USERNAME!,
68
+ password: process.env.SOGNI_PASSWORD!,
236
69
  });
237
70
 
238
- // For videos
239
- const videoResult = await client.createVideoProject({
240
- modelId: 'wan_v2.2-14b-fp8_t2v',
241
- positivePrompt: 'Ocean waves crashing on a beach',
242
- numberOfMedia: 1,
243
- frames: 60,
244
- fps: 30,
245
- });
71
+ const model = await client.getMostPopularModel();
246
72
 
247
- // For audio
248
- const audioResult = await client.createAudioProject({
249
- modelId: 'ace-step-v1',
250
- positivePrompt: 'An uplifting cinematic ambient track',
73
+ const result = await client.createProject({
74
+ type: 'image',
75
+ modelId: model.id,
76
+ positivePrompt: 'A photorealistic portrait of a majestic lion at sunset',
77
+ negativePrompt: 'blurry, cartoon, low quality',
78
+ stylePrompt: 'cinematic',
251
79
  numberOfMedia: 1,
252
- duration: 30,
253
- steps: 20,
254
- outputFormat: 'mp3',
80
+ steps: 30,
81
+ guidance: 8,
255
82
  });
256
- ```
257
83
 
258
- ## Audio Generation
84
+ console.log(result.images.map((i) => i.url));
259
85
 
260
- ```typescript
261
- const audioEstimate = await client.estimateAudioCost({
262
- modelId: 'ace-step-v1',
263
- duration: 30,
264
- steps: 20,
265
- numberOfMedia: 1,
266
- tokenType: 'spark',
267
- });
268
-
269
- console.log('Estimated audio cost (USD):', audioEstimate.usd);
86
+ await client.disconnect();
270
87
  ```
271
88
 
272
- ## Chat Completions
89
+ ### 3. Tool calling against Sogni's hosted catalog
273
90
 
274
91
  ```typescript
275
- // Non-streaming
276
- const completion = await client.createChatCompletion({
277
- model: 'qwen3-30b-a3b-gptq-int4',
278
- messages: [{ role: 'user', content: 'Write a haiku about sunsets.' }],
92
+ import {
93
+ SogniClientWrapper,
94
+ SogniTools,
95
+ isSogniToolCall,
96
+ } from '@sogni-ai/sogni-intelligence-client';
97
+
98
+ const client = new SogniClientWrapper({ /* … */ });
99
+
100
+ const chat = await client.chat.completions.create({
101
+ model: 'openai/gpt-oss-120b',
102
+ messages: [{ role: 'user', content: 'Generate a 3‑second clip of a koi pond.' }],
103
+ tools: SogniTools.all, // the full Sogni-hosted tool catalog
279
104
  });
280
- console.log(completion.content);
281
105
 
282
- // Streaming
283
- const stream = await client.createChatCompletion({
284
- model: 'qwen3-30b-a3b-gptq-int4',
285
- messages: [{ role: 'user', content: 'Explain diffusion models simply.' }],
286
- stream: true,
287
- });
288
- for await (const chunk of stream) {
289
- process.stdout.write(chunk.content);
106
+ const call = chat.choices[0].message.tool_calls?.[0];
107
+ if (call && isSogniToolCall(call.function.name)) {
108
+ // Hand the tool call off to Sogni's hosted execution surface, or
109
+ // dispatch it locally via /public-skill-runtime.
290
110
  }
291
111
  ```
292
112
 
293
- ### Tool Calling (Function Calling)
294
-
295
- `createChatCompletion()` accepts OpenAI-style `tools` and `tool_choice` parameters.
113
+ ### 4. Replay a previous run with redaction
296
114
 
297
115
  ```typescript
298
- import type { ChatMessage, ToolCall, ToolDefinition } from '@sogni-ai/sogni-intelligence-client';
299
-
300
- const tools: ToolDefinition[] = [
301
- {
302
- type: 'function',
303
- function: {
304
- name: 'add_numbers',
305
- description: 'Add two numbers',
306
- parameters: {
307
- type: 'object',
308
- properties: {
309
- a: { type: 'number' },
310
- b: { type: 'number' },
311
- },
312
- required: ['a', 'b'],
313
- },
314
- },
315
- },
316
- ];
317
-
318
- const messages: ChatMessage[] = [
319
- { role: 'user', content: 'Please add 17 and 25.' },
320
- ];
321
-
322
- for (let turn = 0; turn < 4; turn++) {
323
- const result = await client.createChatCompletion({
324
- model: 'qwen3-30b-a3b-gptq-int4',
325
- messages,
326
- tools,
327
- tool_choice: 'auto',
328
- tokenType: 'spark',
329
- });
330
-
331
- const toolCalls = result.tool_calls || [];
332
- if (toolCalls.length === 0) {
333
- console.log('Final answer:', result.content);
334
- break;
335
- }
336
-
337
- messages.push({
338
- role: 'assistant',
339
- content: result.content || null,
340
- tool_calls: toolCalls,
341
- });
342
-
343
- for (const toolCall of toolCalls) {
344
- const args = JSON.parse(toolCall.function.arguments || '{}');
345
- let output = { error: `Unknown tool: ${toolCall.function.name}` };
346
-
347
- if (toolCall.function.name === 'add_numbers') {
348
- const a = Number(args.a || 0);
349
- const b = Number(args.b || 0);
350
- output = { a, b, sum: a + b };
351
- }
352
-
353
- messages.push({
354
- role: 'tool',
355
- tool_call_id: toolCall.id,
356
- name: toolCall.function.name,
357
- content: JSON.stringify(output),
358
- });
359
- }
360
- }
116
+ import {
117
+ type RunRecord,
118
+ redactRunRecord,
119
+ redactPayload,
120
+ } from '@sogni-ai/sogni-intelligence-client/replay';
121
+
122
+ const safeRecord: RunRecord = redactRunRecord(originalRecord);
123
+ // Signed URLs, bearer tokens, JWTs, and inline secrets are scrubbed.
361
124
  ```
362
125
 
363
- ### Sogni Platform Tools (Image/Video/Audio via Chat)
364
-
365
- The wrapper re-exports the SDK helpers for Sogni platform tool calling:
366
-
367
- - `SogniTools` — the canonical 24-tool surface (use `SogniTools.all` for the full list)
368
- - `isSogniToolCall()`
369
- - `parseToolCallArguments()`
126
+ ### 5. Validate a hosted‑tool argument blob
370
127
 
371
128
  ```typescript
372
- import { SogniTools } from '@sogni-ai/sogni-intelligence-client';
373
-
374
- const result = await client.createChatCompletion({
375
- model: 'qwen3-30b-a3b-gptq-int4',
376
- messages: [{ role: 'user', content: 'Create a dramatic sunset image' }],
377
- tools: SogniTools.all,
378
- tool_choice: 'auto',
379
- tokenType: 'spark',
380
- });
129
+ import {
130
+ validateAndNormalizeHostedToolArguments,
131
+ } from '@sogni-ai/sogni-intelligence-client/contracts';
132
+
133
+ const { ok, value, error } = validateAndNormalizeHostedToolArguments(
134
+ 'generate_image',
135
+ { prompt: 'a serene koi pond', steps: 30 },
136
+ );
137
+ if (!ok) throw error;
138
+ // `value` is the normalized argument object ready to dispatch.
381
139
  ```
382
140
 
383
- ### Vision Chat and Thinking Mode
384
-
385
- ```typescript
386
- const result = await client.createChatCompletion({
387
- model: 'qwen3.5-35b-a3b-gguf-q4km',
388
- messages: [
389
- {
390
- role: 'user',
391
- content: [
392
- { type: 'text', text: 'Describe the scene and read any visible text.' },
393
- {
394
- type: 'image_url',
395
- image_url: {
396
- url: 'https://example.com/photo.jpg',
397
- detail: 'high',
398
- },
399
- },
400
- ],
401
- },
402
- ],
403
- think: false,
404
- max_tokens: 300,
405
- tokenType: 'spark',
406
- });
407
-
408
- console.log(result.content);
409
- ```
141
+ ## Authentication
410
142
 
411
- ### Manual Chat Tool Execution
412
-
413
- Useful for streaming or custom multi-round tool loops where you want the wrapper to execute returned Sogni tool calls directly.
143
+ The wrapper accepts three authentication strategies through the `SogniClientConfig`:
414
144
 
415
145
  ```typescript
416
- const result = await client.createChatCompletion({
417
- model: 'qwen3-30b-a3b-gptq-int4',
418
- messages: [{ role: 'user', content: 'Generate a neon cyberpunk city image.' }],
419
- tools: SogniTools.all,
420
- tool_choice: 'auto',
421
- tokenType: 'spark',
422
- });
146
+ // Username/password
147
+ new SogniClientWrapper({ username, password });
423
148
 
424
- if (result.tool_calls?.length) {
425
- const toolResults = await client.executeChatTools(result.tool_calls, {
426
- tokenType: 'spark',
427
- onToolProgress: (toolCall, progress) => {
428
- console.log(toolCall.function.name, progress.status, progress.percent);
429
- },
430
- });
149
+ // API key
150
+ new SogniClientWrapper({ apiKey });
431
151
 
432
- console.log(toolResults);
433
- }
152
+ // Token + cookies (typical for browser/edge contexts)
153
+ new SogniClientWrapper({ token, cookies });
434
154
  ```
435
155
 
436
- ### Full LLM Examples
437
-
438
- Run these scripts with `npx tsx`:
439
-
440
- - `examples/llm-chat-basic.ts`
441
- - `examples/llm-chat-streaming.ts`
442
- - `examples/llm-chat-vision.ts --image ./photo.jpg`
443
- - `examples/llm-tool-calling-custom.ts`
444
- - `examples/llm-tool-calling-sogni-tools.ts` (supports `--dry-run`)
156
+ Connection management, reconnection, and credit/balance polling are handled automatically. Call `client.disconnect()` when finished.
445
157
 
446
- ## Image Editing with Context Images
158
+ ## Generation surfaces
447
159
 
448
- The wrapper supports image editing using Qwen models that accept context images for multi-reference editing. This allows you to transform, combine, or edit images based on reference inputs.
160
+ The root wrapper exposes type‑safe project creation across every modality Sogni supports:
449
161
 
450
- ### Supported Models
451
-
452
- | Model ID | Type | Recommended Steps | Max Context Images |
453
- |----------|------|-------------------|-------------------|
454
- | `qwen_image_edit_2511_fp8` | Standard | 20 | 3 |
455
- | `qwen_image_edit_2511_fp8_lightning` | Fast | 4 | 3 |
456
-
457
- ### Image Edit Example
458
-
459
- ```typescript
460
- import { readFileSync } from 'fs';
162
+ - **Image generation** — Stable Diffusion XL, Flux, full model marketplace.
163
+ - **Video generation** — WAN 2.2, LTX‑2.3, Seedance v2; workflows `t2v`, `i2v`, `s2v`, `ia2v`, `a2v`, `v2v`, `animate_move`, `animate_replace`.
164
+ - **Audio generation** music and SFX models with cost estimation.
165
+ - **Image editing** — Qwen vision‑aware editors with multi‑reference context images.
166
+ - **Chat completions** — OpenAI‑shaped chat API against Sogni's LLM worker network. Streaming, vision (`image_url`), reasoning (`think`), and function/tool calling are first‑class.
461
167
 
462
- // Load your reference image(s)
463
- const referenceImage = readFileSync('./my-image.png');
168
+ See the [SDK docs](https://sdk-docs.sogni.ai/) for full parameter references on each surface.
464
169
 
465
- // Create an image edit project
466
- const result = await client.createImageEditProject({
467
- modelId: 'qwen_image_edit_2511_fp8',
468
- positivePrompt: 'Transform the cat into a majestic lion',
469
- contextImages: [referenceImage],
470
- numberOfMedia: 1,
471
- steps: 20,
472
- guidance: 4.0,
473
- });
170
+ ## Contracts, tools, and skills
474
171
 
475
- console.log('Edited image URLs:', result.imageUrls);
476
- ```
172
+ Sogni's hosted tool surface — `generate_image`, `generate_video`, `analyze_video`, `replace_video_segment`, and 20+ others — is described declaratively. Consumers can:
477
173
 
478
- ### Using Multiple Context Images
174
+ - Enumerate the catalog: `import { SogniTools } from '@sogni-ai/sogni-intelligence-client'`.
175
+ - Validate / normalize arguments before dispatch: `validateAndNormalizeHostedToolArguments` from `/contracts`.
176
+ - Apply gating policies, repair recipes, and prompt contracts at runtime: `createPublicSkillDefaultContractRuntime` from `/public-skill-runtime`.
177
+ - Generate JSON Schema clients for other languages from `/schemas/*`.
479
178
 
480
- Qwen models support up to 3 context images for complex editing operations:
179
+ For an end‑to‑end agent example, see the [Sogni Creative Agent Skill](https://github.com/Sogni-AI/sogni-creative-agent-skill) — the `sogni-agent` CLI plus a `SKILL.md` behavior file for Claude Code, OpenClaw, Hermes Agent, and Manus. It consumes only this package's public surface.
481
180
 
482
- ```typescript
483
- const image1 = readFileSync('./subject.png');
484
- const image2 = readFileSync('./style-reference.png');
485
- const image3 = readFileSync('./background.png');
486
-
487
- const result = await client.createImageEditProject({
488
- modelId: 'qwen_image_edit_2511_fp8_lightning', // Fast variant
489
- positivePrompt: 'Combine the subject with the style and background',
490
- contextImages: [image1, image2, image3],
491
- numberOfMedia: 1,
492
- steps: 4, // Optimized for lightning variant
493
- guidance: 1.0,
494
- });
495
- ```
181
+ ## RunRecord replay & redaction
496
182
 
497
- ### Multiple Angles LoRA (Qwen Image Edit)
183
+ `RunRecord` is the canonical JSON representation of a Sogni run: tool calls, results, costs, audit trail, and timing. Useful for replay, post‑hoc audits, and offline analysis.
498
184
 
499
185
  ```typescript
500
- import { readFileSync } from 'fs';
501
-
502
- const referenceImage = readFileSync('./subject.png');
503
-
504
- const result = await client.createImageEditProject({
505
- modelId: 'qwen_image_edit_2511_fp8_lightning',
506
- positivePrompt: '<sks> front view eye-level shot medium shot',
507
- contextImages: [referenceImage],
508
- numberOfMedia: 1,
509
- steps: 4,
510
- guidance: 1.0,
511
- sampler: 'euler',
512
- scheduler: 'simple',
513
- outputFormat: 'jpg',
514
- loras: ['multiple_angles'],
515
- loraStrengths: [0.9],
516
- });
517
-
518
- console.log('Generated images:', result.imageUrls);
186
+ import {
187
+ type RunRecord,
188
+ type RunRecordRound,
189
+ type RunRecordToolCall,
190
+ type RunRecordToolResult,
191
+ emptyRunRecord,
192
+ redactRunRecord,
193
+ RUN_RECORD_SCHEMA_VERSION,
194
+ } from '@sogni-ai/sogni-intelligence-client/replay';
519
195
  ```
520
196
 
521
- ### Context Image Types
522
-
523
- The `contextImages` parameter accepts an array of `InputMedia` types:
524
-
525
- - `Buffer` - Node.js Buffer containing image data
526
- - `Blob` - Browser Blob object
527
- - `File` - Browser File object
528
- - `true` - Boolean indicating a pre-uploaded image
197
+ `redactRunRecord` / `redactPayload` scrub signed URLs, bearer tokens, JWTs, and inline secrets — call them before persisting or logging records.
529
198
 
530
- ### Helper Functions
199
+ ## Error handling
531
200
 
532
- The wrapper provides helper functions for working with context images:
201
+ Errors are typed for precise dispatch:
533
202
 
534
203
  ```typescript
535
- import { getMaxContextImages, supportsContextImages } from '@sogni-ai/sogni-intelligence-client';
536
-
537
- // Check if a model supports context images
538
- if (supportsContextImages('qwen_image_edit_2511_fp8')) {
539
- console.log('Model supports context images!');
540
- }
541
-
542
- // Get the maximum number of context images for a model
543
- const maxImages = getMaxContextImages('qwen_image_edit_2511_fp8'); // Returns 3
544
-
545
- // Other models have different limits:
546
- getMaxContextImages('flux-1-schnell'); // Returns 6
547
- getMaxContextImages('kontext-model'); // Returns 2
548
- getMaxContextImages('sd-xl-base'); // Returns 0 (not supported)
204
+ import {
205
+ SogniError,
206
+ SogniConnectionError,
207
+ SogniAuthenticationError,
208
+ SogniProjectError,
209
+ SogniTimeoutError,
210
+ SogniBalanceError,
211
+ SogniValidationError,
212
+ SogniConfigurationError,
213
+ SogniModelNotFoundError,
214
+ SogniNetworkError,
215
+ } from '@sogni-ai/sogni-intelligence-client';
549
216
  ```
550
217
 
551
- ## API Reference
218
+ Each error carries `cause` and a typed `data` field where applicable.
552
219
 
553
- ### `new SogniClientWrapper(config)`
220
+ ## TypeScript & module formats
554
221
 
555
- Creates a new client instance.
222
+ - Written in TypeScript; full `.d.ts` declarations ship for every subpath.
223
+ - Dual CJS + ESM builds (`require()` and `import` both work).
224
+ - `moduleResolution: 'node'` and `'bundler'` both supported; `'node16'` / `'nodenext'` consumers should prefer the `import` condition.
556
225
 
557
- **Configuration (`SogniClientConfig`)**
226
+ ## Migrating from `@sogni-ai/sogni-client-wrapper`
558
227
 
559
- | Parameter | Type | Default | Description |
560
- |---|---|---|---|
561
- | `authType` | `'token' \| 'cookies' \| 'apiKey'` | `'token'` | Authentication mode. |
562
- | `username` | `string` | Conditionally required | Required for `token` auth; optional for `cookies`/`apiKey`. |
563
- | `password` | `string` | Conditionally required | Required for `token` auth; optional for `cookies`/`apiKey`. |
564
- | `apiKey` | `string` | Conditionally required | Required for `apiKey` auth. |
565
- | `appId` | `string` | Auto-generated UUID | Unique ID for your application. |
566
- | `network` | `'fast' \| 'relaxed'` | `'fast'` | The Sogni network to use. |
567
- | `testnet` | `boolean` | `false` | Connect to the testnet network. |
568
- | `socketEndpoint` | `string` | `undefined` | Override the default WebSocket API endpoint. |
569
- | `restEndpoint` | `string` | `undefined` | Override the default REST API endpoint. |
570
- | `disableSocket` | `boolean` | `false` | Disable WebSocket connection (advanced/testing). |
571
- | `allowInsecureTLS` | `boolean` | `false` | Allow insecure TLS (useful for testnet with self-signed certs). |
572
- | `autoConnect` | `boolean` | `true` | Connect automatically on the first operation. |
573
- | `reconnect` | `boolean` | `true` | Attempt to reconnect if the connection is lost. |
574
- | `reconnectInterval` | `number` | `5000` | Time in ms between reconnect attempts. |
575
- | `timeout` | `number` | `300000` | Default timeout in ms for operations. |
576
- | `debug` | `boolean` | `false` | Enable detailed console logging. |
228
+ If you previously installed `@sogni-ai/sogni-client-wrapper`, the import path is the only thing that changes:
577
229
 
578
- #### API Key Authentication Example
579
-
580
- ```typescript
581
- const client = new SogniClientWrapper({
582
- authType: 'apiKey',
583
- apiKey: process.env.SOGNI_API_KEY!,
584
- network: 'fast',
585
- });
230
+ ```diff
231
+ - import { SogniClientWrapper } from '@sogni-ai/sogni-client-wrapper';
232
+ + import { SogniClientWrapper } from '@sogni-ai/sogni-intelligence-client';
586
233
  ```
587
234
 
588
- ### Core Methods
589
-
590
- - `connect(): Promise<void>`: Manually initiates the connection to Sogni.
591
- - `disconnect(): Promise<void>`: Disconnects the client.
592
- - `isConnected(): boolean`: Checks if the client is currently connected.
593
- - `getConnectionState(): ConnectionState`: Returns the current connection status.
594
-
595
- ### Main Operations
596
-
597
- - `createProject(config: ProjectConfig): Promise<ProjectResult>`: Creates a new image, video, or audio generation project.
598
- - `waitForCompletion` (default: `true`): If true, the promise resolves only when the media is ready.
599
- - For images: returns `imageUrls` in result
600
- - For videos: returns `videoUrls` in result
601
- - For audio: returns `audioUrls` in result
602
- - `createImageProject(config)`: Convenience method for image generation (automatically sets `type: 'image'`).
603
- - `createVideoProject(config)`: Convenience method for video generation (automatically sets `type: 'video'`).
604
- - `createAudioProject(config)`: Convenience method for audio generation (automatically sets `type: 'audio'`).
605
- - `createImageEditProject(config: QwenImageEditConfig)`: Convenience method for image editing with context images (validates model-specific limits).
606
- - `getAvailableModels(options?: GetModelsOptions): Promise<ModelInfo[]>`: Retrieves a list of available models.
607
- - `getModel(modelId: string): Promise<ModelInfo>`: Retrieves details for a specific model.
608
- - `getMostPopularModel(): Promise<ModelInfo>`: A helper to get the model with the most active workers.
609
- - `getBalance(): Promise<BalanceInfo>`: Fetches your current SOGNI and Spark token balances using the `account.refreshBalance()` method.
610
- - `getWalletBalance(walletAddress?, provider?): Promise<WalletBalanceInfo>`: Fetches Base or Etherlink wallet balances. When `walletAddress` is omitted, the wrapper uses the connected account wallet.
611
- - `getCurrentAccount(): CurrentAccount | null`: Returns the SDK's current account snapshot if the client has connected.
612
- - `getTrackedProjects(): Project[]`: Returns the projects currently tracked by the underlying SDK instance.
613
- - `getSizePresets(network: 'fast' \| 'relaxed', modelId: string): Promise<SizePreset[]>`: Gets available output size presets for a model.
614
- - `estimateVideoCost(params: VideoCostEstimateParams): Promise<CostEstimate>`: Estimates video generation costs (frames/duration, fps, steps, size).
615
- - `estimateAudioCost(params: AudioCostEstimateParams): Promise<CostEstimate>`: Estimates audio generation costs (duration, steps, count).
616
- - `createChatCompletion(params)`: Creates chat completions (streaming or non-streaming, including `tools` / `tool_choice` function calling).
617
- - `executeChatTool(toolCall, options?)`: Executes a single Sogni platform tool call returned by chat.
618
- - `executeChatTools(toolCalls, options?)`: Executes multiple tool calls, including mixed Sogni/custom tool flows.
619
- - `estimateChatCost(params)`: Estimates chat completion cost.
620
- - `getAvailableChatModels()`: Returns available chat/LLM models.
621
- - `waitForChatModels(timeout?)`: Waits until chat/LLM models are available.
622
- - SDK helper exports: `ChatStream`, `ChatToolsApi`, `CurrentAccount`, `SogniTools`, `isSogniToolCall`, `parseToolCallArguments`.
623
-
624
- ### Event Handling
625
-
626
- The wrapper is an `EventEmitter` and provides type-safe events.
235
+ All wrapper APIs are preserved at the root export. The intelligence client adds the new subpaths above; adopt them incrementally. The old `@sogni-ai/sogni-client-wrapper` npm name is deprecated.
627
236
 
628
- ```typescript
629
- import { ClientEvent } from '@sogni-ai/sogni-intelligence-client';
237
+ ## Related packages and docs
630
238
 
631
- client.on(ClientEvent.CONNECTED, () => {
632
- console.log('Client is connected!');
633
- });
634
-
635
- client.on(ClientEvent.PROJECT_PROGRESS, (progress) => {
636
- console.log(`Project ${progress.projectId} is ${progress.percentage}% complete.`);
637
- if (progress.estimatedTimeRemaining) {
638
- console.log(`ETA: ${Math.round(progress.estimatedTimeRemaining / 1000)}s`);
639
- }
640
- });
641
-
642
- client.on(ClientEvent.ERROR, (error) => {
643
- console.error('A client error occurred:', error.message);
644
- });
645
-
646
- // Per-media events - Display outputs as soon as they're ready!
647
- client.on(ClientEvent.JOB_COMPLETED, (data) => {
648
- console.log(`Job ${data.jobIndex + 1}/${data.totalJobs} completed!`);
649
- console.log(`URL: ${data.imageUrl || data.videoUrl || data.audioUrl}`);
650
- // You can now handle this individual output without waiting for the entire batch
651
- });
652
-
653
- client.on(ClientEvent.JOB_FAILED, (data) => {
654
- console.log(`Job ${data.jobIndex + 1}/${data.totalJobs} failed:`, data.error);
655
- });
656
- ```
657
-
658
- #### Available Events
659
-
660
- | Event | Payload | Description |
661
- |---|---|---|
662
- | `connected` | `void` | Fired when the client successfully connects. |
663
- | `disconnected` | `void` | Fired when the client disconnects. |
664
- | `reconnecting` | `number` | Fired when a reconnection attempt starts. Payload is the attempt number. |
665
- | `error` | `ErrorData` | Fired when a client or connection error occurs. |
666
- | `projectProgress` | `ProjectProgress` | Fired with real-time progress updates for a project. |
667
- | `projectCompleted` | `ProjectResult` | Fired when a project successfully completes. |
668
- | `projectFailed` | `ErrorData` | Fired when a project fails. |
669
- | **`jobCompleted`** | **`JobCompletedData`** | **Fired when an individual job finishes (image/video/audio).** |
670
- | **`jobFailed`** | **`JobFailedData`** | **Fired when an individual job fails.** |
671
- | `projectEvent` | `ProjectEvent` | Raw project events from the SDK (`queued`, `completed`, `error`). |
672
- | `jobEvent` | `JobEvent` | Raw job events from the SDK (includes `jobETA`, `started`, `progress`, etc). |
673
- | `chatToken` | `ChatCompletionChunk` | Fired for each streaming chat token chunk. |
674
- | `chatCompleted` | `ChatCompletionResult` | Fired when a chat completion finishes. |
675
- | `chatError` | `ChatErrorData` | Fired when a chat completion fails. |
676
- | `chatJobState` | `ChatJobStateEvent` | Fired on chat job state transitions. |
677
- | `chatModelsUpdated` | `Record<string, LLMModelInfo>` | Fired when available chat models are updated. |
678
-
679
- #### Per-Job Event Example
680
-
681
- Perfect for displaying batch outputs immediately as they complete:
682
-
683
- ```typescript
684
- const client = new SogniClientWrapper({
685
- username: process.env.SOGNI_USERNAME!,
686
- password: process.env.SOGNI_PASSWORD!,
687
- });
688
-
689
- // Listen for individual image completions
690
- client.on(ClientEvent.JOB_COMPLETED, (data) => {
691
- console.log(`✓ Image ${data.jobIndex + 1} of ${data.totalJobs} ready!`);
692
- console.log(` URL: ${data.imageUrl}`);
693
- // Display the image in your UI immediately
694
- displayImage(data.imageUrl);
695
- });
696
-
697
- // Generate a batch of images
698
- const result = await client.createProject({
699
- type: 'image',
700
- modelId: 'flux1-schnell-fp8',
701
- positivePrompt: 'A beautiful landscape',
702
- numberOfMedia: 4, // Generate 4 images
703
- steps: 4,
704
- guidance: 3.5,
705
- });
706
-
707
- // All 4 images will be displayed as they complete, not all at once!
708
- ```
709
-
710
- ## Error Handling
711
-
712
- The library throws custom errors that extend `SogniError`. This allows you to catch specific types of errors.
713
-
714
- - `SogniConnectionError`: Issues with connecting to the WebSocket server.
715
- - `SogniAuthenticationError`: Invalid credentials (username/password, cookie session, or API key).
716
- - `SogniProjectError`: The image generation project failed.
717
- - `SogniTimeoutError`: An operation took longer than the configured timeout.
718
- - `SogniValidationError`: Invalid configuration or parameters.
719
- - `SogniBalanceError`: Insufficient token balance.
720
-
721
- ```typescript
722
- import { SogniAuthenticationError, SogniProjectError } from '@sogni-ai/sogni-intelligence-client';
723
-
724
- try {
725
- // ... your code
726
- } catch (error) {
727
- if (error instanceof SogniAuthenticationError) {
728
- console.error('Please check your credentials.');
729
- } else if (error instanceof SogniProjectError) {
730
- console.error('The image generation failed. Please try a different prompt or model.');
731
- } else {
732
- console.error('An unknown error occurred:', error);
733
- }
734
- }
735
- ```
239
+ | | Where |
240
+ |---|---|
241
+ | **Intelligence Client docs** | https://sdk-docs.sogni.ai/our-superapps/sogni-sdk/intelligence-client/ |
242
+ | **Sogni Intelligence API** | https://sdk-docs.sogni.ai/sogni-intelligence/introduction/ |
243
+ | **`@sogni-ai/sogni-client`** (raw SDK) | [npm](https://www.npmjs.com/package/@sogni-ai/sogni-client) · [docs](https://sdk-docs.sogni.ai/) |
244
+ | **`@sogni-ai/sogni-creative-agent-skill`** (CLI + Anthropic skill) | [GitHub](https://github.com/Sogni-AI/sogni-creative-agent-skill) · [npm](https://www.npmjs.com/package/@sogni-ai/sogni-creative-agent-skill) |
245
+ | **SogniKit** (Swift, regenerated from `/schemas/*.json`) | https://github.com/Sogni-AI/SogniKit |
246
+ | `@sogni/creative-agent` (private) | Server‑side orchestration, billing enforcement, persona management. Not on npm. |
736
247
 
737
248
  ## Testing
738
249
 
739
- The library includes basic unit tests, example type-checking, and end-to-end tests.
740
-
741
- ### Running Tests
742
-
743
250
  ```bash
744
- # Run basic unit tests (no credentials required)
745
- npm test
746
-
747
- # Type-check all example scripts (including LLM/tool-calling examples)
748
- npm run test:examples
749
-
750
- # Run end-to-end tests (requires Sogni API credentials)
751
- npm run test:e2e
752
-
753
- # Run only LLM/tool-calling e2e tests
754
- npm run test:e2e:llm
755
-
756
- # Run all tests
757
- npm run test:all
251
+ npm test # unit + type checks; no credentials required
252
+ npm run test:e2e # full end-to-end, requires SOGNI_USERNAME/SOGNI_PASSWORD in .env
758
253
  ```
759
254
 
760
- ### Setting Up End-to-End Tests
761
-
762
- To run the end-to-end tests, you need to provide your Sogni API credentials via environment variables:
763
-
764
- 1. Copy the example environment file:
765
- ```bash
766
- cp .env.example .env
767
- ```
768
-
769
- 2. Edit `.env` and add your Sogni credentials:
770
- ```env
771
- SOGNI_USERNAME=your_sogni_username
772
- SOGNI_PASSWORD=your_sogni_password
773
- # Optional: force a specific chat/LLM model for e2e tests
774
- # SOGNI_LLM_MODEL=qwen3-30b-a3b-gptq-int4
775
- # Optional: fail suite if LLM tests cannot run (default: skip LLM tests if unavailable)
776
- # SOGNI_REQUIRE_LLM_E2E=true
777
- # Optional: fail suite if tool-calling tests cannot get tool_calls
778
- # SOGNI_REQUIRE_TOOL_CALL_E2E=true
779
- # Optional: run only LLM/tool-calling e2e tests
780
- # SOGNI_E2E_SCOPE=llm
781
- ```
782
-
783
- 3. Run the e2e tests:
784
- ```bash
785
- npm run test:e2e
786
- ```
787
-
788
- **Note:** The e2e tests make real API calls and may consume tokens from your Sogni account. They include image/video generation and live LLM chat calls.
789
-
790
- ## TypeScript
791
-
792
- This library is written in TypeScript and exports all necessary types for a fully-typed experience.
793
-
794
- - `SogniClientConfig`: Configuration for the client constructor.
795
- - `ProjectConfig`: Parameters for creating a project (union of `ImageProjectConfig`, `VideoProjectConfig`, and `AudioProjectConfig`).
796
- - `ImageProjectConfig`: Parameters specific to image generation.
797
- - `VideoProjectConfig`: Parameters specific to video generation.
798
- - `AudioProjectConfig`: Parameters specific to audio generation.
799
- - `QwenImageEditConfig`: Parameters for image editing with context images.
800
- - `InputMedia`: Type for media inputs (`File | Buffer | Blob | boolean`).
801
- - `ProjectResult`: The return type for a completed project.
802
- - `VideoCostEstimateParams`: Parameters for estimating video cost.
803
- - `AudioCostEstimateParams`: Parameters for estimating audio cost.
804
- - `CostEstimate`: Cost estimate response shape.
805
- - `ModelInfo`: Detailed information about an available model.
806
- - `BalanceInfo`: Your token balance.
807
- - `ErrorData`: The structure of error objects.
808
- - `VideoWorkflowType`: Video generation workflow types (`t2v`, `i2v`, `s2v`, `ia2v`, `a2v`, `v2v`, `animate-move`, `animate-replace`).
809
- - `JobCompletedData`: Data emitted when an individual job completes.
810
- - `JobFailedData`: Data emitted when an individual job fails.
811
- - `ChatCompletionParams` / `ChatCompletionResult` / `ChatCompletionChunk`: Types for chat completions.
812
- - `ContentPart` / `ImageUrlContentPart`: Types for multimodal chat content.
813
- - `ToolDefinition` / `ToolChoice` / `ToolCall` / `ToolCallDelta`: Types for LLM tool/function calling.
814
- - `ToolExecutionOptions` / `ToolExecutionProgress` / `ToolExecutionResult` / `ToolHistoryEntry`: Types for manual or automatic chat tool execution.
815
- - `LLMModelInfo` / `LLMCostEstimation`: Types for chat model metadata and cost estimates.
816
- - `WalletBalanceInfo`: Wallet balance response shape for Base/Etherlink lookups.
817
- - `SogniTools` / `isSogniToolCall` / `parseToolCallArguments`: Helper exports for platform tool calling workflows.
818
- - `ProjectEvent`: Raw project events from the SDK.
819
- - `JobEvent`: Raw job events from the SDK (includes ETA updates).
820
-
821
255
  ## License
822
256
 
823
- [MIT](LICENSE)
257
+ MIT — see [LICENSE](./LICENSE).