dsh-extra-plan 0.0.0-stage → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +179 -2
- package/assets/presets/extra-plan/agent.cordis.yml +580 -0
- package/assets/presets/extra-plan/preset-definition-extra-plan-executor.generated.yml +115 -0
- package/assets/presets/extra-plan/preset-definition-extra-plan-planner.generated.yml +113 -0
- package/assets/presets/extra-plan/preset-definition-extra-plan-prober.generated.yml +107 -0
- package/assets/presets/extra-plan/preset-definition-extra-plan-reviewer.generated.yml +115 -0
- package/assets/presets/extra-plan/preset-definition.generated.yml +335 -0
- package/assets/presets/extra-plan/preset.yml +2 -0
- package/cordis.patch.yml +7 -0
- package/index.js +1671 -0
- package/lib/agent-runtime.js +172 -0
- package/lib/agent-session.js +65 -0
- package/lib/assembly-presentation.js +267 -0
- package/lib/client-carrier.js +7 -0
- package/lib/client.js +314 -0
- package/lib/extra-plan-gate-tool.js +387 -0
- package/lib/gate-decisions.js +744 -0
- package/lib/gate-words.js +108 -0
- package/lib/live-config.js +293 -0
- package/lib/log-retention.js +132 -0
- package/lib/model-routing.js +648 -0
- package/lib/path-policy.js +464 -0
- package/lib/plan-draft-tool.js +294 -0
- package/lib/planner-budget.js +136 -0
- package/lib/preset-defaults.generated.js +17 -0
- package/lib/preset-settings.js +3 -0
- package/lib/preset-sync.js +809 -0
- package/lib/preset-yaml.js +438 -0
- package/lib/role-contract.js +11 -0
- package/lib/run-code-scanner.js +360 -0
- package/lib/run-code-static.js +621 -0
- package/lib/runtime-diagnostics.js +89 -0
- package/lib/runtime-lifecycle.js +162 -0
- package/lib/runtime-static.js +23 -0
- package/lib/save-contract.js +263 -0
- package/lib/save-persistence.js +223 -0
- package/lib/save-plan-markdown-parser.js +369 -0
- package/lib/save-plan-validation-diagnostics.js +49 -0
- package/lib/save-plan-validation.js +812 -0
- package/lib/save-probe-validation.js +173 -0
- package/lib/save-source-verification.js +195 -0
- package/lib/save-tool-factories.js +270 -0
- package/lib/sdk-text-cache.js +161 -0
- package/lib/settings-contract.js +191 -0
- package/lib/settings.js +369 -0
- package/lib/shell-mutation.js +484 -0
- package/lib/usage-ledger-background.js +214 -0
- package/lib/usage-ledger-worker.js +116 -0
- package/lib/usage-ledger.js +1393 -0
- package/locale/en.json +6 -0
- package/locale/settings/en.json +6 -0
- package/locale/settings/zh.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +56 -4
- package/scripts/generate-runtime-defaults.mjs +796 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "dsh-extra-plan",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
const React = require("react");
|
|
8
|
+
|
|
9
|
+
// 技术 ID 与 ConfigForms namespace 保持兼容;bundle slot key 是包名,不能当作 namespace。
|
|
10
|
+
const NS = "dsh-extra-plan-settings";
|
|
11
|
+
const BUNDLE_NAME = "dsh-extra-plan";
|
|
12
|
+
|
|
13
|
+
const zh = {
|
|
14
|
+
cardTitle: "按需规划模式全局管理",
|
|
15
|
+
cardDescription: "统一管理按需规划模式的配置、预设核对与界面加载。",
|
|
16
|
+
proSection: "子代理相关",
|
|
17
|
+
generalSection: "通用设置",
|
|
18
|
+
plannerModel: "规划者 | 使用模型",
|
|
19
|
+
crossProviderPlannerModel: "跨提供方",
|
|
20
|
+
plannerPromptSuffix: "规划者 | 额外引导",
|
|
21
|
+
exploreBudget: "规划者 | 探查额度",
|
|
22
|
+
otherAgentModel: "其他子代理 | 使用模型",
|
|
23
|
+
reviewerUsesPlannerModel: "验收者 | 使用规划者模型",
|
|
24
|
+
anchoredBootstrap: "首轮引导开关",
|
|
25
|
+
creativeMode: "创造模式开关",
|
|
26
|
+
runcodeCatchGate: "run_code 容错检查",
|
|
27
|
+
webFetch: "web_fetch开关",
|
|
28
|
+
toolPresentationMode: "工具执行器",
|
|
29
|
+
toolPresentationModeNative: "默认",
|
|
30
|
+
toolPresentationModePtc: "PTC模式",
|
|
31
|
+
save: "保存",
|
|
32
|
+
saving: "保存中…",
|
|
33
|
+
saved: "已保存",
|
|
34
|
+
savedPartial: "保存失败",
|
|
35
|
+
loading: "加载中…",
|
|
36
|
+
unavailable: "该配置命名空间当前未由宿主提供,暂时无法编辑。",
|
|
37
|
+
readOnly: "本部署的设置为只读。",
|
|
38
|
+
trueValue: "开启",
|
|
39
|
+
falseValue: "关闭"
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const en = {
|
|
43
|
+
cardTitle: "Extra Plan Global Manager",
|
|
44
|
+
cardDescription: "Manage configuration, preset checks, and UI loading for Extra Plan.",
|
|
45
|
+
proSection: "Sub-agents",
|
|
46
|
+
generalSection: "General Settings",
|
|
47
|
+
plannerModel: "Planner | Model",
|
|
48
|
+
crossProviderPlannerModel: "Cross-Provider Planner Model",
|
|
49
|
+
plannerPromptSuffix: "Planner | Extra Prompt Suffix",
|
|
50
|
+
exploreBudget: "Planner | Explore Budget",
|
|
51
|
+
otherAgentModel: "Other Agents | Model",
|
|
52
|
+
reviewerUsesPlannerModel: "Reviewer | Use Planner Model",
|
|
53
|
+
anchoredBootstrap: "Anchored Bootstrap",
|
|
54
|
+
creativeMode: "Creative Mode",
|
|
55
|
+
runcodeCatchGate: "RunCode Catch Guard",
|
|
56
|
+
webFetch: "Web Fetch",
|
|
57
|
+
toolPresentationMode: "Tool Executor",
|
|
58
|
+
toolPresentationModeNative: "Native",
|
|
59
|
+
toolPresentationModePtc: "Pure PTC",
|
|
60
|
+
save: "Save",
|
|
61
|
+
saving: "Saving…",
|
|
62
|
+
saved: "Saved.",
|
|
63
|
+
savedPartial: "Save failed.",
|
|
64
|
+
loading: "Loading…",
|
|
65
|
+
unavailable: "The Host does not serve this settings namespace right now.",
|
|
66
|
+
readOnly: "This deployment stores settings read-only.",
|
|
67
|
+
trueValue: "True",
|
|
68
|
+
falseValue: "False"
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// 字段顺序、校验与 descriptor 合同保持一份;1 项宿主设置也在同一 ConfigForms mutate 中提交。
|
|
72
|
+
// BEGIN GENERATED SETTINGS FIELDS
|
|
73
|
+
const EXTRA_FIELDS = Object.freeze([
|
|
74
|
+
{"key":"anchoredBootstrap","control":"select","options":[true,false],"locale":"anchoredBootstrap","section":"general","hint":"首轮极简工具 + 提示词 | 新会话/新子代理生效"},
|
|
75
|
+
{"key":"creativeMode","control":"select","options":[true,false],"locale":"creativeMode","section":"general","hint":"是否开启dsh官方创造模式 | 立即生效"},
|
|
76
|
+
{"key":"webFetch","control":"select","options":[true,false],"locale":"webFetch","section":"general","hint":"是否开启web_fetch | 立即生效"},
|
|
77
|
+
{"key":"runcodeCatchGate","control":"select","options":[true,false],"locale":"runcodeCatchGate","section":"general","hint":"PTC模式下,增加每个工具调用需要try catch的闸门。通过限制+建议的模式保障仅单个调用报错 | 立即生效"},
|
|
78
|
+
{"key":"crossProviderPlannerModel","control":"select","options":[true,false],"locale":"crossProviderPlannerModel","section":"pro","hint":"允许跨提供方选择模型。开启时将以 其他提供方 - 主会话提供方 - deepseek官方 的顺序,获取可用模型。关闭时仅从主会话提供方获取。默认关闭 | 新会话/新子代理生效"},
|
|
79
|
+
{"key":"plannerModel","control":"text","locale":"plannerModel","section":"pro","hint":"规划者默认使用模型。未匹配/置空时:使用主会话模型 | 新会话/新子代理生效"},
|
|
80
|
+
{"key":"plannerPromptSuffix","control":"textarea","locale":"plannerPromptSuffix","section":"pro","hint":"在主会话发送给规划者的任务结尾,拼接上的内容。可能能增加规划者的智商(未验证)。可置空 | 立即生效"},
|
|
81
|
+
{"key":"exploreBudget","control":"number","locale":"exploreBudget","section":"pro","min":1,"step":1,"hint":"允许规划者调用工具的次数,避免后台无限制调用。同时限制一次runcode内可调用的工具上限数 | 立即生效"},
|
|
82
|
+
{"key":"otherAgentModel","control":"text","locale":"otherAgentModel","section":"pro","hint":"其他子代理默认使用模型。未匹配/置空时:使用主会话模型 | 新会话/新子代理生效"},
|
|
83
|
+
{"key":"reviewerUsesPlannerModel","control":"select","options":[true,false],"locale":"reviewerUsesPlannerModel","section":"pro","hint":"验收者是否改用规划者的模型。默认关闭 | 新会话/新子代理生效"},
|
|
84
|
+
]);
|
|
85
|
+
|
|
86
|
+
const HOST_ROW_FIELDS = Object.freeze([
|
|
87
|
+
{"key":"toolPresentationMode","control":"select","options":["native","ptc"],"optionLocale":{"native":"toolPresentationModeNative","ptc":"toolPresentationModePtc"},"locale":"toolPresentationMode","section":"general","hint":"工具执行器切换(默认/PTC模式),无法进行会话内切换 | 重启生效"},
|
|
88
|
+
]);
|
|
89
|
+
const ALL_FIELDS = Object.freeze(EXTRA_FIELDS.concat(HOST_ROW_FIELDS));
|
|
90
|
+
// END GENERATED SETTINGS FIELDS
|
|
91
|
+
|
|
92
|
+
const css =
|
|
93
|
+
'.esp-wrap{display:flex;flex-direction:column;gap:20px;max-width:760px;color:var(--dsw-alias-label-primary)}' +
|
|
94
|
+
'.esp-section{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-3);border-radius:16px;padding:14px 16px;display:flex;flex-direction:column;gap:0}' +
|
|
95
|
+
'.esp-sectionTitle{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary);line-height:1.5;margin:0 0 2px}' +
|
|
96
|
+
'.esp-field{display:flex;flex-direction:column;gap:6px;padding:12px 0}' +
|
|
97
|
+
'.esp-fieldHead{display:flex;align-items:center;gap:8px}' +
|
|
98
|
+
'.esp-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}' +
|
|
99
|
+
'.esp-field + .esp-field{border-top:.5px solid var(--dsw-alias-border-l2)}' +
|
|
100
|
+
'.esp-input,.esp-select{height:34px;border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font:inherit;font-size:13px;width:100%;box-sizing:border-box}' +
|
|
101
|
+
'.esp-textarea{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);border-radius:8px;padding:8px 12px;font:inherit;font-size:13px;width:100%;box-sizing:border-box;resize:vertical;min-height:80px}' +
|
|
102
|
+
'.esp-input:focus-visible,.esp-select:focus-visible,.esp-textarea:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}' +
|
|
103
|
+
'.esp-cardFooter{border-top:.5px solid var(--dsw-alias-border-l2);padding:12px 0 4px;display:flex;align-items:center;gap:8px}' +
|
|
104
|
+
'.esp-actions{display:flex;justify-content:flex-end;gap:8px;margin-left:auto}' +
|
|
105
|
+
'.esp-btn{appearance:none;font:inherit;cursor:pointer;border:.5px solid var(--dsw-alias-border-l4);background:transparent;color:var(--dsw-alias-label-secondary);border-radius:8px;padding:5px 12px;font-size:13px;white-space:nowrap}' +
|
|
106
|
+
'.esp-btnPrimary{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}' +
|
|
107
|
+
'.esp-btn:disabled{opacity:.5;cursor:default}' +
|
|
108
|
+
'.esp-ok{color:var(--dsw-alias-brand-primary);font-size:12px;margin:0}' +
|
|
109
|
+
'.esp-err{color:var(--dsw-alias-label-error);font-size:12px;margin:0}' +
|
|
110
|
+
'.esp-hint{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:1.5;margin:0}' +
|
|
111
|
+
'.esp-empty{color:var(--dsw-alias-label-tertiary);font-size:13px;margin:0}' +
|
|
112
|
+
'.esp-panelTitle{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary);line-height:1.5;margin:0}' +
|
|
113
|
+
'.esp-panelHint{font-size:13px;color:var(--dsw-alias-label-tertiary);line-height:1.5;margin:0}';
|
|
114
|
+
|
|
115
|
+
function apply(ctx) {
|
|
116
|
+
const tag = document.createElement("style");
|
|
117
|
+
tag.dataset.plugin = "dsh-extra-plan-settings";
|
|
118
|
+
tag.textContent = css;
|
|
119
|
+
document.head.appendChild(tag);
|
|
120
|
+
ctx.effect(() => () => tag.remove(), "dsh-extra-plan-settings: css");
|
|
121
|
+
const el = React.createElement;
|
|
122
|
+
const t = ctx.locale.bind(NS);
|
|
123
|
+
const sharedForm = ctx.configForms.get(NS);
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "dsh-extra-plan-settings: dictionaries");
|
|
127
|
+
|
|
128
|
+
function useSharedConfigForm() {
|
|
129
|
+
const [snapshot, setSnapshot] = React.useState(function () { return sharedForm.getSnapshot(); });
|
|
130
|
+
React.useEffect(function () {
|
|
131
|
+
const update = function () { setSnapshot(sharedForm.getSnapshot()); };
|
|
132
|
+
update();
|
|
133
|
+
return sharedForm.subscribe(update);
|
|
134
|
+
}, []);
|
|
135
|
+
return {
|
|
136
|
+
state: snapshot,
|
|
137
|
+
mutate: function (ops, revision) { return sharedForm.mutate(ops, revision); }
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function optionLabel(field, option) {
|
|
142
|
+
const localeKey = field.optionLocale && field.optionLocale[String(option)];
|
|
143
|
+
if (localeKey) return t(localeKey);
|
|
144
|
+
if (typeof option === "boolean") return option ? t("trueValue") : t("falseValue");
|
|
145
|
+
return String(option);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function optionValue(field, raw) {
|
|
149
|
+
if (!Array.isArray(field.options)) return raw;
|
|
150
|
+
for (const option of field.options) if (String(option) === raw) return option;
|
|
151
|
+
return raw;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function renderControl(field, value, disabled, onChange) {
|
|
155
|
+
if (field.control === "textarea") return el("textarea", {
|
|
156
|
+
className: "esp-textarea", disabled: disabled,
|
|
157
|
+
value: value === undefined || value === null ? "" : String(value),
|
|
158
|
+
onChange: function (e) { onChange(e.target.value); }
|
|
159
|
+
});
|
|
160
|
+
if (field.control === "number") return el("input", {
|
|
161
|
+
className: "esp-input", type: "number", disabled: disabled,
|
|
162
|
+
min: field.min === undefined ? undefined : String(field.min),
|
|
163
|
+
step: field.step === undefined ? undefined : String(field.step),
|
|
164
|
+
value: value === undefined || value === null ? "" : String(value),
|
|
165
|
+
onChange: function (e) { onChange(e.target.value); }
|
|
166
|
+
});
|
|
167
|
+
if (field.control === "select") return el("select", {
|
|
168
|
+
className: "esp-select", disabled: disabled,
|
|
169
|
+
value: value === undefined || value === null ? "" : String(value),
|
|
170
|
+
onChange: function (e) { onChange(optionValue(field, e.target.value)); }
|
|
171
|
+
}, field.options.map(function (option) {
|
|
172
|
+
return el("option", { key: String(option), value: String(option) }, optionLabel(field, option));
|
|
173
|
+
}));
|
|
174
|
+
return el("input", {
|
|
175
|
+
className: "esp-input", type: "text", disabled: disabled,
|
|
176
|
+
value: value === undefined || value === null ? "" : String(value),
|
|
177
|
+
onChange: function (e) { onChange(e.target.value); }
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function ExtraPlanForm(props) {
|
|
182
|
+
const form = props.configForm;
|
|
183
|
+
const snapshot = form !== undefined && form !== null ? form.state : undefined;
|
|
184
|
+
const value = snapshot !== undefined && snapshot !== null ? snapshot.value : undefined;
|
|
185
|
+
const writable = snapshot !== undefined && snapshot !== null ? snapshot.writable === true : false;
|
|
186
|
+
const revision = snapshot !== undefined && snapshot !== null ? snapshot.revision : undefined;
|
|
187
|
+
const status = snapshot !== undefined && snapshot !== null ? snapshot.status : "unavailable";
|
|
188
|
+
const [draft, setDraft] = React.useState(null);
|
|
189
|
+
const [saving, setSaving] = React.useState(false);
|
|
190
|
+
const [message, setMessage] = React.useState({ kind: "", text: "" });
|
|
191
|
+
|
|
192
|
+
React.useEffect(function () {
|
|
193
|
+
const next = {};
|
|
194
|
+
for (const field of ALL_FIELDS) {
|
|
195
|
+
const raw = value !== undefined && value !== null ? value[field.key] : undefined;
|
|
196
|
+
next[field.key] = raw === undefined ? "" : raw;
|
|
197
|
+
}
|
|
198
|
+
setDraft(next);
|
|
199
|
+
}, [value]);
|
|
200
|
+
|
|
201
|
+
if (status === "loading" || draft === null) return el("div", { className: "esp-section" }, el("p", { className: "esp-empty" }, t("loading")));
|
|
202
|
+
if (status === "unavailable") return el("div", { className: "esp-section" }, el("p", { className: "esp-empty" }, t("unavailable")));
|
|
203
|
+
|
|
204
|
+
function fieldValue(field) {
|
|
205
|
+
const raw = draft[field.key];
|
|
206
|
+
if (field.control === "number") {
|
|
207
|
+
const number = Number(raw);
|
|
208
|
+
return Number.isFinite(number) ? number : raw;
|
|
209
|
+
}
|
|
210
|
+
return raw;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async function saveAll() {
|
|
214
|
+
if (form === undefined || form === null || typeof form.mutate !== "function" || saving || !writable || draft === null || status !== "ready") return;
|
|
215
|
+
setSaving(true);
|
|
216
|
+
setMessage({ kind: "", text: "" });
|
|
217
|
+
const ops = ALL_FIELDS.map(function (field) {
|
|
218
|
+
return { op: "set", path: [field.key], value: fieldValue(field) };
|
|
219
|
+
});
|
|
220
|
+
try {
|
|
221
|
+
const accepted = await form.mutate(ops, revision);
|
|
222
|
+
setMessage(accepted === true ? { kind: "ok", text: t("saved") } : { kind: "error", text: t("savedPartial") });
|
|
223
|
+
} catch {
|
|
224
|
+
setMessage({ kind: "error", text: t("savedPartial") });
|
|
225
|
+
} finally {
|
|
226
|
+
setSaving(false);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function renderField(field, current, disabled, onChange) {
|
|
231
|
+
return el("label", { className: "esp-field", key: field.key },
|
|
232
|
+
el("span", { className: "esp-fieldHead" }, el("span", { className: "esp-label" }, t(field.locale))),
|
|
233
|
+
renderControl(field, current, disabled, function (next) {
|
|
234
|
+
onChange(next);
|
|
235
|
+
setMessage({ kind: "", text: "" });
|
|
236
|
+
}),
|
|
237
|
+
el("p", { className: "esp-hint" }, field.hint)
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const generalHeadFields = EXTRA_FIELDS.filter(function (field) { return field.section === "general" && field.key !== "runcodeCatchGate"; });
|
|
242
|
+
const generalTailFields = EXTRA_FIELDS.filter(function (field) { return field.section === "general" && field.key === "runcodeCatchGate"; });
|
|
243
|
+
const proFields = EXTRA_FIELDS.filter(function (field) { return field.section === "pro"; });
|
|
244
|
+
const disabled = saving || !writable;
|
|
245
|
+
return el(React.Fragment, null,
|
|
246
|
+
el("div", { className: "esp-section" },
|
|
247
|
+
el("p", { className: "esp-sectionTitle" }, t("generalSection")),
|
|
248
|
+
generalHeadFields.map(function (field) { return renderField(field, draft[field.key], disabled, function (next) { setDraft(function (prev) { return Object.assign({}, prev, { [field.key]: next }); }); }); }),
|
|
249
|
+
HOST_ROW_FIELDS.map(function (field) { return renderField(field, draft[field.key], disabled, function (next) { setDraft(function (prev) { return Object.assign({}, prev, { [field.key]: next }); }); }); }),
|
|
250
|
+
generalTailFields.map(function (field) { return renderField(field, draft[field.key], disabled, function (next) { setDraft(function (prev) { return Object.assign({}, prev, { [field.key]: next }); }); }); })
|
|
251
|
+
),
|
|
252
|
+
el("div", { className: "esp-section" },
|
|
253
|
+
el("p", { className: "esp-sectionTitle" }, t("proSection")),
|
|
254
|
+
proFields.map(function (field) { return renderField(field, draft[field.key], disabled, function (next) { setDraft(function (prev) { return Object.assign({}, prev, { [field.key]: next }); }); }); })
|
|
255
|
+
),
|
|
256
|
+
el("div", { className: "esp-cardFooter" },
|
|
257
|
+
writable ? null : el("p", { className: "esp-hint" }, t("readOnly")),
|
|
258
|
+
message.text ? el("p", { className: message.kind === "ok" ? "esp-ok" : "esp-err" }, message.text) : null,
|
|
259
|
+
el("div", { className: "esp-actions" }, el("button", {
|
|
260
|
+
className: "esp-btn esp-btnPrimary", disabled: disabled, onClick: saveAll
|
|
261
|
+
}, saving ? t("saving") : t("save")))
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function SettingsCard(props) {
|
|
267
|
+
const copy = props.translate !== undefined && props.translate !== null ? props.translate : function (key) { return key; };
|
|
268
|
+
|
|
269
|
+
return el("section", { className: "esp-wrap", "data-plugin-section": "dsh-extra-plan-settings-global" },
|
|
270
|
+
el("h4", { className: "esp-panelTitle" }, copy("cardTitle")),
|
|
271
|
+
el("p", { className: "esp-panelHint" }, copy("cardDescription")),
|
|
272
|
+
el(ExtraPlanForm, { configForm: props.configForm })
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function hasBundleConfigEntry() {
|
|
277
|
+
|
|
278
|
+
try {
|
|
279
|
+
return typeof ctx.slots.entries === "function" && ctx.slots.entries("plugins.bundle.config").some(function (entry) {
|
|
280
|
+
return entry.options !== undefined && entry.options.key === BUNDLE_NAME;
|
|
281
|
+
});
|
|
282
|
+
} catch { return false; }
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function DetailSettingsSection(props) {
|
|
286
|
+
const configForm = useSharedConfigForm();
|
|
287
|
+
const subject = props !== undefined && props !== null ? props.subject : undefined;
|
|
288
|
+
const isBundle = subject !== undefined && subject !== null && subject.kind === "bundle" && subject.pkg !== undefined && subject.pkg.name === BUNDLE_NAME;
|
|
289
|
+
if (!isBundle || hasBundleConfigEntry()) return null;
|
|
290
|
+
return el(SettingsCard, { configForm: configForm, translate: t });
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function safeInject(name, register) {
|
|
294
|
+
try { return ctx.slots.inject(name, register); } catch { return undefined; }
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function registerClientSurfaces() {
|
|
298
|
+
const detailOff = safeInject("plugins.detail.section", function () {
|
|
299
|
+
return ctx.slots.register({ name: "plugins.detail.section", id: "dsh-extra-plan-settings-global", order: 100, label: function () { return t("cardTitle"); }, locale: NS }, DetailSettingsSection);
|
|
300
|
+
});
|
|
301
|
+
return function () {
|
|
302
|
+
if (typeof detailOff === "function") detailOff();
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 设置表单仅经 plugins.detail.section 渲染于 bundle 页行列表之后;若本包 bundle.config 槽被任何一方注册,DetailSettingsSection 让位以保持唯一表单。
|
|
307
|
+
ctx.effect(() => ctx.configForms.whileServed([NS], registerClientSurfaces), "dsh-extra-plan-settings: same-page config surfaces");
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
exports.apply = apply;
|
|
311
|
+
exports.inject = ["slots", "locale", "configForms"];
|
|
312
|
+
return module.exports;
|
|
313
|
+
}
|
|
314
|
+
});
|