exa-js 1.7.2 → 1.7.3

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.mjs CHANGED
@@ -664,7 +664,7 @@ var ResearchClient = class extends ResearchBaseClient {
664
664
  super(client);
665
665
  }
666
666
  /**
667
- * Create and run a research task (blocking call).
667
+ * Create a research task.
668
668
  *
669
669
  * Both parameters are required and have fixed shapes:
670
670
  * 1. `input`
@@ -687,17 +687,36 @@ var ResearchClient = class extends ResearchBaseClient {
687
687
  }
688
688
  /**
689
689
  * Retrieve a research task by ID.
690
- *
691
- * Not yet implemented server-side. Calling this will throw until the API is
692
- * available.
693
690
  */
694
- async getTask() {
695
- throw new Error("getTask is not implemented yet.");
691
+ async getTask(id) {
692
+ return this.request(`/tasks/${id}`, "GET");
693
+ }
694
+ /**
695
+ * Poll a research task until completion or failure.
696
+ * Polls every 1 second with a maximum timeout of 10 minutes.
697
+ */
698
+ async pollTask(id) {
699
+ const pollingInterval = 1e3;
700
+ const maxPollingTime = 10 * 60 * 1e3;
701
+ const startTime = Date.now();
702
+ while (true) {
703
+ const task = await this.request(`/tasks/${id}`, "GET");
704
+ if (task.status === "completed" || task.status === "failed") {
705
+ return task;
706
+ }
707
+ if (Date.now() - startTime > maxPollingTime) {
708
+ throw new Error(
709
+ `Polling timeout: Task ${id} did not complete within 10 minutes`
710
+ );
711
+ }
712
+ await new Promise((resolve) => setTimeout(resolve, pollingInterval));
713
+ }
696
714
  }
697
715
  };
698
716
 
699
717
  // src/research/types.ts
700
718
  var ResearchStatus = /* @__PURE__ */ ((ResearchStatus2) => {
719
+ ResearchStatus2["in_progress"] = "in_progress";
701
720
  ResearchStatus2["completed"] = "completed";
702
721
  ResearchStatus2["failed"] = "failed";
703
722
  return ResearchStatus2;