@vargai/gateway 0.1.5 → 0.1.7

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/client.d.ts CHANGED
@@ -13,6 +13,39 @@ export interface WaitForJobOptions {
13
13
  pollIntervalMs?: number;
14
14
  maxAttempts?: number;
15
15
  }
16
+ export interface VoiceInfo {
17
+ voice_id: string;
18
+ name: string;
19
+ category: string | null;
20
+ labels: {
21
+ gender: string | null;
22
+ age: string | null;
23
+ accent: string | null;
24
+ description: string | null;
25
+ use_case: string | null;
26
+ };
27
+ preview_url: string | null;
28
+ is_curated: boolean;
29
+ usage_count: number;
30
+ }
31
+ export interface VoiceListResponse {
32
+ voices: VoiceInfo[];
33
+ total: number;
34
+ page: number;
35
+ page_size: number;
36
+ }
37
+ export interface VoiceSearchParams {
38
+ search?: string;
39
+ category?: string;
40
+ gender?: string;
41
+ age?: string;
42
+ accent?: string;
43
+ is_curated?: boolean;
44
+ page?: number;
45
+ page_size?: number;
46
+ sort_by?: "usage_count" | "name" | "created_at";
47
+ sort_order?: "asc" | "desc";
48
+ }
16
49
  export declare class VargGatewayError extends Error {
17
50
  statusCode?: number | undefined;
18
51
  field?: string | undefined;
@@ -31,8 +64,15 @@ export declare class VargClient {
31
64
  createSpeech(params: SpeechRequest): Promise<JobResponse>;
32
65
  createMusic(params: MusicRequest): Promise<JobResponse>;
33
66
  uploadFile(file: Blob | Buffer, mediaType: string): Promise<FileUploadResponse>;
67
+ listVoices(params?: VoiceSearchParams): Promise<VoiceListResponse>;
68
+ syncVoices(): Promise<{
69
+ status: string;
70
+ message: string;
71
+ }>;
34
72
  getJob(id: string): Promise<JobResponse>;
35
73
  cancelJob(id: string): Promise<void>;
36
74
  waitForJob(id: string, options?: WaitForJobOptions): Promise<JobResponse>;
75
+ private waitForJobSSE;
76
+ private waitForJobPoll;
37
77
  }
38
78
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d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BAAgB;IAMpC,OAAO,CAAC,UAAU;YAsBJ,cAAc;IAuBtB,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAUvD,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAUvD,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC;IAUzD,WAAW,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;IAUvD,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA2B/E,UAAU,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAmClE,UAAU,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAoB1D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAQxC,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpC,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;YASjE,aAAa;YA4Eb,cAAc;CAgB7B"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { VargClient, VargGatewayError } from "./client.ts";
2
- export type { VargClientConfig, WaitForJobOptions } from "./client.ts";
3
- export { createVarg } from "./provider.ts";
2
+ export type { VargClientConfig, WaitForJobOptions, VoiceInfo, VoiceListResponse, VoiceSearchParams, } from "./client.ts";
3
+ export { createVarg, varg } from "./provider.ts";
4
4
  export type { VargProvider } from "./provider.ts";
5
5
  export { ErrorResponseSchema, FileInputSchema, FileUploadResponseSchema, ImageRequestSchema, JobResponseSchema, JobStatusSchema, MusicRequestSchema, SpeechRequestSchema, VideoRequestSchema, } from "./schemas.ts";
6
6
  export type { ErrorResponse, FileInput, FileUploadResponse, ImageRequest, JobResponse, JobStatus, MusicRequest, SpeechRequest, VideoRequest, } from "./schemas.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,EACT,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,aAAa,EACb,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -267,7 +267,7 @@ __export(exports_core2, {
267
267
  safeDecode: () => safeDecode,
268
268
  registry: () => registry,
269
269
  regexes: () => exports_regexes,
270
- process: () => process,
270
+ process: () => process2,
271
271
  prettifyError: () => prettifyError,
272
272
  parseAsync: () => parseAsync,
273
273
  parse: () => parse,
@@ -10731,7 +10731,7 @@ function initializeContext(params) {
10731
10731
  external: params?.external ?? undefined
10732
10732
  };
10733
10733
  }
10734
- function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
10734
+ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
10735
10735
  var _a2;
10736
10736
  const def = schema._zod.def;
10737
10737
  const seen = ctx.seen.get(schema);
@@ -10768,7 +10768,7 @@ function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
10768
10768
  if (parent) {
10769
10769
  if (!result.ref)
10770
10770
  result.ref = parent;
10771
- process(parent, ctx, params);
10771
+ process2(parent, ctx, params);
10772
10772
  ctx.seen.get(parent).isParent = true;
10773
10773
  }
10774
10774
  }
@@ -11044,14 +11044,14 @@ function isTransforming(_schema, _ctx) {
11044
11044
  }
11045
11045
  var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
11046
11046
  const ctx = initializeContext({ ...params, processors });
11047
- process(schema, ctx);
11047
+ process2(schema, ctx);
11048
11048
  extractDefs(ctx, schema);
11049
11049
  return finalize(ctx, schema);
11050
11050
  };
11051
11051
  var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
11052
11052
  const { libraryOptions, target } = params ?? {};
11053
11053
  const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
11054
- process(schema, ctx);
11054
+ process2(schema, ctx);
11055
11055
  extractDefs(ctx, schema);
11056
11056
  return finalize(ctx, schema);
11057
11057
  };
@@ -11302,7 +11302,7 @@ var arrayProcessor = (schema, ctx, _json, params) => {
11302
11302
  if (typeof maximum === "number")
11303
11303
  json.maxItems = maximum;
11304
11304
  json.type = "array";
11305
- json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
11305
+ json.items = process2(def.element, ctx, { ...params, path: [...params.path, "items"] });
11306
11306
  };
11307
11307
  var objectProcessor = (schema, ctx, _json, params) => {
11308
11308
  const json = _json;
@@ -11311,7 +11311,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11311
11311
  json.properties = {};
11312
11312
  const shape = def.shape;
11313
11313
  for (const key in shape) {
11314
- json.properties[key] = process(shape[key], ctx, {
11314
+ json.properties[key] = process2(shape[key], ctx, {
11315
11315
  ...params,
11316
11316
  path: [...params.path, "properties", key]
11317
11317
  });
@@ -11334,7 +11334,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11334
11334
  if (ctx.io === "output")
11335
11335
  json.additionalProperties = false;
11336
11336
  } else if (def.catchall) {
11337
- json.additionalProperties = process(def.catchall, ctx, {
11337
+ json.additionalProperties = process2(def.catchall, ctx, {
11338
11338
  ...params,
11339
11339
  path: [...params.path, "additionalProperties"]
11340
11340
  });
@@ -11343,7 +11343,7 @@ var objectProcessor = (schema, ctx, _json, params) => {
11343
11343
  var unionProcessor = (schema, ctx, json, params) => {
11344
11344
  const def = schema._zod.def;
11345
11345
  const isExclusive = def.inclusive === false;
11346
- const options = def.options.map((x, i) => process(x, ctx, {
11346
+ const options = def.options.map((x, i) => process2(x, ctx, {
11347
11347
  ...params,
11348
11348
  path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
11349
11349
  }));
@@ -11355,11 +11355,11 @@ var unionProcessor = (schema, ctx, json, params) => {
11355
11355
  };
11356
11356
  var intersectionProcessor = (schema, ctx, json, params) => {
11357
11357
  const def = schema._zod.def;
11358
- const a = process(def.left, ctx, {
11358
+ const a = process2(def.left, ctx, {
11359
11359
  ...params,
11360
11360
  path: [...params.path, "allOf", 0]
11361
11361
  });
11362
- const b = process(def.right, ctx, {
11362
+ const b = process2(def.right, ctx, {
11363
11363
  ...params,
11364
11364
  path: [...params.path, "allOf", 1]
11365
11365
  });
@@ -11376,11 +11376,11 @@ var tupleProcessor = (schema, ctx, _json, params) => {
11376
11376
  json.type = "array";
11377
11377
  const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
11378
11378
  const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
11379
- const prefixItems = def.items.map((x, i) => process(x, ctx, {
11379
+ const prefixItems = def.items.map((x, i) => process2(x, ctx, {
11380
11380
  ...params,
11381
11381
  path: [...params.path, prefixPath, i]
11382
11382
  }));
11383
- const rest = def.rest ? process(def.rest, ctx, {
11383
+ const rest = def.rest ? process2(def.rest, ctx, {
11384
11384
  ...params,
11385
11385
  path: [...params.path, restPath, ...ctx.target === "openapi-3.0" ? [def.items.length] : []]
11386
11386
  }) : null;
@@ -11420,7 +11420,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11420
11420
  const keyBag = keyType._zod.bag;
11421
11421
  const patterns = keyBag?.patterns;
11422
11422
  if (def.mode === "loose" && patterns && patterns.size > 0) {
11423
- const valueSchema = process(def.valueType, ctx, {
11423
+ const valueSchema = process2(def.valueType, ctx, {
11424
11424
  ...params,
11425
11425
  path: [...params.path, "patternProperties", "*"]
11426
11426
  });
@@ -11430,12 +11430,12 @@ var recordProcessor = (schema, ctx, _json, params) => {
11430
11430
  }
11431
11431
  } else {
11432
11432
  if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
11433
- json.propertyNames = process(def.keyType, ctx, {
11433
+ json.propertyNames = process2(def.keyType, ctx, {
11434
11434
  ...params,
11435
11435
  path: [...params.path, "propertyNames"]
11436
11436
  });
11437
11437
  }
11438
- json.additionalProperties = process(def.valueType, ctx, {
11438
+ json.additionalProperties = process2(def.valueType, ctx, {
11439
11439
  ...params,
11440
11440
  path: [...params.path, "additionalProperties"]
11441
11441
  });
@@ -11450,7 +11450,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
11450
11450
  };
11451
11451
  var nullableProcessor = (schema, ctx, json, params) => {
11452
11452
  const def = schema._zod.def;
11453
- const inner = process(def.innerType, ctx, params);
11453
+ const inner = process2(def.innerType, ctx, params);
11454
11454
  const seen = ctx.seen.get(schema);
11455
11455
  if (ctx.target === "openapi-3.0") {
11456
11456
  seen.ref = def.innerType;
@@ -11461,20 +11461,20 @@ var nullableProcessor = (schema, ctx, json, params) => {
11461
11461
  };
11462
11462
  var nonoptionalProcessor = (schema, ctx, _json, params) => {
11463
11463
  const def = schema._zod.def;
11464
- process(def.innerType, ctx, params);
11464
+ process2(def.innerType, ctx, params);
11465
11465
  const seen = ctx.seen.get(schema);
11466
11466
  seen.ref = def.innerType;
11467
11467
  };
11468
11468
  var defaultProcessor = (schema, ctx, json, params) => {
11469
11469
  const def = schema._zod.def;
11470
- process(def.innerType, ctx, params);
11470
+ process2(def.innerType, ctx, params);
11471
11471
  const seen = ctx.seen.get(schema);
11472
11472
  seen.ref = def.innerType;
11473
11473
  json.default = JSON.parse(JSON.stringify(def.defaultValue));
11474
11474
  };
11475
11475
  var prefaultProcessor = (schema, ctx, json, params) => {
11476
11476
  const def = schema._zod.def;
11477
- process(def.innerType, ctx, params);
11477
+ process2(def.innerType, ctx, params);
11478
11478
  const seen = ctx.seen.get(schema);
11479
11479
  seen.ref = def.innerType;
11480
11480
  if (ctx.io === "input")
@@ -11482,7 +11482,7 @@ var prefaultProcessor = (schema, ctx, json, params) => {
11482
11482
  };
11483
11483
  var catchProcessor = (schema, ctx, json, params) => {
11484
11484
  const def = schema._zod.def;
11485
- process(def.innerType, ctx, params);
11485
+ process2(def.innerType, ctx, params);
11486
11486
  const seen = ctx.seen.get(schema);
11487
11487
  seen.ref = def.innerType;
11488
11488
  let catchValue;
@@ -11496,32 +11496,32 @@ var catchProcessor = (schema, ctx, json, params) => {
11496
11496
  var pipeProcessor = (schema, ctx, _json, params) => {
11497
11497
  const def = schema._zod.def;
11498
11498
  const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
11499
- process(innerType, ctx, params);
11499
+ process2(innerType, ctx, params);
11500
11500
  const seen = ctx.seen.get(schema);
11501
11501
  seen.ref = innerType;
11502
11502
  };
11503
11503
  var readonlyProcessor = (schema, ctx, json, params) => {
11504
11504
  const def = schema._zod.def;
11505
- process(def.innerType, ctx, params);
11505
+ process2(def.innerType, ctx, params);
11506
11506
  const seen = ctx.seen.get(schema);
11507
11507
  seen.ref = def.innerType;
11508
11508
  json.readOnly = true;
11509
11509
  };
11510
11510
  var promiseProcessor = (schema, ctx, _json, params) => {
11511
11511
  const def = schema._zod.def;
11512
- process(def.innerType, ctx, params);
11512
+ process2(def.innerType, ctx, params);
11513
11513
  const seen = ctx.seen.get(schema);
11514
11514
  seen.ref = def.innerType;
11515
11515
  };
11516
11516
  var optionalProcessor = (schema, ctx, _json, params) => {
11517
11517
  const def = schema._zod.def;
11518
- process(def.innerType, ctx, params);
11518
+ process2(def.innerType, ctx, params);
11519
11519
  const seen = ctx.seen.get(schema);
11520
11520
  seen.ref = def.innerType;
11521
11521
  };
11522
11522
  var lazyProcessor = (schema, ctx, _json, params) => {
11523
11523
  const innerType = schema._zod.innerType;
11524
- process(innerType, ctx, params);
11524
+ process2(innerType, ctx, params);
11525
11525
  const seen = ctx.seen.get(schema);
11526
11526
  seen.ref = innerType;
11527
11527
  };
@@ -11573,7 +11573,7 @@ function toJSONSchema(input, params) {
11573
11573
  const defs = {};
11574
11574
  for (const entry of registry2._idmap.entries()) {
11575
11575
  const [_, schema] = entry;
11576
- process(schema, ctx2);
11576
+ process2(schema, ctx2);
11577
11577
  }
11578
11578
  const schemas = {};
11579
11579
  const external = {
@@ -11596,7 +11596,7 @@ function toJSONSchema(input, params) {
11596
11596
  return { schemas };
11597
11597
  }
11598
11598
  const ctx = initializeContext({ ...params, processors: allProcessors });
11599
- process(input, ctx);
11599
+ process2(input, ctx);
11600
11600
  extractDefs(ctx, input);
11601
11601
  return finalize(ctx, input);
11602
11602
  }
@@ -11642,7 +11642,7 @@ class JSONSchemaGenerator {
11642
11642
  });
11643
11643
  }
11644
11644
  process(schema, _params = { path: [], schemaPath: [] }) {
11645
- return process(schema, this.ctx, _params);
11645
+ return process2(schema, this.ctx, _params);
11646
11646
  }
11647
11647
  emit(schema, _params) {
11648
11648
  if (_params) {
@@ -13604,7 +13604,8 @@ var JobResponse = exports_external.object({
13604
13604
  completed_at: exports_external.string().optional(),
13605
13605
  output: exports_external.object({
13606
13606
  url: exports_external.string(),
13607
- media_type: exports_external.string()
13607
+ media_type: exports_external.string(),
13608
+ metadata: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
13608
13609
  }).optional(),
13609
13610
  cache: exports_external.object({
13610
13611
  hit: exports_external.boolean(),
@@ -13738,6 +13739,53 @@ class VargClient {
13738
13739
  });
13739
13740
  return this.handleResponse(response, FileUploadResponse);
13740
13741
  }
13742
+ async listVoices(params) {
13743
+ const searchParams = new URLSearchParams;
13744
+ if (params?.search)
13745
+ searchParams.set("search", params.search);
13746
+ if (params?.category)
13747
+ searchParams.set("category", params.category);
13748
+ if (params?.gender)
13749
+ searchParams.set("gender", params.gender);
13750
+ if (params?.age)
13751
+ searchParams.set("age", params.age);
13752
+ if (params?.accent)
13753
+ searchParams.set("accent", params.accent);
13754
+ if (params?.is_curated !== undefined)
13755
+ searchParams.set("is_curated", String(params.is_curated));
13756
+ if (params?.page)
13757
+ searchParams.set("page", String(params.page));
13758
+ if (params?.page_size)
13759
+ searchParams.set("page_size", String(params.page_size));
13760
+ if (params?.sort_by)
13761
+ searchParams.set("sort_by", params.sort_by);
13762
+ if (params?.sort_order)
13763
+ searchParams.set("sort_order", params.sort_order);
13764
+ const qs = searchParams.toString();
13765
+ const url2 = `${this.baseUrl}/voices${qs ? `?${qs}` : ""}`;
13766
+ const response = await fetch(url2, {
13767
+ method: "GET",
13768
+ headers: this.getHeaders()
13769
+ });
13770
+ if (!response.ok) {
13771
+ const raw = await response.json().catch(() => null);
13772
+ const errorData = (raw?.error ?? raw) || {};
13773
+ throw new VargGatewayError(errorData?.message ?? `gateway returned ${response.status}`, response.status);
13774
+ }
13775
+ return await response.json();
13776
+ }
13777
+ async syncVoices() {
13778
+ const response = await fetch(`${this.baseUrl}/voices/sync`, {
13779
+ method: "POST",
13780
+ headers: this.getHeaders()
13781
+ });
13782
+ if (!response.ok) {
13783
+ const raw = await response.json().catch(() => null);
13784
+ const errorData = (raw?.error ?? raw) || {};
13785
+ throw new VargGatewayError(errorData?.message ?? `gateway returned ${response.status}`, response.status);
13786
+ }
13787
+ return await response.json();
13788
+ }
13741
13789
  async getJob(id) {
13742
13790
  const response = await fetch(`${this.baseUrl}/jobs/${id}`, {
13743
13791
  method: "GET",
@@ -13756,8 +13804,68 @@ class VargClient {
13756
13804
  }
13757
13805
  }
13758
13806
  async waitForJob(id, options) {
13807
+ try {
13808
+ return await this.waitForJobSSE(id, options);
13809
+ } catch {
13810
+ return this.waitForJobPoll(id, options);
13811
+ }
13812
+ }
13813
+ async waitForJobSSE(id, options) {
13814
+ const timeoutMs = (options?.maxAttempts ?? 450) * (options?.pollIntervalMs ?? 2000);
13815
+ const response = await fetch(`${this.baseUrl}/jobs/${id}/stream`, {
13816
+ method: "GET",
13817
+ headers: {
13818
+ Authorization: `Bearer ${this.apiKey}`,
13819
+ Accept: "text/event-stream"
13820
+ }
13821
+ });
13822
+ if (!response.ok || !response.body) {
13823
+ throw new VargGatewayError(`SSE connection failed: ${response.status}`);
13824
+ }
13825
+ return new Promise((resolve, reject) => {
13826
+ const reader = response.body.getReader();
13827
+ const decoder = new TextDecoder;
13828
+ let buffer = "";
13829
+ const timer = setTimeout(() => {
13830
+ reader.cancel();
13831
+ reject(new VargGatewayError(`job ${id} did not complete within timeout`));
13832
+ }, timeoutMs);
13833
+ const read = () => {
13834
+ reader.read().then(({ done, value }) => {
13835
+ if (done) {
13836
+ clearTimeout(timer);
13837
+ this.getJob(id).then(resolve).catch(reject);
13838
+ return;
13839
+ }
13840
+ buffer += decoder.decode(value, { stream: true });
13841
+ const lines = buffer.split(`
13842
+ `);
13843
+ buffer = lines.pop() ?? "";
13844
+ for (const line of lines) {
13845
+ if (!line.startsWith("data: "))
13846
+ continue;
13847
+ try {
13848
+ const data = JSON.parse(line.slice(6));
13849
+ if (data.status === "completed" || data.status === "failed" || data.status === "cancelled") {
13850
+ clearTimeout(timer);
13851
+ reader.cancel();
13852
+ this.getJob(id).then(resolve).catch(reject);
13853
+ return;
13854
+ }
13855
+ } catch {}
13856
+ }
13857
+ read();
13858
+ }).catch((err) => {
13859
+ clearTimeout(timer);
13860
+ reject(err);
13861
+ });
13862
+ };
13863
+ read();
13864
+ });
13865
+ }
13866
+ async waitForJobPoll(id, options) {
13759
13867
  const pollIntervalMs = options?.pollIntervalMs ?? 2000;
13760
- const maxAttempts = options?.maxAttempts ?? 150;
13868
+ const maxAttempts = options?.maxAttempts ?? 450;
13761
13869
  for (let i = 0;i < maxAttempts; i++) {
13762
13870
  const job = await this.getJob(id);
13763
13871
  if (job.status === "completed" || job.status === "failed" || job.status === "cancelled") {
@@ -14121,7 +14229,8 @@ async function executeJob(client, capability, params) {
14121
14229
  return {
14122
14230
  data: new Uint8Array(await res2.arrayBuffer()),
14123
14231
  mediaType: job.output.media_type,
14124
- jobId: job.job_id
14232
+ jobId: job.job_id,
14233
+ metadata: job.output.metadata
14125
14234
  };
14126
14235
  }
14127
14236
  const completed = await client.waitForJob(job.job_id);
@@ -14139,10 +14248,11 @@ async function executeJob(client, capability, params) {
14139
14248
  return {
14140
14249
  data: new Uint8Array(await res.arrayBuffer()),
14141
14250
  mediaType: output.media_type,
14142
- jobId: job.job_id
14251
+ jobId: job.job_id,
14252
+ metadata: output.metadata
14143
14253
  };
14144
14254
  }
14145
-
14255
+ var varg_provider = createVarg({ apiKey: process.env.VARG_API_KEY ?? "" });
14146
14256
  class VargVideoModel {
14147
14257
  specificationVersion = "v3";
14148
14258
  provider = "varg";
@@ -14267,7 +14377,8 @@ class VargSpeechModel {
14267
14377
  response: {
14268
14378
  timestamp: new Date,
14269
14379
  modelId: this.modelId
14270
- }
14380
+ },
14381
+ providerMetadata: result.metadata
14271
14382
  };
14272
14383
  }
14273
14384
  }
@@ -14305,6 +14416,7 @@ class VargMusicModel {
14305
14416
  }
14306
14417
  }
14307
14418
  export {
14419
+ varg_provider as varg,
14308
14420
  createVarg,
14309
14421
  VideoRequest as VideoRequestSchema,
14310
14422
  VargGatewayError,
@@ -8,4 +8,6 @@ export interface VargProvider extends ProviderV3 {
8
8
  musicModel(modelId: string): MusicModelV3;
9
9
  }
10
10
  export declare function createVarg(config: VargClientConfig): VargProvider;
11
+ declare const varg_provider: VargProvider;
12
+ export { varg_provider as varg };
11
13
  //# sourceMappingURL=provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAIjB,KAAK,UAAU,EAEf,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EAEb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IAC1C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IAC1C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IAC5C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;CAC3C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAgBjE"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAIjB,KAAK,UAAU,EAEf,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,YAAY,EAEZ,YAAY,EAEb,MAAM,WAAW,CAAC;AACnB,OAAO,EAAc,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,MAAM,WAAW,YAAa,SAAQ,UAAU;IAC9C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IAC1C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;IAC1C,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAAC;IAC5C,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAAC;CAC3C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,YAAY,CAgBjE;AAsED,QAAA,MAAM,aAAa,cAAyD,CAAC;AAC7E,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vargai/gateway",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "typescript client for varg gateway api",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,24 +16,13 @@
16
16
  "types": "./src/provider.ts"
17
17
  }
18
18
  },
19
- "files": [
20
- "dist",
21
- "README.md"
22
- ],
19
+ "files": ["dist", "README.md"],
23
20
  "scripts": {
24
21
  "build": "bun build src/index.ts --outdir dist --target bun --format esm && bun run build:types",
25
22
  "build:types": "tsc --emitDeclarationOnly --declaration --outDir dist",
26
23
  "prepublishOnly": "bun run build"
27
24
  },
28
- "keywords": [
29
- "varg",
30
- "ai",
31
- "video",
32
- "image",
33
- "speech",
34
- "music",
35
- "generation"
36
- ],
25
+ "keywords": ["varg", "ai", "video", "image", "speech", "music", "generation"],
37
26
  "author": "varg",
38
27
  "license": "MIT",
39
28
  "publishConfig": {
@@ -46,9 +35,9 @@
46
35
  },
47
36
  "devDependencies": {
48
37
  "@types/bun": "latest",
49
- "@vargai/schemas": "0.1.0",
38
+ "@vargai/schemas": "workspace:*",
50
39
  "typescript": "^5",
51
- "vargai": "^0.4.0-alpha49"
40
+ "vargai": "^0.4.0-alpha61"
52
41
  },
53
42
  "peerDependencies": {
54
43
  "typescript": "^5"