@unityclaw/sdk 1.0.0 → 1.0.2

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/index.js CHANGED
@@ -1,11 +1,6 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/client.ts
2
+ import path from "path";
3
+ import os from "os";
9
4
  import axios2, { AxiosError } from "axios";
10
5
 
11
6
  // src/task-folder.ts
@@ -206,31 +201,31 @@ var ImageAPI = class {
206
201
  * prompt: 'A beautiful sunset over mountains',
207
202
  * size: { value: '2K', label: '2K' }
208
203
  * });
204
+ * console.log('Task folder:', result.taskFolder);
205
+ * console.log('Local path:', result.response.data?.[0]?.localPath);
209
206
  * ```
210
207
  */
211
208
  async gemini(params) {
212
- const taskResult = await this.client.request("/api/gemini/image", {
209
+ return this.client.request("/api/gemini/image", {
213
210
  prompt: params.prompt,
214
211
  attachment: params.attachment,
215
212
  model: params.model,
216
213
  aspect_ratio: params.aspect_ratio,
217
214
  size: params.size
218
215
  });
219
- return taskResult.response;
220
216
  }
221
217
  /**
222
218
  * Generate image using Gemini API v2
223
219
  * @see /api/gemini/image/v2
224
220
  */
225
221
  async geminiV2(params) {
226
- const taskResult = await this.client.request("/api/gemini/image/v2", {
222
+ return this.client.request("/api/gemini/image/v2", {
227
223
  prompt: params.prompt,
228
224
  attachment: params.attachment,
229
225
  model: params.model,
230
226
  aspect_ratio: params.aspect_ratio,
231
227
  size: params.size
232
228
  });
233
- return taskResult.response;
234
229
  }
235
230
  /**
236
231
  * Generate image using JiMeng (Doubao) API
@@ -242,10 +237,11 @@ var ImageAPI = class {
242
237
  * prompt: '一只可爱的猫咪',
243
238
  * size: { value: '1024x1024', label: '1:1' }
244
239
  * });
240
+ * console.log('Task folder:', result.taskFolder);
245
241
  * ```
246
242
  */
247
243
  async jimeng(params) {
248
- const taskResult = await this.client.request("/api/jimeng/image", {
244
+ return this.client.request("/api/jimeng/image", {
249
245
  prompt: params.prompt,
250
246
  attachment: params.attachment,
251
247
  size: params.size,
@@ -254,14 +250,13 @@ var ImageAPI = class {
254
250
  image_count: params.image_count,
255
251
  model: params.model
256
252
  });
257
- return taskResult.response;
258
253
  }
259
254
  /**
260
255
  * Generate image using JiMeng V3 API
261
256
  * @see /api/jimeng/image/v3
262
257
  */
263
258
  async jimengV3(params) {
264
- const taskResult = await this.client.request("/api/jimeng/image/v3", {
259
+ return this.client.request("/api/jimeng/image/v3", {
265
260
  prompt: params.prompt,
266
261
  attachment: params.attachment,
267
262
  size: params.size,
@@ -270,18 +265,16 @@ var ImageAPI = class {
270
265
  image_count: params.image_count,
271
266
  model: params.model
272
267
  });
273
- return taskResult.response;
274
268
  }
275
269
  /**
276
270
  * Compress image
277
271
  * @see /api/image/compress
278
272
  */
279
273
  async compress(params) {
280
- const taskResult = await this.client.request("/api/image/compress", {
274
+ return this.client.request("/api/image/compress", {
281
275
  attachment: params.attachment,
282
276
  quality: params.quality
283
277
  });
284
- return taskResult.response;
285
278
  }
286
279
  };
287
280
 
@@ -300,28 +293,27 @@ var VideoAPI = class {
300
293
  * prompt: 'A cat playing piano',
301
294
  * orientation: { value: 'landscape', label: 'Landscape' }
302
295
  * });
296
+ * console.log('Task folder:', result.taskFolder);
303
297
  * ```
304
298
  */
305
299
  async sora(params) {
306
- const taskResult = await this.client.request("/api/sora/video", {
300
+ return this.client.request("/api/sora/video", {
307
301
  attachment: params.attachment,
308
302
  prompt: params.prompt,
309
303
  orientation: params.orientation
310
304
  });
311
- return taskResult.response;
312
305
  }
313
306
  /**
314
307
  * Generate video using Sora Stable API
315
308
  * @see /api/sora/video/stable
316
309
  */
317
310
  async soraStable(params) {
318
- const taskResult = await this.client.request("/api/sora/video/stable", {
311
+ return this.client.request("/api/sora/video/stable", {
319
312
  attachment: params.attachment,
320
313
  prompt: params.prompt,
321
314
  size: params.size,
322
315
  seconds: params.seconds
323
316
  });
324
- return taskResult.response;
325
317
  }
326
318
  /**
327
319
  * Generate video using Veo API
@@ -337,7 +329,7 @@ var VideoAPI = class {
337
329
  * ```
338
330
  */
339
331
  async veo(params) {
340
- const taskResult = await this.client.request("/api/veo/video", {
332
+ return this.client.request("/api/veo/video", {
341
333
  prompt: params.prompt,
342
334
  attachment: params.attachment,
343
335
  first_frame: params.first_frame,
@@ -346,7 +338,6 @@ var VideoAPI = class {
346
338
  resolution: params.resolution,
347
339
  duration: params.duration
348
340
  });
349
- return taskResult.response;
350
341
  }
351
342
  /**
352
343
  * Generate video using Kling API
@@ -363,14 +354,13 @@ var VideoAPI = class {
363
354
  * ```
364
355
  */
365
356
  async kling(params) {
366
- const taskResult = await this.client.request("/api/kling/video", {
357
+ return this.client.request("/api/kling/video", {
367
358
  attachment: params.attachment,
368
359
  prompt: params.prompt,
369
360
  aspect_ratio: params.aspect_ratio,
370
361
  duration: params.duration,
371
362
  model: params.model
372
363
  });
373
- return taskResult.response;
374
364
  }
375
365
  /**
376
366
  * Generate video using JiMeng API
@@ -386,13 +376,12 @@ var VideoAPI = class {
386
376
  * ```
387
377
  */
388
378
  async jimeng(params) {
389
- const taskResult = await this.client.request("/api/jimeng/video", {
379
+ return this.client.request("/api/jimeng/video", {
390
380
  action: params.action,
391
381
  attachment: params.attachment,
392
382
  prompt: params.prompt,
393
383
  aspect_ratio: params.aspect_ratio
394
384
  });
395
- return taskResult.response;
396
385
  }
397
386
  /**
398
387
  * Generate video using Doubao API
@@ -408,7 +397,7 @@ var VideoAPI = class {
408
397
  * ```
409
398
  */
410
399
  async doubao(params) {
411
- const taskResult = await this.client.request("/api/doubao/video", {
400
+ return this.client.request("/api/doubao/video", {
412
401
  action: params.action,
413
402
  attachment: params.attachment,
414
403
  prompt: params.prompt,
@@ -416,7 +405,6 @@ var VideoAPI = class {
416
405
  ratio: params.ratio,
417
406
  duration: params.duration
418
407
  });
419
- return taskResult.response;
420
408
  }
421
409
  /**
422
410
  * Generate video using Wan API (Alibaba)
@@ -433,7 +421,7 @@ var VideoAPI = class {
433
421
  * ```
434
422
  */
435
423
  async wan(params) {
436
- const taskResult = await this.client.request("/api/wan/video", {
424
+ return this.client.request("/api/wan/video", {
437
425
  attachment: params.attachment,
438
426
  prompt: params.prompt,
439
427
  size: params.size,
@@ -441,7 +429,6 @@ var VideoAPI = class {
441
429
  model: params.model,
442
430
  shot_type: params.shot_type
443
431
  });
444
- return taskResult.response;
445
432
  }
446
433
  /**
447
434
  * Generate video using MiniMax API
@@ -457,14 +444,13 @@ var VideoAPI = class {
457
444
  * ```
458
445
  */
459
446
  async minimax(params) {
460
- const taskResult = await this.client.request("/api/minimax/video", {
447
+ return this.client.request("/api/minimax/video", {
461
448
  attachment: params.attachment,
462
449
  prompt: params.prompt,
463
450
  size: params.size,
464
451
  duration: params.duration,
465
452
  model: params.model
466
453
  });
467
- return taskResult.response;
468
454
  }
469
455
  };
470
456
 
@@ -484,119 +470,111 @@ var DocumentAPI = class {
484
470
  * source_language: { value: 'en', label: 'English' },
485
471
  * target_language: { value: 'zh', label: 'Chinese' }
486
472
  * });
473
+ * console.log('Task folder:', result.taskFolder);
487
474
  * ```
488
475
  */
489
476
  async translate(params) {
490
- const taskResult = await this.client.request("/api/doc/translate", {
477
+ return this.client.request("/api/doc/translate", {
491
478
  attachment: params.attachment,
492
479
  source_language: params.source_language,
493
480
  target_language: params.target_language
494
481
  });
495
- return taskResult.response;
496
482
  }
497
483
  /**
498
484
  * Convert image to Word document
499
485
  * @see /api/doc_convert/image2word
500
486
  */
501
487
  async image2Word(params) {
502
- const taskResult = await this.client.request(
488
+ return this.client.request(
503
489
  "/api/doc_convert/image2word",
504
490
  {
505
491
  attachment: params.attachment
506
492
  }
507
493
  );
508
- return taskResult.response;
509
494
  }
510
495
  /**
511
496
  * Convert image to PowerPoint
512
497
  * @see /api/doc_convert/image2ppt
513
498
  */
514
499
  async image2Ppt(params) {
515
- const taskResult = await this.client.request(
500
+ return this.client.request(
516
501
  "/api/doc_convert/image2ppt",
517
502
  {
518
503
  attachment: params.attachment
519
504
  }
520
505
  );
521
- return taskResult.response;
522
506
  }
523
507
  /**
524
508
  * Convert image to Excel
525
509
  * @see /api/doc_convert/image2excel
526
510
  */
527
511
  async image2Excel(params) {
528
- const taskResult = await this.client.request(
512
+ return this.client.request(
529
513
  "/api/doc_convert/image2excel",
530
514
  {
531
515
  attachment: params.attachment
532
516
  }
533
517
  );
534
- return taskResult.response;
535
518
  }
536
519
  /**
537
520
  * Convert image to PDF
538
521
  * @see /api/doc_convert/image2pdf
539
522
  */
540
523
  async image2Pdf(params) {
541
- const taskResult = await this.client.request(
524
+ return this.client.request(
542
525
  "/api/doc_convert/image2pdf",
543
526
  {
544
527
  attachment: params.attachment
545
528
  }
546
529
  );
547
- return taskResult.response;
548
530
  }
549
531
  /**
550
532
  * Convert PDF to Word document
551
533
  * @see /api/doc_convert/pdf2word
552
534
  */
553
535
  async pdf2Word(params) {
554
- const taskResult = await this.client.request(
536
+ return this.client.request(
555
537
  "/api/doc_convert/pdf2word",
556
538
  {
557
539
  attachment: params.attachment
558
540
  }
559
541
  );
560
- return taskResult.response;
561
542
  }
562
543
  /**
563
544
  * Convert PDF to PowerPoint
564
545
  * @see /api/doc_convert/pdf2ppt
565
546
  */
566
547
  async pdf2Ppt(params) {
567
- const taskResult = await this.client.request(
548
+ return this.client.request(
568
549
  "/api/doc_convert/pdf2ppt",
569
550
  {
570
551
  attachment: params.attachment
571
552
  }
572
553
  );
573
- return taskResult.response;
574
554
  }
575
555
  /**
576
556
  * Convert PDF to Excel
577
557
  * @see /api/doc_convert/pdf2excel
578
558
  */
579
559
  async pdf2Excel(params) {
580
- const taskResult = await this.client.request(
560
+ return this.client.request(
581
561
  "/api/doc_convert/pdf2excel",
582
562
  {
583
563
  attachment: params.attachment
584
564
  }
585
565
  );
586
- return taskResult.response;
587
566
  }
588
567
  /**
589
568
  * Convert PDF to image
590
569
  * @see /api/doc_convert/pdf2image
591
570
  */
592
571
  async pdf2Image(params) {
593
- const taskResult = await this.client.request(
572
+ return this.client.request(
594
573
  "/api/doc_convert/pdf2image",
595
574
  {
596
575
  attachment: params.attachment
597
576
  }
598
577
  );
599
- return taskResult.response;
600
578
  }
601
579
  /**
602
580
  * Generic document conversion
@@ -606,12 +584,11 @@ var DocumentAPI = class {
606
584
  async convert(params) {
607
585
  const isImage = params.input_format === "image" || !params.input_format;
608
586
  const endpoint = isImage ? "/api/doc_convert/image" : "/api/doc_convert/pdf";
609
- const taskResult = await this.client.request(endpoint, {
587
+ return this.client.request(endpoint, {
610
588
  attachment: params.attachment,
611
589
  input_format: params.input_format,
612
590
  output_format: params.output_format
613
591
  });
614
- return taskResult.response;
615
592
  }
616
593
  };
617
594
 
@@ -635,13 +612,15 @@ var MediaAPI = class {
635
612
  * const result = await client.media.analyze({
636
613
  * url: [{ tmp_url: 'https://...', type: 'video/mp4', name: 'video.mp4' }]
637
614
  * });
615
+ *
616
+ * console.log('Task folder:', result.taskFolder);
617
+ * console.log('Summary:', result.response.data?.summary);
638
618
  * ```
639
619
  */
640
620
  async analyze(params) {
641
- const taskResult = await this.client.request("/api/media_analysis", {
621
+ return this.client.request("/api/media_analysis", {
642
622
  url: params.url
643
623
  });
644
- return taskResult.response;
645
624
  }
646
625
  /**
647
626
  * Analyze video file directly
@@ -656,7 +635,7 @@ var MediaAPI = class {
656
635
  * ```
657
636
  */
658
637
  async analyzeVideo(params) {
659
- const taskResult = await this.client.request("/api/media_analysis", {
638
+ return this.client.request("/api/media_analysis", {
660
639
  url: [
661
640
  {
662
641
  tmp_url: params.file.tmp_url,
@@ -666,7 +645,6 @@ var MediaAPI = class {
666
645
  }
667
646
  ]
668
647
  });
669
- return taskResult.response;
670
648
  }
671
649
  /**
672
650
  * Analyze social media video (TikTok, YouTube, etc.)
@@ -680,10 +658,9 @@ var MediaAPI = class {
680
658
  * ```
681
659
  */
682
660
  async analyzeSocialVideo(params) {
683
- const taskResult = await this.client.request("/api/media_analysis", {
661
+ return this.client.request("/api/media_analysis", {
684
662
  url: [{ link: params.url, type: "url" }]
685
663
  });
686
- return taskResult.response;
687
664
  }
688
665
  };
689
666
 
@@ -709,8 +686,6 @@ var UnityClawClient = class {
709
686
  apiKey,
710
687
  baseUrl,
711
688
  taskDir: config.taskDir ?? (() => {
712
- const path = __require("path");
713
- const os = __require("os");
714
689
  try {
715
690
  return path.join(process.cwd(), "tasks");
716
691
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unityclaw/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Node.js SDK for UnityClaw API - AI-powered image/video generation, media analysis, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -8,9 +8,9 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
- "types": "./dist/index.d.ts"
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "files": [