@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.cjs CHANGED
@@ -40,6 +40,8 @@ __export(index_exports, {
40
40
  module.exports = __toCommonJS(index_exports);
41
41
 
42
42
  // src/client.ts
43
+ var import_path2 = __toESM(require("path"), 1);
44
+ var import_os = __toESM(require("os"), 1);
43
45
  var import_axios2 = __toESM(require("axios"), 1);
44
46
 
45
47
  // src/task-folder.ts
@@ -240,31 +242,31 @@ var ImageAPI = class {
240
242
  * prompt: 'A beautiful sunset over mountains',
241
243
  * size: { value: '2K', label: '2K' }
242
244
  * });
245
+ * console.log('Task folder:', result.taskFolder);
246
+ * console.log('Local path:', result.response.data?.[0]?.localPath);
243
247
  * ```
244
248
  */
245
249
  async gemini(params) {
246
- const taskResult = await this.client.request("/api/gemini/image", {
250
+ return this.client.request("/api/gemini/image", {
247
251
  prompt: params.prompt,
248
252
  attachment: params.attachment,
249
253
  model: params.model,
250
254
  aspect_ratio: params.aspect_ratio,
251
255
  size: params.size
252
256
  });
253
- return taskResult.response;
254
257
  }
255
258
  /**
256
259
  * Generate image using Gemini API v2
257
260
  * @see /api/gemini/image/v2
258
261
  */
259
262
  async geminiV2(params) {
260
- const taskResult = await this.client.request("/api/gemini/image/v2", {
263
+ return this.client.request("/api/gemini/image/v2", {
261
264
  prompt: params.prompt,
262
265
  attachment: params.attachment,
263
266
  model: params.model,
264
267
  aspect_ratio: params.aspect_ratio,
265
268
  size: params.size
266
269
  });
267
- return taskResult.response;
268
270
  }
269
271
  /**
270
272
  * Generate image using JiMeng (Doubao) API
@@ -276,10 +278,11 @@ var ImageAPI = class {
276
278
  * prompt: '一只可爱的猫咪',
277
279
  * size: { value: '1024x1024', label: '1:1' }
278
280
  * });
281
+ * console.log('Task folder:', result.taskFolder);
279
282
  * ```
280
283
  */
281
284
  async jimeng(params) {
282
- const taskResult = await this.client.request("/api/jimeng/image", {
285
+ return this.client.request("/api/jimeng/image", {
283
286
  prompt: params.prompt,
284
287
  attachment: params.attachment,
285
288
  size: params.size,
@@ -288,14 +291,13 @@ var ImageAPI = class {
288
291
  image_count: params.image_count,
289
292
  model: params.model
290
293
  });
291
- return taskResult.response;
292
294
  }
293
295
  /**
294
296
  * Generate image using JiMeng V3 API
295
297
  * @see /api/jimeng/image/v3
296
298
  */
297
299
  async jimengV3(params) {
298
- const taskResult = await this.client.request("/api/jimeng/image/v3", {
300
+ return this.client.request("/api/jimeng/image/v3", {
299
301
  prompt: params.prompt,
300
302
  attachment: params.attachment,
301
303
  size: params.size,
@@ -304,18 +306,16 @@ var ImageAPI = class {
304
306
  image_count: params.image_count,
305
307
  model: params.model
306
308
  });
307
- return taskResult.response;
308
309
  }
309
310
  /**
310
311
  * Compress image
311
312
  * @see /api/image/compress
312
313
  */
313
314
  async compress(params) {
314
- const taskResult = await this.client.request("/api/image/compress", {
315
+ return this.client.request("/api/image/compress", {
315
316
  attachment: params.attachment,
316
317
  quality: params.quality
317
318
  });
318
- return taskResult.response;
319
319
  }
320
320
  };
321
321
 
@@ -334,28 +334,27 @@ var VideoAPI = class {
334
334
  * prompt: 'A cat playing piano',
335
335
  * orientation: { value: 'landscape', label: 'Landscape' }
336
336
  * });
337
+ * console.log('Task folder:', result.taskFolder);
337
338
  * ```
338
339
  */
339
340
  async sora(params) {
340
- const taskResult = await this.client.request("/api/sora/video", {
341
+ return this.client.request("/api/sora/video", {
341
342
  attachment: params.attachment,
342
343
  prompt: params.prompt,
343
344
  orientation: params.orientation
344
345
  });
345
- return taskResult.response;
346
346
  }
347
347
  /**
348
348
  * Generate video using Sora Stable API
349
349
  * @see /api/sora/video/stable
350
350
  */
351
351
  async soraStable(params) {
352
- const taskResult = await this.client.request("/api/sora/video/stable", {
352
+ return this.client.request("/api/sora/video/stable", {
353
353
  attachment: params.attachment,
354
354
  prompt: params.prompt,
355
355
  size: params.size,
356
356
  seconds: params.seconds
357
357
  });
358
- return taskResult.response;
359
358
  }
360
359
  /**
361
360
  * Generate video using Veo API
@@ -371,7 +370,7 @@ var VideoAPI = class {
371
370
  * ```
372
371
  */
373
372
  async veo(params) {
374
- const taskResult = await this.client.request("/api/veo/video", {
373
+ return this.client.request("/api/veo/video", {
375
374
  prompt: params.prompt,
376
375
  attachment: params.attachment,
377
376
  first_frame: params.first_frame,
@@ -380,7 +379,6 @@ var VideoAPI = class {
380
379
  resolution: params.resolution,
381
380
  duration: params.duration
382
381
  });
383
- return taskResult.response;
384
382
  }
385
383
  /**
386
384
  * Generate video using Kling API
@@ -397,14 +395,13 @@ var VideoAPI = class {
397
395
  * ```
398
396
  */
399
397
  async kling(params) {
400
- const taskResult = await this.client.request("/api/kling/video", {
398
+ return this.client.request("/api/kling/video", {
401
399
  attachment: params.attachment,
402
400
  prompt: params.prompt,
403
401
  aspect_ratio: params.aspect_ratio,
404
402
  duration: params.duration,
405
403
  model: params.model
406
404
  });
407
- return taskResult.response;
408
405
  }
409
406
  /**
410
407
  * Generate video using JiMeng API
@@ -420,13 +417,12 @@ var VideoAPI = class {
420
417
  * ```
421
418
  */
422
419
  async jimeng(params) {
423
- const taskResult = await this.client.request("/api/jimeng/video", {
420
+ return this.client.request("/api/jimeng/video", {
424
421
  action: params.action,
425
422
  attachment: params.attachment,
426
423
  prompt: params.prompt,
427
424
  aspect_ratio: params.aspect_ratio
428
425
  });
429
- return taskResult.response;
430
426
  }
431
427
  /**
432
428
  * Generate video using Doubao API
@@ -442,7 +438,7 @@ var VideoAPI = class {
442
438
  * ```
443
439
  */
444
440
  async doubao(params) {
445
- const taskResult = await this.client.request("/api/doubao/video", {
441
+ return this.client.request("/api/doubao/video", {
446
442
  action: params.action,
447
443
  attachment: params.attachment,
448
444
  prompt: params.prompt,
@@ -450,7 +446,6 @@ var VideoAPI = class {
450
446
  ratio: params.ratio,
451
447
  duration: params.duration
452
448
  });
453
- return taskResult.response;
454
449
  }
455
450
  /**
456
451
  * Generate video using Wan API (Alibaba)
@@ -467,7 +462,7 @@ var VideoAPI = class {
467
462
  * ```
468
463
  */
469
464
  async wan(params) {
470
- const taskResult = await this.client.request("/api/wan/video", {
465
+ return this.client.request("/api/wan/video", {
471
466
  attachment: params.attachment,
472
467
  prompt: params.prompt,
473
468
  size: params.size,
@@ -475,7 +470,6 @@ var VideoAPI = class {
475
470
  model: params.model,
476
471
  shot_type: params.shot_type
477
472
  });
478
- return taskResult.response;
479
473
  }
480
474
  /**
481
475
  * Generate video using MiniMax API
@@ -491,14 +485,13 @@ var VideoAPI = class {
491
485
  * ```
492
486
  */
493
487
  async minimax(params) {
494
- const taskResult = await this.client.request("/api/minimax/video", {
488
+ return this.client.request("/api/minimax/video", {
495
489
  attachment: params.attachment,
496
490
  prompt: params.prompt,
497
491
  size: params.size,
498
492
  duration: params.duration,
499
493
  model: params.model
500
494
  });
501
- return taskResult.response;
502
495
  }
503
496
  };
504
497
 
@@ -518,119 +511,111 @@ var DocumentAPI = class {
518
511
  * source_language: { value: 'en', label: 'English' },
519
512
  * target_language: { value: 'zh', label: 'Chinese' }
520
513
  * });
514
+ * console.log('Task folder:', result.taskFolder);
521
515
  * ```
522
516
  */
523
517
  async translate(params) {
524
- const taskResult = await this.client.request("/api/doc/translate", {
518
+ return this.client.request("/api/doc/translate", {
525
519
  attachment: params.attachment,
526
520
  source_language: params.source_language,
527
521
  target_language: params.target_language
528
522
  });
529
- return taskResult.response;
530
523
  }
531
524
  /**
532
525
  * Convert image to Word document
533
526
  * @see /api/doc_convert/image2word
534
527
  */
535
528
  async image2Word(params) {
536
- const taskResult = await this.client.request(
529
+ return this.client.request(
537
530
  "/api/doc_convert/image2word",
538
531
  {
539
532
  attachment: params.attachment
540
533
  }
541
534
  );
542
- return taskResult.response;
543
535
  }
544
536
  /**
545
537
  * Convert image to PowerPoint
546
538
  * @see /api/doc_convert/image2ppt
547
539
  */
548
540
  async image2Ppt(params) {
549
- const taskResult = await this.client.request(
541
+ return this.client.request(
550
542
  "/api/doc_convert/image2ppt",
551
543
  {
552
544
  attachment: params.attachment
553
545
  }
554
546
  );
555
- return taskResult.response;
556
547
  }
557
548
  /**
558
549
  * Convert image to Excel
559
550
  * @see /api/doc_convert/image2excel
560
551
  */
561
552
  async image2Excel(params) {
562
- const taskResult = await this.client.request(
553
+ return this.client.request(
563
554
  "/api/doc_convert/image2excel",
564
555
  {
565
556
  attachment: params.attachment
566
557
  }
567
558
  );
568
- return taskResult.response;
569
559
  }
570
560
  /**
571
561
  * Convert image to PDF
572
562
  * @see /api/doc_convert/image2pdf
573
563
  */
574
564
  async image2Pdf(params) {
575
- const taskResult = await this.client.request(
565
+ return this.client.request(
576
566
  "/api/doc_convert/image2pdf",
577
567
  {
578
568
  attachment: params.attachment
579
569
  }
580
570
  );
581
- return taskResult.response;
582
571
  }
583
572
  /**
584
573
  * Convert PDF to Word document
585
574
  * @see /api/doc_convert/pdf2word
586
575
  */
587
576
  async pdf2Word(params) {
588
- const taskResult = await this.client.request(
577
+ return this.client.request(
589
578
  "/api/doc_convert/pdf2word",
590
579
  {
591
580
  attachment: params.attachment
592
581
  }
593
582
  );
594
- return taskResult.response;
595
583
  }
596
584
  /**
597
585
  * Convert PDF to PowerPoint
598
586
  * @see /api/doc_convert/pdf2ppt
599
587
  */
600
588
  async pdf2Ppt(params) {
601
- const taskResult = await this.client.request(
589
+ return this.client.request(
602
590
  "/api/doc_convert/pdf2ppt",
603
591
  {
604
592
  attachment: params.attachment
605
593
  }
606
594
  );
607
- return taskResult.response;
608
595
  }
609
596
  /**
610
597
  * Convert PDF to Excel
611
598
  * @see /api/doc_convert/pdf2excel
612
599
  */
613
600
  async pdf2Excel(params) {
614
- const taskResult = await this.client.request(
601
+ return this.client.request(
615
602
  "/api/doc_convert/pdf2excel",
616
603
  {
617
604
  attachment: params.attachment
618
605
  }
619
606
  );
620
- return taskResult.response;
621
607
  }
622
608
  /**
623
609
  * Convert PDF to image
624
610
  * @see /api/doc_convert/pdf2image
625
611
  */
626
612
  async pdf2Image(params) {
627
- const taskResult = await this.client.request(
613
+ return this.client.request(
628
614
  "/api/doc_convert/pdf2image",
629
615
  {
630
616
  attachment: params.attachment
631
617
  }
632
618
  );
633
- return taskResult.response;
634
619
  }
635
620
  /**
636
621
  * Generic document conversion
@@ -640,12 +625,11 @@ var DocumentAPI = class {
640
625
  async convert(params) {
641
626
  const isImage = params.input_format === "image" || !params.input_format;
642
627
  const endpoint = isImage ? "/api/doc_convert/image" : "/api/doc_convert/pdf";
643
- const taskResult = await this.client.request(endpoint, {
628
+ return this.client.request(endpoint, {
644
629
  attachment: params.attachment,
645
630
  input_format: params.input_format,
646
631
  output_format: params.output_format
647
632
  });
648
- return taskResult.response;
649
633
  }
650
634
  };
651
635
 
@@ -669,13 +653,15 @@ var MediaAPI = class {
669
653
  * const result = await client.media.analyze({
670
654
  * url: [{ tmp_url: 'https://...', type: 'video/mp4', name: 'video.mp4' }]
671
655
  * });
656
+ *
657
+ * console.log('Task folder:', result.taskFolder);
658
+ * console.log('Summary:', result.response.data?.summary);
672
659
  * ```
673
660
  */
674
661
  async analyze(params) {
675
- const taskResult = await this.client.request("/api/media_analysis", {
662
+ return this.client.request("/api/media_analysis", {
676
663
  url: params.url
677
664
  });
678
- return taskResult.response;
679
665
  }
680
666
  /**
681
667
  * Analyze video file directly
@@ -690,7 +676,7 @@ var MediaAPI = class {
690
676
  * ```
691
677
  */
692
678
  async analyzeVideo(params) {
693
- const taskResult = await this.client.request("/api/media_analysis", {
679
+ return this.client.request("/api/media_analysis", {
694
680
  url: [
695
681
  {
696
682
  tmp_url: params.file.tmp_url,
@@ -700,7 +686,6 @@ var MediaAPI = class {
700
686
  }
701
687
  ]
702
688
  });
703
- return taskResult.response;
704
689
  }
705
690
  /**
706
691
  * Analyze social media video (TikTok, YouTube, etc.)
@@ -714,10 +699,9 @@ var MediaAPI = class {
714
699
  * ```
715
700
  */
716
701
  async analyzeSocialVideo(params) {
717
- const taskResult = await this.client.request("/api/media_analysis", {
702
+ return this.client.request("/api/media_analysis", {
718
703
  url: [{ link: params.url, type: "url" }]
719
704
  });
720
- return taskResult.response;
721
705
  }
722
706
  };
723
707
 
@@ -743,12 +727,10 @@ var UnityClawClient = class {
743
727
  apiKey,
744
728
  baseUrl,
745
729
  taskDir: config.taskDir ?? (() => {
746
- const path = require("path");
747
- const os = require("os");
748
730
  try {
749
- return path.join(process.cwd(), "tasks");
731
+ return import_path2.default.join(process.cwd(), "tasks");
750
732
  } catch {
751
- return path.join(os.homedir(), "tasks");
733
+ return import_path2.default.join(import_os.default.homedir(), "tasks");
752
734
  }
753
735
  })(),
754
736
  timeout: config.timeout ?? DEFAULT_TIMEOUT,