@byte_fluffy/nexra-sdk 0.1.0-alpha.50 → 0.1.0-alpha.53
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 +15 -110
- package/dist/catalog.d.ts +3 -3
- package/dist/catalog.js +2 -2
- package/dist/{chunk-WXPCZYOK.js → chunk-LWJWWD7Z.js} +6871 -8177
- package/dist/chunk-RBKLCJ3H.js +745 -0
- package/dist/{chunk-BS3B6F7W.js → chunk-V3F6VPMP.js} +122 -13
- package/dist/{errors-DJZuAKoO.d.ts → errors-BXPUVOh7.d.ts} +2 -2
- package/dist/index.d.ts +12 -11
- package/dist/index.js +16 -466
- package/dist/{json-Cz0MkWQn.d.ts → json-dnsDzk-s.d.ts} +1 -1
- package/dist/language.d.ts +3 -3
- package/dist/language.js +28 -243
- package/dist/{media-DzOxLGs-.d.ts → media-IaOdOMQC.d.ts} +14 -2
- package/dist/{media-geometry-COln1N_2.d.ts → media-geometry-B92BvuQL.d.ts} +3 -2
- package/dist/media.d.ts +2 -2
- package/dist/media.js +1 -1
- package/dist/node.d.ts +17 -0
- package/dist/node.js +78 -0
- package/dist/types.d.ts +5 -5
- package/dist/{voices-xyPqhQqR.d.ts → voices-Dc94LfyS.d.ts} +42 -5
- package/package.json +7 -1
package/dist/language.js
CHANGED
|
@@ -6,17 +6,18 @@ import {
|
|
|
6
6
|
jsonBody,
|
|
7
7
|
parseServerSentEvents,
|
|
8
8
|
resolveNexraLanguageReasoning
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-LWJWWD7Z.js";
|
|
10
10
|
import {
|
|
11
11
|
isPublicErrorCode,
|
|
12
12
|
publicErrorMessage,
|
|
13
13
|
resolvePublicErrorLocale
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-V3F6VPMP.js";
|
|
15
15
|
|
|
16
16
|
// src/language/index.ts
|
|
17
17
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
18
18
|
import { getModelCapabilities as getAnthropicModelCapabilities } from "@ai-sdk/anthropic/internal";
|
|
19
19
|
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
20
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
20
21
|
import { mapReasoningToProviderBudget } from "@ai-sdk/provider-utils";
|
|
21
22
|
|
|
22
23
|
// src/language/chat-model.ts
|
|
@@ -71,30 +72,6 @@ function nativeOptions(part) {
|
|
|
71
72
|
const value = part.providerOptions?.nexra;
|
|
72
73
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
73
74
|
}
|
|
74
|
-
function nativeMediaUrlPatterns(binding, kind) {
|
|
75
|
-
const field = kind === "audio" ? "input_audio" : `${kind}_url`;
|
|
76
|
-
const messages2 = asObject(asObject(binding.endpoint.inputSchema?.properties).messages);
|
|
77
|
-
const content = asObject(asObject(asObject(messages2.items).properties).content);
|
|
78
|
-
const patterns = /* @__PURE__ */ new Set();
|
|
79
|
-
const visit = (value) => {
|
|
80
|
-
if (Array.isArray(value)) {
|
|
81
|
-
value.forEach(visit);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
const node = asObject(value);
|
|
85
|
-
const properties = asObject(node.properties);
|
|
86
|
-
if (asObject(properties.type).const === field) {
|
|
87
|
-
const url = asObject(asObject(asObject(properties[field]).properties).url);
|
|
88
|
-
if (typeof url.pattern === "string") patterns.add(url.pattern);
|
|
89
|
-
}
|
|
90
|
-
for (const child of Object.values(node)) if (child && typeof child === "object") visit(child);
|
|
91
|
-
};
|
|
92
|
-
visit(content);
|
|
93
|
-
return patterns.size ? [...patterns].map((pattern) => new RegExp(pattern)) : void 0;
|
|
94
|
-
}
|
|
95
|
-
function chatSupportedUrls(binding) {
|
|
96
|
-
return Object.fromEntries(binding.spec.capabilities.inputModalities.filter((kind) => ["image", "audio", "video"].includes(kind)).map((kind) => [`${kind}/*`, nativeMediaUrlPatterns(binding, kind) ?? [/^https?:\/\//]]));
|
|
97
|
-
}
|
|
98
75
|
function filePart(part, binding) {
|
|
99
76
|
const kind = part.mediaType.split("/")[0];
|
|
100
77
|
if (["image", "audio", "video"].includes(kind) && !binding.spec.capabilities.inputModalities.includes(kind)) {
|
|
@@ -106,10 +83,6 @@ function filePart(part, binding) {
|
|
|
106
83
|
throw new UnsupportedFunctionalityError({ functionality: "file reference without a Nexra reference" });
|
|
107
84
|
}
|
|
108
85
|
const url = part.data.type === "url" ? part.data.url.toString() : void 0;
|
|
109
|
-
const patterns = nativeMediaUrlPatterns(binding, kind);
|
|
110
|
-
if (url && patterns && !patterns.some((pattern) => pattern.test(url))) {
|
|
111
|
-
throw new UnsupportedFunctionalityError({ functionality: `native media URL for ${binding.spec.id}; provide bytes or a matching data URL` });
|
|
112
|
-
}
|
|
113
86
|
const data = part.data.type === "data" ? convertToBase64(part.data.data) : void 0;
|
|
114
87
|
if (kind === "image" || kind === "video") {
|
|
115
88
|
const field = kind === "image" ? "image_url" : "video_url";
|
|
@@ -407,7 +380,7 @@ function createChatLanguageModel(binding, transport) {
|
|
|
407
380
|
specificationVersion: "v4",
|
|
408
381
|
provider: "nexra.chat",
|
|
409
382
|
modelId: binding.spec.id,
|
|
410
|
-
supportedUrls:
|
|
383
|
+
supportedUrls: Object.fromEntries(binding.spec.capabilities.inputModalities.filter((kind) => ["image", "audio", "video"].includes(kind)).map((kind) => [`${kind}/*`, [/^https?:\/\//]])),
|
|
411
384
|
async doGenerate(options) {
|
|
412
385
|
const body = chatRequest(binding, options, false);
|
|
413
386
|
const response = await transport.response("/chat/completions", { method: "POST", ...jsonBody(body), headers: combineHeaders(options), signal: options.abortSignal }, { retryable: false });
|
|
@@ -555,190 +528,6 @@ function combineHeaders(options) {
|
|
|
555
528
|
return headers;
|
|
556
529
|
}
|
|
557
530
|
|
|
558
|
-
// src/language/responses-model.ts
|
|
559
|
-
import { createOpenAI } from "@ai-sdk/openai";
|
|
560
|
-
function object3(value) {
|
|
561
|
-
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
562
|
-
}
|
|
563
|
-
function isUnpositionedCitation(value) {
|
|
564
|
-
const node = object3(value);
|
|
565
|
-
return node.type === "url_citation" && typeof node.url === "string" && !Object.hasOwn(node, "start_index") && !Object.hasOwn(node, "end_index");
|
|
566
|
-
}
|
|
567
|
-
function project(value) {
|
|
568
|
-
if (Array.isArray(value)) return value.map(project);
|
|
569
|
-
if (!value || typeof value !== "object") return value;
|
|
570
|
-
const projected = Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
571
|
-
key,
|
|
572
|
-
key === "annotations" && Array.isArray(item) ? item.filter((annotation) => !isUnpositionedCitation(annotation)).map(project) : project(item)
|
|
573
|
-
]));
|
|
574
|
-
if (projected.type === "output_text" && projected.annotations === void 0) projected.annotations = [];
|
|
575
|
-
return projected;
|
|
576
|
-
}
|
|
577
|
-
function citations(value) {
|
|
578
|
-
if (Array.isArray(value)) return value.flatMap(citations);
|
|
579
|
-
const node = object3(value);
|
|
580
|
-
if (isUnpositionedCitation(node)) return [node];
|
|
581
|
-
return Object.values(node).flatMap((item) => item && typeof item === "object" ? citations(item) : []);
|
|
582
|
-
}
|
|
583
|
-
function nativeSearchBody(value, call) {
|
|
584
|
-
const extension = call.providerOptions?.nexra?.web_search;
|
|
585
|
-
if (extension === void 0) return value;
|
|
586
|
-
if (!extension || typeof extension !== "object" || Array.isArray(extension)) throw new Error("Nexra web_search options must be a native tool object");
|
|
587
|
-
const body = object3(value);
|
|
588
|
-
if (!Array.isArray(body.tools) || !body.tools.some((tool) => object3(tool).type === "web_search")) {
|
|
589
|
-
throw new Error("Nexra web_search options require an enabled web_search tool");
|
|
590
|
-
}
|
|
591
|
-
return { ...body, tools: body.tools.map((tool) => object3(tool).type === "web_search" ? { ...object3(tool), ...extension, type: "web_search" } : tool) };
|
|
592
|
-
}
|
|
593
|
-
function nativeSearchRequest(init, call) {
|
|
594
|
-
return typeof init?.body === "string" ? { ...init, body: JSON.stringify(nativeSearchBody(JSON.parse(init.body), call)) } : init;
|
|
595
|
-
}
|
|
596
|
-
function createResponsesLanguageModel(options) {
|
|
597
|
-
const factory = (fetch) => createOpenAI({
|
|
598
|
-
apiKey: options.apiKey,
|
|
599
|
-
headers: options.headers,
|
|
600
|
-
name: "nexra.openai",
|
|
601
|
-
baseURL: options.baseUrl,
|
|
602
|
-
fetch
|
|
603
|
-
}).responses(options.modelId);
|
|
604
|
-
const base = factory(options.fetch);
|
|
605
|
-
return {
|
|
606
|
-
specificationVersion: "v4",
|
|
607
|
-
provider: base.provider,
|
|
608
|
-
modelId: base.modelId,
|
|
609
|
-
supportedUrls: base.supportedUrls,
|
|
610
|
-
async doGenerate(call) {
|
|
611
|
-
let original;
|
|
612
|
-
const fetch = async (input, init) => {
|
|
613
|
-
const response = await options.fetch(input, nativeSearchRequest(init, call));
|
|
614
|
-
if (!response.ok || !response.headers.get("content-type")?.includes("application/json")) return response;
|
|
615
|
-
const text = await response.text();
|
|
616
|
-
try {
|
|
617
|
-
original = JSON.parse(text);
|
|
618
|
-
} catch {
|
|
619
|
-
return new Response(text, response);
|
|
620
|
-
}
|
|
621
|
-
return new Response(JSON.stringify(project(original)), response);
|
|
622
|
-
};
|
|
623
|
-
const result = await factory(fetch).doGenerate(call);
|
|
624
|
-
const seen = /* @__PURE__ */ new Set();
|
|
625
|
-
const sources = sourceParts(original, seen);
|
|
626
|
-
return {
|
|
627
|
-
...result,
|
|
628
|
-
content: [...result.content, ...sources],
|
|
629
|
-
request: result.request ? { ...result.request, body: nativeSearchBody(result.request.body, call) } : void 0,
|
|
630
|
-
response: { ...result.response, ...original === void 0 ? {} : { body: original } }
|
|
631
|
-
};
|
|
632
|
-
},
|
|
633
|
-
async doStream(call) {
|
|
634
|
-
const entries = /* @__PURE__ */ new Map();
|
|
635
|
-
let before = [];
|
|
636
|
-
const canceled = new AbortController();
|
|
637
|
-
const fetch = async (input, init) => {
|
|
638
|
-
const response = await options.fetch(input, nativeSearchRequest(init, call));
|
|
639
|
-
if (!response.ok || !response.headers.get("content-type")?.includes("text/event-stream")) return response;
|
|
640
|
-
const signal = init?.signal ? AbortSignal.any([init.signal, canceled.signal]) : canceled.signal;
|
|
641
|
-
const iterator = parseServerSentEvents(response, { signal });
|
|
642
|
-
const encoder = new TextEncoder();
|
|
643
|
-
const body = new ReadableStream({
|
|
644
|
-
async pull(controller) {
|
|
645
|
-
try {
|
|
646
|
-
while (true) {
|
|
647
|
-
const next = await iterator.next();
|
|
648
|
-
if (next.done) {
|
|
649
|
-
controller.close();
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
const frame = next.value;
|
|
653
|
-
let native;
|
|
654
|
-
try {
|
|
655
|
-
native = JSON.parse(frame.data);
|
|
656
|
-
} catch {
|
|
657
|
-
controller.enqueue(encoder.encode(`${frame.event ? `event: ${frame.event}
|
|
658
|
-
` : ""}data: ${frame.data}
|
|
659
|
-
|
|
660
|
-
`));
|
|
661
|
-
return;
|
|
662
|
-
}
|
|
663
|
-
if (object3(native).type === "response.output_text.annotation.added" && isUnpositionedCitation(object3(native).annotation)) {
|
|
664
|
-
before.push(native);
|
|
665
|
-
continue;
|
|
666
|
-
}
|
|
667
|
-
const projected = project(native);
|
|
668
|
-
const key = JSON.stringify(projected);
|
|
669
|
-
const queue = entries.get(key) ?? [];
|
|
670
|
-
queue.push({ original: native, before });
|
|
671
|
-
before = [];
|
|
672
|
-
entries.set(key, queue);
|
|
673
|
-
controller.enqueue(encoder.encode(`${frame.id ? `id: ${frame.id}
|
|
674
|
-
` : ""}${frame.event ? `event: ${frame.event}
|
|
675
|
-
` : ""}${frame.retry !== void 0 ? `retry: ${frame.retry}
|
|
676
|
-
` : ""}data: ${key}
|
|
677
|
-
|
|
678
|
-
`));
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
} catch (error) {
|
|
682
|
-
controller.error(error);
|
|
683
|
-
await iterator.return(void 0);
|
|
684
|
-
}
|
|
685
|
-
},
|
|
686
|
-
async cancel(reason) {
|
|
687
|
-
canceled.abort(reason);
|
|
688
|
-
await iterator.return(void 0);
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
return new Response(body, response);
|
|
692
|
-
};
|
|
693
|
-
const result = await factory(fetch).doStream({ ...call, includeRawChunks: true });
|
|
694
|
-
const seen = /* @__PURE__ */ new Set();
|
|
695
|
-
return {
|
|
696
|
-
...result,
|
|
697
|
-
request: result.request ? { ...result.request, body: nativeSearchBody(result.request.body, call) } : void 0,
|
|
698
|
-
stream: result.stream.pipeThrough(new TransformStream({
|
|
699
|
-
transform(part, controller) {
|
|
700
|
-
if (part.type !== "raw") {
|
|
701
|
-
controller.enqueue(part);
|
|
702
|
-
return;
|
|
703
|
-
}
|
|
704
|
-
const key = JSON.stringify(part.rawValue);
|
|
705
|
-
const queue = entries.get(key);
|
|
706
|
-
const entry = queue?.shift();
|
|
707
|
-
if (queue?.length === 0) entries.delete(key);
|
|
708
|
-
const native = entry?.original ?? part.rawValue;
|
|
709
|
-
for (const frame of [...entry?.before ?? [], native]) {
|
|
710
|
-
for (const source of sourceParts(frame, seen)) controller.enqueue(source);
|
|
711
|
-
if (call.includeRawChunks) controller.enqueue({ type: "raw", rawValue: frame });
|
|
712
|
-
}
|
|
713
|
-
},
|
|
714
|
-
flush(controller) {
|
|
715
|
-
for (const frame of before) {
|
|
716
|
-
for (const source of sourceParts(frame, seen)) controller.enqueue(source);
|
|
717
|
-
if (call.includeRawChunks) controller.enqueue({ type: "raw", rawValue: frame });
|
|
718
|
-
}
|
|
719
|
-
entries.clear();
|
|
720
|
-
before = [];
|
|
721
|
-
}
|
|
722
|
-
}))
|
|
723
|
-
};
|
|
724
|
-
}
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
function sourceParts(value, seen) {
|
|
728
|
-
return citations(value).flatMap((annotation) => {
|
|
729
|
-
const key = JSON.stringify([annotation.url, annotation.title]);
|
|
730
|
-
if (seen.has(key)) return [];
|
|
731
|
-
seen.add(key);
|
|
732
|
-
return [{
|
|
733
|
-
type: "source",
|
|
734
|
-
sourceType: "url",
|
|
735
|
-
id: `native-source-${seen.size}`,
|
|
736
|
-
url: annotation.url,
|
|
737
|
-
...typeof annotation.title === "string" ? { title: annotation.title } : {}
|
|
738
|
-
}];
|
|
739
|
-
});
|
|
740
|
-
}
|
|
741
|
-
|
|
742
531
|
// src/language/index.ts
|
|
743
532
|
function createNexraLanguageModel(modelId, options) {
|
|
744
533
|
const binding = getLanguageModelBinding(modelId, options);
|
|
@@ -764,30 +553,30 @@ function createNexraLanguageModel(modelId, options) {
|
|
|
764
553
|
input,
|
|
765
554
|
typeof init?.body === "string" ? { ...init, body: JSON.stringify(explicitResponsesMessages(JSON.parse(init.body))) } : init
|
|
766
555
|
);
|
|
767
|
-
model =
|
|
556
|
+
model = createOpenAI({ ...common, name: "nexra.openai", baseURL: `${root}/v1`, fetch: responsesFetch }).responses(binding.spec.id);
|
|
768
557
|
} else {
|
|
769
558
|
model = createAnthropic({ ...common, name: "nexra.anthropic", baseURL: `${root}/v1` })(binding.spec.id);
|
|
770
559
|
}
|
|
771
560
|
return withNativeContract(model, binding);
|
|
772
561
|
}
|
|
773
|
-
function
|
|
562
|
+
function object3(value) {
|
|
774
563
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
775
564
|
}
|
|
776
565
|
function explicitResponsesMessages(value) {
|
|
777
|
-
const body =
|
|
566
|
+
const body = object3(value);
|
|
778
567
|
if (!Array.isArray(body.input)) return value;
|
|
779
568
|
return { ...body, input: body.input.map((value2) => {
|
|
780
|
-
const item =
|
|
569
|
+
const item = object3(value2);
|
|
781
570
|
return item.type === void 0 && ["system", "developer", "user", "assistant"].includes(String(item.role)) && (typeof item.content === "string" || Array.isArray(item.content)) ? { ...item, type: "message" } : value2;
|
|
782
571
|
}) };
|
|
783
572
|
}
|
|
784
573
|
function googleNativeBody(binding, value) {
|
|
785
|
-
const body =
|
|
786
|
-
const config =
|
|
787
|
-
const thinking =
|
|
788
|
-
const fields =
|
|
789
|
-
const nativeThinking =
|
|
790
|
-
const values =
|
|
574
|
+
const body = object3(value);
|
|
575
|
+
const config = object3(body.generationConfig);
|
|
576
|
+
const thinking = object3(config.thinkingConfig);
|
|
577
|
+
const fields = object3(binding.endpoint.inputSchema?.properties);
|
|
578
|
+
const nativeThinking = object3(object3(object3(object3(fields.generationConfig).properties).thinkingConfig).properties);
|
|
579
|
+
const values = object3(nativeThinking.thinkingLevel).enum;
|
|
791
580
|
const level = typeof thinking.thinkingLevel === "string" && Array.isArray(values) ? values.find((value2) => typeof value2 === "string" && value2.toLowerCase() === String(thinking.thinkingLevel).toLowerCase()) : void 0;
|
|
792
581
|
return level === void 0 || level === thinking.thinkingLevel ? value : { ...body, generationConfig: { ...config, thinkingConfig: { ...thinking, thinkingLevel: level } } };
|
|
793
582
|
}
|
|
@@ -795,29 +584,25 @@ function nativeRequest(binding, request, stream = false) {
|
|
|
795
584
|
if (!request) return request;
|
|
796
585
|
return binding.endpoint.protocol === "openai-responses" ? {
|
|
797
586
|
...request,
|
|
798
|
-
body: explicitResponsesMessages(stream ? { ...
|
|
587
|
+
body: explicitResponsesMessages(stream ? { ...object3(request.body), stream: true } : request.body)
|
|
799
588
|
} : binding.endpoint.protocol === "gemini-generate-content" ? { ...request, body: googleNativeBody(binding, request.body) } : request;
|
|
800
589
|
}
|
|
801
590
|
function prepare(options, binding, stream) {
|
|
802
591
|
binding = getLanguageModelBinding(binding.spec.id, { protocol: binding.endpoint.protocol, stream });
|
|
803
592
|
options = prepareLanguageReasoning(options, binding);
|
|
804
|
-
const properties =
|
|
805
|
-
const
|
|
806
|
-
if (options.toolChoice && Array.isArray(choices2) && !choices2.includes(options.toolChoice.type)) {
|
|
807
|
-
throw new Error(`Nexra tool choice is outside the native contract for ${binding.spec.id}: ${options.toolChoice.type}`);
|
|
808
|
-
}
|
|
809
|
-
const tokenField = object4(binding.endpoint.protocol === "gemini-generate-content" ? object4(object4(properties.generationConfig).properties).maxOutputTokens : properties.max_output_tokens ?? properties.max_tokens);
|
|
593
|
+
const properties = object3(binding.endpoint.inputSchema?.properties);
|
|
594
|
+
const tokenField = object3(binding.endpoint.protocol === "gemini-generate-content" ? object3(object3(properties.generationConfig).properties).maxOutputTokens : properties.max_output_tokens ?? properties.max_tokens);
|
|
810
595
|
if (options.maxOutputTokens !== void 0 && (!Number.isInteger(options.maxOutputTokens) || typeof tokenField.minimum === "number" && options.maxOutputTokens < tokenField.minimum || binding.maxOutputTokens !== void 0 && options.maxOutputTokens > binding.maxOutputTokens)) throw new Error(`Nexra output token limit is outside the native contract for ${binding.spec.id}`);
|
|
811
596
|
if (options.tools?.length && !binding.endpoint.capabilities.includes("tool_call")) throw new Error(`Nexra model does not support tools: ${binding.spec.id}`);
|
|
812
597
|
const providerOptions = { ...options.providerOptions };
|
|
813
598
|
if (binding.endpoint.protocol === "openai-responses") {
|
|
814
|
-
const current =
|
|
599
|
+
const current = object3(providerOptions.openai);
|
|
815
600
|
providerOptions.openai = {
|
|
816
601
|
store: false,
|
|
817
602
|
forceReasoning: binding.endpoint.capabilities.includes("reasoning"),
|
|
818
603
|
...current
|
|
819
604
|
};
|
|
820
|
-
const reasoning =
|
|
605
|
+
const reasoning = object3(providerOptions.openai);
|
|
821
606
|
if (reasoning.forceReasoning === true && (options.temperature !== void 0 || options.topP !== void 0)) {
|
|
822
607
|
throw new Error(`Nexra Responses adapter cannot preserve explicit sampling parameters with reasoning for ${binding.spec.id}`);
|
|
823
608
|
}
|
|
@@ -827,8 +612,8 @@ function prepare(options, binding, stream) {
|
|
|
827
612
|
}
|
|
828
613
|
if (binding.endpoint.protocol === "anthropic-messages") {
|
|
829
614
|
const capabilities = getAnthropicModelCapabilities(binding.spec.id);
|
|
830
|
-
const native = { ...
|
|
831
|
-
let thinking =
|
|
615
|
+
const native = { ...object3(providerOptions.anthropic), ...object3(providerOptions.nexra) };
|
|
616
|
+
let thinking = object3(native.thinking);
|
|
832
617
|
if (!native.thinking && native.effort == null && options.reasoning && options.reasoning !== "provider-default") {
|
|
833
618
|
thinking = options.reasoning === "none" ? { type: "disabled" } : capabilities.supportsAdaptiveThinking ? { type: "adaptive" } : { type: "enabled", budgetTokens: mapReasoningToProviderBudget({
|
|
834
619
|
reasoning: options.reasoning,
|
|
@@ -849,20 +634,20 @@ function prepare(options, binding, stream) {
|
|
|
849
634
|
options = { ...options, maxOutputTokens: visible };
|
|
850
635
|
}
|
|
851
636
|
if (stream && binding.endpoint.protocol === "gemini-generate-content" && binding.endpoint.capabilities.includes("reasoning")) {
|
|
852
|
-
const google =
|
|
853
|
-
providerOptions.google = { ...google, thinkingConfig: { includeThoughts: true, ...
|
|
637
|
+
const google = object3(providerOptions.google);
|
|
638
|
+
providerOptions.google = { ...google, thinkingConfig: { includeThoughts: true, ...object3(google.thinkingConfig) } };
|
|
854
639
|
}
|
|
855
640
|
return { ...options, providerOptions };
|
|
856
641
|
}
|
|
857
642
|
function nativeUsage(protocol, value) {
|
|
858
|
-
const payload =
|
|
859
|
-
const raw = protocol === "gemini-generate-content" ? payload.usageMetadata : protocol === "anthropic-messages" ?
|
|
643
|
+
const payload = object3(value);
|
|
644
|
+
const raw = protocol === "gemini-generate-content" ? payload.usageMetadata : protocol === "anthropic-messages" ? object3(payload.message).usage ?? payload.usage : object3(payload.response).usage ?? payload.usage;
|
|
860
645
|
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : void 0;
|
|
861
646
|
}
|
|
862
647
|
function mergeRecords(previous, next) {
|
|
863
648
|
const merged = { ...previous, ...next };
|
|
864
649
|
for (const [key, value] of Object.entries(next)) {
|
|
865
|
-
if (value && typeof value === "object" && !Array.isArray(value)) merged[key] = { ...
|
|
650
|
+
if (value && typeof value === "object" && !Array.isArray(value)) merged[key] = { ...object3(previous?.[key]), ...object3(value) };
|
|
866
651
|
}
|
|
867
652
|
return merged;
|
|
868
653
|
}
|
|
@@ -896,8 +681,8 @@ function withNativeContract(model, binding) {
|
|
|
896
681
|
stream: result.stream.pipeThrough(new TransformStream({
|
|
897
682
|
transform(part, controller) {
|
|
898
683
|
if (part.type === "raw") {
|
|
899
|
-
const payload =
|
|
900
|
-
terminal ||= binding.endpoint.protocol === "anthropic-messages" ? payload.type === "message_stop" : binding.endpoint.protocol === "openai-responses" ? ["response.completed", "response.incomplete", "response.failed"].includes(String(payload.type)) : Array.isArray(payload.candidates) && payload.candidates.some((candidate) => typeof
|
|
684
|
+
const payload = object3(part.rawValue);
|
|
685
|
+
terminal ||= binding.endpoint.protocol === "anthropic-messages" ? payload.type === "message_stop" : binding.endpoint.protocol === "openai-responses" ? ["response.completed", "response.incomplete", "response.failed"].includes(String(payload.type)) : Array.isArray(payload.candidates) && payload.candidates.some((candidate) => typeof object3(candidate).finishReason === "string");
|
|
901
686
|
const next = nativeUsage(binding.endpoint.protocol, part.rawValue);
|
|
902
687
|
if (next) raw = mergeRecords(raw, next);
|
|
903
688
|
if (options.includeRawChunks) controller.enqueue(part);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { J as JsonObject } from './json-dnsDzk-s.js';
|
|
2
2
|
|
|
3
3
|
declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "archive", "other"];
|
|
4
4
|
type MediaKind = (typeof MEDIA_KINDS)[number];
|
|
@@ -161,6 +161,8 @@ type NexraVideoGenerateInput = Readonly<{
|
|
|
161
161
|
duration?: number;
|
|
162
162
|
fit?: "contain" | "cover";
|
|
163
163
|
title?: string;
|
|
164
|
+
/** Audio source for models that expose original-video sound. */
|
|
165
|
+
audio?: "native" | "original";
|
|
164
166
|
generate_audio?: boolean;
|
|
165
167
|
output_format?: string;
|
|
166
168
|
seed?: number;
|
|
@@ -217,8 +219,18 @@ type NexraVideoDepthInput = Readonly<{
|
|
|
217
219
|
resolution?: string;
|
|
218
220
|
}>;
|
|
219
221
|
type NexraVideoSegmentInput = Readonly<{
|
|
220
|
-
content: readonly [NexraVideoContentPart, NexraTextContentPart] | readonly [NexraTextContentPart, NexraVideoContentPart];
|
|
222
|
+
content: readonly [NexraVideoContentPart, NexraTextContentPart] | readonly [NexraTextContentPart, NexraVideoContentPart] | readonly [NexraVideoContentPart];
|
|
221
223
|
resolution?: string;
|
|
224
|
+
mode?: "preview" | "track";
|
|
225
|
+
preview_time_ms?: number;
|
|
226
|
+
prompts?: readonly Readonly<{
|
|
227
|
+
time_ms: number;
|
|
228
|
+
points: readonly Readonly<{
|
|
229
|
+
x: number;
|
|
230
|
+
y: number;
|
|
231
|
+
label: 0 | 1;
|
|
232
|
+
}>[];
|
|
233
|
+
}>[];
|
|
222
234
|
}>;
|
|
223
235
|
type NexraMediaInputByOperation = Readonly<{
|
|
224
236
|
"image.generate": NexraImageGenerateInput;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as JsonPrimitive, J as JsonObject, b as JsonValue } from './json-dnsDzk-s.js';
|
|
2
2
|
|
|
3
3
|
declare const BILLING_METRICS: readonly ["requests", "input_tokens", "cached_input_tokens", "cache_write_tokens", "cache_creation_5m_input_tokens", "cache_creation_1h_input_tokens", "cache_read_input_tokens", "output_tokens", "input_characters", "input_utf8_bytes", "input_images", "output_images", "input_audio_seconds", "output_audio_seconds", "input_video_seconds", "output_video_seconds", "provider_credits", "web_search_requests"];
|
|
4
4
|
type BillingMetric = (typeof BILLING_METRICS)[number];
|
|
@@ -335,6 +335,7 @@ declare class HttpTransport {
|
|
|
335
335
|
private readonly maxRetries;
|
|
336
336
|
constructor(options: NexraClientOptions);
|
|
337
337
|
url(path: string): string;
|
|
338
|
+
headers(additional?: HeadersInit): Headers;
|
|
338
339
|
json<T>(path: string, init?: RequestInit, options?: RequestOptions): Promise<T>;
|
|
339
340
|
response(path: string, init?: RequestInit, options?: RequestOptions): Promise<Response>;
|
|
340
341
|
}
|
|
@@ -366,4 +367,4 @@ declare function decodeMediaGeometry(_inputSchema: JsonObject, input: JsonObject
|
|
|
366
367
|
/** Normalize the SDK convenience alias `ratio` without producing Native fields. */
|
|
367
368
|
declare function applyMediaGeometry(inputSchema: JsonObject, input: JsonObject): JsonObject;
|
|
368
369
|
|
|
369
|
-
export { type
|
|
370
|
+
export { type NexraCatalogChangeParams as A, type NexraCatalogChangePage as B, type CreateNexraDisplayQuoteBatchRequest as C, type NexraCatalogModelState as D, type NexraModelEndpointSpec as E, type FetchLike as F, type NexraCatalogModelIdentity as G, HttpTransport as H, type MediaGeometryField as M, type NexraClientOptions as N, type TaskModel as T, type UnifiedMediaGeometry as U, type CreateNexraQuoteRequest as a, type MediaGeometryProjection as b, type ModelCapabilitySummary as c, type ModelDateVersion as d, type ModelEndpointSummary as e, type ModelModality as f, type ModelResourceList as g, type ModelResourceOption as h, type ModelSchema as i, type ModelSearchParams as j, type NexraBillingCurrency as k, type NexraCatalogRevision as l, type NexraDisplayQuoteBatch as m, type NexraDisplayQuoteBatchEntry as n, type NexraModelOperation as o, type NexraModelSpec as p, type NexraModelSpecFilter as q, type NexraQuote as r, type NexraSalePrice as s, type NexraSalePriceList as t, type NexraSettlement as u, type TaskModelSummary as v, applyMediaGeometry as w, decodeMediaGeometry as x, encodeMediaGeometry as y, projectMediaGeometry as z };
|
package/dist/media.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { k as NEXRA_GENERATION_OPERATIONS, l as NEXRA_MEDIA_API_VERSION, m as NEXRA_MEDIA_FEATURES, n as NEXRA_MEDIA_INPUT_SCHEMAS, o as NEXRA_MEDIA_OPERATIONS, p as NEXRA_MEDIA_OPERATION_DEFINITIONS, q as NEXRA_PUBLISHED_MEDIA_OPERATIONS, r as NexraAudioContentPart, s as NexraAudioGenerateInput, t as NexraAudioTranscribeInput, u as NexraGenerationOperation, v as NexraImageContentPart, w as NexraImageGenerateInput, N as NexraImageLayer, g as NexraImageLayerDecompositionOutput, x as NexraImageUpscaleInput, y as NexraMediaContentPart, z as NexraMediaFeature, B as NexraMediaInputByOperation, C as NexraMediaInputMode, D as NexraMediaInputSlot, E as NexraMediaKind, F as NexraMediaOperation, G as NexraMediaOperationDefinition, H as NexraMediaParameter, I as NexraMediaParameterConstraint, J as NexraMediaSource, K as NexraPublishedMediaOperation, L as NexraResourceContentPart, O as NexraTextContentPart, P as NexraVideoContentPart, Q as NexraVideoDepthInput, R as NexraVideoGenerateInput, S as NexraVideoKeyframeContentPart, T as NexraVideoUpscaleInput, U as isNexraMediaInput, V as nexraMediaInputSchema, W as nexraMediaInputSchemaForMode, X as nexraMediaOperationForMode } from './media-
|
|
2
|
-
import './json-
|
|
1
|
+
export { k as NEXRA_GENERATION_OPERATIONS, l as NEXRA_MEDIA_API_VERSION, m as NEXRA_MEDIA_FEATURES, n as NEXRA_MEDIA_INPUT_SCHEMAS, o as NEXRA_MEDIA_OPERATIONS, p as NEXRA_MEDIA_OPERATION_DEFINITIONS, q as NEXRA_PUBLISHED_MEDIA_OPERATIONS, r as NexraAudioContentPart, s as NexraAudioGenerateInput, t as NexraAudioTranscribeInput, u as NexraGenerationOperation, v as NexraImageContentPart, w as NexraImageGenerateInput, N as NexraImageLayer, g as NexraImageLayerDecompositionOutput, x as NexraImageUpscaleInput, y as NexraMediaContentPart, z as NexraMediaFeature, B as NexraMediaInputByOperation, C as NexraMediaInputMode, D as NexraMediaInputSlot, E as NexraMediaKind, F as NexraMediaOperation, G as NexraMediaOperationDefinition, H as NexraMediaParameter, I as NexraMediaParameterConstraint, J as NexraMediaSource, K as NexraPublishedMediaOperation, L as NexraResourceContentPart, O as NexraTextContentPart, P as NexraVideoContentPart, Q as NexraVideoDepthInput, R as NexraVideoGenerateInput, S as NexraVideoKeyframeContentPart, T as NexraVideoUpscaleInput, U as isNexraMediaInput, V as nexraMediaInputSchema, W as nexraMediaInputSchemaForMode, X as nexraMediaOperationForMode } from './media-IaOdOMQC.js';
|
|
2
|
+
import './json-dnsDzk-s.js';
|
package/dist/media.js
CHANGED
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export { A as AssetImportRequest, a as AssetInput, b as AssetReference, c as AssetUploadOptions, M as MEDIA_KINDS, d as MediaAsset, e as MediaAssetStatus, f as MediaKind, N as NexraImageLayer, g as NexraImageLayerDecompositionOutput } from './media-IaOdOMQC.js';
|
|
2
|
+
import { N as NexraClientOptions } from './media-geometry-B92BvuQL.js';
|
|
3
|
+
export { C as CreateNexraDisplayQuoteBatchRequest, a as CreateNexraQuoteRequest, F as FetchLike, M as MediaGeometryField, b as MediaGeometryProjection, c as ModelCapabilitySummary, d as ModelDateVersion, e as ModelEndpointSummary, f as ModelModality, g as ModelResourceList, h as ModelResourceOption, i as ModelSchema, j as ModelSearchParams, k as NexraBillingCurrency, l as NexraCatalogRevision, m as NexraDisplayQuoteBatch, n as NexraDisplayQuoteBatchEntry, o as NexraModelOperation, p as NexraModelSpec, q as NexraModelSpecFilter, r as NexraQuote, s as NexraSalePrice, t as NexraSalePriceList, u as NexraSettlement, T as TaskModel, v as TaskModelSummary, U as UnifiedMediaGeometry, w as applyMediaGeometry, x as decodeMediaGeometry, y as encodeMediaGeometry, z as projectMediaGeometry } from './media-geometry-B92BvuQL.js';
|
|
4
|
+
export { C as CursorPage, J as JsonObject, a as JsonPrimitive, b as JsonValue } from './json-dnsDzk-s.js';
|
|
5
|
+
export { A as ApiErrorPayload, N as NexraError, P as PublicError, a as PublicErrorContext, b as PublicErrorFields, e as extractUpstreamErrorMessage } from './errors-BXPUVOh7.js';
|
|
6
|
+
export { A as AssetsClient, C as CreateTaskOptions, a as CreateTaskRequest, b as CreateVoiceRequest, N as NexraTranscriptionError, R as RequestDetails, c as RunResult, d as RunTaskOptions, T as TASK_STATUSES, e as Task, f as TaskCost, g as TaskError, h as TaskEvent, i as TaskEventType, j as TaskListParams, k as TaskPage, l as TaskProgress, m as TaskReceipt, e as TaskResult, n as TaskStatus, o as TaskTiming, p as TaskUsage, q as TaskWebhookConfig, r as TasksClient, s as TerminalTaskStatus, t as TranscriptionClient, u as TranscriptionEvent, v as TranscriptionResponse, w as TranscriptionStreamOptions, V as VerifyWebhookOptions, x as Voice, y as VoiceCreation, W as WaitTaskOptions, z as WatchTaskOptions, B as isTerminalTaskStatus, D as verifyWebhook } from './voices-Dc94LfyS.js';
|
|
7
|
+
export { CatalogClient, formatModelDisplayName, getModelSpec, listModelSpecs } from './catalog.js';
|
|
8
|
+
import { NexraClient as NexraClient$1 } from './index.js';
|
|
9
|
+
export { CreateVoiceOptions, ModelsClient, NexraApiError, NexraTaskError, NexraWaitTimeoutError, VoicesClient } from './index.js';
|
|
10
|
+
export { ceilDecimal, multiplyDecimal } from './decimal.js';
|
|
11
|
+
|
|
12
|
+
declare class NexraClient extends NexraClient$1 {
|
|
13
|
+
constructor(options?: NexraClientOptions);
|
|
14
|
+
}
|
|
15
|
+
declare function createNexra(options?: NexraClientOptions): NexraClient;
|
|
16
|
+
|
|
17
|
+
export { NexraClient, NexraClientOptions, createNexra };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AssetsClient,
|
|
3
|
+
ModelsClient,
|
|
4
|
+
NexraClient,
|
|
5
|
+
NexraTranscriptionError,
|
|
6
|
+
TasksClient,
|
|
7
|
+
TranscriptionClient,
|
|
8
|
+
VoicesClient,
|
|
9
|
+
verifyWebhook
|
|
10
|
+
} from "./chunk-RBKLCJ3H.js";
|
|
11
|
+
import {
|
|
12
|
+
ceilDecimal,
|
|
13
|
+
multiplyDecimal
|
|
14
|
+
} from "./chunk-FCH5IQP5.js";
|
|
15
|
+
import {
|
|
16
|
+
CatalogClient,
|
|
17
|
+
NexraApiError,
|
|
18
|
+
NexraTaskError,
|
|
19
|
+
NexraWaitTimeoutError,
|
|
20
|
+
applyMediaGeometry,
|
|
21
|
+
decodeMediaGeometry,
|
|
22
|
+
encodeMediaGeometry,
|
|
23
|
+
formatModelDisplayName,
|
|
24
|
+
getModelSpec,
|
|
25
|
+
listModelSpecs,
|
|
26
|
+
projectMediaGeometry
|
|
27
|
+
} from "./chunk-LWJWWD7Z.js";
|
|
28
|
+
import {
|
|
29
|
+
ASR_MAX_FRAME_BYTES,
|
|
30
|
+
MEDIA_KINDS,
|
|
31
|
+
TASK_STATUSES,
|
|
32
|
+
extractUpstreamErrorMessage,
|
|
33
|
+
isTerminalTaskStatus
|
|
34
|
+
} from "./chunk-V3F6VPMP.js";
|
|
35
|
+
|
|
36
|
+
// src/node.ts
|
|
37
|
+
import WebSocket from "ws";
|
|
38
|
+
var NexraClient2 = class extends NexraClient {
|
|
39
|
+
constructor(options = {}) {
|
|
40
|
+
super(options, (url, headers) => new WebSocket(url, {
|
|
41
|
+
headers: Object.fromEntries(headers),
|
|
42
|
+
maxPayload: ASR_MAX_FRAME_BYTES,
|
|
43
|
+
followRedirects: false,
|
|
44
|
+
perMessageDeflate: false
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function createNexra(options = {}) {
|
|
49
|
+
return new NexraClient2(options);
|
|
50
|
+
}
|
|
51
|
+
export {
|
|
52
|
+
AssetsClient,
|
|
53
|
+
CatalogClient,
|
|
54
|
+
MEDIA_KINDS,
|
|
55
|
+
ModelsClient,
|
|
56
|
+
NexraApiError,
|
|
57
|
+
NexraClient2 as NexraClient,
|
|
58
|
+
NexraTaskError,
|
|
59
|
+
NexraTranscriptionError,
|
|
60
|
+
NexraWaitTimeoutError,
|
|
61
|
+
TASK_STATUSES,
|
|
62
|
+
TasksClient,
|
|
63
|
+
TranscriptionClient,
|
|
64
|
+
VoicesClient,
|
|
65
|
+
applyMediaGeometry,
|
|
66
|
+
ceilDecimal,
|
|
67
|
+
createNexra,
|
|
68
|
+
decodeMediaGeometry,
|
|
69
|
+
encodeMediaGeometry,
|
|
70
|
+
extractUpstreamErrorMessage,
|
|
71
|
+
formatModelDisplayName,
|
|
72
|
+
getModelSpec,
|
|
73
|
+
isTerminalTaskStatus,
|
|
74
|
+
listModelSpecs,
|
|
75
|
+
multiplyDecimal,
|
|
76
|
+
projectMediaGeometry,
|
|
77
|
+
verifyWebhook
|
|
78
|
+
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { A as AssetImportRequest, a as AssetInput, b as AssetReference, c as AssetUploadOptions, d as MediaAsset, e as MediaAssetStatus, f as MediaKind, N as NexraImageLayer, g as NexraImageLayerDecompositionOutput } from './media-
|
|
2
|
-
export {
|
|
3
|
-
export { C as CursorPage,
|
|
4
|
-
export { A as ApiErrorPayload, N as NexraError,
|
|
5
|
-
export {
|
|
1
|
+
export { A as AssetImportRequest, a as AssetInput, b as AssetReference, c as AssetUploadOptions, d as MediaAsset, e as MediaAssetStatus, f as MediaKind, N as NexraImageLayer, g as NexraImageLayerDecompositionOutput } from './media-IaOdOMQC.js';
|
|
2
|
+
export { C as CreateNexraDisplayQuoteBatchRequest, a as CreateNexraQuoteRequest, F as FetchLike, M as MediaGeometryField, b as MediaGeometryProjection, c as ModelCapabilitySummary, d as ModelDateVersion, e as ModelEndpointSummary, f as ModelModality, g as ModelResourceList, h as ModelResourceOption, i as ModelSchema, j as ModelSearchParams, k as NexraBillingCurrency, l as NexraCatalogRevision, N as NexraClientOptions, m as NexraDisplayQuoteBatch, n as NexraDisplayQuoteBatchEntry, o as NexraModelOperation, p as NexraModelSpec, q as NexraModelSpecFilter, r as NexraQuote, s as NexraSalePrice, t as NexraSalePriceList, u as NexraSettlement, T as TaskModel, v as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-B92BvuQL.js';
|
|
3
|
+
export { C as CursorPage, J as JsonObject, a as JsonPrimitive, b as JsonValue } from './json-dnsDzk-s.js';
|
|
4
|
+
export { A as ApiErrorPayload, N as NexraError, P as PublicError, a as PublicErrorContext, b as PublicErrorFields } from './errors-BXPUVOh7.js';
|
|
5
|
+
export { C as CreateTaskOptions, a as CreateTaskRequest, b as CreateVoiceRequest, R as RequestDetails, c as RunResult, d as RunTaskOptions, e as Task, f as TaskCost, g as TaskError, h as TaskEvent, i as TaskEventType, j as TaskListParams, k as TaskPage, l as TaskProgress, m as TaskReceipt, e as TaskResult, n as TaskStatus, o as TaskTiming, p as TaskUsage, q as TaskWebhookConfig, s as TerminalTaskStatus, u as TranscriptionEvent, v as TranscriptionResponse, w as TranscriptionStreamOptions, V as VerifyWebhookOptions, x as Voice, y as VoiceCreation, W as WaitTaskOptions, z as WatchTaskOptions } from './voices-Dc94LfyS.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { c as AssetUploadOptions, d as MediaAsset, A as AssetImportRequest, h as AssetCertificationRequest, i as AssetCertification, j as AssetCertificationWaitOptions } from './media-
|
|
2
|
-
import { H as HttpTransport,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { c as AssetUploadOptions, d as MediaAsset, A as AssetImportRequest, h as AssetCertificationRequest, i as AssetCertification, j as AssetCertificationWaitOptions } from './media-IaOdOMQC.js';
|
|
2
|
+
import { H as HttpTransport, u as NexraSettlement } from './media-geometry-B92BvuQL.js';
|
|
3
|
+
import { J as JsonObject, b as JsonValue, C as CursorPage } from './json-dnsDzk-s.js';
|
|
4
|
+
import { b as PublicErrorFields, P as PublicError, a as PublicErrorContext, N as NexraError } from './errors-BXPUVOh7.js';
|
|
5
5
|
|
|
6
6
|
declare class AssetsClient {
|
|
7
7
|
private readonly transport;
|
|
@@ -53,6 +53,43 @@ declare class TasksClient {
|
|
|
53
53
|
run<TOutput = JsonValue, TInput = Record<string, unknown>>(model: string, input: TInput, options?: RunTaskOptions): Promise<RunResult<TOutput>>;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
interface TranscriptionStreamOptions {
|
|
57
|
+
model: string;
|
|
58
|
+
mode?: "realtime" | "sentence";
|
|
59
|
+
audio: AsyncIterable<Uint8Array>;
|
|
60
|
+
configuration: JsonObject;
|
|
61
|
+
organizationId?: string;
|
|
62
|
+
signal?: AbortSignal;
|
|
63
|
+
onConnected?: () => void;
|
|
64
|
+
}
|
|
65
|
+
type TranscriptionResponse = JsonObject & {
|
|
66
|
+
result?: JsonObject & {
|
|
67
|
+
text?: string;
|
|
68
|
+
};
|
|
69
|
+
audio_info?: JsonObject & {
|
|
70
|
+
duration?: number;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
interface TranscriptionEvent {
|
|
74
|
+
final: boolean;
|
|
75
|
+
response: TranscriptionResponse;
|
|
76
|
+
}
|
|
77
|
+
declare class NexraTranscriptionError extends Error {
|
|
78
|
+
readonly code: string;
|
|
79
|
+
readonly nexraRequestId?: string | undefined;
|
|
80
|
+
readonly closeCode?: number | undefined;
|
|
81
|
+
readonly upstreamCode?: number | undefined;
|
|
82
|
+
constructor(code: string, message: string, nexraRequestId?: string | undefined, closeCode?: number | undefined, upstreamCode?: number | undefined);
|
|
83
|
+
}
|
|
84
|
+
type TranscriptionSocket = Pick<WebSocket, "readyState" | "bufferedAmount" | "binaryType" | "send" | "close" | "addEventListener" | "removeEventListener" | "onmessage" | "onerror" | "onclose">;
|
|
85
|
+
type TranscriptionSocketFactory = (url: URL, headers: Headers) => TranscriptionSocket;
|
|
86
|
+
declare class TranscriptionClient {
|
|
87
|
+
private readonly transport;
|
|
88
|
+
private readonly connect;
|
|
89
|
+
constructor(transport: HttpTransport, connect?: TranscriptionSocketFactory);
|
|
90
|
+
stream(options: TranscriptionStreamOptions): AsyncGenerator<TranscriptionEvent>;
|
|
91
|
+
}
|
|
92
|
+
|
|
56
93
|
interface VerifyWebhookOptions {
|
|
57
94
|
toleranceSeconds?: number;
|
|
58
95
|
now?: Date;
|
|
@@ -345,4 +382,4 @@ type VoiceCreation = Readonly<{
|
|
|
345
382
|
voice: Voice;
|
|
346
383
|
}>;
|
|
347
384
|
|
|
348
|
-
export { AssetsClient as A, type
|
|
385
|
+
export { AssetsClient as A, isTerminalTaskStatus as B, type CreateTaskOptions as C, verifyWebhook as D, type TranscriptionSocketFactory as E, NexraTranscriptionError as N, type RequestDetails as R, TASK_STATUSES as T, type VerifyWebhookOptions as V, type WaitTaskOptions as W, type CreateTaskRequest as a, type CreateVoiceRequest as b, type RunResult as c, type RunTaskOptions as d, type TaskResult as e, type TaskCost as f, type TaskError as g, type TaskEvent as h, type TaskEventType as i, type TaskListParams as j, type TaskPage as k, type TaskProgress as l, type TaskReceipt as m, type TaskStatus as n, type TaskTiming as o, type TaskUsage as p, type TaskWebhookConfig as q, TasksClient as r, type TerminalTaskStatus as s, TranscriptionClient as t, type TranscriptionEvent as u, type TranscriptionResponse as v, type TranscriptionStreamOptions as w, type Voice as x, type VoiceCreation as y, type WatchTaskOptions as z };
|