|
1 | 1 | --- |
2 | 2 | title: Console |
3 | | -description: An AI SRE session holds one complete conversation between you and the agent, including messages, streaming responses, tool calls, and artifacts. This page covers creating and managing sessions, sending messages, previewing artifacts, context compaction, and team binding. |
4 | | -keywords: ["AI SRE", "session", "chat", "streaming response", "tool call", "Artifacts", "context compaction", "team binding"] |
| 3 | +description: An AI SRE session holds one complete conversation between you and the agent, including messages, streaming responses, tool calls, and artifacts. This page covers creating and managing sessions, sending messages, previewing artifacts, context compaction, team binding, and session data export. |
| 4 | +keywords: ["AI SRE", "session", "chat", "streaming response", "tool call", "Artifacts", "context compaction", "team binding", "export", "NDJSON"] |
5 | 5 | sidebarTitle: Console |
6 | 6 | --- |
7 | 7 |
|
@@ -193,6 +193,56 @@ Automatic linking between incidents / war rooms and teams is still evolving. You |
193 | 193 |
|
194 | 194 | For the rules governing team scope for resources (account scope vs. team scope, visibility, and edit permissions), see the "Scope" section on each resource page. |
195 | 195 |
|
| 196 | +## Session entry kind |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +Every session is created with an **entry kind** (`entry_kind`) that identifies which surface produced it. The value is persisted to the database and returned in the create response. |
| 201 | + |
| 202 | +| Value | Source | Notes | |
| 203 | +|---|---|---| |
| 204 | +| `web` | Console | Default; unknown or missing values are automatically normalized to `web` | |
| 205 | +| `im` | IM platform (Feishu / DingTalk / WeCom / Slack) | Set automatically by the IM path; enables **in-place switching** for the session (see below) | |
| 206 | +| `api` | External API call | For programmatic integration scenarios | |
| 207 | +| `automation` | Automated workflow | Sessions triggered by automation tasks | |
| 208 | + |
| 209 | +When calling `POST /safari/session/create`, you may include `entry_kind` in the request body (optional; defaults to `web`). The `entry_kind` cannot be changed after the session is created. |
| 210 | + |
| 211 | +<Note> |
| 212 | +Sessions with `entry_kind=im` support **in-place environment and team switching** — the IM `/env` and `/scope` commands can rebind the session to a different BYOC runner or team scope without discarding the conversation. Console sessions (`web`) have their environment and team fixed at creation time and do not support in-place switching. |
| 213 | +</Note> |
| 214 | + |
| 215 | +## Session data export |
| 216 | + |
| 217 | +--- |
| 218 | + |
| 219 | +`POST /safari/session/export` streams all events from a session as **NDJSON** (`application/x-ndjson`), one JSON object per line. This is intended for auditing, archiving, offline analysis, or feeding session data into external systems. |
| 220 | + |
| 221 | +### Request fields |
| 222 | + |
| 223 | +| Field | Type | Required | Description | |
| 224 | +|---|---|---|---| |
| 225 | +| `session_id` | string | Yes | ID of the session to export | |
| 226 | +| `include_subagents` | bool | No | When `true`, recursively includes the event streams of all subagent child sessions; defaults to `false` | |
| 227 | + |
| 228 | +### Response format |
| 229 | + |
| 230 | +The response `Content-Type` is `application/x-ndjson`. The **first line is always** a `session_meta` envelope containing the session's metadata; subsequent lines are session events. When `include_subagents=true`, each `subagent_dispatch` line is immediately followed by the complete event stream of the child session, which also begins with its own `session_meta` line. |
| 231 | + |
| 232 | +``` |
| 233 | +{"type":"session_meta","session_id":"...","app_name":"..."} // first line: session metadata |
| 234 | +{"type":"message","..."} // subsequent: event lines (type varies) |
| 235 | +{"type":"subagent_dispatch","child_session_id":"..."} // subagent dispatch marker |
| 236 | +{"type":"session_meta","session_id":"<child>","..."} // child session metadata |
| 237 | +{"type":"message","..."} // child session events |
| 238 | +``` |
| 239 | + |
| 240 | +<Warning> |
| 241 | +If an error occurs after streaming has already begun, the server cannot switch to a standard JSON error envelope. Instead, a JSON-encoded error object is appended as the final line of the stream. Consumers must inspect this last line to determine whether the stream completed successfully. |
| 242 | +</Warning> |
| 243 | + |
| 244 | +**Permissions**: the export endpoint uses the same access gate as sending messages (`CanChatSession`), meaning the caller must have message-send permission on the session — read-only access is not sufficient. |
| 245 | + |
196 | 246 | ## Related Pages |
197 | 247 |
|
198 | 248 | --- |
|
0 commit comments