@1agents/acp-service 0.11.2 → 0.11.4

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.
Files changed (45) hide show
  1. package/README.md +1 -1
  2. package/dist/src/a2a/executor.js +9 -6
  3. package/dist/src/acp-connection.js +7 -0
  4. package/dist/src/bridge.d.ts +3 -0
  5. package/dist/src/bridge.js +361 -31
  6. package/dist/src/catalog-descriptors.js +2 -2
  7. package/dist/src/catalog.js +26 -7
  8. package/package.json +1 -1
  9. package/skills/acp-service/SKILL.md +8 -4
  10. package/skills/acp-service/references/a2a.md +15 -2
  11. package/skills/acp-service/references/acp.md +2 -0
  12. package/skills/acp-service/references/roles-and-tasks.md +1 -1
  13. package/vendor/dsh/README.md +1 -1
  14. package/vendor/dsh/adapter.js +23 -0
  15. package/vendor/dsh/client.js +1827 -280
  16. package/vendor/dsh/session-settings.js +22 -3
  17. package/vendor/dsh/transport.d.ts +1 -0
  18. package/vendor/dsh/transport.js +4 -0
  19. package/vendor/runtime/dist/{agent-registry-CsdsVpJb.js → agent-registry-C6ejwCZj.js} +2 -2
  20. package/vendor/runtime/dist/agent-registry-C6ejwCZj.js.map +1 -0
  21. package/vendor/runtime/dist/agent-registry.d.ts.map +1 -1
  22. package/vendor/runtime/dist/agent-registry.js +1 -1
  23. package/vendor/runtime/dist/{cli-B5gQOSDl.js → cli-tuiWjPY4.js} +4 -4
  24. package/vendor/runtime/dist/{cli-B5gQOSDl.js.map → cli-tuiWjPY4.js.map} +1 -1
  25. package/vendor/runtime/dist/cli.js +10 -10
  26. package/vendor/runtime/dist/client-D5y4RXME.d.ts.map +1 -1
  27. package/vendor/runtime/dist/{flows-CDj5YcTh.js → flows-7g_AQzTI.js} +5 -5
  28. package/vendor/runtime/dist/{flows-CDj5YcTh.js.map → flows-7g_AQzTI.js.map} +1 -1
  29. package/vendor/runtime/dist/flows.js +1 -1
  30. package/vendor/runtime/dist/{input-file-BsfVGZgn.js → input-file-CtXEzLxj.js} +5 -5
  31. package/vendor/runtime/dist/{input-file-BsfVGZgn.js.map → input-file-CtXEzLxj.js.map} +1 -1
  32. package/vendor/runtime/dist/{ipc-DfqJsbk6.js → ipc-CcrTSAL7.js} +7 -2
  33. package/vendor/runtime/dist/ipc-CcrTSAL7.js.map +1 -0
  34. package/vendor/runtime/dist/{output-DOIF4iFc.js → output-CQBC8OMR.js} +3 -3
  35. package/vendor/runtime/dist/{output-DOIF4iFc.js.map → output-CQBC8OMR.js.map} +1 -1
  36. package/vendor/runtime/dist/{queue-owner-runtime-DHBQbjXo.js → queue-owner-runtime-BnqiTiN1.js} +5 -4
  37. package/vendor/runtime/dist/queue-owner-runtime-BnqiTiN1.js.map +1 -0
  38. package/vendor/runtime/dist/runtime.js +4 -4
  39. package/vendor/runtime/dist/{session-watch-DRwFHcWw.js → session-watch-BYRZyCfk.js} +4 -4
  40. package/vendor/runtime/dist/{session-watch-DRwFHcWw.js.map → session-watch-BYRZyCfk.js.map} +1 -1
  41. package/vendor/runtime/dist/{watch-CUDGkljG.js → watch-DltPDEQ0.js} +2 -2
  42. package/vendor/runtime/dist/{watch-CUDGkljG.js.map → watch-DltPDEQ0.js.map} +1 -1
  43. package/vendor/runtime/dist/agent-registry-CsdsVpJb.js.map +0 -1
  44. package/vendor/runtime/dist/ipc-DfqJsbk6.js.map +0 -1
  45. package/vendor/runtime/dist/queue-owner-runtime-DHBQbjXo.js.map +0 -1
@@ -1,10 +1,8 @@
1
1
  window.__ModuleLoader__.load({id:"@1agents/acp-service",dependencies:["react"],factory:(require)=>{var module={exports:{}};var exports=module.exports;
2
2
  "use strict";
3
- var __create = Object.create;
4
3
  var __defProp = Object.defineProperty;
5
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
7
  var __export = (target, all) => {
10
8
  for (var name in all)
@@ -18,14 +16,6 @@ var __copyProps = (to, from, except, desc) => {
18
16
  }
19
17
  return to;
20
18
  };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
20
 
31
21
  // src/client.js
@@ -38,236 +28,1751 @@ __export(client_exports, {
38
28
  module.exports = __toCommonJS(client_exports);
39
29
  var import_react2 = require("react");
40
30
 
41
- // src/tool-conversation.js
42
- var names = { execute: "Bash", read: "Read", edit: "Edit", delete: "Delete", move: "Move", search: "Search", fetch: "Fetch", think: "Think" };
43
- function contentOf(tool) {
44
- const content = (tool.content ?? []).flatMap((item) => {
45
- if (item.type === "content" && item.content.type === "text") return [item.content];
46
- if (item.type === "diff") return [{ type: "text", text: `${item.path}
47
- ---
48
- ${item.oldText ?? ""}
49
- +++
50
- ${item.newText}` }];
51
- return [];
31
+ // src/model-select.js
32
+ var import_react = require("react");
33
+ function loadOptional(loader) {
34
+ try {
35
+ return loader();
36
+ } catch {
37
+ return void 0;
38
+ }
39
+ }
40
+ var reactDom = loadOptional(() => require("react-dom"));
41
+ var uiPrimitives = loadOptional(() => require("@deepseek-ai/dsh-client-ui-primitives"));
42
+ var useSafeLayoutEffect = import_react.useLayoutEffect ?? import_react.useEffect;
43
+ function cx(...names) {
44
+ return names.filter(Boolean).join(" ");
45
+ }
46
+ function formatCopy(t, key, params) {
47
+ let text = String(t(key, params));
48
+ if (params) {
49
+ for (const [name, value] of Object.entries(params)) {
50
+ text = text.replaceAll(`{${name}}`, String(value));
51
+ }
52
+ }
53
+ return text;
54
+ }
55
+ function orderModelProviders(groups) {
56
+ const rank = (id) => id === "deepseek-account" ? 0 : id === "deepseek-official" ? 1 : 2;
57
+ return [...groups ?? []].sort((left, right) => rank(left.id) - rank(right.id));
58
+ }
59
+ function resolveLocalizedText(locale, text) {
60
+ if (text == null) return "";
61
+ if (typeof locale?.resolveText === "function") return locale.resolveText(text);
62
+ if (typeof text === "string") return text;
63
+ if (typeof text === "object") {
64
+ const lang = typeof document !== "undefined" ? document.documentElement?.lang?.toLowerCase() ?? "" : "";
65
+ const short = lang.split("-")[0];
66
+ if (short && typeof text[short] === "string") return text[short];
67
+ if (typeof text.zh === "string") return text.zh;
68
+ if (typeof text.en === "string") return text.en;
69
+ const first = Object.values(text).find((value) => typeof value === "string");
70
+ if (first !== void 0) return first;
71
+ }
72
+ return String(text);
73
+ }
74
+ function fallbackRankByName(items, rawQuery) {
75
+ const query = String(rawQuery ?? "").trim().toLowerCase();
76
+ if (!query) return items;
77
+ const matched = [];
78
+ for (let i = 0; i < items.length; i++) {
79
+ const item = items[i];
80
+ const name = String(item?.name ?? "").toLowerCase();
81
+ if (name.startsWith(query)) {
82
+ matched.push({ item, score: 0, index: i });
83
+ continue;
84
+ }
85
+ const sub = name.indexOf(query);
86
+ if (sub !== -1) {
87
+ matched.push({ item, score: 1 + sub / 1e3, index: i });
88
+ continue;
89
+ }
90
+ let qi = 0;
91
+ for (let ni = 0; ni < name.length && qi < query.length; ni++) {
92
+ if (name[ni] === query[qi]) qi++;
93
+ }
94
+ if (qi === query.length) matched.push({ item, score: 2, index: i });
95
+ }
96
+ matched.sort((a, b) => a.score - b.score || a.index - b.index);
97
+ return matched.map((entry) => entry.item);
98
+ }
99
+ var rankByName = typeof uiPrimitives?.rankByName === "function" ? uiPrimitives.rankByName : fallbackRankByName;
100
+ var isMobileDevice = typeof uiPrimitives?.isMobileDevice === "function" ? uiPrimitives.isMobileDevice : () => false;
101
+ var observeStickyMenuGroups = typeof uiPrimitives?.observeStickyMenuGroups === "function" ? uiPrimitives.observeStickyMenuGroups : () => () => {
102
+ };
103
+ function FallbackIconChevronDown({ className }) {
104
+ return (0, import_react.createElement)(
105
+ "svg",
106
+ { className, width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true" },
107
+ (0, import_react.createElement)("path", { d: "M3 4.5L6 7.5L9 4.5", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round" })
108
+ );
109
+ }
110
+ function FallbackIconChevronRight({ className }) {
111
+ return (0, import_react.createElement)(
112
+ "svg",
113
+ { className, width: 12, height: 12, viewBox: "0 0 12 12", fill: "none", "aria-hidden": "true" },
114
+ (0, import_react.createElement)("path", { d: "M4.5 3L7.5 6L4.5 9", stroke: "currentColor", strokeWidth: 1.4, strokeLinecap: "round", strokeLinejoin: "round" })
115
+ );
116
+ }
117
+ function FallbackIconCheck() {
118
+ return (0, import_react.createElement)(
119
+ "svg",
120
+ { width: 14, height: 14, viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true" },
121
+ (0, import_react.createElement)("path", { d: "M3 7.3L5.7 10L11 4.5", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" })
122
+ );
123
+ }
124
+ function FallbackIconClose() {
125
+ return (0, import_react.createElement)("span", { "aria-hidden": "true" }, "\xD7");
126
+ }
127
+ function FallbackIconData({ className, size = 16 }) {
128
+ return (0, import_react.createElement)(
129
+ "svg",
130
+ { className, width: size, height: size, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true" },
131
+ (0, import_react.createElement)("circle", { cx: 8, cy: 8, r: 5.5, stroke: "currentColor", strokeWidth: 1.3 })
132
+ );
133
+ }
134
+ function FallbackIconWarning() {
135
+ return (0, import_react.createElement)("span", { "aria-hidden": "true" }, "!");
136
+ }
137
+ function FallbackMenuGroup({ label, children }) {
138
+ return (0, import_react.createElement)(
139
+ "div",
140
+ { className: "oacp-ms-fallbackGroup" },
141
+ (0, import_react.createElement)("div", { className: "oacp-ms-fallbackGroupLabel" }, label),
142
+ children
143
+ );
144
+ }
145
+ function FallbackTag({ className, children }) {
146
+ return (0, import_react.createElement)("span", { className: cx("oacp-ms-fallbackTag", className) }, children);
147
+ }
148
+ function FallbackStateDot() {
149
+ return (0, import_react.createElement)("span", { className: "oacp-ms-fallbackDot", "aria-hidden": "true" }, "\u2026");
150
+ }
151
+ function FallbackToast({ text }) {
152
+ return (0, import_react.createElement)("div", { role: "alert", className: "oacp-ms-error" }, text);
153
+ }
154
+ var MenuSurfaceComp = uiPrimitives?.MenuSurface ?? "div";
155
+ var MenuGroupComp = uiPrimitives?.MenuGroup ?? FallbackMenuGroup;
156
+ var InputComp = uiPrimitives?.Input ?? "input";
157
+ var TagComp = uiPrimitives?.Tag ?? FallbackTag;
158
+ var ToastComp = uiPrimitives?.Toast ?? FallbackToast;
159
+ var StateDotComp = uiPrimitives?.StateDot ?? FallbackStateDot;
160
+ var IconCheckComp = uiPrimitives?.IconCheckOutlineRegular ?? FallbackIconCheck;
161
+ var IconChevronDownComp = uiPrimitives?.IconChevronDownOutlineRegular ?? FallbackIconChevronDown;
162
+ var IconChevronRightComp = uiPrimitives?.IconChevronRightOutlineRegular ?? FallbackIconChevronRight;
163
+ var IconCloseComp = uiPrimitives?.IconCloseFillRegular ?? FallbackIconClose;
164
+ var IconDataComp = uiPrimitives?.IconDataOutlineRegular ?? FallbackIconData;
165
+ var IconWarningComp = uiPrimitives?.IconWarningOutlineRegular ?? FallbackIconWarning;
166
+ function getModelCommandIcon() {
167
+ return uiPrimitives?.IconDataOutlineRegular;
168
+ }
169
+ var MODEL_SELECT_CSS = `
170
+ .oacp-ms-root {
171
+ position: relative;
172
+ min-width: 0;
173
+ }
174
+ .oacp-ms-trigger {
175
+ anchor-name: var(--dsh-model-anchor);
176
+ display: flex;
177
+ align-items: center;
178
+ gap: 4px;
179
+ min-width: 0;
180
+ max-width: 360px;
181
+ height: 28px;
182
+ padding: 0 4px 0 8px;
183
+ border: none;
184
+ border-radius: var(--dsw-radius-sm, 6px);
185
+ outline: none;
186
+ background: transparent;
187
+ color: var(--dsw-alias-label-secondary, inherit);
188
+ font-size: 13px;
189
+ line-height: 20px;
190
+ font-weight: 400;
191
+ cursor: pointer;
192
+ }
193
+ @media (hover: hover) {
194
+ .oacp-ms-trigger:hover:not(:disabled) {
195
+ background: var(--dsw-alias-interactive-bg-hover);
196
+ }
197
+ }
198
+ .oacp-ms-trigger:focus-visible:not([data-selection-focus]) {
199
+ box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
200
+ }
201
+ .oacp-ms-trigger:disabled {
202
+ color: var(--dsw-alias-label-dimmed);
203
+ cursor: default;
204
+ }
205
+ .oacp-ms-triggerLabel {
206
+ min-width: 0;
207
+ overflow: hidden;
208
+ text-overflow: ellipsis;
209
+ white-space: nowrap;
210
+ }
211
+ .oacp-ms-triggerEffort {
212
+ flex-shrink: 1000;
213
+ min-width: 0;
214
+ overflow: hidden;
215
+ text-overflow: ellipsis;
216
+ white-space: nowrap;
217
+ color: var(--dsw-alias-label-caption);
218
+ }
219
+ .oacp-ms-triggerIcon {
220
+ display: var(--dsh-composer-model-icon-display, none);
221
+ flex: 0 0 auto;
222
+ }
223
+ .oacp-ms-triggerLabel,
224
+ .oacp-ms-triggerEffort {
225
+ display: var(--dsh-composer-model-text-display, block);
226
+ }
227
+ .oacp-ms-chevron {
228
+ flex: 0 0 auto;
229
+ color: var(--dsw-alias-label-caption);
230
+ transition: transform 120ms ease;
231
+ }
232
+ .oacp-ms-chevronOpen {
233
+ transform: rotate(180deg);
234
+ }
235
+ .oacp-ms-menu {
236
+ box-sizing: border-box;
237
+ position: fixed;
238
+ position-anchor: var(--dsh-model-anchor);
239
+ top: max(12px, var(--dsh-frame-overlay-top, 12px));
240
+ left: 12px;
241
+ right: anchor(right);
242
+ bottom: calc(anchor(top) + 8px);
243
+ align-self: safe end;
244
+ justify-self: safe end;
245
+ margin: 0;
246
+ z-index: 1100;
247
+ display: flex;
248
+ flex-direction: column;
249
+ width: fit-content;
250
+ height: fit-content;
251
+ min-width: min(240px, calc(100vw - 24px));
252
+ max-width: min(420px, calc(100vw - 24px));
253
+ max-height: min(360px, calc(100dvh - 96px));
254
+ overflow: hidden;
255
+ padding: 4px;
256
+ border: 0;
257
+ --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
258
+ box-shadow: var(--dsw-elevation-prominent);
259
+ color: var(--dsw-alias-label-primary);
260
+ --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
261
+ --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
262
+ }
263
+ .oacp-ms-status,
264
+ .oacp-ms-empty {
265
+ padding: 8px;
266
+ color: var(--dsw-alias-label-tertiary);
267
+ font-size: 12px;
268
+ line-height: 18px;
269
+ }
270
+ .oacp-ms-error,
271
+ .oacp-ms-warning {
272
+ display: flex;
273
+ align-items: flex-start;
274
+ justify-content: space-between;
275
+ gap: 6px;
276
+ margin-bottom: 3px;
277
+ padding: 6px 7px;
278
+ border-radius: var(--dsw-radius-md, 8px);
279
+ background: var(--dsw-alias-interactive-bg-hover-danger);
280
+ color: var(--dsw-alias-state-error-primary);
281
+ font-size: 11px;
282
+ line-height: 16px;
283
+ }
284
+ .oacp-ms-warning {
285
+ background: var(--dsw-alias-bg-module-platform);
286
+ color: var(--dsw-alias-state-warn-label);
287
+ }
288
+ .oacp-ms-retry {
289
+ flex: 0 0 auto;
290
+ padding: 0;
291
+ border: none;
292
+ background: transparent;
293
+ color: inherit;
294
+ font: inherit;
295
+ font-weight: 600;
296
+ cursor: pointer;
297
+ }
298
+ .oacp-ms-searchRow {
299
+ position: relative;
300
+ flex-shrink: 0;
301
+ margin: 2px 0 3px;
302
+ }
303
+ .oacp-ms-searchRow .oacp-ms-search {
304
+ display: flex;
305
+ height: auto;
306
+ padding: 5px 7px;
307
+ border: 0 solid transparent;
308
+ border-radius: var(--dsw-radius-md, 8px);
309
+ background: transparent;
310
+ }
311
+ .oacp-ms-searchRow .oacp-ms-searchWithQuery {
312
+ padding-right: 34px;
313
+ }
314
+ .oacp-ms-searchClear {
315
+ position: absolute;
316
+ top: 50%;
317
+ right: 4px;
318
+ transform: translateY(-50%);
319
+ display: inline-flex;
320
+ align-items: center;
321
+ justify-content: center;
322
+ width: 24px;
323
+ height: 24px;
324
+ padding: 0;
325
+ border: none;
326
+ border-radius: 50%;
327
+ corner-shape: round;
328
+ background: transparent;
329
+ color: var(--dsw-alias-label-secondary);
330
+ cursor: pointer;
331
+ }
332
+ .oacp-ms-searchClear:focus-visible {
333
+ outline: none;
334
+ background: var(--dsw-alias-interactive-bg-hover);
335
+ }
336
+ @media (hover: hover) {
337
+ .oacp-ms-searchClear:hover {
338
+ outline: none;
339
+ background: var(--dsw-alias-interactive-bg-hover);
340
+ }
341
+ }
342
+ .oacp-ms-searchRow .oacp-ms-search:focus-within {
343
+ border-color: transparent;
344
+ }
345
+ .oacp-ms-searchRow .oacp-ms-search input {
346
+ padding: 0;
347
+ font-size: 12px;
348
+ line-height: normal;
349
+ }
350
+ @media (pointer: coarse) {
351
+ .oacp-ms-searchRow .oacp-ms-search input {
352
+ font-size: 16px;
353
+ }
354
+ }
355
+ .oacp-ms-searchRow .oacp-ms-search input::placeholder {
356
+ color: var(--dsw-alias-label-caption);
357
+ }
358
+ .oacp-ms-groups:not([hidden]) {
359
+ min-height: 0;
360
+ overflow-x: hidden;
361
+ overflow-y: auto;
362
+ }
363
+ .oacp-ms-option {
364
+ box-sizing: border-box;
365
+ display: flex;
366
+ align-items: center;
367
+ gap: 6px;
368
+ width: auto;
369
+ min-width: 100%;
370
+ min-height: 34px;
371
+ padding: 5px 7px;
372
+ border: none;
373
+ border-radius: var(--dsw-radius-md, 8px);
374
+ outline: none;
375
+ background: transparent;
376
+ color: inherit;
377
+ text-align: left;
378
+ cursor: pointer;
379
+ }
380
+ .oacp-ms-option:focus-visible,
381
+ .oacp-ms-optionActive:not(:disabled) {
382
+ background: var(--dsw-alias-interactive-bg-hover);
383
+ }
384
+ .oacp-ms-modelOption {
385
+ max-width: 100%;
386
+ }
387
+ @media (hover: hover) {
388
+ .oacp-ms-option:not(.oacp-ms-modelOption):hover:not(:disabled) {
389
+ background: var(--dsw-alias-interactive-bg-hover);
390
+ }
391
+ }
392
+ .oacp-ms-selected {
393
+ background: transparent;
394
+ }
395
+ .oacp-ms-option:disabled {
396
+ color: var(--dsw-alias-label-dimmed);
397
+ cursor: default;
398
+ }
399
+ .oacp-ms-optionCopy {
400
+ display: flex;
401
+ flex: 1;
402
+ flex-direction: column;
403
+ min-width: 0;
404
+ }
405
+ .oacp-ms-modelName {
406
+ overflow: hidden;
407
+ color: inherit;
408
+ font-size: 13px;
409
+ line-height: 18px;
410
+ font-weight: 400;
411
+ text-overflow: ellipsis;
412
+ white-space: nowrap;
413
+ }
414
+ .oacp-ms-badgedName {
415
+ display: inline-flex;
416
+ align-items: center;
417
+ max-width: 100%;
418
+ gap: 4px;
419
+ vertical-align: baseline;
420
+ white-space: nowrap;
421
+ }
422
+ .oacp-ms-badgedNameText {
423
+ min-width: 0;
424
+ overflow: hidden;
425
+ text-overflow: ellipsis;
426
+ }
427
+ .oacp-ms-badge {
428
+ flex: none;
429
+ }
430
+ .oacp-ms-check {
431
+ display: grid;
432
+ place-items: center;
433
+ flex: 0 0 14px;
434
+ color: var(--dsw-alias-label-primary);
435
+ }
436
+ .oacp-ms-check svg {
437
+ width: 14px;
438
+ height: 14px;
439
+ }
440
+ .oacp-ms-cell {
441
+ box-sizing: border-box;
442
+ display: flex;
443
+ align-items: center;
444
+ gap: 6px;
445
+ width: auto;
446
+ min-width: 100%;
447
+ height: 34px;
448
+ padding: 0 8px;
449
+ border: none;
450
+ border-radius: var(--dsw-radius-md, 8px);
451
+ background: transparent;
452
+ color: var(--dsw-alias-label-primary);
453
+ font-size: 13px;
454
+ line-height: 20px;
455
+ cursor: pointer;
456
+ text-align: left;
457
+ outline: none;
458
+ }
459
+ .oacp-ms-cell:focus-visible {
460
+ background: var(--dsw-alias-interactive-bg-hover);
461
+ }
462
+ @media (hover: hover) {
463
+ .oacp-ms-cell:hover {
464
+ background: var(--dsw-alias-interactive-bg-hover);
465
+ }
466
+ }
467
+ .oacp-ms-cellLabel {
468
+ flex: 0 0 auto;
469
+ white-space: nowrap;
470
+ }
471
+ .oacp-ms-cellValue {
472
+ flex: 1 1 auto;
473
+ min-width: 0;
474
+ overflow: hidden;
475
+ text-overflow: ellipsis;
476
+ white-space: nowrap;
477
+ text-align: right;
478
+ color: var(--dsw-alias-label-tertiary);
479
+ }
480
+ .oacp-ms-cellChevron {
481
+ flex: 0 0 auto;
482
+ width: 12px;
483
+ height: 12px;
484
+ color: var(--dsw-alias-menu-icon);
485
+ }
486
+ .oacp-ms-fallbackGroupLabel {
487
+ padding: 6px 8px 2px;
488
+ font-size: 11px;
489
+ color: var(--dsw-alias-label-tertiary);
490
+ }
491
+ .oacp-ms-fallbackTag {
492
+ display: inline-flex;
493
+ align-items: center;
494
+ padding: 0 5px;
495
+ border-radius: 4px;
496
+ font-size: 11px;
497
+ line-height: 16px;
498
+ background: var(--dsw-alias-interactive-bg-hover, rgba(128, 128, 128, 0.14));
499
+ }
500
+ `;
501
+ function installModelSelectStyles(ctx) {
502
+ ctx.effect(() => {
503
+ if (typeof document === "undefined" || !document.head) return () => {
504
+ };
505
+ const style = document.createElement("style");
506
+ style.textContent = MODEL_SELECT_CSS;
507
+ document.head.append(style);
508
+ return () => style.remove();
52
509
  });
53
- if (content.length || tool.rawOutput == null) return content;
54
- return [{ type: "text", text: typeof tool.rawOutput === "string" ? tool.rawOutput : JSON.stringify(tool.rawOutput, null, 2) }];
55
- }
56
- function rootOf(state, location) {
57
- const { tool, requestId, turn, step } = state.data;
58
- const name = tool.name && tool.name !== "Tool" ? tool.name : names[tool.kind] ?? tool.title ?? tool.name ?? "Tool";
59
- const input = tool.rawInput ?? (tool.locations?.[0]?.path ? { path: tool.locations[0].path } : tool.title ? { description: tool.title } : {});
60
- const argsRaw = JSON.stringify(input);
61
- const head = { callId: `${requestId}:${tool.toolCallId}`, name, argsRaw, turn, step, time: state.time, subCalls: [] };
62
- const settled = tool.status === "completed" || tool.status === "failed";
63
- const closed = location?.kind === "step" && location.step.status === "closed" ? location.step.end : (location?.kind === "step" || location?.kind === "turn") && location.turn.status === "closed" ? location.turn.end : void 0;
64
- if (!settled && !closed) return { ...head, phase: "start" };
510
+ }
511
+ function createModelCatalogStore(ctx) {
512
+ let snapshot = { value: null, status: "idle", error: null };
513
+ let generation = 0;
514
+ let inflight;
515
+ let disposed = false;
516
+ const listeners = /* @__PURE__ */ new Set();
517
+ const reasoningByKey = /* @__PURE__ */ new Map();
518
+ const notify = () => {
519
+ for (const listener of listeners) listener();
520
+ };
521
+ const setSnapshot = (next) => {
522
+ snapshot = next;
523
+ notify();
524
+ };
525
+ const load = () => {
526
+ if (snapshot.status === "ready" && snapshot.value !== null) return Promise.resolve(snapshot.value);
527
+ if (inflight !== void 0) return inflight;
528
+ const currentGen = generation;
529
+ setSnapshot({ ...snapshot, status: "loading", error: null });
530
+ const operation = ctx.remote.session.modelCatalog().then((response) => {
531
+ if (!response.ok) throw new Error(`${response.error.code ? `${response.error.code}: ` : ""}${response.error.message}`);
532
+ if (!disposed && currentGen === generation) {
533
+ for (const group of response.value.groups ?? []) {
534
+ for (const model of group.models ?? []) {
535
+ reasoningByKey.set(JSON.stringify([group.id, model.id]), model.reasoning);
536
+ }
537
+ }
538
+ setSnapshot({ value: response.value, status: "ready", error: null });
539
+ }
540
+ return response.value;
541
+ }).catch((error) => {
542
+ if (!disposed && currentGen === generation) {
543
+ setSnapshot({ ...snapshot, status: "error", error: error instanceof Error ? error.message : String(error) });
544
+ }
545
+ throw error;
546
+ }).finally(() => {
547
+ if (currentGen === generation && inflight === operation) inflight = void 0;
548
+ });
549
+ inflight = operation;
550
+ return operation;
551
+ };
552
+ const invalidate = (clear = false) => {
553
+ generation += 1;
554
+ inflight = void 0;
555
+ setSnapshot({ value: clear ? null : snapshot.value, status: "idle", error: null });
556
+ };
557
+ const refresh = () => {
558
+ invalidate(false);
559
+ void load().catch(() => {
560
+ });
561
+ };
562
+ const resetGeneration = () => {
563
+ reasoningByKey.clear();
564
+ invalidate(true);
565
+ if (listeners.size > 0) void load().catch(() => {
566
+ });
567
+ };
568
+ ctx.effect(() => () => {
569
+ disposed = true;
570
+ listeners.clear();
571
+ });
572
+ ctx.remote.$on("llm/adapters-updated", refresh);
573
+ ctx.remote.$on("llm/models-updated", refresh);
574
+ ctx.remote.$on("settings/document-updated", refresh);
575
+ ctx.remote.$on("credentials/record-updated", refresh);
576
+ ctx.remote.$on("credentials/reference-updated", refresh);
65
577
  return {
66
- kind: "tool-result",
67
- seq: state.seq,
68
- time: settled ? state.updatedAt : closed.time,
69
- callId: head.callId,
70
- call: { name, argsRaw },
71
- callTime: state.time,
72
- content: contentOf(tool),
73
- isError: tool.status === "failed" || !settled,
74
- ...!settled ? { error: { name: "Interrupted", code: "interrupted" } } : {},
75
- meta: { acp: tool },
76
- subCalls: []
77
- };
78
- }
79
- function records(event) {
80
- if (event.type === "assistant/live-chunk") return [{ chunk: event.data.chunk, time: event.time }];
81
- if (event.type === "assistant/message" || event.type === "assistant/attempt") return (event.data.stream ?? []).filter((record) => record.type === "chunk");
82
- return [];
83
- }
84
- function fold(previous, match) {
85
- const event = match.event;
86
- const replay = event.type !== "assistant/live-chunk";
87
- const state = {
88
- blocks: new Map(replay ? void 0 : previous?.blocks),
89
- tools: new Map(replay ? void 0 : previous?.tools),
90
- acp: previous?.acp ?? false,
91
- seq: previous?.seq ?? event.seq,
92
- final: event.type === "assistant/message" || previous?.final === true
93
- };
94
- for (const { chunk, time } of records(event)) {
95
- if (chunk.acpStream || chunk.block?.acpTool) state.acp = true;
96
- const index = chunk.index;
97
- if (chunk.type === "block-start" && (chunk.blockType === "text" || chunk.blockType === "reasoning")) {
98
- state.blocks.set(index, { kind: chunk.blockType, text: "" });
99
- } else if (chunk.type === "text-delta" || chunk.type === "reasoning-delta") {
100
- const kind = chunk.type === "text-delta" ? "text" : "reasoning";
101
- const current = state.blocks.get(index);
102
- state.blocks.set(index, { kind, text: (current?.kind === kind ? current.text : "") + chunk.text });
103
- } else if (chunk.type === "block-end") {
104
- const data = chunk.block.acpTool;
105
- if (data) {
106
- const current = state.tools.get(data.tool.toolCallId);
107
- state.blocks.delete(index);
108
- if (current && current.data.sequence >= data.sequence) continue;
109
- const position = current?.index ?? index;
110
- state.blocks.set(position, { kind: "tool", id: data.tool.toolCallId });
111
- state.tools.set(data.tool.toolCallId, { data, index: position, seq: current?.seq ?? event.seq, time: current?.time ?? time, updatedAt: time });
112
- } else if (chunk.block.type === "text" || chunk.block.type === "reasoning") {
113
- state.blocks.set(index, { kind: chunk.block.type, text: chunk.block.text });
578
+ subscribe: (listener) => {
579
+ listeners.add(listener);
580
+ return () => {
581
+ listeners.delete(listener);
582
+ };
583
+ },
584
+ getSnapshot: () => snapshot,
585
+ reasoningFor: (selection) => selection ? reasoningByKey.get(JSON.stringify([selection.provider, selection.model])) : void 0,
586
+ load,
587
+ refresh,
588
+ resetGeneration
589
+ };
590
+ }
591
+ function renderPortal(node) {
592
+ if (typeof reactDom?.createPortal === "function" && typeof document !== "undefined" && document.body) {
593
+ return reactDom.createPortal(node, document.body);
594
+ }
595
+ return node;
596
+ }
597
+ function StandardModelSelect({
598
+ sessionId,
599
+ locked,
600
+ projected,
601
+ catalogStore,
602
+ selectModel,
603
+ resolveText,
604
+ renderSlot,
605
+ t
606
+ }) {
607
+ const catalogState = (0, import_react.useSyncExternalStore)(
608
+ (fn) => catalogStore.subscribe(fn),
609
+ () => catalogStore.getSnapshot()
610
+ );
611
+ const [open, setOpen] = (0, import_react.useState)(false);
612
+ const [pane, setPane] = (0, import_react.useState)("root");
613
+ const [query, setQuery] = (0, import_react.useState)("");
614
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react.useState)(null);
615
+ const [selectionFocus, setSelectionFocus] = (0, import_react.useState)(false);
616
+ const [pending, setPending] = (0, import_react.useState)(null);
617
+ const [toast, setToast] = (0, import_react.useState)(null);
618
+ const lastActionRef = (0, import_react.useRef)("load");
619
+ const toastSeq = (0, import_react.useRef)(0);
620
+ const selectGeneration = (0, import_react.useRef)(0);
621
+ const mountedRef = (0, import_react.useRef)(true);
622
+ const rootRef = (0, import_react.useRef)(null);
623
+ const triggerRef = (0, import_react.useRef)(null);
624
+ const searchRef = (0, import_react.useRef)(null);
625
+ const menuRef = (0, import_react.useRef)(null);
626
+ const groupsRef = (0, import_react.useRef)(null);
627
+ const itemRefs = (0, import_react.useRef)([]);
628
+ const paneFocus = (0, import_react.useRef)(null);
629
+ const rawId = typeof import_react.useId === "function" ? (0, import_react.useId)() : "oacp-ms";
630
+ const anchorStyle = { "--dsh-model-anchor": `--dsh-model-${rawId.replaceAll(":", "")}` };
631
+ const compute = (factory, deps) => typeof import_react.useMemo === "function" ? (0, import_react.useMemo)(factory, deps) : factory();
632
+ const accountProviderName = t("providerAccount");
633
+ const groups = compute(() => orderModelProviders(catalogState.value?.groups ?? []).map((group) => ({
634
+ ...group,
635
+ provider: {
636
+ id: group.id,
637
+ name: group.id === "deepseek-account" ? accountProviderName : group.name
638
+ }
639
+ })), [catalogState.value, accountProviderName]);
640
+ const choices2 = compute(() => groups.flatMap((group) => (group.models ?? []).map((model) => ({
641
+ group,
642
+ model,
643
+ selection: {
644
+ provider: group.id,
645
+ model: model.id,
646
+ ...model.reasoning?.defaultEffort === void 0 ? {} : { reasoningEffort: model.reasoning.defaultEffort }
647
+ }
648
+ }))), [groups]);
649
+ const showSearch = choices2.length > 4;
650
+ const filteredGroups = compute(() => groups.map((group) => ({
651
+ ...group,
652
+ models: rankByName(group.models ?? [], showSearch ? query.trim() : "")
653
+ })).filter((group) => group.models.length > 0), [groups, query, showSearch]);
654
+ const visibleModels = compute(() => filteredGroups.flatMap((group) => group.models.map((model) => ({ provider: group.id, model: model.id }))), [filteredGroups]);
655
+ const rawCurrent = projected?.next ?? catalogState.value?.default ?? null;
656
+ const current = rawCurrent && rawCurrent.provider !== "1agents-acp" ? rawCurrent : null;
657
+ const currentVisibleIndex = visibleModels.findIndex((model) => model.provider === current?.provider && model.model === current?.model);
658
+ const activeModelIndex = Math.min(highlightedIndex ?? Math.max(0, currentVisibleIndex), visibleModels.length - 1);
659
+ const selectedIndex = current === null ? -1 : choices2.findIndex((choice) => choice.selection.provider === current.provider && choice.selection.model === current.model);
660
+ const currentChoice = choices2[selectedIndex];
661
+ const reasoning = currentChoice?.model.reasoning;
662
+ const cachedReasoning = current ? catalogStore.reasoningFor(current) : void 0;
663
+ const effectiveEffort = current?.reasoningEffort ?? reasoning?.defaultEffort;
664
+ const retainedEffortValue = current?.reasoningEffort ?? cachedReasoning?.defaultEffort;
665
+ const retainedEffort = retainedEffortValue === void 0 ? void 0 : cachedReasoning?.efforts?.find((level) => level.id === retainedEffortValue)?.name ?? retainedEffortValue;
666
+ const effortLabel = currentChoice === void 0 ? void 0 : reasoning === void 0 ? retainedEffort : effectiveEffort === void 0 ? t("effortDefault") : reasoning.efforts.find((level) => level.id === effectiveEffort)?.name ?? effectiveEffort;
667
+ const effortChoices = compute(() => reasoning === void 0 ? [] : [
668
+ ...reasoning.defaultEffort === void 0 ? [{ key: "provider-default", effort: void 0, label: t("effortDefault") }] : [],
669
+ ...(reasoning.efforts ?? []).map((effort) => ({
670
+ key: `effort:${effort.id}`,
671
+ effort: effort.id,
672
+ label: effort.name
673
+ }))
674
+ ], [reasoning, t]);
675
+ const failures = catalogState.value?.failures ?? [];
676
+ const busy = pending !== null;
677
+ (0, import_react.useEffect)(() => {
678
+ selectGeneration.current += 1;
679
+ setPending(null);
680
+ setOpen(false);
681
+ setPane("root");
682
+ }, [sessionId]);
683
+ (0, import_react.useEffect)(() => {
684
+ mountedRef.current = true;
685
+ return () => {
686
+ mountedRef.current = false;
687
+ };
688
+ }, []);
689
+ (0, import_react.useEffect)(() => {
690
+ void catalogStore.load().catch(() => {
691
+ });
692
+ }, [catalogStore, sessionId]);
693
+ (0, import_react.useEffect)(() => {
694
+ if (!open || typeof document === "undefined" || typeof document.addEventListener !== "function") return void 0;
695
+ const closeOutside = (event) => {
696
+ if (rootRef.current?.contains?.(event.target) === true) return;
697
+ if (menuRef.current?.contains?.(event.target) === true) return;
698
+ setOpen(false);
699
+ };
700
+ document.addEventListener("mousedown", closeOutside);
701
+ return () => {
702
+ document.removeEventListener("mousedown", closeOutside);
703
+ };
704
+ }, [open]);
705
+ useSafeLayoutEffect(() => {
706
+ if (!showSearch) {
707
+ setQuery("");
708
+ setHighlightedIndex(null);
709
+ }
710
+ }, [showSearch]);
711
+ const previousShowSearch = (0, import_react.useRef)(showSearch);
712
+ (0, import_react.useEffect)(() => {
713
+ const changedSearchMode = previousShowSearch.current !== showSearch;
714
+ previousShowSearch.current = showSearch;
715
+ const intent = paneFocus.current ?? (changedSearchMode && pane === "model" ? "drill" : null);
716
+ paneFocus.current = null;
717
+ if (!open || intent === null) return;
718
+ if (intent === "drill") {
719
+ if (pane === "model" && showSearch && !isMobileDevice()) {
720
+ searchRef.current?.focus?.();
721
+ return;
114
722
  }
723
+ const checked = menuRef.current?.querySelector?.('[role="menuitemradio"][aria-checked="true"]:not([disabled])');
724
+ const target = checked ?? itemRefs.current.find((item) => item != null && !item.disabled);
725
+ (target ?? triggerRef.current)?.focus?.();
726
+ return;
115
727
  }
116
- }
117
- return state;
118
- }
119
- function groupParts(parts) {
120
- const groups = [];
121
- for (const part of parts) {
122
- const last = groups.at(-1);
123
- if (part.kind === "tool") {
124
- if (last?.kind === "tools") last.roots.push(part.root);
125
- else groups.push({ kind: "tools", key: part.root.callId, roots: [part.root] });
126
- } else groups.push(part);
127
- }
128
- return groups;
129
- }
130
- var toolConversationDefinition = {
131
- kind: "oneagents-acp-tools",
132
- target: "chat",
133
- match: (event) => ["assistant/live-chunk", "assistant/message", "assistant/attempt"].includes(event.type) ? { id: `${event.data.turn}:${event.data.step}`, role: "start" } : null,
134
- start: (_context, match) => fold(void 0, match),
135
- update: (context, match) => fold(context.state, match),
136
- publication: () => "immediate",
137
- buildViewNode: (context) => {
138
- const state = context.state;
139
- if (!state?.acp) return null;
140
- const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
141
- const parts = [];
142
- for (const [index, block] of [...state.blocks].sort(([a], [b]) => a - b)) {
143
- if (block.kind === "tool") parts.push({ kind: "tool", root: rootOf(state.tools.get(block.id), location) });
144
- else if (block.text.trim()) {
145
- const last = parts.at(-1);
146
- if (last?.kind === block.kind) last.text += block.text;
147
- else parts.push({ ...block, key: String(index) });
728
+ const cell = itemRefs.current[intent === "effort" ? 1 : 0];
729
+ (cell != null && !cell.disabled ? cell : triggerRef.current)?.focus?.();
730
+ }, [open, pane, showSearch]);
731
+ (0, import_react.useEffect)(() => {
732
+ const viewport = groupsRef.current;
733
+ if (!viewport) return void 0;
734
+ return observeStickyMenuGroups(viewport);
735
+ }, [open, pane, filteredGroups]);
736
+ useSafeLayoutEffect(() => {
737
+ if (open && pane === "model" && activeModelIndex >= 0) {
738
+ itemRefs.current[activeModelIndex]?.scrollIntoView?.({ block: "nearest" });
739
+ }
740
+ }, [open, pane, activeModelIndex, visibleModels]);
741
+ const reload = () => {
742
+ lastActionRef.current = "load";
743
+ void catalogStore.load().catch(() => {
744
+ });
745
+ };
746
+ const forceReload = () => {
747
+ lastActionRef.current = "load";
748
+ catalogStore.refresh();
749
+ };
750
+ const show = () => {
751
+ setSelectionFocus(false);
752
+ triggerRef.current?.focus?.();
753
+ setQuery("");
754
+ setHighlightedIndex(null);
755
+ if (currentChoice === void 0) paneFocus.current = "drill";
756
+ setPane(currentChoice === void 0 ? "model" : "root");
757
+ setOpen(true);
758
+ reload();
759
+ };
760
+ const changeQuery = (next) => {
761
+ setQuery(next);
762
+ setHighlightedIndex(0);
763
+ };
764
+ const close = (restoreFocus = false) => {
765
+ setOpen(false);
766
+ setPane("root");
767
+ if (restoreFocus) {
768
+ const focus = () => {
769
+ triggerRef.current?.focus?.();
770
+ };
771
+ if (typeof queueMicrotask === "function") queueMicrotask(focus);
772
+ else void Promise.resolve().then(focus);
773
+ }
774
+ };
775
+ const closeAfterSelection = () => {
776
+ setSelectionFocus(true);
777
+ close(true);
778
+ };
779
+ const drill = (next) => {
780
+ setQuery("");
781
+ setHighlightedIndex(null);
782
+ paneFocus.current = "drill";
783
+ setPane(next);
784
+ };
785
+ const back = (from) => {
786
+ paneFocus.current = from;
787
+ setPane("root");
788
+ };
789
+ const moveFocus = (offset) => {
790
+ const items = Array.from(menuRef.current?.querySelectorAll?.(
791
+ 'button[role="menuitem"]:not([disabled]), button[role="menuitemradio"]:not([disabled]), button[role="switch"]:not([disabled])'
792
+ ) ?? []);
793
+ if (items.length === 0) return;
794
+ const active = items.findIndex((item) => item === document.activeElement);
795
+ const next = active === -1 ? offset > 0 ? 0 : items.length - 1 : (active + offset + items.length) % items.length;
796
+ items[next]?.focus?.();
797
+ };
798
+ const submit = (selection) => {
799
+ lastActionRef.current = "select";
800
+ setSelectionFocus(true);
801
+ triggerRef.current?.focus?.();
802
+ const gen = ++selectGeneration.current;
803
+ setPending(selection);
804
+ void selectModel(selection).then((result) => {
805
+ if (gen !== selectGeneration.current) return;
806
+ setPending(null);
807
+ if (result === void 0) return;
808
+ if (result.ok) {
809
+ if (mountedRef.current) closeAfterSelection();
810
+ return;
811
+ }
812
+ const error = result.error ?? { code: "error", message: "unknown error" };
813
+ toastSeq.current += 1;
814
+ setToast({
815
+ seq: toastSeq.current,
816
+ text: error.code === "session/writer-held" ? t("errorSessionInUse") : formatCopy(t, "errorAction", { message: error.code ? `${error.code}: ${error.message}` : error.message })
817
+ });
818
+ }, (error) => {
819
+ if (gen !== selectGeneration.current) return;
820
+ setPending(null);
821
+ toastSeq.current += 1;
822
+ setToast({
823
+ seq: toastSeq.current,
824
+ text: formatCopy(t, "errorAction", { message: error instanceof Error ? error.message : String(error) })
825
+ });
826
+ });
827
+ };
828
+ const choose = (selection) => {
829
+ if (current?.provider === selection.provider && current.model === selection.model) {
830
+ closeAfterSelection();
831
+ return;
832
+ }
833
+ submit(selection);
834
+ };
835
+ const chooseEffort = (effort) => {
836
+ if (current === null) return;
837
+ if (effectiveEffort === effort) {
838
+ closeAfterSelection();
839
+ return;
840
+ }
841
+ submit({
842
+ provider: current.provider,
843
+ model: current.model,
844
+ ...effort === void 0 ? {} : { reasoningEffort: effort }
845
+ });
846
+ };
847
+ const onRootKeyDown = (event) => {
848
+ if (event.nativeEvent?.isComposing) return;
849
+ if (event.key === "Escape" && open) {
850
+ event.preventDefault();
851
+ if (pane !== "root" && currentChoice !== void 0) back(pane);
852
+ else close(true);
853
+ return;
854
+ }
855
+ if (!open) return;
856
+ if (pane === "model" && showSearch && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
857
+ event.preventDefault();
858
+ if (!busy && visibleModels.length > 0) {
859
+ const direction = event.key === "ArrowDown" ? 1 : -1;
860
+ setHighlightedIndex((activeModelIndex + direction + visibleModels.length) % visibleModels.length);
861
+ searchRef.current?.focus?.();
148
862
  }
863
+ return;
864
+ }
865
+ if (pane === "model" && showSearch && typeof HTMLInputElement !== "undefined" && event.target instanceof HTMLInputElement && (event.key === "Enter" || event.key === "Tab" && !event.shiftKey)) {
866
+ if (event.key === "Tab" && visibleModels.length === 0) return;
867
+ event.preventDefault();
868
+ const highlighted = visibleModels[activeModelIndex];
869
+ if (!busy && highlighted !== void 0) choose(highlighted);
870
+ return;
149
871
  }
150
- if (!parts.length) return null;
151
- const status = state.final ? "settled" : location.kind === "step" && location.step.status === "closed" ? "interrupted" : "running";
152
- const turn = context.matches[0].event.data.turn, step = context.matches[0].event.data.step;
153
- const text = parts.filter((part) => part.kind === "text").map((part) => part.text).join("\n");
154
- const blocks = [{ kind: "text", text: text || parts.filter((part) => part.kind === "tool").map((part) => part.root.name ?? part.root.call.name).join(", ") || "ACP" }];
155
- return {
156
- key: context.key,
157
- id: context.id,
158
- kind: "assistant-step",
159
- target: "chat",
160
- anchorSeq: state.seq,
161
- location,
162
- visibility: "visible",
163
- data: {
164
- status,
165
- turn,
166
- step,
167
- blocks,
168
- time: context.matches[0].event.time,
169
- acpTranscript: { groups: groupParts(parts), status }
872
+ if (event.key === "Tab") {
873
+ if (event.shiftKey) {
874
+ event.preventDefault();
875
+ if (pane !== "root" && currentChoice !== void 0) back(pane);
876
+ else close(true);
877
+ return;
878
+ }
879
+ const focused = typeof document !== "undefined" ? document.activeElement : null;
880
+ const rows = Array.from(menuRef.current?.querySelectorAll?.(
881
+ 'button[role="menuitem"]:not([disabled]), button[role="menuitemradio"]:not([disabled]), button[role="switch"]:not([disabled])'
882
+ ) ?? []);
883
+ if (typeof HTMLButtonElement !== "undefined" && focused instanceof HTMLButtonElement && rows.includes(focused)) {
884
+ event.preventDefault();
885
+ focused.click();
886
+ return;
887
+ }
888
+ if (focused !== triggerRef.current) return;
889
+ event.preventDefault();
890
+ if (pane === "model" && showSearch) {
891
+ setHighlightedIndex(null);
892
+ searchRef.current?.focus?.();
893
+ return;
170
894
  }
895
+ const checked = menuRef.current?.querySelector?.('[role="menuitemradio"][aria-checked="true"]:not([disabled])');
896
+ (checked ?? rows.find((item) => !item.disabled))?.focus?.();
897
+ return;
898
+ }
899
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
900
+ event.preventDefault();
901
+ moveFocus(event.key === "ArrowDown" ? 1 : -1);
902
+ }
903
+ };
904
+ const onBlur = (event) => {
905
+ const related = event.relatedTarget;
906
+ if (related && (rootRef.current?.contains?.(related) === true || menuRef.current?.contains?.(related) === true)) return;
907
+ close();
908
+ };
909
+ const waiting = currentChoice === void 0 && (catalogState.status === "loading" || catalogState.status === "idle");
910
+ const modelLabel = waiting ? t("loadingModels") : currentChoice?.model.name ?? t("modelFallback");
911
+ const triggerLabel = effortLabel === void 0 ? modelLabel : `${modelLabel} \xB7 ${effortLabel}`;
912
+ const triggerAria = waiting ? t("loadingModels") : currentChoice === void 0 ? t("modelFallback") : effortLabel === void 0 ? formatCopy(t, "triggerAria", { model: modelLabel }) : formatCopy(t, "triggerAriaEffort", { model: modelLabel, effort: effortLabel });
913
+ const renderModelLabel = (provider, model, placement, selected) => {
914
+ const fallback = model.badge === void 0 ? model.name : (0, import_react.createElement)(
915
+ "span",
916
+ { className: "oacp-ms-badgedName" },
917
+ placement === "trigger" ? (0, import_react.createElement)(import_react.Fragment, null, (0, import_react.createElement)(TagComp, { className: "oacp-ms-badge", tone: model.badge.tone }, resolveText(model.badge.text)), " ") : null,
918
+ (0, import_react.createElement)("span", { className: "oacp-ms-badgedNameText" }, model.name),
919
+ placement === "trigger" ? null : (0, import_react.createElement)(import_react.Fragment, null, " ", (0, import_react.createElement)(TagComp, { className: "oacp-ms-badge", tone: model.badge.tone }, resolveText(model.badge.text)))
920
+ );
921
+ const rendered = typeof renderSlot === "function" ? renderSlot("conversation.input.model.label", { provider, model, placement, selected }, { fallback }) : fallback;
922
+ return (0, import_react.createElement)("span", { "data-provider-id": provider.id, "data-model-id": model.id }, rendered);
923
+ };
924
+ let itemIndex = 0;
925
+ let modelIndex = 0;
926
+ const itemRef = () => {
927
+ const at = itemIndex++;
928
+ return (node) => {
929
+ itemRefs.current[at] = node;
171
930
  };
172
- }
173
- };
174
-
175
- // src/transcript-view.js
176
- var import_react = __toESM(require("react"), 1);
177
- var h = import_react.default.createElement;
178
- var toolKeys = { Bash: "bash", Read: "read", Edit: "edit", Write: "write", Search: "search", Fetch: "web_fetch" };
179
- var assistantContentFactories = {
180
- "conversation.chat.reasoning.body": "conversation.chat.reasoning.content",
181
- "conversation.chat.message.images": "conversation.images.content"
182
- };
183
- function ToolGroup({ roots, owner, renderTool, label }) {
184
- const { expanded, toggle } = owner.useDisclosure();
185
- return h(
931
+ };
932
+ const menu = open ? renderPortal(
933
+ (0, import_react.createElement)(
934
+ MenuSurfaceComp,
935
+ {
936
+ ref: menuRef,
937
+ id: `${rawId}-menu`,
938
+ className: "oacp-ms-menu",
939
+ style: anchorStyle,
940
+ role: pane === "model" ? "group" : "menu",
941
+ "aria-label": t("menuAria"),
942
+ "aria-busy": catalogState.status === "loading" || busy
943
+ },
944
+ pane === "root" && (0, import_react.createElement)(
945
+ import_react.Fragment,
946
+ null,
947
+ (0, import_react.createElement)(
948
+ "button",
949
+ {
950
+ ref: itemRef(),
951
+ type: "button",
952
+ role: "menuitem",
953
+ className: "oacp-ms-cell",
954
+ onClick: () => {
955
+ drill("model");
956
+ }
957
+ },
958
+ (0, import_react.createElement)("span", { className: "oacp-ms-cellLabel" }, t("menuModel")),
959
+ (0, import_react.createElement)(
960
+ "span",
961
+ { className: "oacp-ms-cellValue" },
962
+ currentChoice === void 0 ? modelLabel : renderModelLabel(currentChoice.group.provider, currentChoice.model, "menu", true)
963
+ ),
964
+ (0, import_react.createElement)(IconChevronRightComp, { className: "oacp-ms-cellChevron" })
965
+ ),
966
+ reasoning !== void 0 && (0, import_react.createElement)(
967
+ "button",
968
+ {
969
+ ref: itemRef(),
970
+ type: "button",
971
+ role: "menuitem",
972
+ className: "oacp-ms-cell",
973
+ onClick: () => {
974
+ drill("effort");
975
+ }
976
+ },
977
+ (0, import_react.createElement)("span", { className: "oacp-ms-cellLabel" }, t("menuEffort")),
978
+ (0, import_react.createElement)("span", { className: "oacp-ms-cellValue" }, effortLabel),
979
+ (0, import_react.createElement)(IconChevronRightComp, { className: "oacp-ms-cellChevron" })
980
+ ),
981
+ typeof renderSlot === "function" ? renderSlot("conversation.input.model.options", {
982
+ locked: Boolean(locked) || busy,
983
+ dismiss: () => {
984
+ close();
985
+ triggerRef.current?.focus?.();
986
+ },
987
+ reportFailure: (message) => {
988
+ setToast({ seq: ++toastSeq.current, text: message });
989
+ }
990
+ }) : null
991
+ ),
992
+ pane === "model" && (0, import_react.createElement)(
993
+ import_react.Fragment,
994
+ null,
995
+ showSearch && (0, import_react.createElement)(
996
+ "div",
997
+ { className: "oacp-ms-searchRow" },
998
+ (0, import_react.createElement)(InputComp, {
999
+ ref: searchRef,
1000
+ className: cx("oacp-ms-search", query !== "" && "oacp-ms-searchWithQuery"),
1001
+ type: "text",
1002
+ role: "searchbox",
1003
+ "aria-label": t("searchPlaceholder"),
1004
+ "aria-controls": `${rawId}-models`,
1005
+ "aria-activedescendant": activeModelIndex < 0 ? void 0 : `${rawId}-model-${activeModelIndex}`,
1006
+ placeholder: t("searchPlaceholder"),
1007
+ value: query,
1008
+ readOnly: busy,
1009
+ onChange: (event) => {
1010
+ changeQuery(event.target.value);
1011
+ }
1012
+ }),
1013
+ query !== "" && (0, import_react.createElement)("button", {
1014
+ type: "button",
1015
+ className: "oacp-ms-searchClear",
1016
+ "aria-label": t("searchClear"),
1017
+ disabled: busy,
1018
+ onClick: () => {
1019
+ changeQuery("");
1020
+ searchRef.current?.focus?.();
1021
+ }
1022
+ }, (0, import_react.createElement)(IconCloseComp, null))
1023
+ ),
1024
+ catalogState.status === "loading" && (0, import_react.createElement)("div", { className: "oacp-ms-status" }, t("statusLoading")),
1025
+ catalogState.error !== null && lastActionRef.current === "load" && (0, import_react.createElement)(
1026
+ "div",
1027
+ { className: "oacp-ms-error" },
1028
+ (0, import_react.createElement)("span", null, formatCopy(t, "errorAction", { message: catalogState.error })),
1029
+ (0, import_react.createElement)("button", { type: "button", className: "oacp-ms-retry", onClick: forceReload }, t("retry"))
1030
+ ),
1031
+ failures.map((failure) => (0, import_react.createElement)(
1032
+ "div",
1033
+ { className: "oacp-ms-warning", key: failure.id },
1034
+ (0, import_react.createElement)("span", null, formatCopy(t, "warningGroupLoad", {
1035
+ name: failure.id === "deepseek-account" ? accountProviderName : failure.name,
1036
+ message: failure.message
1037
+ })),
1038
+ (0, import_react.createElement)("button", { type: "button", className: "oacp-ms-retry", onClick: forceReload }, t("retry"))
1039
+ )),
1040
+ (0, import_react.createElement)(
1041
+ "div",
1042
+ {
1043
+ ref: groupsRef,
1044
+ id: `${rawId}-models`,
1045
+ className: "oacp-ms-groups scrollable",
1046
+ role: "menu",
1047
+ "aria-label": t("menuModel"),
1048
+ hidden: filteredGroups.length === 0
1049
+ },
1050
+ filteredGroups.map((group) => (0, import_react.createElement)(
1051
+ MenuGroupComp,
1052
+ { key: group.id, label: group.provider.name },
1053
+ group.models.map((model) => {
1054
+ const index = modelIndex++;
1055
+ const selected = current?.provider === group.id && current.model === model.id;
1056
+ return (0, import_react.createElement)(
1057
+ "button",
1058
+ {
1059
+ ref: itemRef(),
1060
+ type: "button",
1061
+ role: "menuitemradio",
1062
+ "aria-checked": selected,
1063
+ id: `${rawId}-model-${index}`,
1064
+ tabIndex: showSearch ? -1 : 0,
1065
+ onFocus: () => {
1066
+ setHighlightedIndex(index);
1067
+ },
1068
+ "data-highlighted": index === activeModelIndex ? "" : void 0,
1069
+ className: cx("oacp-ms-option", "oacp-ms-modelOption", selected && "oacp-ms-selected", index === activeModelIndex && "oacp-ms-optionActive"),
1070
+ onMouseMove: busy || index === activeModelIndex ? void 0 : () => {
1071
+ if (showSearch) setHighlightedIndex(index);
1072
+ else itemRefs.current[index]?.focus?.();
1073
+ },
1074
+ key: model.id,
1075
+ title: model.name,
1076
+ disabled: busy,
1077
+ onClick: () => {
1078
+ choose({ provider: group.id, model: model.id });
1079
+ }
1080
+ },
1081
+ (0, import_react.createElement)(
1082
+ "span",
1083
+ { className: "oacp-ms-optionCopy" },
1084
+ (0, import_react.createElement)("span", { className: "oacp-ms-modelName" }, renderModelLabel(group.provider, model, "option", selected))
1085
+ ),
1086
+ (0, import_react.createElement)(
1087
+ "span",
1088
+ { className: "oacp-ms-check" },
1089
+ pending?.provider === group.id && pending.model === model.id ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : selected ? (0, import_react.createElement)(IconCheckComp, null) : null
1090
+ )
1091
+ );
1092
+ })
1093
+ ))
1094
+ ),
1095
+ catalogState.status === "ready" && filteredGroups.length === 0 && (0, import_react.createElement)(
1096
+ "div",
1097
+ { className: "oacp-ms-empty", role: "status" },
1098
+ t(choices2.length === 0 ? "emptyModels" : "searchEmpty")
1099
+ )
1100
+ ),
1101
+ pane === "effort" && (0, import_react.createElement)(
1102
+ import_react.Fragment,
1103
+ null,
1104
+ catalogState.error !== null && lastActionRef.current === "load" && (0, import_react.createElement)(
1105
+ "div",
1106
+ { className: "oacp-ms-error" },
1107
+ (0, import_react.createElement)("span", null, formatCopy(t, "errorAction", { message: catalogState.error })),
1108
+ (0, import_react.createElement)("button", { type: "button", className: "oacp-ms-retry", onClick: forceReload }, t("actionReload"))
1109
+ ),
1110
+ (0, import_react.createElement)(
1111
+ "div",
1112
+ { className: "oacp-ms-groups scrollable" },
1113
+ effortChoices.length === 0 ? (0, import_react.createElement)("div", { className: "oacp-ms-empty" }, t("emptyEfforts")) : effortChoices.map((level) => (0, import_react.createElement)(
1114
+ "button",
1115
+ {
1116
+ ref: itemRef(),
1117
+ type: "button",
1118
+ role: "menuitemradio",
1119
+ "aria-checked": effectiveEffort === level.effort,
1120
+ className: cx("oacp-ms-option", effectiveEffort === level.effort && "oacp-ms-selected"),
1121
+ key: level.key,
1122
+ disabled: busy,
1123
+ onClick: () => {
1124
+ chooseEffort(level.effort);
1125
+ }
1126
+ },
1127
+ (0, import_react.createElement)(
1128
+ "span",
1129
+ { className: "oacp-ms-optionCopy" },
1130
+ (0, import_react.createElement)("span", { className: "oacp-ms-modelName" }, level.label)
1131
+ ),
1132
+ (0, import_react.createElement)(
1133
+ "span",
1134
+ { className: "oacp-ms-check" },
1135
+ pending !== null && pending.provider === current?.provider && pending.model === current?.model && pending.reasoningEffort === level.effort ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : effectiveEffort === level.effort ? (0, import_react.createElement)(IconCheckComp, null) : null
1136
+ )
1137
+ ))
1138
+ )
1139
+ )
1140
+ )
1141
+ ) : null;
1142
+ return (0, import_react.createElement)(
186
1143
  "div",
187
- { "data-oneagents-acp-tool-group": "", style: { margin: "8px 0" } },
188
- h(
1144
+ {
1145
+ ref: rootRef,
1146
+ className: "oacp-ms-root",
1147
+ "data-oneagents-acp-controls": "dsh",
1148
+ onKeyDown: onRootKeyDown,
1149
+ onBlur,
1150
+ onMouseDown: (event) => {
1151
+ if (typeof Element !== "undefined" && event.target instanceof Element && event.target.closest("button") !== null) {
1152
+ event.preventDefault();
1153
+ }
1154
+ }
1155
+ },
1156
+ (0, import_react.createElement)(
189
1157
  "button",
190
1158
  {
1159
+ ref: triggerRef,
191
1160
  type: "button",
192
- "aria-expanded": expanded,
193
- onClick: toggle,
194
- style: { border: 0, background: "transparent", color: "inherit", opacity: 0.7, cursor: "pointer", font: "inherit", fontSize: 14, padding: "4px 0" }
1161
+ className: "oacp-ms-trigger",
1162
+ style: anchorStyle,
1163
+ "aria-label": triggerAria,
1164
+ "aria-haspopup": "menu",
1165
+ "aria-expanded": open,
1166
+ "aria-controls": open ? `${rawId}-menu` : void 0,
1167
+ title: triggerLabel,
1168
+ "aria-busy": busy,
1169
+ "data-selection-focus": selectionFocus ? "" : void 0,
1170
+ onBlur: () => {
1171
+ setSelectionFocus(false);
1172
+ },
1173
+ disabled: Boolean(locked),
1174
+ onClick: () => {
1175
+ if (open) close(true);
1176
+ else show();
1177
+ }
195
1178
  },
196
- `${expanded ? "\u2303" : "\u2304"} ${label(roots.length)}`
1179
+ (0, import_react.createElement)(IconDataComp, { className: "oacp-ms-triggerIcon", size: 16 }),
1180
+ (0, import_react.createElement)(
1181
+ "span",
1182
+ { className: "oacp-ms-triggerLabel" },
1183
+ currentChoice === void 0 ? modelLabel : renderModelLabel(currentChoice.group.provider, currentChoice.model, "trigger", true)
1184
+ ),
1185
+ effortLabel !== void 0 && (0, import_react.createElement)("span", { className: "oacp-ms-triggerEffort" }, effortLabel),
1186
+ busy ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : (0, import_react.createElement)(IconChevronDownComp, { className: cx("oacp-ms-chevron", open && "oacp-ms-chevronOpen") })
197
1187
  ),
198
- expanded ? h("div", { style: { paddingTop: 6 } }, roots.map((root) => renderTool(root, owner))) : null
1188
+ menu,
1189
+ toast !== null && (0, import_react.createElement)(ToastComp, {
1190
+ key: toast.seq,
1191
+ text: toast.text,
1192
+ icon: (0, import_react.createElement)(IconWarningComp, null),
1193
+ anchor: rootRef.current?.closest?.("[data-composer-card]") ?? null,
1194
+ onDone: () => {
1195
+ setToast(null);
1196
+ }
1197
+ })
199
1198
  );
200
1199
  }
201
- function installTranscriptView(ctx) {
202
- ctx.slots.inject("conversation.chat.node", () => {
203
- const native = [...ctx.slots.entries("conversation.chat.node")].reverse().find((entry) => entry.options.key === "assistant-step");
204
- if (!native) throw new Error("DSH native assistant renderer is unavailable");
205
- const renderAssistant = (props) => h(native.component, native.children ? {
206
- ...props,
207
- renderSlot: (key, owner) => props.renderFactorySlot(assistantContentFactories[key], owner)
208
- } : props);
209
- const tTool = ctx.locale.bind("conversation");
210
- const t = ctx.locale.bind("oneagentsAcp");
211
- const renderTool = (root, owner) => {
212
- const name = root.name ?? root.call?.name ?? "Tool";
213
- const entries = ctx.slots.entries("tool.call.toolview");
214
- const key = toolKeys[name] ?? name;
215
- const entry = [...entries].reverse().find((entry2) => entry2.options.key === key && !entry2.children) ?? entries.find((entry2) => entry2.options.key === "sleep" && !entry2.children);
216
- if (!entry) throw new Error(`DSH atomic Tool renderer is unavailable for ${name}`);
217
- return h(entry.component, {
218
- ...owner,
219
- key: root.callId,
220
- callId: root.callId,
221
- toolName: key,
222
- phase: root.phase === "start" ? "start" : "result",
223
- block: root,
224
- home: ctx.remote.$host?.home,
225
- inspect: void 0,
226
- t: tTool
227
- });
1200
+ function acpChoices(option) {
1201
+ return (option?.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
1202
+ }
1203
+ function isAcpEffortOption(option) {
1204
+ return option.category === "thought_level" || option.category === "reasoning_effort" || /^(thought_level|thinking_level|reasoning_effort|effort)$/i.test(option.id);
1205
+ }
1206
+ function AcpModelSelect({
1207
+ sessionId,
1208
+ presetId,
1209
+ capabilities,
1210
+ locked,
1211
+ busy,
1212
+ error,
1213
+ loadError,
1214
+ onConfigure,
1215
+ onRefresh,
1216
+ onClearError,
1217
+ t
1218
+ }) {
1219
+ const [open, setOpen] = (0, import_react.useState)(false);
1220
+ const [pane, setPane] = (0, import_react.useState)("root");
1221
+ const [query, setQuery] = (0, import_react.useState)("");
1222
+ const [highlightedIndex, setHighlightedIndex] = (0, import_react.useState)(null);
1223
+ const [selectionFocus, setSelectionFocus] = (0, import_react.useState)(false);
1224
+ const [pendingChoice, setPendingChoice] = (0, import_react.useState)(null);
1225
+ const [toast, setToast] = (0, import_react.useState)(null);
1226
+ const toastSeq = (0, import_react.useRef)(0);
1227
+ const mountedRef = (0, import_react.useRef)(true);
1228
+ const rootRef = (0, import_react.useRef)(null);
1229
+ const triggerRef = (0, import_react.useRef)(null);
1230
+ const searchRef = (0, import_react.useRef)(null);
1231
+ const menuRef = (0, import_react.useRef)(null);
1232
+ const groupsRef = (0, import_react.useRef)(null);
1233
+ const itemRefs = (0, import_react.useRef)([]);
1234
+ const paneFocus = (0, import_react.useRef)(null);
1235
+ const rawId = typeof import_react.useId === "function" ? (0, import_react.useId)() : "oacp-acp-ms";
1236
+ const anchorStyle = { "--dsh-model-anchor": `--dsh-acp-model-${rawId.replaceAll(":", "")}` };
1237
+ const compute = (factory, deps) => typeof import_react.useMemo === "function" ? (0, import_react.useMemo)(factory, deps) : factory();
1238
+ const { modelSection, effortSection, sections } = compute(() => {
1239
+ if (!capabilities) return { modelSection: void 0, effortSection: void 0, sections: [] };
1240
+ const configs = (capabilities.configOptions ?? []).filter((option) => option.type === "select");
1241
+ const model = configs.find((option) => option.category === "model" || option.id === "model");
1242
+ const additional = configs.filter((option) => option !== model && !(capabilities.modes && (option.category === "mode" || option.id === "mode")));
1243
+ const effort = additional.find(isAcpEffortOption);
1244
+ const others = additional.filter((option) => option !== effort);
1245
+ const toSection = (option, fallbackLabel) => {
1246
+ const rows = acpChoices(option);
1247
+ const currentRow = rows.find((row) => row.value === option.currentValue);
1248
+ return {
1249
+ id: option.id,
1250
+ label: option.name || fallbackLabel,
1251
+ currentValue: option.currentValue,
1252
+ currentLabel: currentRow?.name ?? option.currentValue ?? t("choose"),
1253
+ rows
1254
+ };
228
1255
  };
229
- function Assistant(props) {
230
- const projected = props.useChat?.((snapshot) => snapshot?.nodes.values().some((node) => node.data.acpTranscript && node.data.turn === props.node.data.turn && node.data.step === props.node.data.step));
231
- const transcript = props.node.data.acpTranscript;
232
- if (transcript) return h("div", { "data-oneagents-acp-transcript": "" }, transcript.groups.map((group) => {
233
- if (group.kind === "tools") return h(ToolGroup, {
234
- key: group.key,
235
- roots: group.roots,
236
- owner: props,
237
- renderTool,
238
- label: (count) => t("toolGroup").replace("{count}", String(count))
239
- });
240
- const node = { ...props.node, data: {
241
- ...props.node.data,
242
- acpTranscript: void 0,
243
- blocks: [{ kind: group.kind, text: group.text }]
244
- } };
245
- return renderAssistant({ ...props, key: group.key, node, groupPart: void 0, turnProcess: void 0 });
1256
+ const nextSections = [];
1257
+ const builtModel = model ? toSection(model, t("model")) : void 0;
1258
+ if (builtModel) nextSections.push(builtModel);
1259
+ const builtEffort = effort ? toSection(effort, t("effort")) : void 0;
1260
+ if (builtEffort) nextSections.push(builtEffort);
1261
+ for (const opt of others) nextSections.push(toSection(opt, opt.id));
1262
+ if (capabilities.modes?.availableModes?.length) {
1263
+ const rows = capabilities.modes.availableModes.map((mode) => ({
1264
+ value: mode.id,
1265
+ name: mode.name,
1266
+ description: mode.description
246
1267
  }));
247
- const preset = ctx.sessions.binding(props.sessionId)?.session.projections.faceOf("agentPreset").getSnapshot();
248
- return projected && typeof preset === "string" && preset.startsWith("oneagents-acp-") ? h("span", { hidden: true, "data-oneagents-acp-original": "" }) : renderAssistant(props);
249
- }
250
- return ctx.slots.register({
251
- name: "conversation.chat.node",
252
- key: "assistant-step",
253
- priority: (native.options.priority ?? 0) - 1,
254
- locale: native.locale,
255
- inject: native.inject
256
- }, Assistant);
257
- });
258
- ctx.effect(() => {
259
- const style = document.createElement("style");
260
- style.textContent = "[data-step-process]:has([data-oneagents-acp-original]):not(:has([data-oneagents-acp-transcript])){display:none}";
261
- document.head.append(style);
262
- return () => style.remove();
263
- });
1268
+ const currentRow = rows.find((row) => row.value === capabilities.modes.currentModeId);
1269
+ nextSections.push({
1270
+ id: "$mode",
1271
+ label: t("mode"),
1272
+ currentValue: capabilities.modes.currentModeId,
1273
+ currentLabel: currentRow?.name ?? capabilities.modes.currentModeId ?? "",
1274
+ rows
1275
+ });
1276
+ }
1277
+ return { modelSection: builtModel, effortSection: builtEffort, sections: nextSections };
1278
+ }, [capabilities, t]);
1279
+ const activeSection = pane === "root" ? void 0 : sections.find((section) => section.id === pane);
1280
+ const showSearch = (activeSection?.rows.length ?? 0) > 4;
1281
+ const groupedRows = compute(() => {
1282
+ if (!activeSection) return [];
1283
+ const filtered = rankByName(activeSection.rows, showSearch ? query.trim() : "");
1284
+ const hasGroups = filtered.some((row) => row.group);
1285
+ if (!hasGroups) return filtered.length ? [{ id: "__flat__", label: null, rows: filtered }] : [];
1286
+ const map = /* @__PURE__ */ new Map();
1287
+ for (const row of filtered) {
1288
+ const key = row.group ?? "";
1289
+ let bucket = map.get(key);
1290
+ if (!bucket) map.set(key, bucket = { id: key || "__ungrouped__", label: row.group ?? null, rows: [] });
1291
+ bucket.rows.push(row);
1292
+ }
1293
+ return Array.from(map.values());
1294
+ }, [activeSection, query, showSearch]);
1295
+ const visibleRows = compute(() => groupedRows.flatMap((group) => group.rows), [groupedRows]);
1296
+ const currentVisibleIndex = activeSection ? visibleRows.findIndex((row) => row.value === activeSection.currentValue) : -1;
1297
+ const activeRowIndex = Math.min(highlightedIndex ?? Math.max(0, currentVisibleIndex), visibleRows.length - 1);
1298
+ const disabled = Boolean(locked) || Boolean(busy) || capabilities?.writable === false;
1299
+ const triggerDisabled = Boolean(locked) || capabilities?.writable === false;
1300
+ const singleSection = sections.length === 1;
1301
+ const canOpenMenu = sections.length > 0 || Boolean(error || loadError);
1302
+ (0, import_react.useEffect)(() => {
1303
+ setOpen(false);
1304
+ setPane("root");
1305
+ setQuery("");
1306
+ setHighlightedIndex(null);
1307
+ setPendingChoice(null);
1308
+ }, [sessionId, presetId]);
1309
+ (0, import_react.useEffect)(() => {
1310
+ if (!busy) setPendingChoice(null);
1311
+ }, [busy]);
1312
+ (0, import_react.useEffect)(() => {
1313
+ mountedRef.current = true;
1314
+ return () => {
1315
+ mountedRef.current = false;
1316
+ };
1317
+ }, []);
1318
+ (0, import_react.useEffect)(() => {
1319
+ if (error) {
1320
+ toastSeq.current += 1;
1321
+ setToast({ seq: toastSeq.current, text: formatCopy(t, "errorAction", { message: error }) });
1322
+ }
1323
+ }, [error]);
1324
+ (0, import_react.useEffect)(() => {
1325
+ if (!open || typeof document === "undefined" || typeof document.addEventListener !== "function") return void 0;
1326
+ const closeOutside = (event) => {
1327
+ if (rootRef.current?.contains?.(event.target) === true) return;
1328
+ if (menuRef.current?.contains?.(event.target) === true) return;
1329
+ setOpen(false);
1330
+ };
1331
+ document.addEventListener("mousedown", closeOutside);
1332
+ return () => {
1333
+ document.removeEventListener("mousedown", closeOutside);
1334
+ };
1335
+ }, [open]);
1336
+ useSafeLayoutEffect(() => {
1337
+ if (!showSearch) {
1338
+ setQuery("");
1339
+ setHighlightedIndex(null);
1340
+ }
1341
+ }, [showSearch]);
1342
+ (0, import_react.useEffect)(() => {
1343
+ const intent = paneFocus.current;
1344
+ paneFocus.current = null;
1345
+ if (!open || intent === null) return;
1346
+ if (intent === "drill") {
1347
+ if (showSearch && !isMobileDevice()) {
1348
+ searchRef.current?.focus?.();
1349
+ return;
1350
+ }
1351
+ const checked = menuRef.current?.querySelector?.('[role="menuitemradio"][aria-checked="true"]:not([disabled])');
1352
+ const target = checked ?? itemRefs.current.find((item) => item != null && !item.disabled);
1353
+ (target ?? triggerRef.current)?.focus?.();
1354
+ return;
1355
+ }
1356
+ const index = sections.findIndex((section) => section.id === intent);
1357
+ const cell = itemRefs.current[index >= 0 ? index : 0];
1358
+ (cell != null && !cell.disabled ? cell : triggerRef.current)?.focus?.();
1359
+ }, [open, pane, showSearch]);
1360
+ (0, import_react.useEffect)(() => {
1361
+ const viewport = groupsRef.current;
1362
+ if (!viewport) return void 0;
1363
+ return observeStickyMenuGroups(viewport);
1364
+ }, [open, pane, groupedRows]);
1365
+ useSafeLayoutEffect(() => {
1366
+ if (open && pane !== "root" && activeRowIndex >= 0) {
1367
+ itemRefs.current[activeRowIndex]?.scrollIntoView?.({ block: "nearest" });
1368
+ }
1369
+ }, [open, pane, activeRowIndex, visibleRows]);
1370
+ const show = () => {
1371
+ if (!canOpenMenu) return;
1372
+ setSelectionFocus(false);
1373
+ triggerRef.current?.focus?.();
1374
+ setQuery("");
1375
+ setHighlightedIndex(null);
1376
+ const initialPane = singleSection ? sections[0].id : "root";
1377
+ paneFocus.current = singleSection ? "drill" : sections[0]?.id ?? null;
1378
+ setPane(initialPane);
1379
+ setOpen(true);
1380
+ };
1381
+ const close = (restoreFocus = false) => {
1382
+ setOpen(false);
1383
+ setPane("root");
1384
+ if (restoreFocus) {
1385
+ const focus = () => {
1386
+ triggerRef.current?.focus?.();
1387
+ };
1388
+ if (typeof queueMicrotask === "function") queueMicrotask(focus);
1389
+ else void Promise.resolve().then(focus);
1390
+ }
1391
+ };
1392
+ const closeAfterSelection = () => {
1393
+ setSelectionFocus(true);
1394
+ close(true);
1395
+ };
1396
+ const drill = (nextPane) => {
1397
+ setQuery("");
1398
+ setHighlightedIndex(null);
1399
+ paneFocus.current = "drill";
1400
+ setPane(nextPane);
1401
+ };
1402
+ const back = (fromPane) => {
1403
+ paneFocus.current = fromPane;
1404
+ setPane("root");
1405
+ };
1406
+ const changeQuery = (next) => {
1407
+ setQuery(next);
1408
+ setHighlightedIndex(0);
1409
+ };
1410
+ const moveFocus = (offset) => {
1411
+ const items = Array.from(menuRef.current?.querySelectorAll?.(
1412
+ 'button[role="menuitem"]:not([disabled]), button[role="menuitemradio"]:not([disabled])'
1413
+ ) ?? []);
1414
+ if (items.length === 0) return;
1415
+ const active = items.findIndex((item) => item === document.activeElement);
1416
+ const next = active === -1 ? offset > 0 ? 0 : items.length - 1 : (active + offset + items.length) % items.length;
1417
+ items[next]?.focus?.();
1418
+ };
1419
+ const choose = (configId, value) => {
1420
+ if (disabled) return;
1421
+ const section = sections.find((item) => item.id === configId);
1422
+ if (section && section.currentValue === value) {
1423
+ closeAfterSelection();
1424
+ return;
1425
+ }
1426
+ setSelectionFocus(true);
1427
+ setPendingChoice({ configId, value });
1428
+ return Promise.resolve(onConfigure(configId, value)).then((ok) => {
1429
+ if (mountedRef.current) {
1430
+ setPendingChoice(null);
1431
+ if (ok !== false) closeAfterSelection();
1432
+ }
1433
+ });
1434
+ };
1435
+ const onRootKeyDown = (event) => {
1436
+ if (event.nativeEvent?.isComposing) return;
1437
+ if (event.key === "Escape" && open) {
1438
+ event.preventDefault();
1439
+ if (pane !== "root" && !singleSection) back(pane);
1440
+ else close(true);
1441
+ return;
1442
+ }
1443
+ if (!open) return;
1444
+ if (pane !== "root" && showSearch && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
1445
+ event.preventDefault();
1446
+ if (!disabled && visibleRows.length > 0) {
1447
+ const direction = event.key === "ArrowDown" ? 1 : -1;
1448
+ setHighlightedIndex((activeRowIndex + direction + visibleRows.length) % visibleRows.length);
1449
+ searchRef.current?.focus?.();
1450
+ }
1451
+ return;
1452
+ }
1453
+ if (pane !== "root" && showSearch && typeof HTMLInputElement !== "undefined" && event.target instanceof HTMLInputElement && (event.key === "Enter" || event.key === "Tab" && !event.shiftKey)) {
1454
+ if (event.key === "Tab" && visibleRows.length === 0) return;
1455
+ event.preventDefault();
1456
+ const highlighted = visibleRows[activeRowIndex];
1457
+ if (!disabled && highlighted !== void 0 && activeSection) void choose(activeSection.id, highlighted.value);
1458
+ return;
1459
+ }
1460
+ if (event.key === "Tab") {
1461
+ if (event.shiftKey) {
1462
+ event.preventDefault();
1463
+ if (pane !== "root" && !singleSection) back(pane);
1464
+ else close(true);
1465
+ return;
1466
+ }
1467
+ const focused = typeof document !== "undefined" ? document.activeElement : null;
1468
+ const rows = Array.from(menuRef.current?.querySelectorAll?.(
1469
+ 'button[role="menuitem"]:not([disabled]), button[role="menuitemradio"]:not([disabled])'
1470
+ ) ?? []);
1471
+ if (typeof HTMLButtonElement !== "undefined" && focused instanceof HTMLButtonElement && rows.includes(focused)) {
1472
+ event.preventDefault();
1473
+ focused.click();
1474
+ return;
1475
+ }
1476
+ if (focused !== triggerRef.current) return;
1477
+ event.preventDefault();
1478
+ if (pane !== "root" && showSearch) {
1479
+ setHighlightedIndex(null);
1480
+ searchRef.current?.focus?.();
1481
+ return;
1482
+ }
1483
+ const checked = menuRef.current?.querySelector?.('[role="menuitemradio"][aria-checked="true"]:not([disabled])');
1484
+ (checked ?? rows.find((item) => !item.disabled))?.focus?.();
1485
+ return;
1486
+ }
1487
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
1488
+ event.preventDefault();
1489
+ moveFocus(event.key === "ArrowDown" ? 1 : -1);
1490
+ }
1491
+ };
1492
+ const onBlur = (event) => {
1493
+ const related = event.relatedTarget;
1494
+ if (related && (rootRef.current?.contains?.(related) === true || menuRef.current?.contains?.(related) === true)) return;
1495
+ close();
1496
+ };
1497
+ const loading = !capabilities && !error && !loadError;
1498
+ const primaryLabel = loading ? t("loading") : !capabilities ? t("error") : modelSection ? modelSection.currentLabel : `ACP \xB7 ${capabilities.agent}`;
1499
+ const secondaryLabel = effortSection ? effortSection.currentLabel : void 0;
1500
+ const triggerTitle = secondaryLabel ? `${primaryLabel} \xB7 ${secondaryLabel}` : primaryLabel;
1501
+ const triggerAria = loading ? t("loading") : !capabilities ? t("error") : secondaryLabel ? formatCopy(t, "triggerAriaEffort", { model: primaryLabel, effort: secondaryLabel }) : formatCopy(t, "triggerAria", { model: primaryLabel });
1502
+ const errorBannerText = error || loadError;
1503
+ let itemIndex = 0;
1504
+ let rowIndex = 0;
1505
+ const itemRef = () => {
1506
+ const at = itemIndex++;
1507
+ return (node) => {
1508
+ itemRefs.current[at] = node;
1509
+ };
1510
+ };
1511
+ const renderRowButton = (row) => {
1512
+ const index = rowIndex++;
1513
+ const selected = row.value === activeSection.currentValue;
1514
+ const isPending = pendingChoice?.configId === activeSection.id && pendingChoice.value === row.value;
1515
+ return (0, import_react.createElement)(
1516
+ "button",
1517
+ {
1518
+ ref: itemRef(),
1519
+ type: "button",
1520
+ role: "menuitemradio",
1521
+ "aria-checked": selected,
1522
+ id: `${rawId}-opt-${index}`,
1523
+ tabIndex: showSearch ? -1 : 0,
1524
+ onFocus: () => {
1525
+ setHighlightedIndex(index);
1526
+ },
1527
+ "data-highlighted": index === activeRowIndex ? "" : void 0,
1528
+ className: cx("oacp-ms-option", "oacp-ms-modelOption", selected && "oacp-ms-selected", index === activeRowIndex && "oacp-ms-optionActive"),
1529
+ onMouseMove: disabled || index === activeRowIndex ? void 0 : () => {
1530
+ if (showSearch) setHighlightedIndex(index);
1531
+ else itemRefs.current[index]?.focus?.();
1532
+ },
1533
+ key: row.value,
1534
+ title: row.description || row.name,
1535
+ disabled,
1536
+ onClick: () => {
1537
+ void choose(activeSection.id, row.value);
1538
+ }
1539
+ },
1540
+ (0, import_react.createElement)(
1541
+ "span",
1542
+ { className: "oacp-ms-optionCopy" },
1543
+ (0, import_react.createElement)("span", { className: "oacp-ms-modelName" }, row.name)
1544
+ ),
1545
+ (0, import_react.createElement)(
1546
+ "span",
1547
+ { className: "oacp-ms-check" },
1548
+ isPending ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : selected ? (0, import_react.createElement)(IconCheckComp, null) : null
1549
+ )
1550
+ );
1551
+ };
1552
+ const menu = open ? renderPortal(
1553
+ (0, import_react.createElement)(
1554
+ MenuSurfaceComp,
1555
+ {
1556
+ ref: menuRef,
1557
+ id: `${rawId}-menu`,
1558
+ className: "oacp-ms-menu",
1559
+ style: anchorStyle,
1560
+ role: pane === "root" ? "menu" : "group",
1561
+ "aria-label": t("native"),
1562
+ "aria-busy": Boolean(busy)
1563
+ },
1564
+ errorBannerText && (0, import_react.createElement)(
1565
+ "div",
1566
+ { className: "oacp-ms-error", role: "alert" },
1567
+ (0, import_react.createElement)("span", null, errorBannerText),
1568
+ (0, import_react.createElement)("button", {
1569
+ type: "button",
1570
+ className: "oacp-ms-retry",
1571
+ onClick: () => {
1572
+ onClearError?.();
1573
+ void onRefresh?.();
1574
+ }
1575
+ }, t("retry"))
1576
+ ),
1577
+ pane === "root" && sections.map((section) => (0, import_react.createElement)(
1578
+ "button",
1579
+ {
1580
+ key: section.id,
1581
+ ref: itemRef(),
1582
+ type: "button",
1583
+ role: "menuitem",
1584
+ className: "oacp-ms-cell",
1585
+ disabled,
1586
+ onClick: () => {
1587
+ drill(section.id);
1588
+ }
1589
+ },
1590
+ (0, import_react.createElement)("span", { className: "oacp-ms-cellLabel" }, section.label),
1591
+ (0, import_react.createElement)("span", { className: "oacp-ms-cellValue" }, section.currentLabel),
1592
+ (0, import_react.createElement)(IconChevronRightComp, { className: "oacp-ms-cellChevron" })
1593
+ )),
1594
+ pane !== "root" && activeSection && (0, import_react.createElement)(
1595
+ import_react.Fragment,
1596
+ null,
1597
+ showSearch && (0, import_react.createElement)(
1598
+ "div",
1599
+ { className: "oacp-ms-searchRow" },
1600
+ (0, import_react.createElement)(InputComp, {
1601
+ ref: searchRef,
1602
+ className: cx("oacp-ms-search", query !== "" && "oacp-ms-searchWithQuery"),
1603
+ type: "text",
1604
+ role: "searchbox",
1605
+ "aria-label": t("searchPlaceholder"),
1606
+ "aria-controls": `${rawId}-options`,
1607
+ "aria-activedescendant": activeRowIndex < 0 ? void 0 : `${rawId}-opt-${activeRowIndex}`,
1608
+ placeholder: t("searchPlaceholder"),
1609
+ value: query,
1610
+ readOnly: disabled,
1611
+ onChange: (event) => {
1612
+ changeQuery(event.target.value);
1613
+ }
1614
+ }),
1615
+ query !== "" && (0, import_react.createElement)("button", {
1616
+ type: "button",
1617
+ className: "oacp-ms-searchClear",
1618
+ "aria-label": t("searchClear"),
1619
+ disabled,
1620
+ onClick: () => {
1621
+ changeQuery("");
1622
+ searchRef.current?.focus?.();
1623
+ }
1624
+ }, (0, import_react.createElement)(IconCloseComp, null))
1625
+ ),
1626
+ (0, import_react.createElement)(
1627
+ "div",
1628
+ {
1629
+ ref: groupsRef,
1630
+ id: `${rawId}-options`,
1631
+ className: "oacp-ms-groups scrollable",
1632
+ role: "menu",
1633
+ "aria-label": activeSection.label,
1634
+ hidden: groupedRows.length === 0
1635
+ },
1636
+ groupedRows.map((group) => group.label ? (0, import_react.createElement)(MenuGroupComp, { key: group.id, label: group.label }, group.rows.map(renderRowButton)) : (0, import_react.createElement)(import_react.Fragment, { key: group.id }, group.rows.map(renderRowButton)))
1637
+ ),
1638
+ groupedRows.length === 0 && (0, import_react.createElement)(
1639
+ "div",
1640
+ { className: "oacp-ms-empty", role: "status" },
1641
+ t(activeSection.rows.length === 0 ? "emptyModels" : "searchEmpty")
1642
+ )
1643
+ )
1644
+ )
1645
+ ) : null;
1646
+ return (0, import_react.createElement)(
1647
+ "div",
1648
+ {
1649
+ ref: rootRef,
1650
+ className: "oacp-ms-root",
1651
+ "data-oneagents-acp-controls": "acp",
1652
+ onKeyDown: onRootKeyDown,
1653
+ onBlur,
1654
+ onMouseDown: (event) => {
1655
+ if (typeof Element !== "undefined" && event.target instanceof Element && event.target.closest("button") !== null) {
1656
+ event.preventDefault();
1657
+ }
1658
+ }
1659
+ },
1660
+ (0, import_react.createElement)(
1661
+ "button",
1662
+ {
1663
+ ref: triggerRef,
1664
+ type: "button",
1665
+ className: "oacp-ms-trigger",
1666
+ style: anchorStyle,
1667
+ "aria-label": triggerAria,
1668
+ "aria-haspopup": canOpenMenu ? "menu" : void 0,
1669
+ "aria-expanded": canOpenMenu ? open : void 0,
1670
+ "aria-controls": open ? `${rawId}-menu` : void 0,
1671
+ title: capabilities && !modelSection ? t("unsupported") : triggerTitle,
1672
+ "aria-busy": Boolean(busy) || loading,
1673
+ "data-selection-focus": selectionFocus ? "" : void 0,
1674
+ onBlur: () => {
1675
+ setSelectionFocus(false);
1676
+ },
1677
+ disabled: triggerDisabled || !canOpenMenu && !loading,
1678
+ onClick: () => {
1679
+ if (open) close(true);
1680
+ else show();
1681
+ }
1682
+ },
1683
+ loading ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : !capabilities && errorBannerText ? (0, import_react.createElement)(IconWarningComp, null) : (0, import_react.createElement)(IconDataComp, { className: "oacp-ms-triggerIcon", size: 16 }),
1684
+ (0, import_react.createElement)("span", { className: "oacp-ms-triggerLabel" }, primaryLabel),
1685
+ secondaryLabel !== void 0 && (0, import_react.createElement)("span", { className: "oacp-ms-triggerEffort" }, secondaryLabel),
1686
+ busy ? (0, import_react.createElement)(StateDotComp, { state: "ongoing" }) : canOpenMenu ? (0, import_react.createElement)(IconChevronDownComp, { className: cx("oacp-ms-chevron", open && "oacp-ms-chevronOpen") }) : null
1687
+ ),
1688
+ menu,
1689
+ toast !== null && (0, import_react.createElement)(ToastComp, {
1690
+ key: toast.seq,
1691
+ text: toast.text,
1692
+ icon: (0, import_react.createElement)(IconWarningComp, null),
1693
+ anchor: rootRef.current?.closest?.("[data-composer-card]") ?? null,
1694
+ onDone: () => {
1695
+ setToast(null);
1696
+ }
1697
+ })
1698
+ );
264
1699
  }
265
1700
 
266
1701
  // src/client.js
267
- var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
1702
+ var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "conversation"];
268
1703
  var dictionaries = {
269
- zh: { toolGroup: "\u5DF2\u8C03\u7528 {count} \u4E2A\u5DE5\u5177", model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", loadingModels: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E", activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002" },
270
- en: { toolGroup: "{count} tool calls", model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", loadingModels: "Loading models\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings", activeWriter: "The original session is running in another client. History is available; input resumes when it is released." }
1704
+ zh: {
1705
+ model: "\u6A21\u578B",
1706
+ choose: "\u9009\u62E9\u6A21\u578B",
1707
+ loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026",
1708
+ loadingModels: "\u6B63\u5728\u52A0\u8F7D\u6A21\u578B\u2026",
1709
+ retry: "\u91CD\u8BD5",
1710
+ mode: "\u6A21\u5F0F",
1711
+ command: "Agent \u6307\u4EE4",
1712
+ effort: "\u601D\u8003\u5F3A\u5EA6",
1713
+ unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B",
1714
+ description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B",
1715
+ error: "\u8FDE\u63A5\u5931\u8D25",
1716
+ noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4",
1717
+ native: "ACP \u8BBE\u7F6E",
1718
+ activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002",
1719
+ a2aRunning: "\u5F53\u524D\u4F1A\u8BDD\u6B63\u5728\u7531 A2A \u4EFB\u52A1\u6267\u884C\uFF0C\u5B8C\u6210\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002",
1720
+ providerAccount: "DeepSeek \u8D26\u53F7",
1721
+ modelFallback: "\u8BF7\u9009\u62E9\u6A21\u578B",
1722
+ triggerAria: "\u9009\u62E9\u6A21\u578B\uFF0C\u5F53\u524D {model}",
1723
+ triggerAriaEffort: "\u9009\u62E9\u6A21\u578B\uFF0C\u5F53\u524D {model}\uFF0C\u63A8\u7406\u7B49\u7EA7 {effort}",
1724
+ menuAria: "\u6A21\u578B\u4E0E\u63A8\u7406\u7B49\u7EA7",
1725
+ menuModel: "\u6A21\u578B",
1726
+ menuEffort: "\u63A8\u7406\u7B49\u7EA7",
1727
+ effortDefault: "Default",
1728
+ statusLoading: "\u6B63\u5728\u5237\u65B0\u6A21\u578B\u5217\u8868\u2026",
1729
+ errorAction: "\u6A21\u578B\u64CD\u4F5C\u5931\u8D25\uFF1A{message}",
1730
+ errorSessionInUse: "\u5F53\u524D\u4F1A\u8BDD\u5DF2\u88AB\u5360\u7528\uFF0C\u53EF\u80FD\u662F\u5176\u4ED6\u6B63\u5728\u8FD0\u884C\u7684 DSH \u5BFC\u81F4\u7684\uFF08\u5982\u5176\u4ED6 dsh web\u3001\u684C\u9762\u7AEF\uFF09\uFF0C\u8BF7\u9000\u51FA\u5176\u4ED6\u6B63\u5728\u8FD0\u884C\u7684 DSH \u540E\u91CD\u8BD5\u3002",
1731
+ actionReload: "\u91CD\u65B0\u52A0\u8F7D",
1732
+ warningGroupLoad: "{name} \u52A0\u8F7D\u5931\u8D25\uFF1A{message}",
1733
+ optionLoadError: "\u76EE\u5F55\u52A0\u8F7D\u5931\u8D25\uFF1A{message}",
1734
+ searchPlaceholder: "\u641C\u7D22\u6A21\u578B\u2026",
1735
+ searchClear: "\u6E05\u9664\u641C\u7D22",
1736
+ searchEmpty: "\u6CA1\u6709\u5339\u914D\u7684\u6A21\u578B\u3002",
1737
+ emptyModels: "\u6682\u65E0\u53EF\u7528\u6A21\u578B",
1738
+ emptyEfforts: "\u5F53\u524D\u6A21\u578B\u672A\u63D0\u4F9B\u63A8\u7406\u7B49\u7EA7\u3002"
1739
+ },
1740
+ en: {
1741
+ model: "Model",
1742
+ choose: "Select model",
1743
+ loading: "Connecting to Agent\u2026",
1744
+ loadingModels: "Loading models\u2026",
1745
+ retry: "Retry",
1746
+ mode: "Mode",
1747
+ command: "Agent commands",
1748
+ effort: "Reasoning effort",
1749
+ unsupported: "This Agent does not advertise model selection",
1750
+ description: "Select this Agent\u2019s model",
1751
+ error: "Connection failed",
1752
+ noCommands: "No commands advertised",
1753
+ native: "ACP settings",
1754
+ activeWriter: "The original session is running in another client. History is available; input resumes when it is released.",
1755
+ a2aRunning: "An A2A task is running in this session; input resumes once it completes.",
1756
+ providerAccount: "DeepSeek Account",
1757
+ modelFallback: "Select model",
1758
+ triggerAria: "Select model, current {model}",
1759
+ triggerAriaEffort: "Select model, current {model}, reasoning effort {effort}",
1760
+ menuAria: "Model and reasoning effort",
1761
+ menuModel: "Model",
1762
+ menuEffort: "Effort",
1763
+ effortDefault: "Default",
1764
+ statusLoading: "Refreshing model list\u2026",
1765
+ errorAction: "Model operation failed: {message}",
1766
+ errorSessionInUse: "This session is already in use, possibly by another running DSH instance (such as dsh web or the desktop app). Quit other running DSH instances and try again.",
1767
+ actionReload: "Reload",
1768
+ warningGroupLoad: "{name} failed to load: {message}",
1769
+ optionLoadError: "Catalog failed to load: {message}",
1770
+ searchPlaceholder: "Search models\u2026",
1771
+ searchClear: "Clear search",
1772
+ searchEmpty: "No matching models.",
1773
+ emptyModels: "No models available.",
1774
+ emptyEfforts: "This model provides no reasoning effort levels."
1775
+ }
271
1776
  };
272
1777
  function choices(option) {
273
1778
  return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
@@ -282,25 +1787,11 @@ async function acpRequest(sessionId, change, signal) {
282
1787
  if (!response.ok) throw new Error(value.error || `HTTP ${response.status}`);
283
1788
  return value;
284
1789
  }
285
- var selectStyle = { maxWidth: 210, minHeight: 30, borderRadius: 7, border: "1px solid var(--dsw-alias-border-l1, #8885)", color: "inherit", background: "var(--dsw-alias-bg-base, transparent)", padding: "3px 7px", fontSize: 12 };
286
- function Select({ title, value, rows, disabled, onSelect, placeholder }) {
287
- return (0, import_react2.createElement)(
288
- "label",
289
- { style: { display: "inline-flex", gap: 5, alignItems: "center", fontSize: 12 } },
290
- (0, import_react2.createElement)("span", null, title),
291
- (0, import_react2.createElement)(
292
- "select",
293
- { "aria-label": title, style: selectStyle, value: value ?? "", disabled, onChange: (e) => onSelect(e.target.value) },
294
- (0, import_react2.createElement)("option", { value: "", disabled: true }, placeholder || title),
295
- rows.map((row) => (0, import_react2.createElement)("option", { key: row.value, value: row.value, title: row.description }, `${row.group ? `${row.group} \xB7 ` : ""}${row.name}`))
296
- )
297
- );
298
- }
299
1790
  function apply(ctx) {
300
- ctx.uiConversation.events.register(toolConversationDefinition);
301
- installTranscriptView(ctx);
1791
+ installModelSelectStyles(ctx);
302
1792
  ctx.effect(() => ctx.locale.register("oneagentsAcp", dictionaries));
303
1793
  const t = ctx.locale.bind("oneagentsAcp");
1794
+ const catalogStore = createModelCatalogStore(ctx);
304
1795
  const native = /* @__PURE__ */ new Map();
305
1796
  const pending = /* @__PURE__ */ new Map();
306
1797
  const listeners = /* @__PURE__ */ new Map();
@@ -403,11 +1894,12 @@ function apply(ctx) {
403
1894
  };
404
1895
  const reset = () => {
405
1896
  selectedPresets.clear();
1897
+ catalogStore.resetGeneration();
406
1898
  for (const id of /* @__PURE__ */ new Set([...native.keys(), ...pending.keys(), ...blockedSessions, ...listeners.keys()])) invalidate(id);
407
1899
  };
408
1900
  ctx.remote.$on("agent-preset/selected", (sessionId, agentPreset) => invalidate(sessionId, agentPreset));
409
1901
  ctx.on("connection/reset", reset);
410
- function ModelControls({ sessionId, locked }) {
1902
+ function ModelControls({ sessionId, locked, available, resolveText, renderSlot }) {
411
1903
  const binding = ctx.sessions.binding(sessionId);
412
1904
  const preset = binding.session.projections.faceOf("agentPreset");
413
1905
  const selection = binding.session.projections.faceOf("modelSelection");
@@ -422,24 +1914,16 @@ function apply(ctx) {
422
1914
  };
423
1915
  }, () => native.get(sessionId));
424
1916
  const external = String(presetId ?? "").startsWith("oneagents-acp-");
425
- const [catalog, setCatalog] = (0, import_react2.useState)(null);
426
1917
  const [error, setError] = (0, import_react2.useState)("");
427
1918
  const [loadError, setLoadError] = (0, import_react2.useState)("");
428
1919
  const [busy, setBusy] = (0, import_react2.useState)(false);
429
- const [expanded, setExpanded] = (0, import_react2.useState)(false);
430
1920
  const changeSequence = (0, import_react2.useRef)(0);
431
1921
  const refresh = async () => {
432
1922
  const revision = revisionOf(sessionId);
433
1923
  const current = () => !disposed && revision === revisionOf(sessionId) && presetOf(sessionId) === presetId;
434
1924
  try {
435
1925
  if (external) await load(sessionId);
436
- else {
437
- block(sessionId, void 0);
438
- const result = await ctx.remote.session.modelCatalog();
439
- if (!current()) return;
440
- if (!result.ok) throw new Error(result.error.message);
441
- setCatalog(result.value);
442
- }
1926
+ else block(sessionId, void 0);
443
1927
  if (current()) setLoadError("");
444
1928
  } catch (error2) {
445
1929
  if (current()) setLoadError(String(error2.message ?? error2));
@@ -451,7 +1935,7 @@ function apply(ctx) {
451
1935
  setLoadError("");
452
1936
  changeSequence.current += 1;
453
1937
  setBusy(false);
454
- void refresh();
1938
+ if (external) void refresh();
455
1939
  }, [sessionId, presetId]);
456
1940
  (0, import_react2.useEffect)(() => {
457
1941
  if (!external) return;
@@ -486,49 +1970,73 @@ function apply(ctx) {
486
1970
  setError("");
487
1971
  try {
488
1972
  await action();
1973
+ return true;
489
1974
  } catch (error2) {
490
1975
  if (current()) setError(String(error2.message ?? error2));
1976
+ return false;
491
1977
  } finally {
492
1978
  if (operation === changeSequence.current) setBusy(false);
493
1979
  }
494
1980
  };
495
- const disabled = locked || busy || external && capabilities?.writable === false;
496
- const controls = [];
497
- if (external && capabilities) {
498
- const configs = capabilities.configOptions.filter((option) => option.type === "select");
499
- const model = configs.find((option) => option.category === "model" || option.id === "model");
500
- if (model) controls.push((0, import_react2.createElement)(Select, { key: model.id, title: model.name || t("model"), value: model.currentValue, rows: choices(model), disabled, onSelect: (value) => change(() => configure(sessionId, model.id, value)) }));
501
- else controls.push((0, import_react2.createElement)("span", { key: "unsupported", title: t("unsupported"), style: { fontSize: 12 } }, `ACP \xB7 ${capabilities.agent}`));
502
- const additional = configs.filter((option) => option !== model && !(capabilities.modes && (option.category === "mode" || option.id === "mode")));
503
- if (additional.length || capabilities.modes) controls.push((0, import_react2.createElement)("button", { key: "settings", type: "button", style: selectStyle, onClick: () => setExpanded(!expanded), "aria-expanded": expanded }, t("native")));
504
- if (expanded) {
505
- for (const option of additional) controls.push((0, import_react2.createElement)(Select, { key: option.id, title: option.name, value: option.currentValue, rows: choices(option), disabled, onSelect: (value) => change(() => configure(sessionId, option.id, value)) }));
506
- if (capabilities.modes) controls.push((0, import_react2.createElement)(Select, { key: "mode", title: t("mode"), value: capabilities.modes.currentModeId, rows: capabilities.modes.availableModes.map((m) => ({ value: m.id, name: m.name, description: m.description })), disabled, onSelect: (value) => change(() => configure(sessionId, "$mode", value)) }));
507
- }
508
- } else if (!external && catalog) {
509
- const current = projected?.next ?? catalog.default;
510
- const rows = catalog.groups.flatMap((group) => group.models.map((model2) => ({ value: JSON.stringify([group.id, model2.id]), name: model2.name, group: group.name })));
511
- const select = async (provider, model2, reasoningEffort) => {
512
- const result = await ctx.remote.session.selectModel({ sessionId, provider, model: model2, ...reasoningEffort ? { reasoningEffort } : {} });
513
- if (!result.ok) throw new Error(result.error.message);
514
- };
515
- controls.push((0, import_react2.createElement)(Select, { key: "dsh-model", title: t("model"), value: current?.provider === "1agents-acp" ? "" : JSON.stringify([current?.provider, current?.model]), rows, disabled, placeholder: t("choose"), onSelect: (value) => change(() => select(...JSON.parse(value))) }));
516
- const model = catalog.groups.find((g) => g.id === current?.provider)?.models.find((m) => m.id === current?.model);
517
- if (model?.reasoning) controls.push((0, import_react2.createElement)(Select, { key: "effort", title: t("effort"), value: current.reasoningEffort ?? model.reasoning.defaultEffort, rows: model.reasoning.efforts.map((e) => ({ value: e.id, name: e.name })), disabled, onSelect: (value) => change(() => select(current.provider, current.model, value)) }));
518
- } else if (!error && !loadError) controls.push((0, import_react2.createElement)("span", { key: "loading", style: { fontSize: 12 } }, t(external ? "loading" : "loadingModels")));
519
- if (error || loadError) controls.push((0, import_react2.createElement)("span", { key: "error", role: "alert", style: { color: "#c64b45", fontSize: 12, maxWidth: 360 } }, error || loadError, " ", (0, import_react2.createElement)("button", { type: "button", onClick: () => {
520
- setError("");
521
- void refresh();
522
- } }, t("retry"))));
523
- return (0, import_react2.createElement)("div", { "data-oneagents-acp-controls": external ? "acp" : "dsh", style: { display: "flex", alignItems: "center", flexWrap: "wrap", gap: 8 } }, controls);
1981
+ if (!external) {
1982
+ if (available === false) return null;
1983
+ return (0, import_react2.createElement)(StandardModelSelect, {
1984
+ sessionId,
1985
+ locked,
1986
+ projected,
1987
+ catalogStore,
1988
+ selectModel: (next) => ctx.remote.session.selectModel({
1989
+ sessionId,
1990
+ provider: next.provider,
1991
+ model: next.model,
1992
+ ...next.reasoningEffort === void 0 ? {} : { reasoningEffort: next.reasoningEffort }
1993
+ }),
1994
+ resolveText: resolveText ?? ((text) => resolveLocalizedText(ctx.locale, text)),
1995
+ renderSlot,
1996
+ t
1997
+ });
1998
+ }
1999
+ return (0, import_react2.createElement)(AcpModelSelect, {
2000
+ sessionId,
2001
+ presetId,
2002
+ capabilities,
2003
+ locked,
2004
+ busy,
2005
+ error,
2006
+ loadError,
2007
+ onConfigure: (configId, value) => change(() => configure(sessionId, configId, value)),
2008
+ onRefresh: refresh,
2009
+ onClearError: () => setError(""),
2010
+ t
2011
+ });
524
2012
  }
525
- ctx.slots.inject("conversation.input.model", () => ctx.slots.register({ name: "conversation.input.model", inject: (sessionId) => ({ sessionId }) }, ModelControls));
2013
+ ctx.slots.inject("conversation.input.model", () => ctx.slots.register({
2014
+ name: "conversation.input.model",
2015
+ children: {
2016
+ "conversation.input.model.label": { kind: "single", scope: "session", inline: true },
2017
+ "conversation.input.model.options": { kind: "list", scope: "session" }
2018
+ },
2019
+ inject: (sessionId) => ({
2020
+ sessionId,
2021
+ available: ctx.sessions.subagentAddress(sessionId) === void 0,
2022
+ resolveText: (text) => resolveLocalizedText(ctx.locale, text)
2023
+ })
2024
+ }, ModelControls));
2025
+ const modelCommandIcon = getModelCommandIcon();
526
2026
  ctx.effect(() => ctx.commandUi.register({
527
2027
  name: "model",
2028
+ label: () => t("model"),
528
2029
  description: () => t("description"),
2030
+ ...modelCommandIcon ? { icon: modelCommandIcon } : {},
529
2031
  available: (session) => ctx.sessions.subagentAddress(session.sessionId) === void 0,
530
2032
  ui: {
531
2033
  kind: "popupSelect",
2034
+ searchMode: "fuzzy-label",
2035
+ searchLabels: () => ({
2036
+ placeholder: t("searchPlaceholder"),
2037
+ empty: t("emptyModels"),
2038
+ noResults: t("searchEmpty")
2039
+ }),
532
2040
  options: async ({ sessionId }) => {
533
2041
  if (isAcp(sessionId)) {
534
2042
  const capabilities = await load(sessionId);
@@ -537,16 +2045,55 @@ function apply(ctx) {
537
2045
  if (!model) throw new Error(t("unsupported"));
538
2046
  return choices(model).map((option) => ({ id: JSON.stringify([model.id, option.value]), label: option.name, detail: option.description, active: option.value === model.currentValue }));
539
2047
  }
540
- const response = await ctx.remote.session.modelCatalog();
541
- if (!response.ok) throw new Error(response.error.message);
542
- return response.value.groups.flatMap((group) => group.models.map((model) => ({ id: JSON.stringify([group.id, model.id]), label: model.name, detail: group.name })));
2048
+ const value = await catalogStore.load();
2049
+ const projected = ctx.sessions.binding(sessionId)?.session.projections.faceOf("modelSelection").getSnapshot();
2050
+ const current = projected?.next ?? value.default;
2051
+ const accountName = t("providerAccount");
2052
+ const rows = [];
2053
+ for (const group of orderModelProviders(value.groups ?? [])) {
2054
+ const groupLabel = group.id === "deepseek-account" ? accountName : group.name;
2055
+ for (const model of group.models ?? []) {
2056
+ rows.push({
2057
+ id: JSON.stringify([group.id, model.id]),
2058
+ label: model.name,
2059
+ detail: groupLabel,
2060
+ group: { name: group.id, label: groupLabel },
2061
+ ...current?.provider === group.id && current?.model === model.id ? { active: true } : {}
2062
+ });
2063
+ }
2064
+ }
2065
+ for (const failure of value.failures ?? []) {
2066
+ rows.push({
2067
+ id: `failure/${failure.id}`,
2068
+ label: failure.id === "deepseek-account" ? accountName : failure.name,
2069
+ detail: formatCopy(t, "optionLoadError", { message: failure.message })
2070
+ });
2071
+ }
2072
+ return rows;
543
2073
  },
544
2074
  onSelect: async (option, { sessionId }) => {
2075
+ if (!isAcp(sessionId) && String(option.id).startsWith("failure/")) {
2076
+ throw new Error("this provider's catalog failed to load \u2014 pick a model from a loaded group");
2077
+ }
545
2078
  const [key, value] = JSON.parse(option.id);
546
2079
  if (isAcp(sessionId)) await configure(sessionId, key, value);
547
2080
  else {
548
- const result = await ctx.remote.session.selectModel({ sessionId, provider: key, model: value });
549
- if (!result.ok) throw new Error(result.error.message);
2081
+ const catalog = catalogStore.getSnapshot().value;
2082
+ const projected = ctx.sessions.binding(sessionId)?.session.projections.faceOf("modelSelection").getSnapshot();
2083
+ const current = projected?.next ?? catalog?.default;
2084
+ const matched = catalog?.groups?.find((g) => g.id === key)?.models?.find((m) => m.id === value);
2085
+ const sameRoute = current?.provider === key && current?.model === value;
2086
+ const reasoningEffort = sameRoute ? current?.reasoningEffort ?? matched?.reasoning?.defaultEffort : matched?.reasoning?.defaultEffort;
2087
+ const result = await ctx.remote.session.selectModel({
2088
+ sessionId,
2089
+ provider: key,
2090
+ model: value,
2091
+ ...reasoningEffort === void 0 ? {} : { reasoningEffort }
2092
+ });
2093
+ if (!result.ok) {
2094
+ if (result.error?.code === "session/writer-held") throw new Error(t("errorSessionInUse"));
2095
+ throw new Error(result.error?.message ?? "failed to select model");
2096
+ }
550
2097
  }
551
2098
  }
552
2099
  }