@granular-software/sdk 0.4.11 → 0.4.12

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
@@ -4628,7 +4628,7 @@ var Session = class {
4628
4628
  * Respond to a prompt request from the sandbox
4629
4629
  */
4630
4630
  async answerPrompt(promptId, answer) {
4631
- await this.client.call("prompt.answer", { promptId, value: answer });
4631
+ await this.client.call("prompt.answer", { promptId, answer, value: answer });
4632
4632
  }
4633
4633
  /**
4634
4634
  * Get the current list of available effects.
@@ -4945,13 +4945,31 @@ import { ${allImports} } from "./sandbox-tools";
4945
4945
  });
4946
4946
  }
4947
4947
  setupEventHandlers() {
4948
+ this.client.on("open", (payload) => this.emit("open", payload || {}));
4948
4949
  this.client.on("sync", (doc) => {
4949
4950
  this.currentDomainRevision = this.extractDomainRevisionFromDoc(doc);
4950
4951
  this.emit("sync", doc);
4951
4952
  this.checkForToolChanges();
4952
4953
  });
4953
- this.client.on("prompt", (prompt) => this.emit("prompt", prompt));
4954
+ const emitPrompt = (payload) => {
4955
+ const raw = payload;
4956
+ const prompt = raw.prompt || {
4957
+ id: typeof raw.id === "string" ? raw.id : String(raw.promptId || ""),
4958
+ type: raw.type === "confirm" || raw.type === "choice" || raw.type === "input" ? raw.type : raw.promptType === "confirm" || raw.promptType === "choice" ? raw.promptType : "input",
4959
+ title: typeof raw.title === "string" ? raw.title : "Input required",
4960
+ message: typeof raw.message === "string" ? raw.message : "",
4961
+ options: raw.options,
4962
+ defaultValue: raw.defaultValue,
4963
+ placeholder: raw.placeholder,
4964
+ allowEmpty: raw.allowEmpty,
4965
+ metadata: raw.metadata
4966
+ };
4967
+ this.emit("prompt", prompt);
4968
+ };
4969
+ this.client.on("prompt", emitPrompt);
4970
+ this.client.on("prompt.request", emitPrompt);
4954
4971
  this.client.on("disconnect", (payload) => this.emit("disconnect", payload || {}));
4972
+ this.client.on("reconnect_error", (payload) => this.emit("reconnect_error", payload || {}));
4955
4973
  this.client.on("job.status", (data) => {
4956
4974
  this.emit("job:status", data);
4957
4975
  });
@@ -5023,6 +5041,8 @@ function normalizeJobStatus(status) {
5023
5041
  case "failed":
5024
5042
  case "running":
5025
5043
  case "queued":
5044
+ case "awaitingTool":
5045
+ case "awaitingHuman":
5026
5046
  case "succeeded":
5027
5047
  case "timeout":
5028
5048
  case "canceled":
@@ -5157,6 +5177,19 @@ var JobImplementation = class {
5157
5177
  this.client.on(`job.${id}.error`, (error) => {
5158
5178
  this.finalize("failed", void 0, error);
5159
5179
  });
5180
+ this.client.on("job.status", (data) => {
5181
+ const jobData = data;
5182
+ if (jobData.jobId !== id) {
5183
+ return;
5184
+ }
5185
+ const normalizedStatus = normalizeJobStatus(jobData.status);
5186
+ this.status = normalizedStatus;
5187
+ this.metadata.status = normalizedStatus;
5188
+ if (normalizedStatus === "running") {
5189
+ this.markStarted();
5190
+ }
5191
+ this.emit("status", normalizedStatus);
5192
+ });
5160
5193
  this.client.on("job.completed", (data) => {
5161
5194
  const jobData = data;
5162
5195
  if (jobData.jobId === id) {