seacloud-sdk 0.9.8 → 0.9.9

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/cli.js CHANGED
@@ -601,6 +601,7 @@ Commands:
601
601
  llm <prompt> Chat with LLM models
602
602
  agent <prompt> Chat with Fast Agent (supports image/video generation)
603
603
  app <subcommand> App-related operations (search, generation)
604
+ status <task-id> Query task status by task ID
604
605
  <model> Test specific model generation
605
606
 
606
607
  App Subcommands:
@@ -631,6 +632,10 @@ Model Generation Options:
631
632
  --base-url <url> Base URL (default: http://proxy.sg.seaverse.dev)
632
633
  --params <json> JSON parameters for the model
633
634
 
635
+ Status Query Options:
636
+ --api-key <key> API key (or set API_SERVICE_TOKEN env var)
637
+ --base-url <url> Base URL (default: http://proxy.sg.seaverse.dev)
638
+
634
639
  Examples:
635
640
  # Chat with LLM (non-streaming)
636
641
  seacloud llm "What is the capital of France?"
@@ -654,6 +659,9 @@ Examples:
654
659
  # Create generation task (app generation)
655
660
  seacloud app generation --template-id "d26trpte878eqsnm3bjg" --params '[{"field":"prompt1","value":"hello"}]'
656
661
 
662
+ # Query task status
663
+ seacloud status d123456789abcdef
664
+
657
665
  # Test model generation
658
666
  seacloud flux_1_1_pro --params '{"prompt":"a beautiful sunset"}'
659
667
 
@@ -952,6 +960,68 @@ async function runAppSearch(templateIdsStr, args) {
952
960
  });
953
961
  console.log(JSON.stringify(result, null, 2));
954
962
  }
963
+ async function runTaskStatus(taskId, args) {
964
+ const options = {};
965
+ for (let i = 0; i < args.length; i++) {
966
+ const arg = args[i];
967
+ if (arg === "--api-key") options.apiKey = args[++i];
968
+ else if (arg === "--base-url") options.baseUrl = args[++i];
969
+ }
970
+ const apiKey = options.apiKey || process.env.API_SERVICE_TOKEN || "";
971
+ const baseUrl = options.baseUrl || process.env.SEACLOUD_BASE_URL || "http://proxy.sg.seaverse.dev";
972
+ const client = new SeacloudClient({ apiKey, baseUrl });
973
+ console.log(`Querying task status...`);
974
+ console.log(`Task ID: ${taskId}`);
975
+ console.log(`Base URL: ${baseUrl}
976
+ `);
977
+ try {
978
+ const result = await client.getTaskStatus("/model/v1/generation", taskId);
979
+ console.log(`Status: ${result.status}`);
980
+ console.log(`Task ID: ${result.id}
981
+ `);
982
+ if (result.status === "completed") {
983
+ console.log("\u2705 Task completed successfully!\n");
984
+ console.log("Output:");
985
+ console.log(JSON.stringify(result.output, null, 2));
986
+ if (result.output) {
987
+ const urls = [];
988
+ for (const item of result.output) {
989
+ if (item.content) {
990
+ for (const resource of item.content) {
991
+ if (resource.url) {
992
+ urls.push(resource.url);
993
+ }
994
+ }
995
+ }
996
+ }
997
+ if (urls.length > 0) {
998
+ console.log("\nGenerated URLs:");
999
+ urls.forEach((url, i) => {
1000
+ console.log(` ${i + 1}. ${url}`);
1001
+ });
1002
+ }
1003
+ }
1004
+ } else if (result.status === "failed") {
1005
+ console.log("\u274C Task failed!\n");
1006
+ console.log("Error:", JSON.stringify(result.error, null, 2));
1007
+ } else if (result.status === "processing") {
1008
+ console.log("\u23F3 Task is still processing...");
1009
+ console.log("Please check again later.");
1010
+ } else if (result.status === "pending") {
1011
+ console.log("\u23F3 Task is pending...");
1012
+ console.log("Please check again later.");
1013
+ } else {
1014
+ console.log("Full result:");
1015
+ console.log(JSON.stringify(result, null, 2));
1016
+ }
1017
+ } catch (error) {
1018
+ console.error("\nError querying task status:", error.message);
1019
+ if (error.statusCode) {
1020
+ console.error("HTTP Status Code:", error.statusCode);
1021
+ }
1022
+ process.exit(1);
1023
+ }
1024
+ }
955
1025
  async function main() {
956
1026
  const args = process.argv.slice(2);
957
1027
  if (args.length === 0 || args[0] === "--help" || args[0] === "-h") {
@@ -974,6 +1044,13 @@ async function main() {
974
1044
  process.exit(1);
975
1045
  }
976
1046
  await runAgent(args[1], args.slice(2));
1047
+ } else if (command === "status") {
1048
+ if (args.length < 2) {
1049
+ console.error("Error: task ID required for status command");
1050
+ console.log("Usage: seacloud status <task-id> [options]");
1051
+ process.exit(1);
1052
+ }
1053
+ await runTaskStatus(args[1], args.slice(2));
977
1054
  } else if (command === "app") {
978
1055
  const subcommand = args[1];
979
1056
  if (!subcommand) {