> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sidenet.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# General

> Initialize, destroy, and control sidebar visibility.

## Lifecycle

| Function               | Description                                        |
| ---------------------- | -------------------------------------------------- |
| `initSidenet(options)` | Initialize the sidebar (async, call once)          |
| `destroySidenet()`     | Remove sidebar completely (async, returns Promise) |

## Visibility

| Function                    | Description                                           |
| --------------------------- | ----------------------------------------------------- |
| `toggleSidenet()`           | Toggle sidebar visibility                             |
| `openSidenet()`             | Open the sidebar                                      |
| `closeSidenet()`            | Close the sidebar                                     |
| `getSidenetState()`         | Returns `{ isOpen: boolean, isInitialized: boolean }` |
| `triggerKeyboardShortcut()` | Programmatically trigger the shortcut action          |

## Send Message Programmatically

| Function                      | Description                             |
| ----------------------------- | --------------------------------------- |
| `sendMessage(text, options?)` | Send a message programmatically (async) |

```typescript theme={null}
await sendMessage('Analyze this code', {
  agentVersionId: 'agent-123',          // Optional: use specific agent
  openSidebar: true,                    // Optional: auto-open sidebar (default: true)
  prompt: 'Respond as a senior staff engineer.', // Optional: one-shot system prompt for this send only
});
```

### Options

| Field            | Type      | Description                                                                                                                                                                                                                  |
| ---------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `agentVersionId` | `string`  | Route this message to a specific agent version.                                                                                                                                                                              |
| `openSidebar`    | `boolean` | Auto-open the sidebar before sending. Defaults to `true`.                                                                                                                                                                    |
| `prompt`         | `string`  | One-shot system prompt prepended to this single request only — same semantics as `text.suggestions[].prompt`. Cleared automatically after the message is sent, so follow-up messages revert to the agent's normal behaviour. |

<Note>
  `sendMessage()` always starts a **new thread** for the programmatic message — the active thread is reset before sending. Thread titles are auto-generated by the backend after streaming completes.
</Note>

## Get Agents

| **Function**                          | **Description**                   |
| :------------------------------------ | :-------------------------------- |
| `getAgents(copilotId, apiKey, orgId)` | Fetch available subagents (async) |

```javascript theme={null}
import { getAgents } from 'sidenetai-sdk';

// Same three values you pass to initSidenet — handy for building a
// custom picker before the sidebar is mounted.
const agents = await getAgents('copilot-456', 'sk_...', 'org-123');
```
