# Tasks

## Get Task by ID

`client.tasks.retrieve(stringtaskID, TaskRetrieveParamsquery?, RequestOptionsoptions?): TaskRetrieveResponse`

**get** `/tasks/{task_id}`

Get a task by its unique ID.

### Parameters

- `taskID: string`

- `query: TaskRetrieveParams`

  - `relationships?: Array<"agents">`

    - `"agents"`

### Returns

- `TaskRetrieveResponse`

  Task response model with optional related data based on relationships

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.retrieve('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "agents": [
    {
      "id": "id",
      "acp_type": "sync",
      "created_at": "2019-12-27T18:11:19.117Z",
      "description": "description",
      "name": "name",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "agent_input_type": "text",
      "production_deployment_id": "production_deployment_id",
      "registered_at": "2019-12-27T18:11:19.117Z",
      "registration_metadata": {
        "foo": "bar"
      },
      "status": "Ready",
      "status_reason": "status_reason"
    }
  ],
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Delete Task by ID

`client.tasks.delete(stringtaskID, RequestOptionsoptions?): DeleteResponse`

**delete** `/tasks/{task_id}`

Delete a task by its unique ID.

### Parameters

- `taskID: string`

### Returns

- `DeleteResponse`

  - `id: string`

  - `message: string`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const deleteResponse = await client.tasks.delete('task_id');

console.log(deleteResponse.id);
```

#### Response

```json
{
  "id": "id",
  "message": "message"
}
```

## List Tasks

`client.tasks.list(TaskListParamsquery?, RequestOptionsoptions?): TaskListResponse`

**get** `/tasks`

List tasks. Returns a lean summary per task and omits `params`; fetch GET /tasks/{task_id} for the full record including `params`.

### Parameters

- `query: TaskListParams`

  - `agent_id?: string | null`

  - `agent_name?: string | null`

  - `limit?: number`

  - `order_by?: string | null`

  - `order_direction?: string`

  - `page_number?: number`

  - `relationships?: Array<"agents">`

    - `"agents"`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    Filter tasks by status (e.g. RUNNING, COMPLETED).

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `task_metadata?: string | null`

    JSON-encoded object used to filter tasks via JSONB containment. Example: {"created_by_user_id": "abc-123"}.

### Returns

- `TaskListResponse = Array<TaskListResponseItem>`

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const tasks = await client.tasks.list();

console.log(tasks);
```

#### Response

```json
[
  {
    "id": "id",
    "agents": [
      {
        "id": "id",
        "acp_type": "sync",
        "created_at": "2019-12-27T18:11:19.117Z",
        "description": "description",
        "name": "name",
        "updated_at": "2019-12-27T18:11:19.117Z",
        "agent_input_type": "text",
        "production_deployment_id": "production_deployment_id",
        "registered_at": "2019-12-27T18:11:19.117Z",
        "registration_metadata": {
          "foo": "bar"
        },
        "status": "Ready",
        "status_reason": "status_reason"
      }
    ],
    "cleaned_at": "2019-12-27T18:11:19.117Z",
    "created_at": "2019-12-27T18:11:19.117Z",
    "name": "name",
    "status": "CANCELED",
    "status_reason": "status_reason",
    "task_metadata": {
      "foo": "bar"
    },
    "updated_at": "2019-12-27T18:11:19.117Z"
  }
]
```

## Stream Task Events by ID

`client.tasks.streamEvents(stringtaskID, RequestOptionsoptions?): TaskStreamEventsResponse | Stream<TaskStreamEventsResponse>`

**get** `/tasks/{task_id}/stream`

Stream events for a task by its unique ID.

### Parameters

- `taskID: string`

### Returns

- `TaskStreamEventsResponse = unknown`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.tasks.streamEvents('task_id');

console.log(response);
```

#### Response

```json
{}
```

## Get Task by Name

`client.tasks.retrieveByName(stringtaskName, TaskRetrieveByNameParamsquery?, RequestOptionsoptions?): TaskRetrieveByNameResponse`

**get** `/tasks/name/{task_name}`

Get a task by its unique name.

### Parameters

- `taskName: string`

- `query: TaskRetrieveByNameParams`

  - `relationships?: Array<"agents">`

    - `"agents"`

### Returns

- `TaskRetrieveByNameResponse`

  Task response model with optional related data based on relationships

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.tasks.retrieveByName('task_name');

console.log(response.id);
```

#### Response

```json
{
  "id": "id",
  "agents": [
    {
      "id": "id",
      "acp_type": "sync",
      "created_at": "2019-12-27T18:11:19.117Z",
      "description": "description",
      "name": "name",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "agent_input_type": "text",
      "production_deployment_id": "production_deployment_id",
      "registered_at": "2019-12-27T18:11:19.117Z",
      "registration_metadata": {
        "foo": "bar"
      },
      "status": "Ready",
      "status_reason": "status_reason"
    }
  ],
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Delete Task by Name

`client.tasks.deleteByName(stringtaskName, RequestOptionsoptions?): DeleteResponse`

**delete** `/tasks/name/{task_name}`

Delete a task by its unique name.

### Parameters

- `taskName: string`

### Returns

- `DeleteResponse`

  - `id: string`

  - `message: string`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const deleteResponse = await client.tasks.deleteByName('task_name');

console.log(deleteResponse.id);
```

#### Response

```json
{
  "id": "id",
  "message": "message"
}
```

## Stream Task Events by Name

`client.tasks.streamEventsByName(stringtaskName, RequestOptionsoptions?): TaskStreamEventsByNameResponse | Stream<TaskStreamEventsByNameResponse>`

**get** `/tasks/name/{task_name}/stream`

Stream events for a task by its unique name.

### Parameters

- `taskName: string`

### Returns

- `TaskStreamEventsByNameResponse = unknown`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.tasks.streamEventsByName('task_name');

console.log(response);
```

#### Response

```json
{}
```

## Update Task by ID

`client.tasks.updateByID(stringtaskID, TaskUpdateByIDParamsbody, RequestOptionsoptions?): Task`

**put** `/tasks/{task_id}`

Update mutable fields for a task by its unique ID.

### Parameters

- `taskID: string`

- `body: TaskUpdateByIDParams`

  - `merge_params?: Record<string, unknown> | null`

  - `task_metadata?: Record<string, unknown> | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.updateByID('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Update Task by Name

`client.tasks.updateByName(stringtaskName, TaskUpdateByNameParamsbody, RequestOptionsoptions?): Task`

**put** `/tasks/name/{task_name}`

Update mutable fields for a task by its unique Name.

### Parameters

- `taskName: string`

- `body: TaskUpdateByNameParams`

  - `merge_params?: Record<string, unknown> | null`

  - `task_metadata?: Record<string, unknown> | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.updateByName('task_name');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Complete Task

`client.tasks.complete(stringtaskID, TaskCompleteParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/complete`

Mark a running task as completed.

### Parameters

- `taskID: string`

- `body: TaskCompleteParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.complete('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Fail Task

`client.tasks.fail(stringtaskID, TaskFailParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/fail`

Mark a running task as failed.

### Parameters

- `taskID: string`

- `body: TaskFailParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.fail('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Cancel Task

`client.tasks.cancel(stringtaskID, TaskCancelParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/cancel`

Mark a running task as canceled.

### Parameters

- `taskID: string`

- `body: TaskCancelParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.cancel('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Terminate Task

`client.tasks.terminate(stringtaskID, TaskTerminateParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/terminate`

Mark a running task as terminated.

### Parameters

- `taskID: string`

- `body: TaskTerminateParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.terminate('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Timeout Task

`client.tasks.timeout(stringtaskID, TaskTimeoutParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/timeout`

Mark a running task as timed out.

### Parameters

- `taskID: string`

- `body: TaskTimeoutParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.timeout('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Query Task Workflow

`client.tasks.queryWorkflow(stringqueryName, TaskQueryWorkflowParamsparams, RequestOptionsoptions?): TaskQueryWorkflowResponse`

**get** `/tasks/{task_id}/query/{query_name}`

Query a Temporal workflow associated with a task for its current state.

### Parameters

- `queryName: string`

- `params: TaskQueryWorkflowParams`

  - `task_id: string`

### Returns

- `TaskQueryWorkflowResponse = Record<string, unknown>`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const response = await client.tasks.queryWorkflow('query_name', { task_id: 'task_id' });

console.log(response);
```

#### Response

```json
{
  "foo": "bar"
}
```

## Interrupt Task

`client.tasks.interrupt(stringtaskID, TaskInterruptParamsbody?, RequestOptionsoptions?): Task`

**post** `/tasks/{task_id}/interrupt`

Stop the in-flight turn without terminating the task. Transitions a running task to the non-terminal INTERRUPTED status; the task stays continuable and the next message or event resumes it.

### Parameters

- `taskID: string`

- `body: TaskInterruptParams`

  - `reason?: string | null`

### Returns

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Example

```typescript
import Agentex from 'agentex';

const client = new Agentex({
  apiKey: process.env['AGENTEX_SDK_API_KEY'], // This is the default and can be omitted
});

const task = await client.tasks.interrupt('task_id');

console.log(task.id);
```

#### Response

```json
{
  "id": "id",
  "cleaned_at": "2019-12-27T18:11:19.117Z",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "params": {
    "foo": "bar"
  },
  "status": "CANCELED",
  "status_reason": "status_reason",
  "task_metadata": {
    "foo": "bar"
  },
  "updated_at": "2019-12-27T18:11:19.117Z"
}
```

## Domain Types

### Task

- `Task`

  - `id: string`

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Task Retrieve Response

- `TaskRetrieveResponse`

  Task response model with optional related data based on relationships

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Task List Response

- `TaskListResponse = Array<TaskListResponseItem>`

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Task Stream Events Response

- `TaskStreamEventsResponse = unknown`

### Task Retrieve By Name Response

- `TaskRetrieveByNameResponse`

  Task response model with optional related data based on relationships

  - `id: string`

  - `agents?: Array<Agent> | null`

    - `id: string`

      The unique identifier of the agent.

    - `acp_type: AcpType`

      The type of the ACP Server (Either sync or async)

      - `"sync"`

      - `"async"`

      - `"agentic"`

    - `created_at: string`

      The timestamp when the agent was created

    - `description: string`

      The description of the action.

    - `name: string`

      The unique name of the agent.

    - `updated_at: string`

      The timestamp when the agent was last updated

    - `agent_input_type?: "text" | "json" | null`

      The type of input the agent expects.

      - `"text"`

      - `"json"`

    - `production_deployment_id?: string | null`

      ID of the current production deployment.

    - `registered_at?: string | null`

      The timestamp when the agent was last registered

    - `registration_metadata?: Record<string, unknown> | null`

      The metadata for the agent's registration.

    - `status?: "Ready" | "Failed" | "Unknown" | 3 more`

      The status of the action, indicating if it's building, ready, failed, etc.

      - `"Ready"`

      - `"Failed"`

      - `"Unknown"`

      - `"Deleted"`

      - `"Unhealthy"`

      - `"BuildOnly"`

    - `status_reason?: string | null`

      The reason for the status of the action.

  - `cleaned_at?: string | null`

  - `created_at?: string | null`

  - `name?: string | null`

  - `params?: Record<string, unknown> | null`

  - `status?: "CANCELED" | "COMPLETED" | "FAILED" | 5 more | null`

    - `"CANCELED"`

    - `"COMPLETED"`

    - `"FAILED"`

    - `"RUNNING"`

    - `"INTERRUPTED"`

    - `"TERMINATED"`

    - `"TIMED_OUT"`

    - `"DELETED"`

  - `status_reason?: string | null`

  - `task_metadata?: Record<string, unknown> | null`

  - `updated_at?: string | null`

### Task Stream Events By Name Response

- `TaskStreamEventsByNameResponse = unknown`

### Task Query Workflow Response

- `TaskQueryWorkflowResponse = Record<string, unknown>`
