@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.d.mts CHANGED
@@ -457,7 +457,7 @@ interface EffectsChangedEvent extends ToolsChangedEvent {
457
457
  }
458
458
  type EffectHandler = ToolHandler;
459
459
  type InstanceEffectHandler = InstanceToolHandler;
460
- type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
460
+ type JobStatus = 'queued' | 'running' | 'awaitingTool' | 'awaitingHuman' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
461
461
  type JobFeedbackSentiment = 'good' | 'bad';
462
462
  interface JobFeedbackToolCall {
463
463
  callId?: string;
@@ -529,8 +529,15 @@ interface Prompt {
529
529
  type: 'confirm' | 'choice' | 'input';
530
530
  title: string;
531
531
  message: string;
532
- options?: string[];
532
+ options?: Array<string | {
533
+ value: string;
534
+ label: string;
535
+ description?: string;
536
+ }>;
533
537
  defaultValue?: unknown;
538
+ placeholder?: string;
539
+ allowEmpty?: boolean;
540
+ metadata?: Record<string, unknown>;
534
541
  }
535
542
  type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
536
543
  interface SessionHeapFieldValue {
package/dist/index.d.ts CHANGED
@@ -457,7 +457,7 @@ interface EffectsChangedEvent extends ToolsChangedEvent {
457
457
  }
458
458
  type EffectHandler = ToolHandler;
459
459
  type InstanceEffectHandler = InstanceToolHandler;
460
- type JobStatus = 'queued' | 'running' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
460
+ type JobStatus = 'queued' | 'running' | 'awaitingTool' | 'awaitingHuman' | 'succeeded' | 'failed' | 'timeout' | 'canceled';
461
461
  type JobFeedbackSentiment = 'good' | 'bad';
462
462
  interface JobFeedbackToolCall {
463
463
  callId?: string;
@@ -529,8 +529,15 @@ interface Prompt {
529
529
  type: 'confirm' | 'choice' | 'input';
530
530
  title: string;
531
531
  message: string;
532
- options?: string[];
532
+ options?: Array<string | {
533
+ value: string;
534
+ label: string;
535
+ description?: string;
536
+ }>;
533
537
  defaultValue?: unknown;
538
+ placeholder?: string;
539
+ allowEmpty?: boolean;
540
+ metadata?: Record<string, unknown>;
534
541
  }
535
542
  type SessionHeapFieldType = 'string' | 'number' | 'boolean' | 'null' | 'unknown';
536
543
  interface SessionHeapFieldValue {
package/dist/index.js CHANGED
@@ -4650,7 +4650,7 @@ var Session = class {
4650
4650
  * Respond to a prompt request from the sandbox
4651
4651
  */
4652
4652
  async answerPrompt(promptId, answer) {
4653
- await this.client.call("prompt.answer", { promptId, value: answer });
4653
+ await this.client.call("prompt.answer", { promptId, answer, value: answer });
4654
4654
  }
4655
4655
  /**
4656
4656
  * Get the current list of available effects.
@@ -4967,13 +4967,31 @@ import { ${allImports} } from "./sandbox-tools";
4967
4967
  });
4968
4968
  }
4969
4969
  setupEventHandlers() {
4970
+ this.client.on("open", (payload) => this.emit("open", payload || {}));
4970
4971
  this.client.on("sync", (doc) => {
4971
4972
  this.currentDomainRevision = this.extractDomainRevisionFromDoc(doc);
4972
4973
  this.emit("sync", doc);
4973
4974
  this.checkForToolChanges();
4974
4975
  });
4975
- this.client.on("prompt", (prompt) => this.emit("prompt", prompt));
4976
+ const emitPrompt = (payload) => {
4977
+ const raw = payload;
4978
+ const prompt = raw.prompt || {
4979
+ id: typeof raw.id === "string" ? raw.id : String(raw.promptId || ""),
4980
+ type: raw.type === "confirm" || raw.type === "choice" || raw.type === "input" ? raw.type : raw.promptType === "confirm" || raw.promptType === "choice" ? raw.promptType : "input",
4981
+ title: typeof raw.title === "string" ? raw.title : "Input required",
4982
+ message: typeof raw.message === "string" ? raw.message : "",
4983
+ options: raw.options,
4984
+ defaultValue: raw.defaultValue,
4985
+ placeholder: raw.placeholder,
4986
+ allowEmpty: raw.allowEmpty,
4987
+ metadata: raw.metadata
4988
+ };
4989
+ this.emit("prompt", prompt);
4990
+ };
4991
+ this.client.on("prompt", emitPrompt);
4992
+ this.client.on("prompt.request", emitPrompt);
4976
4993
  this.client.on("disconnect", (payload) => this.emit("disconnect", payload || {}));
4994
+ this.client.on("reconnect_error", (payload) => this.emit("reconnect_error", payload || {}));
4977
4995
  this.client.on("job.status", (data) => {
4978
4996
  this.emit("job:status", data);
4979
4997
  });
@@ -5045,6 +5063,8 @@ function normalizeJobStatus(status) {
5045
5063
  case "failed":
5046
5064
  case "running":
5047
5065
  case "queued":
5066
+ case "awaitingTool":
5067
+ case "awaitingHuman":
5048
5068
  case "succeeded":
5049
5069
  case "timeout":
5050
5070
  case "canceled":
@@ -5179,6 +5199,19 @@ var JobImplementation = class {
5179
5199
  this.client.on(`job.${id}.error`, (error) => {
5180
5200
  this.finalize("failed", void 0, error);
5181
5201
  });
5202
+ this.client.on("job.status", (data) => {
5203
+ const jobData = data;
5204
+ if (jobData.jobId !== id) {
5205
+ return;
5206
+ }
5207
+ const normalizedStatus = normalizeJobStatus(jobData.status);
5208
+ this.status = normalizedStatus;
5209
+ this.metadata.status = normalizedStatus;
5210
+ if (normalizedStatus === "running") {
5211
+ this.markStarted();
5212
+ }
5213
+ this.emit("status", normalizedStatus);
5214
+ });
5182
5215
  this.client.on("job.completed", (data) => {
5183
5216
  const jobData = data;
5184
5217
  if (jobData.jobId === id) {