@sogni-ai/sogni-client 5.2.0 → 5.3.1
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/CHANGELOG.md +15 -0
- package/README.md +37 -0
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.d.ts +2 -1
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +2 -2
- package/dist/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/WebSocketClient/index.d.ts +3 -1
- package/dist/ApiClient/WebSocketClient/index.js +4 -1
- package/dist/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist/ApiClient/index.d.ts +10 -1
- package/dist/ApiClient/index.js +16 -3
- package/dist/ApiClient/index.js.map +1 -1
- package/dist/ApiGroup.d.ts +3 -0
- package/dist/ApiGroup.js +13 -0
- package/dist/ApiGroup.js.map +1 -1
- package/dist/Chat/ChatTools.js +2 -1
- package/dist/Chat/ChatTools.js.map +1 -1
- package/dist/Chat/_hostedToolsManifest.generated.js +16 -10
- package/dist/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist/Chat/index.d.ts +6 -0
- package/dist/Chat/index.js +35 -8
- package/dist/Chat/index.js.map +1 -1
- package/dist/Chat/types.d.ts +10 -1
- package/dist/CreativeWorkflows/index.js +4 -5
- package/dist/CreativeWorkflows/index.js.map +1 -1
- package/dist/CreativeWorkflows/types.d.ts +7 -0
- package/dist/Projects/createJobRequestMessage.js +3 -1
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.js +1 -1
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/index.d.ts +6 -0
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/RestClient.d.ts +3 -2
- package/dist/lib/RestClient.js +2 -3
- package/dist/lib/RestClient.js.map +1 -1
- package/dist/lib/attribution.d.ts +24 -0
- package/dist/lib/attribution.js +264 -0
- package/dist/lib/attribution.js.map +1 -0
- package/dist/types/attribution.d.ts +67 -0
- package/dist/types/attribution.js +3 -0
- package/dist/types/attribution.js.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +2 -2
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -1
- package/dist-esm/ApiClient/WebSocketClient/index.js +4 -1
- package/dist-esm/ApiClient/WebSocketClient/index.js.map +1 -1
- package/dist-esm/ApiClient/index.js +16 -3
- package/dist-esm/ApiClient/index.js.map +1 -1
- package/dist-esm/ApiGroup.js +13 -0
- package/dist-esm/ApiGroup.js.map +1 -1
- package/dist-esm/Chat/ChatTools.js +2 -1
- package/dist-esm/Chat/ChatTools.js.map +1 -1
- package/dist-esm/Chat/_hostedToolsManifest.generated.js +16 -10
- package/dist-esm/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist-esm/Chat/index.js +35 -8
- package/dist-esm/Chat/index.js.map +1 -1
- package/dist-esm/CreativeWorkflows/index.js +4 -5
- package/dist-esm/CreativeWorkflows/index.js.map +1 -1
- package/dist-esm/Projects/createJobRequestMessage.js +3 -1
- package/dist-esm/Projects/createJobRequestMessage.js.map +1 -1
- package/dist-esm/Projects/index.js +1 -1
- package/dist-esm/Projects/index.js.map +1 -1
- package/dist-esm/Projects/types/index.js.map +1 -1
- package/dist-esm/index.js +1 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/lib/RestClient.js +2 -3
- package/dist-esm/lib/RestClient.js.map +1 -1
- package/dist-esm/lib/attribution.js +257 -0
- package/dist-esm/lib/attribution.js.map +1 -0
- package/dist-esm/types/attribution.js +2 -0
- package/dist-esm/types/attribution.js.map +1 -0
- package/dist-esm/version.js +1 -1
- package/llms-full.txt +27 -0
- package/llms.txt +4 -0
- package/package.json +3 -2
- package/src/ApiClient/WebSocketClient/BrowserWebSocketClient/index.ts +5 -2
- package/src/ApiClient/WebSocketClient/index.ts +10 -1
- package/src/ApiClient/index.ts +42 -2
- package/src/ApiGroup.ts +25 -0
- package/src/Chat/ChatTools.ts +5 -1
- package/src/Chat/_hostedToolsManifest.generated.ts +16 -10
- package/src/Chat/index.ts +46 -7
- package/src/Chat/types.ts +10 -1
- package/src/CreativeWorkflows/index.ts +11 -3
- package/src/CreativeWorkflows/types.ts +7 -0
- package/src/Projects/createJobRequestMessage.ts +4 -1
- package/src/Projects/index.ts +2 -1
- package/src/Projects/types/index.ts +6 -0
- package/src/index.ts +35 -1
- package/src/lib/RestClient.ts +10 -3
- package/src/lib/attribution.ts +304 -0
- package/src/types/attribution.ts +89 -0
- package/src/version.ts +1 -1
|
@@ -12,7 +12,7 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
12
12
|
"type": "function",
|
|
13
13
|
"function": {
|
|
14
14
|
"name": "generate_image",
|
|
15
|
-
"description": "Generate a new image from a text description. Usually this is text-only: do NOT use this tool when the user expects an existing image to be reused or preserved in the result. That includes (a) people from My Personas, and (b) uploaded assets such as logos, brand marks, mascots, product shots, photos, screenshots, sketches, character designs, or other reference images they want carried through. Use edit_image with sourceImageIndex=-1 (or the appropriate generated index) instead. Exception: when the user explicitly requests Z-image, Z Image,
|
|
15
|
+
"description": "Generate a new image from a text description. Usually this is text-only: do NOT use this tool when the user expects an existing image to be reused or preserved in the result. That includes (a) people from My Personas, and (b) uploaded assets such as logos, brand marks, mascots, product shots, photos, screenshots, sketches, character designs, or other reference images they want carried through. Use edit_image with sourceImageIndex=-1 (or the appropriate generated index) instead. Exception: when the user explicitly requests Z-image, Z Image, Z-image Turbo, or Krea 2 Turbo for an uploaded-image enhancement/image-to-image request, use this tool with model=\"z-turbo\", model=\"z-image\", or model=\"krea-2-turbo\", sourceImageIndex=-1, and starting_image_strength because edit_image does not expose those base image-to-image models.",
|
|
16
16
|
"parameters": {
|
|
17
17
|
"type": "object",
|
|
18
18
|
"properties": {
|
|
@@ -27,7 +27,10 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
27
27
|
"z-turbo",
|
|
28
28
|
"z-image",
|
|
29
29
|
"krea-2-turbo",
|
|
30
|
+
"dark-beast-krea2",
|
|
31
|
+
"dark-beast-z-turbo",
|
|
30
32
|
"chroma-v46-flash",
|
|
33
|
+
"chroma1-hd",
|
|
31
34
|
"chroma-detail",
|
|
32
35
|
"flux1-krea",
|
|
33
36
|
"flux2",
|
|
@@ -36,6 +39,7 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
36
39
|
"qwen-2512-lightning",
|
|
37
40
|
"albedo-xl",
|
|
38
41
|
"animagine-xl",
|
|
42
|
+
"one-obsession-v22",
|
|
39
43
|
"anima-pencil-xl",
|
|
40
44
|
"art-universe-xl",
|
|
41
45
|
"hyphoria-real",
|
|
@@ -47,15 +51,15 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
47
51
|
"pony-faetality",
|
|
48
52
|
"dreamshaper-xl"
|
|
49
53
|
],
|
|
50
|
-
"description": "DO NOT SET THIS PARAMETER unless the user names a specific model, asks for a very complex image render, asks for a video storyboard/storyboard sheet/contact sheet/panel layout image, or explicitly asks for Z-image/Z-image Turbo image-to-image. The app auto-selects based on quality settings. Set \"gpt-image-2\" when the user asks for a ChatGPT, OpenAI, GPT, GPT-2, GPT Image, or gpt-image-2 image/model, when they explicitly request very strong text rendering, or by default for complex single-image renders that need dense labels, crisp typography, multi-panel composition, timing notes, foley notes, professional storyboard-sheet layout, or a comprehensive character/mascot/model sheet with turnarounds, expressions, accessories, palette swatches, and brand notes. Set \"z-turbo\" when the user asks for Z-image Turbo; set \"z-image\" when they ask for Z-image without Turbo. If the user names another image model, honor that requested model instead. A model preference usually does not change which tool to use; the Z-image image-to-image exception uses sourceImageIndex plus starting_image_strength on this tool. NSFW rule: \"gpt-image-2\"/\"flux2\"/\"flux1-krea\" CANNOT do nudity
|
|
54
|
+
"description": "DO NOT SET THIS PARAMETER unless the user names a specific model, asks for a very complex image render, asks for a video storyboard/storyboard sheet/contact sheet/panel layout image, asks for anime without naming a model, requests permitted NSFW/nudity content, or explicitly asks for Z-image/Z-image Turbo/Krea 2 Turbo image-to-image. The app auto-selects based on quality settings. Set \"gpt-image-2\" when the user asks for a ChatGPT, OpenAI, GPT, GPT-2, GPT Image, or gpt-image-2 image/model, when they explicitly request very strong text rendering, or by default for complex single-image renders that need dense labels, crisp typography, multi-panel composition, timing notes, foley notes, professional storyboard-sheet layout, or a comprehensive character/mascot/model sheet with turnarounds, expressions, accessories, palette swatches, and brand notes. Set \"one-obsession-v22\" when the user asks for an anime or anime-style image and has not named a specific image model. Set \"z-turbo\" when the user asks for Z-image Turbo; set \"z-image\" when they ask for Z-image without Turbo. Set \"krea-2-turbo\" when the user asks for Krea 2 Turbo. If the user names another image model, honor that requested model instead. A model preference usually does not change which tool to use; the Z-image and Krea 2 Turbo image-to-image exception uses sourceImageIndex plus starting_image_strength on this tool. NSFW rule: \"gpt-image-2\"/\"flux2\"/\"flux1-krea\"/Qwen image models CANNOT do nudity. For permitted NSFW/nudity content, prefer \"dark-beast-krea2\", then \"dark-beast-z-turbo\"; \"chroma1-hd\", \"pony-v7\", \"chroma-detail\", \"chroma-v46-flash\", and \"z-turbo\" are compatible fallbacks."
|
|
51
55
|
},
|
|
52
56
|
"width": {
|
|
53
57
|
"type": "number",
|
|
54
|
-
"description": "Output image width in pixels. Default: 1024. Supported
|
|
58
|
+
"description": "Output image width in pixels. Default: 1024. Supported bounds depend on the selected image model: Z-Image/Z-Image Turbo, Dark Beast Z-Image Turbo, Chroma, and legacy/specialized image models support 256-2048 on either edge; Krea 2 Turbo, Dark Beast KREA 2, and Qwen image models support 256-2560 on either edge; One Obsession v22 supports 256-1920 on either edge; Flux.2 uses a 2048x2048 total pixel budget (4,194,304 pixels) with non-square edges up to 2816, such as 1408x2816; GPT Image 2 supports flexible dimensions up to 3840px on either edge with max 3:1 aspect ratio and a total pixel budget from 655,360 to 8,294,400. Set when the user specifies a width, exact pixel dimensions, or a named resolution (e.g., \"1280 wide\", \"1280x720\", \"720p\", \"1080x1920\", \"3840x2160\"). If the user gives only one dimension, set only that dimension and preserve/infer the sensible aspect ratio. User-requested dimensions override the default media quality, including Pro. Non-multiple-of-16 values are accepted when in bounds; the renderer snaps to the nearest supported size internally, so do not ask the user to adjust by a few pixels."
|
|
55
59
|
},
|
|
56
60
|
"height": {
|
|
57
61
|
"type": "number",
|
|
58
|
-
"description": "Output image height in pixels. Default: 1024. Supported
|
|
62
|
+
"description": "Output image height in pixels. Default: 1024. Supported bounds depend on the selected image model: Z-Image/Z-Image Turbo, Dark Beast Z-Image Turbo, Chroma, and legacy/specialized image models support 256-2048 on either edge; Krea 2 Turbo, Dark Beast KREA 2, and Qwen image models support 256-2560 on either edge; One Obsession v22 supports 256-1920 on either edge; Flux.2 uses a 2048x2048 total pixel budget (4,194,304 pixels) with non-square edges up to 2816, such as 1408x2816; GPT Image 2 supports flexible dimensions up to 3840px on either edge with max 3:1 aspect ratio and a total pixel budget from 655,360 to 8,294,400. Set when the user specifies a height, exact pixel dimensions, or a named resolution (e.g., \"720 high\", \"1280x720\", \"720p\", \"1080x1920\", \"2160x3840\"). If the user gives only one dimension, set only that dimension and preserve/infer the sensible aspect ratio. User-requested dimensions override the default media quality, including Pro. Non-multiple-of-16 values are accepted when in bounds; the renderer snaps to the nearest supported size internally, so do not ask the user to adjust by a few pixels."
|
|
59
63
|
},
|
|
60
64
|
"numberOfVariations": {
|
|
61
65
|
"type": "number",
|
|
@@ -69,7 +73,7 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
69
73
|
},
|
|
70
74
|
"starting_image_strength": {
|
|
71
75
|
"type": "number",
|
|
72
|
-
"description": "Image-to-image strength (0.0-1.0). Only
|
|
76
|
+
"description": "Image-to-image source guidance strength (0.0-1.0). Only set when a source image is available and the model supports img2img. For Z-Image/Z-Image Turbo, Krea 2 Turbo, or source-preserving enhancement requests, use 0.75 with sourceImageIndex so the source image remains a strong guide while allowing higher-resolution reconstruction. Use lower values only when the user explicitly asks for a lighter guide/subtle variation; higher values are more creative and can deviate further from the source."
|
|
73
77
|
},
|
|
74
78
|
"sourceImageIndex": {
|
|
75
79
|
"type": "number",
|
|
@@ -282,7 +286,7 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
282
286
|
"type": "function",
|
|
283
287
|
"function": {
|
|
284
288
|
"name": "edit_image",
|
|
285
|
-
"description": "Generate images guided by reference photos. Supports GPT Image 2 up to 16 images, Flux.2 up to 6 images,
|
|
289
|
+
"description": "Generate images guided by reference photos. Supports GPT Image 2 up to 16 images, Flux.2 up to 6 images, Qwen up to 3 images, and Krea 2 Identity Edit / Dark Beast Krea 2 Identity Edit up to 2 images. Best for style-guided generation, combining elements from multiple images, ANY persona image creation, identity-preserving Krea edits, and any uploaded brand asset reuse — logos, brand marks, mascots, product shots, photos, screenshots, sketches, or character designs the user expects to appear in or guide the result. ALWAYS use this (never generate_image) when persona photos OR uploaded image assets meant for reuse are in context — even if a specific edit model is requested. Exception: explicit Z-image/Z-image Turbo/Krea 2 Turbo uploaded-image enhancement uses generate_image with sourceImageIndex and starting_image_strength because those base image-to-image models are not edit_image models. If a previous edit_image attempt did not preserve the uploaded asset well, stay on edit_image and tighten the prompt or switch model; generate_image has no access to the upload.",
|
|
286
290
|
"parameters": {
|
|
287
291
|
"type": "object",
|
|
288
292
|
"properties": {
|
|
@@ -296,9 +300,11 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
296
300
|
"gpt-image-2",
|
|
297
301
|
"qwen-lightning",
|
|
298
302
|
"qwen",
|
|
299
|
-
"flux2"
|
|
303
|
+
"flux2",
|
|
304
|
+
"krea-identity-edit",
|
|
305
|
+
"dark-beast-krea2-identity-edit"
|
|
300
306
|
],
|
|
301
|
-
"description": "
|
|
307
|
+
"description": "The app auto-selects Fast→Qwen Lightning, HQ→full Qwen, and Pro→Flux.2 only for ordinary identity-neutral edits. REQUIRED IDENTITY DEFAULT: set \"krea-identity-edit\" whenever an edit of a referenced person or character must keep likeness or character identity while changing clothing, hair or makeup, pose or position, face/head/body, background, lighting, or visual style. Infer that semantic intent in any language; never route from keyword or regex matching. Also use it for a non-Pro single-character sheet. This default applies even when the user did not name Krea; an explicitly requested model always wins. Set \"dark-beast-krea2-identity-edit\" only when the user explicitly requests that model, its uncensored/community variant, or dark_beast_krea2_identity_edit_v1_2. Set \"gpt-image-2\" when the user explicitly names GPT/OpenAI/ChatGPT Image, or when precise typography, dense labels, or a professional multi-panel layout is the primary requirement; Pro character sheets may retain GPT Image 2. If GPT Image 2 is unavailable for detail-critical layout work, fall back to full \"qwen\", never \"qwen-lightning\". Krea identity edit models require at least one reference image, accept up to two context images, and work best at 512-2048px. Let the model tier and worker choose current steps, guidance, sampler, scheduler, grounding, and reference-boost defaults; do not send a negative prompt. When Krea is selected, override the generic prompt-length guidance with a concise 1-4 sentence delta instruction; name only the requested change and details that must remain fixed. Put the base scene/image first and an optional person/detail reference second. Z-image, Z-image Turbo, and base Krea 2 Turbo are generate_image img2img models, not edit_image selectors. If the user names another edit/image model, honor it. GPT Image 2 always processes input images at high fidelity; do not set input_fidelity."
|
|
302
308
|
},
|
|
303
309
|
"sourceImageIndex": {
|
|
304
310
|
"type": "number",
|
|
@@ -312,11 +318,11 @@ export const SOGNI_HOSTED_TOOLS_MANIFEST: unknown = {
|
|
|
312
318
|
},
|
|
313
319
|
"width": {
|
|
314
320
|
"type": "number",
|
|
315
|
-
"description": "Output image width in pixels. Defaults to the context image width. Supported
|
|
321
|
+
"description": "Output image width in pixels. Defaults to the context image width. Supported bounds depend on the selected edit model: Qwen edit models support 256-2560 on either edge; Krea 2 Identity Edit and Dark Beast Krea 2 Identity Edit work best from 512-2048 on either edge; Flux.2 uses a 2048x2048 total pixel budget (4,194,304 pixels) with non-square edges up to 2816, such as 1408x2816; GPT Image 2 supports flexible dimensions up to 3840px on either edge with max 3:1 aspect ratio and a total pixel budget from 655,360 to 8,294,400. Set when the user specifies a width, exact pixel dimensions, or a named resolution (e.g., \"1280 wide\", \"1280x720\", \"720p\", \"3840x2160\"). If the user gives only one dimension, set only that dimension and preserve/infer the sensible aspect ratio. User-requested dimensions override the default media quality, including Pro. Non-multiple-of-16 values are accepted when in bounds; the renderer snaps to the nearest supported size internally, so do not ask the user to adjust by a few pixels."
|
|
316
322
|
},
|
|
317
323
|
"height": {
|
|
318
324
|
"type": "number",
|
|
319
|
-
"description": "Output image height in pixels. Defaults to the context image height. Supported
|
|
325
|
+
"description": "Output image height in pixels. Defaults to the context image height. Supported bounds depend on the selected edit model: Qwen edit models support 256-2560 on either edge; Krea 2 Identity Edit and Dark Beast Krea 2 Identity Edit work best from 512-2048 on either edge; Flux.2 uses a 2048x2048 total pixel budget (4,194,304 pixels) with non-square edges up to 2816, such as 1408x2816; GPT Image 2 supports flexible dimensions up to 3840px on either edge with max 3:1 aspect ratio and a total pixel budget from 655,360 to 8,294,400. Set when the user specifies a height, exact pixel dimensions, or a named resolution (e.g., \"720 high\", \"1280x720\", \"720p\", \"2160x3840\"). If the user gives only one dimension, set only that dimension and preserve/infer the sensible aspect ratio. User-requested dimensions override the default media quality, including Pro. Non-multiple-of-16 values are accepted when in bounds; the renderer snaps to the nearest supported size internally, so do not ask the user to adjust by a few pixels."
|
|
320
326
|
},
|
|
321
327
|
"aspectRatio": {
|
|
322
328
|
"type": "string",
|
package/src/Chat/index.ts
CHANGED
|
@@ -34,6 +34,8 @@ import {
|
|
|
34
34
|
import getUUID from '../lib/getUUID.js';
|
|
35
35
|
import type ProjectsApi from '../Projects/index.js';
|
|
36
36
|
import { mediaInputToInlineDataUri } from '../lib/mediaValidation.js';
|
|
37
|
+
import { workloadAttributionToWireFields } from '../lib/attribution.js';
|
|
38
|
+
import type { WorkloadAttributionInput } from '../types/attribution.js';
|
|
37
39
|
|
|
38
40
|
const MAX_VISION_IMAGE_COUNT = 20;
|
|
39
41
|
const MAX_VISION_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
@@ -510,13 +512,15 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
510
512
|
const normalizedMessages = await normalizeVisionMessages(params.messages);
|
|
511
513
|
const chatTemplateKwargs =
|
|
512
514
|
params.chat_template_kwargs ?? this.buildChatTemplateKwargs(params.think);
|
|
515
|
+
const appSource = params.app_source ?? params.appSource ?? this.client.appSource;
|
|
516
|
+
const attributionHeaders = this.attributionHeaders(appSource, params.attribution, getUUID());
|
|
513
517
|
try {
|
|
514
518
|
return await this.client.rest.post<HostedChatCompletionResult>(
|
|
515
519
|
'/v1/chat/completions',
|
|
516
520
|
{
|
|
517
521
|
model: params.model,
|
|
518
522
|
messages: normalizedMessages,
|
|
519
|
-
app_source:
|
|
523
|
+
app_source: appSource,
|
|
520
524
|
max_tokens: params.max_tokens,
|
|
521
525
|
temperature: params.temperature,
|
|
522
526
|
top_p: params.top_p,
|
|
@@ -541,7 +545,7 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
541
545
|
...(chatTemplateKwargs && { chat_template_kwargs: chatTemplateKwargs }),
|
|
542
546
|
...(params.response_format && { response_format: params.response_format })
|
|
543
547
|
},
|
|
544
|
-
{ timeoutMs: 300000 }
|
|
548
|
+
{ timeoutMs: 300000, headers: attributionHeaders }
|
|
545
549
|
);
|
|
546
550
|
} catch (error) {
|
|
547
551
|
// Re-throw recognized chat-job error bodies (e.g. subscription
|
|
@@ -569,18 +573,22 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
569
573
|
private async executeHostedTool(
|
|
570
574
|
params: HostedToolExecutionParams
|
|
571
575
|
): Promise<HostedToolExecutionResult> {
|
|
576
|
+
const appSource = params.app_source ?? params.appSource ?? this.client.appSource;
|
|
572
577
|
return this.client.rest.post<HostedToolExecutionResult>(
|
|
573
578
|
'/v1/creative-agent/tools/execute',
|
|
574
579
|
{
|
|
575
580
|
tool: params.tool,
|
|
576
581
|
arguments: params.arguments,
|
|
577
|
-
app_source:
|
|
582
|
+
app_source: appSource,
|
|
578
583
|
token_type: params.token_type ?? params.tokenType,
|
|
579
584
|
...(params.safe_content_filter !== undefined || params.safeContentFilter !== undefined
|
|
580
585
|
? { safe_content_filter: params.safe_content_filter ?? params.safeContentFilter }
|
|
581
586
|
: {})
|
|
582
587
|
},
|
|
583
|
-
{
|
|
588
|
+
{
|
|
589
|
+
timeoutMs: 300000,
|
|
590
|
+
headers: this.attributionHeaders(appSource, params.attribution, getUUID())
|
|
591
|
+
}
|
|
584
592
|
);
|
|
585
593
|
}
|
|
586
594
|
|
|
@@ -633,6 +641,7 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
633
641
|
private async createChatRun(params: StartChatRunParams): Promise<ChatRunRecord> {
|
|
634
642
|
assertChatRunUsesExternalMedia(params);
|
|
635
643
|
const appSource = params.appSource ?? this.client.appSource;
|
|
644
|
+
const operationId = getUUID();
|
|
636
645
|
const body: Record<string, unknown> = {
|
|
637
646
|
messages: params.messages,
|
|
638
647
|
...(params.tools ? { tools: params.tools } : {}),
|
|
@@ -652,7 +661,10 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
652
661
|
...(appSource ? { app_source: appSource } : {}),
|
|
653
662
|
...(params.runtimeConfig ? { runtime_config: params.runtimeConfig } : {})
|
|
654
663
|
};
|
|
655
|
-
const headers: Record<string, string> = {
|
|
664
|
+
const headers: Record<string, string> = {
|
|
665
|
+
'Content-Type': 'application/json',
|
|
666
|
+
...this.attributionHeaders(appSource, params.attribution, operationId)
|
|
667
|
+
};
|
|
656
668
|
if (params.idempotencyKey) headers['Idempotency-Key'] = params.idempotencyKey;
|
|
657
669
|
const response = await this.chatRunJson<{
|
|
658
670
|
status: string;
|
|
@@ -828,7 +840,8 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
828
840
|
sogni_tool_execution: params.sogni_tool_execution,
|
|
829
841
|
taskProfile: params.taskProfile,
|
|
830
842
|
...(chatTemplateKwargs && { chat_template_kwargs: chatTemplateKwargs }),
|
|
831
|
-
...(params.response_format && { response_format: params.response_format })
|
|
843
|
+
...(params.response_format && { response_format: params.response_format }),
|
|
844
|
+
...workloadAttributionToWireFields(this.resolveWorkloadAttribution(params.attribution, jobID))
|
|
832
845
|
};
|
|
833
846
|
|
|
834
847
|
const stream = new ChatStream(jobID);
|
|
@@ -891,13 +904,18 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
891
904
|
const maxRounds = params.maxToolRounds || 5;
|
|
892
905
|
const toolHistory: ToolHistoryEntry[] = [];
|
|
893
906
|
let messages = [...params.messages];
|
|
907
|
+
const logicalOperation = this.resolveWorkloadAttribution(params.attribution, getUUID());
|
|
908
|
+
const autoToolChildAttribution = this.createAutoToolChildAttribution(logicalOperation);
|
|
894
909
|
|
|
895
910
|
for (let round = 0; round < maxRounds; round++) {
|
|
896
911
|
const result = (await this.createSingleCompletion({
|
|
897
912
|
...params,
|
|
898
913
|
messages,
|
|
899
914
|
stream: false,
|
|
900
|
-
autoExecuteTools: false
|
|
915
|
+
autoExecuteTools: false,
|
|
916
|
+
// The first LLM admission represents the logical auto-tool request.
|
|
917
|
+
// Later rounds and tool/media work are compute children of that root.
|
|
918
|
+
attribution: round === 0 ? logicalOperation : autoToolChildAttribution
|
|
901
919
|
})) as ChatCompletionResult;
|
|
902
920
|
|
|
903
921
|
// If model didn't request tools, return final result
|
|
@@ -911,6 +929,7 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
911
929
|
// Execute tool calls
|
|
912
930
|
const toolResults = await this.tools.executeAll(result.tool_calls, {
|
|
913
931
|
tokenType: params.tokenType,
|
|
932
|
+
attribution: autoToolChildAttribution,
|
|
914
933
|
onToolCall: params.onToolCall,
|
|
915
934
|
onToolProgress: params.onToolProgress
|
|
916
935
|
});
|
|
@@ -942,6 +961,26 @@ class ChatApi extends ApiGroup<ChatApiEvents> {
|
|
|
942
961
|
throw new Error(`Max tool calling rounds (${maxRounds}) exceeded`);
|
|
943
962
|
}
|
|
944
963
|
|
|
964
|
+
/**
|
|
965
|
+
* Build attribution for compute spawned by one logical auto-tool operation.
|
|
966
|
+
* Each child receives its own transport operation ID while retaining the
|
|
967
|
+
* logical operation as its immediate parent.
|
|
968
|
+
*/
|
|
969
|
+
private createAutoToolChildAttribution(
|
|
970
|
+
attribution: WorkloadAttributionInput | undefined
|
|
971
|
+
): WorkloadAttributionInput | undefined {
|
|
972
|
+
const logicalOperation = this.resolveWorkloadAttribution(attribution, getUUID());
|
|
973
|
+
if (!logicalOperation?.operationId) return undefined;
|
|
974
|
+
const rootOperationId = logicalOperation.rootOperationId ?? logicalOperation.operationId;
|
|
975
|
+
return {
|
|
976
|
+
...logicalOperation,
|
|
977
|
+
operationScope: 'child',
|
|
978
|
+
operationId: undefined,
|
|
979
|
+
rootOperationId,
|
|
980
|
+
parentOperationId: logicalOperation.operationId
|
|
981
|
+
};
|
|
982
|
+
}
|
|
983
|
+
|
|
945
984
|
private handleJobTokens(data: JobTokensData): void {
|
|
946
985
|
const stream = this.activeStreams.get(data.jobID);
|
|
947
986
|
if (!stream) return;
|
package/src/Chat/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BillingMode } from '../Projects/types/index.js';
|
|
2
|
+
import type { WorkloadAttributionInput } from '../types/attribution.js';
|
|
2
3
|
|
|
3
4
|
export interface ToolFunction {
|
|
4
5
|
name: string;
|
|
@@ -96,6 +97,8 @@ export interface ChatCompletionParams {
|
|
|
96
97
|
messages: ChatMessage[];
|
|
97
98
|
/** Optional source label for this request. Defaults to the client appSource when configured. */
|
|
98
99
|
appSource?: string;
|
|
100
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
101
|
+
attribution?: WorkloadAttributionInput;
|
|
99
102
|
max_tokens?: number;
|
|
100
103
|
temperature?: number;
|
|
101
104
|
top_p?: number;
|
|
@@ -181,7 +184,7 @@ export interface ChatCompletionParams {
|
|
|
181
184
|
maxToolRounds?: number;
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
export interface ChatRequestMessage {
|
|
187
|
+
export interface ChatRequestMessage extends WorkloadAttributionInput {
|
|
185
188
|
jobID: string;
|
|
186
189
|
type: 'llm';
|
|
187
190
|
model: string;
|
|
@@ -295,6 +298,8 @@ export interface HostedToolExecutionParams {
|
|
|
295
298
|
app_source?: string;
|
|
296
299
|
/** camelCase alias for {@link HostedToolExecutionParams.app_source}. */
|
|
297
300
|
appSource?: string;
|
|
301
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
302
|
+
attribution?: WorkloadAttributionInput;
|
|
298
303
|
/** Token type to use for hosted REST billing. */
|
|
299
304
|
token_type?: 'sogni' | 'spark' | 'auto';
|
|
300
305
|
/** camelCase alias for {@link HostedToolExecutionParams.token_type}. */
|
|
@@ -457,6 +462,8 @@ export interface StartChatRunParams {
|
|
|
457
462
|
billingMode?: BillingMode;
|
|
458
463
|
/** Optional source label for attribution. Defaults to the client appSource when configured. */
|
|
459
464
|
appSource?: string;
|
|
465
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
466
|
+
attribution?: WorkloadAttributionInput;
|
|
460
467
|
/** Idempotency key (also accepted via `Idempotency-Key` header). */
|
|
461
468
|
idempotencyKey?: string;
|
|
462
469
|
/**
|
|
@@ -647,6 +654,8 @@ export interface ToolExecutionOptions {
|
|
|
647
654
|
network?: 'fast' | 'relaxed';
|
|
648
655
|
/** Number of media items to generate per tool call. Default: 1. */
|
|
649
656
|
numberOfMedia?: number;
|
|
657
|
+
/** Optional workload attribution for media projects executed by the tool. */
|
|
658
|
+
attribution?: WorkloadAttributionInput;
|
|
650
659
|
/** Progress callback fired during media generation. */
|
|
651
660
|
onProgress?: (progress: ToolExecutionProgress) => void;
|
|
652
661
|
/**
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
StartCreativeWorkflowParams,
|
|
17
17
|
StreamCreativeWorkflowEventsOptions
|
|
18
18
|
} from './types.js';
|
|
19
|
+
import getUUID from '../lib/getUUID.js';
|
|
19
20
|
|
|
20
21
|
interface CreativeWorkflowEnvelope {
|
|
21
22
|
workflow?: CreativeWorkflowRecord;
|
|
@@ -187,7 +188,8 @@ class CreativeWorkflowsApi extends ApiGroup {
|
|
|
187
188
|
if (mediaReferences !== undefined) body.media_references = mediaReferences;
|
|
188
189
|
|
|
189
190
|
const headers: Record<string, string> = {
|
|
190
|
-
'Content-Type': 'application/json'
|
|
191
|
+
'Content-Type': 'application/json',
|
|
192
|
+
...this.attributionHeaders(appSource, params.attribution, getUUID())
|
|
191
193
|
};
|
|
192
194
|
if (idempotencyKey) {
|
|
193
195
|
headers['Idempotency-Key'] = idempotencyKey;
|
|
@@ -226,7 +228,10 @@ class CreativeWorkflowsApi extends ApiGroup {
|
|
|
226
228
|
`/v1/creative-agent/workflows/${encodeURIComponent(workflowId)}/resume`,
|
|
227
229
|
{
|
|
228
230
|
method: 'POST',
|
|
229
|
-
headers: {
|
|
231
|
+
headers: {
|
|
232
|
+
'Content-Type': 'application/json',
|
|
233
|
+
...this.attributionHeaders(appSource, params.attribution, getUUID())
|
|
234
|
+
},
|
|
230
235
|
body: JSON.stringify(body),
|
|
231
236
|
signal: options.signal
|
|
232
237
|
}
|
|
@@ -261,7 +266,10 @@ class CreativeWorkflowsApi extends ApiGroup {
|
|
|
261
266
|
`/v1/creative-agent/workflows/${encodeURIComponent(workflowId)}/reseed`,
|
|
262
267
|
{
|
|
263
268
|
method: 'POST',
|
|
264
|
-
headers: {
|
|
269
|
+
headers: {
|
|
270
|
+
'Content-Type': 'application/json',
|
|
271
|
+
...this.attributionHeaders(appSource, params.attribution, getUUID())
|
|
272
|
+
},
|
|
265
273
|
body: JSON.stringify(body),
|
|
266
274
|
signal: options.signal
|
|
267
275
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { TokenType } from '../types/token.js';
|
|
2
2
|
import type { BillingMode } from '../Projects/types/index.js';
|
|
3
|
+
import type { WorkloadAttributionInput } from '../types/attribution.js';
|
|
3
4
|
|
|
4
5
|
export type CreativeWorkflowStatus =
|
|
5
6
|
| 'queued'
|
|
@@ -144,6 +145,8 @@ export interface StartCreativeWorkflowParams {
|
|
|
144
145
|
billingMode?: BillingMode;
|
|
145
146
|
/** Optional source label for attribution. Defaults to the client appSource when configured. */
|
|
146
147
|
appSource?: string;
|
|
148
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
149
|
+
attribution?: WorkloadAttributionInput;
|
|
147
150
|
idempotencyKey?: string;
|
|
148
151
|
/** Durable workflows require uploaded HTTP(S) URLs, not inline data URIs. */
|
|
149
152
|
mediaReferences?: unknown[];
|
|
@@ -174,6 +177,8 @@ export interface ResumeCreativeWorkflowParams {
|
|
|
174
177
|
billingMode?: BillingMode;
|
|
175
178
|
/** Optional source label for attribution. Defaults to the client appSource when configured. */
|
|
176
179
|
appSource?: string;
|
|
180
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
181
|
+
attribution?: WorkloadAttributionInput;
|
|
177
182
|
/** @internal Undocumented compatibility alias. Use tokenType. */
|
|
178
183
|
token_type?: TokenType;
|
|
179
184
|
/** @internal Undocumented compatibility alias. Use billingMode. */
|
|
@@ -203,6 +208,8 @@ export interface ReseedCreativeWorkflowParams {
|
|
|
203
208
|
billingMode?: BillingMode;
|
|
204
209
|
/** Optional source label for attribution. Defaults to the client appSource when configured. */
|
|
205
210
|
appSource?: string;
|
|
211
|
+
/** Optional workload attribution overriding this client's defaults. */
|
|
212
|
+
attribution?: WorkloadAttributionInput;
|
|
206
213
|
/** @internal Undocumented compatibility alias. Use seedOverrides. */
|
|
207
214
|
seed_overrides?: Record<string, number>;
|
|
208
215
|
/** @internal Undocumented compatibility alias. Use tokenType. */
|
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
ModelOptions,
|
|
44
44
|
VideoModelOptions
|
|
45
45
|
} from './types/ModelOptions.js';
|
|
46
|
+
import { workloadAttributionToWireFields } from '../lib/attribution.js';
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Validate that the provided assets match the workflow requirements.
|
|
@@ -735,7 +736,9 @@ function createJobRequestMessage(id: string, params: ProjectParams, options: Mod
|
|
|
735
736
|
tokenType: params.tokenType,
|
|
736
737
|
billingMode: params.billingMode,
|
|
737
738
|
outputFormat:
|
|
738
|
-
params.outputFormat ||
|
|
739
|
+
params.outputFormat ||
|
|
740
|
+
(isAudioParams(params) ? 'mp3' : isVideoParams(params) ? 'mp4' : 'png'),
|
|
741
|
+
...workloadAttributionToWireFields(params.attribution)
|
|
739
742
|
};
|
|
740
743
|
|
|
741
744
|
if (params.network) {
|
package/src/Projects/index.ts
CHANGED
|
@@ -667,7 +667,8 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
667
667
|
const modelOptions = await this.getModelOptions(data.modelId);
|
|
668
668
|
const requestParams = {
|
|
669
669
|
...data,
|
|
670
|
-
appSource: data.appSource || this.client.appSource
|
|
670
|
+
appSource: data.appSource || this.client.appSource,
|
|
671
|
+
attribution: this.resolveWorkloadAttribution(data.attribution, project.id)
|
|
671
672
|
} as ProjectParams;
|
|
672
673
|
const request = createJobRequestMessage(project.id, requestParams, modelOptions);
|
|
673
674
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SupernetType } from '../../ApiClient/WebSocketClient/types.js';
|
|
2
2
|
import { ControlNetParams, VideoControlNetParams } from './ControlNetParams.js';
|
|
3
3
|
import { TokenType } from '../../types/token.js';
|
|
4
|
+
import type { WorkloadAttributionInput } from '../../types/attribution.js';
|
|
4
5
|
|
|
5
6
|
export interface SupportedModel {
|
|
6
7
|
id: string;
|
|
@@ -99,6 +100,11 @@ export interface BaseProjectParams {
|
|
|
99
100
|
* Optional client app/source label to attach to the project request for server-side attribution.
|
|
100
101
|
*/
|
|
101
102
|
appSource?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Optional workload attribution for this project. Fields override the
|
|
105
|
+
* immutable defaults configured on SogniClient.
|
|
106
|
+
*/
|
|
107
|
+
attribution?: WorkloadAttributionInput;
|
|
102
108
|
/**
|
|
103
109
|
* LoRA IDs to apply, in the order they should be chained.
|
|
104
110
|
*
|
package/src/index.ts
CHANGED
|
@@ -176,6 +176,20 @@ import {
|
|
|
176
176
|
TokenAuthManager
|
|
177
177
|
} from './lib/AuthManager/index.js';
|
|
178
178
|
import { MeData } from './Account/types.js';
|
|
179
|
+
import type {
|
|
180
|
+
AgentAttributionMetadata,
|
|
181
|
+
AgentSurface,
|
|
182
|
+
ConnectionAttribution,
|
|
183
|
+
ExecutionMode,
|
|
184
|
+
InteractionKind,
|
|
185
|
+
OperationLineage,
|
|
186
|
+
OperationScope,
|
|
187
|
+
SogniAttributionConfig,
|
|
188
|
+
WorkloadAttribution,
|
|
189
|
+
WorkloadAttributionDefaults,
|
|
190
|
+
WorkloadAttributionInput,
|
|
191
|
+
WorkloadKind
|
|
192
|
+
} from './types/attribution.js';
|
|
179
193
|
|
|
180
194
|
export type {
|
|
181
195
|
AudioFormat,
|
|
@@ -313,7 +327,19 @@ export type {
|
|
|
313
327
|
RawProject,
|
|
314
328
|
ToastMessage,
|
|
315
329
|
DataEntity,
|
|
316
|
-
InputMedia
|
|
330
|
+
InputMedia,
|
|
331
|
+
AgentAttributionMetadata,
|
|
332
|
+
AgentSurface,
|
|
333
|
+
ConnectionAttribution,
|
|
334
|
+
ExecutionMode,
|
|
335
|
+
InteractionKind,
|
|
336
|
+
OperationLineage,
|
|
337
|
+
OperationScope,
|
|
338
|
+
SogniAttributionConfig,
|
|
339
|
+
WorkloadAttribution,
|
|
340
|
+
WorkloadAttributionDefaults,
|
|
341
|
+
WorkloadAttributionInput,
|
|
342
|
+
WorkloadKind
|
|
317
343
|
};
|
|
318
344
|
|
|
319
345
|
export {
|
|
@@ -346,6 +372,13 @@ export interface SogniClientConfig {
|
|
|
346
372
|
* The socket server uses this as the default source for project and chat requests from this client.
|
|
347
373
|
*/
|
|
348
374
|
appSource?: string;
|
|
375
|
+
/**
|
|
376
|
+
* Optional immutable connection and per-workload attribution defaults.
|
|
377
|
+
*
|
|
378
|
+
* Individual project, chat, tool, and workflow calls can override workload
|
|
379
|
+
* fields without mutating other concurrent requests.
|
|
380
|
+
*/
|
|
381
|
+
attribution?: SogniAttributionConfig;
|
|
349
382
|
/**
|
|
350
383
|
* Initial WebSocket event subscriptions for this connection.
|
|
351
384
|
*
|
|
@@ -538,6 +571,7 @@ export class SogniClient {
|
|
|
538
571
|
socketUrl: socketEndpoint,
|
|
539
572
|
appId: config.appId,
|
|
540
573
|
appSource: config.appSource,
|
|
574
|
+
attribution: config.attribution,
|
|
541
575
|
socketEventSubscriptions: config.socketEventSubscriptions,
|
|
542
576
|
networkType: network,
|
|
543
577
|
logger,
|
package/src/lib/RestClient.ts
CHANGED
|
@@ -8,6 +8,11 @@ interface RestRequestInit extends RequestInit {
|
|
|
8
8
|
timeoutMs?: number;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
interface RestPostOptions {
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
headers?: Record<string, string>;
|
|
14
|
+
}
|
|
15
|
+
|
|
11
16
|
class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
|
|
12
17
|
readonly baseUrl: string;
|
|
13
18
|
protected _auth: AuthManager;
|
|
@@ -120,15 +125,17 @@ class RestClient<E extends EventMap = never> extends TypedEventEmitter<E> {
|
|
|
120
125
|
post<T = JSONValue>(
|
|
121
126
|
path: string,
|
|
122
127
|
body: Record<string, unknown> = {},
|
|
123
|
-
options:
|
|
128
|
+
options: RestPostOptions = {}
|
|
124
129
|
): Promise<T> {
|
|
130
|
+
const { headers = {}, ...requestOptions } = options;
|
|
125
131
|
return this.request<T>(this.formatUrl(path), {
|
|
126
132
|
method: 'POST',
|
|
127
133
|
headers: {
|
|
128
|
-
'Content-Type': 'application/json'
|
|
134
|
+
'Content-Type': 'application/json',
|
|
135
|
+
...headers
|
|
129
136
|
},
|
|
130
137
|
body: JSON.stringify(body),
|
|
131
|
-
...
|
|
138
|
+
...requestOptions
|
|
132
139
|
});
|
|
133
140
|
}
|
|
134
141
|
}
|