@sogni-ai/sogni-client 4.2.0-alpha.21 → 4.2.0-alpha.22
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 +7 -0
- package/CLAUDE.md +7 -0
- package/README.md +45 -25
- package/dist/Chat/ChatTools.js +30 -16
- package/dist/Chat/ChatTools.js.map +1 -1
- package/dist/Chat/hostedToolValidation.generated.d.ts +46 -0
- package/dist/Chat/hostedToolValidation.generated.js +306 -0
- package/dist/Chat/hostedToolValidation.generated.js.map +1 -0
- package/dist/Chat/index.d.ts +41 -1
- package/dist/Chat/index.js +166 -2
- package/dist/Chat/index.js.map +1 -1
- package/dist/Chat/modelRouting.d.ts +8 -26
- package/dist/Chat/modelRouting.js +11 -106
- package/dist/Chat/modelRouting.js.map +1 -1
- package/dist/Chat/sogniHostedTools.generated.json +1285 -283
- package/dist/Chat/tools.d.ts +52 -3
- package/dist/Chat/tools.js +80 -27
- package/dist/Chat/tools.js.map +1 -1
- package/dist/Chat/types.d.ts +119 -3
- package/dist/CreativeWorkflows/index.d.ts +1 -7
- package/dist/CreativeWorkflows/index.js +23 -21
- package/dist/CreativeWorkflows/index.js.map +1 -1
- package/dist/CreativeWorkflows/types.d.ts +27 -33
- package/dist/index.d.ts +19 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/Cache.js +6 -1
- package/dist/lib/Cache.js.map +1 -1
- package/dist-esm/Account/CurrentAccount.js +59 -0
- package/dist-esm/Account/CurrentAccount.js.map +1 -0
- package/dist-esm/Account/index.js +543 -0
- package/dist-esm/Account/index.js.map +1 -0
- package/dist-esm/Account/types.js +2 -0
- package/dist-esm/Account/types.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js +327 -0
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/ChannelCoordinator.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js +222 -0
- package/dist-esm/ApiClient/WebSocketClient/BrowserWebSocketClient/index.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/ErrorCode.js +15 -0
- package/dist-esm/ApiClient/WebSocketClient/ErrorCode.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/eventSubscriptions.js +35 -0
- package/dist-esm/ApiClient/WebSocketClient/eventSubscriptions.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/events.js +2 -0
- package/dist-esm/ApiClient/WebSocketClient/events.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/index.js +221 -0
- package/dist-esm/ApiClient/WebSocketClient/index.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/messages.js +2 -0
- package/dist-esm/ApiClient/WebSocketClient/messages.js.map +1 -0
- package/dist-esm/ApiClient/WebSocketClient/types.js +2 -0
- package/dist-esm/ApiClient/WebSocketClient/types.js.map +1 -0
- package/dist-esm/ApiClient/events.js +2 -0
- package/dist-esm/ApiClient/events.js.map +1 -0
- package/dist-esm/ApiClient/index.js +120 -0
- package/dist-esm/ApiClient/index.js.map +1 -0
- package/dist-esm/ApiGroup.js +10 -0
- package/dist-esm/ApiGroup.js.map +1 -0
- package/dist-esm/Chat/ChatStream.js +181 -0
- package/dist-esm/Chat/ChatStream.js.map +1 -0
- package/dist-esm/Chat/ChatTools.js +562 -0
- package/dist-esm/Chat/ChatTools.js.map +1 -0
- package/dist-esm/Chat/hostedToolValidation.generated.js +301 -0
- package/dist-esm/Chat/hostedToolValidation.generated.js.map +1 -0
- package/dist-esm/Chat/index.js +598 -0
- package/dist-esm/Chat/index.js.map +1 -0
- package/dist-esm/Chat/modelRouting.js +326 -0
- package/dist-esm/Chat/modelRouting.js.map +1 -0
- package/dist-esm/Chat/sogniHostedTools.generated.json +1531 -0
- package/dist-esm/Chat/tools.js +149 -0
- package/dist-esm/Chat/tools.js.map +1 -0
- package/dist-esm/Chat/types.js +2 -0
- package/dist-esm/Chat/types.js.map +1 -0
- package/dist-esm/CreativeWorkflows/index.js +256 -0
- package/dist-esm/CreativeWorkflows/index.js.map +1 -0
- package/dist-esm/CreativeWorkflows/types.js +2 -0
- package/dist-esm/CreativeWorkflows/types.js.map +1 -0
- package/dist-esm/Projects/Job.js +391 -0
- package/dist-esm/Projects/Job.js.map +1 -0
- package/dist-esm/Projects/Project.js +295 -0
- package/dist-esm/Projects/Project.js.map +1 -0
- package/dist-esm/Projects/createJobRequestMessage.js +528 -0
- package/dist-esm/Projects/createJobRequestMessage.js.map +1 -0
- package/dist-esm/Projects/index.js +1309 -0
- package/dist-esm/Projects/index.js.map +1 -0
- package/dist-esm/Projects/types/ComfySamplerParams.js +2 -0
- package/dist-esm/Projects/types/ComfySamplerParams.js.map +1 -0
- package/dist-esm/Projects/types/ControlNetParams.js +2 -0
- package/dist-esm/Projects/types/ControlNetParams.js.map +1 -0
- package/dist-esm/Projects/types/EstimationResponse.js +2 -0
- package/dist-esm/Projects/types/EstimationResponse.js.map +1 -0
- package/dist-esm/Projects/types/ModelOptions.js +89 -0
- package/dist-esm/Projects/types/ModelOptions.js.map +1 -0
- package/dist-esm/Projects/types/ModelTiersRaw.js +13 -0
- package/dist-esm/Projects/types/ModelTiersRaw.js.map +1 -0
- package/dist-esm/Projects/types/RawProject.js +2 -0
- package/dist-esm/Projects/types/RawProject.js.map +1 -0
- package/dist-esm/Projects/types/events.js +2 -0
- package/dist-esm/Projects/types/events.js.map +1 -0
- package/dist-esm/Projects/types/index.js +10 -0
- package/dist-esm/Projects/types/index.js.map +1 -0
- package/dist-esm/Projects/utils/index.js +229 -0
- package/dist-esm/Projects/utils/index.js.map +1 -0
- package/dist-esm/Projects/utils/samplers.js +36 -0
- package/dist-esm/Projects/utils/samplers.js.map +1 -0
- package/dist-esm/Projects/utils/scheduler.js +27 -0
- package/dist-esm/Projects/utils/scheduler.js.map +1 -0
- package/dist-esm/Stats/index.js +20 -0
- package/dist-esm/Stats/index.js.map +1 -0
- package/dist-esm/Stats/types.js +2 -0
- package/dist-esm/Stats/types.js.map +1 -0
- package/dist-esm/events.js +2 -0
- package/dist-esm/events.js.map +1 -0
- package/dist-esm/index.js +144 -0
- package/dist-esm/index.js.map +1 -0
- package/dist-esm/lib/AuthManager/ApiKeyAuthManager.js +58 -0
- package/dist-esm/lib/AuthManager/ApiKeyAuthManager.js.map +1 -0
- package/dist-esm/lib/AuthManager/AuthManagerBase.js +9 -0
- package/dist-esm/lib/AuthManager/AuthManagerBase.js.map +1 -0
- package/dist-esm/lib/AuthManager/CookieAuthManager.js +48 -0
- package/dist-esm/lib/AuthManager/CookieAuthManager.js.map +1 -0
- package/dist-esm/lib/AuthManager/TokenAuthManager.js +186 -0
- package/dist-esm/lib/AuthManager/TokenAuthManager.js.map +1 -0
- package/dist-esm/lib/AuthManager/index.js +5 -0
- package/dist-esm/lib/AuthManager/index.js.map +1 -0
- package/dist-esm/lib/Cache.js +32 -0
- package/dist-esm/lib/Cache.js.map +1 -0
- package/dist-esm/lib/DataEntity.js +30 -0
- package/dist-esm/lib/DataEntity.js.map +1 -0
- package/dist-esm/lib/DefaultLogger.js +32 -0
- package/dist-esm/lib/DefaultLogger.js.map +1 -0
- package/dist-esm/lib/EIP712Helper.js +37 -0
- package/dist-esm/lib/EIP712Helper.js.map +1 -0
- package/dist-esm/lib/RestClient.js +90 -0
- package/dist-esm/lib/RestClient.js.map +1 -0
- package/dist-esm/lib/TypedEventEmitter.js +68 -0
- package/dist-esm/lib/TypedEventEmitter.js.map +1 -0
- package/dist-esm/lib/base64.js +18 -0
- package/dist-esm/lib/base64.js.map +1 -0
- package/dist-esm/lib/getUUID.js +7 -0
- package/dist-esm/lib/getUUID.js.map +1 -0
- package/dist-esm/lib/isNodejs.js +3 -0
- package/dist-esm/lib/isNodejs.js.map +1 -0
- package/dist-esm/lib/mediaValidation.js +277 -0
- package/dist-esm/lib/mediaValidation.js.map +1 -0
- package/dist-esm/lib/utils/index.js +30 -0
- package/dist-esm/lib/utils/index.js.map +1 -0
- package/dist-esm/lib/validation.js +138 -0
- package/dist-esm/lib/validation.js.map +1 -0
- package/dist-esm/package.json +3 -0
- package/dist-esm/types/ErrorData.js +2 -0
- package/dist-esm/types/ErrorData.js.map +1 -0
- package/dist-esm/types/json.js +2 -0
- package/dist-esm/types/json.js.map +1 -0
- package/dist-esm/types/token.js +2 -0
- package/dist-esm/types/token.js.map +1 -0
- package/dist-esm/version.js +3 -0
- package/dist-esm/version.js.map +1 -0
- package/llms-full.txt +11 -20
- package/llms.txt +9 -18
- package/package.json +21 -5
- package/src/Chat/ChatTools.ts +36 -16
- package/src/Chat/hostedToolValidation.generated.ts +453 -0
- package/src/Chat/index.ts +198 -3
- package/src/Chat/modelRouting.ts +26 -150
- package/src/Chat/sogniHostedTools.generated.json +1285 -283
- package/src/Chat/tools.ts +106 -41
- package/src/Chat/types.ts +131 -3
- package/src/CreativeWorkflows/index.ts +22 -41
- package/src/CreativeWorkflows/types.ts +69 -42
- package/src/index.ts +33 -12
- package/src/lib/Cache.ts +8 -1
package/src/Chat/modelRouting.ts
CHANGED
|
@@ -3,11 +3,28 @@ import { getVideoWorkflowType } from '../Projects/utils';
|
|
|
3
3
|
export { getVideoWorkflowType };
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Public SDK-local
|
|
7
|
-
* @sogni/creative-agent/backbone/reference.
|
|
8
|
-
*
|
|
6
|
+
* Public SDK-local routing helpers. The validator surface is generated from
|
|
7
|
+
* @sogni/creative-agent/src/backbone/reference/toolValidation.ts via
|
|
8
|
+
* `npm run sync:hosted-tool-validation` and re-exported below so SDK
|
|
9
|
+
* consumers do not need the private creative-agent package while still
|
|
10
|
+
* inheriting the full validator (pattern auto-anchoring, bounds, oneOf/anyOf,
|
|
11
|
+
* nested recursion, coercion, stripping).
|
|
9
12
|
*/
|
|
10
13
|
|
|
14
|
+
export type {
|
|
15
|
+
HostedToolSchemaProperty,
|
|
16
|
+
HostedToolSchema,
|
|
17
|
+
HostedToolDefinition,
|
|
18
|
+
ValidateHostedToolArgumentsOptions,
|
|
19
|
+
HostedToolArgumentValidationResult,
|
|
20
|
+
NormalizeHostedToolArgumentsResult
|
|
21
|
+
} from './hostedToolValidation.generated';
|
|
22
|
+
export {
|
|
23
|
+
validateAndNormalizeHostedToolArguments,
|
|
24
|
+
validateHostedToolArguments,
|
|
25
|
+
assertHostedToolArguments
|
|
26
|
+
} from './hostedToolValidation.generated';
|
|
27
|
+
|
|
11
28
|
export type BackboneMediaType = 'image' | 'video' | 'audio';
|
|
12
29
|
|
|
13
30
|
export type VideoWorkflow =
|
|
@@ -49,28 +66,6 @@ export interface SelectedBackboneModel {
|
|
|
49
66
|
selectedBy: 'requestedModel' | 'preferredModel' | 'workerCount';
|
|
50
67
|
}
|
|
51
68
|
|
|
52
|
-
export interface HostedToolSchemaProperty {
|
|
53
|
-
type?: string | string[];
|
|
54
|
-
enum?: unknown[];
|
|
55
|
-
items?: HostedToolSchemaProperty;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export interface HostedToolSchema {
|
|
59
|
-
required?: string[];
|
|
60
|
-
properties?: Record<string, HostedToolSchemaProperty>;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface HostedToolDefinition {
|
|
64
|
-
function: {
|
|
65
|
-
name: string;
|
|
66
|
-
parameters?: HostedToolSchema;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface ValidateHostedToolArgumentsOptions {
|
|
71
|
-
skipEnumProperties?: string[];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
69
|
export const PREFERRED_MODEL_IDS = {
|
|
75
70
|
image: {
|
|
76
71
|
gptImage2: 'gpt-image-2',
|
|
@@ -269,25 +264,25 @@ export function resolveHostedToolModelSelector(
|
|
|
269
264
|
|
|
270
265
|
let selectors: Record<string, string> | null = null;
|
|
271
266
|
switch (toolName) {
|
|
272
|
-
case '
|
|
267
|
+
case 'generate_image':
|
|
273
268
|
selectors = IMAGE_MODEL_SELECTORS;
|
|
274
269
|
break;
|
|
275
|
-
case '
|
|
270
|
+
case 'edit_image':
|
|
276
271
|
selectors = EDIT_IMAGE_MODEL_SELECTORS;
|
|
277
272
|
break;
|
|
278
|
-
case '
|
|
273
|
+
case 'generate_video':
|
|
279
274
|
selectors =
|
|
280
275
|
isNonEmptyString(args.reference_image_url) || isNonEmptyString(args.reference_image_end_url)
|
|
281
276
|
? IMAGE_VIDEO_MODEL_SELECTORS
|
|
282
277
|
: TEXT_VIDEO_MODEL_SELECTORS;
|
|
283
278
|
break;
|
|
284
|
-
case '
|
|
279
|
+
case 'sound_to_video':
|
|
285
280
|
selectors = SOUND_TO_VIDEO_MODEL_SELECTORS;
|
|
286
281
|
break;
|
|
287
|
-
case '
|
|
282
|
+
case 'video_to_video':
|
|
288
283
|
selectors = VIDEO_TO_VIDEO_MODEL_SELECTORS;
|
|
289
284
|
break;
|
|
290
|
-
case '
|
|
285
|
+
case 'generate_music':
|
|
291
286
|
selectors = MUSIC_MODEL_SELECTORS;
|
|
292
287
|
break;
|
|
293
288
|
default:
|
|
@@ -299,125 +294,6 @@ export function resolveHostedToolModelSelector(
|
|
|
299
294
|
);
|
|
300
295
|
}
|
|
301
296
|
|
|
302
|
-
function matchesType(value: unknown, type: string): boolean {
|
|
303
|
-
switch (type) {
|
|
304
|
-
case 'array':
|
|
305
|
-
return Array.isArray(value);
|
|
306
|
-
case 'integer':
|
|
307
|
-
return typeof value === 'number' && Number.isInteger(value);
|
|
308
|
-
case 'number':
|
|
309
|
-
return typeof value === 'number' && Number.isFinite(value);
|
|
310
|
-
case 'boolean':
|
|
311
|
-
return typeof value === 'boolean';
|
|
312
|
-
case 'object':
|
|
313
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
314
|
-
case 'string':
|
|
315
|
-
return typeof value === 'string';
|
|
316
|
-
case 'null':
|
|
317
|
-
return value === null;
|
|
318
|
-
default:
|
|
319
|
-
return true;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function typeLabel(type: string | string[] | undefined): string {
|
|
324
|
-
if (Array.isArray(type)) return type.join(' or ');
|
|
325
|
-
return type ?? 'valid value';
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
function typeList(type: string | string[] | undefined): string[] {
|
|
329
|
-
if (!type) return [];
|
|
330
|
-
return Array.isArray(type) ? type : [type];
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
function formatEnum(values: unknown[]): string {
|
|
334
|
-
return values.map((value) => JSON.stringify(value)).join(', ');
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export function validateHostedToolArguments(
|
|
338
|
-
tools: HostedToolDefinition[],
|
|
339
|
-
toolName: string,
|
|
340
|
-
args: Record<string, unknown>,
|
|
341
|
-
options: ValidateHostedToolArgumentsOptions = {}
|
|
342
|
-
): { ok: boolean; errors: string[] } {
|
|
343
|
-
if (!args || typeof args !== 'object' || Array.isArray(args)) {
|
|
344
|
-
return {
|
|
345
|
-
ok: false,
|
|
346
|
-
errors: ['Tool arguments must be a JSON object']
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const tool = tools.find((candidate) => candidate.function.name === toolName);
|
|
351
|
-
if (!tool) {
|
|
352
|
-
return {
|
|
353
|
-
ok: false,
|
|
354
|
-
errors: [`Unknown hosted Sogni tool "${toolName}"`]
|
|
355
|
-
};
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
const schema = tool.function.parameters;
|
|
359
|
-
if (!schema) {
|
|
360
|
-
return { ok: true, errors: [] };
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
const errors: string[] = [];
|
|
364
|
-
const properties = schema.properties ?? {};
|
|
365
|
-
const skipEnumProperties = new Set(options.skipEnumProperties ?? ['model']);
|
|
366
|
-
|
|
367
|
-
for (const required of schema.required ?? []) {
|
|
368
|
-
if (args[required] === undefined || args[required] === null) {
|
|
369
|
-
errors.push(`Missing required argument "${required}"`);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
for (const [name, value] of Object.entries(args)) {
|
|
374
|
-
if (value === undefined || value === null) continue;
|
|
375
|
-
|
|
376
|
-
const property = properties[name];
|
|
377
|
-
if (!property) continue;
|
|
378
|
-
|
|
379
|
-
const allowedTypes = typeList(property.type);
|
|
380
|
-
if (allowedTypes.length > 0 && !allowedTypes.some((type) => matchesType(value, type))) {
|
|
381
|
-
errors.push(`Argument "${name}" must be ${typeLabel(property.type)}`);
|
|
382
|
-
continue;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (
|
|
386
|
-
property.enum &&
|
|
387
|
-
!skipEnumProperties.has(name) &&
|
|
388
|
-
!property.enum.some((candidate) => candidate === value)
|
|
389
|
-
) {
|
|
390
|
-
errors.push(`Argument "${name}" must be one of ${formatEnum(property.enum)}`);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
if (Array.isArray(value) && property.items?.type) {
|
|
394
|
-
const itemTypes = typeList(property.items.type);
|
|
395
|
-
value.forEach((item, index) => {
|
|
396
|
-
if (!itemTypes.some((type) => matchesType(item, type))) {
|
|
397
|
-
errors.push(`Argument "${name}[${index}]" must be ${typeLabel(property.items?.type)}`);
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
return {
|
|
404
|
-
ok: errors.length === 0,
|
|
405
|
-
errors
|
|
406
|
-
};
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
export function assertHostedToolArguments(
|
|
410
|
-
tools: HostedToolDefinition[],
|
|
411
|
-
toolName: string,
|
|
412
|
-
args: Record<string, unknown>,
|
|
413
|
-
options?: ValidateHostedToolArgumentsOptions
|
|
414
|
-
): void {
|
|
415
|
-
const result = validateHostedToolArguments(tools, toolName, args, options);
|
|
416
|
-
if (!result.ok) {
|
|
417
|
-
throw new Error(`Invalid ${toolName} arguments: ${result.errors.join('; ')}`);
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
|
|
421
297
|
function isObject(value: unknown): value is Record<string, unknown> {
|
|
422
298
|
return typeof value === 'object' && value !== null;
|
|
423
299
|
}
|