npm package: @haylee-ai/chat-sdk
Description: Haylee AI Chat SDK
Author: Von Uyvico
Latest version: 1.0.1

# Haylee AI Chat SDK

[![TypeScript](https://img.shields.io/badge/TypeScript-5.6-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
[![npm version](https://img.shields.io/npm/v/@haylee-ai/chat-sdk.svg)](https://www.npmjs.com/package/@haylee-ai/chat-sdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Node.js](https://img.shields.io/badge/Node.js-18+-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
[![ESM](https://img.shields.io/badge/ESM-✓-black?logo=javascript)](https://nodejs.org/api/esm.html)

## Getting Started

### Installation

```bash
npm install @haylee-ai/chat-sdk
# or
pnpm add @haylee-ai/chat-sdk
# or
yarn add @haylee-ai/chat-sdk
```

### Setup

Create a client with your API key. You can optionally specify a custom `baseUrl` (defaults to `http://localhost:3000/api/v1/chat`):

```typescript
import { HayleeAI } from "@haylee-ai/chat-sdk";

const client = new HayleeAI({
    baseUrl: "http://localhost:3000/api/v1/chat", // optional
});
```

### Basic Usage

Stream a message with optional conversation history:

```typescript
await client.messages.stream(
  {
    message: "What are my latest campaigns?",
    conversation_history: [
      { role: "human", content: "Hello" },
      { role: "ai", content: "Hi! How can I help with Meta Marketing?" },
    ],
  },
  {
    onLlmToken: (ev) => {
      const text = ev.content?.[0]?.text ?? "";
      if (text) process.stdout.write(text);
    },
    onSearchUpdate: (ev) => {
      console.log("Search:", ev.content?.query, ev.status);
    },
    onError: (err) => {
      console.error("Stream error:", err);
    },
    signal: abortController.signal, 
  }
);
```


<a name="readmemd"></a>

**@haylee-ai/chat-sdk v1.0.0**

***

# @haylee-ai/chat-sdk v1.0.0

## Enumerations

- [EventKind](#enumerationseventkindmd)
- [Role](#enumerationsrolemd)
- [ToolStatus](#enumerationstoolstatusmd)

## Classes

- [AuthenticationError](#classesauthenticationerrormd)
- [AuthorizationError](#classesauthorizationerrormd)
- [BaseEvent](#classesbaseeventmd)
- [CreateMessageDto](#classescreatemessagedtomd)
- [EndEvent](#classesendeventmd)
- [HayleeAI](#classeshayleeaimd)
- [HayleeAIClient](#classeshayleeaiclientmd)
- [HayleeAIError](#classeshayleeaierrormd)
- [IHistoryPayload](#classesihistorypayloadmd)
- [LlmTokenContent](#classesllmtokencontentmd)
- [LlmTokenEvent](#classesllmtokeneventmd)
- [MessageService](#classesmessageservicemd)
- [NotFoundError](#classesnotfounderrormd)
- [ValidationError](#classesvalidationerrormd)

## Interfaces

- [MessageServiceOptions](#interfacesmessageserviceoptionsmd)
- [ToolContent](#interfacestoolcontentmd)
- [ToolEvent](#interfacestooleventmd)
- [ToolResultContent](#interfacestoolresultcontentmd)

## Type Aliases

- [HayleeAIChatClientOptions](#type-aliaseshayleeaichatclientoptionsmd)


<a name="classesauthenticationerrormd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / AuthenticationError

# Class: AuthenticationError

Defined in: src/errors/authentication.error.ts:3

## Extends

- [`HayleeAIError`](#classeshayleeaierrormd)

## Constructors

### Constructor

> **new AuthenticationError**(`message`): `AuthenticationError`

Defined in: src/errors/authentication.error.ts:6

#### Parameters

##### message

`string`

#### Returns

`AuthenticationError`

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)

## Properties

### cause?

> `optional` **cause**: `unknown`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)

***

### message

> **message**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)

***

### name

> `readonly` **name**: `string` = `"AuthenticationError"`

Defined in: src/errors/authentication.error.ts:4

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)

***

### stack?

> `optional` **stack**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured _after_ the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`[]

#### Returns

`any`

#### See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)


<a name="classesauthorizationerrormd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / AuthorizationError

# Class: AuthorizationError

Defined in: src/errors/authorization.error.ts:3

## Extends

- [`HayleeAIError`](#classeshayleeaierrormd)

## Constructors

### Constructor

> **new AuthorizationError**(`message`): `AuthorizationError`

Defined in: src/errors/authorization.error.ts:6

#### Parameters

##### message

`string`

#### Returns

`AuthorizationError`

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)

## Properties

### cause?

> `optional` **cause**: `unknown`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)

***

### message

> **message**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)

***

### name

> `readonly` **name**: `string` = `"AuthorizationError"`

Defined in: src/errors/authorization.error.ts:4

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)

***

### stack?

> `optional` **stack**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured _after_ the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`[]

#### Returns

`any`

#### See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)


<a name="classesbaseeventmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / BaseEvent

# Class: BaseEvent

Defined in: src/messages/types.ts:12

Base event for Streaming
 BaseEvent

## Extended by

- [`LlmTokenEvent`](#classesllmtokeneventmd)
- [`ToolEvent`](#interfacestooleventmd)

## Constructors

### Constructor

> **new BaseEvent**(): `BaseEvent`

#### Returns

`BaseEvent`

## Properties

### kind

> **kind**: [`EventKind`](#enumerationseventkindmd)

Defined in: src/messages/types.ts:16

Used to separate streams

***

### node

> **node**: `string`

Defined in: src/messages/types.ts:20

Source node in langgraph


<a name="classescreatemessagedtomd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / CreateMessageDto

# Class: CreateMessageDto

Defined in: src/types/chat.interface.ts:8

DTO for creating a message

## Constructors

### Constructor

> **new CreateMessageDto**(): `CreateMessageDto`

#### Returns

`CreateMessageDto`

## Properties

### conversation\_history

> **conversation\_history**: [`IHistoryPayload`](#classesihistorypayloadmd)[]

Defined in: src/types/chat.interface.ts:13

Array of messages

***

### message

> **message**: `string`

Defined in: src/types/chat.interface.ts:11

User message


<a name="classesendeventmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / EndEvent

# Class: EndEvent

Defined in: src/messages/types.ts:49

## Constructors

### Constructor

> **new EndEvent**(): `EndEvent`

#### Returns

`EndEvent`

## Properties

### success

> **success**: `boolean`

Defined in: src/messages/types.ts:50


<a name="classeshayleeaimd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / HayleeAI

# Class: HayleeAI

Defined in: src/index.ts:7

Instantiate a new HayleeAI connection

## Extends

- [`HayleeAIClient`](#classeshayleeaiclientmd)

## Constructors

### Constructor

> **new HayleeAI**(`options`): `HayleeAI`

Defined in: src/index.ts:13

#### Parameters

##### options

[`HayleeAIChatClientOptions`](#type-aliaseshayleeaichatclientoptionsmd)

HayleeAIChatClientOptions

#### Returns

`HayleeAI`

#### Overrides

[`HayleeAIClient`](#classeshayleeaiclientmd).[`constructor`](#constructor)

## Properties

### messages

> **messages**: [`MessageService`](#classesmessageservicemd)

Defined in: src/index.ts:8

## Methods

### \_stream()

> **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>

Defined in: src/\_internal/client.ts:35

Internal stream callout

#### Parameters

##### payload

[`CreateMessageDto`](#classescreatemessagedtomd)

Message DTO

##### signal?

`AbortSignal`

Abort signal

#### Returns

`AsyncGenerator`\<`string`, `void`, `unknown`\>

#### Inherited from

[`HayleeAIClient`](#classeshayleeaiclientmd).[`_stream`](#_stream)


<a name="classeshayleeaiclientmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / HayleeAIClient

# Class: HayleeAIClient

Defined in: src/\_internal/client.ts:18

Internal HayleeAI Client. Do not use unless necessary.
 HayleeAIClient

## Extended by

- [`HayleeAI`](#classeshayleeaimd)

## Constructors

### Constructor

> **new HayleeAIClient**(`options`): `HayleeAIClient`

Defined in: src/\_internal/client.ts:26

#### Parameters

##### options

[`HayleeAIChatClientOptions`](#type-aliaseshayleeaichatclientoptionsmd)

Auth, and baseURL

#### Returns

`HayleeAIClient`

## Methods

### \_stream()

> **\_stream**(`payload`, `signal?`): `AsyncGenerator`\<`string`, `void`, `unknown`\>

Defined in: src/\_internal/client.ts:35

Internal stream callout

#### Parameters

##### payload

[`CreateMessageDto`](#classescreatemessagedtomd)

Message DTO

##### signal?

`AbortSignal`

Abort signal

#### Returns

`AsyncGenerator`\<`string`, `void`, `unknown`\>


<a name="classeshayleeaierrormd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / HayleeAIError

# Class: HayleeAIError

Defined in: src/errors/base.ts:1

## Extends

- `Error`

## Extended by

- [`ValidationError`](#classesvalidationerrormd)
- [`NotFoundError`](#classesnotfounderrormd)
- [`AuthorizationError`](#classesauthorizationerrormd)
- [`AuthenticationError`](#classesauthenticationerrormd)

## Constructors

### Constructor

> **new HayleeAIError**(`message`): `HayleeAIError`

Defined in: src/errors/base.ts:4

#### Parameters

##### message

`string`

#### Returns

`HayleeAIError`

#### Overrides

`Error.constructor`

## Properties

### cause?

> `optional` **cause**: `unknown`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

`Error.cause`

***

### message

> **message**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

`Error.message`

***

### name

> `readonly` **name**: `string` = `"HayleeAIError"`

Defined in: src/errors/base.ts:2

#### Overrides

`Error.name`

***

### stack?

> `optional` **stack**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

`Error.stack`

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured _after_ the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

`Error.stackTraceLimit`

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

`Error.captureStackTrace`

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`[]

#### Returns

`any`

#### See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

#### Inherited from

`Error.prepareStackTrace`


<a name="classesihistorypayloadmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / IHistoryPayload

# Class: IHistoryPayload

Defined in: src/types/chat.interface.ts:30

History payload

## Constructors

### Constructor

> **new IHistoryPayload**(): `IHistoryPayload`

#### Returns

`IHistoryPayload`

## Properties

### content

> **content**: `string`

Defined in: src/types/chat.interface.ts:34

Content of message

***

### role

> **role**: [`Role`](#enumerationsrolemd)

Defined in: src/types/chat.interface.ts:32

Role of message sender


<a name="classesllmtokencontentmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / LlmTokenContent

# Class: LlmTokenContent

Defined in: src/messages/types.ts:27

LLmTokenContent

## Constructors

### Constructor

> **new LlmTokenContent**(): `LlmTokenContent`

#### Returns

`LlmTokenContent`

## Properties

### text

> **text**: `string`

Defined in: src/messages/types.ts:35

***

### type

> **type**: `"text"`

Defined in: src/messages/types.ts:31


<a name="classesllmtokeneventmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / LlmTokenEvent

# Class: LlmTokenEvent

Defined in: src/messages/types.ts:38

Base event for Streaming
 BaseEvent

## Extends

- [`BaseEvent`](#classesbaseeventmd)

## Constructors

### Constructor

> **new LlmTokenEvent**(): `LlmTokenEvent`

#### Returns

`LlmTokenEvent`

#### Inherited from

[`BaseEvent`](#classesbaseeventmd).[`constructor`](#constructor)

## Properties

### content

> **content**: [`LlmTokenContent`](#classesllmtokencontentmd)[]

Defined in: src/messages/types.ts:42

***

### kind

> **kind**: [`EventKind`](#enumerationseventkindmd)

Defined in: src/messages/types.ts:16

Used to separate streams

#### Inherited from

[`BaseEvent`](#classesbaseeventmd).[`kind`](#kind)

***

### model

> **model**: `string`

Defined in: src/messages/types.ts:46

***

### node

> **node**: `string`

Defined in: src/messages/types.ts:20

#### Inherited from

[`BaseEvent`](#classesbaseeventmd).[`node`](#node)


<a name="classesmessageservicemd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / MessageService

# Class: MessageService

Defined in: src/messages/message.service.ts:44

## Constructors

### Constructor

> **new MessageService**(`client`): `MessageService`

Defined in: src/messages/message.service.ts:46

#### Parameters

##### client

[`HayleeAIClient`](#classeshayleeaiclientmd)

#### Returns

`MessageService`

## Methods

### stream()

> **stream**(`payload`, `options?`): `Promise`\<`void`\>

Defined in: src/messages/message.service.ts:52

#### Parameters

##### payload

[`CreateMessageDto`](#classescreatemessagedtomd)

The create message payload

##### options?

[`MessageServiceOptions`](#interfacesmessageserviceoptionsmd)

Config for streaming

#### Returns

`Promise`\<`void`\>


<a name="classesnotfounderrormd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / NotFoundError

# Class: NotFoundError

Defined in: src/errors/not-found.error.ts:3

## Extends

- [`HayleeAIError`](#classeshayleeaierrormd)

## Constructors

### Constructor

> **new NotFoundError**(`message`): `NotFoundError`

Defined in: src/errors/not-found.error.ts:6

#### Parameters

##### message

`string`

#### Returns

`NotFoundError`

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)

## Properties

### cause?

> `optional` **cause**: `unknown`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)

***

### message

> **message**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)

***

### name

> `readonly` **name**: `string` = `"NotFoundError"`

Defined in: src/errors/not-found.error.ts:4

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)

***

### stack?

> `optional` **stack**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured _after_ the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`[]

#### Returns

`any`

#### See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)


<a name="classesvalidationerrormd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / ValidationError

# Class: ValidationError

Defined in: src/errors/validation.error.ts:3

## Extends

- [`HayleeAIError`](#classeshayleeaierrormd)

## Constructors

### Constructor

> **new ValidationError**(`message`, `details?`): `ValidationError`

Defined in: src/errors/validation.error.ts:5

#### Parameters

##### message

`string`

##### details?

`any`

#### Returns

`ValidationError`

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`constructor`](#constructor)

## Properties

### cause?

> `optional` **cause**: `unknown`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:26

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`cause`](#cause)

***

### details?

> `optional` **details**: `any`

Defined in: src/errors/validation.error.ts:5

***

### message

> **message**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1077

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`message`](#message)

***

### name

> `readonly` **name**: `string` = `"ValidationError"`

Defined in: src/errors/validation.error.ts:4

#### Overrides

[`HayleeAIError`](#classeshayleeaierrormd).[`name`](#name)

***

### stack?

> `optional` **stack**: `string`

Defined in: node\_modules/.pnpm/typescript@5.9.3/node\_modules/typescript/lib/lib.es5.d.ts:1078

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stack`](#stack)

***

### stackTraceLimit

> `static` **stackTraceLimit**: `number`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:68

The `Error.stackTraceLimit` property specifies the number of stack frames
collected by a stack trace (whether generated by `new Error().stack` or
`Error.captureStackTrace(obj)`).

The default value is `10` but may be set to any valid JavaScript number. Changes
will affect any stack trace captured _after_ the value has been changed.

If set to a non-number value, or set to a negative number, stack traces will
not capture any frames.

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`stackTraceLimit`](#stacktracelimit)

## Methods

### captureStackTrace()

> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:52

Creates a `.stack` property on `targetObject`, which when accessed returns
a string representing the location in the code at which
`Error.captureStackTrace()` was called.

```js
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack;  // Similar to `new Error().stack`
```

The first line of the trace will be prefixed with
`${myObject.name}: ${myObject.message}`.

The optional `constructorOpt` argument accepts a function. If given, all frames
above `constructorOpt`, including `constructorOpt`, will be omitted from the
generated stack trace.

The `constructorOpt` argument is useful for hiding implementation
details of error generation from the user. For instance:

```js
function a() {
  b();
}

function b() {
  c();
}

function c() {
  // Create an error without stack trace to avoid calculating the stack trace twice.
  const { stackTraceLimit } = Error;
  Error.stackTraceLimit = 0;
  const error = new Error();
  Error.stackTraceLimit = stackTraceLimit;

  // Capture the stack trace above function b
  Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
  throw error;
}

a();
```

#### Parameters

##### targetObject

`object`

##### constructorOpt?

`Function`

#### Returns

`void`

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`captureStackTrace`](#capturestacktrace)

***

### prepareStackTrace()

> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`

Defined in: node\_modules/.pnpm/@types+node@22.19.7/node\_modules/@types/node/globals.d.ts:56

#### Parameters

##### err

`Error`

##### stackTraces

`CallSite`[]

#### Returns

`any`

#### See

https://v8.dev/docs/stack-trace-api#customizing-stack-traces

#### Inherited from

[`HayleeAIError`](#classeshayleeaierrormd).[`prepareStackTrace`](#preparestacktrace)


<a name="enumerationseventkindmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / EventKind

# Enumeration: EventKind

Defined in: src/messages/types.ts:1

## Enumeration Members

### LLM\_TOKEN

> **LLM\_TOKEN**: `"llm_token"`

Defined in: src/messages/types.ts:2

***

### TOOLS

> **TOOLS**: `"tools"`

Defined in: src/messages/types.ts:3


<a name="enumerationsrolemd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / Role

# Enumeration: Role

Defined in: src/types/chat.interface.ts:19

## Enumeration Members

### AI

> **AI**: `"ai"`

Defined in: src/types/chat.interface.ts:21

***

### HUMAN

> **HUMAN**: `"human"`

Defined in: src/types/chat.interface.ts:20


<a name="enumerationstoolstatusmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / ToolStatus

# Enumeration: ToolStatus

Defined in: src/messages/types.ts:61

## Enumeration Members

### END

> **END**: `"END"`

Defined in: src/messages/types.ts:63

***

### ERROR

> **ERROR**: `"ERROR"`

Defined in: src/messages/types.ts:64

***

### START

> **START**: `"START"`

Defined in: src/messages/types.ts:62


<a name="interfacesmessageserviceoptionsmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / MessageServiceOptions

# Interface: MessageServiceOptions

Defined in: src/messages/message.service.ts:12

## Properties

### signal?

> `optional` **signal**: `AbortSignal`

Defined in: src/messages/message.service.ts:41

AbortSignal for terminating the upstream stream

## Methods

### onEnd()?

> `optional` **onEnd**(`ev`): `void`

Defined in: src/messages/message.service.ts:22

triggers upon stream end

#### Parameters

##### ev

[`EndEvent`](#classesendeventmd)

EndEvent

#### Returns

`void`

***

### onError()?

> `optional` **onError**(`err`): `void`

Defined in: src/messages/message.service.ts:37

Streams errors on runtime

#### Parameters

##### err

`unknown`

#### Returns

`void`

***

### onLlmToken()?

> `optional` **onLlmToken**(`ev`): `void`

Defined in: src/messages/message.service.ts:17

Streams llm tokens for output

#### Parameters

##### ev

[`LlmTokenEvent`](#classesllmtokeneventmd)

#### Returns

`void`

***

### onToolEnd()?

> `optional` **onToolEnd**(`ev`): `void`

Defined in: src/messages/message.service.ts:32

Streams tool end updates

#### Parameters

##### ev

[`ToolEvent`](#interfacestooleventmd)

ToolEvent

#### Returns

`void`

***

### onToolStart()?

> `optional` **onToolStart**(`ev`): `void`

Defined in: src/messages/message.service.ts:27

Streams tool start updates

#### Parameters

##### ev

[`ToolEvent`](#interfacestooleventmd)

ToolEvent

#### Returns

`void`


<a name="interfacestoolcontentmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / ToolContent

# Interface: ToolContent

Defined in: src/messages/types.ts:67

## Properties

### params

> **params**: `unknown`

Defined in: src/messages/types.ts:68


<a name="interfacestooleventmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / ToolEvent

# Interface: ToolEvent

Defined in: src/messages/types.ts:53

Base event for Streaming
 BaseEvent

## Extends

- [`BaseEvent`](#classesbaseeventmd)

## Properties

### content?

> `optional` **content**: [`ToolContent`](#interfacestoolcontentmd)

Defined in: src/messages/types.ts:54

***

### kind

> **kind**: [`EventKind`](#enumerationseventkindmd)

Defined in: src/messages/types.ts:16

Used to separate streams

#### Inherited from

[`BaseEvent`](#classesbaseeventmd).[`kind`](#kind)

***

### name

> **name**: `string`

Defined in: src/messages/types.ts:55

***

### node

> **node**: `string`

Defined in: src/messages/types.ts:20

#### Inherited from

[`BaseEvent`](#classesbaseeventmd).[`node`](#node)

***

### results

> **results**: [`ToolResultContent`](#interfacestoolresultcontentmd)[]

Defined in: src/messages/types.ts:58

***

### status

> **status**: [`ToolStatus`](#enumerationstoolstatusmd)

Defined in: src/messages/types.ts:57

***

### tool\_call\_id?

> `optional` **tool\_call\_id**: `string`

Defined in: src/messages/types.ts:56


<a name="interfacestoolresultcontentmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / ToolResultContent

# Interface: ToolResultContent

Defined in: src/messages/types.ts:71

## Properties

### content

> **content**: `any`

Defined in: src/messages/types.ts:75

***

### type

> **type**: `string`

Defined in: src/messages/types.ts:73


<a name="type-aliaseshayleeaichatclientoptionsmd"></a>

[**@haylee-ai/chat-sdk v1.0.0**](#readmemd)

***

[@haylee-ai/chat-sdk](#readmemd) / HayleeAIChatClientOptions

# Type Alias: HayleeAIChatClientOptions

> **HayleeAIChatClientOptions** = `object`

Defined in: src/\_internal/client.ts:9

Options for the HayleeAI Client

## Properties

### baseUrl?

> `optional` **baseUrl**: `string`

Defined in: src/\_internal/client.ts:10

Optional base URL, defaults to production