-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCargo.toml
More file actions
175 lines (161 loc) · 8.01 KB
/
Copy pathCargo.toml
File metadata and controls
175 lines (161 loc) · 8.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
[workspace]
resolver = "2"
members = [
# ── 第一层 · 共用(企业版依赖的只有这四个)──────────
# 只准依赖彼此和第三方 crate,不准依赖第二层 —— tw-dialect 里的
# layer_one_depends_only_on_itself 测试守着这条。改这一层要 grep 企业版;
# CI 的 enterprise 任务会拿企业版对着这次改动编译一遍。
# **只有一方在用的「共用件」搬回那一方**,不留在这里;两边都用上了就搬回来
# (tw-bedrock 就是这么回来的)。
"crates/tw-dialect",
"crates/tw-guard",
"crates/tw-breaker",
"crates/tw-bedrock",
# ── 第二层 · 桌面网关(企业版不依赖)────────────────
"crates/tw-types",
"crates/tw-secret",
"crates/tw-api",
"crates/tw-config",
"crates/tw-yaml",
"crates/tw-store",
"crates/tw-pricing",
"crates/tw-watch",
"crates/tw-engine",
"crates/tw-observe",
"crates/tw-gateway",
# 脚本插件的沙箱(QuickJS 跑在 Wasmtime 里)。编它要一个能出 wasm 的 clang,
# 所以**只有 tw-gateway 和 twcore 能依赖它** —— 桌面端从 git 编的那几个
# crate、企业版用的第一层都不能沾上,tw-plugin 的 tests/boundary.rs 守着
"crates/tw-plugin",
"crates/tw-control",
# 控制通道的握手与加密。桌面端按 tag 依赖它,所以只依赖契约层和 tw-yaml
"crates/tw-link",
# ── bin ──────────────────────────────────────────────
"bin/twcore",
]
[workspace.package]
edition = "2024"
# 与企业版对齐。edition 2024 需要 1.85(2025-02 首个稳定版)。
rust-version = "1.85"
license = "MIT"
repository = "https://github.com/ThinkWatchProject/ThinkWatch-Core"
homepage = "https://thinkwat.ch/core/"
# 这些 crate 不发 crates.io(企业版和桌面版按 tag 从 git 取),docs.rs 上
# 没有它们 —— 文档指向项目自己的
documentation = "https://thinkwat.ch/docs/core/"
readme = "README.md"
# 关键词和分类说的是网关本身,只有网关那几个 crate(twcore、tw-gateway、
# tw-control)继承;其余的 crate 各有各的事,只继承上面几项。
# crates.io 的规矩:关键词最多五个,分类只能用它列出的 slug
keywords = ["ai-gateway", "llm", "openai", "anthropic", "gemini"]
categories = ["network-programming", "web-programming::http-server"]
# 二进制走 CalVer,crate 走 SemVer —— 两者是两回事,卖给不同的人。
# 这里是 crate 的版本。
version = "0.58.0"
[workspace.dependencies]
# ── 内部 crate ───────────────────────────────────────────
tw-types = { path = "crates/tw-types" }
tw-api = { path = "crates/tw-api" }
tw-secret = { path = "crates/tw-secret" }
tw-config = { path = "crates/tw-config" }
tw-engine = { path = "crates/tw-engine" }
tw-observe = { path = "crates/tw-observe" }
tw-gateway = { path = "crates/tw-gateway" }
tw-control = { path = "crates/tw-control" }
tw-yaml = { path = "crates/tw-yaml" }
tw-store = { path = "crates/tw-store" }
tw-pricing = { path = "crates/tw-pricing" }
tw-watch = { path = "crates/tw-watch" }
tw-guard = { path = "crates/tw-guard" }
tw-breaker = { path = "crates/tw-breaker" }
tw-dialect = { path = "crates/tw-dialect" }
tw-bedrock = { path = "crates/tw-bedrock" }
tw-link = { path = "crates/tw-link" }
tw-plugin = { path = "crates/tw-plugin" }
# ── 版本与企业版 workspace 对齐,便于反向依赖时不打架 ────
tokio = { version = "1", features = ["rt-multi-thread", "macros", "net", "time", "sync", "io-util", "signal"] }
axum = { version = "0.8", features = ["macros", "ws"] }
tower = "0.5"
hyper = { version = "1", features = ["full"] }
hyper-util = "0.1"
http-body-util = "0.1"
bytes = "1"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml_ng = "0.10"
# 文件监听,只有 tw-watch 直接用
notify = "8"
# 请求历史。bundled 是刻意的:零外部依赖,用户不必装 sqlite
rusqlite = { version = "0.40", features = ["bundled"] }
libc = "0.2"
# 问 Windows 要它自己才知道的东西:网卡清单(tw-config 的 nics)、
# 一个 pid 在不在(twcore 的 proc)。**纯 Rust 的绑定**,不编译任何 C ——
# 和 unix 那边直接用 libc 是同一个取舍。
windows-sys = "0.61"
# 内置价目表压缩着放(2.3 MB → 110 KB)
flate2 = "1"
# regex-automata / regex-syntax 已经在依赖树里(tracing 的 EnvFilter),
# 所以加它的增量很小
regex = "1"
# 保格式地改 TOML。接管 Codex 要写它的 config.toml,而重新序列化
# 会把用户的注释和排版一起抹掉
toml_edit = "0.25"
# 只有它给节点的 span —— 而 span 是「只改一段字节」的全部前提。
# serde_yaml 已经归档,且本来就不保留格式。
saphyr-parser = "0.0.12"
reqwest = { version = "0.13", default-features = false, features = ["stream", "json", "rustls", "socks", "http2", "form"] } # form: OAuth 换 token 是表单 POST,密钥的百分号编码不自己写
# L1 分段测速要自己走握手 —— reqwest 把建连整个包起来,只给一个总时间,
# 而分段正是这一层的全部价值。版本跟着 reqwest 的传递依赖走,不引新的树。
rustls = "0.23"
rustls-platform-verifier = "0.7"
tokio-rustls = "0.26"
# WS 升级代理。**不带自己的 TLS**:连接用我们已经配好的 rustls
# 栈,否则会出现「数据面信任的根证书」和「WS 信任的」是两套
tokio-tungstenite = { version = "0.28", default-features = false, features = ["handshake"] }
base64 = "0.22"
# 控制通道的握手(tw-link)。Noise_NNpsk0_25519_ChaChaPoly_BLAKE2s 用到的
# 三样算法之外一概不开:默认特性会带上 AES-GCM、SHA2
snow = { version = "0.10", default-features = false, features = ["use-curve25519", "use-chacha20poly1305", "use-blake2", "use-getrandom"] }
futures = "0.3"
tokio-stream = "0.1"
async-stream = "0.3"
# ── Bedrock(tw-bedrock):SigV4 签名、eventstream 拆帧 ─────────
# aws-sigv4 1.5 起签名不再带 http 0.2,所以不再关在 feature 后面。
# 最低要 rustc 1.94.1,比上面写的 rust-version 高 —— 两边的 CI 都用 stable
aws-sigv4 = "1"
aws-credential-types = "1"
aws-smithy-eventstream = "0.60"
aws-smithy-types = "1"
percent-encoding = "2"
thiserror = "2"
anyhow = "1"
tracing = "0.1"
metrics = "0.24"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
chrono = { version = "0.4", features = ["serde"] }
arc-swap = "1"
blake3 = "1"
# PKCE 的 S256。版本跟着 reqwest 的传递依赖走,不引新的树
sha2 = "0.11"
uuid = { version = "1", features = ["v4", "serde"] }
rand = "0.10"
# 发给 Codex 后端的请求体用 zstd 压缩(Codex 直连它时就这么发)。只要流式编码,
# 不开旧格式和字典训练
zstd = { version = "0.13", default-features = false }
clap = { version = "4", features = ["derive"] }
# 控制面契约导出成 TypeScript(tw-api 的 `ts` feature)。**不开任何 serde 以外的
# 类型实现**:契约里只有 std 和 serde 的类型
ts-rs = { version = "12", default-features = false, features = ["serde-compat"] }
[profile.release]
# 桌面 sidecar:体积比极限吞吐重要。企业版用 lto = true + codegen-units = 1,
# 那是为服务器热路径调的;这里 "thin" 已经够,链接快得多。
lto = "thin"
codegen-units = 1
strip = "symbols"
# 保持 unwind:catch_unwind 要靠它兜住单个请求的 panic。
# abort 会让那层防护失效,整个进程跟着死 —— 而 core 死了所有 AI 客户端一起瞎。
panic = "unwind"
# 开发和测试构建只留行号表:报错和 panic 仍能指到文件和行,变量级调试信息不要。
# 每个集成测试都是链接整个 crate 的独立二进制,带完整调试信息时 target/ 会涨到上百 GB。
[profile.dev]
debug = "line-tables-only"