dsh-advisor-group 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/LICENSE +15 -0
- package/README.md +100 -0
- package/README.zh.md +100 -0
- package/cordis.patch.yml +10 -0
- package/lib/client.js +1444 -0
- package/lib/index.d.mts +165 -0
- package/lib/index.mjs +2650 -0
- package/package.json +86 -0
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import Schema from "@deepseek-ai/schemastery";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
+
//#region src/config.d.ts
|
|
4
|
+
type ProviderProtocol = 'openai' | 'anthropic' | 'gemini';
|
|
5
|
+
type ProviderAuthMode = 'x-api-key' | 'bearer';
|
|
6
|
+
interface AdvisorConfig {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
avatar?: string;
|
|
10
|
+
provider: string;
|
|
11
|
+
model: string;
|
|
12
|
+
systemPrompt: string;
|
|
13
|
+
temperature?: number;
|
|
14
|
+
maxTokens?: number;
|
|
15
|
+
baseURL?: string;
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
apiKeyEnv?: string;
|
|
18
|
+
protocol?: ProviderProtocol;
|
|
19
|
+
authMode?: ProviderAuthMode;
|
|
20
|
+
/**
|
|
21
|
+
* Server-side per-provider direct-key history for one advisor.
|
|
22
|
+
* Keys are never returned to the browser; they let a user switch back to a
|
|
23
|
+
* previously used provider without losing that provider's API key.
|
|
24
|
+
*/
|
|
25
|
+
apiKeysByProvider?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Client→server only: an explicit "clear the current provider's key" intent
|
|
28
|
+
* (SecretField semantics — an empty apiKey now means "keep the stored key").
|
|
29
|
+
* Stripped before persistence and never returned to the browser.
|
|
30
|
+
*/
|
|
31
|
+
clearApiKey?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Server→client only: per-provider key presence facts (no key material).
|
|
34
|
+
* Derived by `sanitizeConfig`; never persisted and never sent by the client.
|
|
35
|
+
*/
|
|
36
|
+
apiKeyMetaByProvider?: Record<string, {
|
|
37
|
+
configured: boolean;
|
|
38
|
+
last4?: string;
|
|
39
|
+
}>;
|
|
40
|
+
}
|
|
41
|
+
interface DiscussionConfig {
|
|
42
|
+
maxRounds: number;
|
|
43
|
+
maxAdvisorsPerCall: number;
|
|
44
|
+
/**
|
|
45
|
+
* Deprecated (2026-09-05): rounds are now a sequential A → B → C relay,
|
|
46
|
+
* advisors are never invoked in parallel. Kept for stored-config
|
|
47
|
+
* compatibility only.
|
|
48
|
+
*/
|
|
49
|
+
parallel: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Auto-deepen pipeline (2026-09-05): when true, the consultation runs up to
|
|
52
|
+
* `maxRounds` rounds automatically — after each round the driver model
|
|
53
|
+
* (the current agent's provider/model) asks a deeper follow-up, and a final
|
|
54
|
+
* synthesis closes the consultation.
|
|
55
|
+
*/
|
|
56
|
+
autoDeepen: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Fallback driver model used when the session header cannot be read
|
|
59
|
+
* (e.g. resumed sessions without a request/header event).
|
|
60
|
+
*/
|
|
61
|
+
driverModel?: {
|
|
62
|
+
provider: string;
|
|
63
|
+
model: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Deprecated (2026-09-05): the auto-deepen pipeline made this dormant.
|
|
67
|
+
* Kept in the schema only for stored-config compatibility;
|
|
68
|
+
* no longer rendered in the settings card.
|
|
69
|
+
*/
|
|
70
|
+
stopOnConsensus: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Per-advisor call timeout in milliseconds (default 120000 = 2 min).
|
|
73
|
+
* Applied to both the ctx.llm and direct-http channels.
|
|
74
|
+
*/
|
|
75
|
+
advisorTimeoutMs?: number;
|
|
76
|
+
}
|
|
77
|
+
interface TriggerConfig {
|
|
78
|
+
requireClassifier: boolean;
|
|
79
|
+
allowWebFallback: boolean;
|
|
80
|
+
confidenceThreshold: number;
|
|
81
|
+
}
|
|
82
|
+
interface UiConfig {
|
|
83
|
+
theme: 'retro-green' | 'retro-amber' | 'retro-blue';
|
|
84
|
+
showTimestamps: boolean;
|
|
85
|
+
autoExpand: boolean;
|
|
86
|
+
}
|
|
87
|
+
interface Config {
|
|
88
|
+
enabled: boolean;
|
|
89
|
+
discussion: DiscussionConfig;
|
|
90
|
+
trigger: TriggerConfig;
|
|
91
|
+
ui: UiConfig;
|
|
92
|
+
advisors: AdvisorConfig[];
|
|
93
|
+
}
|
|
94
|
+
declare const Config: Schema<Config>;
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/types.d.ts
|
|
97
|
+
type ChatRole = 'main' | 'advisor' | 'system';
|
|
98
|
+
interface ChatMessage {
|
|
99
|
+
role: ChatRole;
|
|
100
|
+
advisorId?: string;
|
|
101
|
+
advisorName?: string;
|
|
102
|
+
content: string;
|
|
103
|
+
thinking?: string;
|
|
104
|
+
round?: number;
|
|
105
|
+
ts: number;
|
|
106
|
+
}
|
|
107
|
+
interface ConsultSession {
|
|
108
|
+
id: string;
|
|
109
|
+
status: 'active' | 'completed' | 'cancelled';
|
|
110
|
+
question: string;
|
|
111
|
+
context?: string;
|
|
112
|
+
advisors: AdvisorConfig[];
|
|
113
|
+
maxRounds: number;
|
|
114
|
+
messages: ChatMessage[];
|
|
115
|
+
createdAt: number;
|
|
116
|
+
updatedAt: number;
|
|
117
|
+
}
|
|
118
|
+
interface AdvisorSummary {
|
|
119
|
+
advisorId: string;
|
|
120
|
+
advisorName: string;
|
|
121
|
+
corePoints: string[];
|
|
122
|
+
uncertainty?: string;
|
|
123
|
+
}
|
|
124
|
+
interface ConsultSummary {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
question: string;
|
|
127
|
+
advisors: AdvisorSummary[];
|
|
128
|
+
consensus: string[];
|
|
129
|
+
disagreements: string[];
|
|
130
|
+
riskNotes: string[];
|
|
131
|
+
/** Driver-model synthesis appended after all auto-deepen rounds (2026-09-05). */
|
|
132
|
+
conclusion?: string;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/events.d.ts
|
|
136
|
+
declare module '@deepseek-ai/cordis' {
|
|
137
|
+
interface Events {
|
|
138
|
+
'advisor-group/session-start'(session: ConsultSession): void;
|
|
139
|
+
'advisor-group/message'(payload: {
|
|
140
|
+
sessionId: string;
|
|
141
|
+
message: ChatMessage;
|
|
142
|
+
}): void;
|
|
143
|
+
'advisor-group/delta'(payload: {
|
|
144
|
+
sessionId: string;
|
|
145
|
+
turn: number;
|
|
146
|
+
step: number;
|
|
147
|
+
advisorId: string;
|
|
148
|
+
advisorName?: string;
|
|
149
|
+
contentDelta?: string;
|
|
150
|
+
thinkingDelta?: string;
|
|
151
|
+
done?: boolean;
|
|
152
|
+
}): void;
|
|
153
|
+
'advisor-group/session-end'(payload: {
|
|
154
|
+
sessionId: string;
|
|
155
|
+
summary: ConsultSummary;
|
|
156
|
+
}): void;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/index.d.ts
|
|
161
|
+
declare const name = "dsh-advisor-group";
|
|
162
|
+
declare const inject: string[];
|
|
163
|
+
declare function apply(ctx: Context, config: Config): void;
|
|
164
|
+
//#endregion
|
|
165
|
+
export { Config, apply, inject, name };
|