widevin 0.3.0

Lightweight Rust Devin provider library
Documentation

widevin for Rust

Rust 1.85+ bindings for Devin/Cascade OAuth login, caller-controlled token storage, model discovery, and streaming chat/tool events. This crate mirrors the behavior of the TypeScript widevin package and uses Reqwest with Rustls.

Only use Devin/Cascade programmatic access when permitted by your organization and applicable terms.

Install

[dependencies]
widevin = "0.3.0"
futures-util = "0.3"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Quick start

use futures_util::StreamExt;
use widevin::{
    DevinChatRequest, DevinContentPart, DevinMessage, DevinStreamEvent,
    create_devin_provider,
};

#[tokio::main]
async fn main() -> Result<(), widevin::DevinError> {
    let provider = create_devin_provider(Default::default());
    provider.set_token(std::env::var("DEVIN_TOKEN").unwrap_or_default()).await?;
    let model = provider.list_models().await?.into_iter().next()
        .ok_or_else(|| widevin::DevinError::protocol("Devin returned no models"))?;
    let mut events = provider.stream_chat(DevinChatRequest {
        model: model.id,
        system_prompt: vec!["You are concise.".into()],
        messages: vec![DevinMessage::User {
            content: vec![DevinContentPart::Text {
                text: "Say hello in one sentence.".into(),
            }],
        }],
        ..Default::default()
    });
    while let Some(event) = events.next().await {
        if let DevinStreamEvent::TextDelta { delta } = event? {
            print!("{delta}");
        }
    }
    Ok(())
}

Store raw tokens. The devin-session-token$ prefix is added only at request boundaries; an empty token is treated as absent. File token stores create private 0600 files on Unix. ToolCallDelta.arguments may contain a throttled parsed JSON snapshot; the final ToolCallEnd.arguments value is authoritative.

Enterprise client metadata

If your Devin organization authorizes Cascade models by client identity, set the approved fields in DevinProviderOptions. They are applied to model discovery, JWT auth, assignment, and chat requests.

use widevin::{DevinClientMetadata, DevinProviderOptions, create_devin_provider};

let provider = create_devin_provider(DevinProviderOptions {
    client_metadata: Some(DevinClientMetadata {
        ide_name: Some("devin".into()),
        ..Default::default()
    }),
    ..Default::default()
});

Discovery defaults to the native Chisel dev identity; auth, assignment, and chat use the released Devin CLI identity (3000.11.3). Discovery falls back to the Windsurf identity and raw key for legacy Enterprise seats. Custom fields override these identities consistently.

Native discovery and routing

provider.list_models() retains the current credential's configurations for provider.stream_chat(). Adaptive routers are assigned before chat; native Fusion pairings run their live lead. When using stream_devin_chat directly, pass a discovered model as StreamDevinChatOptions.model_config, alongside its ID in model. The configuration supplies output limits and parallel-tool capabilities. Credential changes invalidate the provider's stored catalog.

Discovery keeps each native reasoning-effort UID, with family axes, account default, presentation flags, raw token rates, and authoritative capabilities. max_tokens describes output; context_window describes input/context. SWE-1.6 variants are text-only, following upstream's documented limitation. Raw rates do not include pricing tiers or cache-write estimates.

Default chat sampling is temperature 1, float32-widened top-p 0.95, and no implicit stop patterns. Caller overrides take precedence. Inline Gemini nullable and mixed-type schemas are adapted on the wire without changing the caller's schema. Parent and branch constraints are both preserved; overlapping keywords keep the non-null branch under anyOf. Supply inline schemas rather than $ref references. History tool IDs remain paired after sanitization and 40-character capping; empty assistant rows are omitted.

DevinStreamEvent::Done includes optional response_id for replay and upstream_model for the actual/assigned model. Existing matches can use Done { reason, .. }. The new Credits variant exposes raw billing values reported on a response frame. Existing token-usage fields stay separate.

Use ..Default::default() when constructing public request/config structs to accommodate new fields. This update adds fields to DevinModel, DevinClientMetadata, DevinChatRequest, and StreamDevinChatOptions.

Run the full smoke-test example from the repository:

cargo run --manifest-path rust/Cargo.toml --example hello-world
cargo run --manifest-path rust/Cargo.toml --example hello-world -- \
  "Explain what this library does in one sentence."

The example uses DEVIN_TOKEN, .devin-token, or the OAuth callback flow in that order. Delete .devin-token to remove the cached local token; this does not revoke the credential server-side.