@michengai/dsh-im-connect 0.1.38 → 0.1.40
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/CHANGELOG.md +14 -1
- package/CHANGELOG.zh-CN.md +14 -1
- package/README.en.md +44 -63
- package/README.md +44 -63
- package/client.js +39 -301
- package/lib/client.js +39 -301
- package/lib/engine/gateway.d.ts.map +1 -1
- package/lib/engine/gateway.js +12 -2
- package/lib/engine/gateway.js.map +1 -1
- package/lib/engine/router.d.ts +5 -1
- package/lib/engine/router.d.ts.map +1 -1
- package/lib/engine/router.js +111 -17
- package/lib/engine/router.js.map +1 -1
- package/lib/engine/session-id.d.ts +2 -0
- package/lib/engine/session-id.d.ts.map +1 -1
- package/lib/engine/session-id.js.map +1 -1
- package/lib/engine/session-store.d.ts +6 -0
- package/lib/engine/session-store.d.ts.map +1 -1
- package/lib/engine/session-store.js +49 -1
- package/lib/engine/session-store.js.map +1 -1
- package/lib/engine/session-title.d.ts +8 -0
- package/lib/engine/session-title.d.ts.map +1 -0
- package/lib/engine/session-title.js +30 -0
- package/lib/engine/session-title.js.map +1 -0
- package/package.json +1 -1
- package/src/engine/gateway.ts +10 -2
- package/src/engine/router.ts +97 -17
- package/src/engine/session-id.ts +2 -0
- package/src/engine/session-store.ts +47 -1
- package/src/engine/session-title.ts +25 -0
package/client.js
CHANGED
|
@@ -95,13 +95,8 @@ window.__ModuleLoader__.load({
|
|
|
95
95
|
.ima-avatar{width:36px;height:36px;border-radius:50%;display:grid;place-items:center;border:2px solid #111}
|
|
96
96
|
.ima-avatar.bot{background:#123524;margin-right:-8px;z-index:1}
|
|
97
97
|
.ima-avatar.user{background:#3d3428}
|
|
98
|
-
.ima-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px}.ima-title{margin:0;font-size:
|
|
99
|
-
.ima-sub{margin:
|
|
100
|
-
.ima-composer-wrap{margin:0 0 16px}
|
|
101
|
-
.ima-composer{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-items:center;gap:4px;padding:4px 6px;border:1px solid var(--ima-line);border-radius:14px;background:var(--ima-card)}
|
|
102
|
-
.ima-composer-left,.ima-composer-right{display:contents}
|
|
103
|
-
.ima-composer .ima-chip{width:100%;min-width:0}
|
|
104
|
-
.ima-composer .ima-chip-btn{width:100%;justify-content:center}
|
|
98
|
+
.ima-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px}.ima-title{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.4px;white-space:nowrap;text-align:left}
|
|
99
|
+
.ima-sub{margin:12px 0 0;max-width:42em;color:var(--ima-muted);font-size:14px;line-height:22px;text-align:left}
|
|
105
100
|
.ima-chip{position:relative;min-width:0;z-index:1}
|
|
106
101
|
.ima-chip.is-open{z-index:30}
|
|
107
102
|
.ima-chip-btn{display:inline-flex;align-items:center;gap:6px;min-height:28px;height:28px;padding:0 8px;border:0;border-radius:8px;background:transparent;color:var(--ima-muted);font-size:13px;font-weight:500;white-space:nowrap;cursor:pointer}
|
|
@@ -115,7 +110,6 @@ window.__ModuleLoader__.load({
|
|
|
115
110
|
.ima-chip-row-main{display:inline-flex;align-items:center;gap:8px;min-width:0}
|
|
116
111
|
.ima-chip-tick{width:6px;height:12px;border-right:1.6px solid var(--ima-accent);border-bottom:1.6px solid var(--ima-accent);transform:rotate(45deg) translateY(-2px);flex:none}
|
|
117
112
|
.ima-chip-empty{padding:14px 12px;color:var(--ima-muted);font-size:12px;text-align:center}
|
|
118
|
-
.ima-composer-hint{margin-top:8px;color:var(--ima-muted);font-size:12px;text-align:center}
|
|
119
113
|
.ima-chip svg{flex:none}
|
|
120
114
|
.ima-chip-row.is-kv .ima-chip-row-main{flex:none}
|
|
121
115
|
.ima-chip-row-side{display:inline-flex;align-items:center;gap:8px;color:var(--ima-muted);font-size:12px;min-width:0}
|
|
@@ -123,9 +117,9 @@ window.__ModuleLoader__.load({
|
|
|
123
117
|
.ima-chip-split{height:1px;margin:6px 8px;background:var(--ima-line)}
|
|
124
118
|
.ima-chip-effort{color:var(--ima-muted);font-weight:500}
|
|
125
119
|
.ima-model-select .ima-chip-btn{border-radius:24px;gap:4px}
|
|
126
|
-
.ima-model-select .ima-chip-menu{width:min(240px,calc(100vw - 32px));
|
|
120
|
+
.ima-model-select .ima-chip-menu{width:max-content;min-width:min(240px,calc(100vw - 32px));max-width:calc(100vw - 32px);box-sizing:border-box;max-height:min(360px,calc(100vh - 96px));padding:4px;border-radius:12px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base,#fff))}
|
|
127
121
|
.ima-model-select .ima-chip-row{min-height:40px;padding:0 10px;font-size:14px}
|
|
128
|
-
.ima-model-select .ima-chip-row-side{font-size:13px;color:var(--dsw-alias-label-tertiary,var(--ima-muted))}
|
|
122
|
+
.ima-model-select .ima-chip-row-side>span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ima-model-select .ima-chip-row-side{font-size:13px;color:var(--dsw-alias-label-tertiary,var(--ima-muted))}
|
|
129
123
|
.ima-model-group+.ima-model-group{margin-top:4px}
|
|
130
124
|
.ima-model-group-title{position:sticky;top:0;z-index:1;padding:5px 8px 3px;background:var(--dsw-specific-menu,var(--dsw-alias-bg-base,#fff));color:var(--dsw-alias-label-tertiary,var(--ima-muted));font-size:12px;font-weight:500;line-height:18px}
|
|
131
125
|
.ima-model-option{display:flex;width:100%;min-height:38px;align-items:center;gap:8px;padding:6px 8px;border:0;border-radius:10px;background:transparent;color:var(--dsw-alias-label-primary,var(--ima-text));text-align:left;cursor:pointer}
|
|
@@ -208,8 +202,8 @@ window.__ModuleLoader__.load({
|
|
|
208
202
|
.ima-radio small{display:block;color:var(--ima-muted);margin-top:2px}
|
|
209
203
|
.ima-ok{color:var(--ima-ok);font-size:14px;text-align:center;padding:24px 0}
|
|
210
204
|
.ima-modal .ima-error{color:var(--ima-danger)}
|
|
211
|
-
.ima-page.ima-account-page{max-width:1120px;padding-bottom:40px}
|
|
212
|
-
.ima-account-shell{display:grid;grid-template-columns:
|
|
205
|
+
.ima-page.ima-account-page{container-type:inline-size;min-width:0;max-width:1120px;padding-bottom:40px}
|
|
206
|
+
.ima-account-shell{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));min-height:650px;border:1px solid var(--ima-line);border-radius:16px;overflow:hidden;background:transparent}
|
|
213
207
|
.ima-platforms{padding:0;border-right:1px solid var(--ima-line);background:transparent}
|
|
214
208
|
.ima-platform{border:0;border-bottom:1px solid var(--ima-line);border-radius:0;margin:0;overflow:visible;background:transparent}.ima-platform:last-child{border-bottom:0}.ima-platform.open{background:transparent}
|
|
215
209
|
.ima-platform-head{display:flex;align-items:center;gap:10px;width:100%;min-height:64px;padding:10px 18px;border:0;border-radius:0;background:transparent;color:inherit;text-align:left;cursor:pointer}
|
|
@@ -225,14 +219,31 @@ window.__ModuleLoader__.load({
|
|
|
225
219
|
.ima-inspector-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin-top:6px;padding-top:18px;border-top:1px solid var(--ima-line)}.ima-inspector-actions .ima-btn{flex:none;min-width:0;min-height:36px;padding:0 8px;font-size:12px;white-space:nowrap}.ima-inspector-actions .danger{margin-left:auto;color:var(--ima-danger);border-color:color-mix(in srgb,var(--ima-danger) 35%,transparent)}
|
|
226
220
|
.ima-save-note{min-height:18px;color:var(--ima-muted);font-size:11px}.ima-save-note.ok{color:var(--ima-ok)}
|
|
227
221
|
.ima-modal.ima-account-modal{width:min(560px,100%);max-height:min(760px,calc(100vh - 48px));overflow:auto}.ima-setup-section{margin:4px 0 14px;padding-bottom:14px;border-bottom:1px solid var(--ima-line)}
|
|
228
|
-
.ima-account-settings{display:grid;grid-template-columns:1fr 1fr;gap:12px}.ima-account-settings.compact{grid-template-columns:1fr}.ima-picker-field{display:flex;min-width:0;flex-direction:column;gap:7px}.ima-picker-field.wide{grid-column:1/-1}.ima-picker-label{color:var(--ima-muted);font-size:12px;font-weight:550}.ima-account-picker{width:100%}.ima-account-picker .ima-chip-btn{width:100%;height:auto;min-height:44px;justify-content:flex-start;padding:8px 12px;border:1px solid var(--ima-line);border-radius:9px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));color:var(--ima-text);font-size:13px;text-align:left}.ima-account-picker .ima-chip-btn:hover,.ima-account-picker.is-open .ima-chip-btn{border-color:var(--ima-accent);background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));box-shadow:0 0 0 2px color-mix(in srgb,var(--ima-accent) 18%,transparent)}.ima-account-picker .ima-chip-label{flex:1}.ima-account-picker .ima-chip-btn em{margin-left:auto}.ima-account-picker .ima-chip-menu{width:100%;min-width:100%;max-height:min(320px,calc(100vh - 120px))}.ima-account-picker.ima-model-select .ima-chip-btn{border-radius:9px}.ima-account-picker.ima-model-select .ima-chip-menu{width:max(100%,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
222
|
+
.ima-account-settings{display:grid;grid-template-columns:1fr 1fr;gap:12px}.ima-account-settings.compact{grid-template-columns:1fr}.ima-picker-field{display:flex;min-width:0;flex-direction:column;gap:7px}.ima-picker-field.wide{grid-column:1/-1}.ima-picker-label{color:var(--ima-muted);font-size:12px;font-weight:550}.ima-account-picker{width:100%}.ima-account-picker .ima-chip-btn{width:100%;height:auto;min-height:44px;justify-content:flex-start;padding:8px 12px;border:1px solid var(--ima-line);border-radius:9px;background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));color:var(--ima-text);font-size:13px;text-align:left}.ima-account-picker .ima-chip-btn:hover,.ima-account-picker.is-open .ima-chip-btn{border-color:var(--ima-accent);background:var(--dsw-alias-bg-layer-2,rgba(255,255,255,.04));box-shadow:0 0 0 2px color-mix(in srgb,var(--ima-accent) 18%,transparent)}.ima-account-picker .ima-chip-label{flex:1}.ima-account-picker .ima-chip-btn em{margin-left:auto}.ima-account-picker .ima-chip-menu{width:100%;min-width:100%;max-height:min(320px,calc(100vh - 120px))}.ima-account-picker.ima-model-select .ima-chip-btn{border-radius:9px}.ima-account-picker.ima-model-select .ima-chip-menu{width:max-content;min-width:min(100%,calc(100vw - 32px));left:auto;right:0}.ima-account-settings .ima-chip-dialog{grid-column:1/-1;margin-top:0}.ima-picker-note{grid-column:1/-1;color:var(--ima-muted);font-size:11px;line-height:1.5}.ima-picker-note.warning{color:var(--ima-warning)}
|
|
223
|
+
.ima-account-shell,.ima-account-shell *{box-sizing:border-box}
|
|
224
|
+
.ima-platforms{min-width:0}
|
|
225
|
+
.ima-platform-head{display:grid;grid-template-columns:24px minmax(0,1fr) 12px;gap:8px;padding:12px;min-height:76px}
|
|
226
|
+
.ima-platform-head>.ima-logo,.ima-platform-head>.ima-logo svg{width:24px;height:24px}
|
|
227
|
+
.ima-platform-title{grid-column:2;grid-row:1;overflow-wrap:anywhere}
|
|
228
|
+
.ima-platform-caret{grid-column:3;grid-row:1;width:12px;margin:0}
|
|
229
|
+
.ima-platform-count{grid-column:1/3;grid-row:2;font-size:11px;white-space:normal;padding-right:80px}
|
|
230
|
+
.ima-platform-add{grid-column:1/4;grid-row:2;justify-self:end;min-height:28px;padding:0 8px;font-weight:500}
|
|
231
|
+
.ima-account-list{padding:0 8px 10px}
|
|
232
|
+
.ima-account-row{display:grid;grid-template-columns:7px minmax(0,1fr) 12px;gap:6px;min-height:60px;padding:10px 8px}
|
|
233
|
+
.ima-account-row>.ima-logo{display:none}
|
|
234
|
+
.ima-account-copy{grid-column:2;grid-row:1}
|
|
235
|
+
.ima-account-row>.ima-dot{grid-column:1;grid-row:1}
|
|
236
|
+
.ima-account-next{grid-column:3;grid-row:1;width:12px}
|
|
237
|
+
.ima-account-state{grid-column:2;grid-row:2;font-size:11px}
|
|
238
|
+
.ima-inspector{padding:18px 16px;overflow-wrap:anywhere}
|
|
239
|
+
.ima-switch-row{gap:10px}.ima-switch-copy{min-width:0}
|
|
240
|
+
@container(max-width:620px){.ima-inspector{padding:16px 12px}.ima-inspector-head{gap:8px}.ima-inspector-title{font-size:15px}.ima-platform-head{padding:10px 8px;gap:6px}.ima-platform-title{font-size:13px}.ima-inspector-empty{padding:16px;min-height:180px}}
|
|
241
|
+
@container(max-width:420px){.ima-title{font-size:22px}.ima-platform-count{grid-column:1/4;padding-right:0}.ima-platform-add{grid-row:3;justify-self:start}.ima-inspector{padding:12px 8px}.ima-inspector-head{flex-wrap:wrap}}
|
|
242
|
+
@media(max-width:620px){.ima-account-settings{grid-template-columns:1fr}.ima-picker-field.wide{grid-column:auto}}
|
|
232
243
|
@media (prefers-reduced-motion:reduce){.ima-switch i{transition:none}}
|
|
233
244
|
`;
|
|
234
245
|
|
|
235
|
-
const TITLE_LINK_CSS = ".ima-title-row{display:flex;align-items:center;gap:8px;min-width:0}.ima-title-links{display:flex;align-items:center;gap:4px}.ima-title-link{display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:0 8px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap}.ima-title-link:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ima-title-link:focus-visible{outline:2px solid var(--dsw-alias-state-success-primary);outline-offset:2px}.ima-title-link svg{flex:none}@media(max-width:720px){.ima-title-row{flex-wrap:wrap}}";
|
|
246
|
+
const TITLE_LINK_CSS = ".ima-title-row{display:flex;align-items:center;gap:8px 12px;min-width:0;flex-wrap:wrap}.ima-title-links{display:flex;align-items:center;gap:4px;flex-wrap:wrap}.ima-title-link{display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:0 8px;color:var(--dsw-alias-label-secondary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;font-size:12px;font-weight:500;line-height:18px;text-decoration:none;white-space:nowrap}.ima-title-link:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.ima-title-link:focus-visible{outline:2px solid var(--dsw-alias-state-success-primary);outline-offset:2px}.ima-title-link svg{flex:none}@media(max-width:720px){.ima-title-row{flex-wrap:wrap}}";
|
|
236
247
|
|
|
237
248
|
let styleEl = null;
|
|
238
249
|
const ensureStyle = () => {
|
|
@@ -889,7 +900,6 @@ window.__ModuleLoader__.load({
|
|
|
889
900
|
...group.models.map((item) => h(ModelChoiceRow, {
|
|
890
901
|
key: item.value,
|
|
891
902
|
label: item.label,
|
|
892
|
-
description: item.description,
|
|
893
903
|
active: item.provider === provider && item.model === model,
|
|
894
904
|
onClick: () => {
|
|
895
905
|
const nextEffort = (item.reasoning && item.reasoning.defaultEffort) || "";
|
|
@@ -963,284 +973,6 @@ window.__ModuleLoader__.load({
|
|
|
963
973
|
);
|
|
964
974
|
}
|
|
965
975
|
|
|
966
|
-
function ComposerBar(props) {
|
|
967
|
-
const t = props.t || fallbackT;
|
|
968
|
-
const items = typeof props.useWorkspaces === "function"
|
|
969
|
-
? (props.useWorkspaces((state) => (state && state.items) || []) || [])
|
|
970
|
-
: [];
|
|
971
|
-
const [providers, setProviders] = useState([]);
|
|
972
|
-
const [permissions, setPermissions] = useState([]);
|
|
973
|
-
const [provider, setProvider] = useState("");
|
|
974
|
-
const [model, setModel] = useState("");
|
|
975
|
-
const [effort, setEffort] = useState("");
|
|
976
|
-
const [cwd, setCwd] = useState("");
|
|
977
|
-
const [permission, setPermission] = useState("");
|
|
978
|
-
const [confirmingFullAccess, setConfirmingFullAccess] = useState(false);
|
|
979
|
-
const [fullAccessAcknowledged, setFullAccessAcknowledged] = useState(false);
|
|
980
|
-
const [open, setOpen] = useState("");
|
|
981
|
-
const [modelPane, setModelPane] = useState("root");
|
|
982
|
-
const [hint, setHint] = useState("");
|
|
983
|
-
const [adding, setAdding] = useState(false);
|
|
984
|
-
const [addPath, setAddPath] = useState("");
|
|
985
|
-
const [addBusy, setAddBusy] = useState(false);
|
|
986
|
-
|
|
987
|
-
useEffect(() => {
|
|
988
|
-
api("/assistant").then((data) => {
|
|
989
|
-
if (!data.ok) { setHint(serverText(data.error, t) || t("error.loadAssistant")); return; }
|
|
990
|
-
const list = data.providers || [];
|
|
991
|
-
setProviders(list);
|
|
992
|
-
setPermissions(data.permissions || []);
|
|
993
|
-
const current = data.assistant || {};
|
|
994
|
-
const nextProvider = current.provider || (list[0] && list[0].id) || "";
|
|
995
|
-
const models = ((list.find((item) => item.id === nextProvider) || {}).models) || [];
|
|
996
|
-
const nextModel = current.model || (models[0] && models[0].id) || "";
|
|
997
|
-
const found = models.find((item) => item.id === nextModel) || models[0];
|
|
998
|
-
setProvider(nextProvider);
|
|
999
|
-
setModel(nextModel);
|
|
1000
|
-
setEffort(current.reasoningEffort || (found && found.reasoning && found.reasoning.defaultEffort) || "");
|
|
1001
|
-
setCwd(data.cwd || "");
|
|
1002
|
-
setPermission(data.permission || "");
|
|
1003
|
-
if (!list.length) setHint(t("error.noModels"));
|
|
1004
|
-
}).catch(() => setHint(t("error.loadAssistant")));
|
|
1005
|
-
}, []);
|
|
1006
|
-
|
|
1007
|
-
const save = (body) => {
|
|
1008
|
-
api("/assistant", {
|
|
1009
|
-
method: "POST",
|
|
1010
|
-
headers: { "content-type": "application/json" },
|
|
1011
|
-
body: JSON.stringify(body),
|
|
1012
|
-
}).then((data) => {
|
|
1013
|
-
if (!data.ok) setHint(serverText(data.error, t) || t("error.save"));
|
|
1014
|
-
else setHint("");
|
|
1015
|
-
}).catch(() => setHint(t("error.save")));
|
|
1016
|
-
};
|
|
1017
|
-
|
|
1018
|
-
const workspace = items.find((item) => item.path === cwd);
|
|
1019
|
-
const modelGroups = providers.map((item) => ({
|
|
1020
|
-
id: item.id,
|
|
1021
|
-
name: item.name || item.id,
|
|
1022
|
-
models: (item.models || []).map((entry) => ({
|
|
1023
|
-
value: item.id + "::" + entry.id,
|
|
1024
|
-
provider: item.id,
|
|
1025
|
-
providerName: item.name || item.id,
|
|
1026
|
-
model: entry.id,
|
|
1027
|
-
label: entry.name || entry.id,
|
|
1028
|
-
description: entry.description,
|
|
1029
|
-
reasoning: entry.reasoning,
|
|
1030
|
-
})),
|
|
1031
|
-
})).filter((item) => item.models.length > 0);
|
|
1032
|
-
const models = modelGroups.flatMap((item) => item.models);
|
|
1033
|
-
const currentModel = models.find((item) => item.provider === provider && item.model === model);
|
|
1034
|
-
const reasoning = currentModel && currentModel.reasoning;
|
|
1035
|
-
const effectiveEffort = effort || (reasoning && reasoning.defaultEffort) || "";
|
|
1036
|
-
const efforts = reasoning
|
|
1037
|
-
? [
|
|
1038
|
-
...(reasoning.defaultEffort ? [] : [{ id: "", name: props.modelT("effort.providerDefault") }]),
|
|
1039
|
-
...((reasoning.efforts || []).map((item) => ({ id: item.id, name: item.name || item.id, description: item.description }))),
|
|
1040
|
-
]
|
|
1041
|
-
: [];
|
|
1042
|
-
const effortLabel = reasoning
|
|
1043
|
-
? ((efforts.find((item) => item.id === effectiveEffort) || {}).name || effectiveEffort || props.modelT("effort.providerDefault"))
|
|
1044
|
-
: "";
|
|
1045
|
-
const permissionOptions = permissions.map((item) => ({
|
|
1046
|
-
...item,
|
|
1047
|
-
label: permissionLabel(item, t),
|
|
1048
|
-
}));
|
|
1049
|
-
const perm = permissionOptions.find((item) => item.value === permission) || { label: permission || t("composer.permission") };
|
|
1050
|
-
const modelFallback = props.modelT("trigger.fallback");
|
|
1051
|
-
|
|
1052
|
-
const addWorkspace = (path) => {
|
|
1053
|
-
const next = (path || "").trim();
|
|
1054
|
-
if (!next) { setHint(t("error.chooseWorkspace")); return Promise.resolve(); }
|
|
1055
|
-
if (typeof props.createWorkspace !== "function") { setHint(t("error.workspaceUnavailable")); return Promise.resolve(); }
|
|
1056
|
-
setAddBusy(true);
|
|
1057
|
-
return Promise.resolve(props.createWorkspace({ path: next })).then((created) => {
|
|
1058
|
-
const cwdPath = (created && (created.path || created.cwd)) || next;
|
|
1059
|
-
setCwd(cwdPath);
|
|
1060
|
-
save({ cwd: cwdPath });
|
|
1061
|
-
setAdding(false);
|
|
1062
|
-
setAddPath("");
|
|
1063
|
-
setOpen("");
|
|
1064
|
-
}).catch((error) => {
|
|
1065
|
-
setHint((error && error.message) || t("error.addWorkspace"));
|
|
1066
|
-
}).finally(() => setAddBusy(false));
|
|
1067
|
-
};
|
|
1068
|
-
|
|
1069
|
-
const selectPermission = (next) => {
|
|
1070
|
-
setOpen("");
|
|
1071
|
-
if (next === permission) return;
|
|
1072
|
-
if (next === "danger-full-access") {
|
|
1073
|
-
setFullAccessAcknowledged(false);
|
|
1074
|
-
setConfirmingFullAccess(true);
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
1077
|
-
setPermission(next);
|
|
1078
|
-
save({ permission: next });
|
|
1079
|
-
};
|
|
1080
|
-
|
|
1081
|
-
const onAddWorkspace = () => {
|
|
1082
|
-
setOpen("");
|
|
1083
|
-
if (typeof props.pickDirectory === "function") {
|
|
1084
|
-
Promise.resolve(props.pickDirectory()).then((picked) => {
|
|
1085
|
-
if (!picked) return;
|
|
1086
|
-
return addWorkspace(picked);
|
|
1087
|
-
}).catch(() => {
|
|
1088
|
-
setAdding(true);
|
|
1089
|
-
setAddPath("");
|
|
1090
|
-
});
|
|
1091
|
-
return;
|
|
1092
|
-
}
|
|
1093
|
-
setAdding(true);
|
|
1094
|
-
setAddPath("");
|
|
1095
|
-
};
|
|
1096
|
-
|
|
1097
|
-
return h("div", { className: "ima-composer-wrap" },
|
|
1098
|
-
h("div", { className: "ima-composer", "aria-label": t("composer.aria") },
|
|
1099
|
-
h("div", { className: "ima-composer-left" },
|
|
1100
|
-
h(ChipMenu, {
|
|
1101
|
-
open: open === "ws",
|
|
1102
|
-
onToggle: (next) => setOpen(next ? "ws" : ""),
|
|
1103
|
-
icon: h(FolderIcon),
|
|
1104
|
-
label: (workspace && (workspace.title || workspace.path)) || cwd || t("composer.project"),
|
|
1105
|
-
ariaLabel: t("composer.projectAria"),
|
|
1106
|
-
},
|
|
1107
|
-
items.length === 0 && h("div", { className: "ima-chip-empty" }, t("composer.noWorkspaces")),
|
|
1108
|
-
...items.map((item) => h(ChipRow, {
|
|
1109
|
-
key: item.path,
|
|
1110
|
-
icon: h(FolderIcon),
|
|
1111
|
-
label: item.title || item.path,
|
|
1112
|
-
active: item.path === cwd,
|
|
1113
|
-
onClick: () => { setCwd(item.path); save({ cwd: item.path }); setOpen(""); },
|
|
1114
|
-
})),
|
|
1115
|
-
h("div", { className: "ima-chip-split" }),
|
|
1116
|
-
h(ChipRow, {
|
|
1117
|
-
icon: h(PlusIcon),
|
|
1118
|
-
label: t("composer.addWorkspace"),
|
|
1119
|
-
onClick: onAddWorkspace,
|
|
1120
|
-
}),
|
|
1121
|
-
),
|
|
1122
|
-
h(ChipMenu, {
|
|
1123
|
-
open: open === "perm",
|
|
1124
|
-
onToggle: (next) => setOpen(next ? "perm" : ""),
|
|
1125
|
-
icon: h(ShieldIcon),
|
|
1126
|
-
label: perm.label,
|
|
1127
|
-
ariaLabel: t("composer.permission"),
|
|
1128
|
-
},
|
|
1129
|
-
...permissionOptions.map((item) => h(ChipRow, {
|
|
1130
|
-
key: item.value,
|
|
1131
|
-
icon: h(ShieldIcon),
|
|
1132
|
-
label: item.label,
|
|
1133
|
-
active: item.value === permission,
|
|
1134
|
-
onClick: () => selectPermission(item.value),
|
|
1135
|
-
})),
|
|
1136
|
-
),
|
|
1137
|
-
),
|
|
1138
|
-
h("div", { className: "ima-composer-right" },
|
|
1139
|
-
h(ChipMenu, {
|
|
1140
|
-
open: open === "model",
|
|
1141
|
-
onToggle: (next) => {
|
|
1142
|
-
setOpen(next ? "model" : "");
|
|
1143
|
-
if (next) setModelPane("root");
|
|
1144
|
-
},
|
|
1145
|
-
align: "end",
|
|
1146
|
-
className: "ima-model-select",
|
|
1147
|
-
menuClassName: "ima-model-menu",
|
|
1148
|
-
menuAria: props.modelT("menu.aria"),
|
|
1149
|
-
label: (currentModel && currentModel.label) || modelFallback,
|
|
1150
|
-
suffix: effortLabel,
|
|
1151
|
-
ariaLabel: props.modelT("trigger.selectAria"),
|
|
1152
|
-
},
|
|
1153
|
-
modelPane === "root" && [
|
|
1154
|
-
h(ChipRow, {
|
|
1155
|
-
key: "model",
|
|
1156
|
-
kv: true,
|
|
1157
|
-
label: props.modelT("menu.model"),
|
|
1158
|
-
hint: (currentModel && currentModel.label) || modelFallback,
|
|
1159
|
-
chevron: true,
|
|
1160
|
-
onClick: () => setModelPane("model"),
|
|
1161
|
-
}),
|
|
1162
|
-
reasoning && h(ChipRow, {
|
|
1163
|
-
key: "effort",
|
|
1164
|
-
kv: true,
|
|
1165
|
-
label: props.modelT("menu.effort"),
|
|
1166
|
-
hint: effortLabel || props.modelT("effort.providerDefault"),
|
|
1167
|
-
chevron: true,
|
|
1168
|
-
onClick: () => setModelPane("effort"),
|
|
1169
|
-
}),
|
|
1170
|
-
],
|
|
1171
|
-
modelPane === "model" && (
|
|
1172
|
-
models.length === 0
|
|
1173
|
-
? h("div", { className: "ima-chip-empty" }, props.modelT("empty.models"))
|
|
1174
|
-
: modelGroups.map((group) => h("section", { key: group.id, className: "ima-model-group", role: "group", "aria-label": group.name },
|
|
1175
|
-
h("div", { className: "ima-model-group-title" }, group.name),
|
|
1176
|
-
...group.models.map((item) => h(ModelChoiceRow, {
|
|
1177
|
-
key: item.value,
|
|
1178
|
-
label: item.label,
|
|
1179
|
-
description: item.description,
|
|
1180
|
-
active: item.provider === provider && item.model === model,
|
|
1181
|
-
onClick: () => {
|
|
1182
|
-
const nextEffort = (item.reasoning && item.reasoning.defaultEffort) || "";
|
|
1183
|
-
setProvider(item.provider);
|
|
1184
|
-
setModel(item.model);
|
|
1185
|
-
setEffort(nextEffort);
|
|
1186
|
-
save({ provider: item.provider, model: item.model, reasoningEffort: nextEffort || null });
|
|
1187
|
-
setOpen("");
|
|
1188
|
-
},
|
|
1189
|
-
})),
|
|
1190
|
-
))
|
|
1191
|
-
),
|
|
1192
|
-
modelPane === "effort" && efforts.map((item) => h(ModelChoiceRow, {
|
|
1193
|
-
key: item.id,
|
|
1194
|
-
label: item.name,
|
|
1195
|
-
description: item.description,
|
|
1196
|
-
active: item.id === effectiveEffort,
|
|
1197
|
-
onClick: () => {
|
|
1198
|
-
setEffort(item.id);
|
|
1199
|
-
if (provider && model) save({ provider, model, reasoningEffort: item.id || null });
|
|
1200
|
-
setOpen("");
|
|
1201
|
-
},
|
|
1202
|
-
})),
|
|
1203
|
-
),
|
|
1204
|
-
),
|
|
1205
|
-
),
|
|
1206
|
-
adding && h("div", { className: "ima-chip-dialog" },
|
|
1207
|
-
h("strong", null, t("composer.addWorkspace")),
|
|
1208
|
-
h("input", {
|
|
1209
|
-
value: addPath,
|
|
1210
|
-
placeholder: t("composer.workspacePath"),
|
|
1211
|
-
"aria-label": t("composer.workspacePath"),
|
|
1212
|
-
onChange: (event) => setAddPath(event.target.value),
|
|
1213
|
-
}),
|
|
1214
|
-
h("div", { className: "ima-chip-dialog-actions" },
|
|
1215
|
-
h("button", { className: "ima-btn", onClick: () => { setAdding(false); setAddPath(""); } }, t("action.cancel")),
|
|
1216
|
-
h("button", {
|
|
1217
|
-
className: "ima-btn primary",
|
|
1218
|
-
disabled: addBusy || !addPath.trim(),
|
|
1219
|
-
onClick: () => addWorkspace(addPath),
|
|
1220
|
-
}, addBusy ? t("action.adding") : t("action.confirm")),
|
|
1221
|
-
),
|
|
1222
|
-
),
|
|
1223
|
-
hint && h("div", { className: "ima-composer-hint" }, hint),
|
|
1224
|
-
h(RiskConfirmation, {
|
|
1225
|
-
open: confirmingFullAccess,
|
|
1226
|
-
title: props.permissionT("confirm.title"),
|
|
1227
|
-
description: props.permissionT("confirm.description"),
|
|
1228
|
-
acknowledgeLabel: props.permissionT("confirm.acknowledge"),
|
|
1229
|
-
cancelLabel: props.permissionT("confirm.cancel"),
|
|
1230
|
-
confirmLabel: props.permissionT("confirm.enable"),
|
|
1231
|
-
acknowledged: fullAccessAcknowledged,
|
|
1232
|
-
onAcknowledgedChange: setFullAccessAcknowledged,
|
|
1233
|
-
onCancel: () => { setFullAccessAcknowledged(false); setConfirmingFullAccess(false); },
|
|
1234
|
-
onConfirm: () => {
|
|
1235
|
-
setPermission("danger-full-access");
|
|
1236
|
-
save({ permission: "danger-full-access" });
|
|
1237
|
-
setFullAccessAcknowledged(false);
|
|
1238
|
-
setConfirmingFullAccess(false);
|
|
1239
|
-
},
|
|
1240
|
-
}),
|
|
1241
|
-
);
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
976
|
function AccountInspector({ account, catalog, permissions, workspaces, createWorkspace, pickDirectory, modelT, permissionT, t, onAction, onSave }) {
|
|
1245
977
|
const [draft, setDraft] = useState(account);
|
|
1246
978
|
const [note, setNote] = useState("");
|
|
@@ -1772,19 +1504,19 @@ window.__ModuleLoader__.load({
|
|
|
1772
1504
|
body: JSON.stringify(Object.assign({ sessionId: sess.sessionId }, extra || {})),
|
|
1773
1505
|
}).then((data) => { if (data.ok) syncList(data.groups); }).catch(() => undefined);
|
|
1774
1506
|
if (action === "rename" && typeof acts.renameSession === "function") {
|
|
1775
|
-
Promise.resolve(acts.renameSession(sess.sessionId, (extra && extra.title) || title)).then(afterHost).catch(
|
|
1507
|
+
Promise.resolve(acts.renameSession(sess.sessionId, (extra && extra.title) || title)).then(afterHost).catch((error) => console.warn("[dsh-im-connect] 重命名失败", error));
|
|
1776
1508
|
return;
|
|
1777
1509
|
}
|
|
1778
1510
|
if (action === "archive") {
|
|
1779
1511
|
if (typeof acts.archiveSession === "function") {
|
|
1780
|
-
Promise.resolve(acts.archiveSession(sess.sessionId)).then(afterHost).catch(
|
|
1512
|
+
Promise.resolve(acts.archiveSession(sess.sessionId)).then(afterHost).catch((error) => console.warn("[dsh-im-connect] 归档失败", error));
|
|
1781
1513
|
} else {
|
|
1782
|
-
|
|
1514
|
+
console.warn("[dsh-im-connect] 当前宿主未提供归档接口");
|
|
1783
1515
|
}
|
|
1784
1516
|
return;
|
|
1785
1517
|
}
|
|
1786
1518
|
if ((action === "delete" || action === "remove") && typeof acts.deleteSession === "function") {
|
|
1787
|
-
Promise.resolve(acts.deleteSession(sess.sessionId)).then(() => afterHost()).catch(() =>
|
|
1519
|
+
Promise.resolve(acts.deleteSession(sess.sessionId)).then(() => afterHost()).catch((error) => console.warn("[dsh-im-connect] 删除失败", error));
|
|
1788
1520
|
return;
|
|
1789
1521
|
}
|
|
1790
1522
|
if (action === "fork" && typeof acts.forkSession === "function") {
|
|
@@ -1928,7 +1660,13 @@ window.__ModuleLoader__.load({
|
|
|
1928
1660
|
}, [openMenu]);
|
|
1929
1661
|
const needle = query.trim().toLowerCase();
|
|
1930
1662
|
const visibleGroups = groups.map((g) => {
|
|
1931
|
-
const sessions = (g.sessions || []).
|
|
1663
|
+
const sessions = (g.sessions || []).map((sess) => {
|
|
1664
|
+
const host = props.sessionById && props.sessionById[sess.sessionId];
|
|
1665
|
+
// 手动标题及来源未知的旧名称,交给后端可靠标题事件同步。
|
|
1666
|
+
if (sess.titleSource === "user" || (!sess.titleSource && typeof sess.title === "string" && sess.title.trim())) return sess;
|
|
1667
|
+
return host && typeof host.title === "string" && host.title.trim()
|
|
1668
|
+
? Object.assign({}, sess, { title: host.title }) : sess;
|
|
1669
|
+
}).filter((sess) => !archived.has(sess.sessionId));
|
|
1932
1670
|
if (!needle) return Object.assign({}, g, { sessions });
|
|
1933
1671
|
const nameHit = String(channelLabel(g, t)).toLowerCase().includes(needle);
|
|
1934
1672
|
return Object.assign({}, g, { sessions: nameHit ? sessions : sessions.filter((sess) => String(sess.title || sess.chatId || "").toLowerCase().includes(needle)) });
|