@meistrari/tela-sdk-js 2.4.2 → 2.4.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.cjs CHANGED
@@ -24,7 +24,7 @@ const z__default = /*#__PURE__*/_interopDefaultCompat(z);
24
24
  const z__namespace = /*#__PURE__*/_interopNamespaceCompat(z);
25
25
  const Emittery__default = /*#__PURE__*/_interopDefaultCompat(Emittery);
26
26
 
27
- const version = "2.4.2";
27
+ const version = "2.4.3";
28
28
 
29
29
  var __defProp$7 = Object.defineProperty;
30
30
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -1569,7 +1569,7 @@ class CanvasExecution extends Emittery__default {
1569
1569
  * @param outputSchema - Zod schema or object schema for validating/parsing output.
1570
1570
  * @param client - HTTP client instance for making API requests.
1571
1571
  */
1572
- constructor(variables, params = { async: false }, outputSchema, client) {
1572
+ constructor(variables, params = { async: false }, outputSchema, client, isTask = false) {
1573
1573
  super();
1574
1574
  __publicField$2(this, "_id");
1575
1575
  __publicField$2(this, "_status");
@@ -1579,16 +1579,19 @@ class CanvasExecution extends Emittery__default {
1579
1579
  __publicField$2(this, "_outputSchema");
1580
1580
  __publicField$2(this, "_skipResultValidation");
1581
1581
  __publicField$2(this, "_abortController");
1582
+ __publicField$2(this, "_isTask");
1582
1583
  __publicField$2(this, "_resultPromise");
1583
1584
  __publicField$2(this, "_stream");
1584
1585
  __publicField$2(this, "_rawResultValue");
1585
1586
  __publicField$2(this, "_requestId");
1587
+ __publicField$2(this, "_task");
1586
1588
  this._variables = variables;
1587
1589
  this._params = params;
1588
1590
  this._outputSchema = outputSchema;
1589
1591
  this._skipResultValidation = params.skipResultValidation ?? false;
1590
1592
  this._client = client;
1591
1593
  this._abortController = new AbortController();
1594
+ this._isTask = isTask;
1592
1595
  }
1593
1596
  /**
1594
1597
  * Fetches an existing asynchronous execution by its ID.
@@ -1603,6 +1606,7 @@ class CanvasExecution extends Emittery__default {
1603
1606
  * @param options - Optional configuration for polling behavior.
1604
1607
  * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
1605
1608
  * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
1609
+ * @param options.isTask - Whether the execution is a task of a workstation.
1606
1610
  * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
1607
1611
  * @returns A promise resolving to a CanvasExecution instance with the fetched state.
1608
1612
  *
@@ -1636,7 +1640,8 @@ class CanvasExecution extends Emittery__default {
1636
1640
  // No variables needed for fetched execution
1637
1641
  params,
1638
1642
  outputSchema,
1639
- client
1643
+ client,
1644
+ options?.isTask
1640
1645
  );
1641
1646
  execution._id = response.id;
1642
1647
  execution.status = response.status;
@@ -1809,6 +1814,14 @@ class CanvasExecution extends Emittery__default {
1809
1814
  get isStream() {
1810
1815
  return Boolean(this._params.stream);
1811
1816
  }
1817
+ /**
1818
+ * Gets the task associated with this execution if it was created from an application.
1819
+ *
1820
+ * @returns The task creation result or undefined.
1821
+ */
1822
+ get task() {
1823
+ return this._task;
1824
+ }
1812
1825
  /**
1813
1826
  * Gets the raw API response without any processing or validation.
1814
1827
  * Automatically starts execution and waits for completion (including polling for async executions).
@@ -1852,7 +1865,6 @@ class CanvasExecution extends Emittery__default {
1852
1865
  async start() {
1853
1866
  if (this._params.applicationId && !this._params.async) {
1854
1867
  console.warn("[Tela SDK - WARNING] ApplicationId was provided, but async mode was not enabled. This will create a task, and tasks are always async. ");
1855
- console.warn("[Tela SDK - WARNING] Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.");
1856
1868
  console.warn("[Tela SDK - WARNING] To disable these warnings, you can enable async mode explicitly.");
1857
1869
  this._params.async = true;
1858
1870
  }
@@ -1874,10 +1886,6 @@ class CanvasExecution extends Emittery__default {
1874
1886
  * @returns The execution result as a promise or async generator.
1875
1887
  */
1876
1888
  get result() {
1877
- if (this._params.applicationId && !this._params.canvasId) {
1878
- const message = "Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.";
1879
- return Promise.reject(new InvalidExecutionModeError(message));
1880
- }
1881
1889
  if (this.isSync) {
1882
1890
  if (!this._resultPromise) {
1883
1891
  return Promise.reject(new ExecutionNotStartedError());
@@ -1952,9 +1960,6 @@ class CanvasExecution extends Emittery__default {
1952
1960
  * ```
1953
1961
  */
1954
1962
  poll() {
1955
- if (this._params.applicationId && !this._params.canvasId) {
1956
- throw new InvalidExecutionModeError("Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.");
1957
- }
1958
1963
  if (!this.isAsync) {
1959
1964
  throw new InvalidExecutionModeError("Polling is only supported for async executions");
1960
1965
  }
@@ -2084,13 +2089,16 @@ class CanvasExecution extends Emittery__default {
2084
2089
  async startAsync() {
2085
2090
  const resolvedVariables = await this.resolveVariables();
2086
2091
  return await this.create(resolvedVariables, { async: true }).then((response) => {
2087
- this._id = response.id;
2092
+ this._id = "completionRunId" in response ? response.completionRunId : response.id;
2088
2093
  this.status = response.status;
2094
+ if (this._isTask) {
2095
+ this._task = response;
2096
+ }
2089
2097
  this.emit("poll", {
2090
2098
  id: response.id,
2091
2099
  status: response.status,
2092
- outputContent: response.output_content,
2093
- rawOutput: response.raw_output,
2100
+ outputContent: response.outputContent,
2101
+ rawOutput: "rawOutput" in response ? response.rawOutput : void 0,
2094
2102
  requestId: response.requestId
2095
2103
  });
2096
2104
  return response;
@@ -2450,6 +2458,15 @@ class Canvas {
2450
2458
  get isWorkflow() {
2451
2459
  return this._isWorkflow;
2452
2460
  }
2461
+ /**
2462
+ * Gets whether this canvas is a workstation.
2463
+ * This is true if an application ID is provided.
2464
+ *
2465
+ * @returns True if the canvas is a workstation.
2466
+ */
2467
+ get isWorkstation() {
2468
+ return Boolean(this._applicationId);
2469
+ }
2453
2470
  /**
2454
2471
  * Validates and parses input variables using the canvas input schema.
2455
2472
  *
@@ -2477,7 +2494,7 @@ class Canvas {
2477
2494
  ...params ?? { async: false },
2478
2495
  ...idObject
2479
2496
  };
2480
- const execution = new CanvasExecution(parsedInput, fullParams, this._output, this._client);
2497
+ const execution = new CanvasExecution(parsedInput, fullParams, this._output, this._client, this.isWorkstation);
2481
2498
  return {
2482
2499
  then(onfulfilled, onrejected) {
2483
2500
  return Promise.resolve(execution.start()).then(() => onfulfilled?.(execution) ?? execution).catch(onrejected);
@@ -2521,7 +2538,10 @@ class Canvas {
2521
2538
  id,
2522
2539
  this._output,
2523
2540
  this._client,
2524
- options
2541
+ {
2542
+ ...options,
2543
+ isTask: this.isWorkstation
2544
+ }
2525
2545
  );
2526
2546
  }
2527
2547
  }
package/dist/index.d.cts CHANGED
@@ -553,7 +553,7 @@ type ExecutionStatus = 'succeeded' | 'failed' | 'running' | 'created' | 'streami
553
553
  type AsyncCompletionCreateResult = {
554
554
  id: string;
555
555
  status: ExecutionStatus;
556
- input_content: {
556
+ inputContent: {
557
557
  files: Array<any>;
558
558
  messages: Array<any>;
559
559
  variables: {
@@ -561,8 +561,8 @@ type AsyncCompletionCreateResult = {
561
561
  title: string;
562
562
  };
563
563
  };
564
- output_content: null;
565
- raw_input: {
564
+ outputContent: null;
565
+ rawInput: {
566
566
  async: boolean;
567
567
  canvas_id: string;
568
568
  variables: {
@@ -570,8 +570,8 @@ type AsyncCompletionCreateResult = {
570
570
  title: string;
571
571
  };
572
572
  };
573
- raw_output: any;
574
- compatibility_date: string;
573
+ rawOutput: any;
574
+ compatibilityDate: string;
575
575
  metadata: Array<{
576
576
  promptVersion: {
577
577
  modelConfigurations: {
@@ -607,13 +607,42 @@ type AsyncCompletionCreateResult = {
607
607
  };
608
608
  }>;
609
609
  credits_used: number;
610
- prompt_id: string;
611
- prompt_version_id: string;
612
- prompt_application_id: any;
613
- workspace_id: string;
614
- created_at: string;
615
- updated_at: string;
616
- deleted_at: any;
610
+ promptId: string;
611
+ promptVersionId: string;
612
+ promptApplicationId: string;
613
+ workspaceId: string;
614
+ createdAt: string;
615
+ updatedAt: string;
616
+ deletedAt: any;
617
+ };
618
+ type TaskCreationResult = {
619
+ id: string;
620
+ reference: number;
621
+ name: string;
622
+ status: ExecutionStatus;
623
+ rawInput: {
624
+ async: boolean;
625
+ stream: boolean;
626
+ variables: Record<string, unknown>;
627
+ applicationId: string;
628
+ };
629
+ inputContent: any;
630
+ outputContent: any;
631
+ originalOutputContent: any;
632
+ createdBy: string;
633
+ approvedBy: any;
634
+ approvedAt: any;
635
+ completionRunId: string;
636
+ workflowRunId: any;
637
+ promptVersionId: string;
638
+ promptApplicationId: string;
639
+ workspaceId: string;
640
+ metadata: any;
641
+ tags: Array<string>;
642
+ createdAt: string;
643
+ updatedAt: string;
644
+ deletedAt: any;
645
+ requestId: string;
617
646
  };
618
647
  /**
619
648
  * Raw API response type. Represents the unprocessed response from the Tela API.
@@ -750,10 +779,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
750
779
  private readonly _outputSchema;
751
780
  private readonly _skipResultValidation;
752
781
  private readonly _abortController;
782
+ private readonly _isTask;
753
783
  private _resultPromise;
754
784
  private _stream;
755
785
  private _rawResultValue;
756
786
  private _requestId;
787
+ private _task;
757
788
  /**
758
789
  * Creates a new canvas execution instance.
759
790
  *
@@ -762,7 +793,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
762
793
  * @param outputSchema - Zod schema or object schema for validating/parsing output.
763
794
  * @param client - HTTP client instance for making API requests.
764
795
  */
765
- constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient);
796
+ constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, isTask?: boolean);
766
797
  /**
767
798
  * Fetches an existing asynchronous execution by its ID.
768
799
  *
@@ -776,6 +807,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
776
807
  * @param options - Optional configuration for polling behavior.
777
808
  * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
778
809
  * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
810
+ * @param options.isTask - Whether the execution is a task of a workstation.
779
811
  * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
780
812
  * @returns A promise resolving to a CanvasExecution instance with the fetched state.
781
813
  *
@@ -793,6 +825,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
793
825
  static fetch<TOutput = unknown>(id: string, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, options?: {
794
826
  pollingInterval?: number;
795
827
  pollingTimeout?: number;
828
+ isTask?: boolean;
796
829
  }): Promise<CanvasExecution<AsyncExecutionParams, unknown, TOutput>>;
797
830
  /**
798
831
  * Gets the unique execution ID assigned by the server.
@@ -909,6 +942,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
909
942
  * @returns True if stream mode is enabled.
910
943
  */
911
944
  get isStream(): boolean;
945
+ /**
946
+ * Gets the task associated with this execution if it was created from an application.
947
+ *
948
+ * @returns The task creation result or undefined.
949
+ */
950
+ get task(): TaskCreationResult | undefined;
912
951
  /**
913
952
  * Gets the raw API response without any processing or validation.
914
953
  * Automatically starts execution and waits for completion (including polling for async executions).
@@ -933,7 +972,11 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
933
972
  *
934
973
  * @returns A promise or async generator depending on execution mode.
935
974
  */
936
- start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | WithRequestId<AsyncCompletionCreateResult>>;
975
+ start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | (AsyncCompletionCreateResult & {
976
+ requestId?: string;
977
+ }) | (TaskCreationResult & {
978
+ requestId?: string;
979
+ })>;
937
980
  /**
938
981
  * Gets the execution result. For async executions, automatically starts polling.
939
982
  * For sync executions, returns the result promise. For streams, returns the generator.
@@ -1534,6 +1577,13 @@ declare class Canvas<TInput extends ZodTypeOrRecord, TOutput extends ZodTypeOrRe
1534
1577
  * @returns True if the canvas is a workflow.
1535
1578
  */
1536
1579
  get isWorkflow(): boolean;
1580
+ /**
1581
+ * Gets whether this canvas is a workstation.
1582
+ * This is true if an application ID is provided.
1583
+ *
1584
+ * @returns True if the canvas is a workstation.
1585
+ */
1586
+ get isWorkstation(): boolean;
1537
1587
  /**
1538
1588
  * Validates and parses input variables using the canvas input schema.
1539
1589
  *
package/dist/index.d.mts CHANGED
@@ -553,7 +553,7 @@ type ExecutionStatus = 'succeeded' | 'failed' | 'running' | 'created' | 'streami
553
553
  type AsyncCompletionCreateResult = {
554
554
  id: string;
555
555
  status: ExecutionStatus;
556
- input_content: {
556
+ inputContent: {
557
557
  files: Array<any>;
558
558
  messages: Array<any>;
559
559
  variables: {
@@ -561,8 +561,8 @@ type AsyncCompletionCreateResult = {
561
561
  title: string;
562
562
  };
563
563
  };
564
- output_content: null;
565
- raw_input: {
564
+ outputContent: null;
565
+ rawInput: {
566
566
  async: boolean;
567
567
  canvas_id: string;
568
568
  variables: {
@@ -570,8 +570,8 @@ type AsyncCompletionCreateResult = {
570
570
  title: string;
571
571
  };
572
572
  };
573
- raw_output: any;
574
- compatibility_date: string;
573
+ rawOutput: any;
574
+ compatibilityDate: string;
575
575
  metadata: Array<{
576
576
  promptVersion: {
577
577
  modelConfigurations: {
@@ -607,13 +607,42 @@ type AsyncCompletionCreateResult = {
607
607
  };
608
608
  }>;
609
609
  credits_used: number;
610
- prompt_id: string;
611
- prompt_version_id: string;
612
- prompt_application_id: any;
613
- workspace_id: string;
614
- created_at: string;
615
- updated_at: string;
616
- deleted_at: any;
610
+ promptId: string;
611
+ promptVersionId: string;
612
+ promptApplicationId: string;
613
+ workspaceId: string;
614
+ createdAt: string;
615
+ updatedAt: string;
616
+ deletedAt: any;
617
+ };
618
+ type TaskCreationResult = {
619
+ id: string;
620
+ reference: number;
621
+ name: string;
622
+ status: ExecutionStatus;
623
+ rawInput: {
624
+ async: boolean;
625
+ stream: boolean;
626
+ variables: Record<string, unknown>;
627
+ applicationId: string;
628
+ };
629
+ inputContent: any;
630
+ outputContent: any;
631
+ originalOutputContent: any;
632
+ createdBy: string;
633
+ approvedBy: any;
634
+ approvedAt: any;
635
+ completionRunId: string;
636
+ workflowRunId: any;
637
+ promptVersionId: string;
638
+ promptApplicationId: string;
639
+ workspaceId: string;
640
+ metadata: any;
641
+ tags: Array<string>;
642
+ createdAt: string;
643
+ updatedAt: string;
644
+ deletedAt: any;
645
+ requestId: string;
617
646
  };
618
647
  /**
619
648
  * Raw API response type. Represents the unprocessed response from the Tela API.
@@ -750,10 +779,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
750
779
  private readonly _outputSchema;
751
780
  private readonly _skipResultValidation;
752
781
  private readonly _abortController;
782
+ private readonly _isTask;
753
783
  private _resultPromise;
754
784
  private _stream;
755
785
  private _rawResultValue;
756
786
  private _requestId;
787
+ private _task;
757
788
  /**
758
789
  * Creates a new canvas execution instance.
759
790
  *
@@ -762,7 +793,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
762
793
  * @param outputSchema - Zod schema or object schema for validating/parsing output.
763
794
  * @param client - HTTP client instance for making API requests.
764
795
  */
765
- constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient);
796
+ constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, isTask?: boolean);
766
797
  /**
767
798
  * Fetches an existing asynchronous execution by its ID.
768
799
  *
@@ -776,6 +807,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
776
807
  * @param options - Optional configuration for polling behavior.
777
808
  * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
778
809
  * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
810
+ * @param options.isTask - Whether the execution is a task of a workstation.
779
811
  * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
780
812
  * @returns A promise resolving to a CanvasExecution instance with the fetched state.
781
813
  *
@@ -793,6 +825,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
793
825
  static fetch<TOutput = unknown>(id: string, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, options?: {
794
826
  pollingInterval?: number;
795
827
  pollingTimeout?: number;
828
+ isTask?: boolean;
796
829
  }): Promise<CanvasExecution<AsyncExecutionParams, unknown, TOutput>>;
797
830
  /**
798
831
  * Gets the unique execution ID assigned by the server.
@@ -909,6 +942,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
909
942
  * @returns True if stream mode is enabled.
910
943
  */
911
944
  get isStream(): boolean;
945
+ /**
946
+ * Gets the task associated with this execution if it was created from an application.
947
+ *
948
+ * @returns The task creation result or undefined.
949
+ */
950
+ get task(): TaskCreationResult | undefined;
912
951
  /**
913
952
  * Gets the raw API response without any processing or validation.
914
953
  * Automatically starts execution and waits for completion (including polling for async executions).
@@ -933,7 +972,11 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
933
972
  *
934
973
  * @returns A promise or async generator depending on execution mode.
935
974
  */
936
- start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | WithRequestId<AsyncCompletionCreateResult>>;
975
+ start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | (AsyncCompletionCreateResult & {
976
+ requestId?: string;
977
+ }) | (TaskCreationResult & {
978
+ requestId?: string;
979
+ })>;
937
980
  /**
938
981
  * Gets the execution result. For async executions, automatically starts polling.
939
982
  * For sync executions, returns the result promise. For streams, returns the generator.
@@ -1534,6 +1577,13 @@ declare class Canvas<TInput extends ZodTypeOrRecord, TOutput extends ZodTypeOrRe
1534
1577
  * @returns True if the canvas is a workflow.
1535
1578
  */
1536
1579
  get isWorkflow(): boolean;
1580
+ /**
1581
+ * Gets whether this canvas is a workstation.
1582
+ * This is true if an application ID is provided.
1583
+ *
1584
+ * @returns True if the canvas is a workstation.
1585
+ */
1586
+ get isWorkstation(): boolean;
1537
1587
  /**
1538
1588
  * Validates and parses input variables using the canvas input schema.
1539
1589
  *
package/dist/index.d.ts CHANGED
@@ -553,7 +553,7 @@ type ExecutionStatus = 'succeeded' | 'failed' | 'running' | 'created' | 'streami
553
553
  type AsyncCompletionCreateResult = {
554
554
  id: string;
555
555
  status: ExecutionStatus;
556
- input_content: {
556
+ inputContent: {
557
557
  files: Array<any>;
558
558
  messages: Array<any>;
559
559
  variables: {
@@ -561,8 +561,8 @@ type AsyncCompletionCreateResult = {
561
561
  title: string;
562
562
  };
563
563
  };
564
- output_content: null;
565
- raw_input: {
564
+ outputContent: null;
565
+ rawInput: {
566
566
  async: boolean;
567
567
  canvas_id: string;
568
568
  variables: {
@@ -570,8 +570,8 @@ type AsyncCompletionCreateResult = {
570
570
  title: string;
571
571
  };
572
572
  };
573
- raw_output: any;
574
- compatibility_date: string;
573
+ rawOutput: any;
574
+ compatibilityDate: string;
575
575
  metadata: Array<{
576
576
  promptVersion: {
577
577
  modelConfigurations: {
@@ -607,13 +607,42 @@ type AsyncCompletionCreateResult = {
607
607
  };
608
608
  }>;
609
609
  credits_used: number;
610
- prompt_id: string;
611
- prompt_version_id: string;
612
- prompt_application_id: any;
613
- workspace_id: string;
614
- created_at: string;
615
- updated_at: string;
616
- deleted_at: any;
610
+ promptId: string;
611
+ promptVersionId: string;
612
+ promptApplicationId: string;
613
+ workspaceId: string;
614
+ createdAt: string;
615
+ updatedAt: string;
616
+ deletedAt: any;
617
+ };
618
+ type TaskCreationResult = {
619
+ id: string;
620
+ reference: number;
621
+ name: string;
622
+ status: ExecutionStatus;
623
+ rawInput: {
624
+ async: boolean;
625
+ stream: boolean;
626
+ variables: Record<string, unknown>;
627
+ applicationId: string;
628
+ };
629
+ inputContent: any;
630
+ outputContent: any;
631
+ originalOutputContent: any;
632
+ createdBy: string;
633
+ approvedBy: any;
634
+ approvedAt: any;
635
+ completionRunId: string;
636
+ workflowRunId: any;
637
+ promptVersionId: string;
638
+ promptApplicationId: string;
639
+ workspaceId: string;
640
+ metadata: any;
641
+ tags: Array<string>;
642
+ createdAt: string;
643
+ updatedAt: string;
644
+ deletedAt: any;
645
+ requestId: string;
617
646
  };
618
647
  /**
619
648
  * Raw API response type. Represents the unprocessed response from the Tela API.
@@ -750,10 +779,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
750
779
  private readonly _outputSchema;
751
780
  private readonly _skipResultValidation;
752
781
  private readonly _abortController;
782
+ private readonly _isTask;
753
783
  private _resultPromise;
754
784
  private _stream;
755
785
  private _rawResultValue;
756
786
  private _requestId;
787
+ private _task;
757
788
  /**
758
789
  * Creates a new canvas execution instance.
759
790
  *
@@ -762,7 +793,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
762
793
  * @param outputSchema - Zod schema or object schema for validating/parsing output.
763
794
  * @param client - HTTP client instance for making API requests.
764
795
  */
765
- constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient);
796
+ constructor(variables: TInput, params: TParams | undefined, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, isTask?: boolean);
766
797
  /**
767
798
  * Fetches an existing asynchronous execution by its ID.
768
799
  *
@@ -776,6 +807,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
776
807
  * @param options - Optional configuration for polling behavior.
777
808
  * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
778
809
  * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
810
+ * @param options.isTask - Whether the execution is a task of a workstation.
779
811
  * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
780
812
  * @returns A promise resolving to a CanvasExecution instance with the fetched state.
781
813
  *
@@ -793,6 +825,7 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
793
825
  static fetch<TOutput = unknown>(id: string, outputSchema: _zod__default.ZodType | Record<string, unknown>, client: BaseClient, options?: {
794
826
  pollingInterval?: number;
795
827
  pollingTimeout?: number;
828
+ isTask?: boolean;
796
829
  }): Promise<CanvasExecution<AsyncExecutionParams, unknown, TOutput>>;
797
830
  /**
798
831
  * Gets the unique execution ID assigned by the server.
@@ -909,6 +942,12 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
909
942
  * @returns True if stream mode is enabled.
910
943
  */
911
944
  get isStream(): boolean;
945
+ /**
946
+ * Gets the task associated with this execution if it was created from an application.
947
+ *
948
+ * @returns The task creation result or undefined.
949
+ */
950
+ get task(): TaskCreationResult | undefined;
912
951
  /**
913
952
  * Gets the raw API response without any processing or validation.
914
953
  * Automatically starts execution and waits for completion (including polling for async executions).
@@ -933,7 +972,11 @@ declare class CanvasExecution<TParams extends ExecutionParams = SyncExecutionPar
933
972
  *
934
973
  * @returns A promise or async generator depending on execution mode.
935
974
  */
936
- start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | WithRequestId<AsyncCompletionCreateResult>>;
975
+ start(): Promise<CanvasExecutionResult<TParams, TOutput> | AsyncGenerator<Partial<TOutput>, any, any> | (AsyncCompletionCreateResult & {
976
+ requestId?: string;
977
+ }) | (TaskCreationResult & {
978
+ requestId?: string;
979
+ })>;
937
980
  /**
938
981
  * Gets the execution result. For async executions, automatically starts polling.
939
982
  * For sync executions, returns the result promise. For streams, returns the generator.
@@ -1534,6 +1577,13 @@ declare class Canvas<TInput extends ZodTypeOrRecord, TOutput extends ZodTypeOrRe
1534
1577
  * @returns True if the canvas is a workflow.
1535
1578
  */
1536
1579
  get isWorkflow(): boolean;
1580
+ /**
1581
+ * Gets whether this canvas is a workstation.
1582
+ * This is true if an application ID is provided.
1583
+ *
1584
+ * @returns True if the canvas is a workstation.
1585
+ */
1586
+ get isWorkstation(): boolean;
1537
1587
  /**
1538
1588
  * Validates and parses input variables using the canvas input schema.
1539
1589
  *
package/dist/index.mjs CHANGED
@@ -4,7 +4,7 @@ import * as z from 'zod';
4
4
  import z__default, { z as z$1, ZodError } from 'zod';
5
5
  import Emittery from 'emittery';
6
6
 
7
- const version = "2.4.2";
7
+ const version = "2.4.3";
8
8
 
9
9
  var __defProp$7 = Object.defineProperty;
10
10
  var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -1549,7 +1549,7 @@ class CanvasExecution extends Emittery {
1549
1549
  * @param outputSchema - Zod schema or object schema for validating/parsing output.
1550
1550
  * @param client - HTTP client instance for making API requests.
1551
1551
  */
1552
- constructor(variables, params = { async: false }, outputSchema, client) {
1552
+ constructor(variables, params = { async: false }, outputSchema, client, isTask = false) {
1553
1553
  super();
1554
1554
  __publicField$2(this, "_id");
1555
1555
  __publicField$2(this, "_status");
@@ -1559,16 +1559,19 @@ class CanvasExecution extends Emittery {
1559
1559
  __publicField$2(this, "_outputSchema");
1560
1560
  __publicField$2(this, "_skipResultValidation");
1561
1561
  __publicField$2(this, "_abortController");
1562
+ __publicField$2(this, "_isTask");
1562
1563
  __publicField$2(this, "_resultPromise");
1563
1564
  __publicField$2(this, "_stream");
1564
1565
  __publicField$2(this, "_rawResultValue");
1565
1566
  __publicField$2(this, "_requestId");
1567
+ __publicField$2(this, "_task");
1566
1568
  this._variables = variables;
1567
1569
  this._params = params;
1568
1570
  this._outputSchema = outputSchema;
1569
1571
  this._skipResultValidation = params.skipResultValidation ?? false;
1570
1572
  this._client = client;
1571
1573
  this._abortController = new AbortController();
1574
+ this._isTask = isTask;
1572
1575
  }
1573
1576
  /**
1574
1577
  * Fetches an existing asynchronous execution by its ID.
@@ -1583,6 +1586,7 @@ class CanvasExecution extends Emittery {
1583
1586
  * @param options - Optional configuration for polling behavior.
1584
1587
  * @param options.pollingInterval - Time in milliseconds between polling attempts (default: 1000).
1585
1588
  * @param options.pollingTimeout - Maximum time in milliseconds to wait for completion (default: 60000).
1589
+ * @param options.isTask - Whether the execution is a task of a workstation.
1586
1590
  * @throws {InvalidExecutionModeError} If the provided ID is not a valid UUID.
1587
1591
  * @returns A promise resolving to a CanvasExecution instance with the fetched state.
1588
1592
  *
@@ -1616,7 +1620,8 @@ class CanvasExecution extends Emittery {
1616
1620
  // No variables needed for fetched execution
1617
1621
  params,
1618
1622
  outputSchema,
1619
- client
1623
+ client,
1624
+ options?.isTask
1620
1625
  );
1621
1626
  execution._id = response.id;
1622
1627
  execution.status = response.status;
@@ -1789,6 +1794,14 @@ class CanvasExecution extends Emittery {
1789
1794
  get isStream() {
1790
1795
  return Boolean(this._params.stream);
1791
1796
  }
1797
+ /**
1798
+ * Gets the task associated with this execution if it was created from an application.
1799
+ *
1800
+ * @returns The task creation result or undefined.
1801
+ */
1802
+ get task() {
1803
+ return this._task;
1804
+ }
1792
1805
  /**
1793
1806
  * Gets the raw API response without any processing or validation.
1794
1807
  * Automatically starts execution and waits for completion (including polling for async executions).
@@ -1832,7 +1845,6 @@ class CanvasExecution extends Emittery {
1832
1845
  async start() {
1833
1846
  if (this._params.applicationId && !this._params.async) {
1834
1847
  console.warn("[Tela SDK - WARNING] ApplicationId was provided, but async mode was not enabled. This will create a task, and tasks are always async. ");
1835
- console.warn("[Tela SDK - WARNING] Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.");
1836
1848
  console.warn("[Tela SDK - WARNING] To disable these warnings, you can enable async mode explicitly.");
1837
1849
  this._params.async = true;
1838
1850
  }
@@ -1854,10 +1866,6 @@ class CanvasExecution extends Emittery {
1854
1866
  * @returns The execution result as a promise or async generator.
1855
1867
  */
1856
1868
  get result() {
1857
- if (this._params.applicationId && !this._params.canvasId) {
1858
- const message = "Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.";
1859
- return Promise.reject(new InvalidExecutionModeError(message));
1860
- }
1861
1869
  if (this.isSync) {
1862
1870
  if (!this._resultPromise) {
1863
1871
  return Promise.reject(new ExecutionNotStartedError());
@@ -1932,9 +1940,6 @@ class CanvasExecution extends Emittery {
1932
1940
  * ```
1933
1941
  */
1934
1942
  poll() {
1935
- if (this._params.applicationId && !this._params.canvasId) {
1936
- throw new InvalidExecutionModeError("Tasks are not fully supported yet. You can create them, but cannot obtain the results or poll for their status.");
1937
- }
1938
1943
  if (!this.isAsync) {
1939
1944
  throw new InvalidExecutionModeError("Polling is only supported for async executions");
1940
1945
  }
@@ -2064,13 +2069,16 @@ class CanvasExecution extends Emittery {
2064
2069
  async startAsync() {
2065
2070
  const resolvedVariables = await this.resolveVariables();
2066
2071
  return await this.create(resolvedVariables, { async: true }).then((response) => {
2067
- this._id = response.id;
2072
+ this._id = "completionRunId" in response ? response.completionRunId : response.id;
2068
2073
  this.status = response.status;
2074
+ if (this._isTask) {
2075
+ this._task = response;
2076
+ }
2069
2077
  this.emit("poll", {
2070
2078
  id: response.id,
2071
2079
  status: response.status,
2072
- outputContent: response.output_content,
2073
- rawOutput: response.raw_output,
2080
+ outputContent: response.outputContent,
2081
+ rawOutput: "rawOutput" in response ? response.rawOutput : void 0,
2074
2082
  requestId: response.requestId
2075
2083
  });
2076
2084
  return response;
@@ -2430,6 +2438,15 @@ class Canvas {
2430
2438
  get isWorkflow() {
2431
2439
  return this._isWorkflow;
2432
2440
  }
2441
+ /**
2442
+ * Gets whether this canvas is a workstation.
2443
+ * This is true if an application ID is provided.
2444
+ *
2445
+ * @returns True if the canvas is a workstation.
2446
+ */
2447
+ get isWorkstation() {
2448
+ return Boolean(this._applicationId);
2449
+ }
2433
2450
  /**
2434
2451
  * Validates and parses input variables using the canvas input schema.
2435
2452
  *
@@ -2457,7 +2474,7 @@ class Canvas {
2457
2474
  ...params ?? { async: false },
2458
2475
  ...idObject
2459
2476
  };
2460
- const execution = new CanvasExecution(parsedInput, fullParams, this._output, this._client);
2477
+ const execution = new CanvasExecution(parsedInput, fullParams, this._output, this._client, this.isWorkstation);
2461
2478
  return {
2462
2479
  then(onfulfilled, onrejected) {
2463
2480
  return Promise.resolve(execution.start()).then(() => onfulfilled?.(execution) ?? execution).catch(onrejected);
@@ -2501,7 +2518,10 @@ class Canvas {
2501
2518
  id,
2502
2519
  this._output,
2503
2520
  this._client,
2504
- options
2521
+ {
2522
+ ...options,
2523
+ isTask: this.isWorkstation
2524
+ }
2505
2525
  );
2506
2526
  }
2507
2527
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/tela-sdk-js",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/meistrari/tela-sdk-js.git"