mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 00:33:20 +08:00
feat: split group and direct context enhancement
This commit is contained in:
parent
38096d1589
commit
75ebaebf2e
21 changed files with 1423 additions and 873 deletions
543
lib/client.js
543
lib/client.js
|
|
@ -1050,31 +1050,44 @@ var EN = Object.freeze({
|
|||
"\u7FA4\u804A\u548C\u79C1\u804A": "Groups and direct",
|
||||
"\u5173\u95ED\u5F39\u7A97": "Close dialog",
|
||||
"\u67E5\u770B\u4E0A\u4E0B\u6587\u589E\u5F3A\u8BF4\u660E": "View context enhancement details",
|
||||
"\u4E0A\u4E0B\u6587\u589E\u5F3A\u8303\u56F4": "Context enhancement scope",
|
||||
"\u542F\u7528\u8303\u56F4": "Enable in",
|
||||
"\u7FA4\u804A\u4E2D\u542F\u7528": "Enable in group chats",
|
||||
"\u79C1\u804A\u4E2D\u542F\u7528": "Enable in direct chats",
|
||||
"\u542F\u7528": "Enabled",
|
||||
"\uFF08\u5F53\u524D\u6E20\u9053\u4E0D\u652F\u6301\u7FA4\u804A\uFF09": "(This channel does not support group chats)",
|
||||
"\u6765\u6E90\u5B57\u6BB5": "Source fields",
|
||||
"\u67E5\u770B\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E": "View source field details",
|
||||
"\u67E5\u770B\u7FA4\u804A\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E": "View group source field details",
|
||||
"\u67E5\u770B\u79C1\u804A\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E": "View direct source field details",
|
||||
"\u6E20\u9053": "Channel",
|
||||
"\u4F1A\u8BDD\u7C7B\u578B": "Conversation type",
|
||||
"\u53D1\u9001\u8005\u6807\u8BC6": "Sender ID",
|
||||
"\u53D1\u9001\u8005\u6635\u79F0": "Sender name",
|
||||
"\u67E5\u770B\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E": "View sender name field details",
|
||||
"\u67E5\u770B\u7FA4\u804A\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E": "View group sender name field details",
|
||||
"\u67E5\u770B\u79C1\u804A\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E": "View direct sender name field details",
|
||||
"\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6BCF\u4E2A\u6E20\u9053\u90FD\u80FD\u63D0\u4F9B\u3002\u5F53\u524D\u6D88\u606F\u6CA1\u6709\u53D1\u9001\u8005\u6635\u79F0\u65F6\uFF0C\u5373\u4F7F\u5DF2\u9009\u62E9\u8BE5\u5B57\u6BB5\uFF0C<dsh_im_source> \u4E2D\u4E5F\u4F1A\u7701\u7565 senderName\u3002": "This field is not available on every channel. If the current message has no sender name, <dsh_im_source> omits senderName even when the field is selected.",
|
||||
"\u673A\u5668\u4EBA\u6807\u8BC6": "Bot ID",
|
||||
"\u589E\u5F3A\u63D0\u793A\u8BCD": "Guidance",
|
||||
"\u67E5\u770B\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E": "View guidance instructions",
|
||||
"\u67E5\u770B\u7FA4\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E": "View group guidance instructions",
|
||||
"\u67E5\u770B\u79C1\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E": "View direct guidance instructions",
|
||||
"\u4F7F\u7528\u8BF4\u660E": "How to use",
|
||||
"\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528 <dsh_im_source> \u4E2D\u5DF2\u9009\u62E9\u7684\u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002": "Tell the model how to use the selected fields in <dsh_im_source>. Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags.",
|
||||
"\u751F\u6548\u89C4\u5219": "Behavior",
|
||||
"\u9690\u79C1\u63D0\u793A": "Privacy",
|
||||
"\u4F7F\u7528\u793A\u4F8B": "Example",
|
||||
"\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002\nconversationType\u662F\u7FA4\u804A\u65F6\u56DE\u590D\u4E25\u8083\u4E00\u70B9\uFF0CconversationType\u662F\u79C1\u804A\u65F6\u56DE\u590D\u4E00\u5B9A\u8981\u5E7D\u9ED8\u641E\u7B11\uFF0C\u50CF\u5468\u661F\u9A70\u7684\u7535\u5F71\u4E00\u6837\u641E\u7B11": "Understand the source only from fields actually present in <dsh_im_source> for the current message; do not guess or fill in missing fields.\nWhen conversationType is group, reply more seriously. When conversationType is direct, make the reply humorous and funny.",
|
||||
"\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002\n\u5F53\u524D\u6D88\u606F\u6765\u81EA\u7FA4\u804A\uFF0C\u8BF7\u4F7F\u7528\u4E25\u8083\u3001\u514B\u5236\u3001\u7B80\u6D01\u7684\u8868\u8FBE\u65B9\u5F0F\u3002": "Understand the source only from fields actually present in <dsh_im_source> for the current message; do not guess or fill in missing fields.\nThis message is from a group chat. Use a serious, restrained, and concise style.",
|
||||
"\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002\n\u5F53\u524D\u6D88\u606F\u6765\u81EA\u79C1\u804A\uFF0C\u53EF\u4EE5\u4F7F\u7528\u66F4\u8F7B\u677E\u3001\u5E7D\u9ED8\u3001\u8BE6\u7EC6\u7684\u8868\u8FBE\u65B9\u5F0F\u3002": "Understand the source only from fields actually present in <dsh_im_source> for the current message; do not guess or fill in missing fields.\nThis message is from a direct chat. You may use a lighter, more humorous, and detailed style.",
|
||||
"\u586B\u5165\u793A\u4F8B": "Use example",
|
||||
"\u6E05\u7A7A": "Clear",
|
||||
"\u9009\u62E9\u5728\u54EA\u4E9B\u4F1A\u8BDD\u4E2D\u542F\u7528\u3001\u63D0\u4F9B\u54EA\u4E9B\u6765\u6E90\u5B57\u6BB5\uFF0C\u4EE5\u53CA\u5982\u4F55\u4F7F\u7528\u8FD9\u4E9B\u4FE1\u606F\u3002\u4EC5\u4F7F\u7528\u5DF2\u6709\u6D88\u606F\u5143\u6570\u636E\uFF0C\u4E0D\u67E5\u8BE2\u5E73\u53F0 API\u3002": "Choose which conversations to enhance, which source fields to include, and how to use them. Only existing message metadata is used; no platform APIs are queried.",
|
||||
"\u589E\u5F3A\u63D0\u793A\u8BCD\u4E2D\u8BF7\u4F7F\u7528\u5B57\u6BB5\u540D\uFF08\u5982 senderId\u3001conversationType\uFF09\u5F15\u7528\u8FD9\u4E9B\u4FE1\u606F\u3002\u53EA\u53D1\u9001\u52FE\u9009\u4E14\u5F53\u524D\u6D88\u606F\u4E2D\u53EF\u7528\u7684\u5B57\u6BB5\uFF0C\u4E0D\u4F1A\u989D\u5916\u67E5\u8BE2\u6216\u8865\u5168\u3002": "Reference these values by field name (such as senderId or conversationType) in the guidance. Only selected fields available in the current message are sent; no extra lookups are made.",
|
||||
"\u589E\u5F3A\u63D0\u793A\u8BCD\u4E2D\u8BF7\u4F7F\u7528\u5B57\u6BB5\u540D\uFF08\u5982 senderId\u3001conversationType\uFF09\u5F15\u7528\u8FD9\u4E9B\u4FE1\u606F\u3002\u53EA\u53D1\u9001\u5F53\u524D\u4F1A\u8BDD\u4E2D\u52FE\u9009\u4E14\u53EF\u7528\u7684\u5B57\u6BB5\uFF0C\u4E0D\u4F1A\u989D\u5916\u67E5\u8BE2\u6216\u8865\u5168\u3002": "Reference these values by field name (such as senderId or conversationType) in the guidance. Only fields selected and available in the current conversation are sent; no extra lookups are made.",
|
||||
"\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528\u5F53\u524D\u7FA4\u804A\u6D88\u606F\u7684 <dsh_im_source> \u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002": "Tell the model how to use <dsh_im_source> fields for the current group message. Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags.",
|
||||
"\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528\u5F53\u524D\u79C1\u804A\u6D88\u606F\u7684 <dsh_im_source> \u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002": "Tell the model how to use <dsh_im_source> fields for the current direct message. Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags.",
|
||||
"\u4EC5\u5728\u7FA4\u804A\u5F00\u5173\u5F00\u542F\u65F6\u4F7F\u7528\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\u4E0D\u518D\u9644\u52A0\u7FA4\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\uFF1B\u6240\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F53\u524D\u573A\u666F\u8BBE\u7F6E\u53D1\u9001\u3002": "Used only when group enhancement is enabled. Clear and save to omit group guidance; selected source fields still follow the group settings.",
|
||||
"\u4EC5\u5728\u79C1\u804A\u5F00\u5173\u5F00\u542F\u65F6\u4F7F\u7528\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\u4E0D\u518D\u9644\u52A0\u79C1\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\uFF1B\u6240\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F53\u524D\u573A\u666F\u8BBE\u7F6E\u53D1\u9001\u3002": "Used only when direct enhancement is enabled. Clear and save to omit direct guidance; selected source fields still follow the direct settings.",
|
||||
"\u53EA\u9700\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\uFF0C\u4E0D\u518D\u9644\u52A0\u589E\u5F3A\u63D0\u793A\u8BCD\uFF0C\u5DF2\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F00\u5173\u8BBE\u7F6E\u53D1\u9001\u3002": "Enter only the body; the plugin adds paired <dsh_im_source_guidance> tags. Clear and save to omit guidance. Selected source fields still follow the conversation switches.",
|
||||
"\u53D1\u9001\u8005\u6807\u8BC6\u53EF\u80FD\u5305\u542B\u5E73\u53F0\u7528\u6237 ID \u6216\u7535\u8BDD\u53F7\u7801\u5F62\u5F0F\u7684\u6807\u8BC6\u3002\u5173\u95ED\u5F00\u5173\u4E0D\u4F1A\u5220\u9664\u5DF2\u7ECF\u5199\u5165\u4F1A\u8BDD\u5386\u53F2\u7684\u4FE1\u606F\u3002": "Sender IDs may contain platform user IDs or phone-number-like identifiers. Turning this off does not remove information already saved in conversation history.",
|
||||
"\u4E0A\u4E0B\u6587\u589E\u5F3A\u4FDD\u5B58\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002": "Could not save context enhancement. Try again.",
|
||||
|
|
@ -1881,26 +1894,39 @@ var CONTEXT_ENHANCEMENT_FIELDS = Object.freeze([
|
|||
"botId"
|
||||
]);
|
||||
var CONTEXT_ENHANCEMENT_GUIDANCE_MAX_LENGTH = 8e3;
|
||||
var CONTEXT_GUIDANCE_EXAMPLE = `\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002
|
||||
conversationType\u662F\u7FA4\u804A\u65F6\u56DE\u590D\u4E25\u8083\u4E00\u70B9\uFF0CconversationType\u662F\u79C1\u804A\u65F6\u56DE\u590D\u4E00\u5B9A\u8981\u5E7D\u9ED8\u641E\u7B11\uFF0C\u50CF\u5468\u661F\u9A70\u7684\u7535\u5F71\u4E00\u6837\u641E\u7B11`;
|
||||
var CONTEXT_GROUP_GUIDANCE_EXAMPLE = `\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002
|
||||
\u5F53\u524D\u6D88\u606F\u6765\u81EA\u7FA4\u804A\uFF0C\u8BF7\u4F7F\u7528\u4E25\u8083\u3001\u514B\u5236\u3001\u7B80\u6D01\u7684\u8868\u8FBE\u65B9\u5F0F\u3002`;
|
||||
var CONTEXT_DIRECT_GUIDANCE_EXAMPLE = `\u4EC5\u4F9D\u636E\u5F53\u524D\u6D88\u606F\u7684 <dsh_im_source> \u4E2D\u5B9E\u9645\u63D0\u4F9B\u7684\u5B57\u6BB5\u7406\u89E3\u6765\u6E90\uFF1B\u6CA1\u6709\u63D0\u4F9B\u7684\u5B57\u6BB5\u4E0D\u8981\u731C\u6D4B\u6216\u8865\u5168\u3002
|
||||
\u5F53\u524D\u6D88\u606F\u6765\u81EA\u79C1\u804A\uFF0C\u53EF\u4EE5\u4F7F\u7528\u66F4\u8F7B\u677E\u3001\u5E7D\u9ED8\u3001\u8BE6\u7EC6\u7684\u8868\u8FBE\u65B9\u5F0F\u3002`;
|
||||
var DEFAULT_CONTEXT_ENHANCEMENT_CONFIG = Object.freeze({
|
||||
groupEnabled: false,
|
||||
directEnabled: false,
|
||||
fields: Object.freeze(["senderId"]),
|
||||
guidance: ""
|
||||
group: Object.freeze({
|
||||
enabled: false,
|
||||
fields: Object.freeze(["senderId"]),
|
||||
guidance: ""
|
||||
}),
|
||||
direct: Object.freeze({
|
||||
enabled: false,
|
||||
fields: Object.freeze(["senderId"]),
|
||||
guidance: ""
|
||||
})
|
||||
});
|
||||
var CONFIG_KEYS = ["groupEnabled", "directEnabled", "fields", "guidance"];
|
||||
var CONFIG_KEYS = ["group", "direct"];
|
||||
var SCOPE_KEYS = ["enabled", "fields", "guidance"];
|
||||
var LEGACY_CONFIG_KEYS = ["groupEnabled", "directEnabled", "fields", "guidance"];
|
||||
function invalidConfig(message) {
|
||||
const error = new TypeError(message);
|
||||
error.code = "context-enhancement-invalid";
|
||||
return error;
|
||||
}
|
||||
function validateContextEnhancementConfig(input) {
|
||||
if (!input || typeof input !== "object" || Array.isArray(input) || ![Object.prototype, null].includes(Object.getPrototypeOf(input)) || Reflect.ownKeys(input).length !== CONFIG_KEYS.length || !CONFIG_KEYS.every((key) => Object.hasOwn(input, key))) {
|
||||
function hasExactKeys(input, keys) {
|
||||
return input && typeof input === "object" && !Array.isArray(input) && [Object.prototype, null].includes(Object.getPrototypeOf(input)) && Reflect.ownKeys(input).length === keys.length && keys.every((key) => Object.hasOwn(input, key));
|
||||
}
|
||||
function validateContextEnhancementScope(input) {
|
||||
if (!hasExactKeys(input, SCOPE_KEYS)) {
|
||||
throw invalidConfig("\u8BF7\u63D0\u4EA4\u5B8C\u6574\u7684\u4E0A\u4E0B\u6587\u589E\u5F3A\u8BBE\u7F6E\u3002");
|
||||
}
|
||||
const { groupEnabled, directEnabled, fields, guidance } = input;
|
||||
if (typeof groupEnabled !== "boolean" || typeof directEnabled !== "boolean") {
|
||||
const { enabled, fields, guidance } = input;
|
||||
if (typeof enabled !== "boolean") {
|
||||
throw invalidConfig("\u7FA4\u804A\u548C\u79C1\u804A\u5F00\u5173\u5FC5\u987B\u662F\u5E03\u5C14\u503C\u3002");
|
||||
}
|
||||
if (!Array.isArray(fields) || ![...fields].every((field) => CONTEXT_ENHANCEMENT_FIELDS.includes(field))) {
|
||||
|
|
@ -1910,17 +1936,46 @@ function validateContextEnhancementConfig(input) {
|
|||
throw invalidConfig(`\u589E\u5F3A\u63D0\u793A\u8BCD\u4E0D\u5F97\u8D85\u8FC7 ${CONTEXT_ENHANCEMENT_GUIDANCE_MAX_LENGTH} \u4E2A\u5B57\u7B26\u3002`);
|
||||
}
|
||||
return Object.freeze({
|
||||
groupEnabled,
|
||||
directEnabled,
|
||||
enabled,
|
||||
fields: Object.freeze(CONTEXT_ENHANCEMENT_FIELDS.filter((field) => fields.includes(field))),
|
||||
guidance: guidance.trim() ? guidance : ""
|
||||
});
|
||||
}
|
||||
function validateContextEnhancementConfig(input) {
|
||||
if (!hasExactKeys(input, CONFIG_KEYS)) {
|
||||
throw invalidConfig("\u8BF7\u63D0\u4EA4\u5B8C\u6574\u7684\u4E0A\u4E0B\u6587\u589E\u5F3A\u8BBE\u7F6E\u3002");
|
||||
}
|
||||
return Object.freeze({
|
||||
group: validateContextEnhancementScope(input.group),
|
||||
direct: validateContextEnhancementScope(input.direct)
|
||||
});
|
||||
}
|
||||
function migrateLegacyContextEnhancementConfig(input) {
|
||||
if (!hasExactKeys(input, LEGACY_CONFIG_KEYS)) {
|
||||
throw invalidConfig("\u8BF7\u63D0\u4EA4\u5B8C\u6574\u7684\u4E0A\u4E0B\u6587\u589E\u5F3A\u8BBE\u7F6E\u3002");
|
||||
}
|
||||
return validateContextEnhancementConfig({
|
||||
group: {
|
||||
enabled: input.groupEnabled,
|
||||
fields: input.fields,
|
||||
guidance: input.guidance
|
||||
},
|
||||
direct: {
|
||||
enabled: input.directEnabled,
|
||||
fields: input.fields,
|
||||
guidance: input.guidance
|
||||
}
|
||||
});
|
||||
}
|
||||
function normalizeContextEnhancementConfig(input) {
|
||||
try {
|
||||
return validateContextEnhancementConfig(input);
|
||||
} catch {
|
||||
return DEFAULT_CONTEXT_ENHANCEMENT_CONFIG;
|
||||
try {
|
||||
return migrateLegacyContextEnhancementConfig(input);
|
||||
} catch {
|
||||
return DEFAULT_CONTEXT_ENHANCEMENT_CONFIG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2656,11 +2711,33 @@ var FIELD_LABELS = Object.freeze({
|
|||
senderName: "\u53D1\u9001\u8005\u6635\u79F0",
|
||||
botId: "\u673A\u5668\u4EBA\u6807\u8BC6"
|
||||
});
|
||||
var SCOPE_COPY = Object.freeze({
|
||||
group: Object.freeze({
|
||||
title: "\u7FA4\u804A",
|
||||
enable: "\u542F\u7528",
|
||||
fieldsHelpLabel: "\u67E5\u770B\u7FA4\u804A\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E",
|
||||
senderNameHelpLabel: "\u67E5\u770B\u7FA4\u804A\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E",
|
||||
guidanceLabel: "\u589E\u5F3A\u63D0\u793A\u8BCD",
|
||||
guidanceHelpLabel: "\u67E5\u770B\u7FA4\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E",
|
||||
guidanceUsage: "\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528\u5F53\u524D\u7FA4\u804A\u6D88\u606F\u7684 <dsh_im_source> \u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002",
|
||||
guidanceBehavior: "\u4EC5\u5728\u7FA4\u804A\u5F00\u5173\u5F00\u542F\u65F6\u4F7F\u7528\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\u4E0D\u518D\u9644\u52A0\u7FA4\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\uFF1B\u6240\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F53\u524D\u573A\u666F\u8BBE\u7F6E\u53D1\u9001\u3002"
|
||||
}),
|
||||
direct: Object.freeze({
|
||||
title: "\u79C1\u804A",
|
||||
enable: "\u542F\u7528",
|
||||
fieldsHelpLabel: "\u67E5\u770B\u79C1\u804A\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E",
|
||||
senderNameHelpLabel: "\u67E5\u770B\u79C1\u804A\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E",
|
||||
guidanceLabel: "\u589E\u5F3A\u63D0\u793A\u8BCD",
|
||||
guidanceHelpLabel: "\u67E5\u770B\u79C1\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E",
|
||||
guidanceUsage: "\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528\u5F53\u524D\u79C1\u804A\u6D88\u606F\u7684 <dsh_im_source> \u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002",
|
||||
guidanceBehavior: "\u4EC5\u5728\u79C1\u804A\u5F00\u5173\u5F00\u542F\u65F6\u4F7F\u7528\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\u4E0D\u518D\u9644\u52A0\u79C1\u804A\u589E\u5F3A\u63D0\u793A\u8BCD\uFF1B\u6240\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F53\u524D\u573A\u666F\u8BBE\u7F6E\u53D1\u9001\u3002"
|
||||
})
|
||||
});
|
||||
function contextEnhancementLabel(config) {
|
||||
const { groupEnabled, directEnabled } = normalizeContextEnhancementConfig(config);
|
||||
if (groupEnabled && directEnabled) return "\u7FA4\u804A\u548C\u79C1\u804A";
|
||||
if (groupEnabled) return "\u4EC5\u7FA4\u804A";
|
||||
if (directEnabled) return "\u4EC5\u79C1\u804A";
|
||||
const { group, direct } = normalizeContextEnhancementConfig(config);
|
||||
if (group.enabled && direct.enabled) return "\u7FA4\u804A\u548C\u79C1\u804A";
|
||||
if (group.enabled) return "\u4EC5\u7FA4\u804A";
|
||||
if (direct.enabled) return "\u4EC5\u79C1\u804A";
|
||||
return "\u672A\u5F00\u542F";
|
||||
}
|
||||
function ContextIcon({ kind = "sliders" }) {
|
||||
|
|
@ -2678,26 +2755,197 @@ function ContextIcon({ kind = "sliders" }) {
|
|||
focusable: "false"
|
||||
}, h2("path", { d: path }));
|
||||
}
|
||||
function ContextEnhancementScopeEditor({
|
||||
kind,
|
||||
scope,
|
||||
example,
|
||||
supported,
|
||||
busy,
|
||||
idPrefix,
|
||||
onChange
|
||||
}) {
|
||||
const copy = SCOPE_COPY[kind];
|
||||
const unavailableId = `${idPrefix}-${kind}-unavailable`;
|
||||
const fieldsHelpId = `${idPrefix}-${kind}-fields-help`;
|
||||
const senderNameHelpId = `${idPrefix}-${kind}-sender-name-help`;
|
||||
const guidanceId = `${idPrefix}-${kind}-guidance`;
|
||||
const guidanceHelpId = `${idPrefix}-${kind}-guidance-help`;
|
||||
const disabled = busy || !supported;
|
||||
return h2(
|
||||
"fieldset",
|
||||
{
|
||||
className: "dim-contextSection dim-contextScope",
|
||||
"data-context-kind": kind,
|
||||
"aria-label": copy.title,
|
||||
disabled
|
||||
},
|
||||
h2(
|
||||
"label",
|
||||
{ className: "dim-contextSwitchRow" },
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextSwitchLabel" },
|
||||
h2("span", null, copy.enable),
|
||||
!supported ? h2("span", {
|
||||
id: unavailableId,
|
||||
className: "dim-contextUnavailable"
|
||||
}, "\uFF08\u5F53\u524D\u6E20\u9053\u4E0D\u652F\u6301\u7FA4\u804A\uFF09") : null
|
||||
),
|
||||
h2("input", {
|
||||
type: "checkbox",
|
||||
role: "switch",
|
||||
className: "dim-contextSwitch",
|
||||
checked: supported && scope.enabled,
|
||||
disabled,
|
||||
"aria-describedby": !supported ? unavailableId : void 0,
|
||||
onChange: (event) => {
|
||||
if (supported) onChange("enabled", event.target.checked);
|
||||
}
|
||||
})
|
||||
),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextScopeBlock" },
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextLegend" },
|
||||
h2("span", null, "\u6765\u6E90\u5B57\u6BB5"),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp dim-contextLegendHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton",
|
||||
disabled,
|
||||
"aria-label": copy.fieldsHelpLabel,
|
||||
"aria-describedby": fieldsHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2(
|
||||
"span",
|
||||
{ id: fieldsHelpId, className: "dim-contextTooltip dim-contextLegendTooltip", role: "tooltip" },
|
||||
"\u589E\u5F3A\u63D0\u793A\u8BCD\u4E2D\u8BF7\u4F7F\u7528\u5B57\u6BB5\u540D\uFF08\u5982 senderId\u3001conversationType\uFF09\u5F15\u7528\u8FD9\u4E9B\u4FE1\u606F\u3002\u53EA\u53D1\u9001\u5F53\u524D\u4F1A\u8BDD\u4E2D\u52FE\u9009\u4E14\u53EF\u7528\u7684\u5B57\u6BB5\uFF0C\u4E0D\u4F1A\u989D\u5916\u67E5\u8BE2\u6216\u8865\u5168\u3002"
|
||||
)
|
||||
)
|
||||
),
|
||||
h2("div", { className: "dim-contextFields" }, CONTEXT_ENHANCEMENT_FIELDS.map((field) => {
|
||||
const fieldId = `${idPrefix}-${kind}-field-${field}`;
|
||||
return h2(
|
||||
"div",
|
||||
{ key: field, className: "dim-contextField" },
|
||||
h2("input", {
|
||||
id: fieldId,
|
||||
type: "checkbox",
|
||||
name: `${kind}-${field}`,
|
||||
checked: scope.fields.includes(field),
|
||||
disabled,
|
||||
onChange: (event) => onChange("fields", event.target.checked ? [...scope.fields, field] : scope.fields.filter((value) => value !== field))
|
||||
}),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextFieldText" },
|
||||
h2("label", { className: "dim-contextFieldName", htmlFor: fieldId }, FIELD_LABELS[field]),
|
||||
field === "senderName" ? h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp dim-contextFieldHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton dim-contextFieldHelpButton",
|
||||
disabled,
|
||||
"aria-label": copy.senderNameHelpLabel,
|
||||
"aria-describedby": senderNameHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2("span", {
|
||||
id: senderNameHelpId,
|
||||
className: "dim-contextTooltip dim-contextFieldTooltip",
|
||||
role: "tooltip"
|
||||
}, "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6BCF\u4E2A\u6E20\u9053\u90FD\u80FD\u63D0\u4F9B\u3002\u5F53\u524D\u6D88\u606F\u6CA1\u6709\u53D1\u9001\u8005\u6635\u79F0\u65F6\uFF0C\u5373\u4F7F\u5DF2\u9009\u62E9\u8BE5\u5B57\u6BB5\uFF0C<dsh_im_source> \u4E2D\u4E5F\u4F1A\u7701\u7565 senderName\u3002")
|
||||
) : null,
|
||||
h2("label", { className: "dim-contextFieldKey", htmlFor: fieldId }, field)
|
||||
)
|
||||
);
|
||||
}))
|
||||
),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextGuidance dim-contextScopeBlock" },
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextEditorHeader" },
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextEditorTitle" },
|
||||
h2("label", { htmlFor: guidanceId }, copy.guidanceLabel),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton",
|
||||
disabled,
|
||||
"aria-label": copy.guidanceHelpLabel,
|
||||
"aria-describedby": guidanceHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2(
|
||||
"span",
|
||||
{ id: guidanceHelpId, className: "dim-contextTooltip dim-contextGuidanceTooltip", role: "tooltip" },
|
||||
h2("strong", null, "\u4F7F\u7528\u8BF4\u660E"),
|
||||
h2("span", null, copy.guidanceUsage),
|
||||
h2("strong", null, "\u751F\u6548\u89C4\u5219"),
|
||||
h2("span", null, copy.guidanceBehavior),
|
||||
h2("strong", null, "\u9690\u79C1\u63D0\u793A"),
|
||||
h2("span", null, "\u53D1\u9001\u8005\u6807\u8BC6\u53EF\u80FD\u5305\u542B\u5E73\u53F0\u7528\u6237 ID \u6216\u7535\u8BDD\u53F7\u7801\u5F62\u5F0F\u7684\u6807\u8BC6\u3002\u5173\u95ED\u5F00\u5173\u4E0D\u4F1A\u5220\u9664\u5DF2\u7ECF\u5199\u5165\u4F1A\u8BDD\u5386\u53F2\u7684\u4FE1\u606F\u3002"),
|
||||
h2("strong", null, "\u4F7F\u7528\u793A\u4F8B"),
|
||||
h2("span", { className: "dim-contextTooltipExample" }, example)
|
||||
)
|
||||
)
|
||||
),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextTextActions" },
|
||||
h2("button", { type: "button", disabled, onClick: () => onChange("guidance", example) }, "\u586B\u5165\u793A\u4F8B"),
|
||||
h2("button", { type: "button", disabled, onClick: () => onChange("guidance", "") }, "\u6E05\u7A7A")
|
||||
)
|
||||
),
|
||||
h2("textarea", {
|
||||
id: guidanceId,
|
||||
value: scope.guidance,
|
||||
placeholder: example,
|
||||
rows: 4,
|
||||
disabled,
|
||||
"data-context-kind": kind,
|
||||
maxLength: CONTEXT_ENHANCEMENT_GUIDANCE_MAX_LENGTH,
|
||||
"aria-describedby": guidanceHelpId,
|
||||
onChange: (event) => onChange("guidance", event.target.value)
|
||||
})
|
||||
)
|
||||
);
|
||||
}
|
||||
function ContextEnhancementDialog({ config, groupSupported, disabled, onSave, onClose, returnFocusRef, id: id5 }) {
|
||||
const [draft, setDraft] = React7.useState(() => ({
|
||||
...normalizeContextEnhancementConfig(config),
|
||||
...!groupSupported ? { groupEnabled: false } : {}
|
||||
}));
|
||||
const [draft, setDraft] = React7.useState(() => {
|
||||
const normalized = normalizeContextEnhancementConfig(config);
|
||||
return {
|
||||
...normalized,
|
||||
...!groupSupported ? {
|
||||
group: { ...normalized.group, enabled: false }
|
||||
} : {}
|
||||
};
|
||||
});
|
||||
const [saving, setSaving] = React7.useState(false);
|
||||
const [error, setError] = React7.useState(null);
|
||||
const [activeScope, setActiveScope] = React7.useState("direct");
|
||||
const savingRef = React7.useRef(false);
|
||||
const dialogRef = React7.useRef(null);
|
||||
const mountedRef = React7.useRef(true);
|
||||
const groupTabRef = React7.useRef(null);
|
||||
const directTabRef = React7.useRef(null);
|
||||
const titleId = React7.useId();
|
||||
const descriptionId = React7.useId();
|
||||
const groupNoticeId = React7.useId();
|
||||
const guidanceId = React7.useId();
|
||||
const guidanceHelpId = React7.useId();
|
||||
const fieldIdPrefix = React7.useId();
|
||||
const fieldsHelpId = React7.useId();
|
||||
const senderNameHelpId = React7.useId();
|
||||
const guidanceExample = localizeText(CONTEXT_GUIDANCE_EXAMPLE);
|
||||
const scopeIdPrefix = React7.useId();
|
||||
const groupGuidanceExample = localizeText(CONTEXT_GROUP_GUIDANCE_EXAMPLE);
|
||||
const directGuidanceExample = localizeText(CONTEXT_DIRECT_GUIDANCE_EXAMPLE);
|
||||
const busy = disabled || saving;
|
||||
const scopeKinds = ["direct", "group"];
|
||||
const tabRefs = { group: groupTabRef, direct: directTabRef };
|
||||
React7.useEffect(() => {
|
||||
mountedRef.current = true;
|
||||
dialogRef.current?.focus?.();
|
||||
|
|
@ -2711,14 +2959,34 @@ function ContextEnhancementDialog({ config, groupSupported, disabled, onSave, on
|
|||
queueMicrotask(() => returnFocusRef.current?.focus?.());
|
||||
};
|
||||
}, [returnFocusRef]);
|
||||
const change = (key, value) => {
|
||||
const changeScope = (kind, key, value) => {
|
||||
if (busy || savingRef.current) return;
|
||||
setDraft((current) => ({ ...current, [key]: value }));
|
||||
setDraft((current) => ({
|
||||
...current,
|
||||
[kind]: { ...current[kind], [key]: value }
|
||||
}));
|
||||
setError(null);
|
||||
};
|
||||
const cancel = () => {
|
||||
if (!savingRef.current) onClose();
|
||||
};
|
||||
const activateScope = (kind, focus = false) => {
|
||||
if (busy || !scopeKinds.includes(kind)) return;
|
||||
setActiveScope(kind);
|
||||
if (focus) tabRefs[kind].current?.focus?.();
|
||||
};
|
||||
const handleTabKeyDown = (event, kind) => {
|
||||
let next;
|
||||
if (event.key === "Home") next = scopeKinds[0];
|
||||
else if (event.key === "End") next = scopeKinds.at(-1);
|
||||
else if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
|
||||
const offset = event.key === "ArrowRight" ? 1 : -1;
|
||||
next = scopeKinds[(scopeKinds.indexOf(kind) + offset + scopeKinds.length) % scopeKinds.length];
|
||||
}
|
||||
if (!next) return;
|
||||
event.preventDefault();
|
||||
activateScope(next, true);
|
||||
};
|
||||
const save = async () => {
|
||||
if (busy || savingRef.current) return;
|
||||
savingRef.current = true;
|
||||
|
|
@ -2812,166 +3080,45 @@ function ContextEnhancementDialog({ config, groupSupported, disabled, onSave, on
|
|||
onClick: cancel
|
||||
}, h2(ContextIcon, { kind: "close" }))
|
||||
),
|
||||
h2(
|
||||
"fieldset",
|
||||
{ className: "dim-contextSection", disabled: busy },
|
||||
h2("legend", null, "\u542F\u7528\u8303\u56F4"),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextSwitches" },
|
||||
h2(
|
||||
"label",
|
||||
{ className: "dim-contextSwitchRow" },
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextSwitchLabel" },
|
||||
h2("span", null, "\u7FA4\u804A\u4E2D\u542F\u7528"),
|
||||
!groupSupported ? h2("span", {
|
||||
id: groupNoticeId,
|
||||
className: "dim-contextUnavailable"
|
||||
}, "\uFF08\u5F53\u524D\u6E20\u9053\u4E0D\u652F\u6301\u7FA4\u804A\uFF09") : null
|
||||
),
|
||||
h2("input", {
|
||||
type: "checkbox",
|
||||
role: "switch",
|
||||
className: "dim-contextSwitch",
|
||||
checked: groupSupported && draft.groupEnabled,
|
||||
disabled: busy || !groupSupported,
|
||||
"aria-describedby": !groupSupported ? groupNoticeId : void 0,
|
||||
onChange: (event) => {
|
||||
if (groupSupported) change("groupEnabled", event.target.checked);
|
||||
}
|
||||
})
|
||||
),
|
||||
h2(
|
||||
"label",
|
||||
{ className: "dim-contextSwitchRow" },
|
||||
h2("span", null, "\u79C1\u804A\u4E2D\u542F\u7528"),
|
||||
h2("input", {
|
||||
type: "checkbox",
|
||||
role: "switch",
|
||||
className: "dim-contextSwitch",
|
||||
checked: draft.directEnabled,
|
||||
disabled: busy,
|
||||
onChange: (event) => change("directEnabled", event.target.checked)
|
||||
})
|
||||
)
|
||||
)
|
||||
),
|
||||
h2(
|
||||
"fieldset",
|
||||
{ className: "dim-contextSection", disabled: busy },
|
||||
h2(
|
||||
"legend",
|
||||
{ className: "dim-contextLegend" },
|
||||
h2("span", null, "\u6765\u6E90\u5B57\u6BB5"),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp dim-contextLegendHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton",
|
||||
disabled: busy,
|
||||
"aria-label": "\u67E5\u770B\u6765\u6E90\u5B57\u6BB5\u8BF4\u660E",
|
||||
"aria-describedby": fieldsHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2(
|
||||
"span",
|
||||
{ id: fieldsHelpId, className: "dim-contextTooltip dim-contextLegendTooltip", role: "tooltip" },
|
||||
"\u589E\u5F3A\u63D0\u793A\u8BCD\u4E2D\u8BF7\u4F7F\u7528\u5B57\u6BB5\u540D\uFF08\u5982 senderId\u3001conversationType\uFF09\u5F15\u7528\u8FD9\u4E9B\u4FE1\u606F\u3002\u53EA\u53D1\u9001\u52FE\u9009\u4E14\u5F53\u524D\u6D88\u606F\u4E2D\u53EF\u7528\u7684\u5B57\u6BB5\uFF0C\u4E0D\u4F1A\u989D\u5916\u67E5\u8BE2\u6216\u8865\u5168\u3002"
|
||||
)
|
||||
)
|
||||
),
|
||||
h2("div", { className: "dim-contextFields" }, CONTEXT_ENHANCEMENT_FIELDS.map((field) => {
|
||||
const fieldId = `${fieldIdPrefix}-${field}`;
|
||||
return h2(
|
||||
"div",
|
||||
{ key: field, className: "dim-contextField" },
|
||||
h2("input", {
|
||||
id: fieldId,
|
||||
type: "checkbox",
|
||||
name: field,
|
||||
checked: draft.fields.includes(field),
|
||||
disabled: busy,
|
||||
onChange: (event) => change("fields", event.target.checked ? [...draft.fields, field] : draft.fields.filter((value) => value !== field))
|
||||
}),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextFieldText" },
|
||||
h2("label", { className: "dim-contextFieldName", htmlFor: fieldId }, FIELD_LABELS[field]),
|
||||
field === "senderName" ? h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp dim-contextFieldHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton dim-contextFieldHelpButton",
|
||||
disabled: busy,
|
||||
"aria-label": "\u67E5\u770B\u53D1\u9001\u8005\u6635\u79F0\u5B57\u6BB5\u8BF4\u660E",
|
||||
"aria-describedby": senderNameHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2("span", {
|
||||
id: senderNameHelpId,
|
||||
className: "dim-contextTooltip dim-contextFieldTooltip",
|
||||
role: "tooltip"
|
||||
}, "\u8BE5\u5B57\u6BB5\u4E0D\u662F\u6BCF\u4E2A\u6E20\u9053\u90FD\u80FD\u63D0\u4F9B\u3002\u5F53\u524D\u6D88\u606F\u6CA1\u6709\u53D1\u9001\u8005\u6635\u79F0\u65F6\uFF0C\u5373\u4F7F\u5DF2\u9009\u62E9\u8BE5\u5B57\u6BB5\uFF0C<dsh_im_source> \u4E2D\u4E5F\u4F1A\u7701\u7565 senderName\u3002")
|
||||
) : null,
|
||||
h2("label", { className: "dim-contextFieldKey", htmlFor: fieldId }, field)
|
||||
)
|
||||
);
|
||||
}))
|
||||
),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextGuidance" },
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextEditorHeader" },
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextEditorTitle" },
|
||||
h2("label", { htmlFor: guidanceId }, "\u589E\u5F3A\u63D0\u793A\u8BCD"),
|
||||
h2(
|
||||
"span",
|
||||
{ className: "dim-contextHelp" },
|
||||
h2("button", {
|
||||
type: "button",
|
||||
className: "dim-contextHelpButton",
|
||||
disabled: busy,
|
||||
"aria-label": "\u67E5\u770B\u589E\u5F3A\u63D0\u793A\u8BCD\u4F7F\u7528\u8BF4\u660E",
|
||||
"aria-describedby": guidanceHelpId
|
||||
}, h2("span", { "aria-hidden": "true" }, "?")),
|
||||
h2(
|
||||
"span",
|
||||
{ id: guidanceHelpId, className: "dim-contextTooltip dim-contextGuidanceTooltip", role: "tooltip" },
|
||||
h2("strong", null, "\u4F7F\u7528\u8BF4\u660E"),
|
||||
h2("span", null, "\u7528\u4E8E\u544A\u8BC9\u6A21\u578B\u5982\u4F55\u4F7F\u7528 <dsh_im_source> \u4E2D\u5DF2\u9009\u62E9\u7684\u6765\u6E90\u5B57\u6BB5\u3002\u53EA\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u4F1A\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002"),
|
||||
h2("strong", null, "\u751F\u6548\u89C4\u5219"),
|
||||
h2("span", null, "\u53EA\u9700\u586B\u5199\u6B63\u6587\uFF0C\u63D2\u4EF6\u81EA\u52A8\u6DFB\u52A0 <dsh_im_source_guidance> \u6210\u5BF9\u6807\u7B7E\u3002\u6E05\u7A7A\u5E76\u4FDD\u5B58\u540E\uFF0C\u4E0D\u518D\u9644\u52A0\u589E\u5F3A\u63D0\u793A\u8BCD\uFF0C\u5DF2\u9009\u6765\u6E90\u5B57\u6BB5\u4ECD\u6309\u5F00\u5173\u8BBE\u7F6E\u53D1\u9001\u3002"),
|
||||
h2("strong", null, "\u9690\u79C1\u63D0\u793A"),
|
||||
h2("span", null, "\u53D1\u9001\u8005\u6807\u8BC6\u53EF\u80FD\u5305\u542B\u5E73\u53F0\u7528\u6237 ID \u6216\u7535\u8BDD\u53F7\u7801\u5F62\u5F0F\u7684\u6807\u8BC6\u3002\u5173\u95ED\u5F00\u5173\u4E0D\u4F1A\u5220\u9664\u5DF2\u7ECF\u5199\u5165\u4F1A\u8BDD\u5386\u53F2\u7684\u4FE1\u606F\u3002"),
|
||||
h2("strong", null, "\u4F7F\u7528\u793A\u4F8B"),
|
||||
h2("span", { className: "dim-contextTooltipExample" }, guidanceExample)
|
||||
)
|
||||
)
|
||||
),
|
||||
h2(
|
||||
"div",
|
||||
{ className: "dim-contextTextActions" },
|
||||
h2("button", { type: "button", disabled: busy, onClick: () => change("guidance", guidanceExample) }, "\u586B\u5165\u793A\u4F8B"),
|
||||
h2("button", { type: "button", disabled: busy, onClick: () => change("guidance", "") }, "\u6E05\u7A7A")
|
||||
)
|
||||
),
|
||||
h2("textarea", {
|
||||
id: guidanceId,
|
||||
value: draft.guidance,
|
||||
placeholder: guidanceExample,
|
||||
rows: 4,
|
||||
disabled: busy,
|
||||
maxLength: CONTEXT_ENHANCEMENT_GUIDANCE_MAX_LENGTH,
|
||||
"aria-describedby": guidanceHelpId,
|
||||
onChange: (event) => change("guidance", event.target.value)
|
||||
{ className: "dim-contextTabs", role: "tablist", "aria-label": "\u4E0A\u4E0B\u6587\u589E\u5F3A\u8303\u56F4" },
|
||||
scopeKinds.map((kind) => {
|
||||
const selected = activeScope === kind;
|
||||
return h2("button", {
|
||||
key: kind,
|
||||
id: `${scopeIdPrefix}-${kind}-tab`,
|
||||
ref: tabRefs[kind],
|
||||
type: "button",
|
||||
role: "tab",
|
||||
className: "dim-contextTab",
|
||||
"data-context-kind": kind,
|
||||
"aria-selected": selected,
|
||||
"aria-controls": `${scopeIdPrefix}-${kind}-panel`,
|
||||
tabIndex: selected ? 0 : -1,
|
||||
disabled: busy,
|
||||
onClick: () => activateScope(kind),
|
||||
onKeyDown: (event) => handleTabKeyDown(event, kind)
|
||||
}, SCOPE_COPY[kind].title);
|
||||
})
|
||||
),
|
||||
scopeKinds.map((kind) => h2("div", {
|
||||
key: kind,
|
||||
id: `${scopeIdPrefix}-${kind}-panel`,
|
||||
className: "dim-contextTabPanel",
|
||||
role: "tabpanel",
|
||||
"data-context-kind": kind,
|
||||
"aria-labelledby": `${scopeIdPrefix}-${kind}-tab`,
|
||||
hidden: activeScope !== kind
|
||||
}, h2(ContextEnhancementScopeEditor, {
|
||||
kind,
|
||||
scope: draft[kind],
|
||||
example: kind === "group" ? groupGuidanceExample : directGuidanceExample,
|
||||
supported: kind === "group" ? groupSupported : true,
|
||||
busy,
|
||||
idPrefix: scopeIdPrefix,
|
||||
onChange: (key, value) => changeScope(kind, key, value)
|
||||
}))),
|
||||
error ? h2("p", { className: "dim-contextError", role: "alert" }, error) : null,
|
||||
h2(
|
||||
"footer",
|
||||
|
|
@ -2995,7 +3142,10 @@ function ContextEnhancementEditor({ config, groupSupported = true, disabled = fa
|
|||
const dialogId = React7.useId();
|
||||
const statusId = React7.useId();
|
||||
const saved = normalizeContextEnhancementConfig(config);
|
||||
const label = contextEnhancementLabel(groupSupported ? saved : { ...saved, groupEnabled: false });
|
||||
const label = contextEnhancementLabel(groupSupported ? saved : {
|
||||
...saved,
|
||||
group: { ...saved.group, enabled: false }
|
||||
});
|
||||
return h2(
|
||||
React7.Fragment,
|
||||
null,
|
||||
|
|
@ -12776,10 +12926,15 @@ var CSS11 = String.raw`
|
|||
.dim-contextHeaderTooltip { width: min(340px, calc(100vw - 72px)); }
|
||||
.dim-contextClose { width: 30px; height: 30px; flex: none; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; color: var(--dsw-alias-label-secondary, #646a73); background: transparent; cursor: pointer; }
|
||||
.dim-contextClose:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, #eef0f3); }
|
||||
.dim-contextSection { min-width: 0; margin: 14px 0; padding: 0; border: 0; }
|
||||
.dim-contextSection legend { margin-bottom: 8px; padding: 0; font-weight: 500; }
|
||||
.dim-contextTabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; margin-top: 14px; padding: 3px; border: 1px solid var(--dsw-alias-border-l1, #eef0f3); border-radius: 8px; background: var(--dsw-alias-bg-module-platform, #f7f8fa); }
|
||||
.dim-contextTab { min-width: 0; min-height: 34px; padding: 5px 12px; border: 0; border-radius: 6px; color: var(--dsw-alias-label-secondary, #646a73); background: transparent; font: inherit; font-weight: 500; cursor: pointer; transition: color .15s ease, background .15s ease, box-shadow .15s ease; }
|
||||
.dim-contextTab:hover:not(:disabled):not([aria-selected="true"]) { color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-interactive-bg-hover, #eef0f3); }
|
||||
.dim-contextTab[aria-selected="true"] { color: var(--dsw-alias-state-business-primary, #3370ff); background: var(--dsw-alias-bg-layer-1, #fff); box-shadow: 0 1px 3px rgb(31 35 41 / 12%); }
|
||||
.dim-contextTabPanel[hidden] { display: none; }
|
||||
.dim-contextSection { min-width: 0; margin: 0; padding: 0; border: 0; }
|
||||
.dim-contextScope { margin-top: 10px; padding: 12px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 9px; background: var(--dsw-alias-bg-layer-1, #fff); }
|
||||
.dim-contextScopeBlock { margin-top: 12px; }
|
||||
.dim-contextLegend { position: relative; display: inline-flex; align-items: center; gap: 6px; }
|
||||
.dim-contextSwitches { display: grid; grid-template-columns: 1fr; gap: 2px; }
|
||||
.dim-contextSwitchRow { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; cursor: pointer; }
|
||||
.dim-contextSwitchLabel { min-width: 0; display: inline-flex; align-items: baseline; gap: 5px; flex-wrap: wrap; }
|
||||
.dim-contextUnavailable { color: var(--dsw-alias-label-tertiary, #8f959e); font-size: 11px; line-height: 16px; font-weight: 400; }
|
||||
|
|
@ -12822,7 +12977,7 @@ var CSS11 = String.raw`
|
|||
.dim-contextEntry:focus-visible, .dim-contextDialog button:focus-visible, .dim-contextDialog input:focus-visible, .dim-contextDialog textarea:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #3370ff); outline-offset: 2px; }
|
||||
.dim-contextEntry:disabled, .dim-contextDialog button:disabled, .dim-contextDialog input:disabled, .dim-contextDialog textarea:disabled { opacity: .55; cursor: not-allowed; }
|
||||
@media (pointer: coarse) {
|
||||
.dim-contextEntry, .dim-contextClose, .dim-contextFooter button, .dim-contextTextActions button, .dim-contextField, .dim-contextSwitchRow { min-height: 44px; }
|
||||
.dim-contextEntry, .dim-contextTab, .dim-contextClose, .dim-contextFooter button, .dim-contextTextActions button, .dim-contextField, .dim-contextSwitchRow { min-height: 44px; }
|
||||
.dim-contextClose, .dim-contextTextActions button { min-width: 44px; }
|
||||
.dim-contextGuidance textarea { font-size: 16px; }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue