@byte_fluffy/nexra-sdk 0.1.0-alpha.37 → 0.1.0-alpha.39
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/dist/catalog.d.ts +3 -2
- package/dist/catalog.js +2 -2
- package/dist/{chunk-AAGTZN2G.js → chunk-EFSKJCKB.js} +4 -2
- package/dist/{chunk-ENL3IGRX.js → chunk-ZP34I6D7.js} +1079 -59
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/language.d.ts +1 -1
- package/dist/language.js +34 -10
- package/dist/{media-geometry-DAVFGry1.d.ts → media-geometry-YD9Y_CFw.d.ts} +1 -0
- package/dist/media.d.ts +1 -0
- package/dist/media.js +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/{voices-CFRCuodH.d.ts → voices-BXToLr8g.d.ts} +8 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
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 } from './assets-Cusrjj7_.js';
|
|
2
|
-
import { H as HttpTransport, M as ModelSearchParams, T as TaskModelSummary, a as TaskModel, b as ModelSchema, c as ModelResourceList, N as NexraClientOptions } from './media-geometry-
|
|
3
|
-
export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, k as ModelResourceOption, l as NexraBillingCurrency, m as NexraCatalogRevision, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, U as UnifiedMediaGeometry, w as applyMediaGeometry, x as decodeMediaGeometry, y as encodeMediaGeometry, z as projectMediaGeometry } from './media-geometry-
|
|
2
|
+
import { H as HttpTransport, M as ModelSearchParams, T as TaskModelSummary, a as TaskModel, b as ModelSchema, c as ModelResourceList, N as NexraClientOptions } from './media-geometry-YD9Y_CFw.js';
|
|
3
|
+
export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, k as ModelResourceOption, l as NexraBillingCurrency, m as NexraCatalogRevision, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, U as UnifiedMediaGeometry, w as applyMediaGeometry, x as decodeMediaGeometry, y as encodeMediaGeometry, z as projectMediaGeometry } from './media-geometry-YD9Y_CFw.js';
|
|
4
4
|
import { C as CursorPage, J as JsonValue } from './json-Cz0MkWQn.js';
|
|
5
5
|
export { a as JsonObject, b as JsonPrimitive } from './json-Cz0MkWQn.js';
|
|
6
6
|
import { N as NexraError, P as PublicErrorFields } from './errors-DZlSwyv8.js';
|
|
7
7
|
export { A as ApiErrorPayload, a as PublicError, b as PublicErrorContext } from './errors-DZlSwyv8.js';
|
|
8
|
-
import { V as Voice, C as CreateVoiceRequest, a as VoiceCreation, A as AssetsClient, T as TasksClient, R as RunTaskOptions, b as RunResult, c as TaskResult } from './voices-
|
|
9
|
-
export { d as CreateTaskOptions, e as CreateTaskRequest, f as RequestDetails, g as TASK_STATUSES, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, W as WaitTaskOptions, v as WatchTaskOptions, w as isTerminalTaskStatus, x as verifyWebhook } from './voices-
|
|
8
|
+
import { V as Voice, C as CreateVoiceRequest, a as VoiceCreation, A as AssetsClient, T as TasksClient, R as RunTaskOptions, b as RunResult, c as TaskResult } from './voices-BXToLr8g.js';
|
|
9
|
+
export { d as CreateTaskOptions, e as CreateTaskRequest, f as RequestDetails, g as TASK_STATUSES, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, W as WaitTaskOptions, v as WatchTaskOptions, w as isTerminalTaskStatus, x as verifyWebhook } from './voices-BXToLr8g.js';
|
|
10
10
|
import { CatalogClient } from './catalog.js';
|
|
11
11
|
export { formatModelDisplayName, getModelSpec, listModelSpecs } from './catalog.js';
|
|
12
12
|
export { ceilDecimal, multiplyDecimal } from './decimal.js';
|
package/dist/index.js
CHANGED
|
@@ -20,13 +20,13 @@ import {
|
|
|
20
20
|
projectMediaGeometry,
|
|
21
21
|
queryString,
|
|
22
22
|
sleep
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-ZP34I6D7.js";
|
|
24
24
|
import {
|
|
25
25
|
MEDIA_KINDS,
|
|
26
26
|
TASK_STATUSES,
|
|
27
27
|
createTaskRequest,
|
|
28
28
|
isTerminalTaskStatus
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-EFSKJCKB.js";
|
|
30
30
|
|
|
31
31
|
// src/assets.ts
|
|
32
32
|
var AssetsClient = class {
|
package/dist/language.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APICallError, LanguageModelV4 } from '@ai-sdk/provider';
|
|
2
2
|
import { NexraLanguageProtocol } from './catalog.js';
|
|
3
3
|
export { NexraLanguageModelBinding } from './catalog.js';
|
|
4
|
-
import { F as FetchLike } from './media-geometry-
|
|
4
|
+
import { F as FetchLike } from './media-geometry-YD9Y_CFw.js';
|
|
5
5
|
import { N as NexraError } from './errors-DZlSwyv8.js';
|
|
6
6
|
import './json-Cz0MkWQn.js';
|
|
7
7
|
|
package/dist/language.js
CHANGED
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
jsonBody,
|
|
7
7
|
parseServerSentEvents,
|
|
8
8
|
resolveNexraLanguageReasoning
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ZP34I6D7.js";
|
|
10
10
|
import {
|
|
11
11
|
isPublicErrorCode,
|
|
12
12
|
publicErrorMessage,
|
|
13
13
|
resolvePublicErrorLocale
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EFSKJCKB.js";
|
|
15
15
|
|
|
16
16
|
// src/language/index.ts
|
|
17
17
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
@@ -38,7 +38,9 @@ function prepareLanguageReasoning(options, binding) {
|
|
|
38
38
|
if (!binding.endpoint.capabilities.includes("reasoning")) throw new Error(`Nexra model does not support reasoning: ${binding.spec.id}`);
|
|
39
39
|
const namespace = binding.endpoint.protocol === "openai-responses" ? "openai" : binding.endpoint.protocol === "anthropic-messages" ? "anthropic" : binding.endpoint.protocol === "gemini-generate-content" ? "google" : "nexra";
|
|
40
40
|
const current = object(options.providerOptions?.[namespace]);
|
|
41
|
-
if (current.thinking !== void 0 || current.reasoningEffort !== void 0 || current.reasoning_effort !== void 0 || object(current.thinkingConfig).thinkingLevel !== void 0 || object(current.thinkingConfig).thinkingBudget !== void 0)
|
|
41
|
+
if (current.thinking !== void 0 || current.reasoningEffort !== void 0 || current.reasoning_effort !== void 0 || object(current.thinkingConfig).thinkingLevel !== void 0 || object(current.thinkingConfig).thinkingBudget !== void 0) {
|
|
42
|
+
return binding.endpoint.protocol === "gemini-generate-content" ? { ...options, reasoning: void 0 } : options;
|
|
43
|
+
}
|
|
42
44
|
const nativeField = binding.endpoint.protocol === "openai-chat-completions" ? fields.reasoning_effort : binding.endpoint.protocol === "openai-responses" ? object(object(fields.reasoning).properties).effort : binding.endpoint.protocol === "gemini-generate-content" ? object(object(object(object(fields.generationConfig).properties).thinkingConfig).properties).thinkingLevel : void 0;
|
|
43
45
|
const values = object(nativeField).enum;
|
|
44
46
|
if (options.reasoning === "none") {
|
|
@@ -47,7 +49,13 @@ function prepareLanguageReasoning(options, binding) {
|
|
|
47
49
|
const desired = object(resolved.providerOptions[namespace]);
|
|
48
50
|
return { ...options, reasoning: void 0, providerOptions: { ...options.providerOptions, [namespace]: { ...desired, ...current } } };
|
|
49
51
|
}
|
|
50
|
-
if (Array.isArray(values) && !values.
|
|
52
|
+
if (Array.isArray(values) && !values.some((value) => typeof value === "string" && value.toLowerCase() === options.reasoning)) throw new Error(`Nexra reasoning effort is outside the native contract for ${binding.spec.id}: ${options.reasoning}`);
|
|
53
|
+
if (binding.endpoint.protocol === "gemini-generate-content" && Array.isArray(values)) {
|
|
54
|
+
return { ...options, reasoning: void 0, providerOptions: {
|
|
55
|
+
...options.providerOptions,
|
|
56
|
+
google: { ...current, thinkingConfig: { ...object(current.thinkingConfig), thinkingLevel: options.reasoning } }
|
|
57
|
+
} };
|
|
58
|
+
}
|
|
51
59
|
if (binding.endpoint.protocol === "openai-chat-completions") {
|
|
52
60
|
const thinkingType = object(object(object(fields.thinking).properties).type).enum;
|
|
53
61
|
return { ...options, providerOptions: { ...options.providerOptions, nexra: {
|
|
@@ -535,7 +543,11 @@ function createNexraLanguageModel(modelId, options) {
|
|
|
535
543
|
const common = { apiKey, headers: Object.fromEntries(headers), fetch };
|
|
536
544
|
let model;
|
|
537
545
|
if (binding.endpoint.protocol === "gemini-generate-content") {
|
|
538
|
-
|
|
546
|
+
const googleFetch = (input, init) => fetch(
|
|
547
|
+
input,
|
|
548
|
+
typeof init?.body === "string" ? { ...init, body: JSON.stringify(googleNativeBody(binding, JSON.parse(init.body))) } : init
|
|
549
|
+
);
|
|
550
|
+
model = createGoogleGenerativeAI({ ...common, name: "nexra.google", baseURL: `${root}/v1beta/models`, fetch: googleFetch })(binding.spec.id);
|
|
539
551
|
} else if (binding.endpoint.protocol === "openai-responses") {
|
|
540
552
|
const responsesFetch = (input, init) => fetch(
|
|
541
553
|
input,
|
|
@@ -558,13 +570,25 @@ function explicitResponsesMessages(value) {
|
|
|
558
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;
|
|
559
571
|
}) };
|
|
560
572
|
}
|
|
561
|
-
function
|
|
562
|
-
|
|
573
|
+
function googleNativeBody(binding, value) {
|
|
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;
|
|
580
|
+
const level = typeof thinking.thinkingLevel === "string" && Array.isArray(values) ? values.find((value2) => typeof value2 === "string" && value2.toLowerCase() === String(thinking.thinkingLevel).toLowerCase()) : void 0;
|
|
581
|
+
return level === void 0 || level === thinking.thinkingLevel ? value : { ...body, generationConfig: { ...config, thinkingConfig: { ...thinking, thinkingLevel: level } } };
|
|
582
|
+
}
|
|
583
|
+
function nativeRequest(binding, request, stream = false) {
|
|
584
|
+
if (!request) return request;
|
|
585
|
+
return binding.endpoint.protocol === "openai-responses" ? {
|
|
563
586
|
...request,
|
|
564
587
|
body: explicitResponsesMessages(stream ? { ...object3(request.body), stream: true } : request.body)
|
|
565
|
-
} : request;
|
|
588
|
+
} : binding.endpoint.protocol === "gemini-generate-content" ? { ...request, body: googleNativeBody(binding, request.body) } : request;
|
|
566
589
|
}
|
|
567
590
|
function prepare(options, binding, stream) {
|
|
591
|
+
binding = getLanguageModelBinding(binding.spec.id, { protocol: binding.endpoint.protocol, stream });
|
|
568
592
|
options = prepareLanguageReasoning(options, binding);
|
|
569
593
|
const properties = object3(binding.endpoint.inputSchema?.properties);
|
|
570
594
|
const tokenField = object3(binding.endpoint.protocol === "gemini-generate-content" ? object3(object3(properties.generationConfig).properties).maxOutputTokens : properties.max_output_tokens ?? properties.max_tokens);
|
|
@@ -638,7 +662,7 @@ function withNativeContract(model, binding) {
|
|
|
638
662
|
const raw = nativeUsage(binding.endpoint.protocol, result.response?.body);
|
|
639
663
|
return {
|
|
640
664
|
...result,
|
|
641
|
-
request: nativeRequest(binding
|
|
665
|
+
request: nativeRequest(binding, result.request),
|
|
642
666
|
...raw ? { usage: { ...result.usage, raw } } : {}
|
|
643
667
|
};
|
|
644
668
|
},
|
|
@@ -653,7 +677,7 @@ function withNativeContract(model, binding) {
|
|
|
653
677
|
const reasoningMetadata2 = /* @__PURE__ */ new Map();
|
|
654
678
|
return {
|
|
655
679
|
...result,
|
|
656
|
-
request: nativeRequest(binding
|
|
680
|
+
request: nativeRequest(binding, result.request, true),
|
|
657
681
|
stream: result.stream.pipeThrough(new TransformStream({
|
|
658
682
|
transform(part, controller) {
|
|
659
683
|
if (part.type === "raw") {
|
package/dist/media.d.ts
CHANGED
|
@@ -65,6 +65,7 @@ type NexraImageGenerateInput = Readonly<{
|
|
|
65
65
|
}>;
|
|
66
66
|
type NexraVideoGenerateInput = Readonly<{
|
|
67
67
|
content: readonly (NexraMediaContentPart | NexraDraftContentPart | NexraVideoKeyframeContentPart)[];
|
|
68
|
+
task_type?: string;
|
|
68
69
|
draft?: boolean;
|
|
69
70
|
/** Explicit no-watermark value, only on models whose contract declares it. */
|
|
70
71
|
watermark?: false;
|
package/dist/media.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { A as AssetImportRequest, a as AssetInput, b as AssetReference, c as AssetUploadOptions, d as MediaAsset, e as MediaAssetStatus, f as MediaKind } from './assets-Cusrjj7_.js';
|
|
2
|
-
export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, c as ModelResourceList, k as ModelResourceOption, b as ModelSchema, M as ModelSearchParams, l as NexraBillingCurrency, m as NexraCatalogRevision, N as NexraClientOptions, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, a as TaskModel, T as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-
|
|
2
|
+
export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, c as ModelResourceList, k as ModelResourceOption, b as ModelSchema, M as ModelSearchParams, l as NexraBillingCurrency, m as NexraCatalogRevision, N as NexraClientOptions, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, a as TaskModel, T as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-YD9Y_CFw.js';
|
|
3
3
|
export { C as CursorPage, a as JsonObject, b as JsonPrimitive, J as JsonValue } from './json-Cz0MkWQn.js';
|
|
4
4
|
export { A as ApiErrorPayload, N as NexraError, a as PublicError, b as PublicErrorContext, P as PublicErrorFields } from './errors-DZlSwyv8.js';
|
|
5
|
-
export { d as CreateTaskOptions, e as CreateTaskRequest, C as CreateVoiceRequest, f as RequestDetails, b as RunResult, R as RunTaskOptions, c as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, c as TaskResult, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, V as Voice, a as VoiceCreation, W as WaitTaskOptions, v as WatchTaskOptions } from './voices-
|
|
5
|
+
export { d as CreateTaskOptions, e as CreateTaskRequest, C as CreateVoiceRequest, f as RequestDetails, b as RunResult, R as RunTaskOptions, c as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, c as TaskResult, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, V as Voice, a as VoiceCreation, W as WaitTaskOptions, v as WatchTaskOptions } from './voices-BXToLr8g.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as AssetUploadOptions, d as MediaAsset, A as AssetImportRequest, g as AssetCertificationRequest, h as AssetCertification, i as AssetCertificationWaitOptions } from './assets-Cusrjj7_.js';
|
|
2
|
-
import { H as HttpTransport, v as NexraSettlement } from './media-geometry-
|
|
2
|
+
import { H as HttpTransport, v as NexraSettlement } from './media-geometry-YD9Y_CFw.js';
|
|
3
3
|
import { a as JsonObject, J as JsonValue, C as CursorPage } from './json-Cz0MkWQn.js';
|
|
4
4
|
import { P as PublicErrorFields, a as PublicError, b as PublicErrorContext, N as NexraError } from './errors-DZlSwyv8.js';
|
|
5
5
|
|
|
@@ -95,9 +95,13 @@ interface TaskCost {
|
|
|
95
95
|
}
|
|
96
96
|
type TaskBillingReason = "request_failed" | "request_cancelled" | "billing_usage_unavailable" | "billing_usage_invalid" | "billing_usage_incomplete" | "billing_evidence_invalid" | "billing_evidence_incomplete" | "billing_hold_unavailable" | "billing_price_unavailable" | "billing_pricing_unavailable";
|
|
97
97
|
interface TaskQueueSnapshot {
|
|
98
|
-
phase: "waiting_capacity" | "waiting_channel" | "dispatch_pending";
|
|
98
|
+
phase: "waiting_capacity" | "waiting_channel" | "dispatch_pending" | "waiting_upstream";
|
|
99
99
|
since: string;
|
|
100
100
|
deadlineAt?: string;
|
|
101
|
+
/** Upstream gateway queue position, present while waiting_upstream and observed. */
|
|
102
|
+
queuePosition?: number;
|
|
103
|
+
/** Upstream gateway queue ETA in seconds, present while waiting_upstream and observed. */
|
|
104
|
+
etaSeconds?: number;
|
|
101
105
|
cancelable: boolean;
|
|
102
106
|
}
|
|
103
107
|
interface TaskTiming {
|
|
@@ -115,6 +119,8 @@ interface TaskTiming {
|
|
|
115
119
|
generationMs: number | null;
|
|
116
120
|
/** Background: elapsed persistence stage until assets are ready; terminal: measured transfer. Null when unfinished or unavailable. */
|
|
117
121
|
storageMs: number | null;
|
|
122
|
+
/** First-response time outside measured preparation/generation and any pre-response storage; not a separately instrumented stage. */
|
|
123
|
+
responseOverheadMs?: number | null;
|
|
118
124
|
/** Start of in-progress background persistence, when a worker has claimed the output. */
|
|
119
125
|
storageStartedAt?: string;
|
|
120
126
|
/** Background persistence elapsed time from first response to durable asset readiness. */
|