dsh-plugin-doubao 0.0.0-stage → 0.2.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/lib/login.js ADDED
@@ -0,0 +1,357 @@
1
+ /**
2
+ * Sign-in: get a session cookie for an account, without the desktop client.
3
+ *
4
+ * What a credential needs to be is subtle, and we learned it the hard way:
5
+ * - no identity at all -> 710012001 "login invalid"
6
+ * - a fresh device_id + valid cookie -> 710022004 (the account never saw it)
7
+ * - the device_id the client installed -> works
8
+ * So a login alone is not enough; the device id must come from somewhere the
9
+ * account already trusts. This module therefore pairs a scanned session with the
10
+ * device identity recovered from the installed client, and stores the pair.
11
+ *
12
+ * Scanning requires the Douyin app, not the Doubao app — Doubao's own QR
13
+ * endpoint says so in its copywriting, and scanning with Doubao simply fails.
14
+ */
15
+ import { createServer } from 'node:http'
16
+ import { mkdirSync, readFileSync, writeFileSync, existsSync } from 'node:fs'
17
+ import { dirname, join } from 'node:path'
18
+ import { homedir } from 'node:os'
19
+ import { credentialPath, findClientIdentity, toIdentity } from './identity.js'
20
+
21
+ const PASSPORT_AID = '497858'
22
+ const BROWSER_UA =
23
+ process.env.DOUBAO_LOGIN_UA ??
24
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.7727.149 Safari/537.36'
25
+ const NEXT = 'https://www.doubao.com'
26
+
27
+ /** A cookie jar that survives redirects, which is all a passport flow needs. */
28
+ function makeJar() {
29
+ const jar = new Map()
30
+ return {
31
+ jar,
32
+ header: () => [...jar].map(([k, v]) => `${k}=${v}`).join('; '),
33
+ absorb(res) {
34
+ for (const raw of res.headers.getSetCookie?.() ?? []) {
35
+ const pair = raw.split(';')[0]
36
+ const i = pair.indexOf('=')
37
+ if (i > 0) jar.set(pair.slice(0, i).trim(), pair.slice(i + 1).trim())
38
+ }
39
+ },
40
+ }
41
+ }
42
+
43
+ async function passportGet(jar, url, headers = {}) {
44
+ const res = await fetch(url, {
45
+ headers: {
46
+ 'User-Agent': BROWSER_UA,
47
+ Accept: 'application/json, text/plain, */*',
48
+ 'Accept-Language': 'zh-CN,zh;q=0.9',
49
+ Referer: 'https://www.doubao.com/chat/login',
50
+ Origin: 'https://www.doubao.com',
51
+ ...(jar.jar.size ? { Cookie: jar.header() } : {}),
52
+ ...headers,
53
+ },
54
+ })
55
+ jar.absorb(res)
56
+ return { status: res.status, body: await res.text() }
57
+ }
58
+
59
+ /**
60
+ * Fetch one login QR. The `next` and `aid` pair is what makes the code scan into
61
+ * this product; the csrf header is required or the endpoint answers an error.
62
+ */
63
+ export async function fetchQr(jar = makeJar()) {
64
+ await passportGet(jar, 'https://www.doubao.com/chat/')
65
+ if (!jar.jar.has('passport_csrf_token')) {
66
+ await passportGet(jar, `https://www.doubao.com/passport/safe/csrf_token/?aid=${PASSPORT_AID}`)
67
+ }
68
+ const csrf = jar.jar.get('passport_csrf_token') ?? ''
69
+ const query = new URLSearchParams({ aid: PASSPORT_AID, next: NEXT }).toString()
70
+ const res = await passportGet(
71
+ jar,
72
+ `https://www.doubao.com/passport/web/get_qrcode/?${query}`,
73
+ csrf ? { 'x-tt-passport-csrf-token': csrf } : {},
74
+ )
75
+ let data = {}
76
+ try {
77
+ data = JSON.parse(res.body)?.data ?? {}
78
+ } catch {
79
+ throw new Error(`QR request failed: ${res.body.slice(0, 200)}`)
80
+ }
81
+ const raw = data.qrcode || data.qrcode_url || ''
82
+ if (!data.token || !raw) throw new Error(`QR request returned no code: ${res.body.slice(0, 200)}`)
83
+ return {
84
+ jar,
85
+ csrf,
86
+ token: data.token,
87
+ png: raw.startsWith('data:') ? raw.split(',', 2)[1] : raw,
88
+ // The server states, in this field, which app may scan the code.
89
+ hint: parseHint(data.copywriting),
90
+ }
91
+ }
92
+
93
+ /** The QR response embeds its own instruction text as a JSON string. */
94
+ export function parseHint(copywriting) {
95
+ if (typeof copywriting !== 'string' || !copywriting) return undefined
96
+ try {
97
+ const parsed = JSON.parse(copywriting)
98
+ return parsed?.desc ? String(parsed.desc).replace(/\[[^\]]*\]/g, '') : undefined
99
+ } catch {
100
+ return undefined
101
+ }
102
+ }
103
+
104
+ const STATUS_TEXT = {
105
+ new: 'waiting for scan',
106
+ scanned: 'scanned — confirm on your phone',
107
+ confirmed: 'confirmed',
108
+ expired: 'expired',
109
+ }
110
+
111
+ /** Poll one QR until it is confirmed or expires (~60 s). */
112
+ export async function pollQr(jar, csrf, token, { intervalMs = 1500, timeoutMs = 62_000, onStatus } = {}) {
113
+ const started = Date.now()
114
+ let last
115
+ while (Date.now() - started < timeoutMs) {
116
+ const query = new URLSearchParams({ aid: PASSPORT_AID, next: NEXT, token }).toString()
117
+ const res = await passportGet(
118
+ jar,
119
+ `https://www.doubao.com/passport/web/check_qrconnect/?${query}`,
120
+ csrf ? { 'x-tt-passport-csrf-token': csrf } : {},
121
+ )
122
+ let data = {}
123
+ try {
124
+ data = JSON.parse(res.body)?.data ?? {}
125
+ } catch {
126
+ // a transient parse failure is not a terminal state; keep polling
127
+ }
128
+ if (data.status && data.status !== last) {
129
+ last = data.status
130
+ onStatus?.(data.status, STATUS_TEXT[data.status] ?? data.status)
131
+ }
132
+ if (data.status === 'confirmed') return { status: 'confirmed', data }
133
+ if (data.status === 'expired' || data.status === 'canceled') return { status: data.status, data }
134
+ await new Promise((r) => setTimeout(r, intervalMs))
135
+ }
136
+ return { status: 'timeout' }
137
+ }
138
+
139
+ /**
140
+ * Follow the post-confirmation redirect so the session cookies land in the jar.
141
+ *
142
+ * The redirect target is the site root, and the cookies arrive on the hops; a
143
+ * plain `redirect: 'follow'` loses the intermediate Set-Cookie headers in some
144
+ * runtimes, so each hop is walked explicitly.
145
+ */
146
+ export async function harvestSession(jar, redirectUrl, limit = 6) {
147
+ let url = redirectUrl
148
+ for (let hop = 0; hop < limit && url; hop += 1) {
149
+ const res = await fetch(url, {
150
+ redirect: 'manual',
151
+ headers: {
152
+ 'User-Agent': BROWSER_UA,
153
+ Accept: 'text/html,application/xhtml+xml',
154
+ ...(jar.jar.size ? { Cookie: jar.header() } : {}),
155
+ },
156
+ })
157
+ jar.absorb(res)
158
+ const location = res.headers.get('location')
159
+ await res.text().catch(() => '')
160
+ if (!location) break
161
+ url = location.startsWith('http') ? location : new URL(location, url).toString()
162
+ }
163
+ return jar.header()
164
+ }
165
+
166
+ /** Where the credential is written. Kept outside the plugin so upgrades survive. */
167
+ export function credentialsPath(env = process.env) {
168
+ return credentialPath(env)
169
+ }
170
+
171
+ export function readCredentials(env = process.env) {
172
+ const path = credentialsPath(env)
173
+ if (!existsSync(path)) return undefined
174
+ try {
175
+ const raw = JSON.parse(readFileSync(path, 'utf8').replace(/^\uFEFF/, ''))
176
+ if (!raw?.cookies || !raw?.identity?.deviceId) return undefined
177
+ return raw
178
+ } catch {
179
+ return undefined
180
+ }
181
+ }
182
+
183
+ export function writeCredentials(credential, env = process.env) {
184
+ const path = credentialsPath(env)
185
+ mkdirSync(dirname(path), { recursive: true })
186
+ const payload = {
187
+ cookies: credential.cookies,
188
+ identity: credential.identity,
189
+ account: credential.account,
190
+ savedAt: new Date().toISOString(),
191
+ }
192
+ writeFileSync(path, JSON.stringify(payload, null, 2), { mode: 0o600 })
193
+ return path
194
+ }
195
+
196
+ /** Identity for the chat call: the client's device id, never a minted one. */
197
+ export function resolveIdentity(env = process.env) {
198
+ const found = findClientIdentity(env)
199
+ if (found.found) return { identity: toIdentity(found.info), source: 'client', info: found.info }
200
+ return { identity: undefined, source: 'none' }
201
+ }
202
+
203
+ /**
204
+ * Run the whole flow in a browser window at `http://127.0.0.1:<port>/`.
205
+ *
206
+ * The code expires every ~60 s, so a one-shot screenshot is useless; the page
207
+ * reissues in the background and the user scans whenever they are ready.
208
+ */
209
+ export async function runLoginServer({ port = 8899, env = process.env, logger = console, onCredentials } = {}) {
210
+ let state = { png: '', status: 'init', at: 0, hint: '', verdict: '', saved: '' }
211
+ let jar
212
+ let token = ''
213
+ let csrf = ''
214
+ let confirmed = false
215
+ let issuing = false
216
+ let lastIssue = 0
217
+
218
+ const set = (patch) => {
219
+ state = { ...state, ...patch }
220
+ }
221
+
222
+ async function issue() {
223
+ if (issuing || confirmed) return
224
+ issuing = true
225
+ try {
226
+ const fresh = makeJar()
227
+ const qr = await fetchQr(fresh)
228
+ jar = fresh
229
+ token = qr.token
230
+ csrf = qr.csrf
231
+ lastIssue = Date.now()
232
+ set({ png: qr.png, status: 'new', at: Date.now(), hint: qr.hint ?? '' })
233
+ logger.log?.(`doubao: new QR code (expires in ~60s)`)
234
+ } catch (error) {
235
+ set({ status: `error: ${error.message}`, at: Date.now() })
236
+ } finally {
237
+ issuing = false
238
+ }
239
+ }
240
+
241
+ async function confirm(data) {
242
+ confirmed = true
243
+ set({ status: 'confirmed', at: Date.now() })
244
+ const cookies = data.redirect_url ? await harvestSession(jar, data.redirect_url) : jar.header()
245
+ const resolved = resolveIdentity(env)
246
+ if (!resolved.identity) {
247
+ set({
248
+ verdict:
249
+ 'Cookie captured, but no Doubao desktop client identity was found on this machine. ' +
250
+ 'Doubao binds each account to the device id the client registered, so sign-in cannot complete without it.',
251
+ })
252
+ return
253
+ }
254
+ const credential = { cookies, identity: resolved.identity }
255
+ const path = writeCredentials(credential, env)
256
+ set({ verdict: `saved to ${path}`, saved: path })
257
+ logger.log?.(`doubao: credentials saved to ${path}`)
258
+ onCredentials?.(credential)
259
+ }
260
+
261
+ const page = `<!doctype html><meta charset="utf-8"><title>Sign in to Doubao</title>
262
+ <style>
263
+ body{margin:0;min-height:100vh;display:grid;place-items:center;background:#0f172a;color:#e2e8f0;
264
+ font:15px/1.65 system-ui,"Segoe UI",sans-serif}
265
+ .card{background:#1e293b;border-radius:16px;padding:26px 32px;text-align:center;max-width:430px;
266
+ box-shadow:0 24px 60px rgba(0,0,0,.45)}
267
+ h1{font-size:17px;margin:0 0 6px;font-weight:600}
268
+ p{margin:0 0 16px;color:#94a3b8;font-size:13px}
269
+ img{width:272px;height:272px;border-radius:10px;background:#fff;padding:9px;display:block;margin:0 auto}
270
+ .st{margin-top:14px;font-size:13px;color:#38bdf8;min-height:20px}
271
+ .ok{color:#34d399}.bad{color:#f87171}
272
+ .v{margin-top:10px;font-size:12px;color:#cbd5e1;word-break:break-all}
273
+ </style>
274
+ <div class="card">
275
+ <h1>Scan with the Douyin app</h1>
276
+ <p id="hint">Doubao QR sign-in accepts only the Douyin app — scanning with Doubao fails.</p>
277
+ <img id="q" alt="QR code">
278
+ <div class="st" id="s">starting…</div>
279
+ <div class="v" id="v"></div>
280
+ </div>
281
+ <script>
282
+ let seen = ''
283
+ const labels = {init:'starting…',new:'waiting for scan',scanned:'scanned — confirm on your phone',
284
+ confirmed:'signed in',expired:'expired, refreshing…'}
285
+ async function tick(){
286
+ let r
287
+ try { r = await fetch('/state',{cache:'no-store'}).then(r=>r.json()) } catch { return }
288
+ if(r.png && r.at !== seen){ seen = r.at; document.getElementById('q').src = 'data:image/png;base64,' + r.png }
289
+ if(r.hint) document.getElementById('hint').textContent = r.hint
290
+ const el = document.getElementById('s')
291
+ el.textContent = labels[r.status] || r.status
292
+ el.className = 'st' + (r.status === 'confirmed' ? ' ok' : r.status.startsWith('error') ? ' bad' : '')
293
+ const v = document.getElementById('v')
294
+ v.textContent = r.verdict || ''
295
+ v.className = 'v' + (r.verdict.includes('saved') ? ' ok' : '')
296
+ }
297
+ tick(); setInterval(tick, 1200)
298
+ </script>`
299
+
300
+ const server = createServer((req, res) => {
301
+ if (req.url === '/state') {
302
+ res.writeHead(200, { 'Content-Type': 'application/json', 'Cache-Control': 'no-store' })
303
+ res.end(JSON.stringify({ png: state.png, at: state.at, status: state.status, hint: state.hint, verdict: state.verdict }))
304
+ return
305
+ }
306
+ res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Cache-Control': 'no-store' })
307
+ res.end(page)
308
+ })
309
+
310
+ const timer = setInterval(async () => {
311
+ if (confirmed) return
312
+ try {
313
+ if (!token) {
314
+ await issue()
315
+ return
316
+ }
317
+ const result = await pollQr(jar, csrf, token, {
318
+ timeoutMs: 4000,
319
+ onStatus(status, text) {
320
+ set({ status, at: state.at })
321
+ logger.log?.(`doubao: ${text}`)
322
+ },
323
+ })
324
+ if (result.status === 'confirmed') await confirm(result.data)
325
+ else if (result.status === 'expired' || result.status === 'timeout') {
326
+ if (Date.now() - lastIssue > 45_000) await issue()
327
+ }
328
+ } catch (error) {
329
+ logger.warn?.(`doubao: login poll failed: ${error.message}`)
330
+ }
331
+ }, 1500)
332
+
333
+ await new Promise((resolve, reject) => {
334
+ server.once('error', reject)
335
+ server.listen(port, '127.0.0.1', resolve)
336
+ })
337
+ logger.log?.(`doubao: open http://127.0.0.1:${port}/ and scan with the Douyin app`)
338
+ await issue()
339
+
340
+ return {
341
+ url: `http://127.0.0.1:${port}/`,
342
+ get state() {
343
+ return state
344
+ },
345
+ close() {
346
+ clearInterval(timer)
347
+ server.close()
348
+ },
349
+ }
350
+ }
351
+
352
+ /** Default credential path used by tests and the CLI banner. */
353
+ export const DEFAULT_CREDENTIALS = join(
354
+ process.env.DSH_HOME ?? join(homedir(), '.dsh'),
355
+ 'doubao-local',
356
+ 'credentials.json',
357
+ )
package/lib/rates.js ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * The billing rate the Doubao client prints next to each model.
3
+ *
4
+ * The rate is not a documented API field: the client gets it as a display tag
5
+ * on the model rows of the action-bar brief, `/alice/slot/action_bar_v3/brief_list`.
6
+ * Each item carries `tag_list`, and the rate rides in there as text — `0.65x`
7
+ * for a paid model, `限时优惠 0.01x` during a promotion, `小额免费` for the free
8
+ * tier. That is the number the official client shows the user, so it is the
9
+ * only honest source; guessing a table from prices published elsewhere would
10
+ * drift the moment a promotion starts.
11
+ *
12
+ * The fetch needs the same identity pair as chatting (device_id + fp) and the
13
+ * session cookie, so it can only run after sign-in. When it fails, the fallback
14
+ * below keeps the picker informative instead of bare — it is the reading taken
15
+ * on 2026-11-14 and is only ever used until a live fetch succeeds.
16
+ */
17
+ import { BOT_ID, DEFAULT_UA, buildQuery } from './doubao.js'
18
+
19
+ const BRIEF_URL = 'https://www.doubao.com/alice/slot/action_bar_v3/brief_list'
20
+
21
+ /** Reading of 2026-11-14, keyed by `model_item_key`. */
22
+ export const FALLBACK_RATES = Object.freeze({
23
+ '9': '小额免费',
24
+ 'seed-lite-7b': 'x0.01 限时优惠',
25
+ '5': 'x0.65',
26
+ 'person-deepseek-v4-1-flash-261017': 'x0.01 限时优惠',
27
+ 'person-kimi-k3-1-pro-261111': 'x0.95',
28
+ 'person-kimi-k3-1-pro-highspeed-261111': 'x1.44',
29
+ 'person-kimi-k3-261111': 'x1.48',
30
+ 'person-glm-5-3-261111': 'x0.80',
31
+ 'person-glm-5-3-flash-261111': 'x0.08',
32
+ 'person-deepseek-v4-pro-ga-260813': 'x0.46',
33
+ })
34
+
35
+ /**
36
+ * Turn one row's tags into the suffix shown after the model name.
37
+ *
38
+ * The client writes the multiplier and the promotion in one string
39
+ * (`限时优惠 0.01x`), so it is split: the number becomes `x0.01`, the words that
40
+ * remain stay after it. A tag with no number (`小额免费`) is passed through
41
+ * verbatim — there is nothing to reformat and inventing `x0.00` would claim a
42
+ * precision the upstream does not publish.
43
+ */
44
+ export function rateFromTags(tags) {
45
+ const parts = []
46
+ for (const tag of tags ?? []) {
47
+ const text = typeof tag === 'string' ? tag : tag?.text
48
+ if (typeof text !== 'string' || text.trim() === '') continue
49
+ const trimmed = text.trim()
50
+ const match = /(\d+(?:\.\d+)?)\s*x\b/i.exec(trimmed)
51
+ if (!match) {
52
+ parts.push(trimmed)
53
+ continue
54
+ }
55
+ const words = trimmed.replace(match[0], '').replace(/\s+/g, ' ').trim()
56
+ parts.push(`x${match[1]}${words ? ` ${words}` : ''}`)
57
+ }
58
+ return parts.length === 0 ? undefined : parts.join(' · ')
59
+ }
60
+
61
+ /** Walk an arbitrary brief payload and collect `model_item_key` -> rate. */
62
+ export function ratesFromBrief(payload) {
63
+ const rates = {}
64
+ const visit = (node) => {
65
+ if (Array.isArray(node)) {
66
+ for (const child of node) visit(child)
67
+ return
68
+ }
69
+ if (!node || typeof node !== 'object') return
70
+ if (typeof node.model_item_key === 'string' || typeof node.model_item_key === 'number') {
71
+ const rate = rateFromTags(node.tag_list)
72
+ if (rate !== undefined) rates[String(node.model_item_key)] = rate
73
+ }
74
+ for (const value of Object.values(node)) visit(value)
75
+ }
76
+ visit(payload)
77
+ return rates
78
+ }
79
+
80
+ /**
81
+ * Fetch the live rates. Never throws: a failure resolves to an empty table so
82
+ * the caller keeps whatever it last showed instead of downgrading a live rate
83
+ * back to the fallback snapshot. `FALLBACK_RATES` is the caller's starting
84
+ * seed, not this function's error result.
85
+ */
86
+ export async function fetchModelRates({ identity, cookies, signal, timeoutMs = 5_000, logger } = {}) {
87
+ if (!identity?.deviceId || !cookies) return {}
88
+ const query = new URLSearchParams(buildQuery(identity))
89
+ try {
90
+ const response = await fetch(`${BRIEF_URL}?${query}`, {
91
+ method: 'POST',
92
+ headers: {
93
+ 'Content-Type': 'application/json',
94
+ Accept: 'application/json, text/plain, */*',
95
+ 'Agw-Js-Conv': 'str',
96
+ 'User-Agent': DEFAULT_UA,
97
+ Origin: 'https://www.doubao.com',
98
+ Referer: 'https://www.doubao.com/chat/',
99
+ Cookie: cookies,
100
+ },
101
+ body: JSON.stringify({ bot_id: BOT_ID, language_code: 'zh' }),
102
+ signal: signal ?? AbortSignal.timeout(timeoutMs),
103
+ })
104
+ if (!response.ok) {
105
+ logger?.warn?.(`doubao: model rate lookup returned HTTP ${response.status}; keeping the last known table`)
106
+ return {}
107
+ }
108
+ const rates = ratesFromBrief(await response.json())
109
+ if (Object.keys(rates).length === 0) {
110
+ logger?.warn?.('doubao: model rate lookup carried no tags; keeping the last known table')
111
+ }
112
+ return rates
113
+ } catch (error) {
114
+ logger?.warn?.(`doubao: model rate lookup failed (${error?.message ?? error}); keeping the last known table`)
115
+ return {}
116
+ }
117
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Short-lived memory of "this account is under risk control".
3
+ *
4
+ * A direct request to doubao.com is enough while the account is in good
5
+ * standing. Once it returns 710022004, retrying the unsigned path only deepens
6
+ * the flag — so we remember the state and route that account through the signed
7
+ * bridge for a while instead of probing again on every turn.
8
+ *
9
+ * The flag expires. Accounts do recover (a completed slider, a different
10
+ * network), and a permanent memory would keep a recovered account on the
11
+ * bridge — and keep launching the client — forever. Persistence across DSH
12
+ * restarts is optional: pass a `file` and the table is a small JSON object on
13
+ * disk, otherwise it lives only for the process.
14
+ */
15
+
16
+ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs'
17
+ import { dirname } from 'node:path'
18
+
19
+ export const DEFAULT_TTL_MS = 30 * 60 * 1000
20
+
21
+ /**
22
+ * @param {object} opts
23
+ * @param {string} [opts.file] optional JSON file to persist the table
24
+ * @param {number} [opts.ttlMs] how long a flag stays valid
25
+ * @param {Function}[opts.now] injectable clock for tests
26
+ * @param {object} [opts.logger]
27
+ */
28
+ export function createRiskMemory({ file, ttlMs = DEFAULT_TTL_MS, now = Date.now, logger } = {}) {
29
+ let data = {}
30
+ if (file) {
31
+ try {
32
+ const parsed = JSON.parse(readFileSync(file, 'utf8'))
33
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) data = parsed
34
+ } catch {
35
+ // Missing, empty or corrupt: start clean. A flag we cannot trust is worse
36
+ // than one extra direct probe against an already-recovered account.
37
+ data = {}
38
+ }
39
+ }
40
+
41
+ let dirty = false
42
+ function flush() {
43
+ if (!file || !dirty) return
44
+ try {
45
+ mkdirSync(dirname(file), { recursive: true })
46
+ writeFileSync(file, JSON.stringify(data), 'utf8')
47
+ dirty = false
48
+ } catch (error) {
49
+ logger?.warn?.(`doubao: could not persist risk flags (${error?.message ?? error})`)
50
+ }
51
+ }
52
+
53
+ return {
54
+ /** True only while a still-valid flag exists for `key`. */
55
+ isFlagged(key) {
56
+ const until = data[key]
57
+ if (typeof until !== 'number') return false
58
+ if (until <= now()) {
59
+ delete data[key]
60
+ dirty = true
61
+ flush()
62
+ return false
63
+ }
64
+ return true
65
+ },
66
+ /** Record a fresh flag for `key`. */
67
+ mark(key) {
68
+ data[key] = now() + ttlMs
69
+ dirty = true
70
+ flush()
71
+ },
72
+ /** Forget one key, or every key when called with no argument. */
73
+ clear(key) {
74
+ if (key === undefined) data = {}
75
+ else delete data[key]
76
+ dirty = true
77
+ flush()
78
+ },
79
+ /** Debug/test view of the raw table. */
80
+ snapshot() {
81
+ return { ...data }
82
+ },
83
+ }
84
+ }
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "dsh-plugin-doubao",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "Doubao models in DSH, self-contained: talks to doubao.com over plain HTTP and registers itself as an LLM provider. No proxy to start — sign in once with a QR code.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/woc-jpg/dsh-plugin-doubao.git"
10
+ },
11
+ "homepage": "https://github.com/woc-jpg/dsh-plugin-doubao#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/woc-jpg/dsh-plugin-doubao/issues"
14
+ },
15
+ "main": "lib/index.js",
16
+ "bin": {
17
+ "dsh-plugin-doubao": "bin/login.js"
18
+ },
19
+ "engines": {
20
+ "node": ">=22"
21
+ },
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org/",
24
+ "access": "public"
25
+ },
26
+ "files": [
27
+ "lib",
28
+ "bin",
29
+ "cordis.patch.yml",
30
+ "README.md"
31
+ ],
32
+ "keywords": [
33
+ "dsh-plugin",
34
+ "deepseek-harness",
35
+ "doubao",
36
+ "model-provider"
37
+ ],
38
+ "exports": {
39
+ ".": "./lib/index.js",
40
+ "./client": "./lib/client.js",
41
+ "./cordis.patch.yml": "./cordis.patch.yml",
42
+ "./package.json": "./package.json"
43
+ },
44
+ "dsh": {
45
+ "bundle": {
46
+ "patch": "./cordis.patch.yml"
47
+ },
48
+ "client": {
49
+ "platform": "web",
50
+ "inject": [
51
+ "slots",
52
+ "@deepseek-ai/dsh-client-locale"
53
+ ]
54
+ }
55
+ }
56
+ }