Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
test(cli): pin the handshake's content-part caps against the builder
thinhlpg3f16adf5d5bc
diff --git a/src-tauri/jan-cli/tests/agent_rpc.rs b/src-tauri/jan-cli/tests/agent_rpc.rsindex 7450da546..77c4badba 100644--- a/src-tauri/jan-cli/tests/agent_rpc.rs+++ b/src-tauri/jan-cli/tests/agent_rpc.rs@@ -291,6 +291,34 @@ fn rpc_serves_a_session_lifecycle_after_the_handshake() {let _ = std::fs::remove_dir_all(scratch);}+/// A client that sends an image sends bytes into a channel with no+/// backpressure, so the caps are part of the handshake rather than something to+/// discover by being rejected. The RPC handshake carries the same object `init`+/// gives a stream-json client; this asserts the field is on the wire, and that+/// it is that object - compared against the builder, not against a copy of the+/// numbers, so a cap cannot move in one place only.+#[test]+fn the_handshake_advertises_the_content_part_caps() {+ let scratch = scratch("caps");+ let home = scratch.join("home");+ let provider_url = provider(1, 0);+ configure(&home, &provider_url);+ let mut rpc = Rpc::open(&home);++ let init = rpc.ask(serde_json::json!({"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientInfo":{"name":"test","version":"1"},"capabilities":{}}}));+ let caps = &init["result"]["input_content_parts"];+ assert!(!caps.is_null(), "{init}");+ assert_eq!(+ caps,+ &serde_json::to_value(app_lib::core::cli::run_report::InputContentParts::current())+ .expect("the caps serialize"),+ "the handshake advertises the caps the parser enforces",+ );++ rpc.close();+ let _ = std::fs::remove_dir_all(scratch);+}+#[test]fn failed_fork_does_not_close_other_sessions() {let scratch = scratch("failed-fork");diff --git a/src-tauri/src/core/cli/run_report.rs b/src-tauri/src/core/cli/run_report.rsindex a10043b22..10f4908b2 100644--- a/src-tauri/src/core/cli/run_report.rs+++ b/src-tauri/src/core/cli/run_report.rs@@ -312,7 +312,7 @@ pub(crate) struct Init {/// to discover by being rejected. Each is the cap the parser enforces: this is/// the same constant, not a copy of it.#[derive(serde::Serialize, schemars::JsonSchema)]-pub(crate) struct InputContentParts {+pub struct InputContentParts {/// The image types an `image_url` part may name, as MIME types.mime_types: Vec<&'static str>,/// Most decoded bytes one image may carry.@@ -329,7 +329,10 @@ pub(crate) struct InputContentParts {}impl InputContentParts {- pub(crate) fn current() -> Self {+ /// The caps as the parser enforces them. Public so a client-facing test can+ /// compare the handshake against this one value rather than against a copy+ /// of the numbers.+ pub fn current() -> Self {use super::stream_input;Self {mime_types: super::user_message::IMAGE_MIME_TYPES.to_vec(),