@oh-my-dsh/auto-team 0.1.5 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js ADDED
@@ -0,0 +1,616 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@oh-my-dsh/auto-team",
3
+ factory: (require) => {
4
+ const module = { exports: {} };
5
+ const exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let react = require("react");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ //#region src/client/locales.ts
10
+ /** Locale namespace owned by the Auto Team composer control. */
11
+ const LOCALE = "auto-team.parallelism";
12
+ const zh = {
13
+ title: "子 Agent 并行度",
14
+ pill: "并行度",
15
+ toggle: "启用并行度提示",
16
+ restrictWrites: "启用写入限制",
17
+ restrictWritesNote: "仅控制 Auto Team;DSH 原生权限不变。",
18
+ description: "设定提示中的并行子 Agent 数量范围,不限制原生调度。",
19
+ lower: "下限",
20
+ upper: "上限",
21
+ range: "并行度范围",
22
+ running: "运行中的子 Agent:{count}",
23
+ loading: "正在读取会话的并行度…",
24
+ unavailable: "当前会话的并行度暂不可用。",
25
+ updateFailed: "保存失败,请重试。",
26
+ saving: "正在保存…",
27
+ apply: "保存范围",
28
+ close: "关闭"
29
+ };
30
+ const en = {
31
+ title: "Subagent parallelism",
32
+ pill: "Parallelism",
33
+ toggle: "Enable parallelism guidance",
34
+ restrictWrites: "Enable write restrictions",
35
+ restrictWritesNote: "Controls Auto Team only. Native DSH permissions are unchanged.",
36
+ description: "Set the suggested range for concurrent subagents. This does not limit native scheduling.",
37
+ lower: "Lower bound",
38
+ upper: "Upper bound",
39
+ range: "Parallelism range",
40
+ running: "Running subagents: {count}",
41
+ loading: "Reading session parallelism…",
42
+ unavailable: "Parallelism is unavailable for this session.",
43
+ updateFailed: "Could not save. Please try again.",
44
+ saving: "Saving…",
45
+ apply: "Save range",
46
+ close: "Close"
47
+ };
48
+ /** Decode the owner-only bridge result without trusting untyped wire values. */
49
+ function isSnapshot(value) {
50
+ if (typeof value !== "object" || value === null) return false;
51
+ const { lower, upper, running, enabled, restrictWrites } = value;
52
+ return typeof enabled === "boolean" && typeof restrictWrites === "boolean" && typeof lower === "number" && Number.isInteger(lower) && lower >= 0 && typeof upper === "number" && Number.isInteger(upper) && upper >= lower && upper <= 8 && typeof running === "number" && Number.isSafeInteger(running) && running >= 0;
53
+ }
54
+ /**
55
+ * Bind commands to one retained slot Session; never substitute a
56
+ * selected/global Session.
57
+ */
58
+ function createParallelismBridge(rpc, sessionId, isAvailable) {
59
+ async function call(endpoint, patch, signal) {
60
+ try {
61
+ if (signal.aborted || !isAvailable()) return {
62
+ status: "unavailable",
63
+ retry: false
64
+ };
65
+ const result = await rpc.call("/api", `auto-team/${endpoint}`, {
66
+ ...patch,
67
+ sessionId
68
+ }, signal);
69
+ if (result.ok) {
70
+ if (isSnapshot(result.value)) return {
71
+ status: "ready",
72
+ value: result.value
73
+ };
74
+ return {
75
+ status: "unavailable",
76
+ retry: false
77
+ };
78
+ }
79
+ return {
80
+ status: "unavailable",
81
+ retry: result.error.code === "auto-team/session-unavailable" || result.error.code === "gateway/internal"
82
+ };
83
+ } catch {
84
+ return {
85
+ status: "unavailable",
86
+ retry: !signal.aborted
87
+ };
88
+ }
89
+ }
90
+ return {
91
+ read: async (signal) => {
92
+ return await call("parallelism/get", {}, signal);
93
+ },
94
+ update: async (patch, signal) => {
95
+ return await call("parallelism/update", patch, signal);
96
+ }
97
+ };
98
+ }
99
+ //#endregion
100
+ //#region src/client/style.ts
101
+ /** Rules scoped to the client-owned statistics control and modal. */
102
+ const style = `
103
+ .atp-anchor {
104
+ display: inline-flex;
105
+ min-width: 0;
106
+ font-size: calc(var(--dsh-content-font-size-secondary, 13px) - 1px);
107
+ line-height: calc(20px + var(--dsh-content-font-delta-secondary, 0px));
108
+ }
109
+ .atp-pill {
110
+ display: inline-flex;
111
+ align-items: center;
112
+ gap: 6px;
113
+ box-sizing: border-box;
114
+ max-width: 100%;
115
+ padding: 1px 8px;
116
+ border: 0;
117
+ border-radius: var(--dsw-radius-sm, 6px);
118
+ background: transparent;
119
+ color: var(--dsw-alias-label-tertiary, #b1b4bf);
120
+ font: inherit;
121
+ font-variant-numeric: tabular-nums;
122
+ line-height: inherit;
123
+ white-space: nowrap;
124
+ cursor: pointer;
125
+ }
126
+ .atp-pill:is(:hover, [aria-expanded='true']) {
127
+ background: var(--dsw-alias-interactive-bg-hover, #363943);
128
+ color: var(--dsw-alias-label-secondary, #d8dae0);
129
+ }
130
+ .atp-pill svg { flex: none; }
131
+ .atp-pill-label { overflow: hidden; text-overflow: ellipsis; }
132
+ .atp-dialog {
133
+ box-sizing: border-box;
134
+ width: min(360px, calc(100vw - 24px));
135
+ max-height: calc(100dvh - 24px);
136
+ overflow: auto;
137
+ backdrop-filter: var(--dsw-menu-backdrop-filter);
138
+ padding: 0;
139
+ border: 0;
140
+ border-radius: var(--dsw-radius-lg, 12px);
141
+ background: var(--dsw-specific-menu, #25272c);
142
+ color: var(--dsw-alias-label-secondary, #d8dae0);
143
+ box-shadow: var(--dsw-elevation-prominent, 0 12px 40px #0007);
144
+ --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);
145
+ --atp-accent: var(--dsw-alias-brand-primary-new-colorprimary-new-color, #7b9af7);
146
+ font: inherit;
147
+ font-size: 13px;
148
+ line-height: 1.5;
149
+ }
150
+ .atp-dialog::backdrop { background: rgb(0 0 0 / .32); }
151
+ .atp-body { padding: 16px; }
152
+ .atp-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
153
+ .atp-close { border: 0; border-radius: var(--dsw-radius-sm, 6px); background: transparent; color: inherit; font: inherit; cursor: pointer; }
154
+ .atp-close:hover { background: var(--dsw-alias-interactive-bg-hover, #363943); }
155
+ .atp-title { margin: 0; color: var(--dsw-alias-label-primary, #f2f3f5); font-size: 15px; }
156
+ .atp-description { margin: 4px 0 12px; }
157
+ .atp-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; cursor: pointer; }
158
+ .atp-toggle input { margin: 0; accent-color: var(--atp-accent); }
159
+ .atp-toggle:has(+ .atp-toggle), .atp-toggle:has(+ .atp-toggle-note) { margin-bottom: 6px; }
160
+ .atp-toggle-note { margin: 0 0 14px; color: var(--dsw-alias-label-tertiary, #b1b4bf); }
161
+ .atp-bounds, .atp-scale { display: flex; justify-content: space-between; }
162
+ .atp-slider { position: relative; height: 52px; direction: ltr; }
163
+ .atp-track {
164
+ position: absolute;
165
+ inset: 18px 8px auto;
166
+ height: 4px;
167
+ border-radius: 99px;
168
+ background: var(--dsw-alias-separator-primary, #666a77);
169
+ }
170
+ .atp-selection { position: absolute; inset-block: 0; background: var(--atp-accent); }
171
+ .atp-now {
172
+ position: absolute;
173
+ top: 22px;
174
+ transform: translateX(-50%);
175
+ color: var(--dsw-alias-label-primary, #f2f3f5);
176
+ font: 600 10px/1 sans-serif;
177
+ pointer-events: none;
178
+ }
179
+ .atp-slider input {
180
+ position: absolute;
181
+ inset-inline: 0;
182
+ top: 6px;
183
+ appearance: none;
184
+ width: 100%;
185
+ height: 24px;
186
+ margin: 0;
187
+ background: transparent;
188
+ pointer-events: none;
189
+ }
190
+ /* Separate thumb hit targets vertically, so both can be dragged even at an equal bound. */
191
+ .atp-slider [data-thumb='upper'] { top: 18px; }
192
+ .atp-slider input::-webkit-slider-thumb {
193
+ appearance: none;
194
+ width: 16px;
195
+ height: 12px;
196
+ border: 1px solid currentColor;
197
+ border-radius: 6px;
198
+ background: var(--atp-accent);
199
+ color: var(--dsw-alias-label-primary, #f2f3f5);
200
+ pointer-events: auto;
201
+ cursor: ew-resize;
202
+ }
203
+ .atp-slider input::-moz-range-thumb {
204
+ box-sizing: border-box;
205
+ width: 16px;
206
+ height: 12px;
207
+ border: 1px solid currentColor;
208
+ border-radius: 6px;
209
+ background: var(--atp-accent);
210
+ color: var(--dsw-alias-label-primary, #f2f3f5);
211
+ pointer-events: auto;
212
+ cursor: ew-resize;
213
+ }
214
+ .atp-slider input:focus-visible { z-index: 1; }
215
+ .atp-slider input:focus-visible::-webkit-slider-thumb { outline: 2px solid currentColor; outline-offset: 2px; }
216
+ .atp-slider input:focus-visible::-moz-range-thumb { outline: 2px solid currentColor; outline-offset: 2px; }
217
+ .atp-scale { color: var(--dsw-alias-label-tertiary, #b1b4bf); }
218
+ .atp-running { margin: 8px 0 12px; font-variant-numeric: tabular-nums; }
219
+ .atp-actions { display: flex; justify-content: flex-end; gap: 8px; }
220
+ .atp-actions button {
221
+ padding: 4px 10px;
222
+ border: 1px solid var(--dsw-alias-border-l1, #666a77);
223
+ border-radius: var(--dsw-radius-sm, 6px);
224
+ background: transparent;
225
+ color: inherit;
226
+ font: inherit;
227
+ cursor: pointer;
228
+ }
229
+ .atp-actions .atp-apply:not(:disabled) { border-color: var(--atp-accent); }
230
+ .atp-actions button:disabled { opacity: .55; cursor: default; }
231
+ `;
232
+ //#endregion
233
+ //#region src/client/use-parallelism.ts
234
+ const REFRESH_MS = 1e3;
235
+ function useParallelism(bridge) {
236
+ const [reading, setReading] = (0, react.useState)();
237
+ const [saving, setSaving] = (0, react.useState)(false);
238
+ const [failed, setFailed] = (0, react.useState)(false);
239
+ const current = (0, react.useRef)(void 0);
240
+ (0, react.useEffect)(() => {
241
+ const scope = {
242
+ abort: new AbortController(),
243
+ revision: 0,
244
+ writing: false
245
+ };
246
+ const { signal } = scope.abort;
247
+ current.current = scope;
248
+ const poll = {};
249
+ async function refresh() {
250
+ const { revision } = scope;
251
+ if (!scope.writing) {
252
+ const result = await bridge.read(signal);
253
+ if (signal.aborted) return;
254
+ if (revision === scope.revision) {
255
+ setReading(result);
256
+ if (result.status === "unavailable" && !result.retry) return;
257
+ }
258
+ }
259
+ poll.timer = globalThis.setTimeout(() => {
260
+ refresh();
261
+ }, REFRESH_MS);
262
+ }
263
+ refresh();
264
+ return () => {
265
+ scope.abort.abort();
266
+ globalThis.clearTimeout(poll.timer);
267
+ current.current = void 0;
268
+ };
269
+ }, [bridge]);
270
+ async function save(patch) {
271
+ const scope = current.current;
272
+ if (scope === void 0 || scope.writing) return false;
273
+ scope.writing = true;
274
+ scope.revision += 1;
275
+ setSaving(true);
276
+ setFailed(false);
277
+ const result = await bridge.update(patch, scope.abort.signal);
278
+ if (scope.abort.signal.aborted) return false;
279
+ scope.writing = false;
280
+ setSaving(false);
281
+ if (result.status === "ready") {
282
+ setReading(result);
283
+ return true;
284
+ }
285
+ if (!result.retry) setReading(result);
286
+ setFailed(true);
287
+ return false;
288
+ }
289
+ return {
290
+ reading,
291
+ saving,
292
+ failed,
293
+ save
294
+ };
295
+ }
296
+ //#endregion
297
+ //#region src/client/parallelism-pill.tsx
298
+ const PERCENT = 100;
299
+ function position(value) {
300
+ return `${String(Math.min(value, 8) / 8 * PERCENT)}%`;
301
+ }
302
+ function Range({ bounds, running, translate, saving, onChange }) {
303
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
304
+ role: "group",
305
+ "aria-label": translate("range"),
306
+ children: [
307
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
308
+ className: "atp-bounds",
309
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
310
+ translate("lower"),
311
+ ": ",
312
+ bounds.lower
313
+ ] }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: [
314
+ translate("upper"),
315
+ ": ",
316
+ bounds.upper
317
+ ] })]
318
+ }),
319
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
320
+ className: "atp-slider",
321
+ children: [
322
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
323
+ className: "atp-track",
324
+ "aria-hidden": "true",
325
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
326
+ className: "atp-selection",
327
+ style: {
328
+ left: position(bounds.lower),
329
+ right: `calc(100% - ${position(bounds.upper)})`
330
+ }
331
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
332
+ className: "atp-now",
333
+ style: { left: position(running) },
334
+ children: "O"
335
+ })]
336
+ }),
337
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
338
+ type: "range",
339
+ min: 0,
340
+ max: 8,
341
+ step: 1,
342
+ "data-thumb": "lower",
343
+ "aria-label": translate("lower"),
344
+ value: bounds.lower,
345
+ disabled: saving,
346
+ onChange: (event) => {
347
+ onChange({
348
+ lower: Math.min(event.currentTarget.valueAsNumber, bounds.upper),
349
+ upper: bounds.upper
350
+ });
351
+ }
352
+ }),
353
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
354
+ type: "range",
355
+ min: 0,
356
+ max: 8,
357
+ step: 1,
358
+ "data-thumb": "upper",
359
+ "aria-label": translate("upper"),
360
+ value: bounds.upper,
361
+ disabled: saving,
362
+ onChange: (event) => {
363
+ onChange({
364
+ lower: bounds.lower,
365
+ upper: Math.max(event.currentTarget.valueAsNumber, bounds.lower)
366
+ });
367
+ }
368
+ })
369
+ ]
370
+ }),
371
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
372
+ className: "atp-scale",
373
+ "aria-hidden": "true",
374
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: 0 }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: 8 })]
375
+ })
376
+ ]
377
+ });
378
+ }
379
+ function BranchIcon() {
380
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
381
+ width: "14",
382
+ height: "14",
383
+ viewBox: "0 0 16 16",
384
+ fill: "none",
385
+ stroke: "currentColor",
386
+ "aria-hidden": "true",
387
+ children: [
388
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", { d: "M8 4.5v3.25M3.5 11.5V8h9v3.5" }),
389
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
390
+ cx: "8",
391
+ cy: "3",
392
+ r: "1.5"
393
+ }),
394
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
395
+ cx: "3.5",
396
+ cy: "13",
397
+ r: "1.5"
398
+ }),
399
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
400
+ cx: "12.5",
401
+ cy: "13",
402
+ r: "1.5"
403
+ })
404
+ ]
405
+ });
406
+ }
407
+ function Settings({ readState, translate }) {
408
+ const { reading, saving, failed, save } = readState;
409
+ const [draft, setDraft] = (0, react.useState)();
410
+ if (reading === void 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
411
+ role: "status",
412
+ children: translate("loading")
413
+ });
414
+ if (reading.status !== "ready") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
415
+ role: "status",
416
+ children: translate("unavailable")
417
+ });
418
+ async function applyBounds() {
419
+ if (draft !== void 0 && await save(draft)) setDraft(void 0);
420
+ }
421
+ const snapshot = reading.value;
422
+ const dirty = draft !== void 0 && (draft.lower !== snapshot.lower || draft.upper !== snapshot.upper);
423
+ let submitLabel = translate("apply");
424
+ if (saving) submitLabel = translate("saving");
425
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
426
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
427
+ className: "atp-toggle",
428
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
429
+ type: "checkbox",
430
+ role: "switch",
431
+ checked: snapshot.enabled,
432
+ disabled: saving,
433
+ onChange: (event) => {
434
+ save({ enabled: event.currentTarget.checked });
435
+ }
436
+ }), translate("toggle")]
437
+ }),
438
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
439
+ className: "atp-toggle",
440
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
441
+ type: "checkbox",
442
+ role: "switch",
443
+ checked: snapshot.restrictWrites,
444
+ disabled: saving,
445
+ onChange: (event) => {
446
+ save({ restrictWrites: event.currentTarget.checked });
447
+ }
448
+ }), translate("restrictWrites")]
449
+ }),
450
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
451
+ className: "atp-toggle-note",
452
+ children: translate("restrictWritesNote")
453
+ }),
454
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Range, {
455
+ bounds: draft ?? snapshot,
456
+ running: snapshot.running,
457
+ translate,
458
+ saving,
459
+ onChange: setDraft
460
+ }),
461
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
462
+ className: "atp-running",
463
+ role: "status",
464
+ children: translate("running", { count: snapshot.running })
465
+ }),
466
+ failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
467
+ role: "alert",
468
+ children: translate("updateFailed")
469
+ }),
470
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
471
+ className: "atp-actions",
472
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
473
+ type: "button",
474
+ className: "atp-apply",
475
+ disabled: !dirty || saving,
476
+ onClick: () => {
477
+ applyBounds();
478
+ },
479
+ children: submitLabel
480
+ })
481
+ })
482
+ ] });
483
+ }
484
+ function RootPill({ bridge, translate }) {
485
+ const state = useParallelism(bridge);
486
+ const [open, setOpen] = (0, react.useState)(false);
487
+ const dialog = (0, react.useRef)(null);
488
+ const button = (0, react.useRef)(null);
489
+ const title = (0, react.useId)();
490
+ const snapshot = state.reading;
491
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
492
+ className: "atp-anchor",
493
+ "data-composer-stat": "auto-team.parallelism",
494
+ children: [
495
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: style }),
496
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
497
+ ref: button,
498
+ type: "button",
499
+ className: "atp-pill",
500
+ "aria-haspopup": "dialog",
501
+ "aria-expanded": open,
502
+ onClick: () => {
503
+ dialog.current?.showModal();
504
+ setOpen(true);
505
+ },
506
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BranchIcon, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
507
+ className: "atp-pill-label",
508
+ children: [translate("pill"), snapshot?.status === "ready" && ` · ${String(snapshot.value.running)}`]
509
+ })]
510
+ }),
511
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dialog", {
512
+ ref: dialog,
513
+ className: "atp-dialog",
514
+ "aria-labelledby": title,
515
+ onClick: (event) => {
516
+ if (event.target === event.currentTarget) event.currentTarget.close();
517
+ },
518
+ onClose: () => {
519
+ setOpen(false);
520
+ button.current?.focus();
521
+ },
522
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
523
+ className: "atp-body",
524
+ children: [
525
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
526
+ className: "atp-heading",
527
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
528
+ id: title,
529
+ className: "atp-title",
530
+ children: translate("title")
531
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
532
+ type: "button",
533
+ className: "atp-close",
534
+ "aria-label": translate("close"),
535
+ onClick: () => {
536
+ dialog.current?.close();
537
+ },
538
+ children: "×"
539
+ })]
540
+ }),
541
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
542
+ className: "atp-description",
543
+ children: translate("description")
544
+ }),
545
+ open && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Settings, {
546
+ readState: state,
547
+ translate
548
+ })
549
+ ]
550
+ })
551
+ })
552
+ ]
553
+ });
554
+ }
555
+ /**
556
+ * Read and edit only the Session selected by this renderer's session-scoped
557
+ * seat.
558
+ */
559
+ function ParallelismPill({ bridge, sessionId, t: translate, useGeneration, useSession }) {
560
+ const generation = useGeneration((value) => value);
561
+ if (!useSession((state) => state.subagent === null && !state.removed && state.openState === "open") || generation === void 0) return;
562
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RootPill, {
563
+ bridge,
564
+ translate
565
+ }, `${sessionId}:${String(generation)}`);
566
+ }
567
+ //#endregion
568
+ //#region src/client/index.ts
569
+ /** Browser function-plugin metadata. */
570
+ const name = "auto-team";
571
+ const inject = [
572
+ "connection",
573
+ "locale",
574
+ "sessions",
575
+ "slots"
576
+ ];
577
+ const DOCK_ORDER = 2;
578
+ /** Append a client-owned entry after the native activity and usage pills. */
579
+ function apply(ctx) {
580
+ const locale = ctx.locale;
581
+ const slots = ctx.slots;
582
+ ctx.effect(() => locale.register(LOCALE, {
583
+ zh,
584
+ en
585
+ }), "auto-team: parallelism dictionaries");
586
+ const connection = ctx.get("connection");
587
+ const sessions = ctx.get("sessions");
588
+ const generation = {
589
+ getSnapshot: () => connection.generation.getSnapshot()?.id,
590
+ subscribe: (listener) => connection.generation.subscribe(listener)
591
+ };
592
+ slots.inject("conversation.composer.dock", () => slots.register({
593
+ name: "conversation.composer.dock",
594
+ id: "auto-team.parallelism",
595
+ order: DOCK_ORDER,
596
+ locale: LOCALE,
597
+ inject: (sessionId) => {
598
+ const binding = sessions.binding(sessionId);
599
+ return {
600
+ hooks: { generation },
601
+ bridge: createParallelismBridge(connection.rpc, sessionId, () => {
602
+ if (binding === void 0 || sessions.binding(sessionId) !== binding) return false;
603
+ const state = binding.session.getSnapshot();
604
+ return state.openState === "open" && !state.removed && state.subagent === null && connection.generation.getSnapshot() !== void 0;
605
+ })
606
+ };
607
+ }
608
+ }, ParallelismPill));
609
+ }
610
+ //#endregion
611
+ exports.apply = apply;
612
+ exports.inject = inject;
613
+ exports.name = name;
614
+ return module.exports;
615
+ }
616
+ });