dsh-clash-subscription 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-clash-proxy contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,128 @@
1
- # Temporary Holding Version
1
+ # dsh-clash-proxy
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Give DeepSeek Harness its own outbound proxy: import a Clash/mihomo subscription,
4
+ and the plugin runs a **private core** and points the Harness' outbound policy at it.
5
+ `web_fetch`, search/fetch providers, LLM transports and shells then reach blocked
6
+ sites automatically — **no desktop Clash app, no system proxy, no per-command
7
+ `HTTPS_PROXY`**.
8
+
9
+ ## Split routing
10
+
11
+ | Destination | Path |
12
+ | --- | --- |
13
+ | Loopback `127.0.0.1`, `::1`, localhost | direct (never in the tunnel: the Web UI and every plugin route live there) |
14
+ | LAN `10/8`, `172.16/12`, `192.168/16`, `169.254/16` | direct |
15
+ | Chinese addresses (`GEOIP,CN`) | direct |
16
+ | Everything else | proxy, through the selected subscription node |
17
+
18
+ Domestic sites therefore behave exactly as before; only traffic that would otherwise
19
+ be blocked reaches a node.
20
+
21
+ ## No defaults, no borrowed configuration
22
+
23
+ The subscription URL has **no default value and no fallback**. The plugin never reads
24
+ another client's profile, subscription, or node selection. The only machine-level
25
+ information it uses is:
26
+
27
+ - an existing mihomo-compatible executable, so you need not type a path to a core the
28
+ machine already has; and
29
+ - downloaded GeoIP/GeoSite databases, because the core needs them before it can
30
+ classify a single connection — the alternative is a download over the very tunnel
31
+ those databases are required to establish.
32
+
33
+ Both are optional. Without them you point `corePath` at a binary and the core falls
34
+ back to a built-in domestic domain list.
35
+
36
+ ## How it works
37
+
38
+ It does not reimplement transport. It reuses the Harness' own outbound policy module
39
+ `@deepseek-ai/dsh-http-proxy`:
40
+
41
+ 1. **The core parses the subscription.** The config carries a `proxy-providers` entry
42
+ and mihomo downloads it itself, so anytls / hysteria2 / vless / ss / trojan all work
43
+ without a parser or a schema to track.
44
+ 2. **The policy is loaded from the installation, not the profile.** A profile-installed
45
+ plugin resolves bare specifiers from its own `node_modules`; resolving
46
+ `dsh-http-proxy` from the dsh installation's manifest yields the *same module
47
+ instance the host loaded*. Node's `fetch` resolves undici's global dispatcher, and
48
+ `dsh-subprocess` asks this same module for a child's environment — one instance, so
49
+ one install covers `ctx.web`, the LLM transports and every spawned child.
50
+ 3. **A working node is chosen at startup.** A fresh `PROXY` group starts on `DIRECT`,
51
+ which would send foreign traffic straight out, so the plugin measures latency in
52
+ batches, skips dead nodes (a provider can report a node alive long after it stopped
53
+ serving), and never selects `DIRECT`.
54
+ 4. **Geo databases are reused, never re-downloaded.** A missing database makes the core
55
+ fetch one from GitHub at startup — the exact connection it needs the database to
56
+ establish — so an existing copy is reused and a missing one is reported instead of
57
+ retried.
58
+
59
+ ## Configuration
60
+
61
+ Install the bundle, then set the subscription in **Settings → Clash proxy**.
62
+
63
+ | Field | Default | Meaning |
64
+ | --- | --- | --- |
65
+ | `subscriptionUrl` | empty | Subscription URL. `clash://install-config?url=…` import links are accepted. Required. |
66
+ | `node` | empty | Preferred node name; empty picks the lowest-latency working node |
67
+ | `corePath` | empty | mihomo/clash executable; empty searches the usual install locations |
68
+ | `mode` | `rule` | `rule` keeps domestic traffic direct; `global` proxies everything |
69
+ | `autoStart` | `true` | Start the core and install the policy when the plugin loads |
70
+ | `speedTestMinutes` | `30` | Re-measure interval; `0` disables the cycle |
71
+ | `speedTestCount` | `8` | Nodes measured per cycle |
72
+ | `dnsServers` | empty | Resolvers for the core's own lookups, comma separated |
73
+ | `directDomains` | empty | Domain suffixes that must stay direct |
74
+ | `proxyDomains` | empty | Domain suffixes that must always use the node |
75
+ | `dataDir` | `<DSH_HOME>/data/dsh-clash-proxy` | Core config, subscription cache, geo databases |
76
+
77
+ Ports are allocated free on every start, so the plugin never collides with another
78
+ Clash instance, and it only ever stops the process it started.
79
+
80
+ ## UI
81
+
82
+ A page in **Settings → Clash proxy**, with live status, the node table with measured
83
+ latency, the subscription field with a pre-save reachability check, and the
84
+ speed-test cycle. Saving writes through the Harness config editor, so the rest of the
85
+ profile patch stays intact; a routing-relevant change restarts the core, a timing
86
+ change only re-arms the cycle.
87
+
88
+ ## Tool
89
+
90
+ One model-facing tool, `clash_proxy`:
91
+
92
+ - `status` — core, policy, node table, current node, live traffic
93
+ - `import` — probe a URL, restart the core on it, install the policy
94
+ - `start` / `stop` — bring routing up or take it down
95
+ - `select` — switch the exit node by name
96
+ - `test` — measure one node, or the current one
97
+ - `refresh` — re-download the subscription
98
+
99
+ ## Tests
100
+
101
+ ```bash
102
+ node test/unit.mjs # offline assertions: no network, no core, no profile writes
103
+ node test/client-sim.mjs # executes the client bundle in a simulated module loader
104
+ node test/e2e.mjs "<subscription url>" # real core + real subscription
105
+ ```
106
+
107
+ `test/e2e.mjs` asserts the three promises above: the core boots, `fetch` reaches
108
+ foreign hosts once the policy is installed, and domestic plus loopback traffic stays
109
+ direct.
110
+
111
+ ## Known limits
112
+
113
+ - **This process and its children only.** It is the Harness' outbound policy, not a
114
+ system VPN; other applications are unaffected (which is part of why domestic sites
115
+ stay unchanged).
116
+ - **Worker threads do not receive the policy.** `dsh-http-proxy` deliberately withholds
117
+ a possibly credential-bearing proxy URL from model-authored scripts; the plugin
118
+ keeps that boundary.
119
+ - **A plugin that builds its own transport bypasses it.** A fetch provider using
120
+ `node:https` and its own DNS lookup does not read undici's dispatcher, so it will not
121
+ be proxied.
122
+ - **Node quality is the subscription's.** Automatic selection measures latency once;
123
+ later congestion still needs a manual `select` or `test`.
124
+ - **No bundled core.** Bring a mihomo/clash binary; the plugin does not redistribute one.
125
+
126
+ ## License
127
+
128
+ MIT