dsh-advisor-group 0.0.1
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 +98 -0
- package/README.zh.md +103 -0
- package/cordis.patch.yml +10 -0
- package/lib/client.js +1847 -0
- package/lib/index.d.mts +252 -0
- package/lib/index.mjs +3871 -0
- package/package.json +87 -0
package/lib/index.d.mts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
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
|
+
* Per-advisor thinking mode; unset = provider default. `disabled` forces
|
|
22
|
+
* every request from this advisor to run without a thinking/reasoning block
|
|
23
|
+
* (mapped to `reasoningEffort: 'off'` on the DSH built-in channel; on the
|
|
24
|
+
* direct-http channel it maps to provider-specific "no thinking" params
|
|
25
|
+
* where supported). When `enabled`, the selected `reasoningEffort` applies.
|
|
26
|
+
*/
|
|
27
|
+
thinking?: 'enabled' | 'disabled';
|
|
28
|
+
/**
|
|
29
|
+
* Per-advisor thinking strength; unset = provider/model default. Standard
|
|
30
|
+
* DSH effort ids (`off` disables thinking per request). On the direct-http
|
|
31
|
+
* channel the ids are mapped to provider-specific reasoning parameters
|
|
32
|
+
* (OpenAI `reasoning_effort`, Anthropic thinking budget, Gemini
|
|
33
|
+
* `thinkingConfig`).
|
|
34
|
+
*/
|
|
35
|
+
reasoningEffort?: 'off' | 'low' | 'high' | 'max';
|
|
36
|
+
/**
|
|
37
|
+
* Per-advisor tool calling scope override; unset = the global default
|
|
38
|
+
* (`discussion.advisorTools`). Only meaningful on the direct-http channel.
|
|
39
|
+
*/
|
|
40
|
+
tools?: 'readonly' | 'all' | 'off';
|
|
41
|
+
/**
|
|
42
|
+
* Server-side per-provider direct-key history for one advisor.
|
|
43
|
+
* Keys are never returned to the browser; they let a user switch back to a
|
|
44
|
+
* previously used provider without losing that provider's API key.
|
|
45
|
+
*/
|
|
46
|
+
apiKeysByProvider?: Record<string, string>;
|
|
47
|
+
/**
|
|
48
|
+
* Client→server only: an explicit "clear the current provider's key" intent
|
|
49
|
+
* (SecretField semantics — an empty apiKey now means "keep the stored key").
|
|
50
|
+
* Stripped before persistence and never returned to the browser.
|
|
51
|
+
*/
|
|
52
|
+
clearApiKey?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Server→client only: per-provider key presence facts (no key material).
|
|
55
|
+
* Derived by `sanitizeConfig`; never persisted and never sent by the client.
|
|
56
|
+
*/
|
|
57
|
+
apiKeyMetaByProvider?: Record<string, {
|
|
58
|
+
configured: boolean;
|
|
59
|
+
last4?: string;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
interface DiscussionConfig {
|
|
63
|
+
maxRounds: number;
|
|
64
|
+
maxAdvisorsPerCall: number;
|
|
65
|
+
/**
|
|
66
|
+
* Deprecated (2026-09-05): rounds are now a sequential A → B → C relay,
|
|
67
|
+
* advisors are never invoked in parallel. Kept for stored-config
|
|
68
|
+
* compatibility only.
|
|
69
|
+
*/
|
|
70
|
+
parallel: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Auto-deepen pipeline (2026-09-05): when true, the consultation runs up to
|
|
73
|
+
* `maxRounds` rounds automatically — after each round the driver model
|
|
74
|
+
* (the current agent's provider/model) asks a deeper follow-up, and a final
|
|
75
|
+
* synthesis closes the consultation.
|
|
76
|
+
*/
|
|
77
|
+
autoDeepen: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Fallback driver model used when the session header cannot be read
|
|
80
|
+
* (e.g. resumed sessions without a request/header event).
|
|
81
|
+
*/
|
|
82
|
+
driverModel?: {
|
|
83
|
+
provider: string;
|
|
84
|
+
model: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Deprecated (2026-09-05): the auto-deepen pipeline made this dormant.
|
|
88
|
+
* Kept in the schema only for stored-config compatibility;
|
|
89
|
+
* no longer rendered in the settings card.
|
|
90
|
+
*/
|
|
91
|
+
stopOnConsensus: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Per-advisor call timeout in milliseconds (default 600000 = 10 min).
|
|
94
|
+
* Applied to both the ctx.llm and direct-http channels.
|
|
95
|
+
*/
|
|
96
|
+
advisorTimeoutMs?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Advisor tool calling scope (2026-09-05): 'readonly' (default) exposes only
|
|
99
|
+
* a read-only whitelist of the session's tools (read/grep/glob/web_search…);
|
|
100
|
+
* 'all' exposes every session-visible tool (incl. writable ones); 'off'
|
|
101
|
+
* disables tool calling. Only the direct-http OpenAI/Anthropic channel
|
|
102
|
+
* supports tool calling (ctx.llm / dsh-llm 0.1.2-rc.1 does not).
|
|
103
|
+
*/
|
|
104
|
+
advisorTools?: 'readonly' | 'all' | 'off';
|
|
105
|
+
/**
|
|
106
|
+
* Driver (deep-question / conclusion) generation timeout in milliseconds
|
|
107
|
+
* (default 600000 = 10 min).
|
|
108
|
+
*/
|
|
109
|
+
driverTimeoutMs?: number;
|
|
110
|
+
}
|
|
111
|
+
interface TriggerConfig {
|
|
112
|
+
requireClassifier: boolean;
|
|
113
|
+
allowWebFallback: boolean;
|
|
114
|
+
confidenceThreshold: number;
|
|
115
|
+
}
|
|
116
|
+
interface UiConfig {
|
|
117
|
+
theme: 'retro-green' | 'retro-amber' | 'retro-blue';
|
|
118
|
+
showTimestamps: boolean;
|
|
119
|
+
autoExpand: boolean;
|
|
120
|
+
}
|
|
121
|
+
interface QuotaConfig {
|
|
122
|
+
/** Enable the per-UTC-day new-consultation cap (cost safety valve). */
|
|
123
|
+
enabled: boolean;
|
|
124
|
+
/** Max new consultations per UTC day when enabled (1–100000), default 50. */
|
|
125
|
+
maxPerDay: number;
|
|
126
|
+
}
|
|
127
|
+
interface Config {
|
|
128
|
+
enabled: boolean;
|
|
129
|
+
discussion: DiscussionConfig;
|
|
130
|
+
trigger: TriggerConfig;
|
|
131
|
+
ui: UiConfig;
|
|
132
|
+
quota: QuotaConfig;
|
|
133
|
+
advisors: AdvisorConfig[];
|
|
134
|
+
}
|
|
135
|
+
declare const Config: Schema<Config>;
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/types.d.ts
|
|
138
|
+
interface DriverSource {
|
|
139
|
+
provider: string;
|
|
140
|
+
model: string;
|
|
141
|
+
}
|
|
142
|
+
type ChatRole = 'main' | 'advisor' | 'system';
|
|
143
|
+
/** Why an advisor stream ended before producing a complete answer body. */
|
|
144
|
+
interface TruncationInfo {
|
|
145
|
+
reason: 'timeout' | 'network';
|
|
146
|
+
atMs: number;
|
|
147
|
+
}
|
|
148
|
+
/** One tool step (agent-loop style) attached to the advisor message. */
|
|
149
|
+
interface AdvisorToolStep {
|
|
150
|
+
kind: 'call' | 'result';
|
|
151
|
+
name: string;
|
|
152
|
+
text: string;
|
|
153
|
+
atMs: number;
|
|
154
|
+
}
|
|
155
|
+
interface ChatMessage {
|
|
156
|
+
role: ChatRole;
|
|
157
|
+
advisorId?: string;
|
|
158
|
+
advisorName?: string;
|
|
159
|
+
content: string;
|
|
160
|
+
thinking?: string;
|
|
161
|
+
/** Thinking split at each tool-call boundary, in stream order — the card
|
|
162
|
+
* renders ONE row per segment (第 N 步思考), interleaved with tool rows. */
|
|
163
|
+
thinkingSegments?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* The model's TEXT blocks spoken before each tool round (the DSH block order
|
|
166
|
+
* text → reasoning → tool-call): the "我要做什么" announcement the model
|
|
167
|
+
* makes to the user. Precise source for the card's 📋 行动·N rows.
|
|
168
|
+
*/
|
|
169
|
+
actionDescriptions?: string[];
|
|
170
|
+
round?: number;
|
|
171
|
+
/** Tool-calling steps streamed as independent rows (not part of thinking). */
|
|
172
|
+
toolSteps?: AdvisorToolStep[];
|
|
173
|
+
/** Set when the stream was cut before a complete body (e.g. advisor timeout). */
|
|
174
|
+
truncated?: TruncationInfo;
|
|
175
|
+
ts: number;
|
|
176
|
+
}
|
|
177
|
+
interface ConsultSession {
|
|
178
|
+
id: string;
|
|
179
|
+
status: 'active' | 'completed' | 'cancelled';
|
|
180
|
+
question: string;
|
|
181
|
+
context?: string;
|
|
182
|
+
advisors: AdvisorConfig[];
|
|
183
|
+
maxRounds: number;
|
|
184
|
+
messages: ChatMessage[];
|
|
185
|
+
/** Working directory of the agent session (for cross-restart recovery). */
|
|
186
|
+
cwd?: string;
|
|
187
|
+
/** The agent's DSH session id: resume rebuilds THIS session so the card
|
|
188
|
+
* (assembled from the agent session log) keeps receiving events. */
|
|
189
|
+
dshSessionId?: string;
|
|
190
|
+
/** Driver model source captured at first run; resume reuses it because the
|
|
191
|
+
* rebuilt session has no request/header event to read the agent model from. */
|
|
192
|
+
driverSource?: DriverSource;
|
|
193
|
+
/** Why the consultation was interrupted: 'user-stop' (explicit stop button),
|
|
194
|
+
* 'exec-cancel' (host signal), 'abort-error' (unclassified AbortError),
|
|
195
|
+
* or an advisor-level reason mirrored from truncated (timeout/network). */
|
|
196
|
+
stopReason?: string;
|
|
197
|
+
createdAt: number;
|
|
198
|
+
updatedAt: number;
|
|
199
|
+
}
|
|
200
|
+
interface AdvisorSummary {
|
|
201
|
+
advisorId: string;
|
|
202
|
+
advisorName: string;
|
|
203
|
+
corePoints: string[];
|
|
204
|
+
uncertainty?: string;
|
|
205
|
+
}
|
|
206
|
+
interface ConsultSummary {
|
|
207
|
+
sessionId: string;
|
|
208
|
+
question: string;
|
|
209
|
+
advisors: AdvisorSummary[];
|
|
210
|
+
consensus: string[];
|
|
211
|
+
disagreements: string[];
|
|
212
|
+
riskNotes: string[];
|
|
213
|
+
/** Driver-model synthesis appended after all auto-deepen rounds (2026-09-05). */
|
|
214
|
+
conclusion?: string;
|
|
215
|
+
/** True when the consultation was stopped by the user (partial content). */
|
|
216
|
+
stopped?: boolean;
|
|
217
|
+
}
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/events.d.ts
|
|
220
|
+
declare module '@deepseek-ai/cordis' {
|
|
221
|
+
interface Events {
|
|
222
|
+
'advisor-group/session-start'(session: ConsultSession): void;
|
|
223
|
+
'advisor-group/message'(payload: {
|
|
224
|
+
sessionId: string;
|
|
225
|
+
message: ChatMessage;
|
|
226
|
+
}): void;
|
|
227
|
+
'advisor-group/delta'(payload: {
|
|
228
|
+
sessionId: string;
|
|
229
|
+
turn: number;
|
|
230
|
+
step: number;
|
|
231
|
+
advisorId: string;
|
|
232
|
+
advisorName?: string;
|
|
233
|
+
contentDelta?: string;
|
|
234
|
+
thinkingDelta?: string;
|
|
235
|
+
done?: boolean;
|
|
236
|
+
}): void;
|
|
237
|
+
'advisor-group/session-end'(payload: {
|
|
238
|
+
sessionId: string;
|
|
239
|
+
summary: ConsultSummary;
|
|
240
|
+
}): void;
|
|
241
|
+
'advisor-group/resume'(payload: {
|
|
242
|
+
sessionId: string;
|
|
243
|
+
}): void;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//#endregion
|
|
247
|
+
//#region src/index.d.ts
|
|
248
|
+
declare const name = "dsh-advisor-group";
|
|
249
|
+
declare const inject: string[];
|
|
250
|
+
declare function apply(ctx: Context, config: Config): void;
|
|
251
|
+
//#endregion
|
|
252
|
+
export { Config, apply, inject, name };
|