@lynn123411/dsh-matt-plus 0.0.0-stage → 0.13.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -2
- package/assets/icon.svg +7 -0
- package/cordis.patch.yml +3 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/preview.svg +27 -0
- package/docs/preview.zh.svg +27 -0
- package/lib/client.js +1161 -0
- package/lib/client.js.map +7 -0
- package/lib/index.js +587 -0
- package/lib/index.js.map +7 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +76 -4
- package/skills/LICENSE +21 -0
- package/skills/code-review/SKILL.md +91 -0
- package/skills/grilling/SKILL.md +16 -0
- package/skills/implement-spec/SKILL.md +52 -0
- package/skills/retro/SESSION-EVIDENCE.md +27 -0
- package/skills/retro/SKILL.md +44 -0
- package/skills/retro/agents/openai.yaml +5 -0
- package/skills/retro/session-index.mjs +193 -0
- package/skills/retro/session-index.test.mjs +80 -0
package/lib/client.js
ADDED
|
@@ -0,0 +1,1161 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: "@lynn123411/dsh-matt-plus", factory: (require) => { var module = { exports: {} }; var exports = module.exports;
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/client/index.ts
|
|
22
|
+
var index_exports = {};
|
|
23
|
+
__export(index_exports, {
|
|
24
|
+
apply: () => apply,
|
|
25
|
+
inject: () => inject
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/client/GrillingForm.jsx
|
|
30
|
+
var import_react = require("react");
|
|
31
|
+
var import_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
32
|
+
|
|
33
|
+
// src/recommendation.js
|
|
34
|
+
var MARKER = "recommended|\u63A8\u8350";
|
|
35
|
+
var BRACKETED_MARKER = `[\uFF08(\u3010\\[]\\s*(?:${MARKER})\\s*[\uFF09)\u3011\\]]`;
|
|
36
|
+
var SEPARATOR = "\uFF1B;\uFF0C,\u3001:\uFF1A\\-\u2014";
|
|
37
|
+
var TRAILING_PUNCTUATION = "\u3002.\uFF01!\uFF1F?\uFF1B;\uFF0C,\u3001~\uFF5E\\s";
|
|
38
|
+
var BRACKETED_SUFFIX = new RegExp(`[\\s]*[${SEPARATOR}]?\\s*${BRACKETED_MARKER}[${TRAILING_PUNCTUATION}]*$`, "i");
|
|
39
|
+
var BARE_SUFFIX = new RegExp(`[\\s]*[${SEPARATOR}]\\s*(?:${MARKER})[${TRAILING_PUNCTUATION}]*$`, "i");
|
|
40
|
+
function normalizeOption(option) {
|
|
41
|
+
const record = typeof option === "object" && option !== null && !Array.isArray(option) ? (
|
|
42
|
+
/** @type {Record<string, unknown>} */
|
|
43
|
+
option
|
|
44
|
+
) : {};
|
|
45
|
+
const label = stripRecommendationMarker(record.label);
|
|
46
|
+
const description = readExplanation(record.description);
|
|
47
|
+
return {
|
|
48
|
+
label: typeof label.text === "string" ? label.text : "",
|
|
49
|
+
recommended: label.found,
|
|
50
|
+
...description === void 0 ? {} : { description }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function readExplanation(value) {
|
|
54
|
+
if (typeof value !== "string") return void 0;
|
|
55
|
+
const text = value.trim();
|
|
56
|
+
return text === "" ? void 0 : text;
|
|
57
|
+
}
|
|
58
|
+
function stripRecommendationMarker(text) {
|
|
59
|
+
if (typeof text !== "string") return { text, found: false };
|
|
60
|
+
let remaining = text;
|
|
61
|
+
let found = false;
|
|
62
|
+
for (; ; ) {
|
|
63
|
+
const match = BRACKETED_SUFFIX.exec(remaining) ?? BARE_SUFFIX.exec(remaining);
|
|
64
|
+
if (match === null) break;
|
|
65
|
+
found = true;
|
|
66
|
+
remaining = remaining.slice(0, match.index).replace(/\s+$/, "");
|
|
67
|
+
}
|
|
68
|
+
return { text: remaining, found };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// src/answer-block.ts
|
|
72
|
+
var IMPORT_BLOCK_END = "\u3010/\u62F7\u95EE\u4F5C\u7B54\u3011";
|
|
73
|
+
var formIdEncoder = new TextEncoder();
|
|
74
|
+
var FNV64_OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
75
|
+
var FNV64_PRIME = 0x100000001b3n;
|
|
76
|
+
function shortFormId(callId) {
|
|
77
|
+
const text = typeof callId === "string" ? callId : "";
|
|
78
|
+
const compact = text.replace(/:ptc:/g, "").replace(/[^0-9a-z]/gi, "").toLowerCase();
|
|
79
|
+
return compact.length >= 4 ? compact.slice(-4) : compact.padStart(4, "0");
|
|
80
|
+
}
|
|
81
|
+
function importBlockStart(callId) {
|
|
82
|
+
let hash = FNV64_OFFSET_BASIS;
|
|
83
|
+
for (const byte of formIdEncoder.encode(String(callId))) {
|
|
84
|
+
hash = BigInt.asUintN(64, (hash ^ BigInt(byte)) * FNV64_PRIME);
|
|
85
|
+
}
|
|
86
|
+
return `\u3010\u62F7\u95EE\u4F5C\u7B54 #${hash.toString(36).padStart(13, "0")}\u3011`;
|
|
87
|
+
}
|
|
88
|
+
function versionTwoHeader(callId) {
|
|
89
|
+
return `\u3010\u62F7\u95EE\u4F5C\u7B54 v2:${encodeURIComponent(String(callId))}\u3011`;
|
|
90
|
+
}
|
|
91
|
+
function* importBlocks(text) {
|
|
92
|
+
let opening;
|
|
93
|
+
for (const match of text.matchAll(/(?:^|\n)(【(?:拷问作答(?: [^】\r\n]+)?|\/拷问作答)】)(?=\r?\n|$)/g)) {
|
|
94
|
+
const header = match[1];
|
|
95
|
+
const end = match.index + match[0].length;
|
|
96
|
+
const start = end - header.length;
|
|
97
|
+
if (header !== IMPORT_BLOCK_END) {
|
|
98
|
+
opening = { header, start, bodyStart: end };
|
|
99
|
+
} else if (opening !== void 0) {
|
|
100
|
+
yield { ...opening, bodyEnd: start, end };
|
|
101
|
+
opening = void 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function findImportBlock(draft, callId, format = "compatible") {
|
|
106
|
+
const firstHeader = format === "legacy" ? `\u3010\u62F7\u95EE\u4F5C\u7B54 ${shortFormId(callId)}\u3011` : importBlockStart(callId);
|
|
107
|
+
const fallbackHeader = format === "compatible" ? versionTwoHeader(callId) : void 0;
|
|
108
|
+
let fallback;
|
|
109
|
+
for (const block of importBlocks(draft)) {
|
|
110
|
+
if (block.header === firstHeader) return block;
|
|
111
|
+
if (block.header === fallbackHeader && fallback === void 0) fallback = block;
|
|
112
|
+
}
|
|
113
|
+
return fallback;
|
|
114
|
+
}
|
|
115
|
+
function importBlockBody(draft, callId, format = "compatible") {
|
|
116
|
+
if (typeof draft !== "string") return void 0;
|
|
117
|
+
const block = findImportBlock(draft, callId, format);
|
|
118
|
+
if (block === void 0) return void 0;
|
|
119
|
+
return draft.slice(block.bodyStart, block.bodyEnd).replace(/^\r?\n/, "").replace(/\r?\n$/, "");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// src/form-model.js
|
|
123
|
+
var TOOL_NAME = "grilling_form";
|
|
124
|
+
var QUESTION_TYPES = ["single", "multi", "free"];
|
|
125
|
+
function isRecord(value) {
|
|
126
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
127
|
+
}
|
|
128
|
+
function parseJson(text) {
|
|
129
|
+
if (typeof text !== "string" || text === "") return void 0;
|
|
130
|
+
try {
|
|
131
|
+
return JSON.parse(text);
|
|
132
|
+
} catch {
|
|
133
|
+
return void 0;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function isBlank(value) {
|
|
137
|
+
return typeof value !== "string" || value.trim() === "";
|
|
138
|
+
}
|
|
139
|
+
function readQuestionType(question) {
|
|
140
|
+
return QUESTION_TYPES.find((candidate) => question.type === candidate);
|
|
141
|
+
}
|
|
142
|
+
function drawnType(question, options) {
|
|
143
|
+
if (options.length === 0) return "free";
|
|
144
|
+
return readQuestionType(question) === "single" ? "single" : "multi";
|
|
145
|
+
}
|
|
146
|
+
function readOptions(options) {
|
|
147
|
+
if (!Array.isArray(options)) return [];
|
|
148
|
+
return options.filter(isRecord).map((option) => normalizeOption(option));
|
|
149
|
+
}
|
|
150
|
+
function readRound(args) {
|
|
151
|
+
const parsed = isRecord(args) ? args : parseJson(args);
|
|
152
|
+
if (!isRecord(parsed) || !Array.isArray(parsed.questions) || parsed.questions.length === 0) {
|
|
153
|
+
return { questions: [], replace: false };
|
|
154
|
+
}
|
|
155
|
+
const questions = [];
|
|
156
|
+
for (const [index, question] of parsed.questions.entries()) {
|
|
157
|
+
if (!isRecord(question)) return { questions: [], replace: false };
|
|
158
|
+
const options = readOptions(question.options);
|
|
159
|
+
const detail = readExplanation(question.detail);
|
|
160
|
+
questions.push({
|
|
161
|
+
id: String(index + 1),
|
|
162
|
+
number: index + 1,
|
|
163
|
+
question: typeof question.question === "string" ? question.question : "",
|
|
164
|
+
...detail === void 0 ? {} : { detail },
|
|
165
|
+
type: drawnType(question, options),
|
|
166
|
+
options
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return { questions, replace: parsed.replace === true };
|
|
170
|
+
}
|
|
171
|
+
function readQuestions(args) {
|
|
172
|
+
return readRound(args).questions;
|
|
173
|
+
}
|
|
174
|
+
function replacesEarlier(args) {
|
|
175
|
+
return readRound(args).replace;
|
|
176
|
+
}
|
|
177
|
+
function readResult(resultText) {
|
|
178
|
+
const parsed = parseJson(resultText);
|
|
179
|
+
if (!isRecord(parsed) || typeof parsed.ok !== "boolean") return void 0;
|
|
180
|
+
return { shown: parsed.ok, message: typeof parsed.message === "string" ? parsed.message : void 0 };
|
|
181
|
+
}
|
|
182
|
+
function readFormModel({ argsRaw, resultText, failed = false }) {
|
|
183
|
+
const questions = readQuestions(argsRaw);
|
|
184
|
+
const result = readResult(resultText);
|
|
185
|
+
let state;
|
|
186
|
+
if (failed) state = "error";
|
|
187
|
+
else if (result !== void 0) state = result.shown ? "form" : "notShown";
|
|
188
|
+
else if (typeof resultText === "string" && resultText !== "") state = "unknown";
|
|
189
|
+
else state = "running";
|
|
190
|
+
return {
|
|
191
|
+
state,
|
|
192
|
+
questions,
|
|
193
|
+
message: result === void 0 ? void 0 : result.message
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
function drawsForm(model) {
|
|
197
|
+
return model.state === "form" && model.questions.length > 0;
|
|
198
|
+
}
|
|
199
|
+
function drawsNote(model) {
|
|
200
|
+
return model.state === "notShown" || model.state === "error";
|
|
201
|
+
}
|
|
202
|
+
function firstText(content) {
|
|
203
|
+
if (!Array.isArray(content)) return void 0;
|
|
204
|
+
const text = content.find((block) => isRecord(block) && block.type === "text");
|
|
205
|
+
return isRecord(text) && typeof text.text === "string" ? text.text : void 0;
|
|
206
|
+
}
|
|
207
|
+
function argsRawOf(block) {
|
|
208
|
+
if (!isRecord(block)) return void 0;
|
|
209
|
+
const settled = "kind" in block;
|
|
210
|
+
const call = isRecord(block.call) ? block.call : void 0;
|
|
211
|
+
return (settled ? call?.argsRaw : block.argsRaw) ?? "";
|
|
212
|
+
}
|
|
213
|
+
function failureText(resultText, error) {
|
|
214
|
+
if (resultText !== void 0 && resultText !== "") return resultText;
|
|
215
|
+
const parts = [error?.name, error?.code].filter((part) => typeof part === "string" && part !== "");
|
|
216
|
+
return parts.length === 0 ? void 0 : parts.join(": ");
|
|
217
|
+
}
|
|
218
|
+
function readCallModel(block) {
|
|
219
|
+
if (!isRecord(block)) {
|
|
220
|
+
return { ...readFormModel({ argsRaw: "", resultText: void 0, failed: false }), failure: void 0 };
|
|
221
|
+
}
|
|
222
|
+
const settled = "kind" in block;
|
|
223
|
+
const resultText = settled ? firstText(block.content) : void 0;
|
|
224
|
+
const failed = settled && block.isError === true;
|
|
225
|
+
const error = isRecord(block.error) ? block.error : void 0;
|
|
226
|
+
return {
|
|
227
|
+
...readFormModel({ argsRaw: argsRawOf(block), resultText, failed }),
|
|
228
|
+
failure: failed ? failureText(resultText, error) : void 0
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
function selectsOnClick(locked, target) {
|
|
232
|
+
if (locked) return false;
|
|
233
|
+
const element = (
|
|
234
|
+
/** @type {{ closest?: (selector: string) => unknown }|null} */
|
|
235
|
+
target
|
|
236
|
+
);
|
|
237
|
+
if (element === null || typeof element?.closest !== "function") return true;
|
|
238
|
+
return element.closest("a, button") === null;
|
|
239
|
+
}
|
|
240
|
+
function sanitizeAnswers(value) {
|
|
241
|
+
if (!isRecord(value)) return {};
|
|
242
|
+
const answers = {};
|
|
243
|
+
for (const [id, answer] of Object.entries(value)) {
|
|
244
|
+
if (!isRecord(answer)) continue;
|
|
245
|
+
const shaped = Array.isArray(answer.selected) || typeof answer.custom === "string";
|
|
246
|
+
const selected = Array.isArray(answer.selected) ? answer.selected.filter((item) => typeof item === "string") : [];
|
|
247
|
+
const custom = typeof answer.custom === "string" ? answer.custom : "";
|
|
248
|
+
if (!shaped && selected.length === 0 && custom === "") continue;
|
|
249
|
+
answers[id] = { selected, custom };
|
|
250
|
+
}
|
|
251
|
+
return answers;
|
|
252
|
+
}
|
|
253
|
+
function answerParts(answer) {
|
|
254
|
+
if (!isRecord(answer)) return { selected: [], custom: "" };
|
|
255
|
+
return {
|
|
256
|
+
selected: Array.isArray(answer.selected) ? answer.selected.filter((item) => typeof item === "string") : [],
|
|
257
|
+
custom: typeof answer.custom === "string" ? answer.custom.trim() : ""
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function answerItems(answer) {
|
|
261
|
+
const { selected, custom } = answerParts(answer);
|
|
262
|
+
return [
|
|
263
|
+
...selected.map((label) => (
|
|
264
|
+
/** @type {{kind: 'option'|'custom', text: string}} */
|
|
265
|
+
{ kind: "option", text: label }
|
|
266
|
+
)),
|
|
267
|
+
...custom === "" ? [] : [
|
|
268
|
+
/** @type {{kind: 'option'|'custom', text: string}} */
|
|
269
|
+
{ kind: "custom", text: custom }
|
|
270
|
+
]
|
|
271
|
+
];
|
|
272
|
+
}
|
|
273
|
+
function importSegmentLines(question, answer) {
|
|
274
|
+
const items = answerItems(answer);
|
|
275
|
+
if (items.length === 0) return [];
|
|
276
|
+
return [
|
|
277
|
+
`${question.number}.`,
|
|
278
|
+
...items.flatMap((item) => item.text.split("\n").map((line) => `- ${line}`))
|
|
279
|
+
];
|
|
280
|
+
}
|
|
281
|
+
function applyRecommendedDefaults(questions, answers) {
|
|
282
|
+
const merged = isRecord(answers) ? { ...answers } : {};
|
|
283
|
+
for (const question of questions) {
|
|
284
|
+
if (merged[question.id] === void 0) {
|
|
285
|
+
const selected = question.options.filter((option) => option.recommended).map((option) => option.label);
|
|
286
|
+
if (selected.length > 0) merged[question.id] = { selected, custom: "" };
|
|
287
|
+
}
|
|
288
|
+
if (question.type === "single" && merged[question.id] !== void 0) {
|
|
289
|
+
merged[question.id] = selectOne(merged[question.id]);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return merged;
|
|
293
|
+
}
|
|
294
|
+
function selectOne(existing) {
|
|
295
|
+
const [kept] = existing.selected;
|
|
296
|
+
return { selected: kept === void 0 ? [] : [kept], custom: existing.custom };
|
|
297
|
+
}
|
|
298
|
+
function importBody(questions, answers) {
|
|
299
|
+
const blocks = [];
|
|
300
|
+
for (const question of questions) {
|
|
301
|
+
const lines = importSegmentLines(question, answers[question.id]);
|
|
302
|
+
if (lines.length > 0) blocks.push(lines.join("\n"));
|
|
303
|
+
}
|
|
304
|
+
return blocks.join("\n");
|
|
305
|
+
}
|
|
306
|
+
function blockTextOf(body, callId) {
|
|
307
|
+
const start = importBlockStart(callId);
|
|
308
|
+
return body === "" ? `${start}
|
|
309
|
+
${IMPORT_BLOCK_END}` : `${start}
|
|
310
|
+
${body}
|
|
311
|
+
${IMPORT_BLOCK_END}`;
|
|
312
|
+
}
|
|
313
|
+
function applyImport(draft, body, callId) {
|
|
314
|
+
const text = typeof draft === "string" ? draft : "";
|
|
315
|
+
const block = blockTextOf(body, callId);
|
|
316
|
+
const current = findImportBlock(text, callId);
|
|
317
|
+
if (current !== void 0) return text.slice(0, current.start) + block + text.slice(current.end);
|
|
318
|
+
return text === "" ? block : `${block}
|
|
319
|
+
|
|
320
|
+
${text}`;
|
|
321
|
+
}
|
|
322
|
+
function draftHasBody(draft, body, callId) {
|
|
323
|
+
return importBlockBody(draft, callId, "short") === body;
|
|
324
|
+
}
|
|
325
|
+
var QUESTION_LINE = /^(\d+)\.$/;
|
|
326
|
+
var ANSWER_ITEM_LINE = /^[ \t]*- /;
|
|
327
|
+
function splitImportedBody(questions, body) {
|
|
328
|
+
const lines = body.split("\n").map((line) => line.endsWith("\r") ? line.slice(0, -1) : line);
|
|
329
|
+
const found = /* @__PURE__ */ new Map();
|
|
330
|
+
let current;
|
|
331
|
+
const flush = () => {
|
|
332
|
+
if (current === void 0) return;
|
|
333
|
+
found.set(current.question.id, current);
|
|
334
|
+
};
|
|
335
|
+
let stray = false;
|
|
336
|
+
for (const line of lines) {
|
|
337
|
+
const header = QUESTION_LINE.exec(line.trim());
|
|
338
|
+
if (header !== null) {
|
|
339
|
+
flush();
|
|
340
|
+
const question = questions[
|
|
341
|
+
/** @type {number} */
|
|
342
|
+
Number(header[1]) - 1
|
|
343
|
+
];
|
|
344
|
+
current = question === void 0 ? void 0 : { question, selected: [], custom: "" };
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
if (line.trim() === "") continue;
|
|
348
|
+
const marker = ANSWER_ITEM_LINE.exec(line);
|
|
349
|
+
if (marker === null) {
|
|
350
|
+
stray = true;
|
|
351
|
+
continue;
|
|
352
|
+
}
|
|
353
|
+
if (current === void 0) continue;
|
|
354
|
+
const item = line.slice(marker[0].length);
|
|
355
|
+
const option = current.question.options.find((candidate) => candidate.label === item);
|
|
356
|
+
if (option === void 0) current.custom = current.custom === "" ? item : `${current.custom}
|
|
357
|
+
${item}`;
|
|
358
|
+
else current.selected.push(option.label);
|
|
359
|
+
}
|
|
360
|
+
flush();
|
|
361
|
+
if (stray) return [];
|
|
362
|
+
return [...found.values()].map((entry) => ({
|
|
363
|
+
question: entry.question,
|
|
364
|
+
selected: entry.selected,
|
|
365
|
+
custom: entry.custom.replace(/^\n/, "").trim()
|
|
366
|
+
}));
|
|
367
|
+
}
|
|
368
|
+
function asAnswerTable(questions, entries) {
|
|
369
|
+
const answers = blankAnswers(questions);
|
|
370
|
+
for (const entry of entries) {
|
|
371
|
+
answers[entry.question.id] = { selected: entry.selected, custom: entry.custom };
|
|
372
|
+
}
|
|
373
|
+
return answers;
|
|
374
|
+
}
|
|
375
|
+
function blankAnswers(questions) {
|
|
376
|
+
const answers = {};
|
|
377
|
+
for (const question of questions) answers[question.id] = { selected: [], custom: "" };
|
|
378
|
+
return answers;
|
|
379
|
+
}
|
|
380
|
+
function parseImportedAnswersResult(text, questions, callId, legacy = false) {
|
|
381
|
+
const body = importBlockBody(text, callId) ?? (legacy ? importBlockBody(text, callId, "legacy") : void 0);
|
|
382
|
+
if (body === void 0) return { kind: "none", answers: void 0 };
|
|
383
|
+
if (isBlank(body)) return { kind: "parsed", answers: blankAnswers(questions) };
|
|
384
|
+
const entries = splitImportedBody(questions, body);
|
|
385
|
+
return entries.length === 0 ? { kind: "malformed", answers: void 0 } : { kind: "parsed", answers: asAnswerTable(questions, entries) };
|
|
386
|
+
}
|
|
387
|
+
function frozenFormAnswers(questions, storedAnswers, text, callId) {
|
|
388
|
+
const parsed = parseImportedAnswersResult(text, questions, callId, true);
|
|
389
|
+
if (parsed.kind === "parsed") {
|
|
390
|
+
return { answers: applyRecommendedDefaults(questions, parsed.answers), fallback: false };
|
|
391
|
+
}
|
|
392
|
+
return { answers: applyRecommendedDefaults(questions, storedAnswers), fallback: true };
|
|
393
|
+
}
|
|
394
|
+
function initialFormGate() {
|
|
395
|
+
return { call: null, pending: null, seen: [] };
|
|
396
|
+
}
|
|
397
|
+
function foldFormGate(state, event) {
|
|
398
|
+
if (!isRecord(event) || typeof event.type !== "string") return state;
|
|
399
|
+
const data = isRecord(event.data) ? event.data : {};
|
|
400
|
+
if (event.type === "tool/call" || event.type === "tool/ptc-dispatch-start") {
|
|
401
|
+
if (data.name !== TOOL_NAME) return state;
|
|
402
|
+
const questions = readQuestions(data.arguments);
|
|
403
|
+
if (questions.length === 0) return state;
|
|
404
|
+
return {
|
|
405
|
+
...state,
|
|
406
|
+
call: {
|
|
407
|
+
callId: String((event.type === "tool/call" ? data.callId : data.subCallId) ?? ""),
|
|
408
|
+
questions: questions.map((question) => question.question),
|
|
409
|
+
seq: typeof event.seq === "number" ? event.seq : -1
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
if (event.type === "tool/result") {
|
|
414
|
+
const message = isRecord(data.message) ? data.message : void 0;
|
|
415
|
+
if (message === void 0) return state;
|
|
416
|
+
return settleFormGate(state, String(message.toolCallId), firstText(message.content));
|
|
417
|
+
}
|
|
418
|
+
if (event.type === "tool/ptc-dispatch") {
|
|
419
|
+
return settleFormGate(state, String(data.subCallId ?? ""), firstText(data.content));
|
|
420
|
+
}
|
|
421
|
+
if (event.type === "user/message") {
|
|
422
|
+
const pending = state.pending;
|
|
423
|
+
if (pending === null) return state;
|
|
424
|
+
const legacyUnique = state.seen.filter((id) => shortFormId(id) === shortFormId(pending.callId)).length === 1;
|
|
425
|
+
return importBlockBody(messageText(data), pending.callId) === void 0 && (!legacyUnique || importBlockBody(messageText(data), pending.callId, "legacy") === void 0) ? state : { ...state, pending: null };
|
|
426
|
+
}
|
|
427
|
+
return state;
|
|
428
|
+
}
|
|
429
|
+
function settleFormGate(state, callId, resultText) {
|
|
430
|
+
const call = state.call;
|
|
431
|
+
if (call === null || callId !== call.callId) return state;
|
|
432
|
+
const result = readResult(resultText);
|
|
433
|
+
return result !== void 0 && result.shown ? { ...state, call: null, pending: call, seen: [.../* @__PURE__ */ new Set([...state.seen, call.callId])] } : { ...state, call: null };
|
|
434
|
+
}
|
|
435
|
+
function messageText(node) {
|
|
436
|
+
const content = isRecord(node) && Array.isArray(node.content) ? node.content : [];
|
|
437
|
+
return content.filter((block) => isRecord(block) && block.type === "text" && typeof block.text === "string").map((block) => (
|
|
438
|
+
/** @type {string} */
|
|
439
|
+
isRecord(block) ? block.text : ""
|
|
440
|
+
)).join("\n");
|
|
441
|
+
}
|
|
442
|
+
function blockToolName(block) {
|
|
443
|
+
if (!isRecord(block)) return void 0;
|
|
444
|
+
const call = isRecord(block.call) ? block.call : void 0;
|
|
445
|
+
return typeof call?.name === "string" ? call.name : block.name;
|
|
446
|
+
}
|
|
447
|
+
function roundCall(chat, turn) {
|
|
448
|
+
if (!isRecord(chat)) return void 0;
|
|
449
|
+
const snapshot = (
|
|
450
|
+
/** @type {ChatSnapshotLike} */
|
|
451
|
+
chat
|
|
452
|
+
);
|
|
453
|
+
const keys = snapshot.locations?.getTurn?.(turn);
|
|
454
|
+
if (!Array.isArray(keys)) return void 0;
|
|
455
|
+
const getNode = snapshot.nodes?.get;
|
|
456
|
+
if (typeof getNode !== "function") return void 0;
|
|
457
|
+
let last;
|
|
458
|
+
let shown;
|
|
459
|
+
for (const key of keys) {
|
|
460
|
+
if (typeof key !== "string") continue;
|
|
461
|
+
const node = getNode.call(snapshot.nodes, key);
|
|
462
|
+
if (!isRecord(node) || node.kind !== "tool-call") continue;
|
|
463
|
+
const data = isRecord(node.data) ? node.data : void 0;
|
|
464
|
+
for (const block of callsIn(data?.root)) {
|
|
465
|
+
if (blockToolName(block) !== TOOL_NAME) continue;
|
|
466
|
+
const call = { block, toolName: TOOL_NAME, callId: block.callId };
|
|
467
|
+
last = call;
|
|
468
|
+
if (drawsForm(readCallModel(block))) shown = call;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
return shown ?? last;
|
|
472
|
+
}
|
|
473
|
+
function callsIn(block) {
|
|
474
|
+
if (!isRecord(block)) return [];
|
|
475
|
+
const found = blockToolName(block) === void 0 ? [] : [block];
|
|
476
|
+
const children = Array.isArray(block.subCalls) ? block.subCalls : [];
|
|
477
|
+
for (const child of children) found.push(...callsIn(child));
|
|
478
|
+
return found;
|
|
479
|
+
}
|
|
480
|
+
function carryOverAnswers(oldQuestions, newQuestions, oldAnswers) {
|
|
481
|
+
const carried = {};
|
|
482
|
+
for (const question of newQuestions) {
|
|
483
|
+
const source = oldQuestions.find((candidate) => candidate.question === question.question);
|
|
484
|
+
if (source === void 0) continue;
|
|
485
|
+
const answer = isRecord(oldAnswers) ? oldAnswers[source.id] : void 0;
|
|
486
|
+
if (!isRecord(answer)) continue;
|
|
487
|
+
const { selected, custom } = answerParts(answer);
|
|
488
|
+
carried[question.id] = {
|
|
489
|
+
selected: selected.filter((label) => question.options.some((option) => option.label === label)),
|
|
490
|
+
custom
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
return carried;
|
|
494
|
+
}
|
|
495
|
+
function carryImport(draft, fromCallId, body, callId) {
|
|
496
|
+
const text = typeof draft === "string" ? draft : "";
|
|
497
|
+
const from = findImportBlock(text, fromCallId);
|
|
498
|
+
if (from === void 0) return applyImport(text, body, callId);
|
|
499
|
+
const without = text.slice(0, from.start) + text.slice(from.end);
|
|
500
|
+
const current = findImportBlock(without, callId);
|
|
501
|
+
const block = blockTextOf(body, callId);
|
|
502
|
+
if (current !== void 0) return without.slice(0, current.start) + block + without.slice(current.end);
|
|
503
|
+
return without.slice(0, from.start) + block + without.slice(from.start);
|
|
504
|
+
}
|
|
505
|
+
var STORAGE_PREFIX = "dsh-matt-plus.";
|
|
506
|
+
var LEGACY_STORAGE_PREFIX = "dsh-grilling-form.";
|
|
507
|
+
function formStorageKey(sessionId) {
|
|
508
|
+
const scope = typeof sessionId === "string" && sessionId !== "" ? sessionId : "unknown-session";
|
|
509
|
+
return STORAGE_PREFIX + scope;
|
|
510
|
+
}
|
|
511
|
+
function readStorage(storage, key) {
|
|
512
|
+
if (!isRecord(storage) || typeof storage.getItem !== "function") return {};
|
|
513
|
+
try {
|
|
514
|
+
const parsed = parseJson(storage.getItem(key));
|
|
515
|
+
return isRecord(parsed) ? parsed : {};
|
|
516
|
+
} catch {
|
|
517
|
+
return {};
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
function readStoredForm(storage, key, callId) {
|
|
521
|
+
const own = sanitizeAnswers(readStorage(storage, key)[storageCallId(callId)]);
|
|
522
|
+
if (Object.keys(own).length > 0) return own;
|
|
523
|
+
if (!key.startsWith(STORAGE_PREFIX)) return own;
|
|
524
|
+
const legacy = LEGACY_STORAGE_PREFIX + key.slice(STORAGE_PREFIX.length);
|
|
525
|
+
return sanitizeAnswers(readStorage(storage, legacy)[storageCallId(callId)]);
|
|
526
|
+
}
|
|
527
|
+
function storageCallId(callId) {
|
|
528
|
+
return String(callId);
|
|
529
|
+
}
|
|
530
|
+
function writeStoredForm(storage, key, callId, answers) {
|
|
531
|
+
if (!isRecord(storage) || typeof storage.setItem !== "function") return;
|
|
532
|
+
const all = readStorage(storage, key);
|
|
533
|
+
try {
|
|
534
|
+
storage.setItem(key, JSON.stringify({ ...all, [storageCallId(callId)]: sanitizeAnswers(answers) }));
|
|
535
|
+
} catch {
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
// src/form-history.ts
|
|
540
|
+
var noLegacyReplies = /* @__PURE__ */ new Map();
|
|
541
|
+
var legacyRepliesByWindow = /* @__PURE__ */ new WeakMap();
|
|
542
|
+
function legacyRepliesFromWindow(window, open) {
|
|
543
|
+
if (!open || !isRecord(window) || window.hasMore !== false || !Array.isArray(window.entries)) return noLegacyReplies;
|
|
544
|
+
const cached = legacyRepliesByWindow.get(window);
|
|
545
|
+
if (cached !== void 0) return cached;
|
|
546
|
+
const replies = /* @__PURE__ */ new Map();
|
|
547
|
+
let gate = initialFormGate();
|
|
548
|
+
for (const entry of window.entries) {
|
|
549
|
+
if (!isRecord(entry) || entry.type !== "event" || !isRecord(entry.event)) continue;
|
|
550
|
+
const { type, seq, data } = entry.event;
|
|
551
|
+
if (typeof type !== "string") continue;
|
|
552
|
+
const pending = gate.pending;
|
|
553
|
+
const next = foldFormGate(gate, {
|
|
554
|
+
type,
|
|
555
|
+
seq: typeof seq === "number" ? seq : -1,
|
|
556
|
+
data: isRecord(data) ? data : {}
|
|
557
|
+
});
|
|
558
|
+
if (type === "user/message" && pending !== null && next.pending === null) {
|
|
559
|
+
const text = messageText(data);
|
|
560
|
+
if (importBlockBody(text, pending.callId) === void 0 && importBlockBody(text, pending.callId, "legacy") !== void 0 && !replies.has(pending.callId)) {
|
|
561
|
+
replies.set(pending.callId, text);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
gate = next;
|
|
565
|
+
}
|
|
566
|
+
legacyRepliesByWindow.set(window, replies);
|
|
567
|
+
return replies;
|
|
568
|
+
}
|
|
569
|
+
var repliesByNodes = /* @__PURE__ */ new WeakMap();
|
|
570
|
+
function hasSequence(node) {
|
|
571
|
+
return isRecord(node) && typeof node.seq === "number";
|
|
572
|
+
}
|
|
573
|
+
function indexCallPositions(node, rootSeq, positions) {
|
|
574
|
+
if (typeof node.callId === "string" && !positions.has(node.callId)) positions.set(node.callId, rootSeq);
|
|
575
|
+
if (!Array.isArray(node.subCalls)) return;
|
|
576
|
+
for (const child of node.subCalls) {
|
|
577
|
+
if (isRecord(child)) indexCallPositions(child, rootSeq, positions);
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
function replyIndex(nodes) {
|
|
581
|
+
const cached = repliesByNodes.get(nodes);
|
|
582
|
+
if (cached !== void 0) return cached;
|
|
583
|
+
const index = { positions: /* @__PURE__ */ new Map(), replies: /* @__PURE__ */ new Map() };
|
|
584
|
+
for (const node of nodes) {
|
|
585
|
+
if (!hasSequence(node)) continue;
|
|
586
|
+
indexCallPositions(node, node.seq, index.positions);
|
|
587
|
+
if (node.kind !== "user" && node.kind !== "steering") continue;
|
|
588
|
+
for (const { header } of importBlocks(messageText(node))) {
|
|
589
|
+
const matches = index.replies.get(header) ?? [];
|
|
590
|
+
matches.push(node);
|
|
591
|
+
index.replies.set(header, matches);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
repliesByNodes.set(nodes, index);
|
|
595
|
+
return index;
|
|
596
|
+
}
|
|
597
|
+
function formReplyAfter(nodes, callId) {
|
|
598
|
+
if (!Array.isArray(nodes) || typeof callId !== "string") return void 0;
|
|
599
|
+
const index = replyIndex(nodes);
|
|
600
|
+
const mineSeq = index.positions.get(callId);
|
|
601
|
+
if (mineSeq === void 0) return void 0;
|
|
602
|
+
let reply;
|
|
603
|
+
for (const header of [importBlockStart(callId), versionTwoHeader(callId)]) {
|
|
604
|
+
for (const node of index.replies.get(header) ?? []) {
|
|
605
|
+
if (node.seq > mineSeq && (reply === void 0 || node.seq < reply.seq)) reply = node;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return reply;
|
|
609
|
+
}
|
|
610
|
+
var formsByChat = /* @__PURE__ */ new WeakMap();
|
|
611
|
+
function hasTurnOrder(chat) {
|
|
612
|
+
return isRecord(chat) && isRecord(chat.timeline) && Array.isArray(chat.timeline.turnOrder);
|
|
613
|
+
}
|
|
614
|
+
function formsInHistory(chat, legacyReplies) {
|
|
615
|
+
const cached = formsByChat.get(chat);
|
|
616
|
+
if (cached?.legacyReplies === legacyReplies) return cached.forms;
|
|
617
|
+
const forms = /* @__PURE__ */ new Map();
|
|
618
|
+
const pending = [];
|
|
619
|
+
let latestUnanswered;
|
|
620
|
+
for (const turn of chat.timeline.turnOrder) {
|
|
621
|
+
if (typeof turn !== "number") continue;
|
|
622
|
+
const round = roundCall(chat, turn);
|
|
623
|
+
if (round === void 0) continue;
|
|
624
|
+
const model = readCallModel(round.block);
|
|
625
|
+
if (!drawsForm(model)) continue;
|
|
626
|
+
const reply = formReplyAfter(chat.legacy?.nodes, round.callId);
|
|
627
|
+
const replyText = reply === void 0 ? legacyReplies.get(String(round.callId)) : messageText(reply);
|
|
628
|
+
const replaces = replacesEarlier(argsRawOf(round.block));
|
|
629
|
+
const previous = replaces ? latestUnanswered : void 0;
|
|
630
|
+
if (replaces) {
|
|
631
|
+
for (const earlier of pending) earlier.superseded = true;
|
|
632
|
+
pending.length = 0;
|
|
633
|
+
}
|
|
634
|
+
const form = {
|
|
635
|
+
model,
|
|
636
|
+
callId: round.callId,
|
|
637
|
+
replyText,
|
|
638
|
+
superseded: false,
|
|
639
|
+
replaced: previous === void 0 ? void 0 : { callId: previous.callId, questions: previous.model.questions }
|
|
640
|
+
};
|
|
641
|
+
forms.set(turn, form);
|
|
642
|
+
latestUnanswered = replyText === void 0 ? form : void 0;
|
|
643
|
+
if (latestUnanswered !== void 0) pending.push(latestUnanswered);
|
|
644
|
+
}
|
|
645
|
+
formsByChat.set(chat, { legacyReplies, forms });
|
|
646
|
+
return forms;
|
|
647
|
+
}
|
|
648
|
+
function formAtTurn(chat, turn, legacyReplies = noLegacyReplies) {
|
|
649
|
+
if (!hasTurnOrder(chat) || typeof turn !== "number") return void 0;
|
|
650
|
+
return formsInHistory(chat, legacyReplies).get(turn);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// src/form-session.js
|
|
654
|
+
function asAnswerTable2(value) {
|
|
655
|
+
return value !== null && typeof value === "object" && !Array.isArray(value) ? (
|
|
656
|
+
/** @type {import('./form-model.js').AnswerTable} */
|
|
657
|
+
value
|
|
658
|
+
) : {};
|
|
659
|
+
}
|
|
660
|
+
function overwriteOne(existing, answers) {
|
|
661
|
+
const { selected } = answers;
|
|
662
|
+
const kept = selected.length <= 1 ? selected : [selected[selected.length - 1]];
|
|
663
|
+
return { selected: kept, custom: existing.custom };
|
|
664
|
+
}
|
|
665
|
+
function initialFormAnswers({ sessionId, callId, storage, carried }) {
|
|
666
|
+
const own = readStoredForm(storage, formStorageKey(sessionId), callId);
|
|
667
|
+
return carried === void 0 ? own : { ...carried, ...own };
|
|
668
|
+
}
|
|
669
|
+
function carriedAnswers({ sessionId, storage, replaced, questions }) {
|
|
670
|
+
if (replaced === void 0) return void 0;
|
|
671
|
+
const old = readStoredForm(storage, formStorageKey(sessionId), replaced.callId);
|
|
672
|
+
return carryOverAnswers(replaced.questions, questions, old);
|
|
673
|
+
}
|
|
674
|
+
function createFormSession({ questions, sessionId, callId, replacedCallId, replyText, superseded, storedAnswers, storage, draft }) {
|
|
675
|
+
const readOnly = replyText !== void 0 || superseded === true;
|
|
676
|
+
const stored = asAnswerTable2(storedAnswers);
|
|
677
|
+
const frozen = replyText === void 0 ? void 0 : frozenFormAnswers(questions, stored, replyText, callId);
|
|
678
|
+
const answers = frozen === void 0 ? applyRecommendedDefaults(questions, stored) : frozen.answers;
|
|
679
|
+
const body = importBody(questions, answers);
|
|
680
|
+
const storageKey = formStorageKey(sessionId);
|
|
681
|
+
const commit = (id, next) => {
|
|
682
|
+
if (readOnly) return stored;
|
|
683
|
+
const merged = { ...stored, [id]: next };
|
|
684
|
+
writeStoredForm(storage, storageKey, callId, merged);
|
|
685
|
+
return merged;
|
|
686
|
+
};
|
|
687
|
+
const shownAnswer = (id) => answers[id] ?? { selected: [], custom: "" };
|
|
688
|
+
const editAnswer = (id, change) => {
|
|
689
|
+
const question = questions.find((candidate) => candidate.id === id);
|
|
690
|
+
const current = shownAnswer(id);
|
|
691
|
+
const next = question?.type === "single" && change.selected !== void 0 ? overwriteOne(current, { selected: change.selected }) : { ...current, ...change };
|
|
692
|
+
return commit(id, next);
|
|
693
|
+
};
|
|
694
|
+
const toggle = (id, label) => {
|
|
695
|
+
const { selected } = shownAnswer(id);
|
|
696
|
+
return editAnswer(id, {
|
|
697
|
+
selected: selected.includes(label) ? selected.filter((item) => item !== label) : [...selected, label]
|
|
698
|
+
});
|
|
699
|
+
};
|
|
700
|
+
const setCustom = (id, custom) => commit(id, { ...shownAnswer(id), custom });
|
|
701
|
+
const importInto = (draftText) => readOnly ? typeof draftText === "string" ? draftText : "" : replacedCallId === void 0 ? applyImport(draftText, body, callId) : carryImport(draftText, replacedCallId, body, callId);
|
|
702
|
+
return {
|
|
703
|
+
readOnly,
|
|
704
|
+
superseded: superseded === true,
|
|
705
|
+
fallback: frozen === void 0 ? false : frozen.fallback,
|
|
706
|
+
answers,
|
|
707
|
+
draftState: draftStateOf({ readOnly, body, draft, callId }),
|
|
708
|
+
draftBody: body,
|
|
709
|
+
toggle,
|
|
710
|
+
setCustom,
|
|
711
|
+
importInto
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function draftStateOf({ readOnly, body, draft, callId }) {
|
|
715
|
+
if (readOnly) return "empty";
|
|
716
|
+
if (draftHasBody(draft, body, callId)) return "current";
|
|
717
|
+
return importBlockBody(draft, callId) === void 0 ? "none" : "stale";
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
// src/client/GrillingForm.jsx
|
|
721
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
722
|
+
var emptyEventSource = { subscribe: () => () => {
|
|
723
|
+
}, getSnapshot: () => void 0 };
|
|
724
|
+
function GrillingFormTail({ turn, sessionId, t, useInput, useConversation, inputActions, openFile, forkAt, eventSource, useSession }) {
|
|
725
|
+
const source = eventSource ?? emptyEventSource;
|
|
726
|
+
const eventWindow = (0, import_react.useSyncExternalStore)(
|
|
727
|
+
(listener) => source.subscribe(listener),
|
|
728
|
+
() => source.getSnapshot(),
|
|
729
|
+
() => source.getSnapshot()
|
|
730
|
+
);
|
|
731
|
+
const open = useSession?.((state) => state.openState === "open") ?? false;
|
|
732
|
+
const chat = (
|
|
733
|
+
/** @type {import('../form-model.js').ChatSnapshotLike|undefined} */
|
|
734
|
+
useConversation((snapshot) => snapshot.views.get("chat"))
|
|
735
|
+
);
|
|
736
|
+
const legacyReplies = legacyRepliesFromWindow(eventWindow, open);
|
|
737
|
+
const form = formAtTurn(chat, turn?.turn, legacyReplies);
|
|
738
|
+
if (form === void 0) return null;
|
|
739
|
+
const { model, callId, replyText, superseded } = form;
|
|
740
|
+
const replaced = replyText === void 0 && !superseded ? form.replaced : void 0;
|
|
741
|
+
const carried = carriedAnswers({ sessionId, storage: storageOf(), replaced, questions: model.questions });
|
|
742
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
743
|
+
GrillingForm,
|
|
744
|
+
{
|
|
745
|
+
model,
|
|
746
|
+
toolName: TOOL_NAME,
|
|
747
|
+
callId,
|
|
748
|
+
replacedCallId: replaced?.callId,
|
|
749
|
+
carried,
|
|
750
|
+
sessionId,
|
|
751
|
+
t,
|
|
752
|
+
useInput,
|
|
753
|
+
inputActions,
|
|
754
|
+
replyText,
|
|
755
|
+
superseded,
|
|
756
|
+
forkSeq: typeof turn?.end?.seq === "number" ? turn.end.seq : void 0,
|
|
757
|
+
openFile,
|
|
758
|
+
forkAt
|
|
759
|
+
}
|
|
760
|
+
);
|
|
761
|
+
}
|
|
762
|
+
function GrillingFormRow({ block, toolName, t, inspect }) {
|
|
763
|
+
const model = readCallModel(block);
|
|
764
|
+
const unrenderable = model.state === "unknown" || model.state === "form" && !drawsForm(model);
|
|
765
|
+
if (!drawsNote(model) && !unrenderable) return null;
|
|
766
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-root", "data-tool": toolName, "data-state": model.state, children: [
|
|
767
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-form", children: unrenderable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsg-failure", children: t("row.unrenderable") }) : model.state === "notShown" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsg-verdict", children: model.message ?? t("row.notShown") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsg-failure", children: model.failure ?? t("row.failed") }) }),
|
|
768
|
+
inspect === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { type: "button", className: "dsg-inspectButton", onClick: inspect, children: [
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconInspectOutlineRegular, {}),
|
|
770
|
+
t("row.inspect")
|
|
771
|
+
] })
|
|
772
|
+
] });
|
|
773
|
+
}
|
|
774
|
+
function useMarkdownLabels(t) {
|
|
775
|
+
return (0, import_react.useMemo)(() => ({
|
|
776
|
+
code: { copyLabel: t("row.copyCode"), copiedLabel: t("row.copiedCode") },
|
|
777
|
+
footnotes: t("row.footnotes")
|
|
778
|
+
}), [t]);
|
|
779
|
+
}
|
|
780
|
+
function GrillingForm({ model, toolName, callId, replacedCallId, carried, sessionId, t, useInput, inputActions, replyText, superseded, forkSeq, openFile, forkAt }) {
|
|
781
|
+
const draft = useInput((state) => state.draft);
|
|
782
|
+
const markdownLabels = useMarkdownLabels(t);
|
|
783
|
+
const [storedAnswers, setStoredAnswers] = (0, import_react.useState)(
|
|
784
|
+
() => initialFormAnswers({ sessionId, callId, storage: storageOf(), carried: void 0 })
|
|
785
|
+
);
|
|
786
|
+
const [forkFailed, setForkFailed] = (0, import_react.useState)(false);
|
|
787
|
+
const session = createFormSession({
|
|
788
|
+
questions: model.questions,
|
|
789
|
+
sessionId,
|
|
790
|
+
callId,
|
|
791
|
+
replacedCallId,
|
|
792
|
+
replyText,
|
|
793
|
+
superseded,
|
|
794
|
+
storedAnswers: carried === void 0 ? storedAnswers : { ...carried, ...storedAnswers },
|
|
795
|
+
storage: storageOf(),
|
|
796
|
+
draft
|
|
797
|
+
});
|
|
798
|
+
const { readOnly, answers, draftState } = session;
|
|
799
|
+
const onFork = typeof forkAt === "function" && forkSeq !== void 0 ? () => {
|
|
800
|
+
setForkFailed(false);
|
|
801
|
+
forkAt(forkSeq).catch(() => {
|
|
802
|
+
setForkFailed(true);
|
|
803
|
+
});
|
|
804
|
+
} : void 0;
|
|
805
|
+
const toggleOption = (question, label) => setStoredAnswers(session.toggle(question.id, label));
|
|
806
|
+
const writeCustom = (question, custom) => setStoredAnswers(session.setCustom(question.id, custom));
|
|
807
|
+
const onImport = () => inputActions.setDraft(session.importInto(draft));
|
|
808
|
+
if (superseded) {
|
|
809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-root", "data-tool": toolName, "data-state": model.state, "data-superseded": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-form", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsg-superseded", children: t("row.superseded") }) }) });
|
|
810
|
+
}
|
|
811
|
+
const footer = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-footer", children: [
|
|
812
|
+
onFork === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
813
|
+
import_dsh_client_ui_primitives.Button,
|
|
814
|
+
{
|
|
815
|
+
className: "dsg-fork",
|
|
816
|
+
variant: "outline",
|
|
817
|
+
size: "sm",
|
|
818
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconBranchOutlineRegular, {}),
|
|
819
|
+
onClick: onFork,
|
|
820
|
+
children: forkFailed ? t("row.forkFailed") : t("row.fork")
|
|
821
|
+
}
|
|
822
|
+
),
|
|
823
|
+
readOnly ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
824
|
+
import_dsh_client_ui_primitives.Button,
|
|
825
|
+
{
|
|
826
|
+
className: "dsg-import",
|
|
827
|
+
variant: "outline",
|
|
828
|
+
size: "sm",
|
|
829
|
+
icon: draftState === "current" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconDownloadOutlineRegular, {}),
|
|
830
|
+
onClick: onImport,
|
|
831
|
+
children: t(importLabelKey(draftState))
|
|
832
|
+
}
|
|
833
|
+
)
|
|
834
|
+
] });
|
|
835
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.MarkdownDelegateProvider, { openFile, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
836
|
+
"div",
|
|
837
|
+
{
|
|
838
|
+
className: "dsg-root",
|
|
839
|
+
"data-tool": toolName,
|
|
840
|
+
"data-state": model.state,
|
|
841
|
+
...readOnly ? { "data-readonly": "true" } : {},
|
|
842
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-form", children: [
|
|
843
|
+
readOnly ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "dsg-summary", children: [
|
|
844
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsg-summaryIcon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconQuestionOutlineRegular, {}) }),
|
|
845
|
+
t("row.frozenSummary", {
|
|
846
|
+
total: model.questions.length,
|
|
847
|
+
answered: questionsAnswered(model.questions, answers)
|
|
848
|
+
})
|
|
849
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "dsg-summary", children: t("row.progress", {
|
|
850
|
+
total: model.questions.length,
|
|
851
|
+
answered: questionsAnswered(model.questions, answers)
|
|
852
|
+
}) }),
|
|
853
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
854
|
+
QuestionList,
|
|
855
|
+
{
|
|
856
|
+
questions: model.questions,
|
|
857
|
+
answers,
|
|
858
|
+
locked: readOnly,
|
|
859
|
+
t,
|
|
860
|
+
markdownLabels,
|
|
861
|
+
onToggleOption: toggleOption,
|
|
862
|
+
onCustom: writeCustom
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
footer
|
|
866
|
+
] })
|
|
867
|
+
}
|
|
868
|
+
) });
|
|
869
|
+
}
|
|
870
|
+
function importLabelKey(draftState) {
|
|
871
|
+
if (draftState === "current") return "row.imported";
|
|
872
|
+
if (draftState === "stale") return "row.updateImport";
|
|
873
|
+
return "row.import";
|
|
874
|
+
}
|
|
875
|
+
function questionsAnswered(questions, answers) {
|
|
876
|
+
return questions.filter((question) => answerItems(answers[question.id]).length > 0).length;
|
|
877
|
+
}
|
|
878
|
+
function storageOf() {
|
|
879
|
+
try {
|
|
880
|
+
return globalThis.localStorage;
|
|
881
|
+
} catch {
|
|
882
|
+
return void 0;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function QuestionList({ questions, answers, locked, t, markdownLabels, onToggleOption, onCustom }) {
|
|
886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-list", children: questions.map((question) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-item", children: [
|
|
887
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-question", children: [
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "dsg-number", children: [
|
|
889
|
+
question.number,
|
|
890
|
+
"."
|
|
891
|
+
] }),
|
|
892
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsg-type", children: t(`type.${question.type}`) }),
|
|
893
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-questionText", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.MarkdownText, { text: question.question, labels: markdownLabels, variant: "compact" }) })
|
|
894
|
+
] }),
|
|
895
|
+
question.detail === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-questionDetail", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.MarkdownText, { text: question.detail, labels: markdownLabels, variant: "compact" }) }),
|
|
896
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
897
|
+
OptionList,
|
|
898
|
+
{
|
|
899
|
+
question,
|
|
900
|
+
answer: answers[question.id],
|
|
901
|
+
locked,
|
|
902
|
+
t,
|
|
903
|
+
markdownLabels,
|
|
904
|
+
onToggleOption,
|
|
905
|
+
onCustom
|
|
906
|
+
}
|
|
907
|
+
)
|
|
908
|
+
] }, question.id)) });
|
|
909
|
+
}
|
|
910
|
+
function OptionList({ question, answer, locked, t, markdownLabels, onToggleOption, onCustom }) {
|
|
911
|
+
const selected = answer?.selected ?? [];
|
|
912
|
+
const free = question.type === "free";
|
|
913
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-options", children: [
|
|
914
|
+
question.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
915
|
+
OptionRow,
|
|
916
|
+
{
|
|
917
|
+
question,
|
|
918
|
+
option,
|
|
919
|
+
checked: selected.includes(option.label),
|
|
920
|
+
locked,
|
|
921
|
+
t,
|
|
922
|
+
markdownLabels,
|
|
923
|
+
onToggleOption
|
|
924
|
+
},
|
|
925
|
+
option.label
|
|
926
|
+
)),
|
|
927
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
928
|
+
"textarea",
|
|
929
|
+
{
|
|
930
|
+
className: "dsg-custom",
|
|
931
|
+
rows: free ? 4 : 2,
|
|
932
|
+
readOnly: locked,
|
|
933
|
+
value: answer?.custom ?? "",
|
|
934
|
+
placeholder: free ? void 0 : t("row.customPlaceholder"),
|
|
935
|
+
onChange: locked ? () => {
|
|
936
|
+
} : (event) => onCustom(question, event.target.value)
|
|
937
|
+
}
|
|
938
|
+
)
|
|
939
|
+
] });
|
|
940
|
+
}
|
|
941
|
+
function OptionRow({ question, option, checked, locked, t, markdownLabels, onToggleOption }) {
|
|
942
|
+
const single = question.type === "single";
|
|
943
|
+
const select = (event) => {
|
|
944
|
+
if (!selectsOnClick(locked, event.target)) return;
|
|
945
|
+
onToggleOption(question, option.label);
|
|
946
|
+
};
|
|
947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
948
|
+
"div",
|
|
949
|
+
{
|
|
950
|
+
className: single ? "dsg-option dsg-optionSingle" : "dsg-option",
|
|
951
|
+
"data-checked": String(checked),
|
|
952
|
+
onClick: select,
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
955
|
+
"input",
|
|
956
|
+
{
|
|
957
|
+
className: "dsg-optionInput",
|
|
958
|
+
type: "checkbox",
|
|
959
|
+
checked,
|
|
960
|
+
disabled: locked,
|
|
961
|
+
onChange: locked ? () => {
|
|
962
|
+
} : () => onToggleOption(question, option.label)
|
|
963
|
+
}
|
|
964
|
+
),
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dsg-optionControl", children: checked && !single ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.IconCheckOutlineRegular, { size: 13 }) : null }),
|
|
966
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-optionBody", children: [
|
|
967
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dsg-optionLine", children: [
|
|
968
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-optionText", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.MarkdownText, { text: option.label, labels: markdownLabels, variant: "compact" }) }),
|
|
969
|
+
option.recommended ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "info", className: "dsg-badge", children: t("row.recommended") }) : null
|
|
970
|
+
] }),
|
|
971
|
+
option.description === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dsg-optionDescription", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.MarkdownText, { text: option.description, labels: markdownLabels, variant: "compact" }) })
|
|
972
|
+
] })
|
|
973
|
+
]
|
|
974
|
+
}
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// src/client/Settings.tsx
|
|
979
|
+
var import_react2 = require("react");
|
|
980
|
+
var import_dsh_client_ui_primitives2 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
981
|
+
|
|
982
|
+
// src/grilling-settings.ts
|
|
983
|
+
var GRILLING_FIELD = "grillingEnhanced";
|
|
984
|
+
function grillingEnabled(value) {
|
|
985
|
+
const enhanced = value[GRILLING_FIELD];
|
|
986
|
+
return typeof enhanced === "boolean" ? enhanced : value.formTool !== false && value.grillingSkill !== false;
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/client/Settings.tsx
|
|
990
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
991
|
+
function MattPlusCard({ t, form }) {
|
|
992
|
+
const [snapshot, setSnapshot] = (0, import_react2.useState)(() => form.getSnapshot());
|
|
993
|
+
const [failure, setFailure] = (0, import_react2.useState)(void 0);
|
|
994
|
+
const [writing, setWriting] = (0, import_react2.useState)(false);
|
|
995
|
+
(0, import_react2.useEffect)(() => {
|
|
996
|
+
const sync = () => {
|
|
997
|
+
setSnapshot(form.getSnapshot());
|
|
998
|
+
};
|
|
999
|
+
sync();
|
|
1000
|
+
return form.subscribe(sync);
|
|
1001
|
+
}, [form]);
|
|
1002
|
+
if (snapshot.status === "unavailable") {
|
|
1003
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsg-settings", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsg-settingsEmpty", children: t("card.unavailable") }) });
|
|
1004
|
+
}
|
|
1005
|
+
const value = snapshot.value ?? {};
|
|
1006
|
+
const readOnly = snapshot.status !== "ready" || snapshot.writable === false;
|
|
1007
|
+
const settle = (message) => {
|
|
1008
|
+
setWriting(false);
|
|
1009
|
+
setFailure(message);
|
|
1010
|
+
};
|
|
1011
|
+
const write = (next) => {
|
|
1012
|
+
setWriting(true);
|
|
1013
|
+
form.set(GRILLING_FIELD, next).then(
|
|
1014
|
+
(saved) => {
|
|
1015
|
+
settle(saved ? void 0 : t("card.writeFailed"));
|
|
1016
|
+
},
|
|
1017
|
+
() => {
|
|
1018
|
+
settle(t("card.writeFailed"));
|
|
1019
|
+
}
|
|
1020
|
+
);
|
|
1021
|
+
};
|
|
1022
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsg-settings", children: [
|
|
1023
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsg-settingsRows", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsg-settingsRow", children: [
|
|
1024
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "dsg-settingsInfo", children: [
|
|
1025
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsg-settingsTitle", children: t("card.grilling") }),
|
|
1026
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsg-settingsHint", children: t("card.grillingHint") })
|
|
1027
|
+
] }),
|
|
1028
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "dsg-settingsField", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
1029
|
+
import_dsh_client_ui_primitives2.Switch,
|
|
1030
|
+
{
|
|
1031
|
+
label: t("card.grilling"),
|
|
1032
|
+
checked: grillingEnabled(value),
|
|
1033
|
+
disabled: readOnly || writing,
|
|
1034
|
+
onChange: write
|
|
1035
|
+
}
|
|
1036
|
+
) })
|
|
1037
|
+
] }) }),
|
|
1038
|
+
failure === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsg-settingsError", children: failure }),
|
|
1039
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "dsg-settingsNote", children: t("card.note") })
|
|
1040
|
+
] });
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
// src/client/GrillingForm.css
|
|
1044
|
+
var GrillingForm_default = "\n.dsg-root {\n display: flex;\n flex-direction: column;\n gap: 6px;\n margin: 4px 0;\n}\n\n.dsg-form {\n display: flex;\n flex-direction: column;\n gap: 16px;\n}\n\n.dsg-summary,\n.dsg-superseded {\n font-size: var(--dsh-content-font-size-secondary, 13px);\n line-height: calc(20px + var(--dsh-content-font-delta-secondary, 0px));\n color: var(--dsw-alias-label-tertiary);\n}\n\n.dsg-summary {\n display: flex;\n align-items: center;\n gap: 6px;\n margin: 0;\n min-width: 0;\n}\n\n.dsg-summaryIcon {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n width: calc(16px + var(--dsh-content-font-delta, 0px));\n height: calc(16px + var(--dsh-content-font-delta, 0px));\n}\n\n.dsg-summaryIcon svg {\n width: calc(14px + var(--dsh-content-font-delta, 0px));\n height: calc(14px + var(--dsh-content-font-delta, 0px));\n}\n\n.dsg-superseded {\n margin: 0;\n}\n\n.dsg-list {\n display: grid;\n grid-template-columns: 20px auto minmax(0, 1fr);\n column-gap: 4px;\n row-gap: 16px;\n}\n\n.dsg-item {\n display: grid;\n grid-column: 1 / -1;\n grid-template-columns: subgrid;\n row-gap: 4px;\n min-width: 0;\n}\n\n.dsg-question,\n.dsg-questionDetail,\n.dsg-options {\n grid-column: 1 / -1;\n}\n\n.dsg-question {\n display: grid;\n grid-template-columns: subgrid;\n align-items: start;\n min-width: 0;\n font-size: var(--dsh-content-font-size, 14px);\n line-height: calc(24px + var(--dsh-content-font-delta, 0px));\n color: var(--dsw-alias-label-primary);\n}\n\n.dsg-questionText {\n min-width: 0;\n}\n\n.dsg-number,\n.dsg-type {\n color: var(--dsw-alias-label-caption);\n}\n\n.dsg-number {\n font-variant-numeric: tabular-nums;\n}\n\n.dsg-type {\n white-space: nowrap;\n}\n\n.dsg-questionDetail,\n.dsg-optionDescription {\n font-size: var(--dsh-content-font-size-secondary, 13px);\n line-height: calc(20px + var(--dsh-content-font-delta-secondary, 0px));\n color: var(--dsw-alias-label-tertiary);\n}\n\n.dsg-questionDetail {\n margin: 0;\n}\n\n.dsg-verdict {\n margin: 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: var(--dsh-content-font-size, 14px);\n line-height: calc(24px + var(--dsh-content-font-delta, 0px));\n color: var(--dsw-alias-label-primary);\n}\n\n.dsg-failure {\n margin: 0;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n font-size: var(--dsh-content-font-size, 14px);\n line-height: calc(24px + var(--dsh-content-font-delta, 0px));\n color: var(--dsw-alias-state-error-primary);\n}\n\n.dsg-options {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin-top: 4px;\n}\n\n.dsg-option {\n position: relative;\n display: flex;\n align-items: flex-start;\n gap: 10px;\n box-sizing: border-box;\n min-width: 0;\n padding: 8px 12px 8px 0;\n border-radius: var(--dsw-radius-sm);\n cursor: pointer;\n}\n\n.dsg-option:hover {\n background: var(--dsw-alias-interactive-bg-hover);\n}\n\n.dsg-optionInput {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: 0;\n padding: 0;\n border: 0;\n opacity: 0;\n pointer-events: none;\n}\n\n.dsg-optionControl {\n display: inline-flex;\n flex: none;\n align-items: center;\n justify-content: center;\n box-sizing: border-box;\n width: 16px;\n height: 16px;\n margin-top: 2px;\n border: 1px solid var(--dsw-alias-border-l4);\n border-radius: 4px;\n background-color: var(--dsw-alias-bg-base);\n color: var(--dsw-alias-label-primary-inverted);\n}\n\n.dsg-option:has(.dsg-optionInput:checked) .dsg-optionControl {\n border-color: var(--dsw-alias-brand-primary);\n}\n\n.dsg-option:has(.dsg-optionInput:checked):not(.dsg-optionSingle) .dsg-optionControl {\n background-color: var(--dsw-alias-brand-primary);\n color: var(--dsw-alias-label-primary-inverted);\n}\n\n.dsg-optionSingle .dsg-optionControl {\n border-radius: 50%;\n corner-shape: round;\n}\n\n.dsg-optionSingle:has(.dsg-optionInput:checked) .dsg-optionControl {\n border-color: var(--dsw-alias-brand-primary);\n background-image: radial-gradient(circle, var(--dsw-alias-brand-primary) 0 42%, transparent 47%);\n}\n\n.dsg-optionBody {\n display: flex;\n flex: 1;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dsg-optionLine {\n display: flex;\n align-items: baseline;\n gap: 8px;\n min-width: 0;\n}\n\n.dsg-optionText {\n min-width: 0;\n font-size: var(--dsh-content-font-size, 14px);\n line-height: calc(20px + var(--dsh-content-font-delta, 0px));\n color: var(--dsw-alias-label-primary);\n}\n\n.dsg-badge {\n flex: none;\n}\n\n.dsg-optionDescription {\n min-width: 0;\n}\n\n.dsg-questionText > div,\n.dsg-optionText > div {\n font-size: inherit;\n line-height: inherit;\n color: inherit;\n}\n\n.dsg-questionText > div > :first-child,\n.dsg-optionText > div > :first-child,\n.dsg-questionDetail > div > :first-child,\n.dsg-optionDescription > div > :first-child {\n margin-top: 0;\n}\n\n.dsg-questionText > div > :last-child,\n.dsg-optionText > div > :last-child,\n.dsg-questionDetail > div > :last-child,\n.dsg-optionDescription > div > :last-child {\n margin-bottom: 0;\n}\n\n.dsg-custom {\n box-sizing: border-box;\n width: 100%;\n min-height: 56px;\n margin-top: 2px;\n padding: 6px 8px;\n resize: vertical;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-primary);\n font: inherit;\n font-size: var(--dsh-content-font-size, 14px);\n line-height: calc(24px + var(--dsh-content-font-delta, 0px));\n}\n\n.dsg-custom:focus {\n border-color: var(--dsw-alias-state-business-primary);\n outline: none;\n}\n\n.dsg-custom::placeholder {\n color: var(--dsw-alias-label-dimmed);\n}\n\n.dsg-footer {\n display: flex;\n flex-direction: row;\n flex-wrap: wrap;\n align-items: center;\n justify-content: flex-end;\n gap: 8px;\n}\n\n.dsg-fork,\n.dsg-import {\n flex: none;\n}\n\n.dsg-root[data-readonly='true'] .dsg-optionText,\n.dsg-root[data-readonly='true'] .dsg-optionDescription,\n.dsg-root[data-readonly='true'] .dsg-badge,\n.dsg-root[data-readonly='true'] .dsg-custom {\n opacity: 0.5;\n}\n\n.dsg-root[data-readonly='true'] .dsg-option {\n cursor: default;\n}\n\n.dsg-root[data-readonly='true'] .dsg-option:hover {\n background: transparent;\n}\n\n.dsg-inspectButton {\n display: inline-flex;\n align-self: flex-start;\n align-items: center;\n gap: 4px;\n padding: 2px 8px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: 999px;\n corner-shape: round;\n background: var(--dsw-alias-bg-base);\n color: var(--dsw-alias-label-secondary);\n font-size: 11px;\n line-height: 16px;\n opacity: 0;\n cursor: pointer;\n transition: opacity 100ms ease;\n}\n\n.dsg-root:hover .dsg-inspectButton {\n opacity: 1;\n}\n\n.dsg-inspectButton:hover {\n background: var(--dsw-alias-interactive-bg-hover-solid);\n color: var(--dsw-alias-label-primary);\n}\n\n@media (prefers-reduced-motion: reduce) {\n .dsg-inspectButton {\n transition: none;\n }\n}\n";
|
|
1045
|
+
|
|
1046
|
+
// src/client/Settings.css
|
|
1047
|
+
var Settings_default = ".dsg-settings {\n display: flex;\n flex-direction: column;\n gap: 16px;\n padding: 16px 0;\n}\n\n.dsg-settingsRows {\n display: flex;\n flex-direction: column;\n}\n\n.dsg-settingsRow {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n padding: 8px 0;\n border-bottom: 0.5px solid var(--dsw-alias-border-l1);\n}\n\n.dsg-settingsRows > .dsg-settingsRow:last-child {\n border-bottom: 0;\n}\n\n.dsg-settingsInfo {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n\n.dsg-settingsTitle {\n font-size: 14px;\n line-height: 22px;\n color: var(--dsw-alias-label-primary);\n}\n\n.dsg-settingsHint {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n}\n\n.dsg-settingsField {\n flex: none;\n display: flex;\n align-items: center;\n gap: 8px;\n}\n\n.dsg-settingsError {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-state-error-primary);\n}\n\n.dsg-settingsNote {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary);\n padding-top: 8px;\n}\n\n.dsg-settingsEmpty {\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-tertiary);\n}\n";
|
|
1048
|
+
|
|
1049
|
+
// src/client/locales.js
|
|
1050
|
+
var NS = "mattPlus";
|
|
1051
|
+
var zh = {
|
|
1052
|
+
"row.frozenSummary": "\u672C\u8F6E\u5DF2\u8FC7 \xB7 {total} \u9898 \xB7 \u5DF2\u586B {answered}",
|
|
1053
|
+
"row.progress": "\u5DF2\u586B {answered} / {total} \u9898",
|
|
1054
|
+
"row.unrenderable": "\u8868\u5355\u65E0\u6CD5\u663E\u793A\uFF0C\u8BF7\u67E5\u770B\u5DE5\u5177\u8C03\u7528\u8BE6\u60C5",
|
|
1055
|
+
"row.superseded": "\u63D0\u95EE\u8868\u5355\u5DF2\u88AB\u540E\u9762\u90A3\u5F20\u53D6\u4EE3",
|
|
1056
|
+
"row.notShown": "\u8FD9\u4E00\u8F6E\u6CA1\u6709\u6295\u51FA\u8868\u5355",
|
|
1057
|
+
"row.failed": "\u8C03\u7528\u5931\u8D25",
|
|
1058
|
+
"row.recommended": "\u63A8\u8350",
|
|
1059
|
+
"type.single": "\u5355\u9009",
|
|
1060
|
+
"type.multi": "\u591A\u9009",
|
|
1061
|
+
"type.free": "\u81EA\u7531",
|
|
1062
|
+
"row.customPlaceholder": "\u9009\u9879\u4E0D\u591F\u7528\u7684\u8BDD\uFF0C\u5728\u8FD9\u91CC\u81EA\u5DF1\u5199\u4E00\u6BB5",
|
|
1063
|
+
"row.import": "\u5BFC\u5165\u8F93\u5165\u6846",
|
|
1064
|
+
"row.imported": "\u5DF2\u5BFC\u5165",
|
|
1065
|
+
"row.updateImport": "\u66F4\u65B0\u8F93\u5165\u6846",
|
|
1066
|
+
"row.fork": "\u4ECE\u8FD9\u91CC\u5206\u53C9",
|
|
1067
|
+
"row.forkFailed": "\u5206\u53C9\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5",
|
|
1068
|
+
"row.inspect": "\u67E5\u770B",
|
|
1069
|
+
"row.copyCode": "\u590D\u5236",
|
|
1070
|
+
"row.copiedCode": "\u5DF2\u590D\u5236",
|
|
1071
|
+
"row.footnotes": "\u811A\u6CE8",
|
|
1072
|
+
"card.grilling": "grilling\u589E\u5F3A",
|
|
1073
|
+
"card.grillingHint": "\u5173\u95ED\u540E\u505C\u7528\u63D0\u95EE\u8868\u5355\u5DE5\u5177\uFF0Cgrilling \u6280\u80FD\u56DE\u843D\u5230\u5DE5\u4F5C\u533A\u6216 preset \u7248\u672C\u3002\u5DF2\u6295\u51FA\u7684\u8868\u5355\u4ECD\u53EF\u4F5C\u7B54\u3002",
|
|
1074
|
+
"card.unavailable": "\u5F53\u524D profile \u4E0D\u63D0\u4F9B\u8FD9\u7EC4\u914D\u7F6E\u3002",
|
|
1075
|
+
"card.writeFailed": "\u6CA1\u6709\u5199\u5165\u8FD9\u4EFD\u914D\u7F6E\uFF0C\u5B83\u53EF\u80FD\u88AB\u66F4\u9AD8\u4E00\u5C42\u8986\u76D6\u4E86\u3002",
|
|
1076
|
+
"card.note": "\u62E8\u52A8\u7ACB\u5373\u751F\u6548\uFF0C\u4E0D\u9700\u8981\u91CD\u542F\u3002"
|
|
1077
|
+
};
|
|
1078
|
+
var en = {
|
|
1079
|
+
"row.frozenSummary": "Round over \xB7 {total} question(s) \xB7 {answered} answered",
|
|
1080
|
+
"row.progress": "{answered} / {total} answered",
|
|
1081
|
+
"row.unrenderable": "The form cannot be displayed; inspect the tool call",
|
|
1082
|
+
"row.superseded": "The question form was replaced by a later one",
|
|
1083
|
+
"row.notShown": "This round was not shown",
|
|
1084
|
+
"row.failed": "Tool call failed",
|
|
1085
|
+
"row.recommended": "Recommended",
|
|
1086
|
+
"type.single": "Single choice",
|
|
1087
|
+
"type.multi": "Multiple choice",
|
|
1088
|
+
"type.free": "Freeform",
|
|
1089
|
+
"row.customPlaceholder": "Write your own answer here if the options do not cover it",
|
|
1090
|
+
"row.import": "Import to composer",
|
|
1091
|
+
"row.imported": "Imported",
|
|
1092
|
+
"row.updateImport": "Update composer",
|
|
1093
|
+
"row.fork": "Branch from here",
|
|
1094
|
+
"row.forkFailed": "Branch failed; try again",
|
|
1095
|
+
"row.inspect": "Inspect",
|
|
1096
|
+
"row.copyCode": "Copy",
|
|
1097
|
+
"row.copiedCode": "Copied",
|
|
1098
|
+
"row.footnotes": "Footnotes",
|
|
1099
|
+
"card.grilling": "Grilling enhancements",
|
|
1100
|
+
"card.grillingHint": "Turn off to disable the question form tool and use the workspace or preset grilling skill. Existing forms remain answerable.",
|
|
1101
|
+
"card.unavailable": "This profile does not serve this configuration.",
|
|
1102
|
+
"card.writeFailed": "The change was not saved; a higher configuration layer may override it.",
|
|
1103
|
+
"card.note": "Changes take effect immediately; no restart."
|
|
1104
|
+
};
|
|
1105
|
+
|
|
1106
|
+
// src/client/index.ts
|
|
1107
|
+
var PACKAGE_ID = "@lynn123411/dsh-matt-plus";
|
|
1108
|
+
var SETTINGS_NAMESPACE = "dsh-matt-plus";
|
|
1109
|
+
var BUNDLE_CONFIG_SLOT = "plugins.bundle.config";
|
|
1110
|
+
var SHEETS = [
|
|
1111
|
+
["GrillingForm.css", GrillingForm_default],
|
|
1112
|
+
["Settings.css", Settings_default]
|
|
1113
|
+
];
|
|
1114
|
+
var inject = ["locale", "slots", "sessions", "uiWorkspace", "configForms"];
|
|
1115
|
+
function injectStyles() {
|
|
1116
|
+
if (typeof document === "undefined") return () => {
|
|
1117
|
+
};
|
|
1118
|
+
const tags = SHEETS.map(([file, css]) => {
|
|
1119
|
+
const tag = document.createElement("style");
|
|
1120
|
+
tag.dataset.plugin = PACKAGE_ID;
|
|
1121
|
+
tag.dataset.pluginCss = `${PACKAGE_ID}/${file}`;
|
|
1122
|
+
tag.textContent = css;
|
|
1123
|
+
document.head.appendChild(tag);
|
|
1124
|
+
return tag;
|
|
1125
|
+
});
|
|
1126
|
+
return () => {
|
|
1127
|
+
for (const tag of tags) tag.remove();
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
function apply(ctx) {
|
|
1131
|
+
const services = ctx;
|
|
1132
|
+
ctx.effect(injectStyles, "dsh-matt-plus: styles");
|
|
1133
|
+
ctx.effect(() => services.locale.register(NS, { zh, en }), "dsh-matt-plus: dictionaries");
|
|
1134
|
+
ctx.effect(() => services.configForms.whileServed([SETTINGS_NAMESPACE], () => services.slots.inject(
|
|
1135
|
+
BUNDLE_CONFIG_SLOT,
|
|
1136
|
+
() => services.slots.register({
|
|
1137
|
+
name: BUNDLE_CONFIG_SLOT,
|
|
1138
|
+
key: PACKAGE_ID,
|
|
1139
|
+
locale: NS,
|
|
1140
|
+
inject: () => ({ form: services.configForms.get(SETTINGS_NAMESPACE) })
|
|
1141
|
+
}, MattPlusCard)
|
|
1142
|
+
)), "dsh-matt-plus: plugins page config");
|
|
1143
|
+
services.slots.inject("conversation.chat.turnTail", () => services.slots.register({
|
|
1144
|
+
name: "conversation.chat.turnTail",
|
|
1145
|
+
id: PACKAGE_ID,
|
|
1146
|
+
locale: NS,
|
|
1147
|
+
inject: (sessionId) => ({
|
|
1148
|
+
eventSource: services.sessions.binding?.(sessionId)?.eventSource,
|
|
1149
|
+
forkAt: (seq) => services.sessions.fork({ sessionId, atSeq: seq, increaseTitle: true }).then((childId) => {
|
|
1150
|
+
services.uiWorkspace.openSession(childId);
|
|
1151
|
+
})
|
|
1152
|
+
})
|
|
1153
|
+
}, GrillingFormTail));
|
|
1154
|
+
services.slots.inject("tool.call.toolview", () => services.slots.register({
|
|
1155
|
+
name: "tool.call.toolview",
|
|
1156
|
+
key: TOOL_NAME,
|
|
1157
|
+
locale: NS
|
|
1158
|
+
}, GrillingFormRow));
|
|
1159
|
+
}
|
|
1160
|
+
return module.exports; } });
|
|
1161
|
+
//# sourceMappingURL=client.js.map
|