chore(crates): move vendored SDKs into workspace as forkable crates

Per user direction "可以不放在 vendor 里面,我们移动到自己的工程,
后面就和他们分叉" — promote the two community SDKs from vendor/ to
crates/ so they become first-class OP workspace members we own and
evolve, instead of read-only vendored snapshots.

Moves:
  vendor/anthropic-agent-sdk/  →  crates/anthropic-agent-sdk/
  vendor/copilot-sdk-rust/     →  crates/copilot-sdk/

Workspace integration:
  - Root `Cargo.toml` exclude list drops both vendor entries; the
    existing `members = ["crates/*"]` glob auto-includes them.
  - `crates/copilot-sdk/Cargo.toml`: stripped all `[[example]]`
    blocks (22 of them) — the examples/ dir was already removed
    during the import, and leaving the entries broke
    `cargo test --workspace --no-run`.
  - `crates/anthropic-agent-sdk/Cargo.toml`: already had its
    `[[example]]` blocks pruned in the previous commit.

Lockfile pins (workspace `Cargo.lock`):
  Pulling reqwest 0.12.28 (via anthropic-agent-sdk) into the
  unified workspace dep graph re-resolved several `icu_*` crates to
  the 2.2 line, which requires rustc 1.86. OP's toolchain is 1.85
  (locked to stay compatible with the skia-safe-op fork). Pinned:
    icu_collections      2.2.0 → 2.1.1
    icu_locale_core      2.2.0 → 2.1.1
    icu_normalizer       2.2.0 → 2.1.1
    icu_normalizer_data  2.2.0 → 2.1.1
    icu_properties       2.2.0 → 2.1.2
    icu_properties_data  2.2.0 → 2.1.2
    icu_provider         2.2.0 → 2.1.1
    idna_adapter         1.2.2 → 1.2.1
  All eight pins are the latest versions on each crate's 2.1.x /
  1.2.x line that compile on rustc 1.85.

Verification:
  - `cargo check -p anthropic-agent-sdk` ✓
  - `cargo check -p copilot-sdk` ✓
  - `cargo test --workspace --no-run` ✓
  - `cargo test -p openpencil-shell-core --lib` → 250 pass
  - `cargo test -p openpencil-desktop chat_` → 16 pass

Next: replace the hand-rolled subprocess parser in chat_subprocess.rs
with thin per-CLI adapters that route Claude Code through
`anthropic_agent_sdk::SubprocessTransport` and Copilot through
`copilot_sdk::Client + Session`. Gemini stays on the generic stdin
bridge until an upstream Rust SDK exists. Codex + OpenCode get an
HttpServerProvider that spawns `<bin> serve` then connects via a
local HTTP client.
This commit is contained in:
Kayshen-X 2026-05-14 16:49:17 +08:00
parent 5e86b6e731
commit f3f57081da
62 changed files with 1104 additions and 187 deletions

1060
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -8,13 +8,6 @@ exclude = [
"vendor/agent",
"vendor/jian",
"vendor/skia-safe-op",
# Vendored Claude Code SDK from bartolli/anthropic-agent-sdk + the
# community Copilot SDK from copilot-community-sdk/copilot-sdk-rust.
# Both stay out of OP's `--workspace` build because they ship `edition
# = "2024"` (OP root pins 2021) and their test/dev dep sets diverge
# from ours. openpencil-desktop consumes them via direct path deps.
"vendor/anthropic-agent-sdk",
"vendor/copilot-sdk-rust",
"node_modules",
]

View file

@ -40,7 +40,15 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
# Official Anthropic MCP SDK (optional - for SDK MCP servers)
rmcp = { version = "0.12.0", optional = true, features = ["server", "client", "transport-io", "transport-child-process", "transport-streamable-http-server", "transport-worker", "macros"] }
rmcp = { version = "0.12.0", optional = true, features = [
"server",
"client",
"transport-io",
"transport-child-process",
"transport-streamable-http-server",
"transport-worker",
"macros",
] }
# Error handling
thiserror = "2.0.17"
@ -70,7 +78,11 @@ tracing = "0.1.44"
schemars = { version = "1.1.0", optional = true }
sha2 = "0.10.9"
base64 = "0.22.1"
reqwest = { version = "0.12.28", default-features = false, features = ["rustls-tls", "json", "stream"] }
reqwest = { version = "0.12.28", default-features = false, features = [
"rustls-tls",
"json",
"stream",
] }
[dev-dependencies]
anyhow = "1.0"

View file

@ -0,0 +1,59 @@
[package]
name = "copilot-sdk"
version = "0.1.17"
edition = "2021"
rust-version = "1.85"
license = "MIT"
description = "Rust SDK for GitHub Copilot CLI"
repository = "https://github.com/github-community/copilot-sdk-rust"
documentation = "https://docs.rs/copilot-sdk"
readme = "README.md"
keywords = ["copilot", "github", "ai", "sdk"]
categories = ["api-bindings", "asynchronous"]
[dependencies]
# Async runtime
tokio = { version = "1", features = [
"rt-multi-thread",
"net",
"process",
"sync",
"io-util",
"macros",
"time",
] }
# JSON serialization
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# Error handling
thiserror = "2"
# DateTime handling
chrono = { version = "0.4", features = ["serde"] }
# Logging
tracing = "0.1"
# Executable finding
which = "7"
schemars = { version = "0.8", optional = true, features = ["derive"] }
[dev-dependencies]
tokio-test = "0.4"
pretty_assertions = "1"
tempfile = "3"
futures = "0.3"
rand = "0.8"
serde_yaml = "0.9"
[features]
default = []
e2e = [] # Enable E2E tests that require real Copilot CLI
snapshots = [] # Enable snapshot-based conformance tests
schemars = ["dep:schemars"] # Derive tool JSON schemas from Rust types
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]

View file

@ -87,5 +87,7 @@ tokio = { version = "1", default-features = false, features = [
"sync",
"io-util",
"process",
"net",
"time",
] }
futures = { version = "0.3", default-features = false, features = ["std"] }

View file

@ -1,147 +0,0 @@
[package]
name = "copilot-sdk"
version = "0.1.17"
edition = "2021"
rust-version = "1.85"
license = "MIT"
description = "Rust SDK for GitHub Copilot CLI"
repository = "https://github.com/github-community/copilot-sdk-rust"
documentation = "https://docs.rs/copilot-sdk"
readme = "README.md"
keywords = ["copilot", "github", "ai", "sdk"]
categories = ["api-bindings", "asynchronous"]
[dependencies]
# Async runtime
tokio = { version = "1", features = [
"rt-multi-thread",
"net",
"process",
"sync",
"io-util",
"macros",
"time",
] }
# JSON serialization
serde = { version = "1", features = ["derive"] }
serde_json = "1"
# Error handling
thiserror = "2"
# DateTime handling
chrono = { version = "0.4", features = ["serde"] }
# Logging
tracing = "0.1"
# Executable finding
which = "7"
schemars = { version = "0.8", optional = true, features = ["derive"] }
[dev-dependencies]
tokio-test = "0.4"
pretty_assertions = "1"
tempfile = "3"
futures = "0.3"
rand = "0.8"
serde_yaml = "0.9"
[features]
default = []
e2e = [] # Enable E2E tests that require real Copilot CLI
snapshots = [] # Enable snapshot-based conformance tests
schemars = ["dep:schemars"] # Derive tool JSON schemas from Rust types
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
[[example]]
name = "basic_chat"
path = "examples/basic_chat.rs"
[[example]]
name = "tool_usage"
path = "examples/tool_usage.rs"
[[example]]
name = "streaming"
path = "examples/streaming.rs"
[[example]]
name = "multi_turn"
path = "examples/multi_turn.rs"
[[example]]
name = "byok"
path = "examples/byok.rs"
[[example]]
name = "system_prompt"
path = "examples/system_prompt.rs"
[[example]]
name = "custom_agents"
path = "examples/custom_agents.rs"
[[example]]
name = "mcp_servers"
path = "examples/mcp_servers.rs"
[[example]]
name = "attachments"
path = "examples/attachments.rs"
[[example]]
name = "permission_callback"
path = "examples/permission_callback.rs"
[[example]]
name = "resume_with_tools"
path = "examples/resume_with_tools.rs"
[[example]]
name = "multi_tools"
path = "examples/multi_tools.rs"
[[example]]
name = "yolo"
path = "examples/yolo.rs"
[[example]]
name = "debug_pipe"
path = "examples/debug_pipe.rs"
[[example]]
name = "escape_room"
path = "examples/escape_room.rs"
[[example]]
name = "rscopilot-cli"
path = "examples/rscopilot_cli.rs"
[[example]]
name = "set_model"
path = "examples/set_model.rs"
[[example]]
name = "mode_switching"
path = "examples/mode_switching.rs"
[[example]]
name = "plan_ops"
path = "examples/plan_ops.rs"
[[example]]
name = "agent_management"
path = "examples/agent_management.rs"
[[example]]
name = "telemetry"
path = "examples/telemetry.rs"
[[example]]
name = "shell_exec"
path = "examples/shell_exec.rs"