@tt-a1i/hive 2.1.9 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/src/server/agent-stdin-dispatcher.js +1 -0
- package/dist/src/server/post-start-input-writer.js +35 -6
- package/dist/src/server/routes-scenarios.d.ts +12 -17
- package/dist/src/server/routes-scenarios.js +41 -17
- package/dist/src/server/scenario-presets.d.ts +7 -4
- package/dist/src/server/scenario-presets.js +16 -6
- package/dist/src/shared/random-worker-name.d.ts +9 -0
- package/dist/src/shared/random-worker-name.js +382 -0
- package/package.json +1 -1
- package/web/dist/assets/{AddWorkerDialog-QBN0m0eH.js → AddWorkerDialog-Dc0slXtx.js} +2 -2
- package/web/dist/assets/{AddWorkspaceFlow-BJy-W2XI.js → AddWorkspaceFlow-AyzSdx5w.js} +1 -1
- package/web/dist/assets/{FirstRunWizard-V-idMQB7.js → FirstRunWizard-DGB5zWhl.js} +1 -1
- package/web/dist/assets/{MarketplaceDrawer-D4ldgvSM.js → MarketplaceDrawer-DAZ-crqq.js} +1 -1
- package/web/dist/assets/{TaskGraphDrawer-BSxRbr1h.js → TaskGraphDrawer-DYk-0uKD.js} +1 -1
- package/web/dist/assets/{WhatsNewDialog-C-hpR8y4.js → WhatsNewDialog-B5tu3MV2.js} +1 -1
- package/web/dist/assets/{WorkerModal-EuNxsCtr.js → WorkerModal-C73K7SUg.js} +1 -1
- package/web/dist/assets/{WorkflowsDrawer-CoT6kWcM.js → WorkflowsDrawer-mrSAPqAh.js} +1 -1
- package/web/dist/assets/{WorkspaceMemoryDrawer-BXx4Z0kx.js → WorkspaceMemoryDrawer-CCz3HB4F.js} +1 -1
- package/web/dist/assets/{WorkspaceTaskDrawer-DKRRttxQ.js → WorkspaceTaskDrawer-C7JzoRp8.js} +1 -1
- package/web/dist/assets/index-CVQc8PLJ.js +84 -0
- package/web/dist/assets/{search-KbSLfFB8.js → search-Bx1xfpzr.js} +1 -1
- package/web/dist/assets/{square-terminal-C89RIZhu.js → square-terminal-Dfr9QC1I.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/index-D43vHIy2.js +0 -84
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
/* Worker names are historical figures. Each role draws from a flavor-matched
|
|
2
|
+
pool (Coder = artisans/inventors, Reviewer = jurists/philosophers, Tester =
|
|
3
|
+
explorers/experimentalists). The Custom role draws from a much larger
|
|
4
|
+
union that also includes the OTHERS pool — emperors, generals, poets,
|
|
5
|
+
composers, novelists, painters — so picking "custom" is also a way of
|
|
6
|
+
asking for the broadest possible cast.
|
|
7
|
+
|
|
8
|
+
Names are returned bare (no numeric suffix). Multi-word English names use
|
|
9
|
+
hyphens (`marcus-aurelius`) so they survive `team send <name>` without
|
|
10
|
+
quoting. We bias hard toward household names — figures a non-specialist
|
|
11
|
+
recognizes on sight — and skip 20th-century political figures plus living
|
|
12
|
+
people. Niche specialists are intentionally left out; Turing earns a pass
|
|
13
|
+
as a patron saint of the craft.
|
|
14
|
+
|
|
15
|
+
English pools stay within the Greco-Roman / European / Anglo-American
|
|
16
|
+
sphere; Chinese pools stay within the Chinese cultural sphere. This
|
|
17
|
+
avoids the "who counts as which tradition" arguments that pop up the
|
|
18
|
+
moment you mix traditions in the same bucket.
|
|
19
|
+
|
|
20
|
+
Pools are sorted (ASCII for `en`, pinyin for `zh`) so adding a name
|
|
21
|
+
shifts only entries after the insertion point — keeps snapshot tests
|
|
22
|
+
stable.
|
|
23
|
+
*/
|
|
24
|
+
const EN_CODER = [
|
|
25
|
+
'ada-lovelace',
|
|
26
|
+
'archimedes',
|
|
27
|
+
'babbage',
|
|
28
|
+
'bell',
|
|
29
|
+
'da-vinci',
|
|
30
|
+
'edison',
|
|
31
|
+
'eiffel',
|
|
32
|
+
'euclid',
|
|
33
|
+
'euler',
|
|
34
|
+
'fermat',
|
|
35
|
+
'fibonacci',
|
|
36
|
+
'gutenberg',
|
|
37
|
+
'leibniz',
|
|
38
|
+
'marconi',
|
|
39
|
+
'morse',
|
|
40
|
+
'nobel',
|
|
41
|
+
'pascal',
|
|
42
|
+
'pythagoras',
|
|
43
|
+
'tesla',
|
|
44
|
+
'turing',
|
|
45
|
+
'watt',
|
|
46
|
+
'wright-brothers',
|
|
47
|
+
];
|
|
48
|
+
const EN_REVIEWER = [
|
|
49
|
+
'adam-smith',
|
|
50
|
+
'aquinas',
|
|
51
|
+
'aristotle',
|
|
52
|
+
'augustine',
|
|
53
|
+
'bacon',
|
|
54
|
+
'calvin',
|
|
55
|
+
'cicero',
|
|
56
|
+
'democritus',
|
|
57
|
+
'descartes',
|
|
58
|
+
'epicurus',
|
|
59
|
+
'hegel',
|
|
60
|
+
'herodotus',
|
|
61
|
+
'hobbes',
|
|
62
|
+
'hume',
|
|
63
|
+
'kant',
|
|
64
|
+
'kierkegaard',
|
|
65
|
+
'locke',
|
|
66
|
+
'luther',
|
|
67
|
+
'machiavelli',
|
|
68
|
+
'marcus-aurelius',
|
|
69
|
+
'montesquieu',
|
|
70
|
+
'nietzsche',
|
|
71
|
+
'plato',
|
|
72
|
+
'rousseau',
|
|
73
|
+
'seneca',
|
|
74
|
+
'socrates',
|
|
75
|
+
'spinoza',
|
|
76
|
+
'voltaire',
|
|
77
|
+
];
|
|
78
|
+
const EN_TESTER = [
|
|
79
|
+
'amundsen',
|
|
80
|
+
'boyle',
|
|
81
|
+
'cook',
|
|
82
|
+
'copernicus',
|
|
83
|
+
'curie',
|
|
84
|
+
'da-gama',
|
|
85
|
+
'darwin',
|
|
86
|
+
'drake',
|
|
87
|
+
'faraday',
|
|
88
|
+
'fleming',
|
|
89
|
+
'galileo',
|
|
90
|
+
'halley',
|
|
91
|
+
'hippocrates',
|
|
92
|
+
'kepler',
|
|
93
|
+
'magellan',
|
|
94
|
+
'marco-polo',
|
|
95
|
+
'mendel',
|
|
96
|
+
'mendeleev',
|
|
97
|
+
'newton',
|
|
98
|
+
'pasteur',
|
|
99
|
+
'planck',
|
|
100
|
+
'ptolemy',
|
|
101
|
+
'rutherford',
|
|
102
|
+
'volta',
|
|
103
|
+
];
|
|
104
|
+
/* Emperors, generals, poets, novelists, composers, painters — household
|
|
105
|
+
names that don't slot neatly into Coder/Reviewer/Tester but should still
|
|
106
|
+
show up when the user picks "Custom". */
|
|
107
|
+
const EN_OTHERS = [
|
|
108
|
+
'alexander',
|
|
109
|
+
'augustus',
|
|
110
|
+
'austen',
|
|
111
|
+
'bach',
|
|
112
|
+
'beethoven',
|
|
113
|
+
'brahms',
|
|
114
|
+
'byron',
|
|
115
|
+
'caesar',
|
|
116
|
+
'cervantes',
|
|
117
|
+
'charlemagne',
|
|
118
|
+
'chopin',
|
|
119
|
+
'cleopatra',
|
|
120
|
+
'dante',
|
|
121
|
+
'dickens',
|
|
122
|
+
'dostoevsky',
|
|
123
|
+
'dumas',
|
|
124
|
+
'einstein',
|
|
125
|
+
'elizabeth-i',
|
|
126
|
+
'franklin',
|
|
127
|
+
'goethe',
|
|
128
|
+
'goya',
|
|
129
|
+
'handel',
|
|
130
|
+
'hannibal',
|
|
131
|
+
'henry-viii',
|
|
132
|
+
'homer',
|
|
133
|
+
'hugo',
|
|
134
|
+
'jefferson',
|
|
135
|
+
'joan-of-arc',
|
|
136
|
+
'keats',
|
|
137
|
+
'leonidas',
|
|
138
|
+
'lincoln',
|
|
139
|
+
'liszt',
|
|
140
|
+
'louis-xiv',
|
|
141
|
+
'michelangelo',
|
|
142
|
+
'milton',
|
|
143
|
+
'monet',
|
|
144
|
+
'mozart',
|
|
145
|
+
'napoleon',
|
|
146
|
+
'nightingale',
|
|
147
|
+
'orwell',
|
|
148
|
+
'picasso',
|
|
149
|
+
'poe',
|
|
150
|
+
'raphael',
|
|
151
|
+
'rembrandt',
|
|
152
|
+
'schubert',
|
|
153
|
+
'shakespeare',
|
|
154
|
+
'sophocles',
|
|
155
|
+
'tchaikovsky',
|
|
156
|
+
'titian',
|
|
157
|
+
'tolstoy',
|
|
158
|
+
'twain',
|
|
159
|
+
'van-gogh',
|
|
160
|
+
'velazquez',
|
|
161
|
+
'verdi',
|
|
162
|
+
'vermeer',
|
|
163
|
+
'virgil',
|
|
164
|
+
'vivaldi',
|
|
165
|
+
'wagner',
|
|
166
|
+
'washington',
|
|
167
|
+
'whitman',
|
|
168
|
+
'wilde',
|
|
169
|
+
'woolf',
|
|
170
|
+
'wordsworth',
|
|
171
|
+
];
|
|
172
|
+
const ZH_CODER = [
|
|
173
|
+
'八大山人',
|
|
174
|
+
'毕昇',
|
|
175
|
+
'蔡伦',
|
|
176
|
+
'干将',
|
|
177
|
+
'顾恺之',
|
|
178
|
+
'黄道婆',
|
|
179
|
+
'李冰',
|
|
180
|
+
'柳公权',
|
|
181
|
+
'鲁班',
|
|
182
|
+
'莫邪',
|
|
183
|
+
'墨子',
|
|
184
|
+
'沈括',
|
|
185
|
+
'宋应星',
|
|
186
|
+
'唐寅',
|
|
187
|
+
'王羲之',
|
|
188
|
+
'文徵明',
|
|
189
|
+
'吴道子',
|
|
190
|
+
'颜真卿',
|
|
191
|
+
'张衡',
|
|
192
|
+
'张择端',
|
|
193
|
+
'郑板桥',
|
|
194
|
+
'祖冲之',
|
|
195
|
+
];
|
|
196
|
+
const ZH_REVIEWER = [
|
|
197
|
+
'班固',
|
|
198
|
+
'包拯',
|
|
199
|
+
'狄仁杰',
|
|
200
|
+
'董仲舒',
|
|
201
|
+
'范仲淹',
|
|
202
|
+
'顾炎武',
|
|
203
|
+
'管仲',
|
|
204
|
+
'海瑞',
|
|
205
|
+
'韩非',
|
|
206
|
+
'韩愈',
|
|
207
|
+
'嵇康',
|
|
208
|
+
'贾谊',
|
|
209
|
+
'孔子',
|
|
210
|
+
'老子',
|
|
211
|
+
'林则徐',
|
|
212
|
+
'柳宗元',
|
|
213
|
+
'孟子',
|
|
214
|
+
'欧阳修',
|
|
215
|
+
'商鞅',
|
|
216
|
+
'司马光',
|
|
217
|
+
'司马迁',
|
|
218
|
+
'谭嗣同',
|
|
219
|
+
'王安石',
|
|
220
|
+
'王守仁',
|
|
221
|
+
'魏徵',
|
|
222
|
+
'荀子',
|
|
223
|
+
'张居正',
|
|
224
|
+
'周敦颐',
|
|
225
|
+
'朱熹',
|
|
226
|
+
'庄子',
|
|
227
|
+
];
|
|
228
|
+
const ZH_TESTER = [
|
|
229
|
+
'班超',
|
|
230
|
+
'扁鹊',
|
|
231
|
+
'法显',
|
|
232
|
+
'葛洪',
|
|
233
|
+
'华佗',
|
|
234
|
+
'鉴真',
|
|
235
|
+
'郦道元',
|
|
236
|
+
'李时珍',
|
|
237
|
+
'神农',
|
|
238
|
+
'苏武',
|
|
239
|
+
'孙思邈',
|
|
240
|
+
'陶弘景',
|
|
241
|
+
'徐光启',
|
|
242
|
+
'徐霞客',
|
|
243
|
+
'玄奘',
|
|
244
|
+
'张骞',
|
|
245
|
+
'张仲景',
|
|
246
|
+
'郑和',
|
|
247
|
+
];
|
|
248
|
+
/* Household names from outside the artisan / jurist / explorer triad —
|
|
249
|
+
emperors, generals, strategists, poets, novelists, painters. Feeds the
|
|
250
|
+
Custom pool so it's the broadest cast in the system, including the
|
|
251
|
+
figures most Chinese users will recognize first. */
|
|
252
|
+
const ZH_OTHERS = [
|
|
253
|
+
'白居易',
|
|
254
|
+
'蔡文姬',
|
|
255
|
+
'曹操',
|
|
256
|
+
'曹雪芹',
|
|
257
|
+
'曹植',
|
|
258
|
+
'程咬金',
|
|
259
|
+
'大禹',
|
|
260
|
+
'杜甫',
|
|
261
|
+
'杜牧',
|
|
262
|
+
'范蠡',
|
|
263
|
+
'关羽',
|
|
264
|
+
'汉武帝',
|
|
265
|
+
'韩信',
|
|
266
|
+
'忽必烈',
|
|
267
|
+
'花木兰',
|
|
268
|
+
'黄帝',
|
|
269
|
+
'霍去病',
|
|
270
|
+
'姜子牙',
|
|
271
|
+
'康熙',
|
|
272
|
+
'李白',
|
|
273
|
+
'李广',
|
|
274
|
+
'李靖',
|
|
275
|
+
'李清照',
|
|
276
|
+
'李煜',
|
|
277
|
+
'刘邦',
|
|
278
|
+
'刘备',
|
|
279
|
+
'刘伯温',
|
|
280
|
+
'柳永',
|
|
281
|
+
'陆游',
|
|
282
|
+
'罗贯中',
|
|
283
|
+
'吕布',
|
|
284
|
+
'吕不韦',
|
|
285
|
+
'孟浩然',
|
|
286
|
+
'蒙恬',
|
|
287
|
+
'努尔哈赤',
|
|
288
|
+
'庞统',
|
|
289
|
+
'蒲松龄',
|
|
290
|
+
'戚继光',
|
|
291
|
+
'乾隆',
|
|
292
|
+
'秦始皇',
|
|
293
|
+
'屈原',
|
|
294
|
+
'上官婉儿',
|
|
295
|
+
'施耐庵',
|
|
296
|
+
'司马懿',
|
|
297
|
+
'苏轼',
|
|
298
|
+
'孙膑',
|
|
299
|
+
'孙权',
|
|
300
|
+
'孙武',
|
|
301
|
+
'孙中山',
|
|
302
|
+
'唐太宗',
|
|
303
|
+
'唐玄宗',
|
|
304
|
+
'陶渊明',
|
|
305
|
+
'王维',
|
|
306
|
+
'卫青',
|
|
307
|
+
'文天祥',
|
|
308
|
+
'吴承恩',
|
|
309
|
+
'吴起',
|
|
310
|
+
'萧何',
|
|
311
|
+
'谢安',
|
|
312
|
+
'辛弃疾',
|
|
313
|
+
'杨贵妃',
|
|
314
|
+
'雍正',
|
|
315
|
+
'虞姬',
|
|
316
|
+
'岳飞',
|
|
317
|
+
'张飞',
|
|
318
|
+
'张良',
|
|
319
|
+
'张仪',
|
|
320
|
+
'赵子龙',
|
|
321
|
+
'周瑜',
|
|
322
|
+
'朱棣',
|
|
323
|
+
'诸葛亮',
|
|
324
|
+
'朱元璋',
|
|
325
|
+
'左宗棠',
|
|
326
|
+
];
|
|
327
|
+
const EN_CUSTOM = [...EN_CODER, ...EN_REVIEWER, ...EN_TESTER, ...EN_OTHERS];
|
|
328
|
+
const ZH_CUSTOM = [...ZH_CODER, ...ZH_REVIEWER, ...ZH_TESTER, ...ZH_OTHERS];
|
|
329
|
+
/* Sentinel = watchers of the sky and of the record: astronomers, historians,
|
|
330
|
+
and one mythological hundred-eyed guard. Observation without intervention. */
|
|
331
|
+
const EN_SENTINEL = [
|
|
332
|
+
'argus',
|
|
333
|
+
'cassandra',
|
|
334
|
+
'copernicus',
|
|
335
|
+
'halley',
|
|
336
|
+
'herodotus',
|
|
337
|
+
'hypatia',
|
|
338
|
+
'kepler',
|
|
339
|
+
'ptolemy',
|
|
340
|
+
'thucydides',
|
|
341
|
+
'tycho-brahe',
|
|
342
|
+
];
|
|
343
|
+
const ZH_SENTINEL = [
|
|
344
|
+
'班固',
|
|
345
|
+
'郭守敬',
|
|
346
|
+
'沈括',
|
|
347
|
+
'司马光',
|
|
348
|
+
'司马迁',
|
|
349
|
+
'一行',
|
|
350
|
+
'张衡',
|
|
351
|
+
'祖冲之',
|
|
352
|
+
];
|
|
353
|
+
const POOLS = {
|
|
354
|
+
en: {
|
|
355
|
+
coder: EN_CODER,
|
|
356
|
+
reviewer: EN_REVIEWER,
|
|
357
|
+
tester: EN_TESTER,
|
|
358
|
+
sentinel: EN_SENTINEL,
|
|
359
|
+
custom: EN_CUSTOM,
|
|
360
|
+
},
|
|
361
|
+
zh: {
|
|
362
|
+
coder: ZH_CODER,
|
|
363
|
+
reviewer: ZH_REVIEWER,
|
|
364
|
+
tester: ZH_TESTER,
|
|
365
|
+
sentinel: ZH_SENTINEL,
|
|
366
|
+
custom: ZH_CUSTOM,
|
|
367
|
+
},
|
|
368
|
+
};
|
|
369
|
+
const nextRandomUint32 = () => {
|
|
370
|
+
const values = new Uint32Array(1);
|
|
371
|
+
globalThis.crypto.getRandomValues(values);
|
|
372
|
+
return values[0] ?? 0;
|
|
373
|
+
};
|
|
374
|
+
export const generateWorkerName = ({ language = 'en', role = 'coder', usedNames, nextUint32 = nextRandomUint32, } = {}) => {
|
|
375
|
+
const pool = POOLS[language][role];
|
|
376
|
+
const available = usedNames && usedNames.size > 0 ? pool.filter((name) => !usedNames.has(name)) : pool;
|
|
377
|
+
// Every role pool has dozens of figures, so exhaustion is a corner case
|
|
378
|
+
// we tolerate by falling back to the full pool and accepting a duplicate
|
|
379
|
+
// rather than throwing or returning an empty string.
|
|
380
|
+
const draw = available.length > 0 ? available : pool;
|
|
381
|
+
return draw[nextUint32() % draw.length];
|
|
382
|
+
};
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-
|
|
2
|
-
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-D43vHIy2.js";import{S as pe}from"./search-KbSLfFB8.js";import{S as he}from"./square-terminal-C89RIZhu.js";const fe=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ge=z("bookmark-plus",fe);const be=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ve=z("dices",be);const ke=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===c;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{s(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ge,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:l=>n(l.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(te,{commandPresetId:s,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:x})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:m=>t(m.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-D4ldgvSM.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(me,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarketplaceDrawer-DAZ-crqq.js","assets/index-CVQc8PLJ.js","assets/index-DYIPzuPD.css","assets/search-Bx1xfpzr.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as z,j as e,u as j,r as d,C as M,x as L,t as U,J as Y,Q as Z,ag as ee,ah as te,e as ae,i as re,R as se,P as ne,O as oe,k as le,m as ie,a0 as de,z as ce,X as me,T as xe,ai as ue}from"./index-CVQc8PLJ.js";import{S as pe}from"./search-Bx1xfpzr.js";import{S as he}from"./square-terminal-Dfr9QC1I.js";const fe=[["path",{d:"M12 7v6",key:"lw1j43"}],["path",{d:"M15 10H9",key:"o6yqo3"}],["path",{d:"M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z",key:"oz39mx"}]],ge=z("bookmark-plus",fe);const be=[["rect",{width:"12",height:"12",x:"2",y:"10",rx:"2",ry:"2",key:"6agr2n"}],["path",{d:"m17.92 14 3.5-3.5a2.24 2.24 0 0 0 0-3l-5-4.92a2.24 2.24 0 0 0-3 0L10 6",key:"1o487t"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 14h.01",key:"ssrbsk"}],["path",{d:"M15 6h.01",key:"cblpky"}],["path",{d:"M18 9h.01",key:"2061c0"}]],ve=z("dices",be);const ke=[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]],je=z("store",ke),ye=[{value:"coder"},{value:"reviewer"},{value:"tester"},{value:"sentinel"},{value:"custom",dashed:!0}],I=t=>`role.${t}`,S=({children:t})=>e.jsx("span",{className:"text-sm font-medium text-sec",children:t}),Ne=({active:t,spec:a,onSelect:n})=>{const{t:s}=j();return e.jsxs("button",{type:"button",onClick:n,"aria-pressed":t,"data-testid":`role-card-${a.value}`,className:`selectable-card${a.dashed?" selectable-card--dashed":""} flex items-center gap-3 px-3 py-2`,children:[e.jsx(ee,{role:a.value,size:20}),e.jsx("span",{className:"flex-1 text-left text-base font-medium text-pri",children:s(I(a.value))}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Ce=({onRoleChange:t,workerRole:a})=>{const{t:n}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:n("addWorker.role")}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ye.map(s=>e.jsx(Ne,{active:a===s.value,spec:s,onSelect:()=>t(s.value)},s.value))})]})},we=({customTemplates:t,disabledReason:a,onDeleteTemplate:n,onSelect:s,selectedTemplateId:c})=>{const{t:o}=j(),[g,x]=d.useState(!1),[m,u]=d.useState(""),[b,k]=d.useState(null),y=d.useRef(null),N=d.useMemo(()=>t.find(r=>r.id===c)??null,[t,c]),v=d.useMemo(()=>{const r=m.trim().toLowerCase();return r?t.filter(p=>p.name.toLowerCase().includes(r)||p.description.toLowerCase().includes(r)):t},[t,m]);return d.useEffect(()=>{if(!g)return;const r=h=>{h.key==="Escape"&&x(!1)},p=h=>{const l=y.current;l&&!l.contains(h.target)&&x(!1)};return document.addEventListener("keydown",r),document.addEventListener("pointerdown",p),()=>{document.removeEventListener("keydown",r),document.removeEventListener("pointerdown",p)}},[g]),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:o("addWorker.template")}),e.jsxs("div",{ref:y,className:"relative",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":g,"data-testid":"role-template-picker-trigger",onClick:()=>x(r=>!r),className:"flex w-full items-center justify-between gap-2 rounded border px-3 py-2 text-left text-sm transition-colors hover:bg-3",style:{borderColor:"var(--border)",background:"var(--bg-1)"},children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-pri",children:N?N.name:o("addWorker.templatePickPlaceholder")}),e.jsx(M,{size:14,className:"shrink-0 text-ter","aria-hidden":!0})]}),g?e.jsxs("div",{role:"listbox","aria-label":o("addWorker.template"),"data-testid":"role-template-picker-menu",className:"elev-2 absolute left-0 right-0 top-full z-30 mt-1 flex max-h-72 flex-col overflow-hidden rounded border",style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)"},children:[e.jsxs("div",{className:"flex items-center gap-2 border-b px-2 py-1.5",style:{borderColor:"var(--border)"},children:[e.jsx(pe,{size:14,className:"text-ter","aria-hidden":!0}),e.jsx("input",{value:m,onChange:r=>u(r.currentTarget.value),placeholder:o("addWorker.templateSearchPlaceholder"),"data-testid":"role-template-search-input",className:"w-full bg-transparent text-sm text-pri outline-none placeholder:text-ter",spellCheck:!1})]}),e.jsx("div",{className:"flex-1 overflow-y-auto py-1",children:t.length===0?e.jsx("div",{"data-testid":"role-template-empty-state",className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateEmpty")}):v.length===0?e.jsx("div",{className:"px-3 py-3 text-center text-sm text-ter",children:o("addWorker.templateNoMatch")}):v.map(r=>{const p=r.id===c;return e.jsxs("div",{className:"relative",children:[e.jsxs("button",{type:"button",role:"option","aria-selected":p,"data-testid":`role-template-option-${r.id}`,onClick:()=>{s(r.id),x(!1),u("")},className:"flex w-full items-center gap-2 px-3 py-1.5 pr-9 text-left text-sm text-pri hover:bg-3",style:p?{background:"var(--bg-3)"}:void 0,children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:r.name}),p?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]}),e.jsx("button",{type:"button","aria-label":o("addWorker.templateDeleteAria",{name:r.name}),"data-testid":`role-template-delete-${r.id}`,disabled:!!a,title:a??void 0,onClick:h=>{h.preventDefault(),h.stopPropagation(),!a&&k(r)},className:"absolute right-1 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded text-ter transition-colors hover:bg-3 hover:text-pri",children:e.jsx(U,{size:14,"aria-hidden":!0})})]},r.id)})}),c!==null?e.jsx("button",{type:"button","data-testid":"role-template-clear",onClick:()=>{s(null),x(!1),u("")},className:"border-t px-3 py-1.5 text-left text-sm text-ter transition-colors hover:bg-3 hover:text-pri",style:{borderColor:"var(--border)"},children:o("addWorker.templateClear")}):null]}):null]}),e.jsx(Y,{open:b!==null,onOpenChange:r=>{r||k(null)},title:o("addWorker.templateDeleteTitle"),description:b?o("addWorker.templateDeleteConfirm",{name:b.name}):"",confirmLabel:o("addWorker.templateDeleteConfirmLabel"),confirmKind:"danger",onConfirm:()=>{if(!b||a)return;const r=b.id;k(null),n(r)}})]})},We=({canSaveAsTemplate:t,modified:a,onChange:n,onReset:s,onSaveAsTemplate:c,roleDescription:o,templateBusy:g,workerRole:x,writeDisabledReason:m})=>{const{t:u,language:b}=j(),[k,y]=d.useState(!1),[N,v]=d.useState(!1),[r,p]=d.useState("");d.useEffect(()=>{(x==="custom"||a)&&y(!0)},[a,x]),d.useEffect(()=>{t||(v(!1),p(""))},[t]);const h=b==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{open:k,onToggle:l=>y(l.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:u("addWorker.roleInstructions")}),a?e.jsxs("span",{className:"text-xs text-ter",children:["· ",u("addWorker.modifiedFrom",{role:u(I(x))})]}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[k?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:h}),t&&!N?e.jsxs("button",{type:"button","data-testid":"role-template-save",disabled:!!m,title:m??void 0,onClick:l=>{l.preventDefault(),l.stopPropagation(),v(!0)},className:"flex items-center gap-1 rounded px-2 py-0.5 text-xs font-medium transition-colors hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50",style:{color:"var(--accent)",background:"color-mix(in oklab, var(--accent) 14%, transparent)"},children:[e.jsx(ge,{size:12,"aria-hidden":!0}),u("addWorker.saveAsTemplate")]}):null,a?e.jsxs("button",{type:"button",className:"flex items-center gap-1 rounded px-1.5 py-0.5 text-xs text-ter transition-colors hover:bg-3 hover:text-sec",onClick:l=>{l.preventDefault(),l.stopPropagation(),s()},children:[e.jsx(Z,{size:12,"aria-hidden":!0}),u("addWorker.reset")]}):null]})]}),e.jsx("textarea",{"aria-label":"Role instructions",id:"add-worker-role-instructions",value:o,rows:5,onChange:l=>n(l.currentTarget.value),placeholder:x==="custom"?u("addWorker.customPlaceholder"):void 0,title:u("addWorker.roleInstructionsTitle"),className:"input mono resize-y text-sm",style:{minHeight:150},"data-testid":"role-instructions-textarea"}),t&&N?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{autoFocus:!0,value:r,onChange:l=>p(l.currentTarget.value),placeholder:u("addWorker.templateNamePlaceholder"),"data-testid":"role-template-save-name",className:"input flex-1 text-sm"}),e.jsx("button",{type:"button",disabled:g||!r.trim()||!!m,title:m??void 0,"data-testid":"role-template-save-confirm",onClick:async()=>{if(m)return;const l=r.trim();if(l)try{await c(l),v(!1),p("")}catch{}},className:"icon-btn icon-btn--primary text-xs",children:u("addWorker.templateSaveConfirm")}),e.jsx("button",{type:"button","data-testid":"role-template-save-cancel",onClick:()=>{v(!1),p("")},className:"icon-btn text-xs",children:u("common.cancel")})]}):null]})},D=({active:t,command:a,displayName:n,logoPresetId:s,notFound:c=!1,testId:o,onSelect:g})=>{const{t:x}=j(),m=e.jsx("span",{className:"inline-flex h-5 w-5 shrink-0 items-center justify-center rounded border border-border bg-surface-1 text-ter","data-testid":`${o}-generic-icon`,"aria-hidden":!0,children:e.jsx(he,{size:13})});return e.jsxs("button",{type:"button",onClick:g,"aria-pressed":t,"data-testid":o,className:"selectable-card flex items-center justify-between gap-3 px-3 py-2",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(te,{commandPresetId:s,fallback:m,size:22}),e.jsxs("span",{className:"flex min-w-0 flex-col items-start gap-0.5",children:[e.jsx("span",{className:"truncate text-base font-medium text-pri",children:n}),e.jsxs("span",{className:"mono truncate text-xs text-ter",children:[a,c?` · ${x("addWorker.agentNotFound")}`:""]})]})]}),t?e.jsx(L,{size:14,className:"shrink-0 text-accent","aria-hidden":!0}):null]})},Se=({active:t,preset:a,onSelect:n})=>e.jsx(D,{active:t,command:a.command,displayName:a.displayName,logoPresetId:a.id,notFound:a.available===!1,testId:`agent-radio-${a.id}`,onSelect:n}),ze=({commandPresetId:t,commandPresets:a,onPresetChange:n})=>{const{t:s}=j();return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:s("addWorker.agentCli")}),a.length===0?e.jsx("div",{className:"text-sm text-ter",children:s("addWorker.loadingPresets")}):e.jsxs("div",{className:"grid grid-cols-2 gap-2 max-md:grid-cols-1",children:[a.map(c=>e.jsx(Se,{active:t===c.id,preset:c,onSelect:()=>n(c.id)},c.id)),e.jsx(D,{active:t==="",command:s("addWorker.genericCommand"),displayName:s("addWorker.genericAgent"),testId:"agent-radio-generic",onSelect:()=>n("")})]})]})},Me=({onChange:t,value:a})=>{const{t:n,language:s}=j(),[c,o]=d.useState(!1),g=a.trim(),x=s==="zh"?"点击展开":"Click to expand";return e.jsxs("details",{onToggle:m=>o(m.currentTarget.open),className:"group flex flex-col gap-2",children:[e.jsxs("summary",{className:"flex cursor-pointer select-none items-center justify-between gap-2 list-none rounded-lg p-2 -mx-2 hover:bg-3/50 transition-colors group/summary",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-3 border border-bright/30 text-ter transition-colors group-hover/summary:text-pri group-hover/summary:border-accent/40",children:e.jsx(M,{size:12,"aria-hidden":!0,className:"-rotate-90 transition-transform duration-150 group-open:rotate-0"})}),e.jsx("span",{className:"text-sm font-semibold text-pri transition-colors group-hover/summary:text-accent",children:n("addWorker.startupCommand")}),g?e.jsxs("span",{className:"truncate text-xs text-ter",children:["· ",n("addWorker.startupOverrides")]}):null]}),c?null:e.jsx("span",{className:"text-[10px] text-ter font-semibold tracking-wider uppercase opacity-60 group-hover/summary:opacity-100 group-hover/summary:text-accent transition-all pr-1",children:x})]}),e.jsxs("div",{className:"flex flex-col gap-2 rounded border bg-2 p-3",style:{borderColor:"var(--border)"},children:[e.jsx("input",{"aria-label":"Startup command",value:a,onChange:m=>t(m.currentTarget.value),placeholder:"qwen --model qwen3-coder",className:"input mono text-sm",spellCheck:!1}),e.jsx("p",{className:"text-sm leading-5 text-ter",children:n("addWorker.startupHelp",{example:"claude --resume <session-id>"})})]})]})},Le=d.lazy(()=>ue(()=>import("./MarketplaceDrawer-DAZ-crqq.js"),__vite__mapDeps([0,1,2,3])).then(t=>({default:t.MarketplaceDrawer}))),_e=({commandPresets:t,commandPresetId:a,creating:n=!1,customTemplates:s,onApplyMarketplaceImport:c,onClose:o,onDeleteTemplate:g,onNameChange:x,onPresetChange:m,onRandomName:u,onRoleDescriptionChange:b,onRoleDescriptionReset:k,onRoleChange:y,onSaveAsTemplate:N,onStartupCommandChange:v,onSubmit:r,onTemplateChange:p,roleDescription:h,roleDescriptionDefault:l,selectedTemplateId:P,startupCommand:E,templateBusy:B,workerName:O,workerRole:W,writeDisabledReason:w})=>{const{t:i}=j(),_=ae(),C=re(),[q,A]=d.useState(!1),[H,K]=d.useState(!1),V=d.useMemo(()=>new Set(s.map(f=>f.name)),[s]),Q=f=>{c(f),_.show({kind:"success",message:i("marketplace.imported",{name:f.name})})},J=f=>{f||o()},X=h!==l,$=t.find(f=>f.id===a),T=E.trim(),G=()=>w||(O.trim()?!a&&!T?i("addWorker.pickCliOrStartup"):$?.available===!1&&!T?i("addWorker.unavailable",{name:$.displayName}):h.trim()?null:i("addWorker.emptyInstructions"):i("addWorker.enterName")),R=f=>{const F=G();if(F){f.preventDefault(),_.show({kind:"warning",message:F});return}r(f)};return e.jsxs(se,{open:!0,onOpenChange:J,children:[e.jsxs(ne,{children:[e.jsx(oe,{"data-testid":"add-worker-overlay",className:"app-overlay fixed inset-0 z-40"}),e.jsx("div",{className:"pointer-events-none fixed inset-0 z-50 grid place-items-center p-4 max-md:items-end max-md:p-0",children:e.jsx(le,{"data-testid":"add-worker-content","data-mobile":C||void 0,className:`${C?"dialog-slide-up add-worker-sheet":"dialog-scale-pop"} elev-2 pointer-events-auto flex max-h-[calc(100vh-32px)] w-[560px] max-w-full flex-col overflow-hidden rounded-lg border pointer-coarse:max-h-[85dvh] max-md:w-full max-md:rounded-b-none max-md:rounded-t-xl`,style:{background:"var(--bg-elevated)",borderColor:"var(--border-bright)",...C?{height:"85dvh"}:{}},children:e.jsxs("form",{onSubmit:R,"aria-label":i("addWorker.title"),className:"flex min-h-0 flex-1 flex-col overflow-hidden max-h-full",children:[e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b px-5 py-4 max-md:px-4",style:{borderColor:"var(--border)"},children:[e.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[e.jsx(ie,{className:"text-lg font-semibold text-pri",children:i("addWorker.title")}),e.jsx(de,{className:"text-sm text-ter",children:i("addWorker.description",{command:"team send"})})]}),C?e.jsx(ce,{asChild:!0,children:e.jsx("button",{type:"button","aria-label":i("common.closeDialog"),"data-testid":"add-worker-close",className:"-mr-1 flex h-10 w-10 shrink-0 items-center justify-center rounded-md text-sec",style:{background:"var(--bg-2)"},children:e.jsx(me,{size:18,"aria-hidden":!0})})}):null]}),e.jsxs("div",{className:"flex flex-1 min-h-0 flex-col gap-4 overflow-y-auto px-5 py-4 max-md:gap-5 max-md:px-4",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(S,{children:i("addWorker.name")}),e.jsxs("div",{className:"relative flex items-center",children:[e.jsx("input",{autoFocus:!C,value:O,onChange:f=>x(f.target.value),placeholder:i("addWorker.namePlaceholder"),className:"input w-full pr-24",style:{borderRadius:"10px"}}),e.jsx("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2",children:e.jsx(xe,{label:i("addWorker.randomTooltip"),children:e.jsxs("button",{type:"button","aria-label":i("addWorker.randomAria"),className:"flex h-7 items-center gap-1.5 rounded-lg border border-bright/10 bg-3 px-2.5 text-xs font-semibold text-sec hover:text-pri hover:bg-4 active:scale-95 transition-all outline-none",onClick:u,"data-testid":"random-worker-name",children:[e.jsx(ve,{size:13,"aria-hidden":!0}),e.jsx("span",{children:i("addWorker.random")})]})})})]})]}),e.jsx(Ce,{workerRole:W,onRoleChange:y}),e.jsxs("button",{type:"button",onClick:()=>{K(!0),A(!0)},"data-testid":"open-marketplace",className:"marketplace-browse-btn flex cursor-pointer items-center gap-2 self-start rounded-lg border px-3 py-2 text-xs font-semibold text-sec outline-none transition-all duration-200 hover:text-pri hover:-translate-y-0.5 active:scale-98 shadow-sm hover:shadow-md",style:{background:"linear-gradient(to bottom, var(--bg-1), var(--bg-0))",borderColor:"var(--border-bright)","--tw-ring-color":"color-mix(in oklab, var(--accent) 45%, transparent)"},children:[e.jsx(je,{size:14,"aria-hidden":!0,className:"text-accent"}),e.jsx("span",{children:i("marketplace.openFromAddWorker")})]}),W==="custom"?e.jsx(we,{customTemplates:s,disabledReason:w,onDeleteTemplate:g,onSelect:p,selectedTemplateId:P}):null,e.jsx(We,{canSaveAsTemplate:W==="custom"&&!P&&h.trim().length>0,modified:X,onChange:b,onReset:k,onSaveAsTemplate:N,roleDescription:h,templateBusy:B,workerRole:W,writeDisabledReason:w}),e.jsx(ze,{commandPresetId:a,commandPresets:t,onPresetChange:m}),e.jsx(Me,{value:E,onChange:v})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-2 border-t px-5 py-3 max-md:px-4 max-md:pb-[max(12px,env(safe-area-inset-bottom))]",style:{borderColor:"var(--border)",background:"var(--bg-2)"},children:[e.jsx("button",{type:"button",onClick:o,className:`icon-btn border border-bright/20 rounded-lg hover:bg-3 hover:text-pri transition-all active:scale-95 ${C?"flex-1":""}`,"data-testid":"add-worker-cancel",children:i("addWorker.cancel")}),e.jsx("button",{type:"submit",disabled:n||!!w,title:w??void 0,className:`icon-btn icon-btn--primary rounded-lg font-bold shadow-md hover:shadow-lg transition-all active:scale-[0.97] hover:-translate-y-0.5 ${C?"flex-[2]":""}`,"data-testid":"add-worker-submit",children:i(n?"addWorker.creating":"addWorker.create")})]})]})})})]}),H?e.jsx(d.Suspense,{fallback:null,children:e.jsx(Le,{open:q,onClose:()=>A(!1),onImport:Q,importedNames:V})}):null]})};export{_e as AddWorkerDialog};
|