Skip to main content

TcodeConnector

Struct TcodeConnector 

Source
pub struct TcodeConnector { /* private fields */ }
Expand description

tcode’s WorkstreamConnector implementation over the #2983 REST bridge (+ POST /rpc for attach).

Why/What: see module docs.

Implementations§

Source§

impl TcodeConnector

Source

pub fn new() -> Self

Build a connector targeting http://127.0.0.1:<DEFAULT_HTTP_PORT>.

Why: the common case for a caller that just wants “the local tcode daemon on its documented default port.” Unlike tm, tcode has no lock-file/gateway discovery chain yet (DOC-44 §7.1 lists that as a tcode operational prerequisite, out of scope here) — this is a fixed default, matching how the CLI itself defaults --port. What: delegates to Self::with_daemon_url with http://127.0.0.1:{DEFAULT_HTTP_PORT}. Test: exercised indirectly — every connector_e2e.rs test builds via Self::with_daemon_url instead (an ephemeral --port 0 instance), since asserting on this constructor’s exact URL would require either binding the real default port (risking a collision with a developer’s already-running tcode serve) or exposing daemon_url for inspection, which would leak an implementation detail no caller needs.

Source

pub fn with_daemon_url(daemon_url: impl Into<String>) -> Self

Build a connector targeting an explicit daemon URL.

Why: tests need to target a --port 0 ephemeral instance rather than the fixed default. What: stores daemon_url and a plain reqwest::Client.

Trait Implementations§

Source§

impl Default for TcodeConnector

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl WorkstreamConnector for TcodeConnector

Source§

fn create_session<'life0, 'async_trait>( &'life0 self, req: CreateSessionReq, ) -> Pin<Box<dyn Future<Output = Result<SessionInfo, ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

POST /sessions -> session.create (#2983 Slice 3).

Why: mints a new tcode session bound to an existing local project. req.backend must be BackendParams::Tcode — a BackendParams::Tm request is a caller bug (asked the tcode connector to provision a tm-shaped worktree session) and is rejected with ConnectorError::InvalidRequest before any HTTP call is made. What: req.name_hint has no tcode equivalent and is silently ignored (see CreateSessionReq’s docs); req.agent maps onto session.create’s agent param. A 400 (empty task, or project naming no real directory — see session::protocol::create’s AC-16.2 docs) maps to ConnectorError::InvalidRequest. Test: connector_e2e::create_session_full_lifecycle, connector_e2e::create_session_wrong_backend_params_is_invalid_request.

Source§

fn list_sessions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<SessionInfo>, ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

GET /sessions -> session.list (#2983 Slice 2).

Why: enumerates every session the daemon currently owns. What: unwraps the {"sessions": [...]} envelope and maps each Session onto a portable SessionInfo. Test: connector_e2e::list_sessions_empty_fleet_returns_empty_vec.

Source§

fn session_status<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<SessionStatus, ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

GET /sessions/{id} -> session.status (#2983 Slice 2).

Why: point lookup for one session’s current state. What: a 404 (unknown id, -32007 session_not_found) maps to ConnectorError::NotFound. pending_decision is always None — tcode has no equivalent concept in this phase (tm’s managed-session pending-decision surface has no tcode counterpart yet). Test: connector_e2e::session_status_unknown_id_is_not_found.

Source§

fn send_input<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session_id: &'life1 str, input: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<(), ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

POST /sessions/{id}/messages -> session.send (#2983 Slice 3).

Why: the client -> daemon input path. What: a 404 (unknown id) maps to ConnectorError::NotFound; success is () — the daemon’s {"acknowledged": true} confirmation is not surfaced through this trait. Test: connector_e2e::send_input_unknown_id_is_not_found.

Source§

fn attach<'life0, 'life1, 'async_trait>( &'life0 self, session_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<AttachHandle, ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

POST /rpc session.attach — ring-buffer replay + SSE stream URL.

Why: there is no REST route for session.attach (see module docs) — this is the one method that must speak raw JSON-RPC. tcode’s attach surface is fundamentally different from tm’s: it hands back replayed history plus a URL a caller GETs (as SSE) for live events, rather than a command a human runs — see AttachHandle::EventStream’s docs for why this is NOT forced into tm’s shell-command shape. What: POST /rpc always returns HTTP 200 (errors are carried IN the envelope, per crate::serve::http::rpc_handler’s docs) — a non-200 here means transport failure, mapped via [map_error_response]; an error field in the envelope is mapped via [map_rpc_error_object] (-32007 session_not_found -> ConnectorError::NotFound). On success, wraps result.{session_id,stream_url,events} in AttachHandle::EventStream. Test: connector_e2e::create_session_full_lifecycle (asserts the returned handle is an EventStream with the expected stream_url), connector_e2e::attach_unknown_id_is_not_found.

Source§

fn delegate<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session_id: &'life1 str, _agent_spec: &'life2 AgentSpec, ) -> Pin<Box<dyn Future<Output = Result<DelegateHandle, ConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Always ConnectorError::NotSupported — tcode has no delegate surface in this phase (DOC-44 locked decision 3).

Why: tm’s delegate wraps agent_delegate’s gate+record-only MCP tool; tcode has no equivalent endpoint, and adding one is explicit scope creep for issue #3007 (the issue’s locked design calls this out by name). Returning a typed NotSupported — rather than a generic Backend/Transport failure, and rather than making an HTTP call that would 404/METHOD_NOT_FOUND against a route that will never exist — lets a caller (the future lead agent, or a test) distinguish “this backend never does this” from “this particular call failed.” What: returns Err(ConnectorError::NotSupported(_)) unconditionally, with no network call at all. Test: connector_e2e::delegate_is_not_supported.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more