open-index/open-npm huggingface dataset:
npm package: @reminix/client
Description: Reminix client-side SDK for browser, React Native, and Expo
Author: Reminix Team
Latest version: 0.0.8

# @reminix/client

Client-side SDK for Reminix - works in browser, React Native, and Expo.

## Installation

```bash
npm install @reminix/client
```

## Usage

```typescript
import { ReminixClient } from '@reminix/client';

// Create a client with a token from your backend
const client = new ReminixClient({
  clientToken: 'your-client-token',
});

// Chat with an agent
const response = await client.chatAgent('my-agent', {
  messages: [{ role: 'user', content: 'Hello!' }],
});

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

## Streaming

Both `chatAgent` and `invokeAgent` support streaming responses:

```typescript
// Streaming chat
const stream = await client.chatAgent('my-agent', {
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.chunk);
}

// Streaming invoke
const invokeStream = await client.invokeAgent('my-agent', {
  input: { query: 'Generate a report' },
  stream: true,
});

for await (const chunk of invokeStream) {
  process.stdout.write(chunk.chunk);
}
```

## Getting a Client Token

Client tokens are created by your backend using the server-side SDK:

```typescript
// On your backend
import { Reminix } from '@reminix/sdk';

const reminix = new Reminix({ apiKey: process.env.REMINIX_API_KEY });

const { token } = await reminix.clientTokens.create({
  context: { userId: 'user_123' },
  ttlSeconds: 3600, // 1 hour
});

// Return this token to your frontend
```

## API

### `ReminixClient`

#### Constructor Options

- `clientToken` (required): The client token from your backend
- `baseUrl` (optional): Custom API URL (defaults to `https://api.reminix.com`)

#### Methods

- `chatAgent(agentName, request)`: Send a chat message to an agent
  - With `stream: false` (default): Returns `Promise<ClientChatResponse>`
  - With `stream: true`: Returns `Promise<AsyncGenerator<StreamChunk>>`

- `invokeAgent(agentName, request)`: Invoke an agent with custom input. Returns `output` and optional `execution: { id, url, type, status?, duration_ms? }`.
  - With `stream: false` (default): Returns `Promise<ClientExecuteAgentResponse>`
  - With `stream: true`: Returns `Promise<AsyncGenerator<StreamChunk>>`

- `callTool(toolName, request)`: Call a tool with input data. Returns `output` and optional `execution: { id, url, type, status?, duration_ms? }`.

- `getContext()`: Get the context associated with the client token

## License

Apache-2.0