omnicell-router 0.7.0 → 0.8.2

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.
Files changed (246) hide show
  1. package/backend/dist/cli/clients/activity.d.ts +35 -0
  2. package/backend/dist/cli/clients/activity.js +67 -0
  3. package/backend/dist/cli/clients/base.d.ts +13 -2
  4. package/backend/dist/cli/clients/claude.d.ts +2 -2
  5. package/backend/dist/cli/clients/codex.d.ts +2 -2
  6. package/backend/dist/cli/clients/core-adapters.d.ts +3 -4
  7. package/backend/dist/cli/clients/core-adapters.js +3 -4
  8. package/backend/dist/cli/clients/cursor-proxy.d.ts +88 -0
  9. package/backend/dist/cli/clients/cursor-proxy.js +421 -0
  10. package/backend/dist/cli/clients/dsh.d.ts +2 -2
  11. package/backend/dist/cli/clients/grok.d.ts +2 -2
  12. package/backend/dist/cli/clients/index.d.ts +8 -1
  13. package/backend/dist/cli/clients/index.js +55 -21
  14. package/backend/dist/cli/clients/kimi.d.ts +2 -2
  15. package/backend/dist/cli/clients/launcher.d.ts +8 -0
  16. package/backend/dist/cli/clients/model-meta.js +1 -1
  17. package/backend/dist/cli/clients/omp.d.ts +2 -2
  18. package/backend/dist/cli/clients/openclaw.d.ts +2 -2
  19. package/backend/dist/cli/clients/opencode-proxy.d.ts +11 -0
  20. package/backend/dist/cli/clients/opencode-proxy.js +351 -0
  21. package/backend/dist/cli/clients/opencode.d.ts +2 -2
  22. package/backend/dist/cli/clients/pi.d.ts +2 -2
  23. package/backend/dist/cli/clients/plugin-adapters.d.ts +3 -1
  24. package/backend/dist/cli/clients/plugin-adapters.js +6 -29
  25. package/backend/dist/cli/clients/qoder-proxy.d.ts +84 -0
  26. package/backend/dist/cli/clients/qoder-proxy.js +497 -0
  27. package/backend/dist/cli/clients/reserved.d.ts +2 -6
  28. package/backend/dist/cli/clients/reserved.js +2 -0
  29. package/backend/dist/cli/clients/workbuddy.d.ts +2 -2
  30. package/backend/dist/cli/index.js +60 -9
  31. package/backend/dist/cli/types.d.ts +29 -8
  32. package/backend/dist/compression/caveman-prompts.d.ts +1 -1
  33. package/backend/dist/config/comments-en.js +6 -12
  34. package/backend/dist/config/comments-zh.js +6 -12
  35. package/backend/dist/config/defaults.d.ts +56 -1
  36. package/backend/dist/config/defaults.js +68 -0
  37. package/backend/dist/config/index.d.ts +9 -2
  38. package/backend/dist/config/index.js +26 -3
  39. package/backend/dist/config/types.d.ts +55 -43
  40. package/backend/dist/forward-proxy/egress.d.ts +10 -2
  41. package/backend/dist/forward-proxy/egress.js +42 -4
  42. package/backend/dist/forward-proxy/ordered-relay.d.ts +29 -0
  43. package/backend/dist/forward-proxy/ordered-relay.js +46 -0
  44. package/backend/dist/forward-proxy/rules.d.ts +66 -19
  45. package/backend/dist/forward-proxy/rules.js +61 -14
  46. package/backend/dist/forward-proxy/server.js +226 -77
  47. package/backend/dist/forward-proxy/system-proxy.d.ts +42 -2
  48. package/backend/dist/forward-proxy/system-proxy.js +199 -22
  49. package/backend/dist/harness/common/market.d.ts +3 -3
  50. package/backend/dist/harness/host/adapters/amp.d.ts +1 -1
  51. package/backend/dist/harness/host/adapters/antigravity.d.ts +1 -1
  52. package/backend/dist/harness/host/adapters/claude.d.ts +1 -1
  53. package/backend/dist/harness/host/adapters/cline.d.ts +1 -1
  54. package/backend/dist/harness/host/adapters/codex.d.ts +1 -1
  55. package/backend/dist/harness/host/adapters/cursor.d.ts +1 -1
  56. package/backend/dist/harness/host/adapters/dsh.d.ts +2 -2
  57. package/backend/dist/harness/host/adapters/factory.d.ts +1 -1
  58. package/backend/dist/harness/host/adapters/gemini-cli.d.ts +1 -1
  59. package/backend/dist/harness/host/adapters/grok.d.ts +1 -1
  60. package/backend/dist/harness/host/adapters/kimi.d.ts +1 -1
  61. package/backend/dist/harness/host/adapters/omp.d.ts +1 -1
  62. package/backend/dist/harness/host/adapters/openclaw.d.ts +1 -1
  63. package/backend/dist/harness/host/adapters/opencode.d.ts +1 -1
  64. package/backend/dist/harness/host/adapters/pi.d.ts +1 -1
  65. package/backend/dist/harness/host/adapters/universal.d.ts +1 -1
  66. package/backend/dist/harness/host/adapters/windsurf.d.ts +1 -1
  67. package/backend/dist/harness/host/adapters/zed.d.ts +1 -1
  68. package/backend/dist/harness/skill/skills-sh.d.ts +1 -1
  69. package/backend/dist/harness/translation.js +64 -21
  70. package/backend/dist/harness/types.d.ts +1 -1
  71. package/backend/dist/harness/types.js +1 -1
  72. package/backend/dist/index.js +31 -18
  73. package/backend/dist/ir/adapters/anthropic-stream.d.ts +18 -0
  74. package/backend/dist/ir/adapters/anthropic-stream.js +247 -0
  75. package/backend/dist/ir/adapters/anthropic.d.ts +29 -0
  76. package/backend/dist/ir/adapters/anthropic.js +788 -0
  77. package/backend/dist/ir/adapters/chat.d.ts +15 -0
  78. package/backend/dist/ir/adapters/chat.js +602 -0
  79. package/backend/dist/ir/adapters/google-stream.d.ts +22 -0
  80. package/backend/dist/ir/adapters/google-stream.js +242 -0
  81. package/backend/dist/ir/adapters/google.d.ts +9 -0
  82. package/backend/dist/ir/adapters/google.js +317 -0
  83. package/backend/dist/ir/adapters/openai-responses-output.js +8 -5
  84. package/backend/dist/ir/adapters/openai-responses.d.ts +15 -0
  85. package/backend/dist/ir/adapters/openai-responses.js +26 -1
  86. package/backend/dist/ir/adapters/responses-output.d.ts +50 -0
  87. package/backend/dist/ir/adapters/responses-output.js +348 -0
  88. package/backend/dist/ir/adapters/responses-stream.d.ts +12 -0
  89. package/backend/dist/ir/adapters/responses-stream.js +178 -0
  90. package/backend/dist/ir/adapters/responses.d.ts +14 -0
  91. package/backend/dist/ir/adapters/responses.js +646 -0
  92. package/backend/dist/ir/errors.d.ts +2 -2
  93. package/backend/dist/ir/types.d.ts +2 -1
  94. package/backend/dist/metrics/request-cost.d.ts +11 -2
  95. package/backend/dist/metrics/request-cost.js +12 -3
  96. package/backend/dist/observability/request-identity.d.ts +1 -1
  97. package/backend/dist/observability/trace-id.d.ts +40 -0
  98. package/backend/dist/observability/trace-id.js +134 -0
  99. package/backend/dist/observability/upstream-events.d.ts +82 -60
  100. package/backend/dist/observability/upstream-events.js +142 -67
  101. package/backend/dist/opencode/catalog/types.d.ts +9 -0
  102. package/backend/dist/opencode/credentials/types.d.ts +2 -2
  103. package/backend/dist/opencode/probe.d.ts +24 -1
  104. package/backend/dist/opencode/probe.js +28 -4
  105. package/backend/dist/opencode/user-config.d.ts +5 -0
  106. package/backend/dist/pipeline/directives.d.ts +6 -2
  107. package/backend/dist/pipeline/directives.js +7 -3
  108. package/backend/dist/pipeline/orchestrator.d.ts +28 -27
  109. package/backend/dist/pipeline/orchestrator.js +220 -194
  110. package/backend/dist/pipeline/unresolved-model.d.ts +33 -0
  111. package/backend/dist/pipeline/unresolved-model.js +43 -0
  112. package/backend/dist/plugins/catalog-def.d.ts +143 -0
  113. package/backend/dist/plugins/catalog-def.js +177 -0
  114. package/backend/dist/plugins/gateways.d.ts +62 -3
  115. package/backend/dist/plugins/gateways.js +139 -2
  116. package/backend/dist/plugins/host.d.ts +42 -5
  117. package/backend/dist/plugins/host.js +454 -38
  118. package/backend/dist/plugins/manifest.d.ts +119 -10
  119. package/backend/dist/plugins/manifest.js +265 -14
  120. package/backend/dist/plugins/pack.js +26 -0
  121. package/backend/dist/plugins/types.d.ts +187 -21
  122. package/backend/dist/protocols/systemone/convert.d.ts +1 -0
  123. package/backend/dist/protocols/systemone/convert.js +6 -1
  124. package/backend/dist/protocols/systemone/decide.js +18 -8
  125. package/backend/dist/providers/anthropic-messages.d.ts +12 -0
  126. package/backend/dist/providers/anthropic-messages.js +53 -0
  127. package/backend/dist/providers/anthropic.d.ts +7 -8
  128. package/backend/dist/providers/anthropic.js +36 -324
  129. package/backend/dist/providers/base.d.ts +14 -2
  130. package/backend/dist/providers/boot-direct.js +68 -38
  131. package/backend/dist/providers/dispatch.d.ts +5 -19
  132. package/backend/dist/providers/dispatch.js +46 -58
  133. package/backend/dist/providers/executors/anthropic-messages.d.ts +1 -0
  134. package/backend/dist/providers/executors/anthropic-messages.js +3 -0
  135. package/backend/dist/providers/executors/dispatch.d.ts +16 -2
  136. package/backend/dist/providers/executors/dispatch.js +39 -9
  137. package/backend/dist/providers/executors/google-gemini.d.ts +1 -0
  138. package/backend/dist/providers/executors/google-gemini.js +3 -0
  139. package/backend/dist/providers/executors/http-stream.js +16 -3
  140. package/backend/dist/providers/executors/openai-chat.d.ts +1 -0
  141. package/backend/dist/providers/executors/openai-chat.js +3 -0
  142. package/backend/dist/providers/executors/openai-responses.d.ts +1 -0
  143. package/backend/dist/providers/executors/openai-responses.js +3 -0
  144. package/backend/dist/providers/executors/plugin-adapter.js +4 -4
  145. package/backend/dist/providers/google-gemini.d.ts +12 -0
  146. package/backend/dist/providers/google-gemini.js +50 -0
  147. package/backend/dist/providers/google.d.ts +7 -8
  148. package/backend/dist/providers/google.js +35 -308
  149. package/backend/dist/providers/http-json.d.ts +19 -0
  150. package/backend/dist/providers/http-json.js +104 -0
  151. package/backend/dist/providers/http-stream.d.ts +52 -0
  152. package/backend/dist/providers/http-stream.js +423 -0
  153. package/backend/dist/providers/member-match.d.ts +4 -5
  154. package/backend/dist/providers/member-match.js +4 -5
  155. package/backend/dist/providers/openai-chat.d.ts +13 -0
  156. package/backend/dist/providers/openai-chat.js +99 -0
  157. package/backend/dist/providers/openai-compatible.d.ts +7 -4
  158. package/backend/dist/providers/openai-compatible.js +71 -368
  159. package/backend/dist/providers/openai-responses.d.ts +12 -0
  160. package/backend/dist/providers/openai-responses.js +68 -0
  161. package/backend/dist/providers/opencode-proxy.d.ts +5 -5
  162. package/backend/dist/providers/opencode-proxy.js +49 -125
  163. package/backend/dist/providers/plugin-adapter.d.ts +9 -0
  164. package/backend/dist/providers/plugin-adapter.js +31 -0
  165. package/backend/dist/providers/registry.d.ts +49 -24
  166. package/backend/dist/providers/registry.js +97 -55
  167. package/backend/dist/providers/responses.d.ts +7 -28
  168. package/backend/dist/providers/responses.js +45 -253
  169. package/backend/dist/providers/tool-markup-leak.d.ts +41 -0
  170. package/backend/dist/providers/tool-markup-leak.js +57 -0
  171. package/backend/dist/providers/tool-markup-recovery.d.ts +27 -0
  172. package/backend/dist/providers/tool-markup-recovery.js +786 -0
  173. package/backend/dist/providers/virtual-meta.d.ts +21 -2
  174. package/backend/dist/providers/virtual-meta.js +49 -9
  175. package/backend/dist/proxy/asset-download.d.ts +54 -0
  176. package/backend/dist/proxy/asset-download.js +420 -0
  177. package/backend/dist/proxy/manual-node-spec.d.ts +16 -16
  178. package/backend/dist/proxy/mihomo-binary.d.ts +17 -2
  179. package/backend/dist/proxy/mihomo-binary.js +62 -51
  180. package/backend/dist/proxy/mihomo-client.js +15 -1
  181. package/backend/dist/proxy/mihomo-config.js +11 -2
  182. package/backend/dist/proxy/mihomo-geo.d.ts +87 -0
  183. package/backend/dist/proxy/mihomo-geo.js +213 -0
  184. package/backend/dist/proxy/mihomo-logs.d.ts +27 -0
  185. package/backend/dist/proxy/mihomo-logs.js +70 -0
  186. package/backend/dist/proxy/mihomo-pac.d.ts +11 -0
  187. package/backend/dist/proxy/mihomo-pac.js +15 -0
  188. package/backend/dist/proxy/mihomo-rules-import.d.ts +1 -1
  189. package/backend/dist/proxy/mihomo-rules-import.js +7 -7
  190. package/backend/dist/proxy/mihomo-sidecar.d.ts +17 -1
  191. package/backend/dist/proxy/mihomo-sidecar.js +148 -26
  192. package/backend/dist/quota/adapters/minimax.js +36 -13
  193. package/backend/dist/quota/cli-login.d.ts +8 -0
  194. package/backend/dist/quota/cli-login.js +18 -0
  195. package/backend/dist/quota/declarations.js +10 -0
  196. package/backend/dist/quota/dsl.js +18 -5
  197. package/backend/dist/quota/engine.d.ts +22 -1
  198. package/backend/dist/quota/engine.js +170 -29
  199. package/backend/dist/quota/prober.d.ts +5 -0
  200. package/backend/dist/quota/prober.js +11 -2
  201. package/backend/dist/quota/types.d.ts +87 -8
  202. package/backend/dist/quota/verdict.d.ts +35 -0
  203. package/backend/dist/quota/verdict.js +135 -0
  204. package/backend/dist/ratelimit/admission.d.ts +131 -0
  205. package/backend/dist/ratelimit/admission.js +233 -0
  206. package/backend/dist/ratelimit/rate-limiter.js +6 -0
  207. package/backend/dist/resilience/types.d.ts +2 -2
  208. package/backend/dist/router/layer2-decision.d.ts +1 -1
  209. package/backend/dist/router/layer2-decision.js +5 -8
  210. package/backend/dist/routes/console.js +248 -52
  211. package/backend/dist/routes/mihomo.d.ts +2 -0
  212. package/backend/dist/routes/mihomo.js +334 -29
  213. package/backend/dist/routes/responses.d.ts +87 -8
  214. package/backend/dist/routes/responses.js +314 -33
  215. package/backend/dist/server.js +34 -6
  216. package/backend/dist/session/session-manager.d.ts +6 -0
  217. package/backend/dist/session/session-manager.js +20 -9
  218. package/backend/dist/surfaces/chat-pipeline.d.ts +2 -2
  219. package/backend/dist/surfaces/chat-pipeline.js +17 -7
  220. package/backend/dist/surfaces/chat.js +15 -0
  221. package/backend/dist/surfaces/decision-pipeline.js +7 -10
  222. package/backend/dist/surfaces/direct-forward.d.ts +3 -0
  223. package/backend/dist/surfaces/direct-forward.js +206 -0
  224. package/backend/dist/surfaces/rate-limit-response.d.ts +17 -0
  225. package/backend/dist/surfaces/rate-limit-response.js +57 -0
  226. package/backend/dist/surfaces/types.d.ts +11 -0
  227. package/backend/dist/trace/tracker.d.ts +32 -1
  228. package/backend/dist/trace/tracker.js +29 -4
  229. package/backend/dist/types/router.d.ts +34 -12
  230. package/backend/dist/types/router.js +35 -6
  231. package/backend/dist/utils/chat-stream.d.ts +21 -8
  232. package/backend/dist/utils/chat-stream.js +46 -9
  233. package/backend/dist/utils/event-ring.d.ts +4 -0
  234. package/backend/dist/utils/event-ring.js +4 -0
  235. package/backend/dist/utils/popularity.js +29 -4
  236. package/backend/dist/utils/proxy.d.ts +7 -0
  237. package/backend/dist/utils/proxy.js +35 -10
  238. package/backend/dist/utils/retry-after.d.ts +21 -0
  239. package/backend/dist/utils/retry-after.js +36 -0
  240. package/bin/ocr.js +2 -2
  241. package/frontend/dist/assets/index-55VVwfFQ.js +1521 -0
  242. package/frontend/dist/assets/{index-CQSLGFTV.css → index-DxZ9MHKB.css} +1 -1
  243. package/frontend/dist/assets/workbuddy.color-DOMpQkxJ.svg +29 -0
  244. package/frontend/dist/index.html +2 -2
  245. package/package.json +1 -1
  246. package/frontend/dist/assets/index-CLvxJjp_.js +0 -1476
@@ -1,15 +1,15 @@
1
1
  export type CliAction = 'start' | 'stop' | 'restart' | 'status' | 'web' | 'ui' | 'desktop' | 'setup' | 'teardown' | 'install-shims' | 'uninstall-shims'
2
2
  /** Machine-readable shim state for the desktop tray toggle (JSON + exit code). */
3
3
  | 'shims-status' | 'env' | 'version' | 'help';
4
- /** Every client id the console and CLI can ADDRESS: the hooks this build ships
5
- * plus the documented package hooks (`cursor-proxy`, `qoder-proxy`,
6
- * `jetbrains-proxy`, `opencode-gateway` — their adapters arrive with the
7
- * package, see ADR-0030). Listing an id here claims nothing about where it
8
- * lives; `CORE_ADAPTERS` is the build's own set. */
9
- export type SupportedClient = 'opencode' | 'opencode-gateway' | 'claude' | 'codex' | 'pi' | 'dsh' | 'omp' | 'grok' | 'kimi' | 'openclaw' | 'workbuddy' | 'cursor-proxy' | 'qoder-proxy' | 'jetbrains-proxy';
4
+ /** Client ids have NO core vocabulary beyond the hooks this build ships
5
+ * (`CoreClientId`, `cli/clients/reserved.ts`): package hooks arrive with
6
+ * their adapters and register any string id at runtime (ADR-0027). Core code
7
+ * must never string-reference a package client id — presentation text,
8
+ * roster rank and hook exclusivity are declared by the package (manifest
9
+ * `clientText` / `clientRank`, `ClientAdapter.exclusiveWith`). */
10
10
  export interface CliOptions {
11
11
  action: CliAction;
12
- client?: SupportedClient;
12
+ client?: string;
13
13
  port?: number;
14
14
  host?: string;
15
15
  daemon?: boolean;
@@ -35,7 +35,7 @@ export interface DaemonInfo {
35
35
  * inbound proxy. */
36
36
  export type ClientHookKind = 'config' | 'launcher' | 'service-env' | 'proxy-config';
37
37
  export interface ClientHookStatus {
38
- name: SupportedClient;
38
+ name: string;
39
39
  displayName: string;
40
40
  /** Where the hook lands, stamped by the registry from `ClientAdapter.hookKind`
41
41
  * (`getStatus` does not produce it). */
@@ -59,6 +59,9 @@ export interface ClientHookStatus {
59
59
  /** Passthrough launch verbs this hook publishes (`['cursor','cursor-agent']`)
60
60
  * — the console renders `ocr <verb>`; absent = nothing to launch. */
61
61
  launch?: string[];
62
+ /** Retired spellings of `launch` verbs (`ClientLaunchVerb.aliases`): the CLI
63
+ * refuses them by name, so a copyable `ocr …` hint must never use one. */
64
+ launchAliases?: string[];
62
65
  configPath: string;
63
66
  exists: boolean;
64
67
  hooked: boolean;
@@ -75,6 +78,15 @@ export interface ClientHookStatus {
75
78
  modelSlots: ClientModelSlot[];
76
79
  /** Extra concrete models exposed in the client's model switcher (opencode provider models list) */
77
80
  extraModels?: string[];
81
+ /**
82
+ * Client-owned model ids this hook OBSERVED at runtime. A client that
83
+ * compiles its model table into its binary publishes the list only in its
84
+ * own catalog read, so traffic is the one place it can be learned. The
85
+ * console OFFERS these ids where an operator must name one (a mapping row's
86
+ * left side); it never injects entries into the client's list. Absent =
87
+ * nothing observed yet.
88
+ */
89
+ catalogIds?: string[];
78
90
  /** Additional files this adapter owns beyond `configPath` — Cursor publishes
79
91
  * a second launcher for the `cursor-agent` CLI. `exists` is probed at status
80
92
  * time so the console can list every artifact without a second round-trip.
@@ -84,6 +96,15 @@ export interface ClientHookStatus {
84
96
  * each with its own takeover state. Absent for single-product adapters —
85
97
  * the console then renders the card row exactly as before. */
86
98
  products?: ClientProductStatus[];
99
+ /** Last time an inference request was fingerprinted to this client's UA
100
+ * (ms epoch; the auth gate's in-memory activity ledger). Absent = no
101
+ * observed traffic since boot. Display-only sort key — never routing
102
+ * state; the CLI roster table ignores it. */
103
+ lastActiveAt?: number;
104
+ /** Last time `setupClient()` hooked this client successfully (ms epoch).
105
+ * The sort fallback while a client has sent no traffic yet; absent = not
106
+ * hooked this boot. */
107
+ lastSetupAt?: number;
87
108
  }
88
109
  /**
89
110
  * One product instance inside a FAMILY adapter — one installed JetBrains IDE,
@@ -10,7 +10,7 @@
10
10
  * - the style never names or explains itself;
11
11
  * - the user's dominant language is preserved (except wenyan levels).
12
12
  */
13
- export declare const CAVEMAN_LEVELS: readonly ['lite', 'full', 'ultra', 'wenyan-lite', 'wenyan', 'wenyan-ultra'];
13
+ export declare const CAVEMAN_LEVELS: readonly ["lite", "full", "ultra", "wenyan-lite", "wenyan", "wenyan-ultra"];
14
14
  export type CavemanLevel = (typeof CAVEMAN_LEVELS)[number];
15
15
  export declare const CAVEMAN_PROMPTS: Record<CavemanLevel, string>;
16
16
  export declare function isCavemanLevel(level: unknown): level is CavemanLevel;
@@ -33,16 +33,10 @@ export const YAML_FIELD_COMMENTS_EN = {
33
33
  'webAuth.enabled': 'Console login switch: true requires the credential password; MUST be true when binding 0.0.0.0 / a LAN IP (the gateway refuses to boot otherwise); only a 127.0.0.1 binding may disable it',
34
34
  'webAuth.username': 'Console login username',
35
35
  'webAuth.passwordHash': 'scrypt hash of the login password (format scrypt$<saltHex>$<hashHex>, never plaintext; change it on the console "System Settings" page — do not hand-write)',
36
- tiers: 'Tier membership policy: the ONLY source of candidate pools = each tier\'s explicit members list + the global exclude list. Factory default is four EMPTY tiers (no built-in member globs, no runtime seeding) — on first boot every pool is empty and `auto` cannot route; add members on the console /tiers page or here. Models matching no rule are unclassified and join no pool; the selection strategy only affects in-pool usage (visual editing on /tiers, applies on save; deleting the whole tiers section restores these empty defaults on next load)',
36
+ tiers: 'Tier membership policy: the ONLY source of candidate pools = each tier\'s explicit members list + the global exclude list. Factory default is four EMPTY tiers (no built-in member globs, no runtime seeding) — on first boot every pool is empty and `auto` cannot route; add members on the console /tiers page or here. A model no rule matches has no tier and joins no pool; the selection strategy only affects in-pool usage (visual editing on /tiers, applies on save; deleting the whole tiers section restores these empty defaults on next load)',
37
37
  'tiers.*.members': 'Member list (order = priority / failover chain): entries { pattern, weight?, effortMap? } — pattern matches the FULL model id (provider/model) as a glob (* any chars / ? one char, case-insensitive); no wildcard = substring match; a full id = single item. A pattern may also reference a combo via combo:<comboId> — expanded in place to that combo\'s registered members on every submit/save (the tier pool follows combo edits; weight from the combo member entry; a dead reference = unknown/disabled/no-registered-members combo, expands to empty with a save-time warning). effortMap = thinking-level translation (e.g. { none: high, low: high }; unconfigured levels pass through unchanged); effortMap on a combo reference applies to all its expanded members. The same model/combo may join several tiers — membership is computed per tier with that tier\'s own chain order / weight / effortMap',
38
38
  'tiers.exclude': 'Global exclude list (edited on the raw-YAML page; the /tiers page round-trips it verbatim): matching models join NO candidate pool (unconditional; still callable directly by id or via combos)',
39
39
  'tiers.*.selection': 'Primary-pick strategy: priority / weighted random / round_robin',
40
- 'tiers.*.match': '【Match-suggestion engine only】Never routes, no longer generates member lists: powers model-catalog recommendations, /tiers preview and save-time checks. The candidate pool\'s only source is the members list above (factory default empty, no built-in globs) — add/remove members on the console /tiers page (applies on save)',
41
- 'tiers.*.match.patterns': '【Match-suggestion engine only】Name globs',
42
- 'tiers.*.match.minInputPerM': '【Match-suggestion engine only】Input price floor $/M',
43
- 'tiers.*.match.maxInputPerM': '【Match-suggestion engine only】Input price ceiling $/M',
44
- 'tiers.*.match.exclude': '【Match-suggestion engine only】Name/price veto (the tier emits no suggestion when matched)',
45
- 'tiers.*.match.excludeTiers': '【Match-suggestion engine only】Anchored exclusion (a hit on the referenced tier\'s conditions vetoes)',
46
40
  'routing.mode': 'Routing strategy: smart = classifier cascade (default) / cost = always lite / quality = always pro',
47
41
  fallback: 'Final fallback: after retries are exhausted, escalate a tier and retry',
48
42
  'fallback.maxRetries': 'Fallback retry count',
@@ -153,10 +147,10 @@ export const YAML_FIELD_COMMENTS_EN = {
153
147
  'quotaProbes.*': 'That provider\'s probe entry array (key = provider id, e.g. my-gateway); each entry is one window table: windows { form: static|each|eachObject, path?, window|windows, plan? } — field extraction { path | header | literal, firstOf?, scale?, invertOf?, time? }; any two of used/total/remaining derive the third; where limited to exists/equals/∈; name nameSpec { from, enumMap, fallback } or a pure-interpolation template ({field}); successIf single-equality',
154
148
  opencode: 'OpenCode local-service connection',
155
149
  proxy: 'Outbound proxy policy (applies on save, no restart; governs upstream model calls / the L2 decision layer / catalog & logo sync; localhost/127.0.0.1 is NEVER proxied). mode manual uses url; mode mihomo sends traffic to the local Clash core mixed-port (ADR-0022)',
156
- 'proxy.enabled': 'Outbound proxy master switch (default false; true activates the selected mode plus include/exclude rules)',
157
- 'proxy.mode': 'Endpoint mode (default manual): manual uses proxy.url; mihomo routes every proxied call through the gateway-managed Clash core at http://127.0.0.1:<mixedPort>. includes/excludes and the loopback bypass apply in both modes. An omitted mode stays manual, so older files keep their behavior. Hot-applies on save; the sidecar starts when enabled and mode is mihomo',
150
+ 'proxy.enabled': 'Outbound proxy master switch (default false). ON only arms the allowlist below — it never routes traffic by itself: with an empty includes list every upstream call is direct',
151
+ 'proxy.mode': 'Endpoint mode (default manual): manual uses proxy.url; mihomo routes every proxied call through the gateway-managed Clash core at http://127.0.0.1:<mixedPort>. includes/excludes and the loopback bypass apply in both modes. An omitted mode stays manual, so older files keep their behavior. Hot-applies on save; the sidecar follows proxy.mihomo.autoStart (absent = enabled && mode is mihomo), and a started core is a child of the gateway',
158
152
  'proxy.url': 'Manual-mode proxy URL, http(s)://[user:pass@]host:port — embed credentials before the @ (sent as Proxy-Authorization, CONNECT included; URL-encode special chars); empty = direct. Ignored while mode is mihomo',
159
- 'proxy.includes': 'Include rules (globs): non-empty = ONLY matching models/providers go through the proxy; patterns match the provider/model composite and the bare model id — anthropic/* is provider level, */claude-* or claude-* is model level',
153
+ 'proxy.includes': 'Include rules (globs) = the ALLOWLIST: only a matching model/provider goes through the proxy, so an EMPTY list proxies nothing (every upstream call is direct, the master switch alone never routes traffic). Patterns match the provider/model composite and the bare model id — anthropic/* is provider level, */claude-* or claude-* is model level',
160
154
  'proxy.excludes': 'Exclude rules (globs): matches force direct; evaluated before includes (an exclude hit = direct, the rest filter through includes)',
161
155
  'proxy.mihomo': 'Built-in Clash core (mihomo, i.e. Clash.Meta). Outbound traffic uses it only when proxy.mode is mihomo, but the core itself runs independently (see autoStart). The generated config, pid and provider cache live under <env>/mihomo/. The controller listens on 127.0.0.1 only',
162
156
  'proxy.mihomo.enabled': 'Mirrors mode === mihomo after load. Setting this true with mode omitted selects mihomo mode; an explicit mode: manual wins',
@@ -165,7 +159,7 @@ export const YAML_FIELD_COMMENTS_EN = {
165
159
  'proxy.mihomo.mixedPort': 'Loopback mixed-port (HTTP + SOCKS) the gateway uses as its outbound proxy (default 7890). Must differ from controllerPort',
166
160
  'proxy.mihomo.controllerPort': 'Loopback external-controller port (default 9090). The gateway calls it with Authorization: Bearer <controllerSecret>. This port is loopback, so proxy rules never send those calls back through the mixed-port',
167
161
  'proxy.mihomo.controllerSecret': 'Bearer secret for the external controller. Empty until the first start, which generates one and saves it. Redacted in environment archives. Never logged',
168
- 'proxy.mihomo.subscriptions': 'Subscription list { id, name, url, interval?, enabled? }. id is the proxy-provider name inside the core ([A-Za-z0-9_-], max 64). interval is seconds (default 3600, clamp 300..86400). url may carry a token — redacted in archives, never logged. Disabled rows are omitted from the generated config',
162
+ 'proxy.mihomo.subscriptions': 'Subscription list { id, name, url, interval?, proxy?, enabled? }. id is the proxy-provider name inside the core ([A-Za-z0-9_-], max 64). interval is seconds (default 3600, clamp 300..86400). proxy names the node or group the core downloads this subscription through (DIRECT or a proxy name); empty follows the rule set, which is direct until a working node exists — a subscription host the local network blocks needs a reachable node here. url may carry a token — redacted in archives, never logged. Disabled rows are omitted from the generated config',
169
163
  'proxy.mihomo.manualNodes': 'Hand-authored nodes rendered into the generated proxies: block and added to the group beside provider members. A typed row is { id, name, type, server, port } plus that protocol\'s fields: ss → cipher/password; vmess → uuid/alterId/network/tls/sni/wsPath/wsHost; vless → uuid/network/tls/sni/flow/wsPath/wsHost; trojan/hysteria2 → password/sni/skipCertVerify; http/socks5 → username/password/tls/skipCertVerify. A row authored from pasted YAML carries { id, name, type, server, port, yaml } where yaml is the canonical Clash proxy mapping and is emitted verbatim, so client-fingerprint / reality-opts / plugin keys survive. A row missing its identity is dropped on load. Credentials (and any raw yaml mapping) are redacted in environment archives, never logged',
170
164
  'proxy.mihomo.routingMode': "the core's own outbound mode: 'rule' (default), 'global' or 'direct'. With an empty rules list the generated config injects a single MATCH rule, so 'rule' and 'global' behave the same today; 'direct' bypasses the tunnel entirely (a kill switch that keeps subscriptions updating). Changing it in the console hot-applies through the controller — no core restart",
171
165
  'proxy.mihomo.selectedGroup': 'Selector group name written into the generated config (default PROXY). All outbound HTTP traffic that reaches the core uses this group (MATCH rule)',
@@ -173,7 +167,7 @@ export const YAML_FIELD_COMMENTS_EN = {
173
167
  'proxy.mihomo.groupInterval': 'Delay-test cadence in seconds for automatic groups. The cadence IS the failure-detection window: a dead member keeps serving until the next cycle, so the default is 60 (the core itself defaults to 300), clamped to 30..86400. Raising it saves test traffic; lowering it shortens the worst-case failover wait',
174
168
  'proxy.mihomo.groupTolerance': 'url-test only: how much faster (ms) a candidate must be before the group switches. Default 50, clamped to 0..5000',
175
169
  'proxy.mihomo.testUrl': 'Health-check / delay-test URL (http or https, no embedded credentials). Default https://www.gstatic.com/generate_204, the same 204 endpoint the core itself uses; change it when that endpoint is unreachable from this machine or through the nodes (e.g. a mainland-China network). The console offers Google 204 / Google / Cloudflare / OpenAI / Anthropic / Gemini presets but the field is free text and applies to saved nodes before the next test',
176
- 'proxy.mihomo.rules': 'Operator-authored rules, evaluated IN ORDER before the final MATCH (first match wins). Each row is { type, payload, target }: type is one of DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD, IP-CIDR, IP-CIDR6, DST-PORT, SRC-PORT, PROCESS-NAME, PROCESS-PATH — the types the core can evaluate without a geo database or an external rule-set fetch, so GEOIP / GEOSITE / RULE-SET are dropped on load; target is PROXY / DIRECT / REJECT, where PROXY resolves to selectedGroup at render time. A payload containing a comma or newline is dropped. Saving from the console reconciles the core onto the new config; keep the list short — this is a routing override, not a rule-set store',
170
+ 'proxy.mihomo.rules': 'Operator-authored rules, evaluated IN ORDER before the final MATCH (first match wins). Each row is { type, payload, target }: type is one of DOMAIN, DOMAIN-SUFFIX, DOMAIN-KEYWORD, IP-CIDR, IP-CIDR6, GEOIP, GEOSITE, DST-PORT, SRC-PORT, PROCESS-NAME, PROCESS-PATH. GEOIP / GEOSITE are evaluated from the Clash panel\'s downloaded geo databases — the core will not start with such a row while they are missing — while RULE-SET is dropped on load (it fetches a remote document). target is PROXY / DIRECT / REJECT, where PROXY resolves to selectedGroup at render time. A payload containing a comma or newline is dropped. Left absent, the shipped LAN/loopback direct baseline is seeded; an explicit list (even empty) is authoritative. Saving from the console reconciles the core onto the new config; keep the list short — this is a routing override, not a rule-set store',
177
171
  'proxy.mihomo.selectedNodes': 'Map of group name → node name. Restored through the external controller after each start so a restart comes back on the same node',
178
172
  forwardProxy: 'Inbound forward proxy (the HTTP_PROXY/HTTPS_PROXY server): the rules table decides per host whether the connection is decrypted and where the bytes exit (loopback is always direct + passthrough). Decryption follows capability, not a blanket default — plugin-claimed hosts and explicit `ingress: intercept` rows are decrypted, everything else is a blind tunnel unless `intercept: all` turns on the audit posture (see `forwardProxy.intercept`). Decrypted LLM-protocol traffic (chat/messages/responses) enters the routing pipeline, everything else is transparently forwarded; clients whose traffic IS decrypted must trust the exported CA (restart required)',
179
173
  'forwardProxy.enabled': 'Inbound proxy master switch (default false)',
@@ -18,16 +18,10 @@ export const YAML_FIELD_COMMENTS_ZH = {
18
18
  'webAuth.enabled': '控制台登录开关:true 需凭证密码登录;绑定 0.0.0.0 / 局域网 IP 时必须为 true(否则网关拒绝启动),仅 127.0.0.1 绑定可关闭',
19
19
  'webAuth.username': '控制台登录用户名',
20
20
  'webAuth.passwordHash': '登录密码的 scrypt 哈希(格式 scrypt$<saltHex>$<hashHex>,绝不存明文;在控制台「系统设置」页修改,勿手写)',
21
- tiers: '梯队成员策略:候选池唯一依据 = 各梯队显式 members 成员列表 + 全局排除名单;出厂默认为四个空梯队(不内置任何成员 glob,运行时也不自动生成种子),首次启动所有候选池为空、`auto` 无法路由,需在控制台 /tiers 页或本文件添加 members;无任何规则命中的模型=未分类,不进任何池;主选策略只影响池内用法(控制台 /tiers 页可视化编辑,保存即时生效;删除整个 tiers 段会在下次加载时恢复这套空默认)',
21
+ tiers: '梯队成员策略:候选池唯一依据 = 各梯队显式 members 成员列表 + 全局排除名单;出厂默认为四个空梯队(不内置任何成员 glob,运行时也不自动生成种子),首次启动所有候选池为空、`auto` 无法路由,需在控制台 /tiers 页或本文件添加 members;无任何规则命中的模型=无梯队归属,不进任何池;主选策略只影响池内用法(控制台 /tiers 页可视化编辑,保存即时生效;删除整个 tiers 段会在下次加载时恢复这套空默认)',
22
22
  'tiers.*.members': '成员列表(顺序=优先级/failover 链):每项 { pattern, weight?, effortMap? } —— pattern 匹配完整模型 id(provider/model),glob 通配(* 任意 / ? 单字符,不区分大小写),不带通配符=子串匹配、写完整 id=单项;pattern 亦可写 combo:<组合id> 引用模型组合——每次提交/保存时原位展开为该组合已注册成员(组合编辑后梯队池自动跟随;权重取自组合成员条目;死引用=组合不存在/已停用/无已注册成员,展开为空并在保存检查告警);effortMap=思考级别翻译(如 { none: high, low: high },未配置的级别原样透传),组合引用上的 effortMap 作用于其全部展开成员;同一模型/组合可加入多个梯队——各梯队成员资格独立计算,链序/权重/effortMap 均取自本梯队自己的规则',
23
23
  'tiers.exclude': '全局排除名单(在原始 YAML 页编辑;/tiers 页保存时原样回传):命中的模型不进入任何梯队候选池(无条件;仅可按 id 直连或经组合调用)',
24
24
  'tiers.*.selection': '主选策略:priority 优先级 / weighted 加权随机 / round_robin 轮询',
25
- 'tiers.*.match': '【仅匹配建议引擎】不参与路由、不再生成成员列表:用于模型目录页推荐、/tiers 页预览与保存时检查;候选池唯一依据是上方 members(出厂默认为空,无内置 glob),请在控制台 /tiers 页增删成员(保存即时生效)',
26
- 'tiers.*.match.patterns': '【仅匹配建议引擎】名称通配符(glob)',
27
- 'tiers.*.match.minInputPerM': '【仅匹配建议引擎】输入价下限 $/M',
28
- 'tiers.*.match.maxInputPerM': '【仅匹配建议引擎】输入价上限 $/M',
29
- 'tiers.*.match.exclude': '【仅匹配建议引擎】名称/价格否决(不给出该梯队建议)',
30
- 'tiers.*.match.excludeTiers': '【仅匹配建议引擎】锚定排除(被引梯队的条件命中即否决)',
31
25
  'routing.mode': '路由模式:smart=分类级联(默认)/ cost=始终 lite / quality=始终 pro',
32
26
  fallback: '失败兜底:重试耗尽后按梯队升级重试',
33
27
  'fallback.maxRetries': '兜底重试次数',
@@ -138,10 +132,10 @@ export const YAML_FIELD_COMMENTS_ZH = {
138
132
  'quotaProbes.*': '该 provider 的探测条目数组(键=provider id,如 my-gateway);每条目一张窗口表:windows { form: static|each|eachObject, path?, window|windows, plan? } —— 字段抽取 { path | header | literal, firstOf?, scale?, invertOf?, time? };used/total/remaining 任二者可推第三;where 仅限存在/相等/∈ 三谓词;名称 nameSpec { from, enumMap, fallback } 或 template 纯插值({field});successIf 单等值',
139
133
  opencode: 'OpenCode 本地服务连接',
140
134
  proxy: '出站代理策略(保存后即时生效,无需重启;作用于上游模型调用 / Layer2 判定 / 目录与 logo 同步;localhost/127.0.0.1 永不走代理)。mode 为 manual 时使用 url;mode 为 mihomo 时流量进入本机 Clash 核心的混合端口(ADR-0022)',
141
- 'proxy.enabled': '出站代理总开关(默认 false 不启用;true 时按所选 mode 与包含/排除规则出站)',
142
- 'proxy.mode': '端点模式(默认 manual):manual 使用 proxy.url;mihomo 把所有走代理的调用送到网关托管的 Clash 核心(http://127.0.0.1:<mixedPort>)。两种模式都保留 includes/excludes 与 loopback 绕过。未写 mode 的旧文件保持 manual。保存即生效;enabled 且 mode 为 mihomo 时会拉起 sidecar',
135
+ 'proxy.enabled': '出站代理总开关(默认 false 不启用)。打开只是启用下面的白名单本身,并不会让流量走代理:includes 为空时所有上游调用一律直连',
136
+ 'proxy.mode': '端点模式(默认 manual):manual 使用 proxy.url;mihomo 把所有走代理的调用送到网关托管的 Clash 核心(http://127.0.0.1:<mixedPort>)。两种模式都保留 includes/excludes 与 loopback 绕过。未写 mode 的旧文件保持 manual。保存即生效;核心是否运行由 proxy.mihomo.autoStart 决定(缺省 = enabled 且 mode 为 mihomo),被拉起的核心随网关退出而结束',
143
137
  'proxy.url': 'manual 模式的代理 URL,http(s)://[user:pass@]host:port —— 需要鉴权时把用户名:密码嵌在 @ 前(自动转为 Proxy-Authorization,含 HTTPS CONNECT 隧道;特殊字符需 URL 编码);留空 = 直连。mode 为 mihomo 时忽略此项',
144
- 'proxy.includes': '包含规则(glob):非空时仅命中者走代理;pattern 匹配 provider/model 组合与模型 id —— anthropic/* 为 provider 级,*/claude-* 或 claude-* 为模型级',
138
+ 'proxy.includes': '包含规则(glob)= 白名单:只有命中的 provider/model 才走代理,列表为空则一律直连(总开关本身不会让流量走代理)。pattern 匹配 provider/model 组合与模型 id —— anthropic/* 为 provider 级,*/claude-* 或 claude-* 为模型级',
145
139
  'proxy.excludes': '排除规则(glob):命中者强制直连;与 includes 同设时先执行(excludes 命中 = 直连,其余再按 includes 过滤)',
146
140
  'proxy.mihomo': '内置 Clash 核心(mihomo,即 Clash.Meta)。出站仅在 proxy.mode 为 mihomo 时使用它,但核心本身独立运行(见 autoStart)。生成的配置、pid 与订阅缓存位于 <env>/mihomo/。控制器只监听 127.0.0.1',
147
141
  'proxy.mihomo.enabled': '加载后与 mode === mihomo 对齐。未写 mode 但此项为 true 时按 mihomo 模式读取;显式 mode: manual 优先',
@@ -150,7 +144,7 @@ export const YAML_FIELD_COMMENTS_ZH = {
150
144
  'proxy.mihomo.mixedPort': '网关作为出站代理使用的本机混合端口(HTTP + SOCKS,默认 7890),只绑 127.0.0.1。必须与 controllerPort 不同',
151
145
  'proxy.mihomo.controllerPort': '本机 External Controller 端口(默认 9090)。网关用 Authorization: Bearer <controllerSecret> 调用它。该端口在 loopback 上,代理规则不会把这些调用再送回混合端口',
152
146
  'proxy.mihomo.controllerSecret': 'External Controller 的 Bearer 密钥。首次启动前为空,启动时生成并写回。环境归档会脱敏。绝不写入日志',
153
- 'proxy.mihomo.subscriptions': '订阅列表 { id, name, url, interval?, enabled? }。id 即核心内 proxy-provider 名称([A-Za-z0-9_-],最长 64)。interval 单位为秒(默认 3600,钳制 300..86400)。url 可能含令牌——归档脱敏,绝不记日志。enabled 为 false 的行不写入生成的配置',
147
+ 'proxy.mihomo.subscriptions': '订阅列表 { id, name, url, interval?, proxy?, enabled? }。id 即核心内 proxy-provider 名称([A-Za-z0-9_-],最长 64)。interval 单位为秒(默认 3600,钳制 300..86400)。proxy 指定核心拉取该订阅时使用的节点或分组名(DIRECT 或代理名);留空则按规则走,没有可用节点时即直连——本机网络阻断的订阅站点需要在这里填一个可达节点。url 可能含令牌——归档脱敏,绝不记日志。enabled 为 false 的行不写入生成的配置',
154
148
  'proxy.mihomo.manualNodes': '手动添加的节点,写入生成配置的 proxies: 段并与订阅节点一起加入策略组。表单录入的行是 { id, name, type, server, port } 加上该协议的字段:ss → cipher/password;vmess → uuid/alterId/network/tls/sni/wsPath/wsHost;vless → uuid/network/tls/sni/flow/wsPath/wsHost;trojan/hysteria2 → password/sni/skipCertVerify;http/socks5 → username/password/tls/skipCertVerify。YAML 录入的行带 { id, name, type, server, port, yaml },yaml 是规范化后的 Clash 代理定义并原样输出,因此 client-fingerprint / reality-opts / 插件键都会保留。缺少身份字段(白名单协议还要求凭据字段)的行在加载时被丢弃;与内建名或所选分组重名的行同样丢弃。凭据(以及整段原始 yaml)在环境归档中脱敏,绝不写入日志',
155
149
  'proxy.mihomo.routingMode': "核心自身的出站模式:'rule'(默认)/ 'global' / 'direct'。规则列表为空时生成的配置只注入一条 MATCH 规则,因此此时 'rule' 与 'global' 等价;'direct' 完全绕过隧道(相当于保留订阅更新的「断流开关」)。控制台修改后经控制器热生效,不重启核心",
156
150
  'proxy.mihomo.selectedGroup': '写入生成配置的选择器策略组名(默认 PROXY)。到达核心的出站 HTTP 流量都走这个组(MATCH 规则)',
@@ -158,7 +152,7 @@ export const YAML_FIELD_COMMENTS_ZH = {
158
152
  'proxy.mihomo.groupInterval': '自动分组的测速间隔(秒)。这个间隔就是故障检测窗口:失效的成员在下一轮测试前仍会继续承载流量,因此默认 60(核心自身默认 300),取值 30..86400。调大省测速流量,调小缩短最坏切换等待',
159
153
  'proxy.mihomo.groupTolerance': '仅 url-test:候选节点必须快出多少毫秒才会切换。默认 50,取值 0..5000',
160
154
  'proxy.mihomo.testUrl': '健康检查 / 测速地址(http 或 https,不能内嵌账号密码)。默认 https://www.gstatic.com/generate_204,即核心自身使用的 204 地址;当该地址在本机或经过节点不可达时(例如中国大陆网络)改掉它。控制台提供 Google 204 / Google / Cloudflare / OpenAI / Anthropic / Gemini 预设,但输入框可自由填写,保存后下一次测速即生效',
161
- 'proxy.mihomo.rules': '操作者自定义规则,按顺序在最后的 MATCH 之前求值(先匹配先赢)。每行 { type, payload, target }:type 限 DOMAIN / DOMAIN-SUFFIX / DOMAIN-KEYWORD / IP-CIDR / IP-CIDR6 / DST-PORT / SRC-PORT / PROCESS-NAME / PROCESS-PATH——即核心不需要地理数据库或外部规则集就能求值的类型,GEOIP / GEOSITE / RULE-SET 在加载时被丢弃;target 为 PROXY / DIRECT / REJECT,其中 PROXY 在渲染时解析为 selectedGroup。匹配内容含逗号或换行会被丢弃。控制台保存后核心按新配置生效;这个列表是路由覆盖,不是规则集仓库,保持简短',
155
+ 'proxy.mihomo.rules': '操作者自定义规则,按顺序在最后的 MATCH 之前求值(先匹配先赢)。每行 { type, payload, target }:type 限 DOMAIN / DOMAIN-SUFFIX / DOMAIN-KEYWORD / IP-CIDR / IP-CIDR6 / GEOIP / GEOSITE / DST-PORT / SRC-PORT / PROCESS-NAME / PROCESS-PATH。GEOIP / GEOSITE 由 Clash 面板下载的 geo 库求值——缺库时核心不会带这类规则启动;RULE-SET 仍会在加载时被丢弃(它要在线拉取规则集)。target 为 PROXY / DIRECT / REJECT,其中 PROXY 在渲染时解析为 selectedGroup。匹配内容含逗号或换行会被丢弃。缺省(未写过该键)时自动种入内置的局域网/回环直连基线;显式列表(哪怕是空列表)即为准。控制台保存后核心按新配置生效;这个列表是路由覆盖,不是规则集仓库,保持简短',
162
156
  'proxy.mihomo.selectedNodes': '策略组名 → 节点名。每次启动后通过 External Controller 恢复,重启后仍停在同一节点',
163
157
  forwardProxy: '入站前向代理(HTTP_PROXY/HTTPS_PROXY 服务端):rules 规则表逐主机决定这条连接要不要解密、字节从哪里出去(loopback 永远直连 + 透传)。解密跟随能力声明而非一刀切的默认:网关插件声明的主机与显式写了 `ingress: intercept` 的行才解密,其余一律盲隧道——除非用 `intercept: all` 打开审计姿态(见 `forwardProxy.intercept`)。被解密的 LLM 协议流量(chat/messages/responses)走路由管线,其余透明转发;流量被解密的客户端需信任导出的 CA(重启网关生效)',
164
158
  'forwardProxy.enabled': '入站代理总开关(默认 false)',
@@ -1,5 +1,5 @@
1
1
  import type { ReasoningEffort } from '../types/router.js';
2
- import type { ForwardProxyRule, InterceptPosture } from './types.js';
2
+ import type { ForwardProxyRule, InterceptPosture, MihomoCustomRule } from './types.js';
3
3
  /**
4
4
  * Single source of truth for magic defaults that previously lived as
5
5
  * independently-declared literals in multiple modules (config defaults,
@@ -71,6 +71,16 @@ export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
71
71
  * `circuitBreaker.activeProbing` stays off by default for exactly that reason.
72
72
  */
73
73
  export declare const DEFAULT_PROBE_TIMEOUT_MS = 30000;
74
+ /**
75
+ * One quota probe's wall clock (the DSL runner, code adapters, and the
76
+ * plugin-host seam when the operator left `quotaProbes.settings.timeoutMs`
77
+ * unset). Shorter than the capability probe above: quota is a meter read on a
78
+ * key we already hold, and the cadence — not this number — decides whether a
79
+ * slow vendor is worth waiting for. Every failed attempt keeps the previous
80
+ * values and marks them stale, so a timeout costs a stale badge, never a
81
+ * missing number.
82
+ */
83
+ export declare const DEFAULT_QUOTA_PROBE_TIMEOUT_MS = 10000;
74
84
  /** Forward-proxy listen port when `forwardProxy.port` is unset. */
75
85
  export declare const DEFAULT_FORWARD_PROXY_PORT = 4555;
76
86
  /** Forward-proxy listen host when `forwardProxy.host` is unset (loopback only). */
@@ -108,6 +118,21 @@ export declare const DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS = 7;
108
118
  * persistence is on, so the default costs no captured bytes.
109
119
  */
110
120
  export declare const DEFAULT_PROXY_ACCESS_LOG_BODY_BYTES = 1048576;
121
+ /**
122
+ * Traffic feed display windows. TWO numbers, two different costs:
123
+ * - DISSECT — the per-side prefix the read path hands the plugin dissector.
124
+ * The route allocates only `min(fileSize, window)` per side, so the cost
125
+ * tracks the bodies actually on disk (most rows are kilobytes), not the
126
+ * window itself; 256 KiB is the compromise between protocol visibility and
127
+ * the per-row read the 500-row tail pays on every poll.
128
+ * - BODY PREVIEW — the most the console renders of a body it loads through
129
+ * the opaque token. Paid once, on drawer open, and the row payload never
130
+ * carries it, so it can be generous (1 MiB — the proxy log's inline budget).
131
+ * Bodies beyond either window are one download away
132
+ * (`/api/admin/traffic-body/:token`).
133
+ */
134
+ export declare const DEFAULT_TRAFFIC_DISSECT_WINDOW_BYTES = 262144;
135
+ export declare const DEFAULT_TRAFFIC_BODY_PREVIEW_BYTES = 1048576;
111
136
  /** Day-file retention clamp bounds (config input is clamped into this range). */
112
137
  export declare const PROXY_ACCESS_LOG_PERSIST_DAYS_MIN = 1;
113
138
  export declare const PROXY_ACCESS_LOG_PERSIST_DAYS_MAX = 365;
@@ -167,6 +192,36 @@ export declare const MIHOMO_GROUP_TOLERANCE_MAX_MS = 5000;
167
192
  * reachable everywhere).
168
193
  */
169
194
  export declare const DEFAULT_MIHOMO_TEST_URL = "https://www.gstatic.com/generate_204";
195
+ /**
196
+ * Baseline direct rules shipped with the generated Clash config (ADR-0022):
197
+ * loopback, RFC1918, CGNAT, link-local and the IPv6 ULA / link-local ranges
198
+ * must never enter the tunnel. They are the only direct defaults the gateway
199
+ * can guarantee without a geo database — `GEOIP`/`GEOSITE` rows need downloaded
200
+ * data files and are offered as an explicit console preset instead.
201
+ *
202
+ * Seeded into `proxy.mihomo.rules` only while that key is absent. Once the
203
+ * operator touches the list (including deleting every row) the saved list is
204
+ * authoritative and the defaults never come back on their own.
205
+ */
206
+ export declare const MIHOMO_LAN_DIRECT_RULES: MihomoCustomRule[];
207
+ /**
208
+ * One-click "CN direct" preset, inserted only when the operator asks for it
209
+ * (ADR-0022). Deliberately NOT a default: the core's rules apply to EVERY
210
+ * client of the mixed port, including forward-proxy rows whose `egress` is
211
+ * `proxy`, so a blanket domestic-bypass rule would silently leak traffic the
212
+ * operator explicitly routed through the exit.
213
+ *
214
+ * Both rows need the geo databases; the download is an explicit console action
215
+ * and the core refuses to start with these rows before the files exist.
216
+ */
217
+ export declare const MIHOMO_CN_DIRECT_RULES: MihomoCustomRule[];
218
+ /**
219
+ * Age at which the console marks the installed geo databases stale and
220
+ * suggests a re-sync (ADR-0022). Advisory only: nothing refetches on its own
221
+ * and a core with older data still starts — the operator's sync is the only
222
+ * thing that moves the files.
223
+ */
224
+ export declare const MIHOMO_GEO_STALE_DAYS = 30;
170
225
  /**
171
226
  * TCP reachability probe budget for the console's add-node dialog (ms). This
172
227
  * is a connect() deadline, not a delay measurement: the node is not in the
@@ -69,6 +69,16 @@ export const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300_000;
69
69
  * `circuitBreaker.activeProbing` stays off by default for exactly that reason.
70
70
  */
71
71
  export const DEFAULT_PROBE_TIMEOUT_MS = 30_000;
72
+ /**
73
+ * One quota probe's wall clock (the DSL runner, code adapters, and the
74
+ * plugin-host seam when the operator left `quotaProbes.settings.timeoutMs`
75
+ * unset). Shorter than the capability probe above: quota is a meter read on a
76
+ * key we already hold, and the cadence — not this number — decides whether a
77
+ * slow vendor is worth waiting for. Every failed attempt keeps the previous
78
+ * values and marks them stale, so a timeout costs a stale badge, never a
79
+ * missing number.
80
+ */
81
+ export const DEFAULT_QUOTA_PROBE_TIMEOUT_MS = 10_000;
72
82
  /** Forward-proxy listen port when `forwardProxy.port` is unset. */
73
83
  export const DEFAULT_FORWARD_PROXY_PORT = 4555;
74
84
  /** Forward-proxy listen host when `forwardProxy.host` is unset (loopback only). */
@@ -108,6 +118,21 @@ export const DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS = 7;
108
118
  * persistence is on, so the default costs no captured bytes.
109
119
  */
110
120
  export const DEFAULT_PROXY_ACCESS_LOG_BODY_BYTES = 1_048_576;
121
+ /**
122
+ * Traffic feed display windows. TWO numbers, two different costs:
123
+ * - DISSECT — the per-side prefix the read path hands the plugin dissector.
124
+ * The route allocates only `min(fileSize, window)` per side, so the cost
125
+ * tracks the bodies actually on disk (most rows are kilobytes), not the
126
+ * window itself; 256 KiB is the compromise between protocol visibility and
127
+ * the per-row read the 500-row tail pays on every poll.
128
+ * - BODY PREVIEW — the most the console renders of a body it loads through
129
+ * the opaque token. Paid once, on drawer open, and the row payload never
130
+ * carries it, so it can be generous (1 MiB — the proxy log's inline budget).
131
+ * Bodies beyond either window are one download away
132
+ * (`/api/admin/traffic-body/:token`).
133
+ */
134
+ export const DEFAULT_TRAFFIC_DISSECT_WINDOW_BYTES = 262_144;
135
+ export const DEFAULT_TRAFFIC_BODY_PREVIEW_BYTES = 1_048_576;
111
136
  /** Day-file retention clamp bounds (config input is clamped into this range). */
112
137
  export const PROXY_ACCESS_LOG_PERSIST_DAYS_MIN = 1;
113
138
  export const PROXY_ACCESS_LOG_PERSIST_DAYS_MAX = 365;
@@ -167,6 +192,49 @@ export const MIHOMO_GROUP_TOLERANCE_MAX_MS = 5000;
167
192
  * reachable everywhere).
168
193
  */
169
194
  export const DEFAULT_MIHOMO_TEST_URL = 'https://www.gstatic.com/generate_204';
195
+ /**
196
+ * Baseline direct rules shipped with the generated Clash config (ADR-0022):
197
+ * loopback, RFC1918, CGNAT, link-local and the IPv6 ULA / link-local ranges
198
+ * must never enter the tunnel. They are the only direct defaults the gateway
199
+ * can guarantee without a geo database — `GEOIP`/`GEOSITE` rows need downloaded
200
+ * data files and are offered as an explicit console preset instead.
201
+ *
202
+ * Seeded into `proxy.mihomo.rules` only while that key is absent. Once the
203
+ * operator touches the list (including deleting every row) the saved list is
204
+ * authoritative and the defaults never come back on their own.
205
+ */
206
+ export const MIHOMO_LAN_DIRECT_RULES = [
207
+ { type: 'IP-CIDR', payload: '127.0.0.0/8', target: 'DIRECT', source: 'default' },
208
+ { type: 'IP-CIDR', payload: '10.0.0.0/8', target: 'DIRECT', source: 'default' },
209
+ { type: 'IP-CIDR', payload: '172.16.0.0/12', target: 'DIRECT', source: 'default' },
210
+ { type: 'IP-CIDR', payload: '192.168.0.0/16', target: 'DIRECT', source: 'default' },
211
+ { type: 'IP-CIDR', payload: '169.254.0.0/16', target: 'DIRECT', source: 'default' },
212
+ { type: 'IP-CIDR', payload: '100.64.0.0/10', target: 'DIRECT', source: 'default' },
213
+ { type: 'IP-CIDR6', payload: '::1/128', target: 'DIRECT', source: 'default' },
214
+ { type: 'IP-CIDR6', payload: 'fc00::/7', target: 'DIRECT', source: 'default' },
215
+ { type: 'IP-CIDR6', payload: 'fe80::/10', target: 'DIRECT', source: 'default' },
216
+ ];
217
+ /**
218
+ * One-click "CN direct" preset, inserted only when the operator asks for it
219
+ * (ADR-0022). Deliberately NOT a default: the core's rules apply to EVERY
220
+ * client of the mixed port, including forward-proxy rows whose `egress` is
221
+ * `proxy`, so a blanket domestic-bypass rule would silently leak traffic the
222
+ * operator explicitly routed through the exit.
223
+ *
224
+ * Both rows need the geo databases; the download is an explicit console action
225
+ * and the core refuses to start with these rows before the files exist.
226
+ */
227
+ export const MIHOMO_CN_DIRECT_RULES = [
228
+ { type: 'GEOSITE', payload: 'cn', target: 'DIRECT', source: 'preset' },
229
+ { type: 'GEOIP', payload: 'CN', target: 'DIRECT', source: 'preset' },
230
+ ];
231
+ /**
232
+ * Age at which the console marks the installed geo databases stale and
233
+ * suggests a re-sync (ADR-0022). Advisory only: nothing refetches on its own
234
+ * and a core with older data still starts — the operator's sync is the only
235
+ * thing that moves the files.
236
+ */
237
+ export const MIHOMO_GEO_STALE_DAYS = 30;
170
238
  /**
171
239
  * TCP reachability probe budget for the console's add-node dialog (ms). This
172
240
  * is a connect() deadline, not a delay measurement: the node is not in the
@@ -46,8 +46,15 @@ export declare function sanitizeWebAuthInput(input: unknown): WebAuthConfig | un
46
46
  */
47
47
  export declare function resolveRateLimit(parsed: any): RateLimitConfig;
48
48
  /** The one rule-type whitelist: the sanitizer validates against it, the
49
- * subscription importer maps against it, and the console offers exactly it. */
50
- export declare const MIHOMO_CUSTOM_RULE_TYPES: readonly ['DOMAIN', 'DOMAIN-SUFFIX', 'DOMAIN-KEYWORD', 'IP-CIDR', 'IP-CIDR6', 'DST-PORT', 'SRC-PORT', 'PROCESS-NAME', 'PROCESS-PATH'];
49
+ * subscription importer maps against it, and the console offers exactly it.
50
+ *
51
+ * `GEOIP` / `GEOSITE` are allowed because mihomo evaluates them from data
52
+ * files it can use offline once present. They are NOT data-free like the
53
+ * other types: the core exits fatally when the data is missing, so the geo
54
+ * files are an explicit download and both the rule save and the core start
55
+ * refuse a geo-rule config without them (ADR-0022). `RULE-SET` stays out: it
56
+ * fetches a remote document at load time, which cannot be made offline-safe. */
57
+ export declare const MIHOMO_CUSTOM_RULE_TYPES: readonly ["DOMAIN", "DOMAIN-SUFFIX", "DOMAIN-KEYWORD", "IP-CIDR", "IP-CIDR6", "GEOIP", "GEOSITE", "DST-PORT", "SRC-PORT", "PROCESS-NAME", "PROCESS-PATH"];
51
58
  export declare const MIHOMO_CUSTOM_RULES_MAX = 256;
52
59
  export declare function sanitizeProxyConfig(raw: unknown): ProxyConfig;
53
60
  /**
@@ -8,7 +8,7 @@ import { EFFORT_LADDER } from '../types/router.js';
8
8
  import { resolveDirectivePrefix } from '../pipeline/directives.js';
9
9
  import { missingNodeCredential, sanitizeTypedNode } from '../proxy/manual-node-spec.js';
10
10
  import { ensureEnvScaffold, getEnvPaths, resolveEnvName } from './env.js';
11
- import { DEFAULT_FORWARD_PROXY_PORT, DEFAULT_FORWARD_PROXY_HOST, DEFAULT_FORWARD_PROXY_MAX_CONNECTIONS, DEFAULT_FORWARD_PROXY_RULES, DEFAULT_FORWARD_PROXY_INTERCEPT, FORWARD_PROXY_MAX_CONNECTIONS_MIN, FORWARD_PROXY_MAX_CONNECTIONS_MAX, DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS, PROXY_ACCESS_LOG_PERSIST_DAYS_MIN, PROXY_ACCESS_LOG_PERSIST_DAYS_MAX, DEFAULT_HEADROOM_TIMEOUT_MS, DEFAULT_DIRECTIVE_PREFIX, DEFAULT_HEADROOM_URL, DEFAULT_LAYER2_EFFORT_FLOOR, DEFAULT_LAYER2_TIMEOUT_MS, DEFAULT_MAX_BODY_BYTES, DEFAULT_ROUTE_ENTRIES_MAX, DEFAULT_GATEWAY_PORT, DEFAULT_MIHOMO_CONTROLLER_PORT, DEFAULT_MIHOMO_GROUP, DEFAULT_MIHOMO_MIXED_PORT, DEFAULT_MIHOMO_SUB_INTERVAL_SEC, MIHOMO_SUB_INTERVAL_MAX_SEC, MIHOMO_SUB_INTERVAL_MIN_SEC, MIHOMO_GROUP_INTERVAL_MAX_SEC, MIHOMO_GROUP_INTERVAL_MIN_SEC, DEFAULT_MIHOMO_GROUP_TOLERANCE_MS, MIHOMO_GROUP_TOLERANCE_MAX_MS, DEFAULT_MIHOMO_TEST_URL, } from './defaults.js';
11
+ import { DEFAULT_FORWARD_PROXY_PORT, DEFAULT_FORWARD_PROXY_HOST, DEFAULT_FORWARD_PROXY_MAX_CONNECTIONS, DEFAULT_FORWARD_PROXY_RULES, DEFAULT_FORWARD_PROXY_INTERCEPT, FORWARD_PROXY_MAX_CONNECTIONS_MIN, FORWARD_PROXY_MAX_CONNECTIONS_MAX, DEFAULT_PROXY_ACCESS_LOG_PERSIST_DAYS, PROXY_ACCESS_LOG_PERSIST_DAYS_MIN, PROXY_ACCESS_LOG_PERSIST_DAYS_MAX, DEFAULT_HEADROOM_TIMEOUT_MS, DEFAULT_DIRECTIVE_PREFIX, DEFAULT_HEADROOM_URL, DEFAULT_LAYER2_EFFORT_FLOOR, DEFAULT_LAYER2_TIMEOUT_MS, DEFAULT_MAX_BODY_BYTES, DEFAULT_ROUTE_ENTRIES_MAX, DEFAULT_GATEWAY_PORT, DEFAULT_MIHOMO_CONTROLLER_PORT, DEFAULT_MIHOMO_GROUP, DEFAULT_MIHOMO_MIXED_PORT, DEFAULT_MIHOMO_SUB_INTERVAL_SEC, MIHOMO_SUB_INTERVAL_MAX_SEC, MIHOMO_SUB_INTERVAL_MIN_SEC, MIHOMO_GROUP_INTERVAL_MAX_SEC, MIHOMO_GROUP_INTERVAL_MIN_SEC, DEFAULT_MIHOMO_GROUP_TOLERANCE_MS, MIHOMO_GROUP_TOLERANCE_MAX_MS, DEFAULT_MIHOMO_TEST_URL, MIHOMO_LAN_DIRECT_RULES, } from './defaults.js';
12
12
  import { getRateLimiter } from '../ratelimit/rate-limiter.js';
13
13
  import { getQuotaProber } from '../quota/prober.js';
14
14
  import { migrateConfig, toDiskConfig, toRuntimeConfig, SCHEMA_VERSION } from './schema.js';
@@ -663,10 +663,18 @@ const CUSTOM_RULE_PAYLOAD_MAX = 512;
663
663
  /** Longest provenance label kept on a rule (a name, not a document). */
664
664
  const CUSTOM_RULE_SOURCE_MAX = 40;
665
665
  /** The one rule-type whitelist: the sanitizer validates against it, the
666
- * subscription importer maps against it, and the console offers exactly it. */
666
+ * subscription importer maps against it, and the console offers exactly it.
667
+ *
668
+ * `GEOIP` / `GEOSITE` are allowed because mihomo evaluates them from data
669
+ * files it can use offline once present. They are NOT data-free like the
670
+ * other types: the core exits fatally when the data is missing, so the geo
671
+ * files are an explicit download and both the rule save and the core start
672
+ * refuse a geo-rule config without them (ADR-0022). `RULE-SET` stays out: it
673
+ * fetches a remote document at load time, which cannot be made offline-safe. */
667
674
  export const MIHOMO_CUSTOM_RULE_TYPES = [
668
675
  'DOMAIN', 'DOMAIN-SUFFIX', 'DOMAIN-KEYWORD',
669
676
  'IP-CIDR', 'IP-CIDR6',
677
+ 'GEOIP', 'GEOSITE',
670
678
  'DST-PORT', 'SRC-PORT',
671
679
  'PROCESS-NAME', 'PROCESS-PATH',
672
680
  ];
@@ -682,6 +690,11 @@ const CUSTOM_RULE_TARGETS = new Set(['PROXY', 'DIRECT', 'REJECT']);
682
690
  * document. Unknown types are DROPPED rather than passed through — mihomo's
683
691
  * behaviour with a rule it cannot evaluate is either a hard load failure or a
684
692
  * silent fallthrough, and an operator cannot debug either from the console.
693
+ *
694
+ * `GEOIP`/`GEOSITE` survive the whitelist but their DATA does not: the save
695
+ * route and the sidecar both refuse a geo-rule config while the geo files are
696
+ * missing (ADR-0022), so a valid row can never reach a core that would exit on
697
+ * it.
685
698
  */
686
699
  function sanitizeCustomRules(raw) {
687
700
  if (!Array.isArray(raw))
@@ -743,11 +756,16 @@ function sanitizeSubscriptions(raw) {
743
756
  if (typeof rec.interval === 'number' && Number.isFinite(rec.interval)) {
744
757
  interval = Math.min(MIHOMO_SUB_INTERVAL_MAX_SEC, Math.max(MIHOMO_SUB_INTERVAL_MIN_SEC, Math.round(rec.interval)));
745
758
  }
759
+ // A free-form mihomo name (`DIRECT`, a node, or the generated group). Not
760
+ // checked against the live proxy table: existence is a runtime fact and a
761
+ // stale name must not block the file from loading.
762
+ const proxy = typeof rec.proxy === 'string' ? rec.proxy.trim().slice(0, 80) : '';
746
763
  out.push({
747
764
  id,
748
765
  name: name.slice(0, 80),
749
766
  url,
750
767
  interval,
768
+ ...(proxy ? { proxy } : {}),
751
769
  enabled: rec.enabled !== false,
752
770
  });
753
771
  }
@@ -949,7 +967,12 @@ export function sanitizeProxyConfig(raw) {
949
967
  groupType,
950
968
  groupInterval,
951
969
  groupTolerance,
952
- rules: sanitizeCustomRules(mihomoRaw.rules),
970
+ // Seeded only while the key is ABSENT (never configured). An explicit list
971
+ // — including the empty one the console writes after deleting every row —
972
+ // is authoritative, so a deleted default never comes back on the next read.
973
+ rules: mihomoRaw.rules === undefined
974
+ ? MIHOMO_LAN_DIRECT_RULES.map((rule) => ({ ...rule }))
975
+ : sanitizeCustomRules(mihomoRaw.rules),
953
976
  selectedNodes,
954
977
  };
955
978
  return {