dsh-taskbridge 0.0.0-stage → 1.3.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/CHANGELOG.md +754 -0
- package/LICENSE +21 -0
- package/README.md +624 -3
- package/bin/dsh-delegate-codex-agent.js +115 -0
- package/bin/dsh-delegate-control.d.ts +90 -0
- package/bin/dsh-delegate-control.js +450 -0
- package/bin/dsh-delegate-mcp.d.ts +121 -0
- package/bin/dsh-delegate-mcp.js +273 -0
- package/codex/dsh-delegate.toml +245 -0
- package/cordis.patch.yml +6 -0
- package/docs/INTRODUCTION.md +15 -0
- package/docs/INTRODUCTION.zh.md +32 -0
- package/docs/auth-contract.md +138 -0
- package/docs/claude-code.md +31 -0
- package/docs/codex-integration.md +922 -0
- package/docs/contracts-stage-b.md +443 -0
- package/docs/conversation-placement.md +293 -0
- package/docs/plugin-market.md +30 -0
- package/docs/redaction-contract.md +127 -0
- package/docs/runtime-compatibility.md +220 -0
- package/docs/silent-wait.md +191 -0
- package/docs/taskbridge-upgrade.md +28 -0
- package/docs/taskdispatch-upgrade.md +25 -0
- package/docs/worker-permissions.md +347 -0
- package/docs/workspace-contract.md +538 -0
- package/icon.svg +1 -0
- package/lib/client.d.ts +118 -0
- package/lib/client.js +3232 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +135 -4
- package/src/auth/fence.js +361 -0
- package/src/auth/grants.js +789 -0
- package/src/client/api.js +2322 -0
- package/src/client/index.jsx +2333 -0
- package/src/client/styles.js +251 -0
- package/src/codex/installer.js +3260 -0
- package/src/codex/seam.js +429 -0
- package/src/codex/toml.js +784 -0
- package/src/config/defaults.js +164 -0
- package/src/config/redact.js +184 -0
- package/src/config/settings.js +629 -0
- package/src/config/store.js +186 -0
- package/src/config/validate.js +763 -0
- package/src/credentials/seam.js +202 -0
- package/src/http/execution-plane.js +454 -0
- package/src/http/respond.js +175 -0
- package/src/http/user-plane.js +1122 -0
- package/src/index.d.ts +332 -0
- package/src/index.js +657 -0
- package/src/jobs/activity.js +1008 -0
- package/src/jobs/engine.js +3609 -0
- package/src/jobs/history.js +1467 -0
- package/src/mcp/server.js +1820 -0
- package/src/mcp/wait.js +536 -0
- package/src/model/connectivity.js +371 -0
- package/src/model/discovery.js +582 -0
- package/src/model/native-catalog.js +68 -0
- package/src/model/openai-adapter.js +671 -0
- package/src/model/probe.js +264 -0
- package/src/model/providers.js +756 -0
- package/src/model/routing.js +321 -0
- package/src/review/preset.js +868 -0
- package/src/review/prompts.js +126 -0
- package/src/review/reviewer.js +933 -0
- package/src/runtime/agent-runner.js +1738 -0
- package/src/runtime/endpoint-discovery.js +118 -0
- package/src/runtime/permissions.js +1429 -0
- package/src/runtime/sandbox.js +358 -0
- package/src/runtime/session-placement.js +1103 -0
- package/src/workspace/audit.js +775 -0
- package/src/workspace/locks.js +167 -0
- package/src/workspace/preflight.js +424 -0
- package/src/workspace/worktrees.js +613 -0
|
@@ -0,0 +1,2333 @@
|
|
|
1
|
+
// dsh-delegate — native DSH bundle-configuration page (browser half of the plugin).
|
|
2
|
+
//
|
|
3
|
+
// This file is the whole operator GUI. It is a *client plugin*, not a standalone
|
|
4
|
+
// dashboard and not a Codex surface: it registers the dsh-delegate bundle's
|
|
5
|
+
// configuration in the native **Plugins manager** (`plugins.bundle.config`,
|
|
6
|
+
// keyed by the bundle's npm package name), so it renders on this bundle's own
|
|
7
|
+
// details page inside that manager and disappears when the plugin is disabled.
|
|
8
|
+
// Desktop and Web both compose the same client-plugin/module system, so one
|
|
9
|
+
// `platform: "web"` client declaration serves both shells.
|
|
10
|
+
//
|
|
11
|
+
// Contract facts this file is written against (installed
|
|
12
|
+
// `@deepseek-ai/dsh-client-ui-plugin-manager` 0.2.1-rc.2,
|
|
13
|
+
// `lib/types/client/slot-contract.d.ts`):
|
|
14
|
+
//
|
|
15
|
+
// * `plugins.bundle.config` is `kind: 'keyed'`, `scope: 'root'`, keyed by the
|
|
16
|
+
// bundle package name, and is rendered only with `view: 'page'` (the manager's
|
|
17
|
+
// bundle detail page calls `renderSlot(..., { view: 'page' }, { entryKey })`).
|
|
18
|
+
// The slot's `owner` is `{ view }` plus an optional host `form`; this page
|
|
19
|
+
// keeps its own controls and does not use the host form.
|
|
20
|
+
// * `ctx.slots.inject(name, register)` runs `register` once the slot name is
|
|
21
|
+
// declared by its owning entry and disposes the registration when it is not.
|
|
22
|
+
// `ctx.slots.register(options, Component)` returns that disposer.
|
|
23
|
+
// * A slot registration declaring `locale` receives a `t` seat and requires an
|
|
24
|
+
// installed locale face. This page is deliberately Chinese-only and declares
|
|
25
|
+
// no `locale`, so it does not depend on the locale plugin being composed; all
|
|
26
|
+
// operator copy is written here once, in Chinese.
|
|
27
|
+
// * `inject` on a registration is either a plain props object or a
|
|
28
|
+
// `{ hooks, keyedHooks }` face. We return a plain object holding the store, so
|
|
29
|
+
// the component subscribes to the store itself with `useSyncExternalStore`.
|
|
30
|
+
// * A registrant merges the slot contract with `import type` and registers
|
|
31
|
+
// through `ctx.slots`; it never imports the plugin-manager package at
|
|
32
|
+
// runtime. Ordering comes from `dsh.client.inject` in package.json, which
|
|
33
|
+
// names `@deepseek-ai/dsh-client-ui-plugin-manager` so its factory is
|
|
34
|
+
// registered (and its slot declared) before this registration materializes.
|
|
35
|
+
//
|
|
36
|
+
// Security properties that must survive any edit of this file:
|
|
37
|
+
//
|
|
38
|
+
// * No `dangerouslySetInnerHTML` anywhere: model output, diffs and host
|
|
39
|
+
// diagnostics are rendered as text nodes only.
|
|
40
|
+
// * Provider credentials are not entered here. New selections come from DSH's
|
|
41
|
+
// registered provider list, so their existing credential configuration stays
|
|
42
|
+
// inside DSH.
|
|
43
|
+
// * Nothing here submits a task. The GUI controls local MCP access and settings;
|
|
44
|
+
// the MCP host submits. The task panel offers cancel and retry guidance.
|
|
45
|
+
//
|
|
46
|
+
// React and `react/jsx-runtime` are the only module requests this bundle makes
|
|
47
|
+
// beyond `@deepseek-ai/*` platform modules, which is why the native loader can
|
|
48
|
+
// resolve every external against its frozen platform table.
|
|
49
|
+
|
|
50
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
51
|
+
|
|
52
|
+
import {
|
|
53
|
+
CONNECTIVITY_LAYERS,
|
|
54
|
+
CONVERSATION_POLICY_LABEL,
|
|
55
|
+
EFFORT_LABELS,
|
|
56
|
+
EFFORT_UNSET,
|
|
57
|
+
GRANT_KIND_LABELS,
|
|
58
|
+
ISOLATION_LABELS,
|
|
59
|
+
ISOLATION_MODES,
|
|
60
|
+
KNOWN_EFFORTS,
|
|
61
|
+
LIMITS,
|
|
62
|
+
PERMISSION_DECISION_LABELS,
|
|
63
|
+
PERMISSION_OUTCOME_LABELS,
|
|
64
|
+
PERMISSION_STATE_LABELS,
|
|
65
|
+
REVIEW_STATE_LABELS,
|
|
66
|
+
REVIEW_VERDICT_LABELS,
|
|
67
|
+
SUPPORTED_PROTOCOLS,
|
|
68
|
+
TASK_STATES,
|
|
69
|
+
boundedText,
|
|
70
|
+
changedFiles,
|
|
71
|
+
clone,
|
|
72
|
+
codexMcpDriftText,
|
|
73
|
+
codexTargetView,
|
|
74
|
+
createApi,
|
|
75
|
+
createStore,
|
|
76
|
+
describeCodexOutcome,
|
|
77
|
+
describeError,
|
|
78
|
+
documentFromDraft,
|
|
79
|
+
draftFromSettings,
|
|
80
|
+
duplicateProviderIds,
|
|
81
|
+
exportDocument,
|
|
82
|
+
formatTime,
|
|
83
|
+
grantState,
|
|
84
|
+
isAwaitingPermission,
|
|
85
|
+
isCancellable,
|
|
86
|
+
hasLiveTasks,
|
|
87
|
+
formatDuration,
|
|
88
|
+
isLiveTask,
|
|
89
|
+
minutesToSeconds,
|
|
90
|
+
monitoringOf,
|
|
91
|
+
pendingPermission,
|
|
92
|
+
permissionSummary,
|
|
93
|
+
precheckDraft,
|
|
94
|
+
precheckMonitoring,
|
|
95
|
+
previewEffective,
|
|
96
|
+
secondsToMinutes,
|
|
97
|
+
SELF_CHECK_LABELS,
|
|
98
|
+
taskActivity,
|
|
99
|
+
taskOutcome,
|
|
100
|
+
taskPhaseLabel,
|
|
101
|
+
taskProgress,
|
|
102
|
+
taskStateLabel,
|
|
103
|
+
WAIT_REASON_LABELS,
|
|
104
|
+
} from './api.js';
|
|
105
|
+
import { injectStyles } from './styles.js';
|
|
106
|
+
|
|
107
|
+
/** Plugins-manager config slot this page occupies. */
|
|
108
|
+
export const PLUGIN_CONFIG_SLOT = 'plugins.bundle.config';
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Key of this bundle's configuration entry: exactly the bundle's npm package
|
|
112
|
+
* name. The Plugins manager looks the entry up by `pkg.name`, so any other key
|
|
113
|
+
* registers a page that never renders.
|
|
114
|
+
*/
|
|
115
|
+
export const PLUGIN_BUNDLE_KEY = 'dsh-taskbridge';
|
|
116
|
+
|
|
117
|
+
/** Required client services: slot registration only. */
|
|
118
|
+
export const inject = ['slots'];
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Register the bundle configuration page on a client context.
|
|
122
|
+
*
|
|
123
|
+
* Split out from {@link apply} so a test can drive it with a fake `ctx` and
|
|
124
|
+
* assert the registration contract (slot name, key, inject face) without a
|
|
125
|
+
* browser.
|
|
126
|
+
* @param {object} ctx - client Cordis context providing `slots`.
|
|
127
|
+
* @param {object} options - `store`.
|
|
128
|
+
* @returns {Function} disposer releasing the registration.
|
|
129
|
+
*/
|
|
130
|
+
export function registerBundleConfiguration(ctx, options) {
|
|
131
|
+
const store = options.store;
|
|
132
|
+
const injectFace = () => ({ store });
|
|
133
|
+
return ctx.slots.inject(PLUGIN_CONFIG_SLOT, () => ctx.slots.register({
|
|
134
|
+
name: PLUGIN_CONFIG_SLOT,
|
|
135
|
+
key: PLUGIN_BUNDLE_KEY,
|
|
136
|
+
inject: injectFace,
|
|
137
|
+
}, DelegateConfigPage));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Client plugin body.
|
|
142
|
+
* @param {object} ctx - client Cordis context.
|
|
143
|
+
*/
|
|
144
|
+
export function apply(ctx) {
|
|
145
|
+
ctx.effect(() => injectStyles(globalThis.document), 'dsh-delegate: settings styles');
|
|
146
|
+
const store = createStore({ api: createApi() });
|
|
147
|
+
ctx.effect(() => () => store.dispose(), 'dsh-delegate: settings store');
|
|
148
|
+
ctx.effect(() => registerBundleConfiguration(ctx, { store }), 'dsh-delegate: bundle configuration');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
// Small presentational helpers
|
|
153
|
+
// ---------------------------------------------------------------------------
|
|
154
|
+
|
|
155
|
+
/** @param {object} props @returns {object} */
|
|
156
|
+
function Badge({ tone = 'off', children }) {
|
|
157
|
+
return <span className={`dshdg-badge dshdg-badge-${tone}`}>{children}</span>;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** @param {object} props @returns {object} */
|
|
161
|
+
function Field({ label, hint, htmlFor, children }) {
|
|
162
|
+
return (
|
|
163
|
+
<div className="dshdg-field">
|
|
164
|
+
{label === undefined ? null : <label htmlFor={htmlFor}>{label}</label>}
|
|
165
|
+
{children}
|
|
166
|
+
{hint === undefined ? null : <span className="dshdg-hint">{hint}</span>}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Integer input bounded by the host validator's limits.
|
|
173
|
+
* @param {object} props - `label`, `value`, `min`, `max`, `onChange`, `hint`, `disabled`.
|
|
174
|
+
* @returns {object} a numeric field.
|
|
175
|
+
*/
|
|
176
|
+
function IntegerField({ label, value, min, max, onChange, hint, disabled = false, id }) {
|
|
177
|
+
return (
|
|
178
|
+
<Field label={label} hint={hint} htmlFor={id}>
|
|
179
|
+
<input
|
|
180
|
+
id={id}
|
|
181
|
+
type="number"
|
|
182
|
+
inputMode="numeric"
|
|
183
|
+
min={min}
|
|
184
|
+
max={max}
|
|
185
|
+
step={1}
|
|
186
|
+
disabled={disabled}
|
|
187
|
+
value={Number.isFinite(Number(value)) ? String(value) : ''}
|
|
188
|
+
onChange={(event) => {
|
|
189
|
+
const raw = event.target.value;
|
|
190
|
+
onChange(raw === '' ? '' : Number(raw));
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
193
|
+
</Field>
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Provider/model/effort selector triple.
|
|
199
|
+
*
|
|
200
|
+
* The effort list is derived from the *selected model's declared* capabilities,
|
|
201
|
+
* never from a global list, so an unsupported combination cannot be produced by
|
|
202
|
+
* the form in the first place. A model that declares no efforts shows only "不指定".
|
|
203
|
+
* @param {object} props - `providers`, `value`, `onChange`, `idPrefix`, `modelCatalog`.
|
|
204
|
+
* @returns {object} three fields.
|
|
205
|
+
*/
|
|
206
|
+
function SelectionFields(props) {
|
|
207
|
+
const { providers, value, onChange, idPrefix } = props;
|
|
208
|
+
const provider = providers.find((entry) => entry.id === value.providerId) ?? null;
|
|
209
|
+
const models = provider === null ? [] : (provider.models ?? []);
|
|
210
|
+
const model = models.find((entry) => entry.id === value.model) ?? null;
|
|
211
|
+
const efforts = model === null ? [] : (model.efforts ?? []);
|
|
212
|
+
return (
|
|
213
|
+
<div className="dshdg-grid">
|
|
214
|
+
<Field label="提供方" htmlFor={`${idPrefix}-provider`}>
|
|
215
|
+
<select
|
|
216
|
+
id={`${idPrefix}-provider`}
|
|
217
|
+
value={value.providerId ?? ''}
|
|
218
|
+
onChange={(event) => {
|
|
219
|
+
onChange({ providerId: event.target.value === '' ? null : event.target.value, model: null, reasoningEffort: null });
|
|
220
|
+
}}
|
|
221
|
+
>
|
|
222
|
+
<option value="">(未选择)</option>
|
|
223
|
+
{providers.map((entry) => (
|
|
224
|
+
<option key={entry.id} value={entry.id}>{entry.name === '' ? entry.id : `${entry.name}(${entry.id})`}</option>
|
|
225
|
+
))}
|
|
226
|
+
</select>
|
|
227
|
+
</Field>
|
|
228
|
+
<Field label="模型" htmlFor={`${idPrefix}-model`}>
|
|
229
|
+
<select
|
|
230
|
+
id={`${idPrefix}-model`}
|
|
231
|
+
value={value.model ?? ''}
|
|
232
|
+
disabled={provider === null}
|
|
233
|
+
onChange={(event) => {
|
|
234
|
+
const nextModel = event.target.value === '' ? null : event.target.value;
|
|
235
|
+
const declared = (models.find((entry) => entry.id === nextModel)?.efforts ?? []);
|
|
236
|
+
const keep = value.reasoningEffort === null || declared.includes(value.reasoningEffort)
|
|
237
|
+
? value.reasoningEffort
|
|
238
|
+
: null;
|
|
239
|
+
onChange({ providerId: value.providerId ?? null, model: nextModel, reasoningEffort: keep });
|
|
240
|
+
}}
|
|
241
|
+
>
|
|
242
|
+
<option value="">(未选择)</option>
|
|
243
|
+
{models.map((entry) => (
|
|
244
|
+
<option key={entry.id} value={entry.id}>{entry.id}</option>
|
|
245
|
+
))}
|
|
246
|
+
</select>
|
|
247
|
+
</Field>
|
|
248
|
+
<Field
|
|
249
|
+
label="推理强度"
|
|
250
|
+
htmlFor={`${idPrefix}-effort`}
|
|
251
|
+
hint={model === null
|
|
252
|
+
? '选择模型后显示该模型声明的推理强度'
|
|
253
|
+
: (efforts.length === 0 ? '该模型未声明推理强度,只能不指定' : '仅列出该模型声明的能力')}
|
|
254
|
+
>
|
|
255
|
+
<select
|
|
256
|
+
id={`${idPrefix}-effort`}
|
|
257
|
+
value={value.reasoningEffort ?? EFFORT_UNSET}
|
|
258
|
+
disabled={model === null || efforts.length === 0}
|
|
259
|
+
onChange={(event) => {
|
|
260
|
+
onChange({ ...value, reasoningEffort: event.target.value === EFFORT_UNSET ? null : event.target.value });
|
|
261
|
+
}}
|
|
262
|
+
>
|
|
263
|
+
<option value={EFFORT_UNSET}>(不指定)</option>
|
|
264
|
+
{efforts.map((effort) => (
|
|
265
|
+
<option key={effort} value={effort}>{`${EFFORT_LABELS[effort] ?? effort}(${effort})`}</option>
|
|
266
|
+
))}
|
|
267
|
+
</select>
|
|
268
|
+
</Field>
|
|
269
|
+
</div>
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* One connectivity layer row.
|
|
275
|
+
* @param {object} props - `label`, `result`, `name`.
|
|
276
|
+
* @returns {object} a row.
|
|
277
|
+
*/
|
|
278
|
+
function ConnectivityLayer({ label, name, result }) {
|
|
279
|
+
const ok = result?.ok;
|
|
280
|
+
const tone = ok === true ? 'dshdg-ok' : (ok === false ? 'dshdg-fail' : 'dshdg-unknown');
|
|
281
|
+
const verdict = ok === true ? '通过' : (ok === false ? '未通过' : '未确认');
|
|
282
|
+
const detail = result?.detail ?? null;
|
|
283
|
+
const detailText = detail === null
|
|
284
|
+
? ''
|
|
285
|
+
: (typeof detail === 'string' ? detail : `${detail.code ?? ''}${detail.message === undefined ? '' : ` · ${detail.message}`}`);
|
|
286
|
+
return (
|
|
287
|
+
<div className="dshdg-layer">
|
|
288
|
+
<span>
|
|
289
|
+
{label}
|
|
290
|
+
{' '}
|
|
291
|
+
<span className={tone}>{verdict}</span>
|
|
292
|
+
</span>
|
|
293
|
+
<span className="dshdg-layer-detail dshdg-mono" data-layer={name}>
|
|
294
|
+
{detailText === '' ? '—' : detailText}
|
|
295
|
+
</span>
|
|
296
|
+
</div>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// ---------------------------------------------------------------------------
|
|
301
|
+
// Notices
|
|
302
|
+
// ---------------------------------------------------------------------------
|
|
303
|
+
|
|
304
|
+
/** @param {object} props @returns {object|null} the notice strip. */
|
|
305
|
+
function Notices({ store, notices }) {
|
|
306
|
+
if (notices.length === 0) return null;
|
|
307
|
+
return (
|
|
308
|
+
<div className="dshdg-notices" role="status" aria-live="polite">
|
|
309
|
+
{notices.map((notice) => (
|
|
310
|
+
<div key={String(notice.id)} className={`dshdg-notice dshdg-notice-${notice.level}`}>
|
|
311
|
+
<span>{notice.text}</span>
|
|
312
|
+
<button type="button" onClick={() => store.dismissNotice(notice.id)} aria-label="关闭提示">关闭</button>
|
|
313
|
+
</div>
|
|
314
|
+
))}
|
|
315
|
+
</div>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
// Authorization (rendered above the four areas)
|
|
321
|
+
// ---------------------------------------------------------------------------
|
|
322
|
+
|
|
323
|
+
/** @param {object} props @returns {object} the authorization card. */
|
|
324
|
+
function AuthorizationPanel({ store, snapshot }) {
|
|
325
|
+
const enabled = snapshot.status?.delegation?.mode === 'switch'
|
|
326
|
+
? snapshot.status.delegation.authorized === true
|
|
327
|
+
: snapshot.settings?.delegationEnabled === true;
|
|
328
|
+
const busy = snapshot.loading?.delegationSwitch === true;
|
|
329
|
+
return (
|
|
330
|
+
<section className="dshdg-card" aria-labelledby="dshdg-auth-title">
|
|
331
|
+
<div className="dshdg-row">
|
|
332
|
+
<h3 id="dshdg-auth-title">本机调用授权</h3>
|
|
333
|
+
<span className="dshdg-spacer" />
|
|
334
|
+
<Badge tone={enabled ? 'on' : 'off'}>{enabled ? '已开启' : '已关闭'}</Badge>
|
|
335
|
+
</div>
|
|
336
|
+
<div className="dshdg-row">
|
|
337
|
+
<label className="dshdg-switch" htmlFor="dshdg-delegation-switch">
|
|
338
|
+
<input
|
|
339
|
+
id="dshdg-delegation-switch"
|
|
340
|
+
type="checkbox"
|
|
341
|
+
role="switch"
|
|
342
|
+
checked={enabled}
|
|
343
|
+
disabled={busy || snapshot.status === null}
|
|
344
|
+
onChange={(event) => { void store.setDelegationEnabled(event.target.checked); }}
|
|
345
|
+
/>
|
|
346
|
+
允许本机 MCP 调用 DSH 委派
|
|
347
|
+
</label>
|
|
348
|
+
<span className="dshdg-spacer" />
|
|
349
|
+
<span className="dshdg-hint">{busy ? '正在更新…' : (enabled ? '关闭后会拒绝新任务并停止运行中的任务' : '关闭状态会拒绝所有委派请求')}</span>
|
|
350
|
+
</div>
|
|
351
|
+
</section>
|
|
352
|
+
);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function LegacyAuthorizationPanel({ store, snapshot }) {
|
|
356
|
+
const [label, setLabel] = useState('codex');
|
|
357
|
+
const [kind, setKind] = useState('task');
|
|
358
|
+
const [workspacePath, setWorkspacePath] = useState('');
|
|
359
|
+
const [ttlSeconds, setTtlSeconds] = useState('');
|
|
360
|
+
const [copied, setCopied] = useState('');
|
|
361
|
+
const posture = snapshot.status?.delegation ?? null;
|
|
362
|
+
const connections = snapshot.connections ?? [];
|
|
363
|
+
const live = connections.filter((entry) => entry.revoked !== true);
|
|
364
|
+
const selected = live.find((entry) => entry.connectionId === snapshot.selectedConnectionId) ?? null;
|
|
365
|
+
const grants = snapshot.grants ?? [];
|
|
366
|
+
const now = Date.now();
|
|
367
|
+
|
|
368
|
+
const busy = (key) => snapshot.loading?.[key] === true;
|
|
369
|
+
// The engine reports `{ authorized, reason }`; `authorized` is the only
|
|
370
|
+
// authority. The page never derives authorization from what it displays.
|
|
371
|
+
const authorized = posture?.authorized === true;
|
|
372
|
+
|
|
373
|
+
return (
|
|
374
|
+
<section className="dshdg-card" aria-labelledby="dshdg-auth-title">
|
|
375
|
+
<div className="dshdg-row">
|
|
376
|
+
<h3 id="dshdg-auth-title">授权(外部连接)</h3>
|
|
377
|
+
<span className="dshdg-spacer" />
|
|
378
|
+
{posture === null
|
|
379
|
+
? <Badge tone="off">状态未知</Badge>
|
|
380
|
+
: (authorized
|
|
381
|
+
? <Badge tone="on">已授权</Badge>
|
|
382
|
+
: <Badge tone="off">默认关闭</Badge>)}
|
|
383
|
+
</div>
|
|
384
|
+
<p className="dshdg-muted">
|
|
385
|
+
委托默认关闭,安装、重启或提到 DeepSeek 都不会自动开启。只有在这里给<strong>宿主签发的连接</strong>授权后,
|
|
386
|
+
MCP 宿主才能提交任务;插件与 MCP 都无法自行授权。授权由服务端校验,界面只是入口。
|
|
387
|
+
</p>
|
|
388
|
+
<div className="dshdg-kv dshdg-mono">
|
|
389
|
+
<dt>执行通道</dt>
|
|
390
|
+
<dd>
|
|
391
|
+
{snapshot.status?.runtime?.executionPlane ?? '—'}
|
|
392
|
+
{snapshot.status?.runtime?.executionPlaneLocalOnly === true ? '(仅本机)' : '(非本机绑定,请确认暴露面)'}
|
|
393
|
+
</dd>
|
|
394
|
+
<dt>本机绑定</dt>
|
|
395
|
+
<dd>{snapshot.status?.runtime?.bind ?? '—'}:{snapshot.status?.runtime?.port ?? '—'}</dd>
|
|
396
|
+
<dt>宿主裁决</dt>
|
|
397
|
+
<dd>{posture === null ? '—' : (authorized ? '当前存在有效授权' : (posture.reason ?? '未授权'))}</dd>
|
|
398
|
+
</div>
|
|
399
|
+
|
|
400
|
+
<div className="dshdg-row">
|
|
401
|
+
<Field label="连接显示名" htmlFor="dshdg-conn-label" hint="仅用于你区分连接,不影响权限。">
|
|
402
|
+
<input
|
|
403
|
+
id="dshdg-conn-label"
|
|
404
|
+
type="text"
|
|
405
|
+
value={label}
|
|
406
|
+
maxLength={60}
|
|
407
|
+
onChange={(event) => setLabel(event.target.value)}
|
|
408
|
+
/>
|
|
409
|
+
</Field>
|
|
410
|
+
<button
|
|
411
|
+
type="button"
|
|
412
|
+
className="dshdg-primary"
|
|
413
|
+
disabled={busy('issueConnection')}
|
|
414
|
+
onClick={() => { void store.issueConnection(label); }}
|
|
415
|
+
>
|
|
416
|
+
{busy('issueConnection') ? '签发中…' : '签发新连接'}
|
|
417
|
+
</button>
|
|
418
|
+
</div>
|
|
419
|
+
|
|
420
|
+
{snapshot.token === null ? null : (
|
|
421
|
+
<div className="dshdg-secret-warning">
|
|
422
|
+
<strong>连接令牌只显示这一次</strong>
|
|
423
|
+
<p className="dshdg-muted">
|
|
424
|
+
请立即复制到 MCP 宿主配置(形如 <span className="dshdg-mono">Authorization: Bearer …</span>)。
|
|
425
|
+
令牌仅保存在本页面内存中,不会写入地址栏、日志、localStorage 或 sessionStorage;关闭对话框或刷新后无法再次查看,只能重新签发。
|
|
426
|
+
</p>
|
|
427
|
+
<code className="dshdg-token dshdg-mono">{snapshot.token}</code>
|
|
428
|
+
<div className="dshdg-row">
|
|
429
|
+
<button
|
|
430
|
+
type="button"
|
|
431
|
+
onClick={async () => {
|
|
432
|
+
try {
|
|
433
|
+
await globalThis.navigator?.clipboard?.writeText(snapshot.token);
|
|
434
|
+
setCopied('已复制到剪贴板');
|
|
435
|
+
} catch {
|
|
436
|
+
setCopied('无法访问剪贴板,请手动选中复制');
|
|
437
|
+
}
|
|
438
|
+
}}
|
|
439
|
+
>
|
|
440
|
+
复制令牌
|
|
441
|
+
</button>
|
|
442
|
+
<button type="button" onClick={() => { setCopied(''); store.clearToken(); }}>我已完成,清除显示</button>
|
|
443
|
+
{copied === '' ? null : <span className="dshdg-hint">{copied}</span>}
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
)}
|
|
447
|
+
|
|
448
|
+
<div className="dshdg-grid">
|
|
449
|
+
<Field label="选择连接" htmlFor="dshdg-conn-select" hint="授权只能绑定宿主签发的连接身份,不接受手填身份。">
|
|
450
|
+
<select
|
|
451
|
+
id="dshdg-conn-select"
|
|
452
|
+
value={snapshot.selectedConnectionId ?? ''}
|
|
453
|
+
onChange={(event) => { void store.selectConnection(event.target.value === '' ? null : event.target.value); }}
|
|
454
|
+
>
|
|
455
|
+
<option value="">(未选择)</option>
|
|
456
|
+
{live.map((entry) => (
|
|
457
|
+
<option key={entry.connectionId} value={entry.connectionId}>
|
|
458
|
+
{`${entry.label ?? '连接'} · ${entry.connectionId.slice(0, 8)}…`}
|
|
459
|
+
</option>
|
|
460
|
+
))}
|
|
461
|
+
</select>
|
|
462
|
+
</Field>
|
|
463
|
+
<Field label="授权范围" htmlFor="dshdg-grant-kind">
|
|
464
|
+
<select id="dshdg-grant-kind" value={kind} onChange={(event) => setKind(event.target.value)}>
|
|
465
|
+
<option value="task">{GRANT_KIND_LABELS.task}</option>
|
|
466
|
+
<option value="session">{GRANT_KIND_LABELS.session}</option>
|
|
467
|
+
</select>
|
|
468
|
+
</Field>
|
|
469
|
+
<Field label="授权工作区(绝对路径)" htmlFor="dshdg-grant-workspace" hint="任务只能改这个目录;隔离方式在执行设置里。">
|
|
470
|
+
<input
|
|
471
|
+
id="dshdg-grant-workspace"
|
|
472
|
+
type="text"
|
|
473
|
+
value={workspacePath}
|
|
474
|
+
placeholder="C:\\work\\project"
|
|
475
|
+
onChange={(event) => setWorkspacePath(event.target.value)}
|
|
476
|
+
/>
|
|
477
|
+
</Field>
|
|
478
|
+
<Field
|
|
479
|
+
label="有效期(秒,可留空用默认)"
|
|
480
|
+
htmlFor="dshdg-grant-ttl"
|
|
481
|
+
hint={kind === 'task'
|
|
482
|
+
? `${LIMITS.taskGrantTtlSecondsMin}–${LIMITS.taskGrantTtlSecondsMax} 秒`
|
|
483
|
+
: `${LIMITS.sessionGrantTtlSecondsMin}–${LIMITS.sessionGrantTtlSecondsMax} 秒`}
|
|
484
|
+
>
|
|
485
|
+
<input
|
|
486
|
+
id="dshdg-grant-ttl"
|
|
487
|
+
type="number"
|
|
488
|
+
min={kind === 'task' ? LIMITS.taskGrantTtlSecondsMin : LIMITS.sessionGrantTtlSecondsMin}
|
|
489
|
+
max={kind === 'task' ? LIMITS.taskGrantTtlSecondsMax : LIMITS.sessionGrantTtlSecondsMax}
|
|
490
|
+
step={1}
|
|
491
|
+
value={ttlSeconds}
|
|
492
|
+
onChange={(event) => setTtlSeconds(event.target.value)}
|
|
493
|
+
/>
|
|
494
|
+
</Field>
|
|
495
|
+
</div>
|
|
496
|
+
|
|
497
|
+
<div className="dshdg-row">
|
|
498
|
+
<button
|
|
499
|
+
type="button"
|
|
500
|
+
className="dshdg-primary"
|
|
501
|
+
disabled={busy('issueGrant') || snapshot.selectedConnectionId === null}
|
|
502
|
+
onClick={() => {
|
|
503
|
+
void store.issueGrant({
|
|
504
|
+
connectionId: snapshot.selectedConnectionId,
|
|
505
|
+
kind,
|
|
506
|
+
workspacePath,
|
|
507
|
+
ttlSeconds: ttlSeconds === '' ? undefined : Number(ttlSeconds),
|
|
508
|
+
});
|
|
509
|
+
}}
|
|
510
|
+
>
|
|
511
|
+
{busy('issueGrant') ? '签发中…' : (kind === 'task' ? '授权一次任务' : '授权本连接会话')}
|
|
512
|
+
</button>
|
|
513
|
+
<button
|
|
514
|
+
type="button"
|
|
515
|
+
disabled={busy('issueGrant') || snapshot.selectedConnectionId === null}
|
|
516
|
+
onClick={() => { void store.loadGrants(snapshot.selectedConnectionId); }}
|
|
517
|
+
>
|
|
518
|
+
刷新授权
|
|
519
|
+
</button>
|
|
520
|
+
<span className="dshdg-spacer" />
|
|
521
|
+
<button
|
|
522
|
+
type="button"
|
|
523
|
+
className="dshdg-danger"
|
|
524
|
+
disabled={busy('revokeAll')}
|
|
525
|
+
onClick={() => { void store.revokeAll(); }}
|
|
526
|
+
>
|
|
527
|
+
{busy('revokeAll') ? '撤销中…' : '立即全部撤销'}
|
|
528
|
+
</button>
|
|
529
|
+
</div>
|
|
530
|
+
|
|
531
|
+
{selected === null ? (
|
|
532
|
+
<p className="dshdg-faint">还没有选择连接。先“签发新连接”,再把令牌配置到 MCP 宿主。</p>
|
|
533
|
+
) : (
|
|
534
|
+
<div className="dshdg-list">
|
|
535
|
+
<div className="dshdg-item-head">
|
|
536
|
+
<strong>{selected.label ?? '连接'}</strong>
|
|
537
|
+
<span className="dshdg-mono dshdg-faint">{selected.connectionId}</span>
|
|
538
|
+
<span className="dshdg-spacer" />
|
|
539
|
+
<button
|
|
540
|
+
type="button"
|
|
541
|
+
className="dshdg-danger"
|
|
542
|
+
disabled={busy('revokeConnection')}
|
|
543
|
+
onClick={() => { void store.revokeConnection(selected.connectionId); }}
|
|
544
|
+
>
|
|
545
|
+
撤销该连接
|
|
546
|
+
</button>
|
|
547
|
+
</div>
|
|
548
|
+
{grants.length === 0 ? (
|
|
549
|
+
<p className="dshdg-faint">该连接没有未撤销的授权;此时 MCP 提交任务会被拒绝。</p>
|
|
550
|
+
) : grants.map((grant) => {
|
|
551
|
+
const gstate = grantState(grant, now);
|
|
552
|
+
return (
|
|
553
|
+
<div className="dshdg-item" key={grant.grantId}>
|
|
554
|
+
<div className="dshdg-item-head">
|
|
555
|
+
<Badge tone={gstate.key === 'live' ? 'on' : 'off'}>{gstate.label}</Badge>
|
|
556
|
+
<span>{GRANT_KIND_LABELS[grant.kind] ?? grant.kind}</span>
|
|
557
|
+
<span className="dshdg-mono dshdg-faint">{grant.workspacePath}</span>
|
|
558
|
+
<span className="dshdg-spacer" />
|
|
559
|
+
<button
|
|
560
|
+
type="button"
|
|
561
|
+
className="dshdg-danger"
|
|
562
|
+
disabled={busy('revokeGrant') || gstate.key !== 'live'}
|
|
563
|
+
onClick={() => { void store.revokeGrant(grant.grantId); }}
|
|
564
|
+
>
|
|
565
|
+
撤销
|
|
566
|
+
</button>
|
|
567
|
+
</div>
|
|
568
|
+
<div className="dshdg-kv">
|
|
569
|
+
<dt>签发</dt>
|
|
570
|
+
<dd>{formatTime(grant.createdAt)}</dd>
|
|
571
|
+
<dt>到期</dt>
|
|
572
|
+
<dd>{formatTime(grant.expiresAt)}</dd>
|
|
573
|
+
{grant.consumedByTaskId === null || grant.consumedByTaskId === undefined ? null : (
|
|
574
|
+
<>
|
|
575
|
+
<dt>用掉于任务</dt>
|
|
576
|
+
<dd className="dshdg-mono">{grant.consumedByTaskId}</dd>
|
|
577
|
+
</>
|
|
578
|
+
)}
|
|
579
|
+
</div>
|
|
580
|
+
</div>
|
|
581
|
+
);
|
|
582
|
+
})}
|
|
583
|
+
</div>
|
|
584
|
+
)}
|
|
585
|
+
</section>
|
|
586
|
+
);
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// ---------------------------------------------------------------------------
|
|
590
|
+
// API management
|
|
591
|
+
// ---------------------------------------------------------------------------
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* One provider profile editor, including its separate credential seam.
|
|
595
|
+
* @param {object} props - `provider`, `store`, `snapshot`, `index`.
|
|
596
|
+
* @returns {object} an editor card.
|
|
597
|
+
*/
|
|
598
|
+
function ProviderEditor({ provider, store, snapshot, index }) {
|
|
599
|
+
const providerId = provider.id;
|
|
600
|
+
const credential = snapshot.credentials?.[providerId] ?? null;
|
|
601
|
+
// The secret never leaves this component's local state. It is not part of the
|
|
602
|
+
// draft, so it cannot be exported, saved with the document, or restored.
|
|
603
|
+
const [secret, setSecret] = useState('');
|
|
604
|
+
const [confirmRemove, setConfirmRemove] = useState(false);
|
|
605
|
+
const [checkModel, setCheckModel] = useState('');
|
|
606
|
+
const [checkEffort, setCheckEffort] = useState('');
|
|
607
|
+
const busyKey = snapshot.loading?.[`credential:${providerId}`] === true;
|
|
608
|
+
const report = snapshot.connectivity?.[providerId] ?? null;
|
|
609
|
+
const fetched = snapshot.modelCatalog?.[providerId] ?? null;
|
|
610
|
+
const models = provider.models ?? [];
|
|
611
|
+
|
|
612
|
+
const editProvider = useCallback((mutate) => {
|
|
613
|
+
store.editDraft((draft) => {
|
|
614
|
+
const target = draft.providers.find((entry) => entry.id === providerId);
|
|
615
|
+
if (target !== undefined) mutate(target);
|
|
616
|
+
});
|
|
617
|
+
}, [store, providerId]);
|
|
618
|
+
|
|
619
|
+
const selectedModel = models.find((entry) => entry.id === checkModel) ?? null;
|
|
620
|
+
|
|
621
|
+
return (
|
|
622
|
+
<div className="dshdg-item">
|
|
623
|
+
<div className="dshdg-item-head">
|
|
624
|
+
<strong>{provider.name === '' ? `提供方 ${index + 1}` : provider.name}</strong>
|
|
625
|
+
<span className="dshdg-mono dshdg-faint">{provider.id || '(标识未填)'}</span>
|
|
626
|
+
<span className="dshdg-spacer" />
|
|
627
|
+
<button
|
|
628
|
+
type="button"
|
|
629
|
+
className="dshdg-danger"
|
|
630
|
+
disabled={snapshot.dirty !== true}
|
|
631
|
+
title="删除后需要保存才会生效"
|
|
632
|
+
onClick={() => {
|
|
633
|
+
store.editDraft((draft) => {
|
|
634
|
+
draft.providers = draft.providers.filter((entry) => entry.id !== providerId);
|
|
635
|
+
});
|
|
636
|
+
}}
|
|
637
|
+
>
|
|
638
|
+
删除
|
|
639
|
+
</button>
|
|
640
|
+
</div>
|
|
641
|
+
|
|
642
|
+
<div className="dshdg-grid">
|
|
643
|
+
<Field label="标识" htmlFor={`dshdg-p${index}-id`} hint="3–40 位小写字母、数字、连字符;保存后用作路由 id。">
|
|
644
|
+
<input
|
|
645
|
+
id={`dshdg-p${index}-id`}
|
|
646
|
+
type="text"
|
|
647
|
+
value={provider.id}
|
|
648
|
+
onChange={(event) => {
|
|
649
|
+
const nextId = event.target.value.trim().toLowerCase();
|
|
650
|
+
store.editDraft((draft) => {
|
|
651
|
+
const target = draft.providers.find((entry) => entry.id === providerId);
|
|
652
|
+
if (target === undefined) return;
|
|
653
|
+
target.id = nextId;
|
|
654
|
+
for (const block of [draft.worker, draft.review]) {
|
|
655
|
+
if (block?.providerId === providerId) block.providerId = nextId;
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}}
|
|
659
|
+
/>
|
|
660
|
+
</Field>
|
|
661
|
+
<Field label="显示名称" htmlFor={`dshdg-p${index}-name`}>
|
|
662
|
+
<input
|
|
663
|
+
id={`dshdg-p${index}-name`}
|
|
664
|
+
type="text"
|
|
665
|
+
value={provider.name}
|
|
666
|
+
onChange={(event) => editProvider((target) => { target.name = event.target.value; })}
|
|
667
|
+
/>
|
|
668
|
+
</Field>
|
|
669
|
+
<Field label="协议" htmlFor={`dshdg-p${index}-protocol`}>
|
|
670
|
+
<select
|
|
671
|
+
id={`dshdg-p${index}-protocol`}
|
|
672
|
+
value={provider.protocol}
|
|
673
|
+
onChange={(event) => editProvider((target) => { target.protocol = event.target.value; })}
|
|
674
|
+
>
|
|
675
|
+
{SUPPORTED_PROTOCOLS.map((protocol) => (
|
|
676
|
+
<option key={protocol} value={protocol}>OpenAI 兼容 Chat Completions({protocol})</option>
|
|
677
|
+
))}
|
|
678
|
+
</select>
|
|
679
|
+
</Field>
|
|
680
|
+
<Field label="接口地址" htmlFor={`dshdg-p${index}-baseurl`} hint="http/https,不带账号密码、查询串或片段。">
|
|
681
|
+
<input
|
|
682
|
+
id={`dshdg-p${index}-baseurl`}
|
|
683
|
+
type="text"
|
|
684
|
+
value={provider.baseUrl}
|
|
685
|
+
placeholder="https://api.example.com/v1"
|
|
686
|
+
onChange={(event) => editProvider((target) => { target.baseUrl = event.target.value; })}
|
|
687
|
+
/>
|
|
688
|
+
</Field>
|
|
689
|
+
<Field label="凭据引用名(可选)" htmlFor={`dshdg-p${index}-ref`} hint="复用宿主环境变量/凭据引用;不要填密钥本身。">
|
|
690
|
+
<input
|
|
691
|
+
id={`dshdg-p${index}-ref`}
|
|
692
|
+
type="text"
|
|
693
|
+
value={provider.credentialRef ?? ''}
|
|
694
|
+
placeholder="MY_PROVIDER_API_KEY"
|
|
695
|
+
onChange={(event) => {
|
|
696
|
+
const value = event.target.value.trim();
|
|
697
|
+
editProvider((target) => { target.credentialRef = value === '' ? null : value; });
|
|
698
|
+
}}
|
|
699
|
+
/>
|
|
700
|
+
</Field>
|
|
701
|
+
</div>
|
|
702
|
+
|
|
703
|
+
<div className="dshdg-card">
|
|
704
|
+
<div className="dshdg-row">
|
|
705
|
+
<h4>密钥(独立通道)</h4>
|
|
706
|
+
<span className="dshdg-spacer" />
|
|
707
|
+
{credential === null || credential.loaded !== true ? (
|
|
708
|
+
<Badge tone="off">未检查</Badge>
|
|
709
|
+
) : credential.unavailable === true ? (
|
|
710
|
+
<Badge tone="warn">宿主未提供凭据接口</Badge>
|
|
711
|
+
) : credential.configured === true ? (
|
|
712
|
+
<Badge tone="on">{`已配置${credential.source === undefined ? '' : `(${credential.source})`}`}</Badge>
|
|
713
|
+
) : (
|
|
714
|
+
<Badge tone="off">未配置</Badge>
|
|
715
|
+
)}
|
|
716
|
+
<button
|
|
717
|
+
type="button"
|
|
718
|
+
disabled={busyKey}
|
|
719
|
+
onClick={() => { void store.credentialStatus(providerId); }}
|
|
720
|
+
>
|
|
721
|
+
检查状态
|
|
722
|
+
</button>
|
|
723
|
+
</div>
|
|
724
|
+
<p className="dshdg-hint">
|
|
725
|
+
密钥值不会进入设置文档、导出文本、任务历史或日志,也不会回显。保存成功后输入框会被清空。
|
|
726
|
+
</p>
|
|
727
|
+
{credential?.unavailable === true
|
|
728
|
+
? <p className="dshdg-fail">{credential.reason}</p>
|
|
729
|
+
: null}
|
|
730
|
+
<div className="dshdg-row">
|
|
731
|
+
<input
|
|
732
|
+
id={`dshdg-p${index}-secret`}
|
|
733
|
+
type="password"
|
|
734
|
+
autoComplete="new-password"
|
|
735
|
+
spellCheck={false}
|
|
736
|
+
aria-label={`${provider.name || provider.id} 的密钥`}
|
|
737
|
+
placeholder={credential?.configured === true ? '已配置;输入新值可覆盖' : '粘贴密钥'}
|
|
738
|
+
value={secret}
|
|
739
|
+
onChange={(event) => setSecret(event.target.value)}
|
|
740
|
+
/>
|
|
741
|
+
<button
|
|
742
|
+
type="button"
|
|
743
|
+
className="dshdg-primary"
|
|
744
|
+
disabled={busyKey || secret.trim() === ''}
|
|
745
|
+
onClick={async () => {
|
|
746
|
+
const result = await store.setCredential(providerId, secret);
|
|
747
|
+
// Clear on success only: a failed save keeps the operator's paste so
|
|
748
|
+
// they can retry, and nothing has been stored either way.
|
|
749
|
+
if (result.ok === true) setSecret('');
|
|
750
|
+
}}
|
|
751
|
+
>
|
|
752
|
+
{busyKey ? '保存中…' : '保存密钥'}
|
|
753
|
+
</button>
|
|
754
|
+
{confirmRemove ? (
|
|
755
|
+
<>
|
|
756
|
+
<button
|
|
757
|
+
type="button"
|
|
758
|
+
className="dshdg-danger"
|
|
759
|
+
disabled={busyKey}
|
|
760
|
+
onClick={async () => {
|
|
761
|
+
setConfirmRemove(false);
|
|
762
|
+
await store.unsetCredential(providerId);
|
|
763
|
+
}}
|
|
764
|
+
>
|
|
765
|
+
确认清除
|
|
766
|
+
</button>
|
|
767
|
+
<button type="button" onClick={() => setConfirmRemove(false)}>取消</button>
|
|
768
|
+
</>
|
|
769
|
+
) : (
|
|
770
|
+
<button type="button" onClick={() => setConfirmRemove(true)}>清除密钥</button>
|
|
771
|
+
)}
|
|
772
|
+
</div>
|
|
773
|
+
</div>
|
|
774
|
+
|
|
775
|
+
<div className="dshdg-card">
|
|
776
|
+
<div className="dshdg-row">
|
|
777
|
+
<h4>模型与推理强度</h4>
|
|
778
|
+
<span className="dshdg-spacer" />
|
|
779
|
+
<button
|
|
780
|
+
type="button"
|
|
781
|
+
disabled={snapshot.loading?.[`models:${providerId}`] === true}
|
|
782
|
+
onClick={async () => {
|
|
783
|
+
const result = await store.fetchModels(providerId);
|
|
784
|
+
if (result.ok === true && Array.isArray(result.models)) store.mergeModelsIntoDraft(providerId, result.models);
|
|
785
|
+
}}
|
|
786
|
+
>
|
|
787
|
+
{snapshot.loading?.[`models:${providerId}`] === true ? '获取中…' : '从提供方获取模型'}
|
|
788
|
+
</button>
|
|
789
|
+
</div>
|
|
790
|
+
{fetched === null ? null : (
|
|
791
|
+
<p className={fetched.discovery?.failed === true ? 'dshdg-fail' : 'dshdg-hint'}>
|
|
792
|
+
{fetched.source === 'catalog'
|
|
793
|
+
? '宿主尚未提供从提供方获取模型的接口,以下结果来自宿主模型目录(不是远程模型列表)。'
|
|
794
|
+
: fetched.discovery?.failed === true
|
|
795
|
+
? `未能从提供方获取模型:${describeError(fetched.error ?? fetched.discovery)} 已保留现有手工配置,可继续使用。`
|
|
796
|
+
: `已从提供方接口获取 ${fetched.models.length} 个模型(${formatTime(fetched.fetchedAt)})。`}
|
|
797
|
+
{fetched.source === 'catalog' || fetched.discovery?.failed === true
|
|
798
|
+
? ''
|
|
799
|
+
: ' 模型列表不代表推理能力:导入后仍需为每个模型勾选其实际支持的推理强度。'}
|
|
800
|
+
</p>
|
|
801
|
+
)}
|
|
802
|
+
{models.length === 0 ? (
|
|
803
|
+
<p className="dshdg-faint">还没有模型。可以自动获取,也可以手动添加。</p>
|
|
804
|
+
) : models.map((model, modelIndex) => (
|
|
805
|
+
<div className="dshdg-item" key={`${model.id}-${String(modelIndex)}`}>
|
|
806
|
+
<div className="dshdg-item-head">
|
|
807
|
+
<input
|
|
808
|
+
type="text"
|
|
809
|
+
aria-label={`模型 ${modelIndex + 1} 的 ID`}
|
|
810
|
+
value={model.id}
|
|
811
|
+
onChange={(event) => {
|
|
812
|
+
editProvider((target) => {
|
|
813
|
+
const found = target.models[modelIndex];
|
|
814
|
+
if (found !== undefined) found.id = event.target.value.trim();
|
|
815
|
+
});
|
|
816
|
+
}}
|
|
817
|
+
/>
|
|
818
|
+
<span className="dshdg-spacer" />
|
|
819
|
+
<button
|
|
820
|
+
type="button"
|
|
821
|
+
className="dshdg-danger"
|
|
822
|
+
onClick={() => {
|
|
823
|
+
store.editDraft((draft) => {
|
|
824
|
+
const target = draft.providers.find((entry) => entry.id === providerId);
|
|
825
|
+
if (target === undefined) return;
|
|
826
|
+
const removed = target.models[modelIndex];
|
|
827
|
+
target.models.splice(modelIndex, 1);
|
|
828
|
+
// A selection pointing at the removed model would be
|
|
829
|
+
// unroutable; clear it here so the operator sees the
|
|
830
|
+
// consequence instead of saving an invalid pair.
|
|
831
|
+
if (removed !== undefined) {
|
|
832
|
+
for (const block of [draft.worker, draft.review]) {
|
|
833
|
+
if (block?.providerId === providerId && block?.model === removed.id) {
|
|
834
|
+
block.model = null;
|
|
835
|
+
block.reasoningEffort = null;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
}}
|
|
841
|
+
>
|
|
842
|
+
删除模型
|
|
843
|
+
</button>
|
|
844
|
+
</div>
|
|
845
|
+
<div className="dshdg-check" role="group" aria-label={`模型 ${model.id} 支持的推理强度`}>
|
|
846
|
+
{KNOWN_EFFORTS.map((effort) => (
|
|
847
|
+
<label key={effort}>
|
|
848
|
+
<input
|
|
849
|
+
type="checkbox"
|
|
850
|
+
checked={(model.efforts ?? []).includes(effort)}
|
|
851
|
+
onChange={(event) => {
|
|
852
|
+
editProvider((target) => {
|
|
853
|
+
const found = target.models[modelIndex];
|
|
854
|
+
if (found === undefined) return;
|
|
855
|
+
const next = new Set(found.efforts ?? []);
|
|
856
|
+
if (event.target.checked) next.add(effort);
|
|
857
|
+
else next.delete(effort);
|
|
858
|
+
found.efforts = KNOWN_EFFORTS.filter((id) => next.has(id));
|
|
859
|
+
});
|
|
860
|
+
}}
|
|
861
|
+
/>
|
|
862
|
+
{EFFORT_LABELS[effort]}({effort})
|
|
863
|
+
</label>
|
|
864
|
+
))}
|
|
865
|
+
</div>
|
|
866
|
+
</div>
|
|
867
|
+
))}
|
|
868
|
+
<div className="dshdg-row">
|
|
869
|
+
<button
|
|
870
|
+
type="button"
|
|
871
|
+
onClick={() => {
|
|
872
|
+
editProvider((target) => { target.models.push({ id: '', efforts: [] }); });
|
|
873
|
+
}}
|
|
874
|
+
>
|
|
875
|
+
手动添加模型
|
|
876
|
+
</button>
|
|
877
|
+
</div>
|
|
878
|
+
</div>
|
|
879
|
+
|
|
880
|
+
<div className="dshdg-card">
|
|
881
|
+
<div className="dshdg-row">
|
|
882
|
+
<h4>连通性检查</h4>
|
|
883
|
+
<span className="dshdg-spacer" />
|
|
884
|
+
<select aria-label="检查用模型" value={checkModel} onChange={(event) => { setCheckModel(event.target.value); setCheckEffort(''); }}>
|
|
885
|
+
<option value="">(用执行设置的模型)</option>
|
|
886
|
+
{models.map((entry) => <option key={entry.id} value={entry.id}>{entry.id}</option>)}
|
|
887
|
+
</select>
|
|
888
|
+
<select
|
|
889
|
+
aria-label="检查用推理强度"
|
|
890
|
+
value={checkEffort}
|
|
891
|
+
disabled={selectedModel === null || (selectedModel.efforts ?? []).length === 0}
|
|
892
|
+
onChange={(event) => setCheckEffort(event.target.value)}
|
|
893
|
+
>
|
|
894
|
+
<option value="">(不指定)</option>
|
|
895
|
+
{(selectedModel?.efforts ?? []).map((effort) => (
|
|
896
|
+
<option key={effort} value={effort}>{EFFORT_LABELS[effort] ?? effort}</option>
|
|
897
|
+
))}
|
|
898
|
+
</select>
|
|
899
|
+
<button
|
|
900
|
+
type="button"
|
|
901
|
+
disabled={snapshot.loading?.[`connectivity:${providerId}`] === true}
|
|
902
|
+
onClick={() => {
|
|
903
|
+
void store.checkConnectivity({
|
|
904
|
+
providerId,
|
|
905
|
+
...(checkModel === '' ? {} : { model: checkModel }),
|
|
906
|
+
...(checkEffort === '' ? {} : { reasoningEffort: checkEffort }),
|
|
907
|
+
});
|
|
908
|
+
}}
|
|
909
|
+
>
|
|
910
|
+
{snapshot.loading?.[`connectivity:${providerId}`] === true ? '检查中…' : '开始检查'}
|
|
911
|
+
</button>
|
|
912
|
+
</div>
|
|
913
|
+
<p className="dshdg-hint">四层分别判定:地址可达、认证可用、目录可读、模型真的回了话。任何一层未通过都不会显示成“连通”。</p>
|
|
914
|
+
{report === null ? <p className="dshdg-faint">尚未检查。</p> : (
|
|
915
|
+
<div className="dshdg-layers">
|
|
916
|
+
{CONNECTIVITY_LAYERS.map((layer) => (
|
|
917
|
+
<ConnectivityLayer
|
|
918
|
+
key={layer.key}
|
|
919
|
+
name={layer.key}
|
|
920
|
+
label={layer.label}
|
|
921
|
+
result={report[layer.key] ?? null}
|
|
922
|
+
/>
|
|
923
|
+
))}
|
|
924
|
+
{report.modelResponse?.response?.reasoningOnly === true
|
|
925
|
+
? <p className="dshdg-hint">模型只返回了推理内容(reasoning-only),已按协议视为有效响应。</p>
|
|
926
|
+
: null}
|
|
927
|
+
</div>
|
|
928
|
+
)}
|
|
929
|
+
</div>
|
|
930
|
+
</div>
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/** @param {object} props @returns {object} the API management panel. */
|
|
935
|
+
function ProvidersPanel({ store, snapshot }) {
|
|
936
|
+
const providers = snapshot.draft?.providers ?? [];
|
|
937
|
+
const selectedIds = new Set(providers.map((provider) => provider.id));
|
|
938
|
+
const available = (snapshot.nativeProviders ?? []).filter((provider) => !selectedIds.has(provider.id));
|
|
939
|
+
const [candidateId, setCandidateId] = useState('');
|
|
940
|
+
const nativeProviders = snapshot.nativeProviders ?? [];
|
|
941
|
+
|
|
942
|
+
function isUsed(id) {
|
|
943
|
+
const draft = snapshot.draft ?? {};
|
|
944
|
+
const selections = [draft.worker, draft.review, ...(draft.presets ?? []).flatMap((preset) => [preset.worker, preset.review])];
|
|
945
|
+
for (const block of Object.values(draft.projectOverrides ?? {})) {
|
|
946
|
+
selections.push(block?.worker, block?.review);
|
|
947
|
+
}
|
|
948
|
+
return selections.some((selection) => selection?.providerId === id);
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
return (
|
|
952
|
+
<div className="dshdg-panel">
|
|
953
|
+
<div className="dshdg-row">
|
|
954
|
+
<Field label="DSH 已启用的接口" htmlFor="dshdg-native-provider">
|
|
955
|
+
<select id="dshdg-native-provider" value={candidateId} onChange={(event) => setCandidateId(event.target.value)}>
|
|
956
|
+
<option value="">(选择已有接口)</option>
|
|
957
|
+
{available.map((provider) => <option key={provider.id} value={provider.id}>{`${provider.name} (${provider.id})`}</option>)}
|
|
958
|
+
</select>
|
|
959
|
+
</Field>
|
|
960
|
+
<button
|
|
961
|
+
type="button"
|
|
962
|
+
className="dshdg-primary"
|
|
963
|
+
disabled={candidateId === ''}
|
|
964
|
+
onClick={() => {
|
|
965
|
+
const provider = nativeProviders.find((entry) => entry.id === candidateId);
|
|
966
|
+
if (provider === undefined) return;
|
|
967
|
+
store.editDraft((draft) => {
|
|
968
|
+
if (draft.providers.some((entry) => entry.id === provider.id)) return;
|
|
969
|
+
draft.providers.push({
|
|
970
|
+
id: provider.id,
|
|
971
|
+
name: provider.name,
|
|
972
|
+
source: 'native',
|
|
973
|
+
protocol: null,
|
|
974
|
+
baseUrl: null,
|
|
975
|
+
credentialRef: null,
|
|
976
|
+
models: (provider.models ?? []).map((model) => ({ ...model, efforts: [...(model.efforts ?? [])] })),
|
|
977
|
+
});
|
|
978
|
+
});
|
|
979
|
+
setCandidateId('');
|
|
980
|
+
}}
|
|
981
|
+
>
|
|
982
|
+
添加所选接口
|
|
983
|
+
</button>
|
|
984
|
+
<button type="button" disabled={snapshot.loading?.nativeProviders === true} onClick={() => { void store.loadNativeProviders(); }}>
|
|
985
|
+
{snapshot.loading?.nativeProviders === true ? '刷新中…' : '刷新接口列表'}
|
|
986
|
+
</button>
|
|
987
|
+
</div>
|
|
988
|
+
{snapshot.nativeProvidersError ? <p className="dshdg-fail">{snapshot.nativeProvidersError}</p> : null}
|
|
989
|
+
{nativeProviders.length === 0 ? <p className="dshdg-muted">DSH 当前没有可选的已启用接口。先在 DSH 的模型设置中配置并启用接口。</p> : null}
|
|
990
|
+
{providers.length === 0 ? <p className="dshdg-muted">尚未选择委派可用的接口。</p> : null}
|
|
991
|
+
{providers.map((provider) => {
|
|
992
|
+
const current = nativeProviders.find((entry) => entry.id === provider.id);
|
|
993
|
+
const legacy = provider.source !== 'native';
|
|
994
|
+
const used = isUsed(provider.id);
|
|
995
|
+
return (
|
|
996
|
+
<div className="dshdg-item" key={provider.id}>
|
|
997
|
+
<div className="dshdg-item-head">
|
|
998
|
+
<strong>{provider.name}</strong>
|
|
999
|
+
<span className="dshdg-mono dshdg-faint">{provider.id}</span>
|
|
1000
|
+
<Badge tone={legacy ? 'warn' : 'on'}>{legacy ? '旧版自定义接口' : 'DSH 接口'}</Badge>
|
|
1001
|
+
<span className="dshdg-spacer" />
|
|
1002
|
+
{current !== undefined && !legacy ? (
|
|
1003
|
+
<button
|
|
1004
|
+
type="button"
|
|
1005
|
+
disabled={snapshot.loading?.nativeProviders === true || (current.models ?? []).length === 0}
|
|
1006
|
+
onClick={() => store.editDraft((draft) => {
|
|
1007
|
+
const target = draft.providers.find((entry) => entry.id === provider.id);
|
|
1008
|
+
if (target === undefined) return;
|
|
1009
|
+
target.name = current.name;
|
|
1010
|
+
target.models = current.models.map((model) => ({ ...model, efforts: [...(model.efforts ?? [])] }));
|
|
1011
|
+
})}
|
|
1012
|
+
>
|
|
1013
|
+
同步模型
|
|
1014
|
+
</button>
|
|
1015
|
+
) : null}
|
|
1016
|
+
<button
|
|
1017
|
+
type="button"
|
|
1018
|
+
className="dshdg-danger"
|
|
1019
|
+
disabled={used}
|
|
1020
|
+
title={used ? '先将执行、审查和预设中的该接口改为其他接口' : undefined}
|
|
1021
|
+
onClick={() => store.editDraft((draft) => { draft.providers = draft.providers.filter((entry) => entry.id !== provider.id); })}
|
|
1022
|
+
>
|
|
1023
|
+
移除
|
|
1024
|
+
</button>
|
|
1025
|
+
</div>
|
|
1026
|
+
{legacy ? <p className="dshdg-hint">此接口来自旧版插件配置。新接口请从上方 DSH 列表选择。</p> : null}
|
|
1027
|
+
{current?.error ? <p className="dshdg-fail">{current.error}</p> : null}
|
|
1028
|
+
<div className="dshdg-list">
|
|
1029
|
+
{(current?.models ?? provider.models ?? []).map((model) => (
|
|
1030
|
+
<div className="dshdg-item-head" key={model.id}>
|
|
1031
|
+
<span className="dshdg-mono">{model.id}</span>
|
|
1032
|
+
<span className="dshdg-spacer" />
|
|
1033
|
+
<span className="dshdg-hint">{(model.efforts ?? []).map((effort) => EFFORT_LABELS[effort] ?? effort).join('、') || '未声明思考强度'}</span>
|
|
1034
|
+
</div>
|
|
1035
|
+
))}
|
|
1036
|
+
</div>
|
|
1037
|
+
</div>
|
|
1038
|
+
);
|
|
1039
|
+
})}
|
|
1040
|
+
</div>
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
function LegacyProvidersPanel({ store, snapshot }) {
|
|
1045
|
+
const providers = snapshot.draft?.providers ?? [];
|
|
1046
|
+
const duplicates = duplicateProviderIds(snapshot.draft);
|
|
1047
|
+
const [nextId, setNextId] = useState('');
|
|
1048
|
+
|
|
1049
|
+
return (
|
|
1050
|
+
<div className="dshdg-panel">
|
|
1051
|
+
{duplicates.length > 0 ? (
|
|
1052
|
+
<p className="dshdg-fail">{`提供方标识重复:${duplicates.join('、')}`}</p>
|
|
1053
|
+
) : null}
|
|
1054
|
+
{providers.length === 0 ? (
|
|
1055
|
+
<p className="dshdg-muted">还没有接口配置。至少添加一个 OpenAI 兼容提供方,才能选择模型。</p>
|
|
1056
|
+
) : providers.map((provider, index) => (
|
|
1057
|
+
<ProviderEditor
|
|
1058
|
+
key={`${provider.id}-${String(index)}`}
|
|
1059
|
+
provider={provider}
|
|
1060
|
+
store={store}
|
|
1061
|
+
snapshot={snapshot}
|
|
1062
|
+
index={index}
|
|
1063
|
+
/>
|
|
1064
|
+
))}
|
|
1065
|
+
<div className="dshdg-row">
|
|
1066
|
+
<input
|
|
1067
|
+
type="text"
|
|
1068
|
+
aria-label="新提供方标识"
|
|
1069
|
+
placeholder="新提供方标识,例如 deepseek-relay"
|
|
1070
|
+
value={nextId}
|
|
1071
|
+
onChange={(event) => setNextId(event.target.value)}
|
|
1072
|
+
/>
|
|
1073
|
+
<button
|
|
1074
|
+
type="button"
|
|
1075
|
+
className="dshdg-primary"
|
|
1076
|
+
disabled={providers.length >= LIMITS.providers}
|
|
1077
|
+
onClick={() => {
|
|
1078
|
+
const id = nextId.trim().toLowerCase();
|
|
1079
|
+
if (id === '') return;
|
|
1080
|
+
store.editDraft((draft) => {
|
|
1081
|
+
draft.providers.push({
|
|
1082
|
+
id,
|
|
1083
|
+
name: id,
|
|
1084
|
+
protocol: SUPPORTED_PROTOCOLS[0],
|
|
1085
|
+
baseUrl: '',
|
|
1086
|
+
credentialRef: null,
|
|
1087
|
+
models: [],
|
|
1088
|
+
});
|
|
1089
|
+
});
|
|
1090
|
+
setNextId('');
|
|
1091
|
+
}}
|
|
1092
|
+
>
|
|
1093
|
+
添加提供方
|
|
1094
|
+
</button>
|
|
1095
|
+
<span className="dshdg-hint">{`最多 ${LIMITS.providers} 个`}</span>
|
|
1096
|
+
</div>
|
|
1097
|
+
</div>
|
|
1098
|
+
);
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// ---------------------------------------------------------------------------
|
|
1102
|
+
// Execution settings
|
|
1103
|
+
// ---------------------------------------------------------------------------
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* Read-only view of the configuration a job would actually use.
|
|
1107
|
+
* @param {object} props - `label`, `effective`, `note`.
|
|
1108
|
+
* @returns {object} a description list.
|
|
1109
|
+
*/
|
|
1110
|
+
function EffectiveSummary({ label, effective, note }) {
|
|
1111
|
+
const worker = effective?.worker ?? {};
|
|
1112
|
+
const review = effective?.review ?? {};
|
|
1113
|
+
return (
|
|
1114
|
+
<div className="dshdg-card">
|
|
1115
|
+
<h4>{label}</h4>
|
|
1116
|
+
<dl className="dshdg-kv">
|
|
1117
|
+
<dt>执行提供方</dt>
|
|
1118
|
+
<dd className="dshdg-mono">{worker.providerId ?? worker.providerRoute ?? '(未配置)'}</dd>
|
|
1119
|
+
<dt>执行模型</dt>
|
|
1120
|
+
<dd className="dshdg-mono">{worker.model ?? '(未配置)'}</dd>
|
|
1121
|
+
<dt>执行推理强度</dt>
|
|
1122
|
+
<dd className="dshdg-mono">{worker.reasoningEffort ?? '(不指定)'}</dd>
|
|
1123
|
+
<dt>超时</dt>
|
|
1124
|
+
<dd>{worker.timeoutSeconds === undefined ? '—' : `${worker.timeoutSeconds} 秒`}</dd>
|
|
1125
|
+
<dt>最大并发</dt>
|
|
1126
|
+
<dd>{worker.maxParallelism ?? '—'}</dd>
|
|
1127
|
+
<dt>工作区隔离</dt>
|
|
1128
|
+
<dd>{ISOLATION_LABELS[worker.isolation] ?? worker.isolation ?? '—'}</dd>
|
|
1129
|
+
<dt>对话</dt>
|
|
1130
|
+
<dd>{CONVERSATION_POLICY_LABEL}</dd>
|
|
1131
|
+
<dt>附加审查</dt>
|
|
1132
|
+
<dd>
|
|
1133
|
+
{review.enabled === true
|
|
1134
|
+
? `开启 · ${review.providerId ?? '(未配置)'} / ${review.model ?? '(未配置)'} / ${review.reasoningEffort ?? '不指定'}`
|
|
1135
|
+
: '关闭'}
|
|
1136
|
+
</dd>
|
|
1137
|
+
<dt>静默监控</dt>
|
|
1138
|
+
<dd>
|
|
1139
|
+
{effective?.monitoring === null || effective?.monitoring === undefined
|
|
1140
|
+
? '未采集到'
|
|
1141
|
+
: `自检 ${formatDuration(effective.monitoring.selfCheckSeconds * 1000)} · 提醒 ${formatDuration(effective.monitoring.attentionSeconds * 1000)}`}
|
|
1142
|
+
</dd>
|
|
1143
|
+
</dl>
|
|
1144
|
+
{note === undefined ? null : <p className="dshdg-hint">{note}</p>}
|
|
1145
|
+
</div>
|
|
1146
|
+
);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Presets, non-secret export and project overrides.
|
|
1151
|
+
* @param {object} props - `store`, `snapshot`.
|
|
1152
|
+
* @returns {object} the sharing card.
|
|
1153
|
+
*/
|
|
1154
|
+
function PresetsCard({ store, snapshot }) {
|
|
1155
|
+
const draft = snapshot.draft;
|
|
1156
|
+
const presets = draft?.presets ?? [];
|
|
1157
|
+
const overrides = draft?.projectOverrides ?? {};
|
|
1158
|
+
const [presetName, setPresetName] = useState('');
|
|
1159
|
+
const [presetId, setPresetId] = useState('');
|
|
1160
|
+
const [importText, setImportText] = useState('');
|
|
1161
|
+
const [importError, setImportError] = useState('');
|
|
1162
|
+
const [exportCopied, setExportCopied] = useState('');
|
|
1163
|
+
const [overridePath, setOverridePath] = useState('');
|
|
1164
|
+
const [overrideJson, setOverrideJson] = useState('');
|
|
1165
|
+
const [overrideError, setOverrideError] = useState('');
|
|
1166
|
+
const [editingPath, setEditingPath] = useState('');
|
|
1167
|
+
|
|
1168
|
+
const exportText = useMemo(() => (draft === null ? '' : exportDocument(draft)), [draft]);
|
|
1169
|
+
|
|
1170
|
+
return (
|
|
1171
|
+
<div className="dshdg-card">
|
|
1172
|
+
<h4>预设、导出与项目覆盖</h4>
|
|
1173
|
+
<p className="dshdg-hint">
|
|
1174
|
+
预设只包含执行/审查组合;导出内容全部是非敏感配置,任何密钥都不会出现(密钥只存在宿主的凭据存储里)。
|
|
1175
|
+
正在运行的任务保留它自己的生效快照,之后的修改不会改写历史。
|
|
1176
|
+
</p>
|
|
1177
|
+
|
|
1178
|
+
<div className="dshdg-row">
|
|
1179
|
+
<input
|
|
1180
|
+
type="text"
|
|
1181
|
+
aria-label="预设名称"
|
|
1182
|
+
placeholder="预设标识,例如 fast-local"
|
|
1183
|
+
value={presetId}
|
|
1184
|
+
onChange={(event) => setPresetId(event.target.value.trim().toLowerCase())}
|
|
1185
|
+
/>
|
|
1186
|
+
<input
|
|
1187
|
+
type="text"
|
|
1188
|
+
aria-label="预设显示名"
|
|
1189
|
+
placeholder="显示名"
|
|
1190
|
+
value={presetName}
|
|
1191
|
+
onChange={(event) => setPresetName(event.target.value)}
|
|
1192
|
+
/>
|
|
1193
|
+
<button
|
|
1194
|
+
type="button"
|
|
1195
|
+
disabled={presetId === ''}
|
|
1196
|
+
onClick={() => {
|
|
1197
|
+
store.editDraft((current) => {
|
|
1198
|
+
const existing = current.presets.find((entry) => entry.id === presetId);
|
|
1199
|
+
const snapshotWorker = clone(current.worker);
|
|
1200
|
+
const snapshotReview = current.review?.enabled === true ? clone(current.review) : null;
|
|
1201
|
+
if (existing === undefined) {
|
|
1202
|
+
current.presets.push({
|
|
1203
|
+
id: presetId,
|
|
1204
|
+
name: presetName === '' ? presetId : presetName,
|
|
1205
|
+
worker: snapshotWorker,
|
|
1206
|
+
...(snapshotReview === null ? {} : { review: snapshotReview }),
|
|
1207
|
+
});
|
|
1208
|
+
} else {
|
|
1209
|
+
existing.name = presetName === '' ? existing.name : presetName;
|
|
1210
|
+
existing.worker = snapshotWorker;
|
|
1211
|
+
existing.review = snapshotReview;
|
|
1212
|
+
}
|
|
1213
|
+
});
|
|
1214
|
+
setPresetId('');
|
|
1215
|
+
setPresetName('');
|
|
1216
|
+
}}
|
|
1217
|
+
>
|
|
1218
|
+
用当前设置保存预设
|
|
1219
|
+
</button>
|
|
1220
|
+
</div>
|
|
1221
|
+
|
|
1222
|
+
{presets.length === 0 ? <p className="dshdg-faint">还没有预设。</p> : (
|
|
1223
|
+
<div className="dshdg-list">
|
|
1224
|
+
{presets.map((preset) => (
|
|
1225
|
+
<div className="dshdg-item" key={preset.id}>
|
|
1226
|
+
<div className="dshdg-item-head">
|
|
1227
|
+
<strong>{preset.name}</strong>
|
|
1228
|
+
<span className="dshdg-mono dshdg-faint">{preset.id}</span>
|
|
1229
|
+
<span className="dshdg-spacer" />
|
|
1230
|
+
<button
|
|
1231
|
+
type="button"
|
|
1232
|
+
onClick={() => {
|
|
1233
|
+
store.editDraft((current) => {
|
|
1234
|
+
if (preset.worker !== null && preset.worker !== undefined) current.worker = { ...preset.worker };
|
|
1235
|
+
if (preset.review !== null && preset.review !== undefined) current.review = { ...preset.review };
|
|
1236
|
+
});
|
|
1237
|
+
}}
|
|
1238
|
+
>
|
|
1239
|
+
应用到草稿
|
|
1240
|
+
</button>
|
|
1241
|
+
<button
|
|
1242
|
+
type="button"
|
|
1243
|
+
className="dshdg-danger"
|
|
1244
|
+
onClick={() => {
|
|
1245
|
+
store.editDraft((current) => {
|
|
1246
|
+
current.presets = current.presets.filter((entry) => entry.id !== preset.id);
|
|
1247
|
+
});
|
|
1248
|
+
}}
|
|
1249
|
+
>
|
|
1250
|
+
删除
|
|
1251
|
+
</button>
|
|
1252
|
+
</div>
|
|
1253
|
+
</div>
|
|
1254
|
+
))}
|
|
1255
|
+
</div>
|
|
1256
|
+
)}
|
|
1257
|
+
|
|
1258
|
+
<Field label="导出(非敏感)" htmlFor="dshdg-export" hint="复制这段文本即可备份或在另一台机器恢复。">
|
|
1259
|
+
<textarea id="dshdg-export" readOnly rows={6} value={exportText} />
|
|
1260
|
+
</Field>
|
|
1261
|
+
<div className="dshdg-row">
|
|
1262
|
+
<button
|
|
1263
|
+
type="button"
|
|
1264
|
+
onClick={async () => {
|
|
1265
|
+
try {
|
|
1266
|
+
await globalThis.navigator?.clipboard?.writeText(exportText);
|
|
1267
|
+
setExportCopied('已复制');
|
|
1268
|
+
} catch {
|
|
1269
|
+
setExportCopied('无法访问剪贴板,请手动复制');
|
|
1270
|
+
}
|
|
1271
|
+
}}
|
|
1272
|
+
>
|
|
1273
|
+
复制导出内容
|
|
1274
|
+
</button>
|
|
1275
|
+
{exportCopied === '' ? null : <span className="dshdg-hint">{exportCopied}</span>}
|
|
1276
|
+
<span className="dshdg-spacer" />
|
|
1277
|
+
<button
|
|
1278
|
+
type="button"
|
|
1279
|
+
onClick={async () => {
|
|
1280
|
+
try {
|
|
1281
|
+
const text = await globalThis.navigator?.clipboard?.readText?.();
|
|
1282
|
+
if (typeof text === 'string') setImportText(text);
|
|
1283
|
+
} catch {
|
|
1284
|
+
setExportCopied('无法访问剪贴板,请手动粘贴');
|
|
1285
|
+
}
|
|
1286
|
+
}}
|
|
1287
|
+
>
|
|
1288
|
+
从剪贴板粘贴
|
|
1289
|
+
</button>
|
|
1290
|
+
</div>
|
|
1291
|
+
|
|
1292
|
+
<Field
|
|
1293
|
+
label="导入(覆盖草稿,保存后才生效)"
|
|
1294
|
+
htmlFor="dshdg-import"
|
|
1295
|
+
hint="只接受本插件导出的非敏感文档;包含密钥的字段会被宿主拒绝。"
|
|
1296
|
+
>
|
|
1297
|
+
<textarea
|
|
1298
|
+
id="dshdg-import"
|
|
1299
|
+
rows={6}
|
|
1300
|
+
value={importText}
|
|
1301
|
+
onChange={(event) => { setImportText(event.target.value); setImportError(''); }}
|
|
1302
|
+
/>
|
|
1303
|
+
</Field>
|
|
1304
|
+
<div className="dshdg-row">
|
|
1305
|
+
<button
|
|
1306
|
+
type="button"
|
|
1307
|
+
onClick={() => {
|
|
1308
|
+
try {
|
|
1309
|
+
const parsed = JSON.parse(importText);
|
|
1310
|
+
const next = draftFromSettings(parsed);
|
|
1311
|
+
store.editDraft((current) => {
|
|
1312
|
+
current.providers = next.providers;
|
|
1313
|
+
current.worker = next.worker;
|
|
1314
|
+
current.review = next.review;
|
|
1315
|
+
current.authorization = next.authorization;
|
|
1316
|
+
current.projectOverrides = next.projectOverrides;
|
|
1317
|
+
current.presets = next.presets;
|
|
1318
|
+
});
|
|
1319
|
+
setImportError('');
|
|
1320
|
+
} catch (error) {
|
|
1321
|
+
setImportError(`无法解析:${String(error?.message ?? error).slice(0, 160)}`);
|
|
1322
|
+
}
|
|
1323
|
+
}}
|
|
1324
|
+
disabled={importText.trim() === ''}
|
|
1325
|
+
>
|
|
1326
|
+
解析并应用到草稿
|
|
1327
|
+
</button>
|
|
1328
|
+
{importError === '' ? null : <span className="dshdg-fail">{importError}</span>}
|
|
1329
|
+
</div>
|
|
1330
|
+
|
|
1331
|
+
<h4>项目覆盖</h4>
|
|
1332
|
+
<p className="dshdg-hint">为某个绝对路径单独指定执行/审查覆盖;任务生效值会显示实际用了哪一层。</p>
|
|
1333
|
+
{Object.keys(overrides).length === 0 ? <p className="dshdg-faint">还没有项目覆盖。</p> : (
|
|
1334
|
+
<div className="dshdg-list">
|
|
1335
|
+
{Object.entries(overrides).map(([path, block]) => (
|
|
1336
|
+
<div className="dshdg-item" key={path}>
|
|
1337
|
+
<div className="dshdg-item-head">
|
|
1338
|
+
<span className="dshdg-mono">{path}</span>
|
|
1339
|
+
<span className="dshdg-spacer" />
|
|
1340
|
+
<button
|
|
1341
|
+
type="button"
|
|
1342
|
+
onClick={() => {
|
|
1343
|
+
setEditingPath(path);
|
|
1344
|
+
setOverridePath(path);
|
|
1345
|
+
setOverrideJson(`${JSON.stringify(block, null, 2)}\n`);
|
|
1346
|
+
setOverrideError('');
|
|
1347
|
+
}}
|
|
1348
|
+
>
|
|
1349
|
+
编辑
|
|
1350
|
+
</button>
|
|
1351
|
+
<button
|
|
1352
|
+
type="button"
|
|
1353
|
+
className="dshdg-danger"
|
|
1354
|
+
onClick={() => {
|
|
1355
|
+
store.editDraft((current) => {
|
|
1356
|
+
const copy = { ...current.projectOverrides };
|
|
1357
|
+
delete copy[path];
|
|
1358
|
+
current.projectOverrides = copy;
|
|
1359
|
+
});
|
|
1360
|
+
if (editingPath === path) setEditingPath('');
|
|
1361
|
+
}}
|
|
1362
|
+
>
|
|
1363
|
+
删除
|
|
1364
|
+
</button>
|
|
1365
|
+
</div>
|
|
1366
|
+
<pre className="dshdg-pre">{boundedText(block, 4000)}</pre>
|
|
1367
|
+
</div>
|
|
1368
|
+
))}
|
|
1369
|
+
</div>
|
|
1370
|
+
)}
|
|
1371
|
+
<Field
|
|
1372
|
+
label={editingPath === '' ? '新增覆盖:绝对路径' : `编辑覆盖:${editingPath}`}
|
|
1373
|
+
htmlFor="dshdg-override-path"
|
|
1374
|
+
>
|
|
1375
|
+
<input
|
|
1376
|
+
id="dshdg-override-path"
|
|
1377
|
+
type="text"
|
|
1378
|
+
value={overridePath}
|
|
1379
|
+
readOnly={editingPath !== ''}
|
|
1380
|
+
placeholder="C:\\work\\project"
|
|
1381
|
+
onChange={(event) => setOverridePath(event.target.value)}
|
|
1382
|
+
/>
|
|
1383
|
+
</Field>
|
|
1384
|
+
<Field
|
|
1385
|
+
label={`覆盖内容(JSON,仅允许 worker / review)`}
|
|
1386
|
+
htmlFor="dshdg-override-json"
|
|
1387
|
+
hint={'例如 {"worker":{"model":"deepseek-chat","reasoningEffort":"high"},"review":{"enabled":false}}'}
|
|
1388
|
+
>
|
|
1389
|
+
<textarea
|
|
1390
|
+
id="dshdg-override-json"
|
|
1391
|
+
rows={5}
|
|
1392
|
+
value={overrideJson}
|
|
1393
|
+
onChange={(event) => { setOverrideJson(event.target.value); setOverrideError(''); }}
|
|
1394
|
+
/>
|
|
1395
|
+
</Field>
|
|
1396
|
+
<div className="dshdg-row">
|
|
1397
|
+
<button
|
|
1398
|
+
type="button"
|
|
1399
|
+
disabled={overridePath.trim() === ''}
|
|
1400
|
+
onClick={() => {
|
|
1401
|
+
let parsed;
|
|
1402
|
+
try {
|
|
1403
|
+
parsed = overrideJson.trim() === '' ? {} : JSON.parse(overrideJson);
|
|
1404
|
+
} catch (error) {
|
|
1405
|
+
setOverrideError(`无法解析:${String(error?.message ?? error).slice(0, 160)}`);
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
const unknown = Object.keys(parsed).filter((key) => key !== 'worker' && key !== 'review');
|
|
1409
|
+
if (unknown.length > 0) {
|
|
1410
|
+
setOverrideError(`不支持的字段:${unknown.join('、')}`);
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
setOverrideError('');
|
|
1414
|
+
const path = overridePath.trim().replace(/[\\/]+$/, '');
|
|
1415
|
+
store.editDraft((current) => {
|
|
1416
|
+
const copy = { ...current.projectOverrides };
|
|
1417
|
+
if (editingPath !== '' && editingPath !== path) delete copy[editingPath];
|
|
1418
|
+
copy[path] = parsed;
|
|
1419
|
+
current.projectOverrides = copy;
|
|
1420
|
+
});
|
|
1421
|
+
setEditingPath('');
|
|
1422
|
+
setOverrideJson('');
|
|
1423
|
+
setOverridePath('');
|
|
1424
|
+
}}
|
|
1425
|
+
>
|
|
1426
|
+
{editingPath === '' ? '添加覆盖' : '保存覆盖'}
|
|
1427
|
+
</button>
|
|
1428
|
+
{editingPath === '' ? null : (
|
|
1429
|
+
<button type="button" onClick={() => { setEditingPath(''); setOverrideJson(''); setOverridePath(''); setOverrideError(''); }}>
|
|
1430
|
+
取消编辑
|
|
1431
|
+
</button>
|
|
1432
|
+
)}
|
|
1433
|
+
{overrideError === '' ? null : <span className="dshdg-fail">{overrideError}</span>}
|
|
1434
|
+
</div>
|
|
1435
|
+
</div>
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Advanced monitoring controls for a running task's silence.
|
|
1441
|
+
*
|
|
1442
|
+
* What this card deliberately does NOT do: it does not submit work, does not read a
|
|
1443
|
+
* task, does not call a model, and does not create a monitoring process of its own.
|
|
1444
|
+
* It edits two numbers and, on the operator's click, sends them to the one narrow
|
|
1445
|
+
* authenticated route. Everything it says about the behaviour is a statement about
|
|
1446
|
+
* the engine, not a control here.
|
|
1447
|
+
*
|
|
1448
|
+
* Units: the operator thinks in minutes, the document stores whole seconds. Each
|
|
1449
|
+
* field converts on the way in and out (`minutesToSeconds` / `secondsToMinutes`), so a
|
|
1450
|
+
* stored value of 300 s shows as 5 and a value of 90 s shows as 1.5 rather than being
|
|
1451
|
+
* rounded into a different setting.
|
|
1452
|
+
* @param {object} props - `store`, `snapshot`.
|
|
1453
|
+
* @returns {object} the monitoring card.
|
|
1454
|
+
*/
|
|
1455
|
+
function MonitoringCard({ store, snapshot }) {
|
|
1456
|
+
const draft = snapshot.draft;
|
|
1457
|
+
const monitoring = monitoringOf(draft);
|
|
1458
|
+
const saved = monitoringOf(snapshot.settings);
|
|
1459
|
+
const [saving, setSaving] = useState(false);
|
|
1460
|
+
const problems = precheckMonitoring(monitoring);
|
|
1461
|
+
const dirty = monitoring.selfCheckSeconds !== saved.selfCheckSeconds
|
|
1462
|
+
|| monitoring.attentionSeconds !== saved.attentionSeconds;
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Write one field, converting minutes back to the stored unit.
|
|
1466
|
+
* @param {'selfCheckSeconds' | 'attentionSeconds'} field - target field.
|
|
1467
|
+
* @param {unknown} raw - operator input, in minutes.
|
|
1468
|
+
* @returns {void}
|
|
1469
|
+
*/
|
|
1470
|
+
const edit = (field, raw) => {
|
|
1471
|
+
store.editDraft((current) => {
|
|
1472
|
+
current.monitoring = { ...monitoringOf(current), [field]: minutesToSeconds(raw) };
|
|
1473
|
+
});
|
|
1474
|
+
};
|
|
1475
|
+
|
|
1476
|
+
return (
|
|
1477
|
+
<div className="dshdg-card" data-dshdg-monitoring="">
|
|
1478
|
+
<h4>进阶:静默监控间隔</h4>
|
|
1479
|
+
<p className="dshdg-hint">
|
|
1480
|
+
任务长时间没有新输出时,插件自己会看一眼执行器还在不在(程序自检),再过一段时间才提醒你。
|
|
1481
|
+
<strong>这些检查完全在本机进行,不会调用任何大模型,也不消耗 token。</strong>
|
|
1482
|
+
</p>
|
|
1483
|
+
<div className="dshdg-grid">
|
|
1484
|
+
<Field
|
|
1485
|
+
label="程序自检间隔(分钟)"
|
|
1486
|
+
htmlFor="dshdg-monitoring-selfcheck"
|
|
1487
|
+
hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${monitoring.selfCheckSeconds} 秒)`}
|
|
1488
|
+
>
|
|
1489
|
+
<input
|
|
1490
|
+
id="dshdg-monitoring-selfcheck"
|
|
1491
|
+
type="number"
|
|
1492
|
+
inputMode="decimal"
|
|
1493
|
+
min={LIMITS.selfCheckSecondsMin / 60}
|
|
1494
|
+
max={LIMITS.selfCheckSecondsMax / 60}
|
|
1495
|
+
step={0.5}
|
|
1496
|
+
value={String(Number.isFinite(secondsToMinutes(monitoring.selfCheckSeconds)) ? secondsToMinutes(monitoring.selfCheckSeconds) : '')}
|
|
1497
|
+
onChange={(event) => {
|
|
1498
|
+
const raw = event.target.value;
|
|
1499
|
+
edit('selfCheckSeconds', raw === '' ? '' : raw);
|
|
1500
|
+
}}
|
|
1501
|
+
/>
|
|
1502
|
+
</Field>
|
|
1503
|
+
<Field
|
|
1504
|
+
label="提醒你的间隔(分钟)"
|
|
1505
|
+
htmlFor="dshdg-monitoring-attention"
|
|
1506
|
+
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${monitoring.attentionSeconds} 秒)`}
|
|
1507
|
+
>
|
|
1508
|
+
<input
|
|
1509
|
+
id="dshdg-monitoring-attention"
|
|
1510
|
+
type="number"
|
|
1511
|
+
inputMode="decimal"
|
|
1512
|
+
min={LIMITS.attentionSecondsMin / 60}
|
|
1513
|
+
max={LIMITS.attentionSecondsMax / 60}
|
|
1514
|
+
step={0.5}
|
|
1515
|
+
value={String(Number.isFinite(secondsToMinutes(monitoring.attentionSeconds)) ? secondsToMinutes(monitoring.attentionSeconds) : '')}
|
|
1516
|
+
onChange={(event) => {
|
|
1517
|
+
const raw = event.target.value;
|
|
1518
|
+
edit('attentionSeconds', raw === '' ? '' : raw);
|
|
1519
|
+
}}
|
|
1520
|
+
/>
|
|
1521
|
+
</Field>
|
|
1522
|
+
</div>
|
|
1523
|
+
{problems.length === 0 ? null : <p className="dshdg-fail">{problems.join(';')}</p>}
|
|
1524
|
+
<ul className="dshdg-hint">
|
|
1525
|
+
<li>「没有新进展」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
|
|
1526
|
+
<li>只有确实没有进展、并且超过「提醒你的间隔」之后,才会把这件事报告给派工方。</li>
|
|
1527
|
+
<li>修改只影响<strong>之后新提交</strong>的任务;已经运行的任务保留它开始时的那份间隔快照。</li>
|
|
1528
|
+
<li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具),不读取代码差异,也不会读取你的文件内容。</li>
|
|
1529
|
+
</ul>
|
|
1530
|
+
<div className="dshdg-row">
|
|
1531
|
+
<button
|
|
1532
|
+
type="button"
|
|
1533
|
+
disabled={!dirty || saving || snapshot.loading?.monitoring === true || problems.length > 0}
|
|
1534
|
+
onClick={async () => {
|
|
1535
|
+
setSaving(true);
|
|
1536
|
+
try {
|
|
1537
|
+
await store.saveMonitoring(monitoring);
|
|
1538
|
+
} finally {
|
|
1539
|
+
setSaving(false);
|
|
1540
|
+
}
|
|
1541
|
+
}}
|
|
1542
|
+
>
|
|
1543
|
+
{snapshot.loading?.monitoring === true || saving ? '保存中…' : '只保存监控间隔'}
|
|
1544
|
+
</button>
|
|
1545
|
+
<span className="dshdg-hint">
|
|
1546
|
+
{dirty ? '与已保存的值不同。' : `已保存:自检 ${saved.selfCheckSeconds} 秒,提醒 ${saved.attentionSeconds} 秒。`}
|
|
1547
|
+
</span>
|
|
1548
|
+
</div>
|
|
1549
|
+
<p className="dshdg-hint">
|
|
1550
|
+
也可以点页面底部的「保存设置」一起保存;保存的是同一个设置文档。
|
|
1551
|
+
</p>
|
|
1552
|
+
</div>
|
|
1553
|
+
);
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
/** @param {object} props @returns {object} the execution settings panel. */
|
|
1557
|
+
function ExecutionPanel({ store, snapshot }) {
|
|
1558
|
+
const draft = snapshot.draft;
|
|
1559
|
+
const providers = draft?.providers ?? [];
|
|
1560
|
+
const worker = draft?.worker ?? {};
|
|
1561
|
+
// There is no conversation-mode control any more: the policy is per submission
|
|
1562
|
+
// (new by default, continue only the task named by `continueFromTaskId`), so the
|
|
1563
|
+
// panel states it instead of offering a setting that no longer exists.
|
|
1564
|
+
// Global preview only: which project a task will run in is decided at submit
|
|
1565
|
+
// time, so previewing against an arbitrary override key would be a guess.
|
|
1566
|
+
const preview = draft === null ? null : previewEffective(draft, null);
|
|
1567
|
+
const served = snapshot.catalog?.effective ?? null;
|
|
1568
|
+
if (draft === null) return <p className="dshdg-faint">正在读取设置…</p>;
|
|
1569
|
+
return (
|
|
1570
|
+
<div className="dshdg-panel">
|
|
1571
|
+
<SelectionFields
|
|
1572
|
+
providers={providers}
|
|
1573
|
+
idPrefix="dshdg-worker"
|
|
1574
|
+
value={{ providerId: worker.providerId ?? null, model: worker.model ?? null, reasoningEffort: worker.reasoningEffort ?? null }}
|
|
1575
|
+
onChange={(next) => {
|
|
1576
|
+
store.editDraft((current) => {
|
|
1577
|
+
current.worker.providerId = next.providerId;
|
|
1578
|
+
current.worker.model = next.model;
|
|
1579
|
+
current.worker.reasoningEffort = next.reasoningEffort;
|
|
1580
|
+
});
|
|
1581
|
+
}}
|
|
1582
|
+
/>
|
|
1583
|
+
<div className="dshdg-grid">
|
|
1584
|
+
<IntegerField
|
|
1585
|
+
id="dshdg-worker-timeout"
|
|
1586
|
+
label="超时(秒)"
|
|
1587
|
+
value={worker.timeoutSeconds}
|
|
1588
|
+
min={LIMITS.timeoutSecondsMin}
|
|
1589
|
+
max={LIMITS.timeoutSecondsMax}
|
|
1590
|
+
hint={`${LIMITS.timeoutSecondsMin}–${LIMITS.timeoutSecondsMax}`}
|
|
1591
|
+
onChange={(value) => {
|
|
1592
|
+
store.editDraft((current) => { current.worker.timeoutSeconds = value; });
|
|
1593
|
+
}}
|
|
1594
|
+
/>
|
|
1595
|
+
<IntegerField
|
|
1596
|
+
id="dshdg-worker-parallelism"
|
|
1597
|
+
label="最大并发"
|
|
1598
|
+
value={worker.maxParallelism}
|
|
1599
|
+
min={LIMITS.maxParallelismMin}
|
|
1600
|
+
max={LIMITS.maxParallelismMax}
|
|
1601
|
+
hint={`${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax},超出会被拒绝而不是自动调整`}
|
|
1602
|
+
onChange={(value) => {
|
|
1603
|
+
store.editDraft((current) => { current.worker.maxParallelism = value; });
|
|
1604
|
+
}}
|
|
1605
|
+
/>
|
|
1606
|
+
<Field label="工作区隔离" htmlFor="dshdg-worker-isolation" hint="默认独立工作树;共享工作区需要你明确选择。">
|
|
1607
|
+
<select
|
|
1608
|
+
id="dshdg-worker-isolation"
|
|
1609
|
+
value={worker.isolation ?? ISOLATION_MODES[0]}
|
|
1610
|
+
onChange={(event) => {
|
|
1611
|
+
store.editDraft((current) => { current.worker.isolation = event.target.value; });
|
|
1612
|
+
}}
|
|
1613
|
+
>
|
|
1614
|
+
{ISOLATION_MODES.map((mode) => (
|
|
1615
|
+
<option key={mode} value={mode}>{ISOLATION_LABELS[mode]}</option>
|
|
1616
|
+
))}
|
|
1617
|
+
</select>
|
|
1618
|
+
</Field>
|
|
1619
|
+
<Field
|
|
1620
|
+
label="对话"
|
|
1621
|
+
htmlFor="dshdg-conversation-policy"
|
|
1622
|
+
hint="固定的按任务策略:每个新提交在执行目录对应的 Workspace 里新开一条会话;只有显式带 continueFromTaskId 的跟进任务才续接那一条会话。"
|
|
1623
|
+
>
|
|
1624
|
+
<p id="dshdg-conversation-policy" className="dshdg-hint">
|
|
1625
|
+
{CONVERSATION_POLICY_LABEL}
|
|
1626
|
+
</p>
|
|
1627
|
+
</Field>
|
|
1628
|
+
</div>
|
|
1629
|
+
<p className="dshdg-hint">
|
|
1630
|
+
不会自动回退到别的模型,也不会隐式使用 Harness 默认模型:选中的组合不可路由时任务直接拒绝。
|
|
1631
|
+
</p>
|
|
1632
|
+
<p className="dshdg-hint">
|
|
1633
|
+
目录级的「复用上一对话」设置已移除:它曾经让同目录的第二个任务自动接续上一次会话,现在不会发生。
|
|
1634
|
+
需要续接时由派工方在 <code>delegate_submit</code> 里带上 <code>continueFromTaskId</code>,
|
|
1635
|
+
指向要继续的那条任务历史;隔离工作树的跟进任务必须回到同一棵工作树,否则会被拒绝。
|
|
1636
|
+
</p>
|
|
1637
|
+
{preview === null ? null : (
|
|
1638
|
+
<EffectiveSummary
|
|
1639
|
+
label="保存后生效(当前草稿预览)"
|
|
1640
|
+
effective={preview}
|
|
1641
|
+
note={preview.applied.length === 0
|
|
1642
|
+
? '未命中项目覆盖。'
|
|
1643
|
+
: `已应用:${preview.applied.join(';')}`}
|
|
1644
|
+
/>
|
|
1645
|
+
)}
|
|
1646
|
+
<MonitoringCard store={store} snapshot={snapshot} />
|
|
1647
|
+
{served === null ? (
|
|
1648
|
+
<p className="dshdg-faint">宿主尚未回报实际生效值(模型目录不可用或尚未加载)。</p>
|
|
1649
|
+
) : (
|
|
1650
|
+
<EffectiveSummary
|
|
1651
|
+
label="宿主当前实际生效"
|
|
1652
|
+
effective={served}
|
|
1653
|
+
note="这是任务真正会用的配置快照;模型目录无法解析时会在这里显示拒绝原因。"
|
|
1654
|
+
/>
|
|
1655
|
+
)}
|
|
1656
|
+
<PresetsCard store={store} snapshot={snapshot} />
|
|
1657
|
+
</div>
|
|
1658
|
+
);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// ---------------------------------------------------------------------------
|
|
1662
|
+
// Additional review
|
|
1663
|
+
// ---------------------------------------------------------------------------
|
|
1664
|
+
|
|
1665
|
+
/** @param {object} props @returns {object} the review panel. */
|
|
1666
|
+
function ReviewPanel({ store, snapshot }) {
|
|
1667
|
+
const draft = snapshot.draft;
|
|
1668
|
+
const providers = draft?.providers ?? [];
|
|
1669
|
+
const review = draft?.review ?? { enabled: false };
|
|
1670
|
+
const enabled = review.enabled === true;
|
|
1671
|
+
const worker = draft?.worker ?? {};
|
|
1672
|
+
const sameRoute = enabled
|
|
1673
|
+
&& review.providerId === (worker.providerId ?? null)
|
|
1674
|
+
&& review.model === (worker.model ?? null);
|
|
1675
|
+
if (draft === null) return <p className="dshdg-faint">正在读取设置…</p>;
|
|
1676
|
+
return (
|
|
1677
|
+
<div className="dshdg-panel">
|
|
1678
|
+
<div className="dshdg-card">
|
|
1679
|
+
<div className="dshdg-row">
|
|
1680
|
+
<label htmlFor="dshdg-review-enabled">
|
|
1681
|
+
<input
|
|
1682
|
+
id="dshdg-review-enabled"
|
|
1683
|
+
type="checkbox"
|
|
1684
|
+
checked={enabled}
|
|
1685
|
+
onChange={(event) => {
|
|
1686
|
+
store.editDraft((current) => { current.review.enabled = event.target.checked; });
|
|
1687
|
+
}}
|
|
1688
|
+
/>
|
|
1689
|
+
{' '}启用附加模型审查(默认关闭)
|
|
1690
|
+
</label>
|
|
1691
|
+
<span className="dshdg-spacer" />
|
|
1692
|
+
<Badge tone={enabled ? 'on' : 'off'}>{enabled ? '已启用' : '关闭'}</Badge>
|
|
1693
|
+
</div>
|
|
1694
|
+
<p className="dshdg-muted">
|
|
1695
|
+
附加审查是独立的只读检查:它读交付的 diff 与证据,给出建议,但<strong>不能</strong>代替宿主验收、不能修改文件、
|
|
1696
|
+
也不会触发自动修复循环。它和本机调用开关相互独立。
|
|
1697
|
+
</p>
|
|
1698
|
+
{sameRoute ? (
|
|
1699
|
+
<p className="dshdg-fail">
|
|
1700
|
+
审查与执行的提供方/模型相同,独立性问题无法保证;建议换一个模型。宿主可能会拒绝这种组合。
|
|
1701
|
+
</p>
|
|
1702
|
+
) : null}
|
|
1703
|
+
</div>
|
|
1704
|
+
{enabled ? (
|
|
1705
|
+
<SelectionFields
|
|
1706
|
+
providers={providers}
|
|
1707
|
+
idPrefix="dshdg-review"
|
|
1708
|
+
value={{
|
|
1709
|
+
providerId: review.providerId ?? null,
|
|
1710
|
+
model: review.model ?? null,
|
|
1711
|
+
reasoningEffort: review.reasoningEffort ?? null,
|
|
1712
|
+
}}
|
|
1713
|
+
onChange={(next) => {
|
|
1714
|
+
store.editDraft((current) => {
|
|
1715
|
+
current.review.providerId = next.providerId;
|
|
1716
|
+
current.review.model = next.model;
|
|
1717
|
+
if ('reasoningEffort' in next) current.review.reasoningEffort = next.reasoningEffort;
|
|
1718
|
+
});
|
|
1719
|
+
}}
|
|
1720
|
+
/>
|
|
1721
|
+
) : (
|
|
1722
|
+
<p className="dshdg-faint">关闭时不创建审查代理,也不发出任何审查请求。</p>
|
|
1723
|
+
)}
|
|
1724
|
+
</div>
|
|
1725
|
+
);
|
|
1726
|
+
}
|
|
1727
|
+
|
|
1728
|
+
// ---------------------------------------------------------------------------
|
|
1729
|
+
// Task records
|
|
1730
|
+
// ---------------------------------------------------------------------------
|
|
1731
|
+
|
|
1732
|
+
/**
|
|
1733
|
+
* One task's details: effective config, diff, evidence, usage, review outcome.
|
|
1734
|
+
* @param {object} props - `store`, `task`.
|
|
1735
|
+
* @returns {object} the detail card.
|
|
1736
|
+
*/
|
|
1737
|
+
function TaskDetail({ store, task }) {
|
|
1738
|
+
const outcome = taskOutcome(task);
|
|
1739
|
+
const files = changedFiles(task);
|
|
1740
|
+
// A bounded read of the task's own activity metadata. `available: false` means the
|
|
1741
|
+
// record carries none (an old record, or a task that never reached execution), and
|
|
1742
|
+
// that is stated as "未采集到" rather than as "idle" or "healthy".
|
|
1743
|
+
const progress = taskProgress(task);
|
|
1744
|
+
const activity = taskActivity(task);
|
|
1745
|
+
// `view()` freezes the configuration that actually ran; a later settings edit
|
|
1746
|
+
// does not retroactively change what a finished task reports.
|
|
1747
|
+
const worker = task.effective?.worker ?? {};
|
|
1748
|
+
const review = task.review ?? null;
|
|
1749
|
+
const reviewState = review === null ? 'not_run' : (review.state ?? 'not_run');
|
|
1750
|
+
const diff = task.diff ?? null;
|
|
1751
|
+
const execution = task.execution ?? null;
|
|
1752
|
+
const error = task.error ?? execution?.error ?? null;
|
|
1753
|
+
const permission = permissionSummary(task);
|
|
1754
|
+
const pending = pendingPermission(task);
|
|
1755
|
+
const evidence = Array.isArray(task.permission?.evidence) ? task.permission.evidence : [];
|
|
1756
|
+
const badgeTone = isAwaitingPermission(task)
|
|
1757
|
+
? 'warn'
|
|
1758
|
+
: (task.state === 'awaiting-host-review' ? 'warn' : (task.state === 'failed' ? 'warn' : 'off'));
|
|
1759
|
+
return (
|
|
1760
|
+
<div className="dshdg-item">
|
|
1761
|
+
<div className="dshdg-item-head">
|
|
1762
|
+
<strong className="dshdg-mono">{task.taskId}</strong>
|
|
1763
|
+
<Badge tone={badgeTone}>
|
|
1764
|
+
{taskStateLabel(task.state)}
|
|
1765
|
+
</Badge>
|
|
1766
|
+
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
1767
|
+
<span className="dshdg-spacer" />
|
|
1768
|
+
<button
|
|
1769
|
+
type="button"
|
|
1770
|
+
className="dshdg-danger"
|
|
1771
|
+
disabled={!isCancellable(task.state)}
|
|
1772
|
+
onClick={() => { void store.cancelTask(task.taskId); }}
|
|
1773
|
+
>
|
|
1774
|
+
取消任务
|
|
1775
|
+
</button>
|
|
1776
|
+
</div>
|
|
1777
|
+
<p className="dshdg-muted">{outcome.note}</p>
|
|
1778
|
+
|
|
1779
|
+
<div className="dshdg-card" data-dshdg-task-progress="">
|
|
1780
|
+
<h4>进展</h4>
|
|
1781
|
+
<p className="dshdg-mono">{progress.headline}</p>
|
|
1782
|
+
<p className="dshdg-hint">{progress.detail}</p>
|
|
1783
|
+
</div>
|
|
1784
|
+
|
|
1785
|
+
<dl className="dshdg-kv">
|
|
1786
|
+
<dt>生效提供方</dt>
|
|
1787
|
+
<dd className="dshdg-mono">{worker.providerId ?? '—'}</dd>
|
|
1788
|
+
<dt>生效模型</dt>
|
|
1789
|
+
<dd className="dshdg-mono">{worker.model ?? '—'}</dd>
|
|
1790
|
+
<dt>推理强度</dt>
|
|
1791
|
+
<dd className="dshdg-mono">{worker.reasoningEffort ?? '(不指定)'}</dd>
|
|
1792
|
+
<dt>工作区</dt>
|
|
1793
|
+
<dd className="dshdg-mono">{task.workspacePath ?? '—'}</dd>
|
|
1794
|
+
<dt>隔离</dt>
|
|
1795
|
+
<dd>{ISOLATION_LABELS[task.isolation ?? worker.isolation] ?? task.isolation ?? worker.isolation ?? '—'}</dd>
|
|
1796
|
+
<dt>对话</dt>
|
|
1797
|
+
<dd>
|
|
1798
|
+
{execution?.conversation === null || execution?.conversation === undefined
|
|
1799
|
+
? (task.continueFromTaskId === null || task.continueFromTaskId === undefined
|
|
1800
|
+
? '(未放置对话)'
|
|
1801
|
+
: `(未放置对话;本任务声明续接 ${task.continueFromTaskId})`)
|
|
1802
|
+
: (execution.conversation.reused === true
|
|
1803
|
+
? `续接 ${execution.conversation.continuedFromTaskId ?? '上一任务'} · 工作区 ${execution.conversation.workspaceId ?? '—'}`
|
|
1804
|
+
: `新开 · 工作区 ${execution.conversation.workspaceId ?? '—'}`)}
|
|
1805
|
+
</dd>
|
|
1806
|
+
<dt>阶段</dt>
|
|
1807
|
+
<dd>{taskPhaseLabel(task.phase)}</dd>
|
|
1808
|
+
<dt>最近进展</dt>
|
|
1809
|
+
<dd>
|
|
1810
|
+
{activity === null || activity.lastActivityAt === null
|
|
1811
|
+
? '未采集到'
|
|
1812
|
+
: `${formatTime(activity.lastActivityAt)}(距上次进展 ${formatDuration(activity.idleForMs)})`}
|
|
1813
|
+
</dd>
|
|
1814
|
+
<dt>当前工具</dt>
|
|
1815
|
+
<dd>
|
|
1816
|
+
{activity === null || activity.currentTool === null
|
|
1817
|
+
? (activity === null ? '未采集到' : '当前没有正在运行的工具')
|
|
1818
|
+
: `${activity.currentTool.name} · 已运行 ${formatDuration(activity.currentTool.elapsedMs)}`}
|
|
1819
|
+
</dd>
|
|
1820
|
+
<dt>无进展诊断</dt>
|
|
1821
|
+
<dd>
|
|
1822
|
+
{activity === null || activity.selfCheck === null || activity.selfCheck.verdict === null
|
|
1823
|
+
? (activity === null ? '未采集到' : '尚未触发程序自检(安静时间还没到自检间隔)')
|
|
1824
|
+
: `${SELF_CHECK_LABELS[activity.selfCheck.verdict] ?? activity.selfCheck.verdict}`
|
|
1825
|
+
+ (activity.selfCheck.checkedAt === null ? '' : `(${formatTime(activity.selfCheck.checkedAt)})`)}
|
|
1826
|
+
</dd>
|
|
1827
|
+
<dt>监控间隔</dt>
|
|
1828
|
+
<dd>
|
|
1829
|
+
{activity === null || activity.selfCheckSeconds === null
|
|
1830
|
+
? '未采集到'
|
|
1831
|
+
: `自检 ${formatDuration(activity.selfCheckSeconds * 1000)} · 提醒 ${formatDuration((activity.attentionSeconds ?? 0) * 1000)}`}
|
|
1832
|
+
</dd>
|
|
1833
|
+
<dt>创建</dt>
|
|
1834
|
+
<dd>{formatTime(task.createdAt)}</dd>
|
|
1835
|
+
<dt>结束</dt>
|
|
1836
|
+
<dd>{formatTime(task.endedAt)}</dd>
|
|
1837
|
+
<dt>用量</dt>
|
|
1838
|
+
<dd>{execution?.usage === null || execution?.usage === undefined ? '不可用' : boundedText(execution.usage, 600)}</dd>
|
|
1839
|
+
<dt>附加审查</dt>
|
|
1840
|
+
<dd>
|
|
1841
|
+
{REVIEW_STATE_LABELS[reviewState] ?? reviewState}
|
|
1842
|
+
{review?.verdict === null || review?.verdict === undefined
|
|
1843
|
+
? ''
|
|
1844
|
+
: ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`}
|
|
1845
|
+
</dd>
|
|
1846
|
+
<dt>宿主验收</dt>
|
|
1847
|
+
<dd>{task.hostAcceptance === null || task.hostAcceptance === undefined ? '未记录(插件不会自行验收)' : '已由宿主记录'}</dd>
|
|
1848
|
+
</dl>
|
|
1849
|
+
|
|
1850
|
+
<h4>改动文件</h4>
|
|
1851
|
+
{files === null
|
|
1852
|
+
? <p className="dshdg-faint">宿主未回报可识别的文件摘要,请以下方原始 diff 为准。</p>
|
|
1853
|
+
: <ul className="dshdg-mono">{files.map((file) => <li key={file}>{file}</li>)}</ul>}
|
|
1854
|
+
{diff?.patchWithheld === true
|
|
1855
|
+
? <p className="dshdg-fail">宿主判定这批改动不宜展示内容(命中敏感路径或超出上限),只给出说明。</p>
|
|
1856
|
+
: null}
|
|
1857
|
+
{diff?.patchTruncated === true ? <p className="dshdg-hint">diff 已截断。</p> : null}
|
|
1858
|
+
|
|
1859
|
+
<h4>diff</h4>
|
|
1860
|
+
<pre className="dshdg-pre">{boundedText(diff?.patchText ?? '(无 diff 内容)')}</pre>
|
|
1861
|
+
|
|
1862
|
+
<h4>验证证据</h4>
|
|
1863
|
+
<pre className="dshdg-pre">{boundedText(execution?.text ?? execution ?? '(无验证证据)')}</pre>
|
|
1864
|
+
|
|
1865
|
+
{error === null ? null : (
|
|
1866
|
+
<>
|
|
1867
|
+
<h4>错误</h4>
|
|
1868
|
+
<pre className="dshdg-pre">{boundedText(error, 4000)}</pre>
|
|
1869
|
+
</>
|
|
1870
|
+
)}
|
|
1871
|
+
|
|
1872
|
+
{review?.text === undefined || review?.text === null || review.text === '' ? null : (
|
|
1873
|
+
<>
|
|
1874
|
+
<h4>审查发现</h4>
|
|
1875
|
+
<pre className="dshdg-pre">{boundedText(review.text, 8000)}</pre>
|
|
1876
|
+
</>
|
|
1877
|
+
)}
|
|
1878
|
+
|
|
1879
|
+
<h4>本次调用授权</h4>
|
|
1880
|
+
<p className={isAwaitingPermission(task) ? 'dshdg-hint' : 'dshdg-faint'}>{permission.note}</p>
|
|
1881
|
+
{permission.detail === '' ? null : <p className="dshdg-faint dshdg-mono">{permission.detail}</p>}
|
|
1882
|
+
{pending === null ? null : (
|
|
1883
|
+
<dl className="dshdg-kv">
|
|
1884
|
+
<dt>工具</dt>
|
|
1885
|
+
<dd className="dshdg-mono">{pending.toolName ?? '—'}</dd>
|
|
1886
|
+
<dt>调用编号</dt>
|
|
1887
|
+
<dd className="dshdg-mono">{pending.callId ?? '—'}</dd>
|
|
1888
|
+
<dt>请求的权限</dt>
|
|
1889
|
+
<dd className="dshdg-mono">{pending.requestedAccess?.mode ?? '(该工具自身的调用)'}</dd>
|
|
1890
|
+
<dt>实际参数(已脱敏)</dt>
|
|
1891
|
+
<dd className="dshdg-mono">{boundedText(pending.arguments ?? '(不可读)', 2000)}</dd>
|
|
1892
|
+
<dt>工作进程给出的理由</dt>
|
|
1893
|
+
<dd>{pending.reason ?? '(未给出)'}(这是工作进程自己的说法,不是被决定的操作本身)</dd>
|
|
1894
|
+
<dt>截止</dt>
|
|
1895
|
+
<dd>{formatTime(pending.deadlineAt)}</dd>
|
|
1896
|
+
</dl>
|
|
1897
|
+
)}
|
|
1898
|
+
{evidence.length === 0 ? null : (
|
|
1899
|
+
<>
|
|
1900
|
+
<h4>授权决定记录</h4>
|
|
1901
|
+
<ul className="dshdg-mono">
|
|
1902
|
+
{evidence.slice().reverse().map((entry) => (
|
|
1903
|
+
<li key={entry.requestId}>
|
|
1904
|
+
{`${entry.requestId} · ${entry.toolName ?? '—'} · `
|
|
1905
|
+
+ `${PERMISSION_STATE_LABELS[entry.state] ?? entry.state ?? '—'} · `
|
|
1906
|
+
+ `${PERMISSION_OUTCOME_LABELS[entry.outcome] ?? entry.outcome ?? '—'}`
|
|
1907
|
+
+ `${entry.decidedBy === 'commander' ? ` · ${PERMISSION_DECISION_LABELS[entry.outcome === 'allowed-once' ? 'allow-once' : 'reject'] ?? '本机指挥官'}` : ''}`}
|
|
1908
|
+
</li>
|
|
1909
|
+
))}
|
|
1910
|
+
</ul>
|
|
1911
|
+
</>
|
|
1912
|
+
)}
|
|
1913
|
+
<p className="dshdg-hint">
|
|
1914
|
+
逐次授权桥只决定“这一次调用”。它不能创建或扩大任何长期有效的授权(“长期有效”指跨调用、跨会话持久的授权),不能修改设置、凭据、本机调用开关、提供方、模型或隔离方式,
|
|
1915
|
+
也不能预先批准后续调用;工作进程的常规沙箱权限始终保持 workspace-write。此界面不提供手工批准按钮,决定由本机 MCP 指挥官通过
|
|
1916
|
+
delegate_permission_decide 作出。
|
|
1917
|
+
</p>
|
|
1918
|
+
|
|
1919
|
+
<p className="dshdg-hint">
|
|
1920
|
+
重试前请确认顶部的本机调用开关已开启,然后在 MCP 宿主重新提交任务。本界面不会直接提交任务。
|
|
1921
|
+
</p>
|
|
1922
|
+
</div>
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
|
|
1926
|
+
/** @param {object} props @returns {object} the task records panel. */
|
|
1927
|
+
/**
|
|
1928
|
+
* Bounded, program-driven task refresh.
|
|
1929
|
+
*
|
|
1930
|
+
* Every condition here exists to keep a *visible page* from doing work on its own:
|
|
1931
|
+
*
|
|
1932
|
+
* * it runs ONLY while the tasks tab is mounted (the effect lives in `TasksPanel`),
|
|
1933
|
+
* so switching tabs or unmounting clears the timer;
|
|
1934
|
+
* * it runs ONLY while there is something that can change — a live task in the list
|
|
1935
|
+
* or a live selected detail. A page full of terminal records never polls;
|
|
1936
|
+
* * it skips a hidden document (`document.hidden`) and registers a
|
|
1937
|
+
* `visibilitychange` listener so returning to the tab reads immediately instead
|
|
1938
|
+
* of waiting out the interval;
|
|
1939
|
+
* * it never overlaps: a refresh in flight suppresses the next tick, and the
|
|
1940
|
+
* interval is reset after each attempt, so a slow host cannot accumulate calls;
|
|
1941
|
+
* * it is a pure read of the task list — no model call, no task action, no settings
|
|
1942
|
+
* write — so it cannot disturb an unsaved draft or the selected task.
|
|
1943
|
+
*
|
|
1944
|
+
* The interval is deliberately much slower than the host's 5 s suggestion is worth
|
|
1945
|
+
* fighting over: 5 s of list reads costs nothing and keeps the page truthful.
|
|
1946
|
+
* @param {object} props - `store`, `snapshot`, `intervalMs`.
|
|
1947
|
+
* @returns {object | null} nothing (side effects only).
|
|
1948
|
+
*/
|
|
1949
|
+
function useTaskAutoRefresh({ store, snapshot, intervalMs = 5000 }) {
|
|
1950
|
+
const live = hasLiveTasks(snapshot.tasks) || (snapshot.taskDetail !== null && isLiveTask(snapshot.taskDetail));
|
|
1951
|
+
// Read through a ref so the effect does not restart on every store revision: a
|
|
1952
|
+
// restarted effect would reset the timer constantly and effectively poll far
|
|
1953
|
+
// faster than the interval.
|
|
1954
|
+
const liveRef = useRef(live);
|
|
1955
|
+
liveRef.current = live;
|
|
1956
|
+
|
|
1957
|
+
useEffect(() => {
|
|
1958
|
+
if (!live) return undefined;
|
|
1959
|
+
let timer = null;
|
|
1960
|
+
let disposed = false;
|
|
1961
|
+
|
|
1962
|
+
const schedule = () => {
|
|
1963
|
+
if (disposed) return;
|
|
1964
|
+
if (timer !== null) clearTimeout(timer);
|
|
1965
|
+
timer = setTimeout(tick, intervalMs);
|
|
1966
|
+
timer.unref?.();
|
|
1967
|
+
};
|
|
1968
|
+
|
|
1969
|
+
const tick = () => {
|
|
1970
|
+
timer = null;
|
|
1971
|
+
if (disposed) return;
|
|
1972
|
+
// A hidden tab is not watching anything: skip the read entirely, and let the
|
|
1973
|
+
// visibility listener below schedule the next one when it comes back.
|
|
1974
|
+
if (globalThis.document?.hidden === true) return;
|
|
1975
|
+
if (!liveRef.current) return;
|
|
1976
|
+
void store.refreshTasks('auto').finally(() => { schedule(); });
|
|
1977
|
+
};
|
|
1978
|
+
|
|
1979
|
+
const onVisibility = () => {
|
|
1980
|
+
if (globalThis.document?.hidden === true) return;
|
|
1981
|
+
if (!liveRef.current) return;
|
|
1982
|
+
if (timer !== null) clearTimeout(timer);
|
|
1983
|
+
timer = null;
|
|
1984
|
+
void store.refreshTasks('auto').finally(() => { schedule(); });
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
schedule();
|
|
1988
|
+
const doc = globalThis.document;
|
|
1989
|
+
doc?.addEventListener?.('visibilitychange', onVisibility);
|
|
1990
|
+
return () => {
|
|
1991
|
+
disposed = true;
|
|
1992
|
+
if (timer !== null) clearTimeout(timer);
|
|
1993
|
+
timer = null;
|
|
1994
|
+
doc?.removeEventListener?.('visibilitychange', onVisibility);
|
|
1995
|
+
};
|
|
1996
|
+
}, [store, live, intervalMs]);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
function TasksPanel({ store, snapshot }) {
|
|
2000
|
+
const tasks = snapshot.tasks ?? [];
|
|
2001
|
+
const detail = snapshot.taskDetail;
|
|
2002
|
+
useTaskAutoRefresh({ store, snapshot });
|
|
2003
|
+
const liveCount = tasks.filter(isLiveTask).length;
|
|
2004
|
+
return (
|
|
2005
|
+
<div className="dshdg-panel">
|
|
2006
|
+
<div className="dshdg-row">
|
|
2007
|
+
<p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。</p>
|
|
2008
|
+
<span className="dshdg-spacer" />
|
|
2009
|
+
<span className="dshdg-hint">
|
|
2010
|
+
{liveCount === 0 && !(detail !== null && isLiveTask(detail))
|
|
2011
|
+
? '当前没有运行中的任务,不会自动刷新。'
|
|
2012
|
+
: `有 ${liveCount} 个进行中的任务,页面可见时每 5 秒自动刷新一次(只读,不调用模型)。`}
|
|
2013
|
+
</span>
|
|
2014
|
+
<button type="button" disabled={snapshot.loading?.tasks === true} onClick={() => { void store.refreshTasks('manual'); }}>
|
|
2015
|
+
{snapshot.loading?.tasks === true ? '读取中…' : '刷新'}
|
|
2016
|
+
</button>
|
|
2017
|
+
</div>
|
|
2018
|
+
{tasks.length === 0 ? <p className="dshdg-faint">还没有任务记录。</p> : (
|
|
2019
|
+
<div className="dshdg-list">
|
|
2020
|
+
{tasks.map((task) => {
|
|
2021
|
+
const progress = taskProgress(task);
|
|
2022
|
+
return (
|
|
2023
|
+
<div className="dshdg-item" key={task.taskId}>
|
|
2024
|
+
<div className="dshdg-item-head">
|
|
2025
|
+
<span className="dshdg-mono">{task.taskId}</span>
|
|
2026
|
+
<Badge tone={isAwaitingPermission(task)
|
|
2027
|
+
? 'warn'
|
|
2028
|
+
: (task.state === 'awaiting-host-review' ? 'warn' : (task.state === 'failed' ? 'warn' : 'off'))}>
|
|
2029
|
+
{taskStateLabel(task.state)}
|
|
2030
|
+
</Badge>
|
|
2031
|
+
<Badge tone={progress.tone}>{taskPhaseLabel(task.phase)}</Badge>
|
|
2032
|
+
{isAwaitingPermission(task) ? <Badge tone="warn">{PERMISSION_STATE_LABELS.pending}</Badge> : null}
|
|
2033
|
+
<span className="dshdg-mono dshdg-faint">
|
|
2034
|
+
{task.config?.worker?.model ?? task.effective?.worker?.model ?? '—'}
|
|
2035
|
+
{' / '}
|
|
2036
|
+
{task.config?.worker?.reasoningEffort ?? task.effective?.worker?.reasoningEffort ?? '不指定'}
|
|
2037
|
+
</span>
|
|
2038
|
+
<span className="dshdg-spacer" />
|
|
2039
|
+
<span className="dshdg-faint">{formatTime(task.createdAt)}</span>
|
|
2040
|
+
<button
|
|
2041
|
+
type="button"
|
|
2042
|
+
disabled={snapshot.loading?.taskDetail === true}
|
|
2043
|
+
onClick={() => { void store.openTask(task.taskId); }}
|
|
2044
|
+
>
|
|
2045
|
+
详情
|
|
2046
|
+
</button>
|
|
2047
|
+
<button
|
|
2048
|
+
type="button"
|
|
2049
|
+
className="dshdg-danger"
|
|
2050
|
+
disabled={!isCancellable(task.state)}
|
|
2051
|
+
onClick={() => { void store.cancelTask(task.taskId); }}
|
|
2052
|
+
>
|
|
2053
|
+
取消
|
|
2054
|
+
</button>
|
|
2055
|
+
</div>
|
|
2056
|
+
<p className="dshdg-hint">{progress.headline}</p>
|
|
2057
|
+
{isAwaitingPermission(task)
|
|
2058
|
+
? <p className="dshdg-hint">{permissionSummary(task).note}</p>
|
|
2059
|
+
: null}
|
|
2060
|
+
</div>
|
|
2061
|
+
);
|
|
2062
|
+
})}
|
|
2063
|
+
</div>
|
|
2064
|
+
)}
|
|
2065
|
+
{detail === null ? null : <TaskDetail store={store} task={detail} />}
|
|
2066
|
+
<p className="dshdg-faint">{`状态集合:${TASK_STATES.map(taskStateLabel).join(' / ')}`}</p>
|
|
2067
|
+
</div>
|
|
2068
|
+
);
|
|
2069
|
+
}
|
|
2070
|
+
|
|
2071
|
+
// ---------------------------------------------------------------------------
|
|
2072
|
+
// Codex integration
|
|
2073
|
+
// ---------------------------------------------------------------------------
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* One target row: a single fact, with its own badge.
|
|
2077
|
+
*
|
|
2078
|
+
* The three targets are separate rows because they are separate facts. The page
|
|
2079
|
+
* must never let an operator read "agent installed" as "delegation authorized".
|
|
2080
|
+
* @param {object} props - `view`, a value from `codexTargetView`.
|
|
2081
|
+
* @returns {object} the row.
|
|
2082
|
+
*/
|
|
2083
|
+
function CodexTargetRow({ view }) {
|
|
2084
|
+
const paths = Array.isArray(view.paths) ? view.paths : [];
|
|
2085
|
+
return (
|
|
2086
|
+
<div className="dshdg-item">
|
|
2087
|
+
<div className="dshdg-item-head">
|
|
2088
|
+
<strong>{view.label}</strong>
|
|
2089
|
+
<Badge tone={view.tone}>{view.detail}</Badge>
|
|
2090
|
+
<span className="dshdg-spacer" />
|
|
2091
|
+
<span className="dshdg-mono dshdg-faint">{paths[0] ?? ''}</span>
|
|
2092
|
+
</div>
|
|
2093
|
+
{paths.length > 1 ? <p className="dshdg-mono dshdg-faint">{paths.slice(1).join(';')}</p> : null}
|
|
2094
|
+
</div>
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
/**
|
|
2099
|
+
* The Codex integration card.
|
|
2100
|
+
*
|
|
2101
|
+
* Only explicit clicks write anything: `install` / `repair` / `remove` are the
|
|
2102
|
+
* plugin's own buttons and nothing else in `init()` or a save calls them. The card
|
|
2103
|
+
* also states, in the panel itself, what Codex has to do afterwards (reload) and
|
|
2104
|
+
* that the plugin does not claim any particular `@`-selection behaviour for a Codex
|
|
2105
|
+
* surface.
|
|
2106
|
+
* @param {object} props - `store`, `snapshot`.
|
|
2107
|
+
* @returns {object} the card.
|
|
2108
|
+
*/
|
|
2109
|
+
function CodexPanel({ store, snapshot }) {
|
|
2110
|
+
const codex = snapshot.codex ?? null;
|
|
2111
|
+
const error = snapshot.codexError ?? null;
|
|
2112
|
+
const busy = snapshot.loading?.codexAction === true;
|
|
2113
|
+
const refreshing = snapshot.loading?.codexStatus === true;
|
|
2114
|
+
const agentView = codexTargetView(codex, null, 'agent');
|
|
2115
|
+
const mcpView = codexTargetView(codex, null, 'mcp');
|
|
2116
|
+
// The switch is reported from the delegation posture the page already reads. It
|
|
2117
|
+
// is displayed here so "files installed" is never confused with "dispatch allowed";
|
|
2118
|
+
// this card never turns it on.
|
|
2119
|
+
const switchAuthorized = snapshot.status?.delegation?.authorized === true
|
|
2120
|
+
|| snapshot.settings?.delegationEnabled === true;
|
|
2121
|
+
const switchView = codexTargetView(codex, { authorized: switchAuthorized }, 'switch');
|
|
2122
|
+
const ready = codex?.ready === true;
|
|
2123
|
+
const notes = Array.isArray(codex?.notes) ? codex.notes : [];
|
|
2124
|
+
const disabled = busy || refreshing || codex === null;
|
|
2125
|
+
return (
|
|
2126
|
+
<section className="dshdg-card" aria-labelledby="dshdg-codex-title">
|
|
2127
|
+
<div className="dshdg-row">
|
|
2128
|
+
<h3 id="dshdg-codex-title">Codex 集成(子智能体 + MCP)</h3>
|
|
2129
|
+
<span className="dshdg-spacer" />
|
|
2130
|
+
<Badge tone={ready ? 'on' : 'off'}>{ready ? '已就绪' : '未就绪'}</Badge>
|
|
2131
|
+
</div>
|
|
2132
|
+
<p className="dshdg-muted">
|
|
2133
|
+
{'点下面的按钮,把 '}
|
|
2134
|
+
<span className="dshdg-mono">agents/dsh-delegate.toml</span>
|
|
2135
|
+
{' 装进 Codex 目录,并在 Codex 的 '}
|
|
2136
|
+
<span className="dshdg-mono">config.toml</span>
|
|
2137
|
+
{' 里登记本插件的 stdio MCP 服务(delegate_status / delegate_submit / delegate_result / delegate_wait / delegate_cancel)。'
|
|
2138
|
+
+ '首次安装只会由你点击触发:打开本页、安装或升级本插件都不会自动创建子智能体文件或 MCP 条目。'
|
|
2139
|
+
+ '已经安装过的情况下,插件下次启动会把本插件自己写入的过期托管条目就地更新(例如补上 tool_timeout_sec);'
|
|
2140
|
+
+ '它不会改写非托管、被你改过的条目,也不会触碰 Codex 的其他设置。下面会显示当前条目缺了什么。'}
|
|
2141
|
+
</p>
|
|
2142
|
+
{error === null ? null : <p className="dshdg-fail">{error}</p>}
|
|
2143
|
+
{codex === null ? (
|
|
2144
|
+
<p className="dshdg-faint">正在读取 Codex 状态…</p>
|
|
2145
|
+
) : (
|
|
2146
|
+
<>
|
|
2147
|
+
<p className="dshdg-faint">
|
|
2148
|
+
{'Codex 目录:'}
|
|
2149
|
+
<span className="dshdg-mono">{String(codex.codexHome ?? '')}</span>
|
|
2150
|
+
{'(设置环境变量 CODEX_HOME 可改到别处)'}
|
|
2151
|
+
</p>
|
|
2152
|
+
<div className="dshdg-list" data-dshdg-codex-targets="">
|
|
2153
|
+
<CodexTargetRow view={agentView} />
|
|
2154
|
+
<CodexTargetRow view={mcpView} />
|
|
2155
|
+
<CodexTargetRow view={switchView} />
|
|
2156
|
+
</div>
|
|
2157
|
+
{codex.mcp?.state === 'outdated' ? (
|
|
2158
|
+
<p className="dshdg-hint" data-dshdg-codex-drift="">
|
|
2159
|
+
{'这个托管 MCP 条目已经过期:'}
|
|
2160
|
+
{codexMcpDriftText(codex.mcp)}
|
|
2161
|
+
{'。插件下次启动会自动在原地更新;也可以点上面的「安装 / 更新 Codex 集成」。'}
|
|
2162
|
+
</p>
|
|
2163
|
+
) : null}
|
|
2164
|
+
{notes.length === 0 ? null : (
|
|
2165
|
+
<ul className="dshdg-hint">
|
|
2166
|
+
{notes.map((note) => <li key={note.code}>{note.text}</li>)}
|
|
2167
|
+
</ul>
|
|
2168
|
+
)}
|
|
2169
|
+
<div className="dshdg-row">
|
|
2170
|
+
<button type="button" disabled={busy || refreshing} onClick={() => { void store.refreshCodexStatus(); }}>
|
|
2171
|
+
{refreshing ? '读取中…' : '刷新状态'}
|
|
2172
|
+
</button>
|
|
2173
|
+
<button type="button" className="dshdg-primary" disabled={disabled} onClick={() => { void store.runCodexAction('install'); }}>
|
|
2174
|
+
{busy ? '处理中…' : '安装 / 更新 Codex 集成'}
|
|
2175
|
+
</button>
|
|
2176
|
+
<button type="button" disabled={disabled} onClick={() => { void store.runCodexAction('repair'); }}>
|
|
2177
|
+
仅修复 MCP 配置
|
|
2178
|
+
</button>
|
|
2179
|
+
<button type="button" className="dshdg-danger" disabled={disabled} onClick={() => { void store.runCodexAction('remove'); }}>
|
|
2180
|
+
移除插件托管项
|
|
2181
|
+
</button>
|
|
2182
|
+
</div>
|
|
2183
|
+
{snapshot.codexOutcome === null || snapshot.codexOutcome === undefined
|
|
2184
|
+
? null
|
|
2185
|
+
: <p className="dshdg-hint">{describeCodexOutcome(snapshot.codexOutcome)}</p>}
|
|
2186
|
+
</>
|
|
2187
|
+
)}
|
|
2188
|
+
<p className="dshdg-hint">
|
|
2189
|
+
{'安装后需要让 Codex 重新载入:新开会话或重启 Codex,才会读到新的子智能体和 MCP 条目。'
|
|
2190
|
+
+ '本插件不宣称当前 Codex 桌面版/CLI 能在输入框用 @dsh-delegate 直接选中该子智能体——这取决于 Codex 版本自身是否提供提及选择;'
|
|
2191
|
+
+ '这里只保证子智能体文件与 MCP 工具存在,并由你在 Codex 提供的选择方式中指派它。'
|
|
2192
|
+
+ '子智能体只在明确指派时派发任务,并在提交前先检查上面的本机调用开关;本页不会替你打开该开关。'
|
|
2193
|
+
+ '同名的自定义 agent 会被保留并报告为冲突;没有本插件托管标记注释的同名 MCP 条目也视为你自己写的,不会被覆盖或删除。'}
|
|
2194
|
+
</p>
|
|
2195
|
+
</section>
|
|
2196
|
+
);
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
// ---------------------------------------------------------------------------
|
|
2200
|
+
// Root page
|
|
2201
|
+
// ---------------------------------------------------------------------------
|
|
2202
|
+
|
|
2203
|
+
/** Tab definitions: authorization is not a tab — it renders above all four. */
|
|
2204
|
+
const TABS = Object.freeze([
|
|
2205
|
+
{ key: 'providers', label: '接口管理' },
|
|
2206
|
+
{ key: 'execution', label: '执行设置' },
|
|
2207
|
+
{ key: 'review', label: '附加审查' },
|
|
2208
|
+
{ key: 'tasks', label: '任务记录' },
|
|
2209
|
+
{ key: 'codex', label: 'Codex 集成' },
|
|
2210
|
+
]);
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* The page registered as this bundle's configuration in the Plugins manager.
|
|
2214
|
+
*
|
|
2215
|
+
* Props arrive from the slot registration's `inject` face: `{ store }`, plus the
|
|
2216
|
+
* slot owner props `{ view }` (always `'page'` here) and the optional host
|
|
2217
|
+
* `form`, which this page deliberately ignores — its save control belongs to
|
|
2218
|
+
* the plugin's own user-plane store, not to the host config form.
|
|
2219
|
+
* @param {object} props - `store`, and the slot owner props.
|
|
2220
|
+
* @returns {object} the page.
|
|
2221
|
+
*/
|
|
2222
|
+
export function DelegateConfigPage(props) {
|
|
2223
|
+
const store = props.store;
|
|
2224
|
+
const snapshot = useSyncExternalStore(
|
|
2225
|
+
useCallback((listener) => store.subscribe(listener), [store]),
|
|
2226
|
+
useCallback(() => store.getSnapshot(), [store]),
|
|
2227
|
+
useCallback(() => store.getSnapshot(), [store]),
|
|
2228
|
+
);
|
|
2229
|
+
const [tab, setTab] = useState(TABS[0].key);
|
|
2230
|
+
const [saving, setSaving] = useState(false);
|
|
2231
|
+
const loaded = useRef(false);
|
|
2232
|
+
|
|
2233
|
+
useEffect(() => {
|
|
2234
|
+
if (loaded.current) return;
|
|
2235
|
+
loaded.current = true;
|
|
2236
|
+
void store.init();
|
|
2237
|
+
}, [store]);
|
|
2238
|
+
|
|
2239
|
+
const problems = useMemo(
|
|
2240
|
+
() => (snapshot.draft === null ? [] : precheckDraft(snapshot.draft)),
|
|
2241
|
+
[snapshot.draft],
|
|
2242
|
+
);
|
|
2243
|
+
const tabRefs = useRef(new Map());
|
|
2244
|
+
|
|
2245
|
+
return (
|
|
2246
|
+
<div className="dshdg-root">
|
|
2247
|
+
<Notices store={store} notices={snapshot.notices ?? []} />
|
|
2248
|
+
|
|
2249
|
+
<AuthorizationPanel store={store} snapshot={snapshot} />
|
|
2250
|
+
|
|
2251
|
+
<div className="dshdg-tabs" role="tablist" aria-label="DSH 委托设置">
|
|
2252
|
+
{TABS.map((entry) => (
|
|
2253
|
+
<button
|
|
2254
|
+
key={entry.key}
|
|
2255
|
+
type="button"
|
|
2256
|
+
role="tab"
|
|
2257
|
+
className="dshdg-tab"
|
|
2258
|
+
id={`dshdg-tab-${entry.key}`}
|
|
2259
|
+
aria-selected={tab === entry.key}
|
|
2260
|
+
aria-controls={`dshdg-panel-${entry.key}`}
|
|
2261
|
+
tabIndex={tab === entry.key ? 0 : -1}
|
|
2262
|
+
ref={(node) => {
|
|
2263
|
+
if (node === null) tabRefs.current.delete(entry.key);
|
|
2264
|
+
else tabRefs.current.set(entry.key, node);
|
|
2265
|
+
}}
|
|
2266
|
+
onClick={() => setTab(entry.key)}
|
|
2267
|
+
onKeyDown={(event) => {
|
|
2268
|
+
if (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft') return;
|
|
2269
|
+
event.preventDefault();
|
|
2270
|
+
const index = TABS.findIndex((candidate) => candidate.key === tab);
|
|
2271
|
+
const step = event.key === 'ArrowRight' ? 1 : -1;
|
|
2272
|
+
const next = TABS[(index + step + TABS.length) % TABS.length];
|
|
2273
|
+
setTab(next.key);
|
|
2274
|
+
tabRefs.current.get(next.key)?.focus?.();
|
|
2275
|
+
}}
|
|
2276
|
+
>
|
|
2277
|
+
{entry.label}
|
|
2278
|
+
</button>
|
|
2279
|
+
))}
|
|
2280
|
+
</div>
|
|
2281
|
+
|
|
2282
|
+
<div
|
|
2283
|
+
className="dshdg-panel"
|
|
2284
|
+
role="tabpanel"
|
|
2285
|
+
id={`dshdg-panel-${tab}`}
|
|
2286
|
+
aria-labelledby={`dshdg-tab-${tab}`}
|
|
2287
|
+
tabIndex={-1}
|
|
2288
|
+
>
|
|
2289
|
+
{tab === 'providers' ? <ProvidersPanel store={store} snapshot={snapshot} /> : null}
|
|
2290
|
+
{tab === 'execution' ? <ExecutionPanel store={store} snapshot={snapshot} /> : null}
|
|
2291
|
+
{tab === 'review' ? <ReviewPanel store={store} snapshot={snapshot} /> : null}
|
|
2292
|
+
{tab === 'tasks' ? <TasksPanel store={store} snapshot={snapshot} /> : null}
|
|
2293
|
+
{tab === 'codex' ? <CodexPanel store={store} snapshot={snapshot} /> : null}
|
|
2294
|
+
</div>
|
|
2295
|
+
|
|
2296
|
+
<div className="dshdg-row">
|
|
2297
|
+
<span className="dshdg-hint">
|
|
2298
|
+
{snapshot.dirty === true ? '有未保存的修改。' : '所有修改已保存。'}
|
|
2299
|
+
{problems.length === 0 ? '' : ` 待修正:${problems[0]}${problems.length > 1 ? ` 等 ${problems.length} 项` : ''}`}
|
|
2300
|
+
</span>
|
|
2301
|
+
<span className="dshdg-spacer" />
|
|
2302
|
+
<button
|
|
2303
|
+
type="button"
|
|
2304
|
+
disabled={snapshot.dirty !== true || snapshot.loading?.save === true}
|
|
2305
|
+
onClick={() => { store.resetDraft(); }}
|
|
2306
|
+
>
|
|
2307
|
+
放弃修改
|
|
2308
|
+
</button>
|
|
2309
|
+
<button
|
|
2310
|
+
type="button"
|
|
2311
|
+
className="dshdg-primary"
|
|
2312
|
+
disabled={snapshot.dirty !== true || snapshot.loading?.save === true || saving}
|
|
2313
|
+
onClick={async () => {
|
|
2314
|
+
setSaving(true);
|
|
2315
|
+
try {
|
|
2316
|
+
await store.saveSettings();
|
|
2317
|
+
} finally {
|
|
2318
|
+
setSaving(false);
|
|
2319
|
+
}
|
|
2320
|
+
}}
|
|
2321
|
+
>
|
|
2322
|
+
{snapshot.loading?.save === true || saving ? '保存中…' : '保存设置'}
|
|
2323
|
+
</button>
|
|
2324
|
+
</div>
|
|
2325
|
+
<p className="dshdg-faint">
|
|
2326
|
+
保存会整体替换设置文档;正在运行的任务保留它自己的快照。密钥从不随设置保存或导出。
|
|
2327
|
+
</p>
|
|
2328
|
+
</div>
|
|
2329
|
+
);
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
/** Re-exported so the documented contract and tests share one name for the body document. */
|
|
2333
|
+
export { documentFromDraft, describeError, exportDocument };
|