@byte_fluffy/nexra-sdk 0.1.0-alpha.4 → 0.1.0-alpha.6
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 -3
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +11 -3
- package/dist/{chunk-AV3GN4TV.js → chunk-BQQU5NJ7.js} +685 -92
- package/dist/{index-mytCeh5t.d.ts → index-FyUOK0F-.d.ts} +32 -1
- package/dist/index.d.ts +93 -3
- package/dist/index.js +246 -10
- package/package.json +1 -1
|
@@ -302,6 +302,37 @@ declare function jsonBody(value: unknown): Pick<RequestInit, "body" | "headers">
|
|
|
302
302
|
declare function queryString(values: Record<string, string | number | undefined>): string;
|
|
303
303
|
declare function sleep(milliseconds: number, signal?: AbortSignal | null): Promise<void>;
|
|
304
304
|
|
|
305
|
+
/** Unified canvas vocabulary: resolution 1K/2K/4K, ratio X:X. */
|
|
306
|
+
type UnifiedMediaGeometry = {
|
|
307
|
+
resolution?: string;
|
|
308
|
+
ratio?: string;
|
|
309
|
+
quality?: string;
|
|
310
|
+
};
|
|
311
|
+
type MediaGeometryField = {
|
|
312
|
+
field: string;
|
|
313
|
+
nest?: string;
|
|
314
|
+
options: readonly string[];
|
|
315
|
+
default?: string;
|
|
316
|
+
optionLabels: Readonly<Record<string, string>>;
|
|
317
|
+
};
|
|
318
|
+
type MediaGeometryProjection = {
|
|
319
|
+
kind: "pixel-size" | "tier-size" | "resolution-ratio" | "ratio-only" | "none";
|
|
320
|
+
resolution?: MediaGeometryField;
|
|
321
|
+
ratio?: MediaGeometryField;
|
|
322
|
+
quality?: MediaGeometryField;
|
|
323
|
+
};
|
|
324
|
+
/** Schema → unified resolution/ratio/quality controls for app UIs. */
|
|
325
|
+
declare function projectMediaGeometry(inputSchema: JsonObject): MediaGeometryProjection;
|
|
326
|
+
/** Unified geometry → the model's native catalog fields (channel original params). */
|
|
327
|
+
declare function encodeMediaGeometry(inputSchema: JsonObject, geometry: UnifiedMediaGeometry): JsonObject;
|
|
328
|
+
/** Native catalog fields → unified resolution/ratio/quality. */
|
|
329
|
+
declare function decodeMediaGeometry(inputSchema: JsonObject, nativeInput: JsonObject): UnifiedMediaGeometry;
|
|
330
|
+
/**
|
|
331
|
+
* Rewrite a Task/quote body: unified keys become native catalog fields.
|
|
332
|
+
* Native size/ratio already present is left alone (existing callers keep working).
|
|
333
|
+
*/
|
|
334
|
+
declare function applyMediaGeometry(inputSchema: JsonObject, input: JsonObject): JsonObject;
|
|
335
|
+
|
|
305
336
|
declare class CatalogClient {
|
|
306
337
|
private readonly transport;
|
|
307
338
|
constructor(transport: HttpTransport);
|
|
@@ -310,4 +341,4 @@ declare class CatalogClient {
|
|
|
310
341
|
declare function getModelSpec(modelId: string): NexraModelSpec | undefined;
|
|
311
342
|
declare function listModelSpecs(filter?: NexraModelSpecFilter): readonly NexraModelSpec[];
|
|
312
343
|
|
|
313
|
-
export { type
|
|
344
|
+
export { listModelSpecs as $, type NexraQuote as A, type BillingMetric as B, type CursorPage as C, type NexraSalePrice as D, type NormalizedUsageV1 as E, type FetchLike as F, type PriceEvaluationIssue as G, HttpTransport as H, type PriceEvaluationLine as I, type JsonObject as J, type PriceRule as K, type UsageComponentEvidence as L, type ModelSchema as M, type NexraSettlement as N, type UsageEvidenceAssessment as O, type PriceEvaluation as P, type UsageEvidenceStatus as Q, allocateDiscountedPriceLines as R, applyMediaGeometry as S, type TaskModelSummary as T, type UnifiedMediaGeometry as U, assessUsageEvidence as V, decodeMediaGeometry as W, encodeMediaGeometry as X, evaluatePriceRule as Y, getModelSpec as Z, jsonBody as _, type JsonValue as a, projectMediaGeometry as a0, queryString as a1, sleep as a2, validateMeteringContract as a3, validateNormalizedUsage as a4, validatePriceRule as a5, type ModelSearchParams as b, type TaskModel as c, CatalogClient as d, type NexraClientOptions as e, BILLING_EXPORT_DIMENSIONS as f, BILLING_METRICS as g, type CreateNexraQuoteRequest as h, type JsonPrimitive as i, type MediaGeometryField as j, type MediaGeometryProjection as k, type MeteredPriceRate as l, type MeteredPriceRuleV1 as m, type MeteredUsageComponent as n, type MeteringContract as o, type MeteringKind as p, type ModelCapabilitySummary as q, type ModelDateVersion as r, type ModelEndpointSummary as s, type ModelModality as t, type ModelResourceList as u, type ModelResourceOption as v, type NexraBillingCurrency as w, type NexraModelOperation as x, type NexraModelSpec as y, type NexraModelSpecFilter as z };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { J as JsonObject, B as BillingMetric, a as JsonValue, N as NexraSettlement, C as CursorPage,
|
|
2
|
-
export { f as BILLING_EXPORT_DIMENSIONS, g as BILLING_METRICS, h as CreateNexraQuoteRequest, F as FetchLike, i as JsonPrimitive, j as
|
|
1
|
+
import { J as JsonObject, B as BillingMetric, a as JsonValue, N as NexraSettlement, C as CursorPage, M as ModelSchema, T as TaskModelSummary, H as HttpTransport, b as ModelSearchParams, c as TaskModel, d as CatalogClient, e as NexraClientOptions } from './index-FyUOK0F-.js';
|
|
2
|
+
export { f as BILLING_EXPORT_DIMENSIONS, g as BILLING_METRICS, h as CreateNexraQuoteRequest, F as FetchLike, i as JsonPrimitive, j as MediaGeometryField, k as MediaGeometryProjection, l as MeteredPriceRate, m as MeteredPriceRuleV1, n as MeteredUsageComponent, o as MeteringContract, p as MeteringKind, q as ModelCapabilitySummary, r as ModelDateVersion, s as ModelEndpointSummary, t as ModelModality, u as ModelResourceList, v as ModelResourceOption, w as NexraBillingCurrency, x as NexraModelOperation, y as NexraModelSpec, z as NexraModelSpecFilter, A as NexraQuote, D as NexraSalePrice, E as NormalizedUsageV1, P as PriceEvaluation, G as PriceEvaluationIssue, I as PriceEvaluationLine, K as PriceRule, U as UnifiedMediaGeometry, L as UsageComponentEvidence, O as UsageEvidenceAssessment, Q as UsageEvidenceStatus, R as allocateDiscountedPriceLines, S as applyMediaGeometry, V as assessUsageEvidence, W as decodeMediaGeometry, X as encodeMediaGeometry, Y as evaluatePriceRule, Z as getModelSpec, _ as jsonBody, $ as listModelSpecs, a0 as projectMediaGeometry, a1 as queryString, a2 as sleep, a3 as validateMeteringContract, a4 as validateNormalizedUsage, a5 as validatePriceRule } from './index-FyUOK0F-.js';
|
|
3
3
|
export { ceilDecimal, multiplyDecimal } from './decimal.js';
|
|
4
4
|
|
|
5
5
|
declare const MEDIA_KINDS: readonly ["image", "video", "audio", "document", "archive", "other"];
|
|
@@ -647,6 +647,8 @@ interface RequestDetails {
|
|
|
647
647
|
model: string | null;
|
|
648
648
|
operation: string | null;
|
|
649
649
|
status: string;
|
|
650
|
+
/** Linked Task lifecycle when this request accepted a Task; HTTP `status` stays accepted. */
|
|
651
|
+
taskStatus?: string | null;
|
|
650
652
|
httpStatus: number | null;
|
|
651
653
|
errorCode: string | null;
|
|
652
654
|
/** HTTP duration, never substituted with asynchronous task duration. */
|
|
@@ -664,6 +666,10 @@ interface RequestDetails {
|
|
|
664
666
|
startedAt?: string;
|
|
665
667
|
completedAt?: string;
|
|
666
668
|
input: JsonObject | null;
|
|
669
|
+
/** Present only on single-request reads (`includeOutput`). */
|
|
670
|
+
output?: JsonValue | null;
|
|
671
|
+
/** Output media with durable TOS URLs; present only on `includeOutput`. */
|
|
672
|
+
assets?: MediaAsset[];
|
|
667
673
|
receivedAt: string;
|
|
668
674
|
finishedAt: string | null;
|
|
669
675
|
}
|
|
@@ -718,6 +724,8 @@ interface TaskRun<TOutput = JsonValue> {
|
|
|
718
724
|
updatedAt: string;
|
|
719
725
|
}
|
|
720
726
|
interface CreateTaskRunRequest<TInput = Record<string, unknown>> {
|
|
727
|
+
/** Versioned experience-center canonical input. Omitted means native shared input. */
|
|
728
|
+
inputFormat?: "sandbox-v1";
|
|
721
729
|
submittedAt?: string;
|
|
722
730
|
models: string[];
|
|
723
731
|
repetitions?: number;
|
|
@@ -906,6 +914,88 @@ declare function availabilityBuckets(items: readonly AvailabilityObservation[],
|
|
|
906
914
|
declare function rateProbeUsage(price: unknown, usage: JsonObject | undefined): string | undefined;
|
|
907
915
|
declare function probeCostExceeds(actual: string, limit: string): boolean;
|
|
908
916
|
|
|
917
|
+
declare const SANDBOX_OPERATIONS: readonly [{
|
|
918
|
+
readonly id: "text-to-speech";
|
|
919
|
+
readonly modality: "audio";
|
|
920
|
+
readonly label: "语音合成";
|
|
921
|
+
}, {
|
|
922
|
+
readonly id: "text-to-music";
|
|
923
|
+
readonly modality: "audio";
|
|
924
|
+
readonly label: "音乐生成";
|
|
925
|
+
}, {
|
|
926
|
+
readonly id: "multimodal-to-video";
|
|
927
|
+
readonly modality: "video";
|
|
928
|
+
readonly label: "全能参考生";
|
|
929
|
+
}, {
|
|
930
|
+
readonly id: "text-to-video";
|
|
931
|
+
readonly modality: "video";
|
|
932
|
+
readonly label: "参考生成视频";
|
|
933
|
+
}, {
|
|
934
|
+
readonly id: "image-to-video";
|
|
935
|
+
readonly modality: "video";
|
|
936
|
+
readonly label: "首尾帧生成视频";
|
|
937
|
+
}, {
|
|
938
|
+
readonly id: "text-to-image";
|
|
939
|
+
readonly modality: "image";
|
|
940
|
+
readonly label: "文生图";
|
|
941
|
+
}, {
|
|
942
|
+
readonly id: "image-to-image";
|
|
943
|
+
readonly modality: "image";
|
|
944
|
+
readonly label: "图生图";
|
|
945
|
+
}, {
|
|
946
|
+
readonly id: "text-to-text";
|
|
947
|
+
readonly modality: "language";
|
|
948
|
+
readonly label: "对话生成";
|
|
949
|
+
}];
|
|
950
|
+
type SandboxOperation = typeof SANDBOX_OPERATIONS[number]['id'];
|
|
951
|
+
declare const sandboxObject: (v: unknown) => JsonObject;
|
|
952
|
+
/** Catalog aliases are separate routes, not additional comparison models. */
|
|
953
|
+
declare function sandboxIdentity(slug: string): string;
|
|
954
|
+
declare function sandboxModelModes(model: Pick<TaskModelSummary, 'slug' | 'modality' | 'capabilities'>): string[];
|
|
955
|
+
declare function sandboxOperations(models: TaskModelSummary[]): ({
|
|
956
|
+
readonly id: "text-to-speech";
|
|
957
|
+
readonly modality: "audio";
|
|
958
|
+
readonly label: "语音合成";
|
|
959
|
+
} | {
|
|
960
|
+
readonly id: "text-to-music";
|
|
961
|
+
readonly modality: "audio";
|
|
962
|
+
readonly label: "音乐生成";
|
|
963
|
+
} | {
|
|
964
|
+
readonly id: "multimodal-to-video";
|
|
965
|
+
readonly modality: "video";
|
|
966
|
+
readonly label: "全能参考生";
|
|
967
|
+
} | {
|
|
968
|
+
readonly id: "text-to-video";
|
|
969
|
+
readonly modality: "video";
|
|
970
|
+
readonly label: "参考生成视频";
|
|
971
|
+
} | {
|
|
972
|
+
readonly id: "image-to-video";
|
|
973
|
+
readonly modality: "video";
|
|
974
|
+
readonly label: "首尾帧生成视频";
|
|
975
|
+
} | {
|
|
976
|
+
readonly id: "text-to-image";
|
|
977
|
+
readonly modality: "image";
|
|
978
|
+
readonly label: "文生图";
|
|
979
|
+
} | {
|
|
980
|
+
readonly id: "image-to-image";
|
|
981
|
+
readonly modality: "image";
|
|
982
|
+
readonly label: "图生图";
|
|
983
|
+
} | {
|
|
984
|
+
readonly id: "text-to-text";
|
|
985
|
+
readonly modality: "language";
|
|
986
|
+
readonly label: "对话生成";
|
|
987
|
+
})[];
|
|
988
|
+
declare function sandboxProperties(schema: ModelSchema): {
|
|
989
|
+
root: JsonObject;
|
|
990
|
+
parameters: JsonObject;
|
|
991
|
+
};
|
|
992
|
+
declare function sandboxSupports(schema: ModelSchema, feature: string): boolean;
|
|
993
|
+
declare function sandboxVoiceKey(model: string): string;
|
|
994
|
+
/** Canonical inputs are opt-in; ordinary API calls and detail Playgrounds retain native schemas. */
|
|
995
|
+
declare function adaptSandboxInput(schema: ModelSchema, mode: string, input: JsonObject): JsonObject;
|
|
996
|
+
/** Minimal operation form. Unsupported controls remain explicit provider defaults. */
|
|
997
|
+
declare function sandboxInputSchema(schemas: ModelSchema[], mode: string): ModelSchema;
|
|
998
|
+
|
|
909
999
|
declare class AssetsClient {
|
|
910
1000
|
private readonly transport;
|
|
911
1001
|
constructor(transport: HttpTransport);
|
|
@@ -1003,4 +1093,4 @@ interface VerifyWebhookOptions {
|
|
|
1003
1093
|
/** @deprecated Only verifies legacy signed webhooks, not callback_url notifications. */
|
|
1004
1094
|
declare function verifyWebhook(request: Request, secret: string, options?: VerifyWebhookOptions): Promise<boolean>;
|
|
1005
1095
|
|
|
1006
|
-
export { ADMIN_USER_ACTIVITY_KINDS, ADMIN_USER_ROLES, ADMIN_USER_STATUSES, type AdminOverview, type AdminUserActivityKind, type AdminUserActivityPage, type AdminUserActivityRow, type AdminUserApiKeyUpdate, type AdminUserApiKeyUpdateResult, type AdminUserDetail, type AdminUserDiscountRow, type AdminUserKeyRow, type AdminUserListCursor, type AdminUserListPage, type AdminUserListQuery, type AdminUserPricingAdjustmentRow, type AdminUserRole, type AdminUserStatus, type AdminUserSummaryRow, type AdminUserUpdate, type AdminUserUpdateResult, type AdminUserWalletOpenInput, type AdminUserWalletOpenResult, type AdminUserWalletSummary, type AdminWalletRechargeInput, type AdminWalletRechargeResult, type ApiErrorPayload, type AssetImportRequest, type AssetInput, type AssetReference, type AssetUploadOptions, AssetsClient, type AvailabilityBucket, type AvailabilityObservation, type AvailabilityStats, BILLING_CURRENCY, BillingMetric, CatalogClient, type CreateTaskOptions, type CreateTaskRequest, type CreateTaskRunRequest, CursorPage, HttpTransport, JsonObject, JsonValue, MEDIA_KINDS, MONEY_STRING_PATTERN, type MediaAsset, type MediaAssetStatus, type MediaKind, ModelSchema, ModelSearchParams, ModelsClient, type MoneyString, NexraApiError, NexraClient, NexraClientOptions, NexraSettlement, NexraTaskError, NexraWaitTimeoutError, type ObservationResult, type ProbeRunView, type ProbeTargetConfig, type ProbeTargetView, type RequestDetails, type RunResult, type RunTaskOptions, TASK_STATUSES, TOKEN_METRICS, type Task, type TaskCost, type TaskError, type TaskEvent, type TaskEventType, type TaskListParams, TaskModel, TaskModelSummary, type TaskPage, type TaskProgress, type TaskReceipt, type TaskResult, type TaskRun, type TaskRunListParams, type TaskStatus, type TaskTiming, type TaskUsage, type TaskWebhookConfig, TasksClient, type TerminalTaskStatus, USAGE_AMOUNT_KINDS, USAGE_ANOMALY_CATEGORIES, USAGE_FILTER_KINDS, USAGE_FILTER_SELECTION_LIMIT, USAGE_GROUP_BYS, USAGE_NORMALIZATION_STATUSES, USAGE_RATING_STATUSES, USAGE_SOURCES, type UploadDeliveryRegion, type UsageAmountKind, type UsageAnomaliesPage, type UsageAnomaliesQuery, type UsageAnomalyBreakdownRow, type UsageAnomalyCategory, type UsageAnomalyRow, type UsageAnomalySummaryPage, type UsageAnomalySummaryQuery, type UsageAnomalySummaryRow, type UsageDetailCharge, type UsageDetailRow, type UsageDetailUsage, type UsageDetailsPage, type UsageDetailsQuery, type UsageFilterKind, type UsageFilterOption, type UsageFilterOptionsPage, type UsageFilterOptionsQuery, type UsageFilters, type UsageGroupBy, type UsageNormalizationStatus, type UsageRatingStatus, type UsageSource, type UsageSummaryAmount, type UsageSummaryGroup, type UsageSummaryPage, type UsageSummaryQuery, type UsageSummaryRow, type UsageTimeWindow, type VerifyWebhookOptions, WALLET_MAX_BALANCE_UNITS, type WaitTaskOptions, type WatchTaskOptions, availabilityBuckets, availabilityStats, classifyObservation, createNexra, defaultProbeInterval, defaultProbeTimeout, encodeAdminUserCursor, encodeUsageFilterCursor, encodeUsageKeysetCursor, encodeUsageSummaryCursor, isMoneyString, isTerminalTaskStatus, modelInputDefaults, modelInputUi, modelUploadRegion, moneyFromUnits, moneyToUnits, multiplyMoney, normalizeModelParameterSchema, orderedSchemaProperties, parseAdminUserCursor, parseUsageFilterCursor, parseUsageKeysetCursor, parseUsageSummaryCursor, probeCostExceeds, rateProbeUsage, taskReceipt, taskResult, uploadedMediaInput, uploadedMediaUrl, validateAdminUserApiKeyUpdate, validateAdminUserListQuery, validateAdminUserUpdate, validateAdminWalletRechargeInput, validateUsageAnomaliesQuery, validateUsageAnomalySummaryQuery, validateUsageDetailsQuery, validateUsageFilterOptionsQuery, validateUsageFilters, validateUsageSummaryQuery, verifyWebhook };
|
|
1096
|
+
export { ADMIN_USER_ACTIVITY_KINDS, ADMIN_USER_ROLES, ADMIN_USER_STATUSES, type AdminOverview, type AdminUserActivityKind, type AdminUserActivityPage, type AdminUserActivityRow, type AdminUserApiKeyUpdate, type AdminUserApiKeyUpdateResult, type AdminUserDetail, type AdminUserDiscountRow, type AdminUserKeyRow, type AdminUserListCursor, type AdminUserListPage, type AdminUserListQuery, type AdminUserPricingAdjustmentRow, type AdminUserRole, type AdminUserStatus, type AdminUserSummaryRow, type AdminUserUpdate, type AdminUserUpdateResult, type AdminUserWalletOpenInput, type AdminUserWalletOpenResult, type AdminUserWalletSummary, type AdminWalletRechargeInput, type AdminWalletRechargeResult, type ApiErrorPayload, type AssetImportRequest, type AssetInput, type AssetReference, type AssetUploadOptions, AssetsClient, type AvailabilityBucket, type AvailabilityObservation, type AvailabilityStats, BILLING_CURRENCY, BillingMetric, CatalogClient, type CreateTaskOptions, type CreateTaskRequest, type CreateTaskRunRequest, CursorPage, HttpTransport, JsonObject, JsonValue, MEDIA_KINDS, MONEY_STRING_PATTERN, type MediaAsset, type MediaAssetStatus, type MediaKind, ModelSchema, ModelSearchParams, ModelsClient, type MoneyString, NexraApiError, NexraClient, NexraClientOptions, NexraSettlement, NexraTaskError, NexraWaitTimeoutError, type ObservationResult, type ProbeRunView, type ProbeTargetConfig, type ProbeTargetView, type RequestDetails, type RunResult, type RunTaskOptions, SANDBOX_OPERATIONS, type SandboxOperation, TASK_STATUSES, TOKEN_METRICS, type Task, type TaskCost, type TaskError, type TaskEvent, type TaskEventType, type TaskListParams, TaskModel, TaskModelSummary, type TaskPage, type TaskProgress, type TaskReceipt, type TaskResult, type TaskRun, type TaskRunListParams, type TaskStatus, type TaskTiming, type TaskUsage, type TaskWebhookConfig, TasksClient, type TerminalTaskStatus, USAGE_AMOUNT_KINDS, USAGE_ANOMALY_CATEGORIES, USAGE_FILTER_KINDS, USAGE_FILTER_SELECTION_LIMIT, USAGE_GROUP_BYS, USAGE_NORMALIZATION_STATUSES, USAGE_RATING_STATUSES, USAGE_SOURCES, type UploadDeliveryRegion, type UsageAmountKind, type UsageAnomaliesPage, type UsageAnomaliesQuery, type UsageAnomalyBreakdownRow, type UsageAnomalyCategory, type UsageAnomalyRow, type UsageAnomalySummaryPage, type UsageAnomalySummaryQuery, type UsageAnomalySummaryRow, type UsageDetailCharge, type UsageDetailRow, type UsageDetailUsage, type UsageDetailsPage, type UsageDetailsQuery, type UsageFilterKind, type UsageFilterOption, type UsageFilterOptionsPage, type UsageFilterOptionsQuery, type UsageFilters, type UsageGroupBy, type UsageNormalizationStatus, type UsageRatingStatus, type UsageSource, type UsageSummaryAmount, type UsageSummaryGroup, type UsageSummaryPage, type UsageSummaryQuery, type UsageSummaryRow, type UsageTimeWindow, type VerifyWebhookOptions, WALLET_MAX_BALANCE_UNITS, type WaitTaskOptions, type WatchTaskOptions, adaptSandboxInput, availabilityBuckets, availabilityStats, classifyObservation, createNexra, defaultProbeInterval, defaultProbeTimeout, encodeAdminUserCursor, encodeUsageFilterCursor, encodeUsageKeysetCursor, encodeUsageSummaryCursor, isMoneyString, isTerminalTaskStatus, modelInputDefaults, modelInputUi, modelUploadRegion, moneyFromUnits, moneyToUnits, multiplyMoney, normalizeModelParameterSchema, orderedSchemaProperties, parseAdminUserCursor, parseUsageFilterCursor, parseUsageKeysetCursor, parseUsageSummaryCursor, probeCostExceeds, rateProbeUsage, sandboxIdentity, sandboxInputSchema, sandboxModelModes, sandboxObject, sandboxOperations, sandboxProperties, sandboxSupports, sandboxVoiceKey, taskReceipt, taskResult, uploadedMediaInput, uploadedMediaUrl, validateAdminUserApiKeyUpdate, validateAdminUserListQuery, validateAdminUserUpdate, validateAdminWalletRechargeInput, validateUsageAnomaliesQuery, validateUsageAnomalySummaryQuery, validateUsageDetailsQuery, validateUsageFilterOptionsQuery, validateUsageFilters, validateUsageSummaryQuery, verifyWebhook };
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,16 @@ import {
|
|
|
4
4
|
NexraApiError,
|
|
5
5
|
NexraTaskError,
|
|
6
6
|
NexraWaitTimeoutError,
|
|
7
|
+
applyMediaGeometry,
|
|
8
|
+
decodeMediaGeometry,
|
|
9
|
+
encodeMediaGeometry,
|
|
7
10
|
getModelSpec,
|
|
8
11
|
jsonBody,
|
|
9
12
|
listModelSpecs,
|
|
13
|
+
projectMediaGeometry,
|
|
10
14
|
queryString,
|
|
11
15
|
sleep
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-BQQU5NJ7.js";
|
|
13
17
|
import {
|
|
14
18
|
ceilDecimal,
|
|
15
19
|
multiplyDecimal
|
|
@@ -926,6 +930,222 @@ function probeCostExceeds(actual, limit) {
|
|
|
926
930
|
return units(actual) > units(limit);
|
|
927
931
|
}
|
|
928
932
|
|
|
933
|
+
// ../contracts/src/sandbox.ts
|
|
934
|
+
var SANDBOX_OPERATIONS = [
|
|
935
|
+
{ id: "text-to-speech", modality: "audio", label: "\u8BED\u97F3\u5408\u6210" },
|
|
936
|
+
{ id: "text-to-music", modality: "audio", label: "\u97F3\u4E50\u751F\u6210" },
|
|
937
|
+
{ id: "multimodal-to-video", modality: "video", label: "\u5168\u80FD\u53C2\u8003\u751F" },
|
|
938
|
+
{ id: "text-to-video", modality: "video", label: "\u53C2\u8003\u751F\u6210\u89C6\u9891" },
|
|
939
|
+
{ id: "image-to-video", modality: "video", label: "\u9996\u5C3E\u5E27\u751F\u6210\u89C6\u9891" },
|
|
940
|
+
{ id: "text-to-image", modality: "image", label: "\u6587\u751F\u56FE" },
|
|
941
|
+
{ id: "image-to-image", modality: "image", label: "\u56FE\u751F\u56FE" },
|
|
942
|
+
{ id: "text-to-text", modality: "language", label: "\u5BF9\u8BDD\u751F\u6210" }
|
|
943
|
+
];
|
|
944
|
+
var sandboxObject = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
|
|
945
|
+
var obj = sandboxObject;
|
|
946
|
+
var array = (v) => Array.isArray(v) ? v : [];
|
|
947
|
+
function sandboxIdentity(slug) {
|
|
948
|
+
return slug === "google/veo-3-1-fast" ? "google/veo-3-1-fast-generate-001" : slug;
|
|
949
|
+
}
|
|
950
|
+
function sandboxModelModes(model) {
|
|
951
|
+
if (model.modality === "language") return ["text-to-text"];
|
|
952
|
+
if (model.modality === "audio") return model.capabilities.inputModes.includes("text-to-speech") ? ["text-to-speech"] : ["elevenlabs/music_v2", "minimax/music-2.6"].includes(model.slug) ? ["text-to-music"] : [];
|
|
953
|
+
if (model.slug === "heygen/heygen-avatar-video" || model.slug === "yadan/minimax-h3-local") return [];
|
|
954
|
+
const modes = model.capabilities.inputModes.filter((mode) => ["text-to-image", "image-to-image", "text-to-video", "image-to-video"].includes(mode)).filter((mode) => !(model.slug === "pixverse/baidu-vod-pc1" && mode === "image-to-video"));
|
|
955
|
+
if (model.capabilities.inputModes.includes("audio-to-video") && model.capabilities.inputModes.includes("video-to-video")) modes.push("multimodal-to-video");
|
|
956
|
+
return modes;
|
|
957
|
+
}
|
|
958
|
+
function sandboxOperations(models) {
|
|
959
|
+
return SANDBOX_OPERATIONS.filter((op) => new Set(models.filter((m) => m.modality === op.modality && sandboxModelModes(m).includes(op.id)).map((m) => sandboxIdentity(m.slug))).size >= 2);
|
|
960
|
+
}
|
|
961
|
+
function sandboxProperties(schema) {
|
|
962
|
+
const root = obj(schema.inputSchema.properties);
|
|
963
|
+
return { root, parameters: obj(obj(root.parameters).properties) };
|
|
964
|
+
}
|
|
965
|
+
function values(field) {
|
|
966
|
+
return Array.isArray(field.enum) ? field.enum : [];
|
|
967
|
+
}
|
|
968
|
+
function normalized(value) {
|
|
969
|
+
return String(value).toLowerCase();
|
|
970
|
+
}
|
|
971
|
+
function choose(field, requested, numeric = false) {
|
|
972
|
+
const options = values(field);
|
|
973
|
+
if (options.length) {
|
|
974
|
+
const exact = options.find((v) => normalized(v) === normalized(requested));
|
|
975
|
+
if (exact !== void 0) return exact;
|
|
976
|
+
if (numeric) {
|
|
977
|
+
const n = parseFloat(String(requested));
|
|
978
|
+
const ranked = options.filter((v) => Number.isFinite(parseFloat(String(v)))).sort((a, b) => Math.abs(parseFloat(String(a)) - n) - Math.abs(parseFloat(String(b)) - n));
|
|
979
|
+
if (ranked.length && Number.isFinite(n)) return ranked[0];
|
|
980
|
+
}
|
|
981
|
+
throw new Error(`\u4E0D\u652F\u6301 ${String(requested)}`);
|
|
982
|
+
}
|
|
983
|
+
const branches = array(field.anyOf).map(obj);
|
|
984
|
+
const range = branches.find((b) => b.type === "integer" || typeof b.minimum === "number") ?? field;
|
|
985
|
+
if (numeric) {
|
|
986
|
+
const n = Number(requested);
|
|
987
|
+
if (!Number.isFinite(n)) throw new Error("\u9700\u8981\u6709\u6548\u6570\u503C");
|
|
988
|
+
const bounded = Math.min(Number(range.maximum ?? n), Math.max(Number(range.minimum ?? n), n));
|
|
989
|
+
return range.type === "integer" || field.type === "integer" ? Math.round(bounded) : bounded;
|
|
990
|
+
}
|
|
991
|
+
return requested;
|
|
992
|
+
}
|
|
993
|
+
function urls(value) {
|
|
994
|
+
return array(value).map((v) => typeof v === "string" ? v : String(obj(v).url ?? "")).filter(Boolean);
|
|
995
|
+
}
|
|
996
|
+
function mediaRoles(schema) {
|
|
997
|
+
const { root } = sandboxProperties(schema);
|
|
998
|
+
if (root.content) return array(obj(obj(root.content).items).oneOf).flatMap((v) => array(obj(obj(obj(v).properties).role).enum)).filter((v) => typeof v === "string");
|
|
999
|
+
return array(obj(obj(root.images)["x-ui"]).roles).filter((v) => typeof v === "string");
|
|
1000
|
+
}
|
|
1001
|
+
function sandboxSupports(schema, feature) {
|
|
1002
|
+
const { root } = sandboxProperties(schema);
|
|
1003
|
+
if (feature === "last_frame") return schema.model !== "yadan/minimax-h3-local" && mediaRoles(schema).includes("last_frame");
|
|
1004
|
+
if (feature === "reference_images") return mediaRoles(schema).includes("reference_image") || schema.model === "pixverse/baidu-vod-pc1";
|
|
1005
|
+
if (feature === "videos") return mediaRoles(schema).includes("reference_video") || array(obj(obj(root.videos)["x-ui"]).roles).includes("reference_video");
|
|
1006
|
+
if (feature === "audios") return mediaRoles(schema).includes("reference_audio") || !!root.audios && array(obj(obj(root.audios)["x-ui"]).accept).includes("url");
|
|
1007
|
+
return false;
|
|
1008
|
+
}
|
|
1009
|
+
function sandboxVoiceKey(model) {
|
|
1010
|
+
return `voice:${model}`;
|
|
1011
|
+
}
|
|
1012
|
+
function adaptSandboxInput(schema, mode, input) {
|
|
1013
|
+
const { root, parameters } = sandboxProperties(schema);
|
|
1014
|
+
const nested = !!root.input && !!root.parameters;
|
|
1015
|
+
const fields = nested ? parameters : root;
|
|
1016
|
+
const body = {};
|
|
1017
|
+
const settings = nested ? {} : body;
|
|
1018
|
+
for (const key of array(schema.inputSchema.required)) if (typeof key === "string" && obj(root[key]).default !== void 0) body[key] = obj(root[key]).default;
|
|
1019
|
+
if (root.model) body.model = String(schema.defaults?.model ?? schema.model.split("/").at(-1));
|
|
1020
|
+
const prompt = typeof input.prompt === "string" ? input.prompt.trim() : "";
|
|
1021
|
+
if (!prompt) throw new Error("\u8BF7\u586B\u5199\u63D0\u793A\u8BCD\u6216\u6717\u8BFB\u6587\u672C");
|
|
1022
|
+
if (nested) body.input = { messages: [{ role: "user", content: [{ text: prompt }, ...urls(input.images).map((image) => ({ image }))] }] };
|
|
1023
|
+
else if (root.content) body.content = [{ type: "text", text: prompt }];
|
|
1024
|
+
else body[root.prompt ? "prompt" : root.texts ? "texts" : "text"] = prompt;
|
|
1025
|
+
if (schema.model === "yadan/minimax-h3-local" && !["first_frame", "reference_images", "videos", "audios"].some((key) => urls(input[key]).length)) throw new Error("H3 Local \u5F53\u524D\u63A5\u5165\u9700\u8981\u81F3\u5C11\u4E00\u4EFD\u53C2\u8003\u7D20\u6750");
|
|
1026
|
+
const imageInput = urls(input.images);
|
|
1027
|
+
const first = urls(input.first_frame);
|
|
1028
|
+
if (mode === "image-to-image" && !imageInput.length) throw new Error("\u56FE\u751F\u56FE\u9700\u8981\u8F93\u5165\u56FE\u7247");
|
|
1029
|
+
if (mode === "image-to-video" && first.length !== 1) throw new Error("\u9996\u5C3E\u5E27\u751F\u6210\u89C6\u9891\u9700\u8981\u4E00\u5F20\u9996\u5E27");
|
|
1030
|
+
if (mode === "text-to-image" && imageInput.length) throw new Error("\u8BF7\u5207\u6362\u5230\u56FE\u751F\u56FE");
|
|
1031
|
+
if (mode === "text-to-video" && first.length) throw new Error("\u8BF7\u5207\u6362\u5230\u9996\u5C3E\u5E27\u751F\u6210\u89C6\u9891");
|
|
1032
|
+
if (!nested && mode === "image-to-image") {
|
|
1033
|
+
if (root.imageUrl) {
|
|
1034
|
+
if (imageInput.length > 1) throw new Error("\u6B64\u6A21\u578B\u53EA\u652F\u6301\u4E00\u5F20\u8F93\u5165\u56FE");
|
|
1035
|
+
body.imageUrl = imageInput[0];
|
|
1036
|
+
} else if (obj(root.image).type === "object") body.images = imageInput.map((url) => ({ url }));
|
|
1037
|
+
else if (root.image) body.image = imageInput;
|
|
1038
|
+
else if (root.images) body.images = imageInput;
|
|
1039
|
+
else throw new Error("\u6A21\u578B\u6CA1\u6709\u53EF\u6620\u5C04\u7684\u56FE\u7247\u8F93\u5165");
|
|
1040
|
+
}
|
|
1041
|
+
const media = [];
|
|
1042
|
+
for (const [key, role, type] of [["first_frame", "first_frame", "image_url"], ["last_frame", "last_frame", "image_url"], ["reference_images", "reference_image", "image_url"], ["videos", "reference_video", "video_url"], ["audios", "reference_audio", "audio_url"]]) {
|
|
1043
|
+
const entries = urls(input[key]);
|
|
1044
|
+
if (key !== "first_frame" && entries.length && !sandboxSupports(schema, key)) throw new Error(`\u6A21\u578B\u4E0D\u652F\u6301 ${key}`);
|
|
1045
|
+
for (const url of entries) media.push({ key, role, type, url });
|
|
1046
|
+
}
|
|
1047
|
+
if (urls(input.last_frame).length && !first.length) throw new Error("\u5C3E\u5E27\u9700\u8981\u540C\u65F6\u63D0\u4F9B\u9996\u5E27");
|
|
1048
|
+
if (first.length && (urls(input.reference_images).length || urls(input.videos).length || urls(input.audios).length)) throw new Error("\u9996\u5C3E\u5E27\u4E0E\u53C2\u8003\u7D20\u6750\u8BF7\u5206\u5F00\u8FD0\u884C");
|
|
1049
|
+
if (root.content) body.content = [...array(body.content), ...media.map((m) => ({ type: m.type, [m.type]: { url: m.url }, role: m.role }))];
|
|
1050
|
+
else for (const [key, type] of [["images", "image_url"], ["videos", "video_url"], ["audios", "audio_url"]]) {
|
|
1051
|
+
const entries = media.filter((m) => m.type === type);
|
|
1052
|
+
if (entries.length) body[key] = entries.map((m, i) => schema.model === "yadan/minimax-h3-local" ? { url: m.url } : schema.model === "pixverse/baidu-vod-pc1" ? { url: m.url, role: "subject", referenceName: `ref${i + 1}` } : { url: m.url, role: m.role });
|
|
1053
|
+
}
|
|
1054
|
+
if (schema.model === "pixverse/baidu-vod-pc1" && urls(input.reference_images).length) {
|
|
1055
|
+
const names = urls(input.reference_images).map((_, i) => `@ref${i + 1}`);
|
|
1056
|
+
if (!names.every((name) => prompt.includes(name))) throw new Error(`\u8BF7\u5728\u63D0\u793A\u8BCD\u4E2D\u5F15\u7528 ${names.join("\u3001")}`);
|
|
1057
|
+
}
|
|
1058
|
+
if (schema.model.startsWith("xai/grok-imagine-video")) body.mode = first.length ? "image-to-video" : urls(input.reference_images).length ? "reference-to-video" : "text-to-video";
|
|
1059
|
+
const ratio = typeof input.aspect_ratio === "string" && input.aspect_ratio !== "default" ? input.aspect_ratio : void 0;
|
|
1060
|
+
const resolution = typeof input.resolution === "string" && input.resolution !== "default" ? input.resolution : void 0;
|
|
1061
|
+
const ratioKey = ["ratio", "aspect_ratio", "aspectRatio"].find((k) => fields[k]);
|
|
1062
|
+
if (ratio && ratioKey && !(["kuaishou/baidu-vod-kling-v3", "pixverse/baidu-vod-p60", "bytedance/doubao-seedance-2-5-260628"].includes(schema.model) && first.length)) settings[ratioKey] = choose(obj(fields[ratioKey]), ratio);
|
|
1063
|
+
if (first.length && schema.model === "bytedance/doubao-seedance-2-5-260628") settings.ratio = "adaptive";
|
|
1064
|
+
if (resolution && fields.resolution) settings.resolution = choose(obj(fields.resolution), resolution);
|
|
1065
|
+
if (fields.size && (ratio || resolution)) {
|
|
1066
|
+
const [rw, rh] = (ratio ?? "1:1").split(":").map(Number);
|
|
1067
|
+
if (!rw || !rh) throw new Error("\u65E0\u6548\u753B\u9762\u6BD4\u4F8B");
|
|
1068
|
+
const edge = resolution ? parseFloat(resolution) * 1024 : 1024;
|
|
1069
|
+
let w = Math.round(edge * Math.sqrt(rw / rh) / 16) * 16;
|
|
1070
|
+
let h = Math.round(edge * Math.sqrt(rh / rw) / 16) * 16;
|
|
1071
|
+
const max = schema.model.startsWith("openai/") ? 3840 : schema.model.includes("qwen-image-edit") || nested && mode === "image-to-image" ? 2048 : 4096;
|
|
1072
|
+
if (Math.max(w, h) > max) {
|
|
1073
|
+
const scale = max / Math.max(w, h);
|
|
1074
|
+
w = Math.floor(w * scale / 16) * 16;
|
|
1075
|
+
h = Math.floor(h * scale / 16) * 16;
|
|
1076
|
+
}
|
|
1077
|
+
settings.size = `${w}${nested ? "*" : "x"}${h}`;
|
|
1078
|
+
}
|
|
1079
|
+
if (input.duration !== void 0 && fields.duration) settings.duration = choose(obj(fields.duration), input.duration, true);
|
|
1080
|
+
if (input.generate_audio !== void 0) {
|
|
1081
|
+
const key = fields.generate_audio ? "generate_audio" : fields.with_audio ? "with_audio" : void 0;
|
|
1082
|
+
if (!key) throw new Error("\u6A21\u578B\u4E0D\u652F\u6301\u63A7\u5236\u751F\u6210\u97F3\u9891");
|
|
1083
|
+
settings[key] = input.generate_audio;
|
|
1084
|
+
}
|
|
1085
|
+
if (mode === "text-to-speech") {
|
|
1086
|
+
const voice = input[sandboxVoiceKey(schema.model)] ?? obj(root.voice_id).default;
|
|
1087
|
+
if (!voice) throw new Error("\u8BF7\u9009\u62E9\u6B64\u6A21\u578B\u7684\u97F3\u8272");
|
|
1088
|
+
body.voice_id = voice;
|
|
1089
|
+
}
|
|
1090
|
+
if (mode === "text-to-music") {
|
|
1091
|
+
body.instrumental = input.instrumental ?? true;
|
|
1092
|
+
if (root.lyrics_optimizer && body.instrumental === false) body.lyrics_optimizer = true;
|
|
1093
|
+
}
|
|
1094
|
+
if (nested) body.parameters = settings;
|
|
1095
|
+
return body;
|
|
1096
|
+
}
|
|
1097
|
+
function sandboxInputSchema(schemas, mode) {
|
|
1098
|
+
const field = (title, type = "string", extra = {}) => ({ type, title, ...extra });
|
|
1099
|
+
const properties = { prompt: field(mode === "text-to-speech" ? "\u6717\u8BFB\u6587\u672C" : "\u63D0\u793A\u8BCD", "string", { minLength: 1, "x-ui": { control: "textarea", order: 0 } }) };
|
|
1100
|
+
const required = ["prompt"];
|
|
1101
|
+
const mediaField = (title, maxItems) => field(title, "array", { items: { type: "object", properties: { url: { type: "string", minLength: 1 }, role: { type: "string" } }, required: ["url"] }, maxItems, "x-ui": { control: "media", accept: ["url"] } });
|
|
1102
|
+
if (mode === "image-to-image") {
|
|
1103
|
+
properties.images = mediaField("\u8F93\u5165\u56FE\u7247", 16);
|
|
1104
|
+
required.push("images");
|
|
1105
|
+
obj(properties.images).minItems = 1;
|
|
1106
|
+
}
|
|
1107
|
+
if (mode === "image-to-video") {
|
|
1108
|
+
properties.first_frame = mediaField("\u9996\u5E27", 1);
|
|
1109
|
+
required.push("first_frame");
|
|
1110
|
+
obj(properties.first_frame).minItems = 1;
|
|
1111
|
+
}
|
|
1112
|
+
if (mode.endsWith("video")) {
|
|
1113
|
+
for (const [key, title, max] of [["last_frame", "\u5C3E\u5E27", 1], ["reference_images", "\u53C2\u8003\u56FE\u7247", 9], ["videos", "\u53C2\u8003\u89C6\u9891", 3], ["audios", "\u53C2\u8003\u97F3\u9891", 3]]) {
|
|
1114
|
+
if (key === "last_frame" && mode !== "image-to-video") continue;
|
|
1115
|
+
if (key !== "last_frame" && mode === "image-to-video") continue;
|
|
1116
|
+
if (new Set(schemas.map((s) => sandboxIdentity(s.model))).size >= 2 && schemas.every((s) => sandboxSupports(s, key))) properties[key] = mediaField(title, max);
|
|
1117
|
+
}
|
|
1118
|
+
properties.duration = field("\u76EE\u6807\u65F6\u957F\uFF08\u79D2\uFF09", "integer", { minimum: 1, maximum: 30 });
|
|
1119
|
+
}
|
|
1120
|
+
if (mode.endsWith("image") || mode.endsWith("video")) {
|
|
1121
|
+
const fields = schemas.map((s) => {
|
|
1122
|
+
const { root, parameters } = sandboxProperties(s);
|
|
1123
|
+
return root.parameters ? parameters : root;
|
|
1124
|
+
});
|
|
1125
|
+
const ratios = ["1:1", "16:9", "9:16", "4:3", "3:4", "3:2", "2:3", "21:9"].filter((r) => fields.every((p) => {
|
|
1126
|
+
const k = ["ratio", "aspect_ratio", "aspectRatio"].find((k2) => p[k2]);
|
|
1127
|
+
return !k || !values(obj(p[k])).length || values(obj(p[k])).includes(r);
|
|
1128
|
+
}));
|
|
1129
|
+
properties.aspect_ratio = field("\u753B\u9762\u6BD4\u4F8B", "string", { enum: ["default", ...ratios], default: "default", "x-ui": { optionLabels: { default: "\u5404\u6A21\u578B\u9ED8\u8BA4" } } });
|
|
1130
|
+
const resolutions = (mode.endsWith("image") ? ["1K", "2K", "4K"] : ["480p", "540p", "720p", "768p", "1080p", "2K", "4K"]).filter((r) => fields.every((p) => !p.resolution || !values(obj(p.resolution)).length || values(obj(p.resolution)).some((v) => normalized(v) === r.toLowerCase())));
|
|
1131
|
+
properties.resolution = field("\u6E05\u6670\u5EA6", "string", { enum: ["default", ...resolutions], default: "default", "x-ui": { optionLabels: { default: "\u5404\u6A21\u578B\u9ED8\u8BA4" } } });
|
|
1132
|
+
if (schemas.length >= 2 && fields.every((p) => p.generate_audio || p.with_audio)) properties.generate_audio = field("\u751F\u6210\u58F0\u97F3", "boolean");
|
|
1133
|
+
}
|
|
1134
|
+
if (mode === "text-to-speech") for (const s of schemas) {
|
|
1135
|
+
const voice = obj(sandboxProperties(s).root.voice_id);
|
|
1136
|
+
properties[sandboxVoiceKey(s.model)] = { ...voice, title: `${s.model} \xB7 \u97F3\u8272`, "x-ui": { ...obj(voice["x-ui"]), resourceModel: s.model } };
|
|
1137
|
+
required.push(sandboxVoiceKey(s.model));
|
|
1138
|
+
}
|
|
1139
|
+
if (mode === "text-to-text") {
|
|
1140
|
+
properties.system = field("\u7CFB\u7EDF\u63D0\u793A\u8BCD", "string", { "x-ui": { control: "textarea" } });
|
|
1141
|
+
properties.messages = field("\u5BF9\u8BDD\u5386\u53F2\uFF08\u53EF\u9009\uFF09", "array", { items: { type: "object", properties: { role: { type: "string", enum: ["user", "assistant"] }, content: { type: "string" } }, required: ["role", "content"], additionalProperties: false }, "x-ui": { control: "json" } });
|
|
1142
|
+
}
|
|
1143
|
+
if (mode === "text-to-music") properties.instrumental = field("\u7EAF\u97F3\u4E50", "boolean", { default: true });
|
|
1144
|
+
const defaults = {};
|
|
1145
|
+
for (const [key, value] of Object.entries(properties)) if (obj(value).default !== void 0) defaults[key] = obj(value).default;
|
|
1146
|
+
return { model: schemas.map((s) => s.model).join(","), version: 1, dialect: "https://json-schema.org/draft/2020-12/schema", inputSchema: { type: "object", properties, required, additionalProperties: false }, outputSchema: {}, uiSchema: {}, defaults, examples: [] };
|
|
1147
|
+
}
|
|
1148
|
+
|
|
929
1149
|
// src/assets.ts
|
|
930
1150
|
var AssetsClient = class {
|
|
931
1151
|
constructor(transport) {
|
|
@@ -1020,11 +1240,11 @@ var ModelsClient = class {
|
|
|
1020
1240
|
|
|
1021
1241
|
// src/input.ts
|
|
1022
1242
|
async function normalizeTaskInput(input, assets, signal) {
|
|
1023
|
-
const
|
|
1024
|
-
if (!isPlainObject(
|
|
1243
|
+
const normalized2 = await normalizeValue(input, assets, signal, /* @__PURE__ */ new WeakSet());
|
|
1244
|
+
if (!isPlainObject(normalized2)) {
|
|
1025
1245
|
throw new TypeError("Task input must be a JSON object");
|
|
1026
1246
|
}
|
|
1027
|
-
return
|
|
1247
|
+
return normalized2;
|
|
1028
1248
|
}
|
|
1029
1249
|
async function normalizeValue(value, assets, signal, ancestors) {
|
|
1030
1250
|
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
@@ -1045,21 +1265,21 @@ async function normalizeValue(value, assets, signal, ancestors) {
|
|
|
1045
1265
|
if (isAssetReference(value)) return { assetId: value.assetId };
|
|
1046
1266
|
if (Array.isArray(value)) {
|
|
1047
1267
|
assertNotCircular(value, ancestors);
|
|
1048
|
-
const
|
|
1268
|
+
const normalized2 = await Promise.all(
|
|
1049
1269
|
value.map((item) => normalizeValue(item, assets, signal, ancestors))
|
|
1050
1270
|
);
|
|
1051
1271
|
ancestors.delete(value);
|
|
1052
|
-
return
|
|
1272
|
+
return normalized2;
|
|
1053
1273
|
}
|
|
1054
1274
|
if (isPlainObject(value)) {
|
|
1055
1275
|
assertNotCircular(value, ancestors);
|
|
1056
|
-
const
|
|
1276
|
+
const normalized2 = {};
|
|
1057
1277
|
for (const [key, item] of Object.entries(value)) {
|
|
1058
1278
|
if (item === void 0) continue;
|
|
1059
|
-
|
|
1279
|
+
normalized2[key] = await normalizeValue(item, assets, signal, ancestors);
|
|
1060
1280
|
}
|
|
1061
1281
|
ancestors.delete(value);
|
|
1062
|
-
return
|
|
1282
|
+
return normalized2;
|
|
1063
1283
|
}
|
|
1064
1284
|
throw new TypeError(`Task input contains a non-serializable ${typeof value} value`);
|
|
1065
1285
|
}
|
|
@@ -1137,7 +1357,9 @@ var TasksClient = class {
|
|
|
1137
1357
|
transport;
|
|
1138
1358
|
assets;
|
|
1139
1359
|
async create(model, options) {
|
|
1140
|
-
const
|
|
1360
|
+
const schema = getModelSpec(model)?.operations[0]?.inputSchema;
|
|
1361
|
+
const mapped = schema && options.input && typeof options.input === "object" && !Array.isArray(options.input) ? applyMediaGeometry(schema, options.input) : options.input;
|
|
1362
|
+
const input = await normalizeTaskInput(mapped, this.assets, options.signal);
|
|
1141
1363
|
const body = {
|
|
1142
1364
|
model,
|
|
1143
1365
|
input,
|
|
@@ -1359,6 +1581,7 @@ export {
|
|
|
1359
1581
|
NexraClient,
|
|
1360
1582
|
NexraTaskError,
|
|
1361
1583
|
NexraWaitTimeoutError,
|
|
1584
|
+
SANDBOX_OPERATIONS,
|
|
1362
1585
|
TASK_STATUSES,
|
|
1363
1586
|
TOKEN_METRICS,
|
|
1364
1587
|
TasksClient,
|
|
@@ -1371,16 +1594,20 @@ export {
|
|
|
1371
1594
|
USAGE_RATING_STATUSES,
|
|
1372
1595
|
USAGE_SOURCES,
|
|
1373
1596
|
WALLET_MAX_BALANCE_UNITS,
|
|
1597
|
+
adaptSandboxInput,
|
|
1374
1598
|
allocateDiscountedPriceLines,
|
|
1599
|
+
applyMediaGeometry,
|
|
1375
1600
|
assessUsageEvidence,
|
|
1376
1601
|
availabilityBuckets,
|
|
1377
1602
|
availabilityStats,
|
|
1378
1603
|
ceilDecimal,
|
|
1379
1604
|
classifyObservation,
|
|
1380
1605
|
createNexra,
|
|
1606
|
+
decodeMediaGeometry,
|
|
1381
1607
|
defaultProbeInterval,
|
|
1382
1608
|
defaultProbeTimeout,
|
|
1383
1609
|
encodeAdminUserCursor,
|
|
1610
|
+
encodeMediaGeometry,
|
|
1384
1611
|
encodeUsageFilterCursor,
|
|
1385
1612
|
encodeUsageKeysetCursor,
|
|
1386
1613
|
encodeUsageSummaryCursor,
|
|
@@ -1404,8 +1631,17 @@ export {
|
|
|
1404
1631
|
parseUsageKeysetCursor,
|
|
1405
1632
|
parseUsageSummaryCursor,
|
|
1406
1633
|
probeCostExceeds,
|
|
1634
|
+
projectMediaGeometry,
|
|
1407
1635
|
queryString,
|
|
1408
1636
|
rateProbeUsage,
|
|
1637
|
+
sandboxIdentity,
|
|
1638
|
+
sandboxInputSchema,
|
|
1639
|
+
sandboxModelModes,
|
|
1640
|
+
sandboxObject,
|
|
1641
|
+
sandboxOperations,
|
|
1642
|
+
sandboxProperties,
|
|
1643
|
+
sandboxSupports,
|
|
1644
|
+
sandboxVoiceKey,
|
|
1409
1645
|
sleep,
|
|
1410
1646
|
taskReceipt,
|
|
1411
1647
|
taskResult,
|