@sogni-ai/sogni-intelligence-client 3.0.0-alpha.0 → 3.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -729
- package/chatRun/index.d.ts +1 -0
- package/chatRun/index.js +2 -0
- package/context/index.d.ts +1 -0
- package/context/index.js +2 -0
- package/dist/agent/index.d.ts +5 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +38 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/intentInput.d.ts +106 -0
- package/dist/agent/intentInput.d.ts.map +1 -0
- package/dist/agent/intentInput.js +410 -0
- package/dist/agent/intentInput.js.map +1 -0
- package/dist/agent/toolMetadata.d.ts +37 -0
- package/dist/agent/toolMetadata.d.ts.map +1 -0
- package/dist/agent/toolMetadata.js +146 -0
- package/dist/agent/toolMetadata.js.map +1 -0
- package/dist/agent/turnAnalysis.d.ts +34 -0
- package/dist/agent/turnAnalysis.d.ts.map +1 -0
- package/dist/agent/turnAnalysis.js +155 -0
- package/dist/agent/turnAnalysis.js.map +1 -0
- package/dist/agent/turnPlan.d.ts +40 -0
- package/dist/agent/turnPlan.d.ts.map +1 -0
- package/dist/agent/turnPlan.js +187 -0
- package/dist/agent/turnPlan.js.map +1 -0
- package/dist/artifacts/graph.d.ts +92 -0
- package/dist/artifacts/graph.d.ts.map +1 -0
- package/dist/artifacts/graph.js +484 -0
- package/dist/artifacts/graph.js.map +1 -0
- package/dist/artifacts/index.d.ts +3 -0
- package/dist/artifacts/index.d.ts.map +1 -0
- package/dist/artifacts/index.js +28 -0
- package/dist/artifacts/index.js.map +1 -0
- package/dist/artifacts/queries.d.ts +7 -0
- package/dist/artifacts/queries.d.ts.map +1 -0
- package/dist/artifacts/queries.js +85 -0
- package/dist/artifacts/queries.js.map +1 -0
- package/dist/billing/index.d.ts +3 -0
- package/dist/billing/index.d.ts.map +1 -0
- package/dist/billing/index.js +27 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/billing/spendGate.d.ts +72 -0
- package/dist/billing/spendGate.d.ts.map +1 -0
- package/dist/billing/spendGate.js +344 -0
- package/dist/billing/spendGate.js.map +1 -0
- package/dist/billing/workflowAuthorization.d.ts +56 -0
- package/dist/billing/workflowAuthorization.d.ts.map +1 -0
- package/dist/billing/workflowAuthorization.js +270 -0
- package/dist/billing/workflowAuthorization.js.map +1 -0
- package/dist/chatRun/costApproval.d.ts +10 -0
- package/dist/chatRun/costApproval.d.ts.map +1 -0
- package/dist/chatRun/costApproval.js +70 -0
- package/dist/chatRun/costApproval.js.map +1 -0
- package/dist/chatRun/index.d.ts +223 -0
- package/dist/chatRun/index.d.ts.map +1 -0
- package/dist/chatRun/index.js +396 -0
- package/dist/chatRun/index.js.map +1 -0
- package/dist/client/SogniClientWrapper.d.ts +2 -2
- package/dist/client/SogniClientWrapper.d.ts.map +1 -1
- package/dist/client/SogniClientWrapper.js +60 -57
- package/dist/client/SogniClientWrapper.js.map +1 -1
- package/dist/context/index.d.ts +56 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +460 -0
- package/dist/context/index.js.map +1 -0
- package/dist/contracts/data/gatingPolicies.d.ts +1 -1
- package/dist/contracts/data/gatingPolicies.d.ts.map +1 -1
- package/dist/contracts/data/gatingPolicies.js +5 -5
- package/dist/contracts/data/gatingPolicies.js.map +1 -1
- package/dist/contracts/data/index.d.ts +3 -3
- package/dist/contracts/data/index.d.ts.map +1 -1
- package/dist/contracts/data/index.js +4 -4
- package/dist/contracts/data/index.js.map +1 -1
- package/dist/contracts/data/promptContracts.d.ts +1 -1
- package/dist/contracts/data/promptContracts.d.ts.map +1 -1
- package/dist/contracts/data/promptContracts.js +224 -45
- package/dist/contracts/data/promptContracts.js.map +1 -1
- package/dist/contracts/data/repairRecipes.d.ts +1 -1
- package/dist/contracts/data/repairRecipes.d.ts.map +1 -1
- package/dist/contracts/data/repairRecipes.js +3 -3
- package/dist/contracts/data/repairRecipes.js.map +1 -1
- package/dist/contracts/data/toolCatalog.js +1 -1
- package/dist/contracts/data/toolCatalog.js.map +1 -1
- package/dist/contracts/data/toolPermissions.d.ts +2 -0
- package/dist/contracts/data/toolPermissions.d.ts.map +1 -1
- package/dist/contracts/data/toolPermissions.js +2 -13
- package/dist/contracts/data/toolPermissions.js.map +1 -1
- package/dist/contracts/index.d.ts +3 -3
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +8 -6
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/storyboard.d.ts +1 -0
- package/dist/contracts/storyboard.d.ts.map +1 -1
- package/dist/contracts/storyboard.js.map +1 -1
- package/dist/contracts/toolGatingPolicy.d.ts.map +1 -1
- package/dist/contracts/toolGatingPolicy.js +6 -2
- package/dist/contracts/toolGatingPolicy.js.map +1 -1
- package/dist/contracts/toolSurface.d.ts +1 -0
- package/dist/contracts/toolSurface.d.ts.map +1 -1
- package/dist/contracts/toolSurface.js +12 -5
- package/dist/contracts/toolSurface.js.map +1 -1
- package/dist/contracts/turnPolicy.d.ts +2 -1
- package/dist/contracts/turnPolicy.d.ts.map +1 -1
- package/dist/contracts/turnPolicy.js +14 -0
- package/dist/contracts/turnPolicy.js.map +1 -1
- package/dist/events/index.d.ts +2 -0
- package/dist/events/index.d.ts.map +1 -0
- package/dist/events/index.js +12 -0
- package/dist/events/index.js.map +1 -0
- package/dist/events/runEvent.d.ts +31 -0
- package/dist/events/runEvent.d.ts.map +1 -0
- package/dist/events/runEvent.js +161 -0
- package/dist/events/runEvent.js.map +1 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +73 -35
- package/dist/index.js.map +1 -1
- package/dist/media/generationJob.d.ts +1 -1
- package/dist/media/generationJob.d.ts.map +1 -1
- package/dist/openai-tools/_manifests.generated.d.ts +4 -0
- package/dist/openai-tools/_manifests.generated.d.ts.map +1 -0
- package/dist/openai-tools/_manifests.generated.js +1792 -0
- package/dist/openai-tools/_manifests.generated.js.map +1 -0
- package/dist/openai-tools/app-tools.json +297 -0
- package/dist/openai-tools/composition-tools.json +228 -0
- package/dist/openai-tools/generation-tools.json +1263 -0
- package/dist/openai-tools/index.d.ts +17 -0
- package/dist/openai-tools/index.d.ts.map +1 -0
- package/dist/openai-tools/index.js +32 -0
- package/dist/openai-tools/index.js.map +1 -0
- package/dist/public-skill-runtime/index.d.ts +3 -1
- package/dist/public-skill-runtime/index.d.ts.map +1 -1
- package/dist/public-skill-runtime/index.js +619 -156
- package/dist/public-skill-runtime/index.js.map +1 -1
- package/dist/schemas/agent/intent-input.schema.json +128 -0
- package/dist/schemas/agent/turn-analysis.schema.json +75 -0
- package/dist/schemas/artifacts/artifact-graph.schema.json +42 -0
- package/dist/schemas/artifacts/artifact-node.schema.json +137 -0
- package/dist/schemas/billing/spend-gate.schema.json +130 -0
- package/dist/schemas/billing/workflow-authorization.schema.json +83 -0
- package/dist/schemas/errors/error.schema.json +21 -0
- package/dist/schemas/errors/repair-control.schema.json +40 -0
- package/dist/schemas/events/artifact-reference.schema.json +22 -0
- package/dist/schemas/events/progress-event.schema.json +28 -0
- package/dist/schemas/events/run-event.schema.json +111 -0
- package/dist/schemas/events/workflow-event.schema.json +22 -0
- package/dist/schemas/prompt-contract.schema.json +42 -0
- package/dist/schemas/storyboards/storyboard-planning-contract.schema.json +108 -0
- package/dist/schemas/tools/add_subtitles.schema.json +77 -0
- package/dist/schemas/tools/animate_photo.schema.json +104 -0
- package/dist/schemas/tools/apply_style.schema.json +37 -0
- package/dist/schemas/tools/change_angle.schema.json +30 -0
- package/dist/schemas/tools/compose_instrumental.schema.json +24 -0
- package/dist/schemas/tools/compose_lyrics.schema.json +28 -0
- package/dist/schemas/tools/compose_script.schema.json +68 -0
- package/dist/schemas/tools/compose_workflow.schema.json +67 -0
- package/dist/schemas/tools/compose_workflow_template.schema.json +156 -0
- package/dist/schemas/tools/dance_montage.schema.json +47 -0
- package/dist/schemas/tools/edit_image.schema.json +74 -0
- package/dist/schemas/tools/enhance_prompt.schema.json +76 -0
- package/dist/schemas/tools/extend_video.schema.json +42 -0
- package/dist/schemas/tools/generate_image.schema.json +104 -0
- package/dist/schemas/tools/generate_music.schema.json +62 -0
- package/dist/schemas/tools/generate_video.schema.json +97 -0
- package/dist/schemas/tools/manage_memory.schema.json +28 -0
- package/dist/schemas/tools/orbit_video.schema.json +70 -0
- package/dist/schemas/tools/overlay_video.schema.json +126 -0
- package/dist/schemas/tools/refine_result.schema.json +43 -0
- package/dist/schemas/tools/replace_video_segment.schema.json +60 -0
- package/dist/schemas/tools/resolve_personas.schema.json +15 -0
- package/dist/schemas/tools/restore_photo.schema.json +47 -0
- package/dist/schemas/tools/set_content_filter.schema.json +14 -0
- package/dist/schemas/tools/sound_to_video.schema.json +70 -0
- package/dist/schemas/tools/stitch_video.schema.json +52 -0
- package/dist/schemas/tools/tool-metadata.schema.json +78 -0
- package/dist/schemas/tools/video_to_video.schema.json +77 -0
- package/dist/schemas/workflows/durable-workflow-run.schema.json +165 -0
- package/dist/schemas/workflows/durable-workflow-step.schema.json +141 -0
- package/dist/skill-runtime-source/crossSurfaceParity.d.ts +23 -0
- package/dist/skill-runtime-source/crossSurfaceParity.d.ts.map +1 -0
- package/dist/skill-runtime-source/crossSurfaceParity.js +472 -0
- package/dist/skill-runtime-source/crossSurfaceParity.js.map +1 -0
- package/dist/skill-runtime-source/index.d.ts +4 -0
- package/dist/skill-runtime-source/index.d.ts.map +1 -0
- package/dist/skill-runtime-source/index.js +20 -0
- package/dist/skill-runtime-source/index.js.map +1 -0
- package/dist/skill-runtime-source/seedanceAudioWindow.d.ts +8 -0
- package/dist/skill-runtime-source/seedanceAudioWindow.d.ts.map +1 -0
- package/dist/skill-runtime-source/seedanceAudioWindow.js +52 -0
- package/dist/skill-runtime-source/seedanceAudioWindow.js.map +1 -0
- package/dist/skill-runtime-source/workflowStatus.d.ts +17 -0
- package/dist/skill-runtime-source/workflowStatus.d.ts.map +1 -0
- package/dist/skill-runtime-source/workflowStatus.js +353 -0
- package/dist/skill-runtime-source/workflowStatus.js.map +1 -0
- package/dist/tools/definitions/animate-photo/definition.js +8 -8
- package/dist/tools/definitions/animate-photo/definition.js.map +1 -1
- package/dist/tools/definitions/edit-image/definition.js +3 -3
- package/dist/tools/definitions/edit-image/definition.js.map +1 -1
- package/dist/tools/definitions/generate-image/definition.js +4 -4
- package/dist/tools/definitions/generate-image/definition.js.map +1 -1
- package/dist/tools/definitions/generate-music/definition.js +2 -2
- package/dist/tools/definitions/generate-music/definition.js.map +1 -1
- package/dist/tools/definitions/generate-video/definition.js +2 -2
- package/dist/tools/definitions/generate-video/definition.js.map +1 -1
- package/dist/tools/definitions/replace-video-segment/definition.d.ts.map +1 -1
- package/dist/tools/definitions/replace-video-segment/definition.js +6 -5
- package/dist/tools/definitions/replace-video-segment/definition.js.map +1 -1
- package/dist/tools/definitions/sound-to-video/definition.js +2 -2
- package/dist/tools/definitions/sound-to-video/definition.js.map +1 -1
- package/dist/tools/definitions/stitch-video/definition.d.ts.map +1 -1
- package/dist/tools/definitions/stitch-video/definition.js +9 -22
- package/dist/tools/definitions/stitch-video/definition.js.map +1 -1
- package/dist/tools/index.d.ts +6 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +20 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/normalizeArgs.d.ts +1 -0
- package/dist/tools/normalizeArgs.d.ts.map +1 -1
- package/dist/tools/normalizeArgs.js +83 -8
- package/dist/tools/normalizeArgs.js.map +1 -1
- package/dist/tools/shared/_catalogs.generated.d.ts +2 -0
- package/dist/tools/shared/_catalogs.generated.d.ts.map +1 -0
- package/dist/tools/shared/_catalogs.generated.js +13 -0
- package/dist/tools/shared/_catalogs.generated.js.map +1 -0
- package/dist/tools/shared/dynamicPromptBranches.d.ts +20 -0
- package/dist/tools/shared/dynamicPromptBranches.d.ts.map +1 -0
- package/dist/tools/shared/dynamicPromptBranches.js +193 -0
- package/dist/tools/shared/dynamicPromptBranches.js.map +1 -0
- package/dist/tools/shared/multiImageIntent.d.ts +2 -0
- package/dist/tools/shared/multiImageIntent.d.ts.map +1 -0
- package/dist/tools/shared/multiImageIntent.js +13 -0
- package/dist/tools/shared/multiImageIntent.js.map +1 -0
- package/dist/tools/shared/numberOfVariationsAlignment.d.ts +2 -0
- package/dist/tools/shared/numberOfVariationsAlignment.d.ts.map +1 -0
- package/dist/tools/shared/numberOfVariationsAlignment.js +37 -0
- package/dist/tools/shared/numberOfVariationsAlignment.js.map +1 -0
- package/dist/tools/shared/seedancePolicyErrors.d.ts +1 -0
- package/dist/tools/shared/seedancePolicyErrors.d.ts.map +1 -1
- package/dist/tools/shared/seedancePolicyErrors.js +14 -1
- package/dist/tools/shared/seedancePolicyErrors.js.map +1 -1
- package/dist/tools/shared/seedanceReferences.d.ts +22 -0
- package/dist/tools/shared/seedanceReferences.d.ts.map +1 -0
- package/dist/tools/shared/seedanceReferences.js +38 -0
- package/dist/tools/shared/seedanceReferences.js.map +1 -0
- package/dist/types/index.d.ts +2 -4
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +1 -1
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +62 -57
- package/dist/utils/helpers.js.map +1 -1
- package/dist/workflows/bindings.d.ts.map +1 -1
- package/dist/workflows/bindings.js +32 -2
- package/dist/workflows/bindings.js.map +1 -1
- package/dist/workflows/index.d.ts +5 -0
- package/dist/workflows/index.d.ts.map +1 -1
- package/dist/workflows/index.js +30 -1
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/primitives/index.d.ts +4 -0
- package/dist/workflows/primitives/index.d.ts.map +1 -0
- package/dist/workflows/primitives/index.js +20 -0
- package/dist/workflows/primitives/index.js.map +1 -0
- package/dist/workflows/primitives/retryUntilCondition.d.ts +39 -0
- package/dist/workflows/primitives/retryUntilCondition.d.ts.map +1 -0
- package/dist/workflows/primitives/retryUntilCondition.js +102 -0
- package/dist/workflows/primitives/retryUntilCondition.js.map +1 -0
- package/dist/workflows/primitives/sanitizer.d.ts +22 -0
- package/dist/workflows/primitives/sanitizer.d.ts.map +1 -0
- package/dist/workflows/primitives/sanitizer.js +96 -0
- package/dist/workflows/primitives/sanitizer.js.map +1 -0
- package/dist/workflows/primitives/validateWithRubric.d.ts +28 -0
- package/dist/workflows/primitives/validateWithRubric.d.ts.map +1 -0
- package/dist/workflows/primitives/validateWithRubric.js +148 -0
- package/dist/workflows/primitives/validateWithRubric.js.map +1 -0
- package/dist-esm/agent/index.js +5 -0
- package/dist-esm/agent/index.js.map +1 -0
- package/dist-esm/agent/intentInput.js +397 -0
- package/dist-esm/agent/intentInput.js.map +1 -0
- package/dist-esm/agent/toolMetadata.js +136 -0
- package/dist-esm/agent/toolMetadata.js.map +1 -0
- package/dist-esm/agent/turnAnalysis.js +147 -0
- package/dist-esm/agent/turnAnalysis.js.map +1 -0
- package/dist-esm/agent/turnPlan.js +180 -0
- package/dist-esm/agent/turnPlan.js.map +1 -0
- package/dist-esm/artifacts/graph.js +465 -0
- package/dist-esm/artifacts/graph.js.map +1 -0
- package/dist-esm/artifacts/index.js +3 -0
- package/dist-esm/artifacts/index.js.map +1 -0
- package/dist-esm/artifacts/queries.js +78 -0
- package/dist-esm/artifacts/queries.js.map +1 -0
- package/dist-esm/billing/index.js +3 -0
- package/dist-esm/billing/index.js.map +1 -0
- package/dist-esm/billing/spendGate.js +329 -0
- package/dist-esm/billing/spendGate.js.map +1 -0
- package/dist-esm/billing/workflowAuthorization.js +260 -0
- package/dist-esm/billing/workflowAuthorization.js.map +1 -0
- package/dist-esm/chatRun/costApproval.js +64 -0
- package/dist-esm/chatRun/costApproval.js.map +1 -0
- package/dist-esm/chatRun/index.js +372 -0
- package/dist-esm/chatRun/index.js.map +1 -0
- package/dist-esm/client/SogniClientWrapper.js +8 -5
- package/dist-esm/client/SogniClientWrapper.js.map +1 -1
- package/dist-esm/context/index.js +453 -0
- package/dist-esm/context/index.js.map +1 -0
- package/dist-esm/contracts/data/gatingPolicies.js +4 -4
- package/dist-esm/contracts/data/gatingPolicies.js.map +1 -1
- package/dist-esm/contracts/data/index.js +3 -3
- package/dist-esm/contracts/data/index.js.map +1 -1
- package/dist-esm/contracts/data/promptContracts.js +223 -44
- package/dist-esm/contracts/data/promptContracts.js.map +1 -1
- package/dist-esm/contracts/data/repairRecipes.js +2 -2
- package/dist-esm/contracts/data/repairRecipes.js.map +1 -1
- package/dist-esm/contracts/data/toolCatalog.js +2 -2
- package/dist-esm/contracts/data/toolCatalog.js.map +1 -1
- package/dist-esm/contracts/data/toolPermissions.js +2 -13
- package/dist-esm/contracts/data/toolPermissions.js.map +1 -1
- package/dist-esm/contracts/index.js +3 -3
- package/dist-esm/contracts/index.js.map +1 -1
- package/dist-esm/contracts/storyboard.js.map +1 -1
- package/dist-esm/contracts/toolGatingPolicy.js +6 -2
- package/dist-esm/contracts/toolGatingPolicy.js.map +1 -1
- package/dist-esm/contracts/toolSurface.js +11 -4
- package/dist-esm/contracts/toolSurface.js.map +1 -1
- package/dist-esm/contracts/turnPolicy.js +13 -0
- package/dist-esm/contracts/turnPolicy.js.map +1 -1
- package/dist-esm/events/index.js +2 -0
- package/dist-esm/events/index.js.map +1 -0
- package/dist-esm/events/runEvent.js +152 -0
- package/dist-esm/events/runEvent.js.map +1 -0
- package/dist-esm/index.js +13 -5
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/openai-tools/_manifests.generated.js +1789 -0
- package/dist-esm/openai-tools/_manifests.generated.js.map +1 -0
- package/dist-esm/openai-tools/app-tools.json +297 -0
- package/dist-esm/openai-tools/composition-tools.json +228 -0
- package/dist-esm/openai-tools/generation-tools.json +1263 -0
- package/dist-esm/openai-tools/index.js +27 -0
- package/dist-esm/openai-tools/index.js.map +1 -0
- package/dist-esm/public-skill-runtime/index.js +619 -156
- package/dist-esm/public-skill-runtime/index.js.map +1 -1
- package/dist-esm/schemas/agent/intent-input.schema.json +128 -0
- package/dist-esm/schemas/agent/turn-analysis.schema.json +75 -0
- package/dist-esm/schemas/artifacts/artifact-graph.schema.json +42 -0
- package/dist-esm/schemas/artifacts/artifact-node.schema.json +137 -0
- package/dist-esm/schemas/billing/spend-gate.schema.json +130 -0
- package/dist-esm/schemas/billing/workflow-authorization.schema.json +83 -0
- package/dist-esm/schemas/errors/error.schema.json +21 -0
- package/dist-esm/schemas/errors/repair-control.schema.json +40 -0
- package/dist-esm/schemas/events/artifact-reference.schema.json +22 -0
- package/dist-esm/schemas/events/progress-event.schema.json +28 -0
- package/dist-esm/schemas/events/run-event.schema.json +111 -0
- package/dist-esm/schemas/events/workflow-event.schema.json +22 -0
- package/dist-esm/schemas/prompt-contract.schema.json +42 -0
- package/dist-esm/schemas/storyboards/storyboard-planning-contract.schema.json +108 -0
- package/dist-esm/schemas/tools/add_subtitles.schema.json +77 -0
- package/dist-esm/schemas/tools/animate_photo.schema.json +104 -0
- package/dist-esm/schemas/tools/apply_style.schema.json +37 -0
- package/dist-esm/schemas/tools/change_angle.schema.json +30 -0
- package/dist-esm/schemas/tools/compose_instrumental.schema.json +24 -0
- package/dist-esm/schemas/tools/compose_lyrics.schema.json +28 -0
- package/dist-esm/schemas/tools/compose_script.schema.json +68 -0
- package/dist-esm/schemas/tools/compose_workflow.schema.json +67 -0
- package/dist-esm/schemas/tools/compose_workflow_template.schema.json +156 -0
- package/dist-esm/schemas/tools/dance_montage.schema.json +47 -0
- package/dist-esm/schemas/tools/edit_image.schema.json +74 -0
- package/dist-esm/schemas/tools/enhance_prompt.schema.json +76 -0
- package/dist-esm/schemas/tools/extend_video.schema.json +42 -0
- package/dist-esm/schemas/tools/generate_image.schema.json +104 -0
- package/dist-esm/schemas/tools/generate_music.schema.json +62 -0
- package/dist-esm/schemas/tools/generate_video.schema.json +97 -0
- package/dist-esm/schemas/tools/manage_memory.schema.json +28 -0
- package/dist-esm/schemas/tools/orbit_video.schema.json +70 -0
- package/dist-esm/schemas/tools/overlay_video.schema.json +126 -0
- package/dist-esm/schemas/tools/refine_result.schema.json +43 -0
- package/dist-esm/schemas/tools/replace_video_segment.schema.json +60 -0
- package/dist-esm/schemas/tools/resolve_personas.schema.json +15 -0
- package/dist-esm/schemas/tools/restore_photo.schema.json +47 -0
- package/dist-esm/schemas/tools/set_content_filter.schema.json +14 -0
- package/dist-esm/schemas/tools/sound_to_video.schema.json +70 -0
- package/dist-esm/schemas/tools/stitch_video.schema.json +52 -0
- package/dist-esm/schemas/tools/tool-metadata.schema.json +78 -0
- package/dist-esm/schemas/tools/video_to_video.schema.json +77 -0
- package/dist-esm/schemas/workflows/durable-workflow-run.schema.json +165 -0
- package/dist-esm/schemas/workflows/durable-workflow-step.schema.json +141 -0
- package/dist-esm/skill-runtime-source/crossSurfaceParity.js +469 -0
- package/dist-esm/skill-runtime-source/crossSurfaceParity.js.map +1 -0
- package/dist-esm/skill-runtime-source/index.js +4 -0
- package/dist-esm/skill-runtime-source/index.js.map +1 -0
- package/dist-esm/skill-runtime-source/seedanceAudioWindow.js +47 -0
- package/dist-esm/skill-runtime-source/seedanceAudioWindow.js.map +1 -0
- package/dist-esm/skill-runtime-source/workflowStatus.js +348 -0
- package/dist-esm/skill-runtime-source/workflowStatus.js.map +1 -0
- package/dist-esm/tools/definitions/animate-photo/definition.js +8 -8
- package/dist-esm/tools/definitions/animate-photo/definition.js.map +1 -1
- package/dist-esm/tools/definitions/edit-image/definition.js +3 -3
- package/dist-esm/tools/definitions/edit-image/definition.js.map +1 -1
- package/dist-esm/tools/definitions/generate-image/definition.js +4 -4
- package/dist-esm/tools/definitions/generate-image/definition.js.map +1 -1
- package/dist-esm/tools/definitions/generate-music/definition.js +2 -2
- package/dist-esm/tools/definitions/generate-music/definition.js.map +1 -1
- package/dist-esm/tools/definitions/generate-video/definition.js +2 -2
- package/dist-esm/tools/definitions/generate-video/definition.js.map +1 -1
- package/dist-esm/tools/definitions/replace-video-segment/definition.js +6 -5
- package/dist-esm/tools/definitions/replace-video-segment/definition.js.map +1 -1
- package/dist-esm/tools/definitions/sound-to-video/definition.js +2 -2
- package/dist-esm/tools/definitions/sound-to-video/definition.js.map +1 -1
- package/dist-esm/tools/definitions/stitch-video/definition.js +9 -22
- package/dist-esm/tools/definitions/stitch-video/definition.js.map +1 -1
- package/dist-esm/tools/index.js +5 -1
- package/dist-esm/tools/index.js.map +1 -1
- package/dist-esm/tools/normalizeArgs.js +82 -8
- package/dist-esm/tools/normalizeArgs.js.map +1 -1
- package/dist-esm/tools/shared/_catalogs.generated.js +10 -0
- package/dist-esm/tools/shared/_catalogs.generated.js.map +1 -0
- package/dist-esm/tools/shared/dynamicPromptBranches.js +183 -0
- package/dist-esm/tools/shared/dynamicPromptBranches.js.map +1 -0
- package/dist-esm/tools/shared/multiImageIntent.js +10 -0
- package/dist-esm/tools/shared/multiImageIntent.js.map +1 -0
- package/dist-esm/tools/shared/numberOfVariationsAlignment.js +34 -0
- package/dist-esm/tools/shared/numberOfVariationsAlignment.js.map +1 -0
- package/dist-esm/tools/shared/seedancePolicyErrors.js +13 -0
- package/dist-esm/tools/shared/seedancePolicyErrors.js.map +1 -1
- package/dist-esm/tools/shared/seedanceReferences.js +33 -0
- package/dist-esm/tools/shared/seedanceReferences.js.map +1 -0
- package/dist-esm/utils/helpers.js +8 -3
- package/dist-esm/utils/helpers.js.map +1 -1
- package/dist-esm/workflows/bindings.js +32 -2
- package/dist-esm/workflows/bindings.js.map +1 -1
- package/dist-esm/workflows/index.js +2 -0
- package/dist-esm/workflows/index.js.map +1 -1
- package/dist-esm/workflows/primitives/index.js +4 -0
- package/dist-esm/workflows/primitives/index.js.map +1 -0
- package/dist-esm/workflows/primitives/retryUntilCondition.js +95 -0
- package/dist-esm/workflows/primitives/retryUntilCondition.js.map +1 -0
- package/dist-esm/workflows/primitives/sanitizer.js +89 -0
- package/dist-esm/workflows/primitives/sanitizer.js.map +1 -0
- package/dist-esm/workflows/primitives/validateWithRubric.js +141 -0
- package/dist-esm/workflows/primitives/validateWithRubric.js.map +1 -0
- package/package.json +111 -4
- package/src/skill-runtime-source/crossSurfaceParity.ts +525 -0
- package/src/skill-runtime-source/index.ts +10 -0
- package/src/skill-runtime-source/seedanceAudioWindow.ts +61 -0
- package/src/skill-runtime-source/workflowStatus.ts +375 -0
- package/dist/contracts/index.mjs +0 -102
- package/dist/media/index.mjs +0 -116
- package/dist/public-skill-runtime/index.mjs +0 -141
- package/dist/replay/index.mjs +0 -12
- package/dist/runtime/index.mjs +0 -21
- package/dist/skills/asset_reference_management/index.mjs +0 -18
- package/dist/tools/index.mjs +0 -86
- package/dist/workflows/index.mjs +0 -22
package/README.md
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sogni-ai/sogni-intelligence-client
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@sogni-ai/sogni-intelligence-client) [](https://www.npmjs.com/package/@sogni-ai/sogni-intelligence-client)
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
9
|
+
## Which package should I install?
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
|
|
@@ -30,794 +21,239 @@ This library simplifies interaction with the Sogni AI Supernet by providing a pr
|
|
|
30
21
|
npm install @sogni-ai/sogni-intelligence-client
|
|
31
22
|
```
|
|
32
23
|
|
|
33
|
-
|
|
24
|
+
Requires Node.js ≥ 18.
|
|
34
25
|
|
|
35
|
-
|
|
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
|
+
## Package structure
|
|
108
27
|
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### 4. Run the Script
|
|
28
|
+
The package exposes the following subpath entry points so consumers import only what they need:
|
|
113
29
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
30
|
+
| Subpath | Purpose |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `@sogni-ai/sogni-intelligence-client` | `SogniClientWrapper` connection class + helpers + re‑exports from the underlying SDK |
|
|
33
|
+
| `…/contracts` | Public contracts, default policies, repair recipes, prompt contracts, schema registry |
|
|
34
|
+
| `…/tools` | Sogni‑hosted tool definitions and argument validators (image, video, audio, editing, analysis) |
|
|
35
|
+
| `…/replay` | `RunRecord` types + redaction utilities (signed URLs, JWTs, bearer tokens scrubbed) |
|
|
36
|
+
| `…/runtime` | Contract runtime — apply policies, recipes, and prompt contracts at call sites |
|
|
37
|
+
| `…/public-skill-runtime` | Skill‑side helpers: classify turns, compile tool surface, dispatch tool calls |
|
|
38
|
+
| `…/skills/asset_reference_management` | Asset‑reference resolution helpers for hosted media |
|
|
39
|
+
| `…/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) |
|
|
40
|
+
| `…/media` | Media reference helpers (upload / download URL flows) |
|
|
41
|
+
| `…/chatRun` | Durable hosted `ChatRun` contracts — state machine, events, cost‑approval types |
|
|
42
|
+
| `…/context` | Context‑window primitives — token accounting, message protection, summarization budgeting |
|
|
43
|
+
| `…/openai-tools` | OpenAI‑shaped tool manifests (`app-tools.json`, `composition-tools.json`, `generation-tools.json`) baked into TS so consumers can compile a tool surface without filesystem reads |
|
|
44
|
+
| `…/skill-runtime-source` | Cross‑surface parity helpers (workflow status, Seedance audio windows) shared with the private skill runtime |
|
|
45
|
+
| `…/schemas/*` | Raw JSON Schema artifacts for cross‑language codegen (Swift, Kotlin, Python, etc.) |
|
|
121
46
|
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
});
|
|
47
|
+
Each subpath ships dual CJS + ESM with TypeScript declarations.
|
|
143
48
|
|
|
144
|
-
|
|
145
|
-
```
|
|
49
|
+
## Quick start
|
|
146
50
|
|
|
147
|
-
###
|
|
51
|
+
### 1. Configure credentials
|
|
148
52
|
|
|
149
|
-
|
|
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
|
-
});
|
|
53
|
+
Create a `.env` in your project root:
|
|
159
54
|
|
|
160
|
-
|
|
55
|
+
```env
|
|
56
|
+
SOGNI_USERNAME=your-username
|
|
57
|
+
SOGNI_PASSWORD=your-password
|
|
58
|
+
SOGNI_APP_ID=your-app-id # optional; auto‑generated if omitted
|
|
59
|
+
SOGNI_NETWORK=fast # or "relaxed"
|
|
161
60
|
```
|
|
162
61
|
|
|
163
|
-
###
|
|
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
|
|
62
|
+
### 2. Image generation
|
|
174
63
|
|
|
175
64
|
```typescript
|
|
176
|
-
|
|
177
|
-
|
|
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:
|
|
65
|
+
import 'dotenv/config';
|
|
66
|
+
import { SogniClientWrapper } from '@sogni-ai/sogni-intelligence-client';
|
|
229
67
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
modelId: 'flux1-schnell-fp8',
|
|
234
|
-
positivePrompt: 'A beautiful sunset',
|
|
235
|
-
numberOfMedia: 1,
|
|
68
|
+
const client = new SogniClientWrapper({
|
|
69
|
+
username: process.env.SOGNI_USERNAME!,
|
|
70
|
+
password: process.env.SOGNI_PASSWORD!,
|
|
236
71
|
});
|
|
237
72
|
|
|
238
|
-
|
|
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
|
-
});
|
|
73
|
+
const model = await client.getMostPopularModel();
|
|
246
74
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
modelId:
|
|
250
|
-
positivePrompt: '
|
|
75
|
+
const result = await client.createProject({
|
|
76
|
+
type: 'image',
|
|
77
|
+
modelId: model.id,
|
|
78
|
+
positivePrompt: 'A photorealistic portrait of a majestic lion at sunset',
|
|
79
|
+
negativePrompt: 'blurry, cartoon, low quality',
|
|
80
|
+
stylePrompt: 'cinematic',
|
|
251
81
|
numberOfMedia: 1,
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
outputFormat: 'mp3',
|
|
82
|
+
steps: 30,
|
|
83
|
+
guidance: 8,
|
|
255
84
|
});
|
|
256
|
-
```
|
|
257
85
|
|
|
258
|
-
|
|
86
|
+
console.log(result.images.map((i) => i.url));
|
|
259
87
|
|
|
260
|
-
|
|
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);
|
|
88
|
+
await client.disconnect();
|
|
270
89
|
```
|
|
271
90
|
|
|
272
|
-
|
|
91
|
+
### 3. Tool calling against Sogni's hosted catalog
|
|
273
92
|
|
|
274
93
|
```typescript
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const
|
|
284
|
-
model: '
|
|
285
|
-
messages: [{ role: 'user', content: '
|
|
286
|
-
|
|
94
|
+
import {
|
|
95
|
+
SogniClientWrapper,
|
|
96
|
+
SogniTools,
|
|
97
|
+
isSogniToolCall,
|
|
98
|
+
} from '@sogni-ai/sogni-intelligence-client';
|
|
99
|
+
|
|
100
|
+
const client = new SogniClientWrapper({ /* … */ });
|
|
101
|
+
|
|
102
|
+
const chat = await client.chat.completions.create({
|
|
103
|
+
model: 'openai/gpt-oss-120b',
|
|
104
|
+
messages: [{ role: 'user', content: 'Generate a 3‑second clip of a koi pond.' }],
|
|
105
|
+
tools: SogniTools.all, // the full Sogni-hosted tool catalog
|
|
287
106
|
});
|
|
288
|
-
for await (const chunk of stream) {
|
|
289
|
-
process.stdout.write(chunk.content);
|
|
290
|
-
}
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
### Tool Calling (Function Calling)
|
|
294
|
-
|
|
295
|
-
`createChatCompletion()` accepts OpenAI-style `tools` and `tool_choice` parameters.
|
|
296
107
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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
|
-
}
|
|
108
|
+
const call = chat.choices[0].message.tool_calls?.[0];
|
|
109
|
+
if (call && isSogniToolCall(call.function.name)) {
|
|
110
|
+
// Hand the tool call off to Sogni's hosted execution surface, or
|
|
111
|
+
// dispatch it locally via /public-skill-runtime.
|
|
360
112
|
}
|
|
361
113
|
```
|
|
362
114
|
|
|
363
|
-
###
|
|
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()`
|
|
370
|
-
|
|
371
|
-
```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
|
-
});
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### Vision Chat and Thinking Mode
|
|
115
|
+
### 4. Replay a previous run with redaction
|
|
384
116
|
|
|
385
117
|
```typescript
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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);
|
|
118
|
+
import {
|
|
119
|
+
type RunRecord,
|
|
120
|
+
redactRunRecord,
|
|
121
|
+
redactPayload,
|
|
122
|
+
} from '@sogni-ai/sogni-intelligence-client/replay';
|
|
123
|
+
|
|
124
|
+
const safeRecord: RunRecord = redactRunRecord(originalRecord);
|
|
125
|
+
// Signed URLs, bearer tokens, JWTs, and inline secrets are scrubbed.
|
|
409
126
|
```
|
|
410
127
|
|
|
411
|
-
###
|
|
412
|
-
|
|
413
|
-
Useful for streaming or custom multi-round tool loops where you want the wrapper to execute returned Sogni tool calls directly.
|
|
128
|
+
### 5. Validate a hosted‑tool argument blob
|
|
414
129
|
|
|
415
130
|
```typescript
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
|
|
426
|
-
tokenType: 'spark',
|
|
427
|
-
onToolProgress: (toolCall, progress) => {
|
|
428
|
-
console.log(toolCall.function.name, progress.status, progress.percent);
|
|
429
|
-
},
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
console.log(toolResults);
|
|
433
|
-
}
|
|
131
|
+
import {
|
|
132
|
+
validateAndNormalizeHostedToolArguments,
|
|
133
|
+
} from '@sogni-ai/sogni-intelligence-client/contracts';
|
|
134
|
+
|
|
135
|
+
const { ok, value, error } = validateAndNormalizeHostedToolArguments(
|
|
136
|
+
'generate_image',
|
|
137
|
+
{ prompt: 'a serene koi pond', steps: 30 },
|
|
138
|
+
);
|
|
139
|
+
if (!ok) throw error;
|
|
140
|
+
// `value` is the normalized argument object ready to dispatch.
|
|
434
141
|
```
|
|
435
142
|
|
|
436
|
-
|
|
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`)
|
|
445
|
-
|
|
446
|
-
## Image Editing with Context Images
|
|
143
|
+
## Authentication
|
|
447
144
|
|
|
448
|
-
The wrapper
|
|
449
|
-
|
|
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
|
|
145
|
+
The wrapper accepts three authentication strategies through the `SogniClientConfig`:
|
|
458
146
|
|
|
459
147
|
```typescript
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
// Load your reference image(s)
|
|
463
|
-
const referenceImage = readFileSync('./my-image.png');
|
|
148
|
+
// Username/password
|
|
149
|
+
new SogniClientWrapper({ username, password });
|
|
464
150
|
|
|
465
|
-
//
|
|
466
|
-
|
|
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
|
-
});
|
|
151
|
+
// API key
|
|
152
|
+
new SogniClientWrapper({ apiKey });
|
|
474
153
|
|
|
475
|
-
|
|
154
|
+
// Token + cookies (typical for browser/edge contexts)
|
|
155
|
+
new SogniClientWrapper({ token, cookies });
|
|
476
156
|
```
|
|
477
157
|
|
|
478
|
-
|
|
158
|
+
Connection management, reconnection, and credit/balance polling are handled automatically. Call `client.disconnect()` when finished.
|
|
479
159
|
|
|
480
|
-
|
|
160
|
+
## Generation surfaces
|
|
481
161
|
|
|
482
|
-
|
|
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
|
-
```
|
|
496
|
-
|
|
497
|
-
### Multiple Angles LoRA (Qwen Image Edit)
|
|
498
|
-
|
|
499
|
-
```typescript
|
|
500
|
-
import { readFileSync } from 'fs';
|
|
162
|
+
The root wrapper exposes type‑safe project creation across every modality Sogni supports:
|
|
501
163
|
|
|
502
|
-
|
|
164
|
+
- **Image generation** — Stable Diffusion XL, Flux, full model marketplace.
|
|
165
|
+
- **Video generation** — WAN 2.2, LTX‑2.3, Seedance v2; workflows `t2v`, `i2v`, `s2v`, `ia2v`, `a2v`, `v2v`, `animate_move`, `animate_replace`.
|
|
166
|
+
- **Audio generation** — music and SFX models with cost estimation.
|
|
167
|
+
- **Image editing** — Qwen vision‑aware editors with multi‑reference context images.
|
|
168
|
+
- **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.
|
|
503
169
|
|
|
504
|
-
|
|
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
|
-
});
|
|
170
|
+
See the [SDK docs](https://sdk-docs.sogni.ai/) for full parameter references on each surface.
|
|
517
171
|
|
|
518
|
-
|
|
519
|
-
```
|
|
172
|
+
## Contracts, tools, and skills
|
|
520
173
|
|
|
521
|
-
|
|
174
|
+
Sogni's hosted tool surface — `generate_image`, `generate_video`, `analyze_video`, `replace_video_segment`, and 20+ others — is described declaratively. Consumers can:
|
|
522
175
|
|
|
523
|
-
|
|
176
|
+
- Enumerate the catalog: `import { SogniTools } from '@sogni-ai/sogni-intelligence-client'`.
|
|
177
|
+
- Validate / normalize arguments before dispatch: `validateAndNormalizeHostedToolArguments` from `/contracts`.
|
|
178
|
+
- Apply gating policies, repair recipes, and prompt contracts at runtime: `createPublicSkillDefaultContractRuntime` from `/public-skill-runtime`.
|
|
179
|
+
- Generate JSON Schema clients for other languages from `/schemas/*`.
|
|
524
180
|
|
|
525
|
-
- `
|
|
526
|
-
- `Blob` - Browser Blob object
|
|
527
|
-
- `File` - Browser File object
|
|
528
|
-
- `true` - Boolean indicating a pre-uploaded image
|
|
181
|
+
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.
|
|
529
182
|
|
|
530
|
-
|
|
183
|
+
## RunRecord replay & redaction
|
|
531
184
|
|
|
532
|
-
|
|
185
|
+
`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.
|
|
533
186
|
|
|
534
187
|
```typescript
|
|
535
|
-
import {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
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)
|
|
188
|
+
import {
|
|
189
|
+
type RunRecord,
|
|
190
|
+
type RunRecordRound,
|
|
191
|
+
type RunRecordToolCall,
|
|
192
|
+
type RunRecordToolResult,
|
|
193
|
+
emptyRunRecord,
|
|
194
|
+
redactRunRecord,
|
|
195
|
+
RUN_RECORD_SCHEMA_VERSION,
|
|
196
|
+
} from '@sogni-ai/sogni-intelligence-client/replay';
|
|
549
197
|
```
|
|
550
198
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
### `new SogniClientWrapper(config)`
|
|
554
|
-
|
|
555
|
-
Creates a new client instance.
|
|
199
|
+
`redactRunRecord` / `redactPayload` scrub signed URLs, bearer tokens, JWTs, and inline secrets — call them before persisting or logging records.
|
|
556
200
|
|
|
557
|
-
|
|
201
|
+
## Error handling
|
|
558
202
|
|
|
559
|
-
|
|
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. |
|
|
577
|
-
|
|
578
|
-
#### API Key Authentication Example
|
|
203
|
+
Errors are typed for precise dispatch:
|
|
579
204
|
|
|
580
205
|
```typescript
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
206
|
+
import {
|
|
207
|
+
SogniError,
|
|
208
|
+
SogniConnectionError,
|
|
209
|
+
SogniAuthenticationError,
|
|
210
|
+
SogniProjectError,
|
|
211
|
+
SogniTimeoutError,
|
|
212
|
+
SogniBalanceError,
|
|
213
|
+
SogniValidationError,
|
|
214
|
+
SogniConfigurationError,
|
|
215
|
+
SogniModelNotFoundError,
|
|
216
|
+
SogniNetworkError,
|
|
217
|
+
} from '@sogni-ai/sogni-intelligence-client';
|
|
586
218
|
```
|
|
587
219
|
|
|
588
|
-
|
|
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.
|
|
627
|
-
|
|
628
|
-
```typescript
|
|
629
|
-
import { ClientEvent } from '@sogni-ai/sogni-intelligence-client';
|
|
630
|
-
|
|
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
|
-
});
|
|
220
|
+
Each error carries `cause` and a typed `data` field where applicable.
|
|
645
221
|
|
|
646
|
-
|
|
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
|
-
});
|
|
222
|
+
## TypeScript & module formats
|
|
652
223
|
|
|
653
|
-
|
|
654
|
-
|
|
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
|
-
});
|
|
224
|
+
- Written in TypeScript; full `.d.ts` declarations ship for every subpath.
|
|
225
|
+
- Dual CJS + ESM builds (`require()` and `import` both work).
|
|
226
|
+
- `moduleResolution: 'node'` and `'bundler'` both supported; `'node16'` / `'nodenext'` consumers should prefer the `import` condition.
|
|
688
227
|
|
|
689
|
-
|
|
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
|
-
});
|
|
228
|
+
## Migrating from `@sogni-ai/sogni-client-wrapper`
|
|
696
229
|
|
|
697
|
-
|
|
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
|
-
});
|
|
230
|
+
If you previously installed `@sogni-ai/sogni-client-wrapper`, the import path is the only thing that changes:
|
|
706
231
|
|
|
707
|
-
|
|
232
|
+
```diff
|
|
233
|
+
- import { SogniClientWrapper } from '@sogni-ai/sogni-client-wrapper';
|
|
234
|
+
+ import { SogniClientWrapper } from '@sogni-ai/sogni-intelligence-client';
|
|
708
235
|
```
|
|
709
236
|
|
|
710
|
-
|
|
237
|
+
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.
|
|
711
238
|
|
|
712
|
-
|
|
239
|
+
## Related packages and docs
|
|
713
240
|
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
-
|
|
719
|
-
-
|
|
720
|
-
|
|
721
|
-
|
|
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
|
-
```
|
|
241
|
+
| | Where |
|
|
242
|
+
|---|---|
|
|
243
|
+
| **Intelligence Client docs** | https://sdk-docs.sogni.ai/our-superapps/sogni-sdk/intelligence-client/ |
|
|
244
|
+
| **Sogni Intelligence API** | https://sdk-docs.sogni.ai/sogni-intelligence/introduction/ |
|
|
245
|
+
| **`@sogni-ai/sogni-client`** (raw SDK) | [npm](https://www.npmjs.com/package/@sogni-ai/sogni-client) · [docs](https://sdk-docs.sogni.ai/) |
|
|
246
|
+
| **`@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) |
|
|
247
|
+
| **SogniKit** (Swift, regenerated from `/schemas/*.json`) | https://github.com/Sogni-AI/SogniKit |
|
|
248
|
+
| `@sogni/creative-agent` (private) | Server‑side orchestration, billing enforcement, persona management. Not on npm. |
|
|
736
249
|
|
|
737
250
|
## Testing
|
|
738
251
|
|
|
739
|
-
The library includes basic unit tests, example type-checking, and end-to-end tests.
|
|
740
|
-
|
|
741
|
-
### Running Tests
|
|
742
|
-
|
|
743
252
|
```bash
|
|
744
|
-
#
|
|
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
|
|
253
|
+
npm test # unit + type checks; no credentials required
|
|
254
|
+
npm run test:e2e # full end-to-end, requires SOGNI_USERNAME/SOGNI_PASSWORD in .env
|
|
758
255
|
```
|
|
759
256
|
|
|
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
257
|
## License
|
|
822
258
|
|
|
823
|
-
[
|
|
259
|
+
MIT — see [LICENSE](./LICENSE).
|