dsh-autotier 0.1.0
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/AGENTS.md +93 -0
- package/CHANGELOG.md +85 -0
- package/LICENSE +201 -0
- package/README.es.md +247 -0
- package/README.hi.md +241 -0
- package/README.md +245 -0
- package/README.pt.md +246 -0
- package/README.zh.md +221 -0
- package/SECURITY.md +55 -0
- package/THIRD_PARTY_NOTICES.md +63 -0
- package/cordis.patch.yml +125 -0
- package/docs/preset-row.md +61 -0
- package/docs/supporting-lanes.md +45 -0
- package/lib/index.js +2848 -0
- package/lib/types/command.d.ts +17 -0
- package/lib/types/command.d.ts.map +1 -0
- package/lib/types/config.d.ts +94 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/guard-rules.d.ts +97 -0
- package/lib/types/guard-rules.d.ts.map +1 -0
- package/lib/types/guard.d.ts +70 -0
- package/lib/types/guard.d.ts.map +1 -0
- package/lib/types/index.d.ts +60 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/intent.d.ts +179 -0
- package/lib/types/intent.d.ts.map +1 -0
- package/lib/types/judge.d.ts +50 -0
- package/lib/types/judge.d.ts.map +1 -0
- package/lib/types/policy.d.ts +109 -0
- package/lib/types/policy.d.ts.map +1 -0
- package/lib/types/routing.d.ts +135 -0
- package/lib/types/routing.d.ts.map +1 -0
- package/lib/types/schema.d.ts +134 -0
- package/lib/types/schema.d.ts.map +1 -0
- package/lib/types/service.d.ts +67 -0
- package/lib/types/service.d.ts.map +1 -0
- package/lib/types/state.d.ts +46 -0
- package/lib/types/state.d.ts.map +1 -0
- package/lib/types/tiers.d.ts +103 -0
- package/lib/types/tiers.d.ts.map +1 -0
- package/lib/types/tools.d.ts +26 -0
- package/lib/types/tools.d.ts.map +1 -0
- package/lib/types/types.d.ts +96 -0
- package/lib/types/types.d.ts.map +1 -0
- package/package.json +179 -0
- package/src/command.ts +73 -0
- package/src/config.ts +358 -0
- package/src/guard-rules.ts +303 -0
- package/src/guard.ts +285 -0
- package/src/index.ts +149 -0
- package/src/intent.ts +484 -0
- package/src/judge.ts +150 -0
- package/src/policy.ts +246 -0
- package/src/routing.ts +575 -0
- package/src/schema.ts +295 -0
- package/src/service.ts +131 -0
- package/src/state.ts +134 -0
- package/src/tiers.ts +212 -0
- package/src/tools.ts +128 -0
- package/src/types.ts +120 -0
package/README.hi.md
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# dsh-autotier
|
|
2
|
+
|
|
3
|
+
DeepSeek Harness के लिए स्वचालित मॉडल-स्तर रूटिंग: एक उपयोगकर्ता निर्देश अंदर
|
|
4
|
+
आता है, एक स्तर-निर्णय बाहर आता है — मॉडल हाथ से बदलने की ज़रूरत नहीं।
|
|
5
|
+
|
|
6
|
+
जटिल आशय (आर्किटेक्चर, योजना, डिबगिंग, बहु-चरण इंजीनियरिंग) को पहले
|
|
7
|
+
**strong** स्तर पर योजना बनाई जाती है, फिर **cheap** स्तर पर लागू किया जाता है।
|
|
8
|
+
सरल आशय (प्रश्न, पुनर्प्राप्ति, बैच कार्य, दैनिक काम) सीधे **cheap** स्तर पर
|
|
9
|
+
डिज़ाइन और कार्यान्वित होता है। cheap स्तर के निष्पादन के दौरान उच्च-जोखिम
|
|
10
|
+
टूल कॉल को एक नियतात्मक गार्ड अस्वीकार करता है, और बार-बार विफलता पर TTL
|
|
11
|
+
के साथ strong स्तर पर वृद्धि होती है।
|
|
12
|
+
|
|
13
|
+
- **आधिकारिक रिपॉज़िटरी**: <https://github.com/PerryLink/dsh-autotier>
|
|
14
|
+
- **npm**: `dsh-autotier` (सादा नाम, बिना scope)
|
|
15
|
+
|
|
16
|
+
## संगतता
|
|
17
|
+
|
|
18
|
+
| Harness | स्थिति |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `@deepseek-ai/dsh` `0.1.2-rc.1` | संगत (CI इसी की जाँच करता है और compat वर्कफ़्लो इसे इंस्टॉल करता है) |
|
|
21
|
+
| `0.1.5-alpha.1` (वर्तमान checkout लाइन) | इसके प्रकाशित type faces के विरुद्ध टाइप-जाँच; end-to-end smoke `0.1.2-rc.1` पर चलता है |
|
|
22
|
+
| `@deepseek-ai/cordis` `^4.0.2`, `@deepseek-ai/schemastery` `^3.18.2` | peer आधार |
|
|
23
|
+
|
|
24
|
+
यह प्लगइन केवल host plane पर रहता है और अपना preset नहीं माँगता: host पंक्ति
|
|
25
|
+
हर सत्र पर लागू होती है। *आपके* preset में एक प्रॉम्प्ट खंड वैकल्पिक है और
|
|
26
|
+
केवल मॉडल को निर्णय दिखाता है ([इंस्टॉल और अनइंस्टॉल](#इंस्टॉल-और-अनइंस्टॉल) देखें)।
|
|
27
|
+
|
|
28
|
+
## आपको क्या मिलता है
|
|
29
|
+
|
|
30
|
+
- **आशय द्वार** — हर turn को नियतात्मक संकेतों (संदेश पाठ, टूल नाम, चित्र की
|
|
31
|
+
उपस्थिति, संवाद की लंबाई) से वर्गीकृत किया जाता है। नियम-परत आत्मविश्वास होने
|
|
32
|
+
पर बिना token खर्च किए निर्णय लेती है; केवल कम-आत्मविश्वास वाला turn सस्ते
|
|
33
|
+
जज मॉडल को बुलाता है, और कभी cooldown के भीतर नहीं।
|
|
34
|
+
- **आधिकारिक seam पर लैंडिंग** — निर्णय `agent/request` waterfall पर बदली हुई
|
|
35
|
+
provider/model/effort तिकड़ी लौटाकर लागू होता है। सत्र द्वारा पहले से चुने गए
|
|
36
|
+
सैंपलिंग scalars (`temperature`, `maxTokens`, `stop`) सुरक्षित रहते हैं।
|
|
37
|
+
- **प्लान-मोड हैंडऑफ़** — जटिल निर्देश strong स्तर पर प्लान मोड में जाता है;
|
|
38
|
+
प्लान मोड छोड़ने पर कार्यान्वयन के लिए cheap स्तर पर लौट आता है।
|
|
39
|
+
- **उच्च-जोखिम गार्ड** — cheap निष्पादन के दौरान विनाशकारी कमांड (`rm -rf`,
|
|
40
|
+
`sudo`, `mkfs`, `git push --force`, क्रेडेंशियल फ़ाइल लेखन, …) को सुधारात्मक
|
|
41
|
+
संदेश के साथ अस्वीकार किया जाता है जो स्तर बढ़ाने को कहता है।
|
|
42
|
+
- **विफलता पर वृद्धि** — बार-बार विफलता (वैकल्पिक रूप से समान हस्ताक्षर पर)
|
|
43
|
+
TTL के लिए स्तर बढ़ाती है; मॉडल/मार्ग विफलता पर कॉन्फ़िगर की गई fallback
|
|
44
|
+
श्रृंखला चली जाती है।
|
|
45
|
+
- **मैनुअल एस्केप हैच** — `/tier auto|strong|cheap|off` और `tier_status` /
|
|
46
|
+
`tier_route` टूल। जिस सत्र को अपना मॉडल रखना है, उसके लिए
|
|
47
|
+
`routingMode: delegated` (या `/tier off`) रूटिंग बंद कर देता है।
|
|
48
|
+
- **`ctx.autotier` सेवा** — एक छोटा पठन-तल (`status`) तथा `autotier/route`
|
|
49
|
+
वीटो waterfall और `autotier/tier-changed` इवेंट, जिससे अन्य प्लगइन निर्णय
|
|
50
|
+
देख या रद्द कर सकें।
|
|
51
|
+
|
|
52
|
+
## त्वरित शुरुआत
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm i -g dsh1024
|
|
56
|
+
dsh1024 plugin --profile web add dsh-autotier
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
फिर harness शुरू करें (या पुनः आरंभ करें)। पंक्ति आपके
|
|
60
|
+
`cordis.patch.yml` में जुड़ जाती है; अगले turn से रूटिंग शुरू हो जाती है।
|
|
61
|
+
|
|
62
|
+
## इंस्टॉल और अनइंस्टॉल
|
|
63
|
+
|
|
64
|
+
**npm चैनल**
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npm i -g dsh1024
|
|
68
|
+
dsh1024 plugin --profile web add dsh-autotier
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**git चैनल**
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
git clone https://github.com/PerryLink/dsh-autotier.git
|
|
75
|
+
cd dsh-autotier && pnpm install && pnpm run build
|
|
76
|
+
dsh plugin --profile web add .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**वैकल्पिक preset प्रॉम्प्ट खंड।** इसके बिना भी राउटर काम करता है। मॉडल को यह
|
|
80
|
+
बताने के लिए कि वह किस स्तर पर चल रहा है, *अपने* preset में एक पंक्ति जोड़ें
|
|
81
|
+
(सटीक ब्लॉक `docs/preset-row.md` में है):
|
|
82
|
+
|
|
83
|
+
```yaml
|
|
84
|
+
- insert:
|
|
85
|
+
- id: autotier-prompt
|
|
86
|
+
name: '@deepseek-ai/dsh-system-prompt'
|
|
87
|
+
# sections: [...] — देखें docs/preset-row.md
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**अनइंस्टॉल**
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
dsh plugin --profile web remove dsh-autotier
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
पंक्ति, उसका settings namespace, उसका कमांड, उसके टूल और सभी listeners
|
|
97
|
+
प्लगइन के साथ हट जाते हैं; settings दस्तावेज़ के बाहर कुछ नहीं लिखा जाता।
|
|
98
|
+
|
|
99
|
+
## कॉन्फ़िगरेशन
|
|
100
|
+
|
|
101
|
+
हर कुंजी लोड के समय जाँची जाती है; अमान्य मान चुपचाप रूटिंग बंद करने के बजाय
|
|
102
|
+
ज़ोर से विफल होता है। इस रिपॉज़िटरी का `cordis.patch.yml` वही कुंजियाँ इनलाइन
|
|
103
|
+
दस्तावेज़ित करता है।
|
|
104
|
+
|
|
105
|
+
| कुंजी | डिफ़ॉल्ट | अर्थ |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| `tiers.strong.provider` | `deepseek-official` | योजना/समीक्षा स्तर का provider। |
|
|
108
|
+
| `tiers.strong.model` | `deepseek-v4-pro` | strong मॉडल की कैटलॉग id। |
|
|
109
|
+
| `tiers.strong.effort` | `high` | एडाप्टर शब्दावली `off` \| `low` \| `high` \| `max`। |
|
|
110
|
+
| `tiers.strong.followSession` | `false` | `false` = इस स्तर का effort सत्र के effort को ओवरराइड करता है। |
|
|
111
|
+
| `tiers.strong.fallback` | `[]` | स्तर अनुपलब्ध होने पर क्रमबद्ध provider/model लैंडिंग। |
|
|
112
|
+
| `tiers.cheap.provider` | `deepseek-official` | कार्यान्वयन स्तर का provider। |
|
|
113
|
+
| `tiers.cheap.model` | `deepseek-v4-flash` | cheap मॉडल की कैटलॉग id। |
|
|
114
|
+
| `tiers.cheap.effort` | `low` | एडाप्टर शब्दावली `off` \| `low` \| `high` \| `max`। |
|
|
115
|
+
| `tiers.cheap.followSession` | `true` | `true` = सत्र का effort विरासत में लें, जिससे स्पष्ट चयन जीते। |
|
|
116
|
+
| `tiers.cheap.fallback` | `[]` | स्तर अनुपलब्ध होने पर क्रमबद्ध provider/model लैंडिंग। |
|
|
117
|
+
| `tiers.vision.provider` | `deepseek-official` | चित्र वाले turn का provider। |
|
|
118
|
+
| `tiers.vision.model` | `deepseek-v4-flash-vision-exp` | कैटलॉग का एकमात्र image-सक्षम मॉडल। |
|
|
119
|
+
| `intent.ruleThreshold` | `0.7` | जिस आत्मविश्वास से नियम-परत अकेले निर्णय लेती है। |
|
|
120
|
+
| `intent.attemptBand.enabled` | `false` | मध्य पट्टी को cheap पर शुरू कर संकेत मिलने पर बढ़ाना। |
|
|
121
|
+
| `intent.attemptBand.tauLow` | `0.45` | attempt-first पट्टी की निचली सीमा। |
|
|
122
|
+
| `intent.hysteresis.toStrong` | `0.8` | वह स्कोर जो cheap turn को strong कर देता है। |
|
|
123
|
+
| `intent.hysteresis.toCheap` | `0.6` | जिस स्कोर से नीचे strong turn cheap पर लौटता है। |
|
|
124
|
+
| `intent.rules` | `[]` | घोषणात्मक नियम तालिका (`when.patterns` / `when.tools` / `when.cwd`, `tier`, `priority`)। |
|
|
125
|
+
| `intent.judge.enabled` | `true` | कम-आत्मविश्वास वाले जज की अनुमति। |
|
|
126
|
+
| `intent.judge.model` | `''` | जज मॉडल id; खाली = कैटलॉग का पहला `flash` वाला मॉडल। |
|
|
127
|
+
| `intent.judge.temperature` | `0` | जज सैंपलिंग तापमान। |
|
|
128
|
+
| `intent.judge.maxTokens` | `16` | जज आउटपुट सीमा (एक शब्द में उत्तर)। |
|
|
129
|
+
| `intent.judge.cooldownMs` | `30000` | दो जज कॉल के बीच न्यूनतम अंतर। |
|
|
130
|
+
| `intent.judge.timeoutMs` | `2000` | जज कॉल का समय-समाप्ति। |
|
|
131
|
+
| `intent.judge.unavailableSkip` | `2` | कितनी लगातार विफलताओं के बाद turn जज छोड़ दे। |
|
|
132
|
+
| `intent.scenarios` | सभी `true` | प्रति-परिदृश्य स्विच: `coding`, `review`, `planning`, `retrieval`, `batch`, `daily`, `longText`, `multimodal`। |
|
|
133
|
+
| `intent.costMode` | `balanced` | अस्पष्टता में निर्णय: `cost-first` \| `quality-first` \| `balanced`। |
|
|
134
|
+
| `guard.enabled` | `true` | नियतात्मक उच्च-जोखिम गार्ड सक्रिय करें। |
|
|
135
|
+
| `guard.tiers` | `[cheap]` | गार्ड किन स्तरों की रक्षा करता है। |
|
|
136
|
+
| `guard.whitelist` | `[]` | कमांड, टूल या पथ-उपसर्ग जो गार्ड को कभी नहीं छूते। |
|
|
137
|
+
| `guard.protectedPaths` | `['.dsh','AGENTS.md','package.json','.github/workflows']` | स्व-संशोधन सतहें जो strong समीक्षा ज़रूरी करती हैं। |
|
|
138
|
+
| `guard.interopDefend` | `auto` | `dsh-defend` से संबंध: `auto` सहअस्तित्व का ऑडिट, `none` शांत। |
|
|
139
|
+
| `escalation.threshold` | `2` | विंडो में इतनी विफलताओं पर स्तर बढ़ता है। |
|
|
140
|
+
| `escalation.windowMs` | `60000` | विफलता गिनती की विंडो। |
|
|
141
|
+
| `escalation.ttlMs` | `180000` | वृद्धि कितनी देर प्रभावी रहती है। |
|
|
142
|
+
| `escalation.fallbackTtlMs` | `300000` | fallback लैंडिंग लेने के बाद का TTL। |
|
|
143
|
+
| `escalation.signature` | `true` | हर विफलता के बजाय समान हस्ताक्षर की पुनरावृत्ति गिनें। |
|
|
144
|
+
| `routingMode` | `auto` | `auto` \| `strong` \| `cheap` \| `delegated` \| `off`। |
|
|
145
|
+
|
|
146
|
+
सभी कुंजियाँ `autotier` settings namespace (`$DSH_HOME/settings.yaml`) से
|
|
147
|
+
लाइव भी बदली जा सकती हैं; क्रॉस-फ़ील्ड शर्त तोड़ने वाला लेखन सहेजने के समय
|
|
148
|
+
अस्वीकार हो जाता है और अंतिम वैध नीति लागू रहती है।
|
|
149
|
+
|
|
150
|
+
## टूल और सतहें
|
|
151
|
+
|
|
152
|
+
| सतह | प्रकार | उद्देश्य |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| `/tier` | कमांड | `auto` \| `strong` \| `cheap` \| `off` \| `status`; सत्र-स्तरीय ओवरराइड। |
|
|
155
|
+
| `tier_status` | टूल | वर्तमान स्तर, मोड, वृद्धि TTL और गार्ड स्थिति। |
|
|
156
|
+
| `tier_route` | टूल | बिना अनुरोध भेजे किसी आशय का ड्राई-रन रूटिंग। |
|
|
157
|
+
| `ctx.autotier` | सेवा | अन्य प्लगइन के लिए `status()` पठन-तल। |
|
|
158
|
+
| `autotier/route` | serial इवेंट | तीसरे पक्ष प्रस्तावित स्तर को वीटो कर सकते हैं। |
|
|
159
|
+
| `autotier/tier-changed` | emit इवेंट | प्रभावी स्तर बदलने पर अवलोकनीयता। |
|
|
160
|
+
|
|
161
|
+
## अनुमतियाँ और डेटा
|
|
162
|
+
|
|
163
|
+
- **फ़ाइलें** — प्लगइन साझा settings सेवा (`autotier` namespace) के अलावा कुछ
|
|
164
|
+
नहीं पढ़ता या लिखता।
|
|
165
|
+
- **नेटवर्क** — एकमात्र आउटबाउंड ट्रैफ़िक जज कॉल है, जो सामान्य `ctx.llm` मार्ग
|
|
166
|
+
और कॉन्फ़िगर किए गए provider से जाता है।
|
|
167
|
+
- **सत्र लॉग** — प्लगइन कोई अपना सत्र इवेंट नहीं जोड़ता। रूटिंग का निशान प्लगइन
|
|
168
|
+
logger और लाइव `autotier/tier-changed` बस इवेंट है; एकमात्र जोड़ तब होता है जब
|
|
169
|
+
plan-mode सेवा अनुपलब्ध हो और `plan/mode` फ़ॉलबैक लिखा जाए। `0.1.2-alpha.1` से
|
|
170
|
+
अपने इवेंट प्रकार fail-closed हैं, इसलिए प्लगइन का कोई स्थायी रिकॉर्ड नहीं लिखा
|
|
171
|
+
जाता।
|
|
172
|
+
- **रहस्य** — यह प्लगइन कोई क्रेडेंशियल नहीं पढ़ता, दर्ज नहीं करता, संग्रह नहीं करता।
|
|
173
|
+
|
|
174
|
+
## सुरक्षा सीमाएँ
|
|
175
|
+
|
|
176
|
+
- गार्ड **गहन रक्षा** है, sandbox नहीं। यह cheap स्तर पर अपने ज्ञात पैटर्न
|
|
177
|
+
अस्वीकार करता है और `dsh-defend`, अनुमोदन सेवा या sandbox नीति को कभी कमज़ोर
|
|
178
|
+
नहीं करता। उन्हें सक्रिय रखें।
|
|
179
|
+
- गार्ड केवल `guard.tiers` में दिए स्तरों की रक्षा करता है (डिफ़ॉल्ट cheap)।
|
|
180
|
+
strong turn डिज़ाइन से अवरुद्ध नहीं होता: strong मॉडल स्वयं समीक्षक है।
|
|
181
|
+
- यदि गार्ड स्वयं त्रुटि दे, तो कॉल को अनुमति देने के बजाय strong पर बढ़ा दिया
|
|
182
|
+
जाता है — टूटा हुआ गार्ड खुला दरवाज़ा नहीं बनना चाहिए।
|
|
183
|
+
- `/tier off` रूटिंग पूरी तरह बंद कर देता है; harness ठीक वैसा ही व्यवहार करता
|
|
184
|
+
है जैसा प्लगइन लगाने से पहले था।
|
|
185
|
+
|
|
186
|
+
## ज्ञात सीमाएँ
|
|
187
|
+
|
|
188
|
+
- नियम-परत नियतात्मक है और इसलिए सीमित: किसी जटिल अनुरोध का नया वाक्य cheap पर
|
|
189
|
+
शुरू हो सकता है और विफलता या गार्ड अस्वीकृति के बाद ही बढ़ेगा। कम-आत्मविश्वास
|
|
190
|
+
वाला मध्य भाग जज कॉल से ढका जाता है।
|
|
191
|
+
- वृद्धि प्रति-agent और स्मृति में है; harness पुनः आरंभ होने पर `auto` से शुरू
|
|
192
|
+
होती है।
|
|
193
|
+
- स्तर बदलने पर उस अनुरोध का provider prompt cache रीसेट होता है, इसलिए बहुत
|
|
194
|
+
सक्रिय सत्रों में बदलाव वाले turn पर थोड़ी cache-miss लागत दिख सकती है;
|
|
195
|
+
hysteresis सीमाएँ इसी को दुर्लभ रखने के लिए हैं।
|
|
196
|
+
- प्लगइन संवाद अनुरोध रूट करता है। संपीड़न और शीर्षक निर्माण host के अलग seams
|
|
197
|
+
हैं; समान लागत प्रोफ़ाइल चाहिए तो उनकी मॉडल सेटिंग्स को cheap स्तर के साथ
|
|
198
|
+
संरेखित करें (`docs/supporting-lanes.md`)।
|
|
199
|
+
- cheap स्तर पर `followSession: true` का अर्थ है कि सत्र का स्पष्ट मॉडल चयन
|
|
200
|
+
जीतता है; उस स्थिति में cheap स्तर अपना मॉडल नहीं थोप सकता।
|
|
201
|
+
- **अभी Settings कार्ड या composer पिल नहीं है।** रूटिंग पूरी तरह स्वचालित है और
|
|
202
|
+
host सतह (`ctx.autotier.status()` / `catalog()`, `/tier`, `tier_status`,
|
|
203
|
+
`tier_route`) पूरी है; ब्राउज़र आधा v0.2 में नियोजित है।
|
|
204
|
+
- **GUI में चुना गया मॉडल स्वचालित रूप से नहीं पहचाना जाता।** रूटिंग रोकने के लिए
|
|
205
|
+
`routingMode: delegated` या `/tier off` इस्तेमाल करें।
|
|
206
|
+
- **फिंगरप्रिंट posteriors केवल स्मृति में रहते हैं** और पुनः आरंभ पर रीसेट होते हैं।
|
|
207
|
+
- **attempt-first मध्य पट्टी डिफ़ॉल्ट रूप से बंद है**, कैलिब्रेशन कॉर्पस (v0.2) के
|
|
208
|
+
बाद सक्रिय होगी।
|
|
209
|
+
|
|
210
|
+
## विकास
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
pnpm install
|
|
214
|
+
pnpm run typecheck # स्थानीय harness checkout के type faces के विरुद्ध
|
|
215
|
+
pnpm run typecheck:ci # प्रकाशित 0.1.2-rc.1 faces के विरुद्ध (CI यही चलाता है)
|
|
216
|
+
pnpm test
|
|
217
|
+
pnpm run build
|
|
218
|
+
pnpm run verify:self-contained
|
|
219
|
+
pnpm run verify:artifacts
|
|
220
|
+
pnpm pack
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`pnpm run build` `lib/types` (tsc declarations) और `lib/index.js` (tsdown
|
|
224
|
+
बंडल) उत्पन्न करता है। परीक्षण सीधे प्रकाशित host पैकेजों का उपयोग करते हैं —
|
|
225
|
+
वास्तविक `Context`, वास्तविक session/tools/commands/settings सेवाएँ — साथ ही
|
|
226
|
+
एक अस्थायी `cordis.yml` पर एक वास्तविक Loader संयोजन।
|
|
227
|
+
|
|
228
|
+
## विषय
|
|
229
|
+
|
|
230
|
+
`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `router`,
|
|
231
|
+
`model-tier`, `cost`, `auto`.
|
|
232
|
+
|
|
233
|
+
## योगदानकर्ता
|
|
234
|
+
|
|
235
|
+
PerryLink. Issues और pull requests:
|
|
236
|
+
<https://github.com/PerryLink/dsh-autotier/issues>।
|
|
237
|
+
|
|
238
|
+
## लाइसेंस
|
|
239
|
+
|
|
240
|
+
Apache-2.0. देखें [LICENSE](./LICENSE) और
|
|
241
|
+
[THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md)।
|
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# dsh-autotier
|
|
2
|
+
|
|
3
|
+
Automatic model-tier routing for DeepSeek Harness: one user instruction enters,
|
|
4
|
+
one tier decision comes out — no manual model switching.
|
|
5
|
+
|
|
6
|
+
Complex intent (architecture, planning, debugging, multi-step engineering) is
|
|
7
|
+
planned on the **strong** tier and then implemented on the **cheap** tier.
|
|
8
|
+
Simple intent (questions, retrieval, batch chores, daily work) is designed and
|
|
9
|
+
implemented on the **cheap** tier directly. While the cheap tier executes,
|
|
10
|
+
high-risk tool calls are denied by a deterministic guard, and repeated failures
|
|
11
|
+
escalate to the strong tier with a TTL fallback.
|
|
12
|
+
|
|
13
|
+
- **Official repository**: <https://github.com/PerryLink/dsh-autotier>
|
|
14
|
+
- **npm**: `dsh-autotier` (bare, unscoped)
|
|
15
|
+
|
|
16
|
+
## Compatibility
|
|
17
|
+
|
|
18
|
+
| Harness | Status |
|
|
19
|
+
|---|---|
|
|
20
|
+
| `@deepseek-ai/dsh` `0.1.2-rc.1` | compatible (this is what CI type-checks and the compat workflow installs) |
|
|
21
|
+
| `0.1.5-alpha.1` (the current harness checkout line) | type-checked against its published type faces; the end-to-end smoke runs on `0.1.2-rc.1` |
|
|
22
|
+
| `@deepseek-ai/cordis` `^4.0.2`, `@deepseek-ai/schemastery` `^3.18.2` | peer baseline |
|
|
23
|
+
|
|
24
|
+
The plugin is host-plane only. It needs no agent preset of its own: the host
|
|
25
|
+
row applies to every session. A one-line prompt section in *your* preset is
|
|
26
|
+
optional and only makes the router's decisions visible to the model (see
|
|
27
|
+
[Install & uninstall](#install--uninstall)).
|
|
28
|
+
|
|
29
|
+
## What you get
|
|
30
|
+
|
|
31
|
+
- **Intent gate** — every turn is classified from deterministic signals
|
|
32
|
+
(message text, tool names, image presence, conversation length). The
|
|
33
|
+
zero-token rule layer decides when it is confident; only a low-confidence turn
|
|
34
|
+
calls the cheap judge model, and never on a cooldown.
|
|
35
|
+
- **Tier landing on the official seam** — the decision is applied on the
|
|
36
|
+
`agent/request` waterfall by returning a replacement provider/model/effort
|
|
37
|
+
triple. Sampling scalars the session already chose (`temperature`, `maxTokens`,
|
|
38
|
+
`stop`) are preserved.
|
|
39
|
+
- **Plan-mode handoff** — a complex instruction enters plan mode on the strong
|
|
40
|
+
tier; leaving plan mode drops back to the cheap tier for implementation.
|
|
41
|
+
- **High-risk guard** — while the cheap tier executes, destructive commands
|
|
42
|
+
(`rm -rf`, `sudo`, `mkfs`, `git push --force`, credential-file writes, …) are
|
|
43
|
+
denied with a corrective message telling the model to escalate instead.
|
|
44
|
+
- **Failure escalation** — repeated failures (optionally same-signature) raise
|
|
45
|
+
the tier for a TTL; a model/route failure walks the configured fallback chain.
|
|
46
|
+
- **Manual escape hatches** — `/tier auto|strong|cheap|off` and the
|
|
47
|
+
`tier_status` / `tier_route` tools. Setting `routingMode: delegated` (or
|
|
48
|
+
`/tier off`) stops routing for a session that must keep its own model.
|
|
49
|
+
- **`ctx.autotier` service** — a small read surface (`status`) plus the
|
|
50
|
+
`autotier/route` veto waterfall and `autotier/tier-changed` event, so other
|
|
51
|
+
plugins can observe or override a decision.
|
|
52
|
+
|
|
53
|
+
## Quick start
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm i -g dsh1024
|
|
57
|
+
dsh1024 plugin --profile web add dsh-autotier
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Then start (or restart) the harness. The row is appended to your profile's
|
|
61
|
+
`cordis.patch.yml`; routing starts on the next turn with no further setup.
|
|
62
|
+
|
|
63
|
+
## Install & uninstall
|
|
64
|
+
|
|
65
|
+
**npm channel**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm i -g dsh1024
|
|
69
|
+
dsh1024 plugin --profile web add dsh-autotier
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
**git channel**
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/PerryLink/dsh-autotier.git
|
|
76
|
+
cd dsh-autotier && pnpm install && pnpm run build
|
|
77
|
+
dsh plugin --profile web add .
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Optional preset prompt section.** The router works without it. To let the
|
|
81
|
+
model know which tier it is running on, add one row to *your* agent preset
|
|
82
|
+
(`docs/preset-row.md` has the exact block):
|
|
83
|
+
|
|
84
|
+
```yaml
|
|
85
|
+
- insert:
|
|
86
|
+
- id: autotier-prompt
|
|
87
|
+
name: '@deepseek-ai/dsh-system-prompt'
|
|
88
|
+
# sections: [...] — see docs/preset-row.md
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**Uninstall**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
dsh plugin --profile web remove dsh-autotier
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The row, its settings namespace, its command, its tools and its listeners are
|
|
98
|
+
all removed with the plugin; nothing is written outside the settings document.
|
|
99
|
+
|
|
100
|
+
## Configuration
|
|
101
|
+
|
|
102
|
+
Every key is validated at load time; an invalid value fails loudly instead of
|
|
103
|
+
silently disabling routing. `cordis.patch.yml` in this repository documents the
|
|
104
|
+
same keys inline.
|
|
105
|
+
|
|
106
|
+
| Key | Default | Meaning |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `tiers.strong.provider` | `deepseek-official` | Provider for the planning/review tier. |
|
|
109
|
+
| `tiers.strong.model` | `deepseek-v4-pro` | Catalog id of the strong model. |
|
|
110
|
+
| `tiers.strong.effort` | `high` | Adapter vocabulary `off` \| `low` \| `high` \| `max`. |
|
|
111
|
+
| `tiers.strong.followSession` | `false` | `false` = this tier's effort overrides the session's. |
|
|
112
|
+
| `tiers.strong.fallback` | `[]` | Ordered provider/model landings when the tier is unavailable. |
|
|
113
|
+
| `tiers.cheap.provider` | `deepseek-official` | Provider for the implementation tier. |
|
|
114
|
+
| `tiers.cheap.model` | `deepseek-v4-flash` | Catalog id of the cheap model. |
|
|
115
|
+
| `tiers.cheap.effort` | `low` | Adapter vocabulary `off` \| `low` \| `high` \| `max`. |
|
|
116
|
+
| `tiers.cheap.followSession` | `true` | `true` = inherit the session's effort so an explicit choice wins. |
|
|
117
|
+
| `tiers.cheap.fallback` | `[]` | Ordered provider/model landings when the tier is unavailable. |
|
|
118
|
+
| `tiers.vision.provider` | `deepseek-official` | Provider for image-carrying turns. |
|
|
119
|
+
| `tiers.vision.model` | `deepseek-v4-flash-vision-exp` | The catalog's image-capable model. |
|
|
120
|
+
| `intent.ruleThreshold` | `0.7` | Confidence at or above which the rule layer decides alone. |
|
|
121
|
+
| `intent.attemptBand.enabled` | `false` | Start the middle band on the cheap tier and escalate on a signal. |
|
|
122
|
+
| `intent.attemptBand.tauLow` | `0.45` | Lower bound of the attempt-first band. |
|
|
123
|
+
| `intent.hysteresis.toStrong` | `0.8` | Score that switches a cheap turn to strong. |
|
|
124
|
+
| `intent.hysteresis.toCheap` | `0.6` | Score below which a strong turn returns to cheap. |
|
|
125
|
+
| `intent.rules` | `[]` | Declarative rule table (`when.patterns` / `when.tools` / `when.cwd`, `tier`, `priority`). |
|
|
126
|
+
| `intent.judge.enabled` | `true` | Allow the low-confidence judge. |
|
|
127
|
+
| `intent.judge.model` | `''` | Judge model id; empty = first catalog model containing `flash`. |
|
|
128
|
+
| `intent.judge.temperature` | `0` | Judge sampling temperature. |
|
|
129
|
+
| `intent.judge.maxTokens` | `16` | Judge output cap (it answers with one word). |
|
|
130
|
+
| `intent.judge.cooldownMs` | `30000` | Minimum gap between two judge calls. |
|
|
131
|
+
| `intent.judge.timeoutMs` | `2000` | Judge call timeout. |
|
|
132
|
+
| `intent.judge.unavailableSkip` | `2` | Consecutive judge failures after which the turn skips it. |
|
|
133
|
+
| `intent.scenarios` | all `true` | Per-scenario switches: `coding`, `review`, `planning`, `retrieval`, `batch`, `daily`, `longText`, `multimodal`. |
|
|
134
|
+
| `intent.costMode` | `balanced` | Ambiguity arbitration: `cost-first` \| `quality-first` \| `balanced`. |
|
|
135
|
+
| `guard.enabled` | `true` | Enable the deterministic high-risk guard. |
|
|
136
|
+
| `guard.tiers` | `[cheap]` | Tiers the guard protects. |
|
|
137
|
+
| `guard.whitelist` | `[]` | Commands, tools or path prefixes that never trip the guard. |
|
|
138
|
+
| `guard.protectedPaths` | `['.dsh','AGENTS.md','package.json','.github/workflows']` | Self-modification surfaces that force strong-tier review. |
|
|
139
|
+
| `guard.interopDefend` | `auto` | Relationship with `dsh-defend`: `auto` audits coexistence, `none` stays silent. |
|
|
140
|
+
| `escalation.threshold` | `2` | Failures within the window that raise the tier. |
|
|
141
|
+
| `escalation.windowMs` | `60000` | Failure-counting window. |
|
|
142
|
+
| `escalation.ttlMs` | `180000` | How long an escalation stays in effect. |
|
|
143
|
+
| `escalation.fallbackTtlMs` | `300000` | TTL used after a fallback landing was taken. |
|
|
144
|
+
| `escalation.signature` | `true` | Count same-signature recurrences instead of every failure. |
|
|
145
|
+
| `routingMode` | `auto` | `auto` \| `strong` \| `cheap` \| `delegated` \| `off`. |
|
|
146
|
+
|
|
147
|
+
All keys can also be edited live from the `autotier` settings namespace
|
|
148
|
+
(`$DSH_HOME/settings.yaml`); a write that violates a cross-field requirement is
|
|
149
|
+
refused at save time and the last good policy stays in effect.
|
|
150
|
+
|
|
151
|
+
## Tools & surfaces
|
|
152
|
+
|
|
153
|
+
| Surface | Kind | Purpose |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| `/tier` | command | `auto` \| `strong` \| `cheap` \| `off` \| `status`; session-scoped override. |
|
|
156
|
+
| `tier_status` | tool | Current tier, mode, escalation TTL and guard state. |
|
|
157
|
+
| `tier_route` | tool | Route one intent string without sending a request (dry run). |
|
|
158
|
+
| `ctx.autotier` | service | `status()` read surface for other plugins. |
|
|
159
|
+
| `autotier/route` | serial event | Third parties may veto a proposed tier. |
|
|
160
|
+
| `autotier/tier-changed` | emit event | Observability when the effective tier changes. |
|
|
161
|
+
|
|
162
|
+
## Permissions & data
|
|
163
|
+
|
|
164
|
+
- **Files** — the plugin reads nothing and writes nothing except through the
|
|
165
|
+
shared settings service (the `autotier` namespace).
|
|
166
|
+
- **Network** — the only outbound traffic is the judge call, which goes through
|
|
167
|
+
the normal `ctx.llm` path and the configured provider.
|
|
168
|
+
- **Session log** — the plugin appends no custom session events. The routing
|
|
169
|
+
trail is the plugin logger plus the live `autotier/tier-changed` bus event;
|
|
170
|
+
the only append it makes is the `plan/mode` fallback when the plan-mode
|
|
171
|
+
service is absent. Custom event types are fail-closed on `0.1.2-alpha.1` and
|
|
172
|
+
later, so no durable plugin-owned record is written.
|
|
173
|
+
- **Secrets** — no credential is read, logged or stored by this plugin.
|
|
174
|
+
|
|
175
|
+
## Security boundaries
|
|
176
|
+
|
|
177
|
+
- The guard is a **defence in depth**, not a sandbox. It denies the patterns it
|
|
178
|
+
knows on the cheap tier and never weakens `dsh-defend`, the approval service,
|
|
179
|
+
or the sandbox policy. Keep those enabled.
|
|
180
|
+
- The guard protects only the tiers listed in `guard.tiers` (cheap by default).
|
|
181
|
+
A strong-tier turn is not blocked by design: the strong model is the reviewer.
|
|
182
|
+
- If the guard itself throws, the call is escalated to the strong tier rather
|
|
183
|
+
than allowed — a broken guard must not become an open door.
|
|
184
|
+
- `/tier off` disables routing entirely; the harness then behaves exactly as it
|
|
185
|
+
did before the plugin was installed.
|
|
186
|
+
|
|
187
|
+
## Known limitations
|
|
188
|
+
|
|
189
|
+
- The rule layer is deterministic and therefore finite: a novel phrasing of a
|
|
190
|
+
complex request may start on the cheap tier and escalate only after a failure
|
|
191
|
+
or a guard denial. The judge call covers the low-confidence middle.
|
|
192
|
+
- Escalation is per-agent and in-memory; a harness restart starts from `auto`.
|
|
193
|
+
- Tier switching resets the provider prompt cache for the changed request, so
|
|
194
|
+
very chatty sessions may see a small cache-miss cost on the switch turn. The
|
|
195
|
+
hysteresis thresholds exist to keep that rare.
|
|
196
|
+
- The plugin routes conversation requests. Compaction and title generation are
|
|
197
|
+
separate host seams; align their own model settings with the cheap tier if you
|
|
198
|
+
want the same cost profile (`docs/supporting-lanes.md`).
|
|
199
|
+
- `followSession: true` on the cheap tier means an explicit session model choice
|
|
200
|
+
wins; in that case the cheap tier cannot force its own model.
|
|
201
|
+
- **No Settings card or composer pill yet.** Routing is fully automatic and the
|
|
202
|
+
host surface (`ctx.autotier.status()` / `catalog()`, `/tier`, `tier_status`,
|
|
203
|
+
`tier_route`) is complete; the browser half that renders a Settings tab and a
|
|
204
|
+
composer tier pill is planned for v0.2.
|
|
205
|
+
- **A model picked in the GUI is not detected automatically.** The router does
|
|
206
|
+
not watch the `agent-default-model` document, so switching models there does
|
|
207
|
+
not by itself stop routing — use `routingMode: delegated` or `/tier off`.
|
|
208
|
+
- **Fingerprint posteriors are in-memory.** They reset on restart and re-learn
|
|
209
|
+
from the judge's cold-start fallback; persisting them through the settings
|
|
210
|
+
document is planned for v0.2.
|
|
211
|
+
- **The attempt-first middle band ships disabled.** `intent.attemptBand.enabled`
|
|
212
|
+
stays `false` until the calibration corpus and its metric gate land (v0.2).
|
|
213
|
+
|
|
214
|
+
## Development
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
pnpm install
|
|
218
|
+
pnpm run typecheck # against the local harness checkout type faces
|
|
219
|
+
pnpm run typecheck:ci # against the published 0.1.2-rc.1 faces (what CI runs)
|
|
220
|
+
pnpm test
|
|
221
|
+
pnpm run build
|
|
222
|
+
pnpm run verify:self-contained
|
|
223
|
+
pnpm run verify:artifacts
|
|
224
|
+
pnpm pack
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`pnpm run build` emits `lib/types` (tsc declarations) and `lib/index.js`
|
|
228
|
+
(tsdown bundle). Tests use the published host packages directly — real
|
|
229
|
+
`Context`, real session/tools/commands/settings services — plus one real Loader
|
|
230
|
+
composition over a temporary `cordis.yml`.
|
|
231
|
+
|
|
232
|
+
## Topics
|
|
233
|
+
|
|
234
|
+
`dsh`, `dsh-plugin`, `deepseek-harness`, `deepseek`, `cordis`, `router`,
|
|
235
|
+
`model-tier`, `cost`, `auto`.
|
|
236
|
+
|
|
237
|
+
## Contributors
|
|
238
|
+
|
|
239
|
+
PerryLink. Issues and pull requests are welcome at
|
|
240
|
+
<https://github.com/PerryLink/dsh-autotier/issues>.
|
|
241
|
+
|
|
242
|
+
## License
|
|
243
|
+
|
|
244
|
+
Apache-2.0. See [LICENSE](./LICENSE) and
|
|
245
|
+
[THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md).
|