playkit-sdk 1.4.0-beta.3 → 1.6.0
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 +9 -1
- package/dist/playkit-sdk.cjs.js +242 -1022
- package/dist/playkit-sdk.cjs.js.map +1 -1
- package/dist/playkit-sdk.d.ts +304 -309
- package/dist/playkit-sdk.esm.js +243 -1022
- package/dist/playkit-sdk.esm.js.map +1 -1
- package/dist/playkit-sdk.umd.js +242 -1022
- package/dist/playkit-sdk.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/playkit-sdk.d.ts
CHANGED
|
@@ -244,6 +244,199 @@ declare class CallbackLogHandler implements LogHandler {
|
|
|
244
244
|
handle(entry: LogEntry): void;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
+
/**
|
|
248
|
+
* Chat and text generation types
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Reasoning ("thinking") effort level for thinking-capable models.
|
|
253
|
+
*
|
|
254
|
+
* Wire values are lowercase strings sent as `thinking: { effort }`.
|
|
255
|
+
* - `'off'` explicitly disables reasoning (the server also defaults to off when
|
|
256
|
+
* no effort is provided).
|
|
257
|
+
* - `'minimal'` .. `'max'` request progressively more reasoning effort.
|
|
258
|
+
*/
|
|
259
|
+
type Effort = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'max';
|
|
260
|
+
/**
|
|
261
|
+
* Tool definition for function calling
|
|
262
|
+
*/
|
|
263
|
+
interface ChatTool {
|
|
264
|
+
type: 'function';
|
|
265
|
+
function: {
|
|
266
|
+
name: string;
|
|
267
|
+
description: string;
|
|
268
|
+
parameters: Record<string, any>;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Configuration for text generation
|
|
273
|
+
*/
|
|
274
|
+
interface ChatConfig {
|
|
275
|
+
/** Array of messages in the conversation */
|
|
276
|
+
messages: Message[];
|
|
277
|
+
/** Model to use for generation */
|
|
278
|
+
model?: string;
|
|
279
|
+
/** Temperature for generation (0.0 - 2.0) */
|
|
280
|
+
temperature?: number;
|
|
281
|
+
/** Maximum tokens to generate */
|
|
282
|
+
maxTokens?: number;
|
|
283
|
+
/** Random seed for reproducible results */
|
|
284
|
+
seed?: number;
|
|
285
|
+
/** Stop sequences */
|
|
286
|
+
stop?: string[];
|
|
287
|
+
/** Top-p sampling */
|
|
288
|
+
topP?: number;
|
|
289
|
+
/** Tools available for the model to use */
|
|
290
|
+
tools?: ChatTool[];
|
|
291
|
+
/** Tool choice: 'auto', 'required', 'none', or specific tool */
|
|
292
|
+
tool_choice?: 'auto' | 'required' | 'none' | {
|
|
293
|
+
type: 'function';
|
|
294
|
+
function: {
|
|
295
|
+
name: string;
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
/** Reasoning effort for thinking-capable models */
|
|
299
|
+
thinking?: {
|
|
300
|
+
/**
|
|
301
|
+
* Whether thinking is enabled.
|
|
302
|
+
*
|
|
303
|
+
* @deprecated Use `effort` instead. `enabled: false` is an alias for
|
|
304
|
+
* `effort: 'off'`; `enabled: true` (without `effort`) maps to
|
|
305
|
+
* `effort: 'minimal'`. Per-request `effort` takes precedence.
|
|
306
|
+
*/
|
|
307
|
+
enabled?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Reasoning effort level. When set, this is sent to the server as
|
|
310
|
+
* `thinking: { effort }`. Overrides the SDK-level `defaultThinkingEffort`.
|
|
311
|
+
*/
|
|
312
|
+
effort?: Effort;
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Configuration for streaming text generation
|
|
317
|
+
*/
|
|
318
|
+
interface ChatStreamConfig extends ChatConfig {
|
|
319
|
+
/** Callback for each chunk of text */
|
|
320
|
+
onChunk: (chunk: string) => void;
|
|
321
|
+
/** Callback for each chunk of reasoning (thinking) text */
|
|
322
|
+
onReasoning?: (chunk: string) => void;
|
|
323
|
+
/** Callback when generation is complete */
|
|
324
|
+
onComplete?: (fullText: string) => void;
|
|
325
|
+
/** Callback for errors during streaming */
|
|
326
|
+
onError?: (error: Error) => void;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Result of a text generation request
|
|
330
|
+
*/
|
|
331
|
+
interface ChatResult {
|
|
332
|
+
/** Generated text content */
|
|
333
|
+
content: string;
|
|
334
|
+
/** Model used for generation */
|
|
335
|
+
model: string;
|
|
336
|
+
/** Finish reason */
|
|
337
|
+
finishReason: 'stop' | 'length' | 'content_filter' | 'tool_calls' | 'null';
|
|
338
|
+
/** Token usage information */
|
|
339
|
+
usage?: {
|
|
340
|
+
promptTokens: number;
|
|
341
|
+
completionTokens: number;
|
|
342
|
+
totalTokens: number;
|
|
343
|
+
};
|
|
344
|
+
/** Unique ID for this completion */
|
|
345
|
+
id?: string;
|
|
346
|
+
/** Timestamp of creation */
|
|
347
|
+
created?: number;
|
|
348
|
+
/** Tool calls made by the model */
|
|
349
|
+
tool_calls?: ToolCall[];
|
|
350
|
+
/** Model's reasoning (thinking) content, present only when the model produced thinking */
|
|
351
|
+
reasoning?: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Configuration for structured output generation
|
|
355
|
+
*/
|
|
356
|
+
interface StructuredOutputConfig {
|
|
357
|
+
/** Name of the schema to use */
|
|
358
|
+
schemaName: string;
|
|
359
|
+
/** Prompt for generation */
|
|
360
|
+
prompt: string;
|
|
361
|
+
/** Model to use */
|
|
362
|
+
model?: string;
|
|
363
|
+
/** Temperature */
|
|
364
|
+
temperature?: number;
|
|
365
|
+
/** Additional messages for context */
|
|
366
|
+
messages?: Message[];
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* OpenAI-compatible chat completion response
|
|
370
|
+
*/
|
|
371
|
+
interface ChatCompletionResponse {
|
|
372
|
+
id: string;
|
|
373
|
+
object: string;
|
|
374
|
+
created: number;
|
|
375
|
+
model: string;
|
|
376
|
+
choices: Array<{
|
|
377
|
+
index: number;
|
|
378
|
+
message: Message & {
|
|
379
|
+
reasoning_content?: string;
|
|
380
|
+
};
|
|
381
|
+
finish_reason: string;
|
|
382
|
+
}>;
|
|
383
|
+
usage?: {
|
|
384
|
+
prompt_tokens: number;
|
|
385
|
+
completion_tokens: number;
|
|
386
|
+
total_tokens: number;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Streaming chunk formats
|
|
391
|
+
*/
|
|
392
|
+
interface StreamChunk {
|
|
393
|
+
type: 'text-delta' | 'reasoning-delta' | 'reasoning-start' | 'reasoning-end' | 'done' | 'finish' | 'abort' | 'error';
|
|
394
|
+
id?: string;
|
|
395
|
+
delta?: string;
|
|
396
|
+
error?: string;
|
|
397
|
+
errorText?: string;
|
|
398
|
+
reason?: string;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* NPC Action parameter types
|
|
402
|
+
*/
|
|
403
|
+
type NpcActionParamType = 'string' | 'number' | 'boolean' | 'stringEnum';
|
|
404
|
+
/**
|
|
405
|
+
* NPC Action parameter definition
|
|
406
|
+
*/
|
|
407
|
+
interface NpcActionParameter {
|
|
408
|
+
name: string;
|
|
409
|
+
description: string;
|
|
410
|
+
type: NpcActionParamType;
|
|
411
|
+
required?: boolean;
|
|
412
|
+
enumOptions?: string[];
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* NPC Action definition
|
|
416
|
+
*/
|
|
417
|
+
interface NpcAction {
|
|
418
|
+
actionName: string;
|
|
419
|
+
description: string;
|
|
420
|
+
parameters?: NpcActionParameter[];
|
|
421
|
+
enabled?: boolean;
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* NPC Action call result
|
|
425
|
+
*/
|
|
426
|
+
interface NpcActionCall {
|
|
427
|
+
id: string;
|
|
428
|
+
actionName: string;
|
|
429
|
+
arguments: Record<string, any>;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Response from NPC with actions
|
|
433
|
+
*/
|
|
434
|
+
interface NpcActionResponse {
|
|
435
|
+
text: string;
|
|
436
|
+
actionCalls: NpcActionCall[];
|
|
437
|
+
hasActions: boolean;
|
|
438
|
+
}
|
|
439
|
+
|
|
247
440
|
/**
|
|
248
441
|
* Common types used across the SDK
|
|
249
442
|
*/
|
|
@@ -294,10 +487,50 @@ interface AudioContentPart {
|
|
|
294
487
|
format: 'wav' | 'mp3' | 'webm' | 'flac' | 'ogg';
|
|
295
488
|
};
|
|
296
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Canonical PlayKit tool-call content part.
|
|
492
|
+
* Matches the server's internal model-message shape while legacy `tool_calls`
|
|
493
|
+
* fields remain accepted for backward compatibility.
|
|
494
|
+
*/
|
|
495
|
+
interface ToolCallContentPart {
|
|
496
|
+
type: 'tool-call';
|
|
497
|
+
toolCallId: string;
|
|
498
|
+
toolName: string;
|
|
499
|
+
input: unknown;
|
|
500
|
+
providerExecuted?: boolean;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Canonical PlayKit tool-result output.
|
|
504
|
+
*/
|
|
505
|
+
type ToolResultOutput = {
|
|
506
|
+
type: 'text';
|
|
507
|
+
value: string;
|
|
508
|
+
} | {
|
|
509
|
+
type: 'json';
|
|
510
|
+
value: unknown;
|
|
511
|
+
} | {
|
|
512
|
+
type: 'execution-denied';
|
|
513
|
+
reason?: string;
|
|
514
|
+
} | {
|
|
515
|
+
type: 'error-text';
|
|
516
|
+
value: string;
|
|
517
|
+
} | {
|
|
518
|
+
type: 'error-json';
|
|
519
|
+
value: unknown;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Canonical PlayKit tool-result content part.
|
|
523
|
+
*/
|
|
524
|
+
interface ToolResultContentPart {
|
|
525
|
+
type: 'tool-result';
|
|
526
|
+
toolCallId: string;
|
|
527
|
+
toolName: string;
|
|
528
|
+
output: ToolResultOutput;
|
|
529
|
+
}
|
|
297
530
|
/**
|
|
298
531
|
* Content part types for multimodal messages
|
|
299
532
|
*/
|
|
300
|
-
type MessageContentPart = TextContentPart | ImageContentPart | AudioContentPart;
|
|
533
|
+
type MessageContentPart = TextContentPart | ImageContentPart | AudioContentPart | ToolCallContentPart | ToolResultContentPart;
|
|
301
534
|
/**
|
|
302
535
|
* Message content - can be a simple string or array of content parts for multimodal
|
|
303
536
|
*/
|
|
@@ -309,9 +542,15 @@ interface Message {
|
|
|
309
542
|
role: MessageRole;
|
|
310
543
|
/** Content can be a string or array of content parts (for multimodal) */
|
|
311
544
|
content: MessageContent;
|
|
312
|
-
/**
|
|
545
|
+
/**
|
|
546
|
+
* Legacy OpenAI-compatible tool calls made by the assistant.
|
|
547
|
+
* Prefer canonical `{ type: 'tool-call' }` content parts for new history.
|
|
548
|
+
*/
|
|
313
549
|
tool_calls?: ToolCall[];
|
|
314
|
-
/**
|
|
550
|
+
/**
|
|
551
|
+
* Legacy OpenAI-compatible tool call ID this message responds to.
|
|
552
|
+
* Prefer canonical `{ type: 'tool-result' }` content parts for new history.
|
|
553
|
+
*/
|
|
315
554
|
tool_call_id?: string;
|
|
316
555
|
}
|
|
317
556
|
/**
|
|
@@ -337,14 +576,6 @@ interface APIResult<T> {
|
|
|
337
576
|
error?: string;
|
|
338
577
|
errorCode?: string;
|
|
339
578
|
}
|
|
340
|
-
/**
|
|
341
|
-
* Authentication method type
|
|
342
|
-
* - 'device': Device Authorization flow with PKCE (recommended, opens browser for auth)
|
|
343
|
-
* - 'headless': Embedded verification code login (creates global tokens)
|
|
344
|
-
*
|
|
345
|
-
* @deprecated 'headless' is deprecated and will be removed in v2.0. Use 'device' instead.
|
|
346
|
-
*/
|
|
347
|
-
type AuthMethod = 'device' | 'headless';
|
|
348
579
|
/**
|
|
349
580
|
* Configuration for developerToken fallback behavior
|
|
350
581
|
* When developerToken authentication fails, the SDK can automatically
|
|
@@ -371,8 +602,6 @@ interface SDKConfig {
|
|
|
371
602
|
gameId: string;
|
|
372
603
|
/** Developer token for testing (optional, for development only) */
|
|
373
604
|
developerToken?: string;
|
|
374
|
-
/** Player JWT token for production (optional) */
|
|
375
|
-
playerJWT?: string;
|
|
376
605
|
/**
|
|
377
606
|
* Player token to use directly (optional)
|
|
378
607
|
* When provided, SDK will use this token without triggering login flow.
|
|
@@ -400,15 +629,16 @@ interface SDKConfig {
|
|
|
400
629
|
* Default: 'browser'
|
|
401
630
|
*/
|
|
402
631
|
mode?: SDKMode;
|
|
403
|
-
/**
|
|
404
|
-
* Authentication method to use
|
|
405
|
-
* - 'device': Device Authorization flow with PKCE (recommended, opens browser for auth)
|
|
406
|
-
* - 'headless': Embedded verification code login (creates global tokens)
|
|
407
|
-
* Default: 'device'
|
|
408
|
-
*/
|
|
409
|
-
authMethod?: AuthMethod;
|
|
410
632
|
/** Default chat model to use */
|
|
411
633
|
defaultChatModel?: string;
|
|
634
|
+
/**
|
|
635
|
+
* Default reasoning ("thinking") effort to use for chat requests.
|
|
636
|
+
*
|
|
637
|
+
* Resolution order per request: per-request `thinking.effort` > this SDK-level
|
|
638
|
+
* default > omit (the server then defaults to off). Sent on the wire as
|
|
639
|
+
* `thinking: { effort }`. Use `'off'` to explicitly disable reasoning.
|
|
640
|
+
*/
|
|
641
|
+
defaultThinkingEffort?: Effort;
|
|
412
642
|
/** Default image model to use */
|
|
413
643
|
defaultImageModel?: string;
|
|
414
644
|
/** Default transcription model to use */
|
|
@@ -544,181 +774,6 @@ declare class PlayKitError extends Error {
|
|
|
544
774
|
constructor(message: string, code?: string | undefined, statusCode?: number | undefined);
|
|
545
775
|
}
|
|
546
776
|
|
|
547
|
-
/**
|
|
548
|
-
* Chat and text generation types
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* Tool definition for function calling
|
|
553
|
-
*/
|
|
554
|
-
interface ChatTool {
|
|
555
|
-
type: 'function';
|
|
556
|
-
function: {
|
|
557
|
-
name: string;
|
|
558
|
-
description: string;
|
|
559
|
-
parameters: Record<string, any>;
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Configuration for text generation
|
|
564
|
-
*/
|
|
565
|
-
interface ChatConfig {
|
|
566
|
-
/** Array of messages in the conversation */
|
|
567
|
-
messages: Message[];
|
|
568
|
-
/** Model to use for generation */
|
|
569
|
-
model?: string;
|
|
570
|
-
/** Temperature for generation (0.0 - 2.0) */
|
|
571
|
-
temperature?: number;
|
|
572
|
-
/** Maximum tokens to generate */
|
|
573
|
-
maxTokens?: number;
|
|
574
|
-
/** Random seed for reproducible results */
|
|
575
|
-
seed?: number;
|
|
576
|
-
/** Stop sequences */
|
|
577
|
-
stop?: string[];
|
|
578
|
-
/** Top-p sampling */
|
|
579
|
-
topP?: number;
|
|
580
|
-
/** Tools available for the model to use */
|
|
581
|
-
tools?: ChatTool[];
|
|
582
|
-
/** Tool choice: 'auto', 'required', 'none', or specific tool */
|
|
583
|
-
tool_choice?: 'auto' | 'required' | 'none' | {
|
|
584
|
-
type: 'function';
|
|
585
|
-
function: {
|
|
586
|
-
name: string;
|
|
587
|
-
};
|
|
588
|
-
};
|
|
589
|
-
/** Reasoning effort for thinking-capable models */
|
|
590
|
-
thinking?: {
|
|
591
|
-
/** Whether thinking is enabled */
|
|
592
|
-
enabled?: boolean;
|
|
593
|
-
/** Reasoning effort level */
|
|
594
|
-
effort?: 'minimal' | 'low' | 'medium' | 'high' | 'max';
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Configuration for streaming text generation
|
|
599
|
-
*/
|
|
600
|
-
interface ChatStreamConfig extends ChatConfig {
|
|
601
|
-
/** Callback for each chunk of text */
|
|
602
|
-
onChunk: (chunk: string) => void;
|
|
603
|
-
/** Callback for each chunk of reasoning (thinking) text */
|
|
604
|
-
onReasoning?: (chunk: string) => void;
|
|
605
|
-
/** Callback when generation is complete */
|
|
606
|
-
onComplete?: (fullText: string) => void;
|
|
607
|
-
/** Callback for errors during streaming */
|
|
608
|
-
onError?: (error: Error) => void;
|
|
609
|
-
}
|
|
610
|
-
/**
|
|
611
|
-
* Result of a text generation request
|
|
612
|
-
*/
|
|
613
|
-
interface ChatResult {
|
|
614
|
-
/** Generated text content */
|
|
615
|
-
content: string;
|
|
616
|
-
/** Model used for generation */
|
|
617
|
-
model: string;
|
|
618
|
-
/** Finish reason */
|
|
619
|
-
finishReason: 'stop' | 'length' | 'content_filter' | 'tool_calls' | 'null';
|
|
620
|
-
/** Token usage information */
|
|
621
|
-
usage?: {
|
|
622
|
-
promptTokens: number;
|
|
623
|
-
completionTokens: number;
|
|
624
|
-
totalTokens: number;
|
|
625
|
-
};
|
|
626
|
-
/** Unique ID for this completion */
|
|
627
|
-
id?: string;
|
|
628
|
-
/** Timestamp of creation */
|
|
629
|
-
created?: number;
|
|
630
|
-
/** Tool calls made by the model */
|
|
631
|
-
tool_calls?: ToolCall[];
|
|
632
|
-
/** Model's reasoning (thinking) content, present only when the model produced thinking */
|
|
633
|
-
reasoning?: string;
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Configuration for structured output generation
|
|
637
|
-
*/
|
|
638
|
-
interface StructuredOutputConfig {
|
|
639
|
-
/** Name of the schema to use */
|
|
640
|
-
schemaName: string;
|
|
641
|
-
/** Prompt for generation */
|
|
642
|
-
prompt: string;
|
|
643
|
-
/** Model to use */
|
|
644
|
-
model?: string;
|
|
645
|
-
/** Temperature */
|
|
646
|
-
temperature?: number;
|
|
647
|
-
/** Additional messages for context */
|
|
648
|
-
messages?: Message[];
|
|
649
|
-
}
|
|
650
|
-
/**
|
|
651
|
-
* OpenAI-compatible chat completion response
|
|
652
|
-
*/
|
|
653
|
-
interface ChatCompletionResponse {
|
|
654
|
-
id: string;
|
|
655
|
-
object: string;
|
|
656
|
-
created: number;
|
|
657
|
-
model: string;
|
|
658
|
-
choices: Array<{
|
|
659
|
-
index: number;
|
|
660
|
-
message: Message & {
|
|
661
|
-
reasoning_content?: string;
|
|
662
|
-
};
|
|
663
|
-
finish_reason: string;
|
|
664
|
-
}>;
|
|
665
|
-
usage?: {
|
|
666
|
-
prompt_tokens: number;
|
|
667
|
-
completion_tokens: number;
|
|
668
|
-
total_tokens: number;
|
|
669
|
-
};
|
|
670
|
-
}
|
|
671
|
-
/**
|
|
672
|
-
* Streaming chunk formats
|
|
673
|
-
*/
|
|
674
|
-
interface StreamChunk {
|
|
675
|
-
type: 'text-delta' | 'reasoning-delta' | 'reasoning-start' | 'reasoning-end' | 'done' | 'finish' | 'abort' | 'error';
|
|
676
|
-
id?: string;
|
|
677
|
-
delta?: string;
|
|
678
|
-
error?: string;
|
|
679
|
-
errorText?: string;
|
|
680
|
-
reason?: string;
|
|
681
|
-
}
|
|
682
|
-
/**
|
|
683
|
-
* NPC Action parameter types
|
|
684
|
-
*/
|
|
685
|
-
type NpcActionParamType = 'string' | 'number' | 'boolean' | 'stringEnum';
|
|
686
|
-
/**
|
|
687
|
-
* NPC Action parameter definition
|
|
688
|
-
*/
|
|
689
|
-
interface NpcActionParameter {
|
|
690
|
-
name: string;
|
|
691
|
-
description: string;
|
|
692
|
-
type: NpcActionParamType;
|
|
693
|
-
required?: boolean;
|
|
694
|
-
enumOptions?: string[];
|
|
695
|
-
}
|
|
696
|
-
/**
|
|
697
|
-
* NPC Action definition
|
|
698
|
-
*/
|
|
699
|
-
interface NpcAction {
|
|
700
|
-
actionName: string;
|
|
701
|
-
description: string;
|
|
702
|
-
parameters?: NpcActionParameter[];
|
|
703
|
-
enabled?: boolean;
|
|
704
|
-
}
|
|
705
|
-
/**
|
|
706
|
-
* NPC Action call result
|
|
707
|
-
*/
|
|
708
|
-
interface NpcActionCall {
|
|
709
|
-
id: string;
|
|
710
|
-
actionName: string;
|
|
711
|
-
arguments: Record<string, any>;
|
|
712
|
-
}
|
|
713
|
-
/**
|
|
714
|
-
* Response from NPC with actions
|
|
715
|
-
*/
|
|
716
|
-
interface NpcActionResponse {
|
|
717
|
-
text: string;
|
|
718
|
-
actionCalls: NpcActionCall[];
|
|
719
|
-
hasActions: boolean;
|
|
720
|
-
}
|
|
721
|
-
|
|
722
777
|
/**
|
|
723
778
|
* Image generation types
|
|
724
779
|
*/
|
|
@@ -996,6 +1051,26 @@ interface TTSTimestampsResult extends TTSResult {
|
|
|
996
1051
|
/** Word/sentence timings, or null if unavailable. */
|
|
997
1052
|
alignment: Alignment | null;
|
|
998
1053
|
}
|
|
1054
|
+
/** One voice available for speech synthesis. */
|
|
1055
|
+
interface VoiceInfo {
|
|
1056
|
+
/** Voice id to pass as `voice` in a TTS request. */
|
|
1057
|
+
voiceId: string;
|
|
1058
|
+
/** Human-readable display name (if reported). */
|
|
1059
|
+
name?: string;
|
|
1060
|
+
/** Description of the voice (if reported). */
|
|
1061
|
+
description?: string;
|
|
1062
|
+
/** Primary language of the voice (if reported). */
|
|
1063
|
+
language?: string;
|
|
1064
|
+
/** Whether this is a built-in system voice or a custom voice. */
|
|
1065
|
+
kind: 'system' | 'custom';
|
|
1066
|
+
}
|
|
1067
|
+
/** Result of `listVoices`: the available voices and a total count. */
|
|
1068
|
+
interface VoiceListResult {
|
|
1069
|
+
/** Voices available for synthesis. */
|
|
1070
|
+
voices: VoiceInfo[];
|
|
1071
|
+
/** Total number of voices. */
|
|
1072
|
+
total: number;
|
|
1073
|
+
}
|
|
999
1074
|
|
|
1000
1075
|
/**
|
|
1001
1076
|
* Device Authorization Flow Manager
|
|
@@ -1052,8 +1127,6 @@ interface DeviceAuthInitResult {
|
|
|
1052
1127
|
declare class DeviceAuthFlowManager extends EventEmitter {
|
|
1053
1128
|
/** Shared promise for the current flow - allows multiple callers to await the same result */
|
|
1054
1129
|
private static currentFlowPromise;
|
|
1055
|
-
/** Reference to the currently active instance */
|
|
1056
|
-
private static activeInstance;
|
|
1057
1130
|
private baseURL;
|
|
1058
1131
|
private gameId;
|
|
1059
1132
|
private pollInterval;
|
|
@@ -1187,7 +1260,6 @@ declare class AuthManager extends EventEmitter {
|
|
|
1187
1260
|
private authState;
|
|
1188
1261
|
private config;
|
|
1189
1262
|
private baseURL;
|
|
1190
|
-
private authFlowManager;
|
|
1191
1263
|
private deviceAuthFlowManager;
|
|
1192
1264
|
private logger;
|
|
1193
1265
|
/** Shared promise for current device auth flow - allows multiple callers to await the same result */
|
|
@@ -1200,21 +1272,14 @@ declare class AuthManager extends EventEmitter {
|
|
|
1200
1272
|
*/
|
|
1201
1273
|
initialize(): Promise<void>;
|
|
1202
1274
|
/**
|
|
1203
|
-
* Start the authentication flow
|
|
1204
|
-
*
|
|
1205
|
-
* @param authMethod - Authentication method to use ('device' or 'headless')
|
|
1206
|
-
* @deprecated 'headless' authentication is deprecated and will be removed in v2.0. Use 'device' instead.
|
|
1275
|
+
* Start the authentication flow (Device Authorization + PKCE).
|
|
1207
1276
|
*/
|
|
1208
|
-
startAuthFlow(
|
|
1277
|
+
startAuthFlow(): Promise<void>;
|
|
1209
1278
|
/**
|
|
1210
|
-
* Internal method that executes the
|
|
1279
|
+
* Internal method that executes the Device Authorization flow.
|
|
1211
1280
|
* @private
|
|
1212
1281
|
*/
|
|
1213
1282
|
private executeAuthFlow;
|
|
1214
|
-
/**
|
|
1215
|
-
* Exchange JWT for player token
|
|
1216
|
-
*/
|
|
1217
|
-
exchangeJWT(jwt: string): Promise<string>;
|
|
1218
1283
|
/**
|
|
1219
1284
|
* Get current authentication token
|
|
1220
1285
|
*/
|
|
@@ -1596,6 +1661,21 @@ declare class ChatProvider {
|
|
|
1596
1661
|
* Set player client for balance checking
|
|
1597
1662
|
*/
|
|
1598
1663
|
setPlayerClient(playerClient: PlayerClient): void;
|
|
1664
|
+
/**
|
|
1665
|
+
* Resolve the `thinking` payload to send on the wire.
|
|
1666
|
+
*
|
|
1667
|
+
* Resolution order for effort: per-request `thinking.effort` > SDK-level
|
|
1668
|
+
* `defaultThinkingEffort` > omit (the server then defaults to off). This
|
|
1669
|
+
* mirrors how the chat model resolves (`chatConfig.model || defaultChatModel`).
|
|
1670
|
+
*
|
|
1671
|
+
* The deprecated `enabled` flag is preserved as an alias: when no effort can be
|
|
1672
|
+
* resolved, `enabled: false` maps to `{ effort: 'off' }` and `enabled: true`
|
|
1673
|
+
* maps to `{ effort: 'minimal' }`.
|
|
1674
|
+
*
|
|
1675
|
+
* @returns The `{ effort }` (and/or `enabled`) object to assign to
|
|
1676
|
+
* `requestBody.thinking`, or `undefined` to send nothing.
|
|
1677
|
+
*/
|
|
1678
|
+
private resolveThinking;
|
|
1599
1679
|
/**
|
|
1600
1680
|
* Make a chat completion request (non-streaming)
|
|
1601
1681
|
*/
|
|
@@ -2051,6 +2131,8 @@ declare class TTSProvider {
|
|
|
2051
2131
|
private buildRequestBody;
|
|
2052
2132
|
/** POST to a TTS endpoint; throws a PlayKitError on a non-ok response. */
|
|
2053
2133
|
private post;
|
|
2134
|
+
/** GET a TTS endpoint; throws a PlayKitError on a non-ok response. */
|
|
2135
|
+
private get;
|
|
2054
2136
|
private checkBalanceAfter;
|
|
2055
2137
|
/**
|
|
2056
2138
|
* Synthesize text into speech audio (raw bytes).
|
|
@@ -2062,6 +2144,10 @@ declare class TTSProvider {
|
|
|
2062
2144
|
* (base64 audio + alignment), so it is parsed as JSON — not raw bytes.
|
|
2063
2145
|
*/
|
|
2064
2146
|
synthesizeWithTimestamps(ttsConfig: TTSTimestampsConfig): Promise<TTSTimestampsResult>;
|
|
2147
|
+
/**
|
|
2148
|
+
* List the voices available for speech synthesis.
|
|
2149
|
+
*/
|
|
2150
|
+
listVoices(): Promise<VoiceListResult>;
|
|
2065
2151
|
}
|
|
2066
2152
|
|
|
2067
2153
|
/**
|
|
@@ -2088,6 +2174,11 @@ declare class TTSClient {
|
|
|
2088
2174
|
* @param config - TTS configuration; `granularity` defaults to 'word'.
|
|
2089
2175
|
*/
|
|
2090
2176
|
synthesizeWithTimestamps(config: TTSTimestampsConfig): Promise<TTSTimestampsResult>;
|
|
2177
|
+
/**
|
|
2178
|
+
* List the voices available for speech synthesis
|
|
2179
|
+
* @returns The available voices and a total count
|
|
2180
|
+
*/
|
|
2181
|
+
listVoices(): Promise<VoiceListResult>;
|
|
2091
2182
|
/**
|
|
2092
2183
|
* Synthesize text into speech and return it as a Blob (browser-friendly)
|
|
2093
2184
|
* @param config - Full TTS configuration
|
|
@@ -2279,6 +2370,9 @@ declare class NPCClient extends EventEmitter {
|
|
|
2279
2370
|
* Report a single action result
|
|
2280
2371
|
*/
|
|
2281
2372
|
reportActionResult(callId: string, result: string): void;
|
|
2373
|
+
private createAssistantHistoryMessage;
|
|
2374
|
+
private createToolResultHistoryMessage;
|
|
2375
|
+
private findToolNameForCall;
|
|
2282
2376
|
/**
|
|
2283
2377
|
* Parse tool arguments from JSON string
|
|
2284
2378
|
*/
|
|
@@ -2590,10 +2684,6 @@ declare class PlayKitSDK extends EventEmitter {
|
|
|
2590
2684
|
* Check if authenticated
|
|
2591
2685
|
*/
|
|
2592
2686
|
isAuthenticated(): boolean;
|
|
2593
|
-
/**
|
|
2594
|
-
* Exchange JWT for player token
|
|
2595
|
-
*/
|
|
2596
|
-
login(jwt: string): Promise<string>;
|
|
2597
2687
|
/**
|
|
2598
2688
|
* Logout
|
|
2599
2689
|
*/
|
|
@@ -2915,101 +3005,6 @@ declare class TokenStorage {
|
|
|
2915
3005
|
private base64ToArrayBuffer;
|
|
2916
3006
|
}
|
|
2917
3007
|
|
|
2918
|
-
/**
|
|
2919
|
-
* Authentication Flow Manager
|
|
2920
|
-
* Manages the headless authentication flow with automatic UI
|
|
2921
|
-
*
|
|
2922
|
-
* @deprecated This class is deprecated. Use DeviceAuthFlowManager instead.
|
|
2923
|
-
* Will be removed in v2.0
|
|
2924
|
-
*/
|
|
2925
|
-
|
|
2926
|
-
declare class AuthFlowManager extends EventEmitter {
|
|
2927
|
-
private baseURL;
|
|
2928
|
-
private currentSessionId;
|
|
2929
|
-
private _uiContainer;
|
|
2930
|
-
private _isSuccess;
|
|
2931
|
-
private currentLanguage;
|
|
2932
|
-
private modal;
|
|
2933
|
-
private identifierPanel;
|
|
2934
|
-
private verificationPanel;
|
|
2935
|
-
private loadingOverlay;
|
|
2936
|
-
private otpInstance;
|
|
2937
|
-
constructor(baseURL?: string);
|
|
2938
|
-
/**
|
|
2939
|
-
* Detect browser language (safe for Node.js environment)
|
|
2940
|
-
*/
|
|
2941
|
-
private detectLanguage;
|
|
2942
|
-
/**
|
|
2943
|
-
* Get translated text
|
|
2944
|
-
*/
|
|
2945
|
-
private t;
|
|
2946
|
-
/**
|
|
2947
|
-
* Start the authentication flow
|
|
2948
|
-
* Returns a promise that resolves with the JWT token
|
|
2949
|
-
*/
|
|
2950
|
-
startFlow(): Promise<string>;
|
|
2951
|
-
/**
|
|
2952
|
-
* Create the authentication UI
|
|
2953
|
-
*/
|
|
2954
|
-
private createUI;
|
|
2955
|
-
/**
|
|
2956
|
-
* Load VanillaOTP library
|
|
2957
|
-
*/
|
|
2958
|
-
private loadVanillaOTP;
|
|
2959
|
-
/**
|
|
2960
|
-
* Add CSS styles to the page
|
|
2961
|
-
*/
|
|
2962
|
-
private addStyles;
|
|
2963
|
-
/**
|
|
2964
|
-
* Setup event listeners
|
|
2965
|
-
*/
|
|
2966
|
-
private setupEventListeners;
|
|
2967
|
-
/**
|
|
2968
|
-
* Handle send code button click
|
|
2969
|
-
*/
|
|
2970
|
-
private onSendCodeClicked;
|
|
2971
|
-
/**
|
|
2972
|
-
* Handle verify button click
|
|
2973
|
-
*/
|
|
2974
|
-
private onVerifyClicked;
|
|
2975
|
-
/**
|
|
2976
|
-
* Send verification code to backend
|
|
2977
|
-
*/
|
|
2978
|
-
private sendVerificationCode;
|
|
2979
|
-
/**
|
|
2980
|
-
* Verify the code and get global token
|
|
2981
|
-
*/
|
|
2982
|
-
private verifyCode;
|
|
2983
|
-
/**
|
|
2984
|
-
* Set default auth type based on user region
|
|
2985
|
-
*/
|
|
2986
|
-
private setDefaultAuthTypeByRegion;
|
|
2987
|
-
/**
|
|
2988
|
-
* Show/hide panels
|
|
2989
|
-
*/
|
|
2990
|
-
private showIdentifierPanel;
|
|
2991
|
-
private showVerificationPanel;
|
|
2992
|
-
/**
|
|
2993
|
-
* Show/hide loading
|
|
2994
|
-
*/
|
|
2995
|
-
private showLoading;
|
|
2996
|
-
private hideLoading;
|
|
2997
|
-
/**
|
|
2998
|
-
* Show/hide error messages
|
|
2999
|
-
*/
|
|
3000
|
-
private showError;
|
|
3001
|
-
private clearError;
|
|
3002
|
-
/**
|
|
3003
|
-
* Show/hide modal
|
|
3004
|
-
*/
|
|
3005
|
-
private showModal;
|
|
3006
|
-
private hideModal;
|
|
3007
|
-
/**
|
|
3008
|
-
* Clean up
|
|
3009
|
-
*/
|
|
3010
|
-
destroy(): void;
|
|
3011
|
-
}
|
|
3012
|
-
|
|
3013
3008
|
/**
|
|
3014
3009
|
* Server-Sent Events (SSE) stream parser
|
|
3015
3010
|
* Handles parsing of streaming text responses
|
|
@@ -3166,5 +3161,5 @@ declare global {
|
|
|
3166
3161
|
}
|
|
3167
3162
|
}
|
|
3168
3163
|
|
|
3169
|
-
export { AIContextManager,
|
|
3170
|
-
export type { AIContextManagerConfig, AIContextManagerEvents, APIResult, Alignment, AlignmentItem, AudioContentPart, AuthState, ChatCompletionResponse, ChatConfig, ChatResult, ChatStreamConfig, ChatWithToolsConfig, ChatWithToolsStreamConfig, ConversationSaveData, DeveloperTokenFallbackConfig, DeviceAuthFlowOptions, DeviceAuthInitResult, DeviceAuthResult, GameInfo, GeneratedImage, IStorage, ImageContentPart, ImageGenerationConfig, ImageGenerationResponse, ImageInput, ImageSize, LogConfig, LogEntry, LogHandler, MemoryEntry, Message, MessageContent, MessageContentPart, MessageRole, NPCConfig, PlayerInfo, RechargeConfig, RechargeEvents, RechargeModalOptions, SDKConfig, SDKMode, SchemaEntry, SetNicknameRequest, SetNicknameResponse, StreamChunk, StructuredGenerationConfig, StructuredOutputConfig, StructuredResult, TTSConfig, TTSOptions, TTSResult, TTSTimestampsConfig, TTSTimestampsResult, TextContentPart, TokenRefreshResult, TokenScope, TokenStorageOptions, TokenValidatorOptions, TokenVerificationResult, TranscriptionConfig, TranscriptionOptions, TranscriptionResult, TranscriptionSegment, ValidatedPlayerInfo, VoiceMixEntry, VoiceSettings };
|
|
3164
|
+
export { AIContextManager, AuthManager, BrowserStorage, BufferLogHandler, CallbackLogHandler, ChatClient, DeviceAuthFlowManager, ImageClient, LogLevel, Logger, MemoryStorage, NPCClient, PlayKitError, PlayKitSDK, PlayerClient, RechargeManager, SchemaLibrary, StreamParser, TTSClient, TokenStorage, TokenValidator, TranscriptionClient, createMultimodalMessage, createStorage, createTextMessage, PlayKitSDK as default, defaultContextManager, defaultSchemaLibrary, defaultTokenValidator, isLocalStorageAvailable };
|
|
3165
|
+
export type { AIContextManagerConfig, AIContextManagerEvents, APIResult, Alignment, AlignmentItem, AudioContentPart, AuthState, ChatCompletionResponse, ChatConfig, ChatResult, ChatStreamConfig, ChatWithToolsConfig, ChatWithToolsStreamConfig, ConversationSaveData, DeveloperTokenFallbackConfig, DeviceAuthFlowOptions, DeviceAuthInitResult, DeviceAuthResult, Effort, GameInfo, GeneratedImage, IStorage, ImageContentPart, ImageGenerationConfig, ImageGenerationResponse, ImageInput, ImageSize, LogConfig, LogEntry, LogHandler, MemoryEntry, Message, MessageContent, MessageContentPart, MessageRole, NPCConfig, PlayerInfo, RechargeConfig, RechargeEvents, RechargeModalOptions, SDKConfig, SDKMode, SchemaEntry, SetNicknameRequest, SetNicknameResponse, StreamChunk, StructuredGenerationConfig, StructuredOutputConfig, StructuredResult, TTSConfig, TTSOptions, TTSResult, TTSTimestampsConfig, TTSTimestampsResult, TextContentPart, TokenRefreshResult, TokenScope, TokenStorageOptions, TokenValidatorOptions, TokenVerificationResult, TranscriptionConfig, TranscriptionOptions, TranscriptionResult, TranscriptionSegment, ValidatedPlayerInfo, VoiceInfo, VoiceListResult, VoiceMixEntry, VoiceSettings };
|