@doitian/dsh-music 0.1.1 → 0.1.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.
- package/README.md +152 -34
- package/cordis.patch.yml +14 -0
- package/lib/client.js +48 -11
- package/lib/dj.js +234 -48
- package/lib/index.js +35 -2
- package/lib/netease.js +23 -7
- package/lib/panel.html +451 -212
- package/lib/router.js +7 -4
- package/lib/session.js +14 -2
- package/package.json +2 -1
package/lib/router.js
CHANGED
|
@@ -88,7 +88,7 @@ export class MusicRouter {
|
|
|
88
88
|
* @param {string} options.panelHtml
|
|
89
89
|
* @param {string} options.qrcodeJs
|
|
90
90
|
* @param {object} [options.config]
|
|
91
|
-
* @param {() => Promise<object>} [options.listRoutes]
|
|
91
|
+
* @param {() => Promise<object>} [options.listRoutes] model routes for the picker.
|
|
92
92
|
* @param {() => object} [options.diagnostics] extra facts for `/health`.
|
|
93
93
|
* @param {{warn: Function, info: Function, debug: Function}} [options.logger]
|
|
94
94
|
*/
|
|
@@ -117,7 +117,7 @@ export class MusicRouter {
|
|
|
117
117
|
* The level to stream at.
|
|
118
118
|
*
|
|
119
119
|
* The player's saved choice wins over the profile patch, matching how the
|
|
120
|
-
*
|
|
120
|
+
* DJ's model route resolves — a GUI choice should not be silently overridden.
|
|
121
121
|
* An unknown value falls back rather than failing a request.
|
|
122
122
|
*/
|
|
123
123
|
preferredLevel() {
|
|
@@ -280,11 +280,14 @@ export class MusicRouter {
|
|
|
280
280
|
};
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
/** Where the
|
|
283
|
+
/** Where the DJ's model route comes from. */
|
|
284
284
|
modelSource() {
|
|
285
285
|
const settings = this.store.settings;
|
|
286
286
|
if (settings.djProvider || settings.djModel) return 'panel';
|
|
287
287
|
if (this.config?.dj?.provider || this.config?.dj?.model) return 'config';
|
|
288
|
+
// Nothing pinned: the DJ follows the session's own model when the
|
|
289
|
+
// deployment publishes one, and falls back to discovery when it does not.
|
|
290
|
+
if (this.dj.sessionModel?.()) return 'agent-default';
|
|
288
291
|
return 'discovered';
|
|
289
292
|
}
|
|
290
293
|
|
|
@@ -455,7 +458,7 @@ export class MusicRouter {
|
|
|
455
458
|
model: nextModel || configured.model || null,
|
|
456
459
|
});
|
|
457
460
|
this.logger?.info?.(
|
|
458
|
-
`[music]
|
|
461
|
+
`[music] DJ model route set to ${this.dj.model.provider ?? '(none)'}/${this.dj.model.model ?? '(none)'} from the player`,
|
|
459
462
|
);
|
|
460
463
|
}
|
|
461
464
|
if (prompt !== undefined) this.store.updateSettings({ djPrompt: String(prompt) });
|
package/lib/session.js
CHANGED
|
@@ -42,13 +42,23 @@ function emptyState() {
|
|
|
42
42
|
/** Free-text taste/mood brief the DJ includes in its prompt. */
|
|
43
43
|
djPrompt: '',
|
|
44
44
|
/**
|
|
45
|
-
*
|
|
45
|
+
* DJ model route chosen from the player. Empty means "use the profile
|
|
46
46
|
* patch's `config.dj`", so clearing the picker reverts to it.
|
|
47
47
|
*/
|
|
48
48
|
djProvider: '',
|
|
49
49
|
djModel: '',
|
|
50
50
|
djAutoExtendBelow: 3,
|
|
51
51
|
djBatchSize: 5,
|
|
52
|
+
/**
|
|
53
|
+
* The DJ's model-call identity, minted on first use and persisted here.
|
|
54
|
+
*
|
|
55
|
+
* A leaf call cannot carry headers, so this string is the only identity
|
|
56
|
+
* the DJ can give a provider — and adapters map it onto whatever that
|
|
57
|
+
* provider calls a per-conversation header (pi-ai emits
|
|
58
|
+
* `x-opencode-session` for `opencode-go`). Persisting it keeps every plan
|
|
59
|
+
* and every restart inside one conversation.
|
|
60
|
+
*/
|
|
61
|
+
djSessionId: '',
|
|
52
62
|
},
|
|
53
63
|
history: [],
|
|
54
64
|
feedback: { likes: [], dislikes: [], skips: [] },
|
|
@@ -309,7 +319,9 @@ export class QrLogin {
|
|
|
309
319
|
} catch (error) {
|
|
310
320
|
this.lastError = error.message;
|
|
311
321
|
this.logger?.warn?.(`[music] QR poll failed: ${error.message}`);
|
|
312
|
-
|
|
322
|
+
// `error` is the machine-usable half; the panel localizes around it,
|
|
323
|
+
// while `message` stays bilingual for the agent-facing login tool.
|
|
324
|
+
return { state: attempt.state, message: `轮询失败 (poll failed): ${error.message}`, error: error.message, loginUrl: attempt.loginUrl };
|
|
313
325
|
}
|
|
314
326
|
|
|
315
327
|
if (result.code === 800) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doitian/dsh-music",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "NetEase Cloud Music (music.163.com) player and AI DJ for DeepSeek Harness: a sidebar page with in-app playback, QR sign-in, and agent tools that curate the queue.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"scripts": {
|
|
56
56
|
"check": "node --check lib/index.js && node --check lib/client.js && node --check lib/netease.js && node --check lib/session.js && node --check lib/state.js && node --check lib/dj.js && node --check lib/router.js",
|
|
57
57
|
"test": "node test/netease.test.mjs && node test/dj.test.mjs && node test/client.test.mjs",
|
|
58
|
+
"probe:headers": "node scripts/probe-headers.mjs",
|
|
58
59
|
"test:live": "node test/host.test.mjs",
|
|
59
60
|
"test:all": "npm test && npm run test:live"
|
|
60
61
|
},
|