feat(relay): add @agent-relay/session SDK for cross-harness session continuity with full identity/attribution model

Merged
KH
4mo ago
+1676-3

Summary

  • add the new public @agent-relay/session workspace package
  • persist stable session identity, immutable ownership, the active actor, and the full steering audit trail through Relayhistory's existing ordered turns journal
  • select native continuation only for Claude-to-Claude sessions with a native resume ID; inject attributed journal context for cross-CLI and all non-Claude handoffs
  • provide best-effort turn capture, steering records, and Git commit attribution trailers
  • document the API and wire the package into root builds, typechecking, Vitest resolution, the lockfile, and the changelog

Why

Session continuity is a Relay platform concern. Keeping the SDK in this repository gives Workforce, ai-hist, OpenCode, Cursor, and other harness integrations one stable session and identity model instead of duplicating workforce-specific resume behavior.

Backend contract

The client uses RELAYHISTORY_URL and the existing Relayhistory endpoints:

  • POST /v1/sessions/:sessionId/turns
  • GET /v1/sessions/:sessionId/turns

Creation and steering are durable system turns carrying a complete RelaySession snapshot, so the conversation journal and identity audit trail remain one source of truth.

Validation

  • tsc -p packages/session/tsconfig.json
  • focused Vitest suite: 5/5 passed
  • built-package export smoke test
  • Prettier check
  • git diff --check
  • workspace discovery: npm ls @agent-relay/session --depth=0