feat: [AI-6949] add session transcript REST endpoint for datamates extension

Merged
AL
5mo ago
+223-0

Summary

  • Adds GET /session/:sessionID/transcript REST endpoint to altimate-code server
  • Returns the session conversation as a formatted markdown transcript (text/plain; charset=utf-8)
  • Reuses formatTranscript from cli/cmd/tui/util/transcript.ts (same function powering the TUI /export command)
  • Supports optional query params: thinking (bool), toolDetails (bool), assistantMetadata (bool) — all default false

Endpoint

GET /session/:sessionID/transcript[?thinking=true&toolDetails=true&assistantMetadata=true]

Response: text/plain; charset=utf-8 — markdown string starting with # <session title>

Example response:

# My session title

**Session ID:** ses_xxx
**Created:** 6/15/2026, 7:04:58 AM
**Updated:** 6/15/2026, 7:04:58 AM

---

Test plan

  • Created session via POST /session, called GET /session/:id/transcript
  • Response is 200 OK, Content-Type: text/plain; charset=UTF-8
  • Body starts with # (markdown session title)
  • Query params (thinking, toolDetails, assistantMetadata) accepted without error
  • Verify with a session that has messages (tool calls, reasoning) to confirm option flags work

Files changed

  • packages/opencode/src/server/routes/session.ts — added import + route handler

Requested by @saravmajestic via harness


Summary by cubic

Adds a new REST endpoint to export a session’s conversation as a markdown transcript for easy sharing and offline viewing. Implements Linear AI-6949.

  • New Features

    • Adds GET /session/:sessionID/transcript returning markdown (text/plain; charset=utf-8); reuses formatTranscript to match the TUI /export; supports thinking, toolDetails, and assistantMetadata flags (default false); includes tests for 200/404, empty sessions, and flag behavior.
  • Bug Fixes

    • Fixes boolean parsing for query flags using z.preprocess so ?thinking=false is respected; aligns import to @/cli/...; strengthens tests to assert reasoning is included/excluded.