Skip to content

openagents_sdk::sessions

Computer sessions in the account's chat list (#11897).

A desktop or phone host publishes one summary row per session it runs: title, computer, project, status, last activity, and a short recap. The web and every app list them with the account's chats, marked source: "session" with their computer home. A row holds no transcript. The transcript is opt-in per chat or per project, off by default; while it is on, the host uploads a read-only copy.

ItemWhat it does
CopiedMessage structOne message of a session's read-only transcript copy.
CopiedRole enumWho wrote a message in a transcript copy.
PublishedSession structOne session a host publishes.
SessionDetail structOne session, and its transcript copy when it is shared with the caller.
SessionStatus enumWhat a session is doing.
SessionSummary structOne session row as the account lists it.
forget_computer fnRemove this computer's rows and transcript copies, as when it signs out.
get fnOne session, with its transcript copy when it is shared with the caller.
list fnThe account's session rows, newest first, or a shared project's rows.
pending_moves fnRequests from the web wait for this computer's normal handoff path.
publish fnPublish this computer's current sessions, replacing what it published before.
set_project_transcripts fnTurn the transcripts of every session in a project on or off.
set_transcript fnTurn one chat's transcript on or off on the web.
upload_transcript fnUpload a session's read-only transcript copy, replacing the last one.
MAX_PER_COMPUTER constThe most sessions one publish may carry.

CopiedMessage

pub struct CopiedMessage {
    pub role: CopiedRole,
    pub text: String,
}

One message of a session's read-only transcript copy.

CopiedRole

pub enum CopiedRole {
    User,
    Assistant,
    Tool,
}

Who wrote a message in a transcript copy.

PublishedSession

pub struct PublishedSession {
    pub id: String,
    pub home_transfer: bool,
    pub continues: Option<PartRef>,
    pub title: String,
    pub project: Option<String>,
    pub folder: Option<String>,
    pub status: SessionStatus,
    pub last_activity_unix: u64,
    pub recap: String,
    pub workspace: Option<String>,
    pub agent: Option<String>,
}

One session a host publishes. Text is bounded and screened by the service; never put transcript content in recap.

SessionDetail

pub struct SessionDetail {
    pub session: SessionSummary,
    pub messages: Option<Vec<CopiedMessage>>,
}

One session, and its transcript copy when it is shared with the caller.

SessionStatus

pub enum SessionStatus {
    Idle,
    Working,
    AwaitingInput,
    Errored,
    Other(String),
}

What a session is doing.

SessionStatus::as_str

pub fn as_str(&self) -> &str

The status as the service writes it.

SessionSummary

pub struct SessionSummary {
    pub id: String,
    pub home: Home,
    pub title: String,
    pub computer: String,
    pub project: Option<String>,
    pub folder: Option<String>,
    pub status: SessionStatus,
    pub last_activity_unix: u64,
    pub recap: String,
    pub online: bool,
    pub transcript: bool,
    pub app_link: Option<String>,
    pub continues: Option<PartRef>,
    pub continued_by: Option<PartRef>,
    pub home_transfer: bool,
    pub agent: Option<String>,
}

One session row as the account lists it.

forget_computer

pub async fn forget_computer(
    client: &Client,
    session: &Session,
    device: &str,
    cancel: &CancellationToken,
) -> Result<bool, Error>

Remove this computer's rows and transcript copies, as when it signs out.

Calls DELETE /v1/history/sessions/computers/{device}

get

pub async fn get(
    client: &Client,
    session: &Session,
    id: &str,
    cancel: &CancellationToken,
) -> Result<SessionDetail, Error>

One session, with its transcript copy when it is shared with the caller.

Calls GET /v1/history/sessions/{id}

list

pub async fn list(
    client: &Client,
    session: &Session,
    project: Option<&str>,
    cancel: &CancellationToken,
) -> Result<Vec<SessionSummary>, Error>

The account's session rows, newest first, or a shared project's rows.

Calls GET /v1/history/sessions

pending_moves

pub async fn pending_moves(
    client: &Client,
    session: &Session,
    device: &str,
    cancel: &CancellationToken,
) -> Result<Vec<MoveRequest>, Error>

Requests from the web wait for this computer's normal handoff path.

Calls GET /v1/history/sessions/computers/{device}/moves

publish

pub async fn publish(
    client: &Client,
    session: &Session,
    device: &str,
    name: &str,
    sessions: &[PublishedSession],
    cancel: &CancellationToken,
) -> Result<Vec<String>, Error>

Publish this computer's current sessions, replacing what it published before. Returns the ids whose transcript is on, which the host may upload with [upload_transcript]. Publishing also says the computer is online, so a host republishes about every 30 seconds.

Calls PUT /v1/history/sessions/computers/{device}

set_project_transcripts

pub async fn set_project_transcripts(
    client: &Client,
    session: &Session,
    project: &str,
    on: bool,
    cancel: &CancellationToken,
) -> Result<(), Error>

Turn the transcripts of every session in a project on or off.

Calls PUT /v1/history/sessions/projects/{project}/transcript

set_transcript

pub async fn set_transcript(
    client: &Client,
    session: &Session,
    id: &str,
    on: bool,
    cancel: &CancellationToken,
) -> Result<bool, Error>

Turn one chat's transcript on or off on the web. Returns whether it is now on, counting its project's choice. Off deletes the copy.

Calls PUT /v1/history/sessions/{id}/transcript

upload_transcript

pub async fn upload_transcript(
    client: &Client,
    session: &Session,
    id: &str,
    messages: &[CopiedMessage],
    cancel: &CancellationToken,
) -> Result<usize, Error>

Upload a session's read-only transcript copy, replacing the last one. Refused with transcript_off while its transcript is off.

Calls PUT /v1/history/sessions/{id}/messages

MAX_PER_COMPUTER

pub const MAX_PER_COMPUTER: usize = 200;

The most sessions one publish may carry.

Re-exported from other crates

  • Home from chat_home
  • MoveRequest from chat_home
  • PartRef from chat_home