Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,12 @@ pub struct AdminConfig {

/// The desktop's limits — rate cap, heartbeat, tree size, journal size,
/// timeouts. Unset fields are the defaults; the two safety limits may
/// only be made stricter. See [`crate::desktop::limits`].
/// only be made stricter. See [`incord_desktop::limits`].
#[serde(
default,
skip_serializing_if = "crate::desktop::limits::DesktopLimits::is_empty"
skip_serializing_if = "incord_desktop::limits::DesktopLimits::is_empty"
)]
pub desktop_limits: crate::desktop::limits::DesktopLimits,
pub desktop_limits: incord_desktop::limits::DesktopLimits,

/// How the REPL says a long turn finished or that it is waiting on you:
/// `auto` (the default: OSC 9 where the terminal is known to show it, a
Expand Down
2 changes: 1 addition & 1 deletion src/admin/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ fn settings_round_trip_through_the_file() {
plugins: Plugins::default(),
desktop_hooks: a_hook_on_every_desktop_event(),
desktop_display: Some("xvfb:1280x800".to_string()),
desktop_limits: crate::desktop::limits::DesktopLimits {
desktop_limits: incord_desktop::limits::DesktopLimits {
max_actions_per_minute: Some(60),
tree_depth: Some(20),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ pub(crate) fn desktop_setup_for(
let exe = exe?;
desktop.then(|| crate::toolbox::DesktopSetup {
exe,
journal: crate::desktop::journal::path_in(workspace),
journal: incord_desktop::journal::path_in(workspace),
})
}

Expand All @@ -249,7 +249,7 @@ pub(crate) fn mcp_overrides_for(
if desktop {
out.extend(crate::desktop::mcp::codex_config_overrides(
&exe,
Some(&crate::desktop::journal::path_in(workspace)),
Some(&incord_desktop::journal::path_in(workspace)),
mode,
));
}
Expand Down
35 changes: 16 additions & 19 deletions src/desktop.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
//! Computer use, as incode sees it: the `incord-desktop` crate (`crates/desktop`,
//! binary `incu`) under its old path, and the few things that name incode.
//! The part of computer use that names incode. The desktop itself is the
//! `incord-desktop` crate (`crates/desktop`, binary `incu`).
//!
//! # Where this sits
//!
//! The desktop began as this module and moved out whole, for the reasons in the
//! `incord-desktop` crate header: it does not depend on incode, and incode
//! depends on it as it does on `incord-sandbox`. `pub use incord_desktop::*`
//! keeps every `crate::desktop::…` path in incode (`serve::http`, `runtime::
//! cancel`, `migrate`, `admin`, `cli`, the toolbox) as it was; rewriting them to
//! name the crate is a later step.
//!
//! Three things are not re-exported as they are, because they are incode's:
//! depends on it as it does on `incord-sandbox`. incode names the crate
//! directly (`incord_desktop::journal`, `incord_desktop::capture`, …) for
//! everything the crate has; this module holds only the three things that are
//! incode's:
//!
//! - [`mcp::client_config`], [`mcp::client_config_json`] and
//! [`mcp::codex_config_overrides`] build the registration an agent CLI needs
Expand All @@ -28,23 +26,23 @@
//! # Wired to
//!
//! - **Called by** `main.rs` (`Parsed::DesktopMcp`) for [`serve`];
//! `cli::agent_session` and `agent::codex` for [`mcp::codex_config_overrides`].
//! - **Calls** `incord_desktop` for everything else.
//! `cli::agent_session` and `agent::codex` for [`mcp::codex_config_overrides`];
//! `serve::http`, `runtime::cancel` and `main.rs` (`--desktop-stop`) for
//! [`safety::request_stop`].
//! - **Calls** `incord_desktop` (`cli::serve`, `safety::request_stop`).

use std::path::PathBuf;

pub use incord_desktop::*;

use incord_desktop::cli;
use incord_desktop::hooks::{HookOutcome, Hooks};
use incord_desktop::permission::Tier;

use crate::admin::AdminConfig;
use crate::permissions::PermissionMode;

pub mod mcp {
//! The server (the crate's), and the registration of it that names incode.

pub use incord_desktop::mcp::*;
//! The registration of the desktop server (the crate's
//! `incord_desktop::mcp`) that names incode.

use serde_json::{json, Value};

Expand Down Expand Up @@ -141,10 +139,8 @@ pub mod mcp {
}

pub mod safety {
//! The kill switch (the crate's), with incode's `.incode/` folder handling on
//! the one function that creates a file.

pub use incord_desktop::safety::*;
//! incode's `.incode/` folder handling on the one function of the crate's
//! kill switch (`incord_desktop::safety`) that creates a file.

/// Ask the desktop at this path to stop.
///
Expand Down Expand Up @@ -259,6 +255,7 @@ pub fn serve(
#[cfg(test)]
mod tests {
use super::*;
use incord_desktop::permission;
use serde_json::{json, Value};

/// The config has to name the flag that actually starts the server.
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ fn main() -> anyhow::Result<()> {
return Ok(());
}
Parsed::DesktopStop { workspace } => {
let path = incord_code::desktop::safety::stop_path_in(&workspace);
let path = incord_desktop::safety::stop_path_in(&workspace);
// REPORTED, never swallowed. A stop request that silently failed is
// worse than no stop button at all, because the operator walks away
// believing the desktop is halted.
Expand Down
4 changes: 2 additions & 2 deletions src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -613,13 +613,13 @@ mod tests {
/// file added there later is migrated too — or this fails and says which.
#[test]
fn every_project_path_incode_writes_is_on_the_list() {
let desktop_stop = crate::desktop::safety::stop_path_in(Path::new(""));
let desktop_stop = incord_desktop::safety::stop_path_in(Path::new(""));
let paths: Vec<String> = vec![
crate::brief::CACHE_FILE.to_string(),
crate::contracts::CONTRACTS_FILE.to_string(),
crate::guards::GUARDS_FILE.to_string(),
crate::findings::DIR.to_string(),
crate::desktop::journal::FILE.to_string(),
incord_desktop::journal::FILE.to_string(),
desktop_stop.to_string_lossy().replace('\\', "/"),
crate::team::FILE.to_string(),
crate::transcript::DIR.to_string(),
Expand Down
10 changes: 5 additions & 5 deletions src/serve/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,13 +405,13 @@ fn stream(workspace: PathBuf) -> Response<Body> {
let (tx, rx) = tokio::sync::mpsc::channel::<Bytes>(8);

tokio::spawn(async move {
let journal = crate::desktop::journal::path_in(&workspace);
let journal = incord_desktop::journal::path_in(&workspace);
// `None` would mean "send everything in the file", which on connect is
// a replay of the whole recent history. The FIRST poll therefore takes
// the current end as the starting cursor and shows nothing older —
// this stream is what the agent is doing NOW. The file itself is the
// record for anyone who wants the history.
let mut seen: Option<u64> = crate::desktop::journal::since(&journal, None)
let mut seen: Option<u64> = incord_desktop::journal::since(&journal, None)
.last()
.map(|entry| entry.seq);

Expand All @@ -421,7 +421,7 @@ fn stream(workspace: PathBuf) -> Response<Body> {
// discrete thing that happened, not a change to a board, and
// folding it into the run snapshot would lose every action that
// happened between two polls.
let fresh = crate::desktop::journal::since(&journal, seen);
let fresh = incord_desktop::journal::since(&journal, seen);
let mut sent_desktop = false;
for entry in &fresh {
let data = serde_json::to_string(entry).unwrap_or_default();
Expand Down Expand Up @@ -1120,8 +1120,8 @@ mod tests {
#[tokio::test]
async fn a_desktop_action_reaches_the_stream_as_its_own_event() {
let dir = tempfile::tempdir().expect("a workspace");
let path = crate::desktop::journal::path_in(dir.path());
let mut journal = crate::desktop::journal::Journal::at(path);
let path = incord_desktop::journal::path_in(dir.path());
let mut journal = incord_desktop::journal::Journal::at(path);

// Written BEFORE the stream opens, so it belongs to the history the
// stream must NOT replay.
Expand Down
2 changes: 1 addition & 1 deletion src/team.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//!
//! # Why a file, and not a socket or a queue
//!
//! Same reason as [`crate::desktop::journal`], and it is the same constraint.
//! Same reason as [`incord_desktop::journal`], and it is the same constraint.
//! An agent is a SUBPROCESS with its own loop; the harness does not share
//! memory with it, and there may be no second agent alive at the moment a
//! question is asked. A file is the one medium every participant can reach,
Expand Down
4 changes: 2 additions & 2 deletions src/tool_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,9 +1087,9 @@ mod tests {
fn the_bridge_hands_the_model_a_picture_and_incode_a_placeholder() {
use std::sync::atomic::AtomicUsize;
let ws = tempfile::tempdir().expect("ws");
let png = crate::desktop::capture::encode(
let png = incord_desktop::capture::encode(
&image::RgbaImage::from_pixel(32, 24, image::Rgba([10, 20, 30, 255])),
crate::desktop::capture::ShotFormat::Png,
incord_desktop::capture::ShotFormat::Png,
0,
)
.expect("png");
Expand Down
4 changes: 2 additions & 2 deletions src/toolbox/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub(super) fn is_desktop(name: &str) -> bool {
/// The desktop tools, in the toolbox's spelling (`input_schema`), from the
/// desktop server's own definitions — one source for both.
pub(super) fn definitions() -> Vec<Value> {
crate::desktop::mcp::tool_definitions()
incord_desktop::mcp::tool_definitions()
.into_iter()
.map(|mut def| {
if let Some(object) = def.as_object_mut() {
Expand Down Expand Up @@ -247,7 +247,7 @@ pub(super) mod tests {
let calls = std::sync::Arc::new(std::sync::atomic::AtomicUsize::new(0));
let png = {
let canvas = image::RgbaImage::from_pixel(4, 3, image::Rgba([1, 2, 3, 255]));
crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0)
.expect("png")
};
use base64::Engine as _;
Expand Down
10 changes: 5 additions & 5 deletions src/toolbox/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Image {
decoded
};
let png =
crate::desktop::capture::encode(&shown, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&shown, incord_desktop::capture::ShotFormat::Png, 0)
.map_err(|e| e.to_string())?;
let mut note = (scale < 1.0).then(|| {
format!(
Expand All @@ -204,9 +204,9 @@ impl Image {
return Ok((Self::from_encoded(png)?, note));
}
for quality in [85u8, 70, 50] {
let jpeg = crate::desktop::capture::encode(
let jpeg = incord_desktop::capture::encode(
&shown,
crate::desktop::capture::ShotFormat::Jpeg,
incord_desktop::capture::ShotFormat::Jpeg,
quality,
)
.map_err(|e| e.to_string())?;
Expand Down Expand Up @@ -410,7 +410,7 @@ mod tests {

fn png(width: u32, height: u32) -> Vec<u8> {
let canvas = image::RgbaImage::from_pixel(width, height, image::Rgba([30, 60, 120, 255]));
crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0)
.expect("encode")
}

Expand All @@ -425,7 +425,7 @@ mod tests {
let [a, b, c, _] = state.to_le_bytes();
image::Rgba([a, b, c, 255])
});
crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0)
.expect("encode")
}

Expand Down
8 changes: 4 additions & 4 deletions src/toolbox/picture_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};

fn png(width: u32, height: u32) -> Vec<u8> {
let canvas = ::image::RgbaImage::from_pixel(width, height, ::image::Rgba([40, 80, 160, 255]));
crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0)
.expect("png")
}

Expand All @@ -25,7 +25,7 @@ fn heavy_png() -> Vec<u8> {
let [a, b, c, _] = state.to_le_bytes();
::image::Rgba([a, b, c, 255])
});
crate::desktop::capture::encode(&canvas, crate::desktop::capture::ShotFormat::Png, 0)
incord_desktop::capture::encode(&canvas, incord_desktop::capture::ShotFormat::Png, 0)
.expect("png")
}

Expand Down Expand Up @@ -209,8 +209,8 @@ fn a_read_only_session_refuses_every_input_action_before_the_desktop() {
#[test]
fn the_real_desktop_screenshot_is_an_image_block() {
let ws = tempfile::tempdir().expect("ws");
let input = crate::desktop::thread::InputThread::start().expect("input thread");
let mut server = crate::desktop::mcp::Server::new(input);
let input = incord_desktop::thread::InputThread::start().expect("input thread");
let mut server = incord_desktop::mcp::Server::new(input);
let link = desktop::tests::InProcess::new(
move |line| server.handle_line(line),
Arc::new(AtomicUsize::new(0)),
Expand Down
Loading