@michengai/dsh-agency-agents 0.1.10 → 0.1.12
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/lib/client.js +53 -15
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2509,6 +2509,9 @@ window.__ModuleLoader__.load({
|
|
|
2509
2509
|
"settings.loading": "正在加载专家…",
|
|
2510
2510
|
"settings.enabled": "已启用",
|
|
2511
2511
|
"settings.disabled": "已停用",
|
|
2512
|
+
"error.conflict": "配置已被其他窗口修改。",
|
|
2513
|
+
"error.conflict.refreshed": "配置已被其他窗口修改,已为您刷新。",
|
|
2514
|
+
"error.conflict.refreshFailed": "配置已被其他窗口修改,但刷新失败,请手动刷新。",
|
|
2512
2515
|
"btn.refresh": "刷新",
|
|
2513
2516
|
"btn.enable": "启用",
|
|
2514
2517
|
"btn.disable": "停用",
|
|
@@ -2547,6 +2550,9 @@ window.__ModuleLoader__.load({
|
|
|
2547
2550
|
"settings.loading": "Loading experts…",
|
|
2548
2551
|
"settings.enabled": "Enabled",
|
|
2549
2552
|
"settings.disabled": "Disabled",
|
|
2553
|
+
"error.conflict": "Settings were changed in another window.",
|
|
2554
|
+
"error.conflict.refreshed": "Settings were changed in another window and have been refreshed.",
|
|
2555
|
+
"error.conflict.refreshFailed": "Settings were changed in another window, but refresh failed. Please refresh manually.",
|
|
2550
2556
|
"btn.refresh": "Refresh",
|
|
2551
2557
|
"btn.enable": "Enable",
|
|
2552
2558
|
"btn.disable": "Disable",
|
|
@@ -6646,9 +6652,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6646
6652
|
return active === "en" && e.descriptionEn !== "" ? e.descriptionEn : e.description;
|
|
6647
6653
|
}
|
|
6648
6654
|
const CSS = ".aag-btn-wrap{position:relative;order:1;margin-right:-8px}.aag-btn{display:inline-flex;align-items:center;gap:4px;height:28px;padding:0 4px 0 8px;border:none;border-radius:24px;background:transparent;color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px;font-weight:500;cursor:pointer}.aag-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.aag-menu{position:absolute;bottom:calc(100% + 4px);left:0;box-sizing:border-box;padding:4px;display:flex;flex-direction:column;gap:0;width:300px;max-width:360px;max-height:calc(100vh - 24px);overflow-y:auto;border:1px solid var(--dsw-alias-border-inverted);border-radius:12px;background:var(--dsw-specific-menu);box-shadow:var(--dsw-shadow-lv3);z-index:10000}.aag-menu-title{padding:8px 10px;font-size:12px;line-height:16px;color:var(--dsw-alias-label-tertiary)}.aag-menu-item{display:flex;align-items:center;gap:8px;width:100%;min-height:40px;padding:8px 10px;border:none;border-radius:10px;background:transparent;cursor:pointer;text-align:left;font-size:14px;line-height:22px;color:var(--dsw-alias-label-primary);box-sizing:border-box}.aag-menu-item:hover{background:var(--dsw-alias-interactive-bg-hover)}.aag-emoji{flex:0 0 auto;font-size:16px}.aag-menu-empty{padding:8px 10px;color:var(--dsw-alias-label-secondary);font-size:13px}[data-composer-card] :has(> button[aria-haspopup=\"listbox\"]) > :nth-child(2){order:2}\n.aag-section{box-sizing:border-box;display:flex;min-width:0;max-width:760px;width:100%;margin:0 auto;flex-direction:column;gap:16px;padding:0 0 32px;color:var(--dsw-alias-label-primary)}\n.aag-toolbar{display:flex;align-items:flex-start;gap:16px;padding-bottom:12px}\n.aag-title{margin:0;font-size:20px;line-height:28px;font-weight:650;letter-spacing:-.2px}\n.aag-desc{margin:4px 0 0;max-width:42em;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}\n.aag-actions{display:flex;align-items:center;gap:8px;margin-left:auto}\n.aag-action{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-height:32px;padding:0 12px;border:1px solid transparent;border-radius:8px;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-foreground);font:inherit;font-size:13px;font-weight:550;cursor:pointer;transition:opacity 180ms ease,background 180ms ease,border-color 180ms ease}\n.aag-action:hover:not(:disabled){opacity:.9}.aag-action:disabled{opacity:.5;cursor:default}\n.aag-action-secondary{background:transparent;border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}\n.aag-action:focus-visible{outline:2px solid var(--dsw-alias-state-success-primary);outline-offset:2px}\n.aag-summary{display:flex;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--dsw-alias-border-l2);border-radius:10px;background:var(--dsw-alias-bg-layer-2)}\n.aag-summary-count{font-size:18px;font-weight:650}.aag-summary-label{color:var(--dsw-alias-label-secondary);font-size:12px}.aag-summary-separator{width:1px;height:24px;background:var(--dsw-alias-border-l2)}\n.aag-group{display:flex;flex-direction:column;overflow:hidden;border:1px solid var(--dsw-alias-border-l2);border-radius:12px;background:var(--dsw-alias-bg-layer-2)}\n.aag-group-head{display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}\n.aag-group-title{margin:0;font-size:14px;font-weight:600}.aag-count{color:var(--dsw-alias-label-tertiary);font-size:12px}\n.aag-row{display:flex;align-items:center;gap:12px;padding:13px 16px;border-bottom:1px solid var(--dsw-alias-border-l1)}\n.aag-row:last-child{border-bottom:0}\n.aag-row-main{display:flex;min-width:0;flex:1;flex-direction:column;gap:3px}\n.aag-row-id{display:flex;align-items:center;gap:7px;min-width:0}\n.aag-row-name{overflow:hidden;font-size:13px;font-weight:500;line-height:20px;text-overflow:ellipsis;white-space:nowrap}\n.aag-tag{flex:none;padding:1px 6px;border:1px solid var(--dsw-alias-border-l3);border-radius:4px;color:var(--dsw-alias-label-secondary);font-size:11px;line-height:16px}\n.aag-tag-on{border-color:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-state-success-primary)}\n.aag-tag-off{border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}\n.aag-note{overflow:hidden;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;text-overflow:ellipsis;white-space:nowrap}\n.aag-error{color:var(--dsw-alias-state-error-primary);font-size:13px;line-height:20px}\n@media (max-width:560px){.aag-toolbar{flex-wrap:wrap}.aag-actions{margin-left:0}.aag-row{align-items:flex-start;flex-wrap:wrap}.aag-row>.aag-action{margin-left:auto}}\n@media (prefers-reduced-motion:reduce){.aag-action{transition:none}}\n" + DIVISION_ORDER.map((d) => `[role="listbox"] div[data-source="division.${d}"] ~ button span:last-child`).join(",") + "{flex:1 1 auto;max-width:none;min-width:0}";
|
|
6649
|
-
|
|
6650
|
-
function
|
|
6651
|
-
if (error instanceof Error && error.message.includes("changed since it was read"))
|
|
6655
|
+
/** 将写失败映射到 agency 词条;非冲突错误返回 null,由调用方展示原始消息。 */
|
|
6656
|
+
function writeErrorKey(error, options) {
|
|
6657
|
+
if (error instanceof Error && error.message.includes("changed since it was read")) {
|
|
6658
|
+
if (options?.refreshed === true) return "error.conflict.refreshed";
|
|
6659
|
+
if (options?.refreshed === false) return "error.conflict.refreshFailed";
|
|
6660
|
+
return "error.conflict";
|
|
6661
|
+
}
|
|
6662
|
+
return null;
|
|
6663
|
+
}
|
|
6664
|
+
/** 写失败时的用户可见文案。冲突场景必须显式传入 refreshed;传入 t 时按当前语言翻译。 */
|
|
6665
|
+
function writeErrorMessage(error, options) {
|
|
6666
|
+
const key = writeErrorKey(error, options);
|
|
6667
|
+
if (key !== null) return (options?.t ?? ((item) => zh[item]))(key);
|
|
6652
6668
|
return error instanceof Error ? error.message : String(error);
|
|
6653
6669
|
}
|
|
6654
6670
|
async function readEnabled(remote) {
|
|
@@ -6710,6 +6726,18 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6710
6726
|
window.requestAnimationFrame(select);
|
|
6711
6727
|
});
|
|
6712
6728
|
}
|
|
6729
|
+
/** 根据当前草稿生成召唤指令。有内容时把原草稿包进 withTask 模板。 */
|
|
6730
|
+
function buildSummonInstruction(t, name, slug, draft) {
|
|
6731
|
+
return t(draft.trim().length > 0 ? "summon.instruction.withTask" : "summon.instruction", {
|
|
6732
|
+
name,
|
|
6733
|
+
slug,
|
|
6734
|
+
task: draft
|
|
6735
|
+
});
|
|
6736
|
+
}
|
|
6737
|
+
/** 将召唤指令写入输入框。有草稿时也不自动发送,留给用户确认后再提交。 */
|
|
6738
|
+
function applyExpertSummon(options) {
|
|
6739
|
+
if (options.inputActions !== void 0) options.inputActions.setDraft(options.instruction);
|
|
6740
|
+
}
|
|
6713
6741
|
function AgentsButton(props) {
|
|
6714
6742
|
const [open, setOpen] = react.default.useState(false);
|
|
6715
6743
|
const [enabled, setEnabled] = react.default.useState(/* @__PURE__ */ new Set());
|
|
@@ -6739,16 +6767,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6739
6767
|
const expert = EXPERTS.find((e) => e.slug === slug);
|
|
6740
6768
|
const name = expert === void 0 ? slug : displayName(expert, props.getActive());
|
|
6741
6769
|
const draft = props.input !== void 0 && typeof props.input.draft === "string" ? props.input.draft : "";
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
name,
|
|
6745
|
-
slug,
|
|
6746
|
-
task: draft
|
|
6770
|
+
applyExpertSummon({
|
|
6771
|
+
inputActions: props.inputActions,
|
|
6772
|
+
instruction: buildSummonInstruction(props.t, name, slug, draft)
|
|
6747
6773
|
});
|
|
6748
|
-
if (props.inputActions !== void 0) {
|
|
6749
|
-
props.inputActions.setDraft(instruction);
|
|
6750
|
-
if (hasTask) props.inputActions.submit();
|
|
6751
|
-
}
|
|
6752
6774
|
setOpen(false);
|
|
6753
6775
|
};
|
|
6754
6776
|
const groups = groupByDivision(EXPERTS.filter((e) => enabled.has(e.slug)));
|
|
@@ -6787,6 +6809,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6787
6809
|
}, [props.remote]);
|
|
6788
6810
|
const toggle = (slug) => {
|
|
6789
6811
|
if (state === null || saving.current) return;
|
|
6812
|
+
const previous = state;
|
|
6790
6813
|
const next = new Set(state.enabled);
|
|
6791
6814
|
if (next.has(slug)) next.delete(slug);
|
|
6792
6815
|
else next.add(slug);
|
|
@@ -6796,11 +6819,23 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6796
6819
|
enabled: next,
|
|
6797
6820
|
revision: state.revision
|
|
6798
6821
|
});
|
|
6799
|
-
writeEnabled(props.remote, next, state.revision).then(
|
|
6822
|
+
writeEnabled(props.remote, next, state.revision).then((current) => {
|
|
6823
|
+
setState(current);
|
|
6824
|
+
setError(null);
|
|
6825
|
+
}).catch(async (err) => {
|
|
6800
6826
|
try {
|
|
6801
6827
|
setState(await readEnabled(props.remote));
|
|
6802
|
-
|
|
6803
|
-
|
|
6828
|
+
setError(writeErrorMessage(err, {
|
|
6829
|
+
refreshed: true,
|
|
6830
|
+
t: props.t
|
|
6831
|
+
}));
|
|
6832
|
+
} catch {
|
|
6833
|
+
setState(previous);
|
|
6834
|
+
setError(writeErrorMessage(err, {
|
|
6835
|
+
refreshed: false,
|
|
6836
|
+
t: props.t
|
|
6837
|
+
}));
|
|
6838
|
+
}
|
|
6804
6839
|
}).finally(() => {
|
|
6805
6840
|
saving.current = false;
|
|
6806
6841
|
setIsSaving(false);
|
|
@@ -6928,7 +6963,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6928
6963
|
}
|
|
6929
6964
|
//#endregion
|
|
6930
6965
|
exports.apply = apply;
|
|
6966
|
+
exports.applyExpertSummon = applyExpertSummon;
|
|
6967
|
+
exports.buildSummonInstruction = buildSummonInstruction;
|
|
6931
6968
|
exports.inject = inject;
|
|
6969
|
+
exports.writeErrorKey = writeErrorKey;
|
|
6932
6970
|
exports.writeErrorMessage = writeErrorMessage;
|
|
6933
6971
|
return module.exports;
|
|
6934
6972
|
}
|
package/package.json
CHANGED