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
impl TcodeConnector
Sourcepub fn new() -> Self
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.
Sourcepub fn with_daemon_url(daemon_url: impl Into<String>) -> Self
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
impl Default for TcodeConnector
Source§impl WorkstreamConnector for TcodeConnector
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,
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,
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,
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,
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,
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,
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§
impl !RefUnwindSafe for TcodeConnector
impl !UnwindSafe for TcodeConnector
impl Freeze for TcodeConnector
impl Send for TcodeConnector
impl Sync for TcodeConnector
impl Unpin for TcodeConnector
impl UnsafeUnpin for TcodeConnector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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