@michengai/dsh-agency-agents 0.1.9 → 0.1.11
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 +114 -29
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -2505,11 +2505,23 @@ window.__ModuleLoader__.load({
|
|
|
2505
2505
|
/** 简体中文词条(key 集真相源)。 */
|
|
2506
2506
|
const zh = {
|
|
2507
2507
|
"settings.nav": "专家",
|
|
2508
|
-
"
|
|
2509
|
-
"menu.empty": "暂无可召唤的专家",
|
|
2508
|
+
"settings.intro": "选择对话里可以召唤的专家。停用后不会出现在 @ 菜单中。",
|
|
2510
2509
|
"settings.loading": "正在加载专家…",
|
|
2511
2510
|
"settings.enabled": "已启用",
|
|
2512
2511
|
"settings.disabled": "已停用",
|
|
2512
|
+
"error.conflict": "配置已被其他窗口修改。",
|
|
2513
|
+
"error.conflict.refreshed": "配置已被其他窗口修改,已为您刷新。",
|
|
2514
|
+
"error.conflict.refreshFailed": "配置已被其他窗口修改,但刷新失败,请手动刷新。",
|
|
2515
|
+
"btn.refresh": "刷新",
|
|
2516
|
+
"btn.enable": "启用",
|
|
2517
|
+
"btn.disable": "停用",
|
|
2518
|
+
"summary.total.one": "位专家",
|
|
2519
|
+
"summary.total.other": "位专家",
|
|
2520
|
+
"summary.enabled.one": "位已启用",
|
|
2521
|
+
"summary.enabled.other": "位已启用",
|
|
2522
|
+
"summary.group": "{count} 个",
|
|
2523
|
+
"button.title": "召唤专家",
|
|
2524
|
+
"menu.empty": "暂无可召唤的专家",
|
|
2513
2525
|
"group.count": "{division}({count})",
|
|
2514
2526
|
"summon.instruction": "召唤专家「{name}」({slug})处理以下任务:",
|
|
2515
2527
|
"summon.instruction.withTask": "召唤专家「{name}」({slug})处理以下任务:\n{task}",
|
|
@@ -2534,11 +2546,23 @@ window.__ModuleLoader__.load({
|
|
|
2534
2546
|
/** 英文词条,key 完整性由 satisfies 在编译期保证。 */
|
|
2535
2547
|
const en = {
|
|
2536
2548
|
"settings.nav": "Experts",
|
|
2537
|
-
"
|
|
2538
|
-
"menu.empty": "No experts available yet",
|
|
2549
|
+
"settings.intro": "Choose which experts can be summoned in chat. Disabled experts stay out of the @ menu.",
|
|
2539
2550
|
"settings.loading": "Loading experts…",
|
|
2540
2551
|
"settings.enabled": "Enabled",
|
|
2541
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.",
|
|
2556
|
+
"btn.refresh": "Refresh",
|
|
2557
|
+
"btn.enable": "Enable",
|
|
2558
|
+
"btn.disable": "Disable",
|
|
2559
|
+
"summary.total.one": "expert",
|
|
2560
|
+
"summary.total.other": "experts",
|
|
2561
|
+
"summary.enabled.one": "enabled",
|
|
2562
|
+
"summary.enabled.other": "enabled",
|
|
2563
|
+
"summary.group": "{count} items",
|
|
2564
|
+
"button.title": "Summon expert",
|
|
2565
|
+
"menu.empty": "No experts available yet",
|
|
2542
2566
|
"group.count": "{division} ({count})",
|
|
2543
2567
|
"summon.instruction": "Summon expert \"{name}\" ({slug}) to handle the following task:",
|
|
2544
2568
|
"summon.instruction.withTask": "Summon expert \"{name}\" ({slug}) to handle the following task:\n{task}",
|
|
@@ -6627,10 +6651,20 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6627
6651
|
function displayDescription(e, active) {
|
|
6628
6652
|
return active === "en" && e.descriptionEn !== "" ? e.descriptionEn : e.description;
|
|
6629
6653
|
}
|
|
6630
|
-
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}.aag-
|
|
6631
|
-
|
|
6632
|
-
function
|
|
6633
|
-
if (error instanceof Error && error.message.includes("changed since it was read"))
|
|
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}";
|
|
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);
|
|
6634
6668
|
return error instanceof Error ? error.message : String(error);
|
|
6635
6669
|
}
|
|
6636
6670
|
async function readEnabled(remote) {
|
|
@@ -6747,6 +6781,14 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6747
6781
|
const [error, setError] = react.default.useState(null);
|
|
6748
6782
|
const saving = react.default.useRef(false);
|
|
6749
6783
|
const [isSaving, setIsSaving] = react.default.useState(false);
|
|
6784
|
+
const load = react.default.useCallback(() => {
|
|
6785
|
+
readEnabled(props.remote).then((current) => {
|
|
6786
|
+
setState(current);
|
|
6787
|
+
setError(null);
|
|
6788
|
+
}).catch((err) => {
|
|
6789
|
+
setError(err instanceof Error ? err.message : String(err));
|
|
6790
|
+
});
|
|
6791
|
+
}, [props.remote]);
|
|
6750
6792
|
react.default.useEffect(() => {
|
|
6751
6793
|
let alive = true;
|
|
6752
6794
|
readEnabled(props.remote).then((current) => {
|
|
@@ -6761,6 +6803,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6761
6803
|
}, [props.remote]);
|
|
6762
6804
|
const toggle = (slug) => {
|
|
6763
6805
|
if (state === null || saving.current) return;
|
|
6806
|
+
const previous = state;
|
|
6764
6807
|
const next = new Set(state.enabled);
|
|
6765
6808
|
if (next.has(slug)) next.delete(slug);
|
|
6766
6809
|
else next.add(slug);
|
|
@@ -6770,34 +6813,75 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6770
6813
|
enabled: next,
|
|
6771
6814
|
revision: state.revision
|
|
6772
6815
|
});
|
|
6773
|
-
writeEnabled(props.remote, next, state.revision).then(
|
|
6816
|
+
writeEnabled(props.remote, next, state.revision).then((current) => {
|
|
6817
|
+
setState(current);
|
|
6818
|
+
setError(null);
|
|
6819
|
+
}).catch(async (err) => {
|
|
6774
6820
|
try {
|
|
6775
6821
|
setState(await readEnabled(props.remote));
|
|
6776
|
-
|
|
6777
|
-
|
|
6822
|
+
setError(writeErrorMessage(err, {
|
|
6823
|
+
refreshed: true,
|
|
6824
|
+
t: props.t
|
|
6825
|
+
}));
|
|
6826
|
+
} catch {
|
|
6827
|
+
setState(previous);
|
|
6828
|
+
setError(writeErrorMessage(err, {
|
|
6829
|
+
refreshed: false,
|
|
6830
|
+
t: props.t
|
|
6831
|
+
}));
|
|
6832
|
+
}
|
|
6778
6833
|
}).finally(() => {
|
|
6779
6834
|
saving.current = false;
|
|
6780
6835
|
setIsSaving(false);
|
|
6781
6836
|
});
|
|
6782
6837
|
};
|
|
6783
|
-
|
|
6784
|
-
if (
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
}
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6838
|
+
const nodes = [];
|
|
6839
|
+
if (error !== null) nodes.push(react.default.createElement("div", {
|
|
6840
|
+
key: "error",
|
|
6841
|
+
className: "aag-error",
|
|
6842
|
+
role: "alert"
|
|
6843
|
+
}, error));
|
|
6844
|
+
if (state === null) nodes.push(react.default.createElement("div", {
|
|
6845
|
+
key: "loading",
|
|
6846
|
+
className: "aag-note"
|
|
6847
|
+
}, props.t("settings.loading")));
|
|
6848
|
+
else {
|
|
6849
|
+
const groups = groupByDivision(EXPERTS);
|
|
6850
|
+
const enabledCount = [...state.enabled].filter((slug) => EXPERTS.some((e) => e.slug === slug)).length;
|
|
6851
|
+
const total = EXPERTS.length;
|
|
6852
|
+
nodes.push(react.default.createElement("div", {
|
|
6853
|
+
key: "toolbar",
|
|
6854
|
+
className: "aag-toolbar"
|
|
6855
|
+
}, react.default.createElement("div", null, react.default.createElement("h2", { className: "aag-title" }, props.t("settings.nav")), react.default.createElement("p", { className: "aag-desc" }, props.t("settings.intro"))), react.default.createElement("div", { className: "aag-actions" }, react.default.createElement("button", {
|
|
6856
|
+
type: "button",
|
|
6857
|
+
className: "aag-action aag-action-secondary",
|
|
6858
|
+
disabled: isSaving,
|
|
6859
|
+
onClick: load
|
|
6860
|
+
}, props.t("btn.refresh")))));
|
|
6861
|
+
nodes.push(react.default.createElement("div", {
|
|
6862
|
+
key: "summary",
|
|
6863
|
+
className: "aag-summary"
|
|
6864
|
+
}, react.default.createElement("span", { className: "aag-summary-count" }, total), react.default.createElement("span", { className: "aag-summary-label" }, props.t(total === 1 ? "summary.total.one" : "summary.total.other", { count: total })), react.default.createElement("span", { className: "aag-summary-separator" }), react.default.createElement("span", { className: "aag-summary-count" }, enabledCount), react.default.createElement("span", { className: "aag-summary-label" }, props.t(enabledCount === 1 ? "summary.enabled.one" : "summary.enabled.other", { count: enabledCount }))));
|
|
6865
|
+
for (const g of groups) nodes.push(react.default.createElement("div", {
|
|
6866
|
+
key: g.division,
|
|
6867
|
+
className: "aag-group"
|
|
6868
|
+
}, react.default.createElement("div", { className: "aag-group-head" }, react.default.createElement("h3", { className: "aag-group-title" }, props.t(`division.${g.division}`)), react.default.createElement("span", { className: "aag-count" }, props.t("summary.group", { count: g.experts.length }))), g.experts.map((e) => {
|
|
6869
|
+
const on = state.enabled.has(e.slug);
|
|
6870
|
+
return react.default.createElement("div", {
|
|
6871
|
+
key: e.slug,
|
|
6872
|
+
className: "aag-row"
|
|
6873
|
+
}, react.default.createElement("div", { className: "aag-row-main" }, react.default.createElement("div", { className: "aag-row-id" }, react.default.createElement("span", { className: "aag-row-name" }, displayName(e, props.getActive())), react.default.createElement("span", { className: "aag-tag" }, e.slug), react.default.createElement("span", { className: `aag-tag ${on ? "aag-tag-on" : "aag-tag-off"}` }, props.t(on ? "settings.enabled" : "settings.disabled"))), react.default.createElement("div", {
|
|
6874
|
+
className: "aag-note",
|
|
6875
|
+
title: displayDescription(e, props.getActive())
|
|
6876
|
+
}, displayDescription(e, props.getActive()))), react.default.createElement("button", {
|
|
6877
|
+
type: "button",
|
|
6878
|
+
className: "aag-action aag-action-secondary",
|
|
6879
|
+
disabled: isSaving,
|
|
6880
|
+
onClick: () => toggle(e.slug)
|
|
6881
|
+
}, props.t(on ? "btn.disable" : "btn.enable")));
|
|
6882
|
+
})));
|
|
6883
|
+
}
|
|
6884
|
+
return react.default.createElement("section", { className: "aag-section" }, nodes);
|
|
6801
6885
|
}
|
|
6802
6886
|
const inject = [
|
|
6803
6887
|
"slots",
|
|
@@ -6874,6 +6958,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
6874
6958
|
//#endregion
|
|
6875
6959
|
exports.apply = apply;
|
|
6876
6960
|
exports.inject = inject;
|
|
6961
|
+
exports.writeErrorKey = writeErrorKey;
|
|
6877
6962
|
exports.writeErrorMessage = writeErrorMessage;
|
|
6878
6963
|
return module.exports;
|
|
6879
6964
|
}
|
package/package.json
CHANGED