Tela SDK for JavaScript
    Preparing search index...

    Represents a workstation (prompt application) in the Tela platform.

    A Workstation enables creating and managing tasks (async workflow executions) with input/output schema validation using Zod.

    // Get a workstation with schemas
    const workstation = await tela.workstation.get({
    applicationId: 'app-id',
    input: schema => schema.object({
    query: schema.string(),
    }),
    output: schema => schema.object({
    result: schema.string(),
    }),
    })

    // Create a task
    const task = await workstation.createTask({ query: 'test' })

    // Get the result
    const result = await task.result

    Type Parameters

    • TInput extends ZodTypeOrRecord

      Zod schema type for task input variables

    • TOutput extends ZodTypeOrRecord

      Zod schema type for task output results

    Index

    Constructors

    Accessors

    • get id(): string

      The unique identifier for this workstation (application ID).

      Returns string

    Methods

    • Creates a new task for this workstation and returns a promise-like object.

      The returned object can be awaited directly to get the Task instance, or you can access .result to get the final task output directly.

      Parameters

      • variables: input<TInput>

        Input variables for the task (must match the input schema)

      • params: TaskParams & { skipResultValidation?: boolean } = {}

        Optional task parameters (label, tags, skipResultValidation)

      Returns TaskPromiseLike<TInput, TOutput>

      A promise-like object that resolves to the Task instance

      // Get the task instance
      const task = await workstation.createTask({ query: 'test' })

      // Or get the result directly
      const result = await workstation.createTask({ query: 'test' }).result
    • Retrieves an existing task by its ID.

      This is useful for resuming monitoring of a task that was created earlier.

      Parameters

      • id: string

        The task ID to retrieve

      • options: { skipResultValidation?: boolean } = {}

        Optional configuration

        • OptionalskipResultValidation?: boolean

          Whether to skip output validation

      Returns Promise<Task<TInput, TOutput>>

      A promise that resolves to the Task instance

      const task = await workstation.getTask('task-id')

      // Set up event listeners
      task.on('statusChange', (status) => console.log('Status:', status))
      task.on('success', (result) => console.log('Result:', result))

      // Start polling
      task.poll()
    • Asynchronously iterates through all tasks matching the specified filters.

      This generator automatically handles pagination, fetching additional pages as needed. Each iteration yields a task and the current page metadata.

      Parameters

      • params: {
            filters?: {
                approvedAt?: { since?: string | Date; until?: string | Date };
                approvedBy?: string;
                completionRunId?: string;
                createdAt?: { since?: string | Date; until?: string | Date };
                createdBy?: string;
                id?: string[];
                name?: string;
                promptVersionId?: string;
                status?: (
                    | "created"
                    | "failed"
                    | "running"
                    | "validating"
                    | "completed"
                    | "cancelled"
                )[];
                updatedAt?: { since?: string
                | Date; until?: string | Date };
                [key: string]: unknown;
            };
            options?: {
                limit?: number;
                offset?: number;
                order?: {
                    by: | "name"
                    | "status"
                    | "reference"
                    | "approvedAt"
                    | "createdAt"
                    | "updatedAt";
                    direction: "asc"
                    | "desc";
                };
                [key: string]: unknown;
            };
        }

        Query parameters

        • Optionalfilters?: {
              approvedAt?: { since?: string | Date; until?: string | Date };
              approvedBy?: string;
              completionRunId?: string;
              createdAt?: { since?: string | Date; until?: string | Date };
              createdBy?: string;
              id?: string[];
              name?: string;
              promptVersionId?: string;
              status?: (
                  | "created"
                  | "failed"
                  | "running"
                  | "validating"
                  | "completed"
                  | "cancelled"
              )[];
              updatedAt?: { since?: string
              | Date; until?: string | Date };
              [key: string]: unknown;
          }

          Optional filters to apply (ID, name, status, dates, etc.)

        • Optionaloptions?: {
              limit?: number;
              offset?: number;
              order?: {
                  by:
                      | "name"
                      | "status"
                      | "reference"
                      | "approvedAt"
                      | "createdAt"
                      | "updatedAt";
                  direction: "asc"
                  | "desc";
              };
              [key: string]: unknown;
          }

          Optional initial pagination and sorting options

      Returns AsyncGenerator<readonly [Task<TInput, TOutput>, TaskListMeta], void, unknown>

      A tuple of [task, metadata] for each task

      // Iterate through all pending tasks
      for await (const [task, meta] of workstation.iterateTasks({
      filters: { status: ['pending'] },
      })) {
      console.log(`Task ${task.id}: ${task.status}`)
      console.log(`Page ${meta.currentPage} of ${meta.totalPages}`)
      }

      // Process tasks in batches
      for await (const [task, meta] of workstation.iterateTasks({
      options: { limit: 50 },
      })) {
      await processTask(task)
      }
    • Lists tasks for this workstation with optional filtering and pagination.

      Returns a page of tasks matching the specified filters, along with metadata for pagination.

      Parameters

      • params: {
            filters?: {
                approvedAt?: { since?: string | Date; until?: string | Date };
                approvedBy?: string;
                completionRunId?: string;
                createdAt?: { since?: string | Date; until?: string | Date };
                createdBy?: string;
                id?: string[];
                name?: string;
                promptVersionId?: string;
                status?: (
                    | "created"
                    | "failed"
                    | "running"
                    | "validating"
                    | "completed"
                    | "cancelled"
                )[];
                updatedAt?: { since?: string
                | Date; until?: string | Date };
                [key: string]: unknown;
            };
            options?: {
                limit?: number;
                offset?: number;
                order?: {
                    by: | "name"
                    | "status"
                    | "reference"
                    | "approvedAt"
                    | "createdAt"
                    | "updatedAt";
                    direction: "asc"
                    | "desc";
                };
                [key: string]: unknown;
            };
            rawQuery?: Record<string, any>;
        }

        Query parameters

        • Optionalfilters?: {
              approvedAt?: { since?: string | Date; until?: string | Date };
              approvedBy?: string;
              completionRunId?: string;
              createdAt?: { since?: string | Date; until?: string | Date };
              createdBy?: string;
              id?: string[];
              name?: string;
              promptVersionId?: string;
              status?: (
                  | "created"
                  | "failed"
                  | "running"
                  | "validating"
                  | "completed"
                  | "cancelled"
              )[];
              updatedAt?: { since?: string
              | Date; until?: string | Date };
              [key: string]: unknown;
          }

          Optional filters to apply (ID, name, status, dates, etc.)

        • Optionaloptions?: {
              limit?: number;
              offset?: number;
              order?: {
                  by:
                      | "name"
                      | "status"
                      | "reference"
                      | "approvedAt"
                      | "createdAt"
                      | "updatedAt";
                  direction: "asc"
                  | "desc";
              };
              [key: string]: unknown;
          }

          Optional pagination and sorting options

        • OptionalrawQuery?: Record<string, any>

          Raw query object (internal use, overrides filters/options)

      Returns Promise<{ meta: TaskListMeta; tasks: Task<TInput, TOutput>[] }>

      A promise that resolves to an object containing tasks and pagination metadata

      // Get first 10 completed tasks
      const { tasks, meta } = await workstation.listTasks({
      filters: { status: ['completed'] },
      options: { limit: 10, offset: 0 },
      })

      // Sort by creation date
      const { tasks, meta } = await workstation.listTasks({
      options: {
      order: { by: 'createdAt', direction: 'desc' },
      limit: 20,
      },
      })
    • Retrieves a workstation by application ID and optionally validates schemas.

      This is the recommended way to create a Workstation instance.

      Type Parameters

      • TInput extends ZodTypeOrRecord
      • TOutput extends ZodTypeOrRecord

      Parameters

      • options: Omit<WorkstationOptions<TInput, TOutput>, "promptVersion" | "client"> & {
            skipSchemaValidation?: boolean;
        } & { client: BaseClient }

        Configuration options

        • client

          The BaseClient instance for API communication

        • applicationId

          The unique ID of the workstation

        • input

          Optional input schema function

        • output

          Optional output schema function

        • skipSchemaValidation

          Whether to skip schema validation (defaults to false)

        • OptionalskipSchemaValidation?: boolean

          Whether to skip schema validation against the server configuration. Defaults to false.

        • client: BaseClient

          The BaseClient instance for API communication

      Returns Promise<Workstation<TInput, TOutput>>

      A promise that resolves to a Workstation instance

      If schema validation fails (when schemas are provided and skipSchemaValidation is false)

      const workstation = await Workstation.get({
      client,
      applicationId: 'app-123',
      input: schema => schema.object({
      query: schema.string(),
      }),
      output: schema => schema.object({
      answer: schema.string(),
      }),
      })