Skip to main content

Module forge_sdk_bridge

Module forge_sdk_bridge 

Source
Expand description

ForgeSdkBridge - in-process driver around a forge_sdk::Client.

Drives a forge_sdk::Client directly - no Node.js subprocess, no NDJSON, no command queue. The bridge holds the spawned Arc<Client> and dispatches each method as a direct call (or a tokio::spawn’d async task when the method is fire-and-forget). Synthesized events (Connected, PermissionRequest, McpSnapshot, …) flow back through an mpsc::UnboundedSender<AgentEvent> the bridge owns; consumers grab the matching receiver once via ForgeSdkBridge::take_events.

    view                    ForgeSdkBridge                  forge_sdk::Client
     | trait method            |                                    |
     |------------------------>|  client.method().await             |
     |                         |----------------------------------->|
     |                         |                                    |
     |       AgentEvent        |  reader_loop / callbacks           |
     |<------ event_tx --------+<-----------------------------------|

Re-exportsΒ§

use std::collections::HashMap; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::sync::Arc; πŸ”’
use std::time::Instant; πŸ”’
use forge_sdk::Client; πŸ”’
use parking_lot::Mutex; πŸ”’
use serde_json::Value; πŸ”’
use tokio::sync::mpsc; πŸ”’
use tokio::sync::oneshot; πŸ”’
use tracing::Instrument; πŸ”’
use crate::client::AgentEvent; πŸ”’
use crate::client::SessionLaunchSettings; πŸ”’
use crate::client::SpawnFailureKind; πŸ”’
use crate::forge_sdk_worker; πŸ”’
use crate::forge_sdk_worker::SessionId; πŸ”’
use forge_primitives::PermissionMode; πŸ”’
use forge_primitives::PermissionOutcome; πŸ”’
use forge_primitives::QuestionOutcome; πŸ”’

StructsΒ§

BridgeInner πŸ”’
ForgeSdkBridge
In-process bridge wrapping a single forge_sdk::Client.
ProbeInFlight πŸ”’
Holds a seat’s probe mark while its probe is out, and releases it however the probe ends: an answer, an error, a timeout, or a dispatch that never reached a client at all.

ConstantsΒ§

TESTING_STUB_CONFIG_DIR πŸ”’
Sentinel config_dir for ForgeSdkBridge test stubs that never exercise the path. Production code constructs the bridge with a real account config_dir; tests that don’t drive a session use this path so the typed field stays non-optional.

FunctionsΒ§

spawn_failure_kind πŸ”’
Name the class of a spawn failure from the SDK error itself, so a consumer never has to infer it from the rendered message.
turn_error πŸ”’
The turn-error event for a failure forge hit itself, classified where the message is built: a reader branching on the class gets it without searching the prose.

Type AliasesΒ§

PendingQuestions πŸ”’
Pending question outcomes keyed by tool_use_id. The AskUserQuestion driver in the can_use_tool callback parks a fresh oneshot per question, emits a QuestionRequest, and awaits the matching question_response.
PendingResponses πŸ”’
Pending permission responses keyed by tool_use_id. The can_use_tool callback parks a oneshot here when the CLI asks; dispatch drains it when the matching permission_response arrives from a view.