@klarkxy/dsh-delegation 0.1.0 → 0.1.1
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/README.md +3 -3
- package/docs/README.zh-CN.md +3 -3
- package/lib/client.inner.cjs +16 -18
- package/lib/client.inner.cjs.map +1 -1
- package/lib/client.js +16 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,14 +16,14 @@ Enable the plugin in your profile, then reload the page or restart the profile a
|
|
|
16
16
|
|
|
17
17
|
## Use
|
|
18
18
|
|
|
19
|
-
- On the new-session page, use the
|
|
19
|
+
- On the new-session page, use the **Delegate** chip on the same row as the workspace and preset selectors before sending the first message: the chip shows the theme color when delegation is on. The choice locks once the session starts, including after reopening it. The chip applies to the session's main agent, and its subagents automatically receive matching execution guidance.
|
|
20
20
|
- In **Plugins → Delegation Mode**, **Enable Delegation Mode for new sessions** sets the initial state for sessions created later.
|
|
21
21
|
- Simple tasks can be completed directly. For larger tasks, the main agent assigns scoped work to subagents, coordinates shared interfaces, and checks their results before reporting completion.
|
|
22
22
|
|
|
23
23
|
## Limits
|
|
24
24
|
|
|
25
|
-
- Presets that expose subagent tools — Standard and PTC — support delegation; presets without subagent tools (such as Minimal and other complete-persona presets) keep the
|
|
26
|
-
- The
|
|
25
|
+
- Presets that expose subagent tools — Standard and PTC — support delegation; presets without subagent tools (such as Minimal and other complete-persona presets) keep the chip disabled.
|
|
26
|
+
- The chip updates prompt guidance only; tool access and permissions remain unchanged, and delegation is guided rather than strictly enforced.
|
|
27
27
|
- Delegation Mode stays fixed once a session starts, keeping the session's prompt cache stable.
|
|
28
28
|
- Changing the default applies to sessions created afterwards; existing sessions keep their current state.
|
|
29
29
|
- The added prompt section may reduce provider prompt-cache hits.
|
package/docs/README.zh-CN.md
CHANGED
|
@@ -16,14 +16,14 @@ dsh plugin --profile web add @klarkxy/dsh-delegation
|
|
|
16
16
|
|
|
17
17
|
## 使用
|
|
18
18
|
|
|
19
|
-
-
|
|
19
|
+
- 在创建会话页,发送第一条消息前,使用工作区、预设选择器同一行的「委派」按钮:未开启时为普通样式,开启后显示主题色。选择在会话开始后锁定,重新打开也保持不变。按钮作用于该会话的主代理,它的子代理会自动获得对应的执行指引。
|
|
20
20
|
- 在「插件 → 委派模式」中,「新会话默认启用委派」决定之后新建会话的初始状态。
|
|
21
21
|
- 简单任务可以直接完成;较大任务由主代理先分派具体工作,再协调共同接口、检查子代理结果,最后汇报完成情况。
|
|
22
22
|
|
|
23
23
|
## 限制
|
|
24
24
|
|
|
25
|
-
- 带子代理工具的预设(Standard 与 PTC)可使用委派;无子代理工具的预设(如 Minimal
|
|
26
|
-
-
|
|
25
|
+
- 带子代理工具的预设(Standard 与 PTC)可使用委派;无子代理工具的预设(如 Minimal 及其他完整人设预设)按钮显示为禁用状态。
|
|
26
|
+
- 按钮仅调整提示词引导,保持原有的工具与权限设置,通过提示引导模型委派。
|
|
27
27
|
- 委派模式在会话开始后保持固定,以维持提示词缓存稳定。
|
|
28
28
|
- 修改默认值仅影响之后新建的会话,已有会话保持原状态。
|
|
29
29
|
- 新增的提示词小节可能降低模型供应商的提示词缓存命中率。
|
package/lib/client.inner.cjs
CHANGED
|
@@ -427,7 +427,6 @@ const inject = [
|
|
|
427
427
|
const NS = "dsh-delegation.action";
|
|
428
428
|
const zh = {
|
|
429
429
|
action: "委派",
|
|
430
|
-
normal: "默认",
|
|
431
430
|
mode: "委派模式",
|
|
432
431
|
titleOn: "本会话将使用委派模式:主代理负责拆解、委派和验收;会话开始后保持锁定",
|
|
433
432
|
titleOff: "开启委派模式:主代理把具体工作交给子代理;会话开始后保持锁定",
|
|
@@ -438,7 +437,6 @@ const zh = {
|
|
|
438
437
|
};
|
|
439
438
|
const en = {
|
|
440
439
|
action: "Delegate",
|
|
441
|
-
normal: "Default",
|
|
442
440
|
mode: "Delegation Mode",
|
|
443
441
|
titleOn: "This session will use Delegation Mode: the main agent plans, delegates, and reviews. Locked once the session starts.",
|
|
444
442
|
titleOff: "Turn on Delegation Mode: the main agent hands the work to subagents. Locked once the session starts.",
|
|
@@ -563,18 +561,16 @@ function DelegationAction({ sessionId, call, subscribeGeneration, useSession, us
|
|
|
563
561
|
label: tooltip,
|
|
564
562
|
side: "bottom",
|
|
565
563
|
gap: 4,
|
|
566
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
567
|
-
className: "dlg-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
disabled: !capable || locked || saving,
|
|
577
|
-
onChange: () => void toggle()
|
|
564
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Pill, {
|
|
565
|
+
className: "dlg-chip",
|
|
566
|
+
active: enabled,
|
|
567
|
+
"aria-pressed": enabled,
|
|
568
|
+
"aria-label": t("mode"),
|
|
569
|
+
disabled: !capable || locked || saving,
|
|
570
|
+
onClick: () => void toggle(),
|
|
571
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUsersOutlineRegular, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
572
|
+
className: "dlg-chip-label",
|
|
573
|
+
children: t("action")
|
|
578
574
|
})]
|
|
579
575
|
})
|
|
580
576
|
}), notice ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -586,10 +582,12 @@ function DelegationAction({ sessionId, call, subscribeGeneration, useSession, us
|
|
|
586
582
|
}
|
|
587
583
|
const clientCss = `${officialUiCss("dlg-root")}
|
|
588
584
|
.dlg-root.dlg-action { display: inline-flex; align-items: center; gap: 6px; }
|
|
589
|
-
.dlg-root .dlg-
|
|
590
|
-
.dlg-root .dlg-
|
|
591
|
-
.dlg-root .dlg-
|
|
592
|
-
.dlg-root .dlg-
|
|
585
|
+
.dlg-root .dlg-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; line-height: 20px; border: 1px solid var(--dsw-alias-border-l3); background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
586
|
+
.dlg-root .dlg-chip svg { width: 16px; height: 16px; }
|
|
587
|
+
.dlg-root .dlg-chip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
588
|
+
.dlg-root .dlg-chip[aria-pressed="true"] { background: var(--dsw-alias-button-primary-fill); border-color: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
|
|
589
|
+
.dlg-root .dlg-chip[aria-pressed="true"]:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); border-color: var(--dsw-alias-button-primary-hover); }
|
|
590
|
+
.dlg-root .dlg-chip:disabled { opacity: 0.5; cursor: default; }
|
|
593
591
|
.dlg-root .dlg-note { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
|
|
594
592
|
`;
|
|
595
593
|
/** Host UI language, following live switches with the host's English fallback. */
|
package/lib/client.inner.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.inner.cjs","names":["useState","useRef","useCallback","Tooltip","Switch","useSyncExternalStore","Button"],"sources":["../../dsh-plugin-kit/src/official-ui.ts","../src/contracts.ts","../src/client.tsx"],"sourcesContent":["/**\n * Shared contract that keeps every plugin's browser-side UI on the official\n * DeepSeek Harness Web design language.\n *\n * Two rules produce that language, and both are load-bearing here:\n *\n * 1. Colour, radius, elevation and focus come from the host theme's real\n * `--dsw-*` tokens, written under their own names. Plugins never invent a\n * token, never alias the official ones behind a private palette (a private\n * alias is just a second, diverging theme), and never carries a literal\n * fallback — the host publishes light and dark, and a literal would pin one\n * of them. The only non-colour custom properties used are the host's own\n * content-font axis and frame clearance.\n *\n * 2. Anything the host already ships is used, not reimplemented. Controls come\n * from `@deepseek-ai/dsh-client-ui-primitives` (`Button`, `Input`,\n * `Checkbox`, `Switch`, `Tag`, `Pill`, `SegmentedControl`, `Menu`, `Modal`,\n * `Tooltip`, `Toast`, `DisclosureRow`, `StateDot`, `PathLabel`, the settings\n * form suite). This module only styles what primitives do not cover: page\n * scaffolding, field layout, banners, empty states and scroll regions.\n *\n * The metrics below are transcribed from the primitives' own CSS modules so a\n * feature panel lines up pixel-for-pixel with a native one: the 14/22 body and\n * 13/20 compact type tiers, the 0.5px hairline scale, and the elevation family\n * that draws a surface's edge in its shadow (`border: 0`) instead of a border.\n */\n\n/**\n * Every `--dsw-*` token this repo is allowed to reference, grouped by role.\n *\n * Plugins may only colour through this list. It is exported so the guard test\n * can fail a build when a stylesheet reaches for anything else — the failure\n * mode this prevents is silent: an unknown token resolves to nothing, so a\n * border disappears or a label inherits the wrong colour with no error anywhere.\n */\nexport const OFFICIAL_THEME_TOKENS = {\n /** Surfaces, from the page up to the topmost nested card. */\n surface: [\n '--dsw-alias-bg-base',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-bg-layer-2',\n '--dsw-alias-bg-layer-3',\n '--dsw-alias-bg-layer-4',\n '--dsw-alias-bg-module-platform',\n '--dsw-alias-bg-overlay',\n ],\n /** Hairlines. l1 is near-invisible on a menu surface, so menus use l2+. */\n border: ['--dsw-alias-border-l1', '--dsw-alias-border-l2', '--dsw-alias-border-l3', '--dsw-alias-border-l4'],\n /** Text. `caption` is menu shortcut text, `dimmed` is placeholder text. */\n label: [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-label-tertiary',\n '--dsw-alias-label-caption',\n '--dsw-alias-label-dimmed',\n '--dsw-alias-label-error',\n '--dsw-alias-label-primary-foreground',\n ],\n /** Interactive fills. The `-danger` hover belongs to destructive rows. */\n interactive: [\n '--dsw-alias-interactive-bg-hover',\n '--dsw-alias-interactive-bg-active',\n '--dsw-alias-interactive-bg-hover-danger',\n ],\n /** Accent and status. `business` is the focus ring's default colour. */\n accent: [\n '--dsw-alias-brand-primary',\n '--dsw-alias-button-primary-fill',\n '--dsw-alias-button-primary-hover',\n '--dsw-alias-button-tool-bar-fill',\n '--dsw-alias-button-tool-bar-hover',\n '--dsw-alias-button-ghost-active-fill',\n '--dsw-alias-button-ghost-active-border',\n ],\n state: [\n '--dsw-alias-state-business-primary',\n '--dsw-alias-state-success-primary',\n '--dsw-alias-state-warn-primary',\n '--dsw-alias-state-error-primary',\n '--dsw-alias-state-idle-primary',\n ],\n /** Corner scale: sm 8, md 12, lg the large card, panel the modal. */\n radius: ['--dsw-radius-sm', '--dsw-radius-md', '--dsw-radius-lg', '--dsw-radius-panel'],\n /** An elevated surface draws its edge in the shadow, so it keeps border: 0. */\n elevation: [\n '--dsw-elevation-soft',\n '--dsw-elevation-stroke',\n '--dsw-elevation-stroke-color',\n '--dsw-elevation-panel',\n '--dsw-elevation-prominent',\n ],\n /** Floats, masks and scrollbars. */\n overlay: [\n '--dsw-menu-surface-fill',\n '--dsw-menu-backdrop-filter',\n '--dsw-mask-blur',\n '--dsw-alias-bg-mask-1',\n '--dsw-alias-menu-icon',\n '--dsw-alias-scrollbar-bg-l2',\n '--dsw-alias-scrollbar-hover-l2',\n '--dsw-shadow-lv3',\n ],\n /** Motion, focus and type axis, published by the host rather than by a component. */\n system: [\n '--dsw-focus-ring-width',\n '--dsw-focus-ring-color',\n '--dsw-font-markdown-code-font-family',\n '--ds-transition-duration',\n '--ds-ease-in-out',\n '--ds-font-family-code',\n '--dsh-scrollbar-thumb',\n '--dsh-scrollbar-thumb-hover',\n '--dsh-content-font-size-secondary',\n '--dsh-content-font-delta',\n '--dsh-frame-top-clearance',\n ],\n} as const\n\n/** Every official token name, flat. Used by the token guard test. */\nexport const OFFICIAL_THEME_TOKEN_NAMES: readonly string[] = Object.values(OFFICIAL_THEME_TOKENS).flat()\n\n/** The elevation steps a surface can be raised by, softest first. */\nexport type OfficialElevation = 'soft' | 'stroke' | 'panel' | 'prominent'\n\n/**\n * The host's focus ring shorthand, verbatim. Writing this per control is how\n * rings drift apart; a stylesheet that draws its own focus style should use\n * {@link officialFocus} instead. The colour fallback is the host's own default.\n */\nexport const OFFICIAL_FOCUS_RING =\n 'var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))'\n\n/**\n * A complete `outline` declaration at the official geometry. `offset` defaults\n * to the 2px the native controls use; the host's inline field rules sit at 1px\n * and a segmented tab pulls the ring inside itself at -2px.\n */\nexport function officialFocus(offset = '2px'): string {\n return `outline: ${OFFICIAL_FOCUS_RING}; outline-offset: ${offset}`\n}\n\n/**\n * An elevated surface. The host draws a raised surface's edge inside its\n * shadow rather than as a border, so a card sets `border: 0` and takes the edge\n * from the elevation — which is also why its border stays off the alias-border\n * set that a flat, non-elevated rule would use.\n */\nexport function officialElevation(level: OfficialElevation): string {\n return `border: 0; box-shadow: var(--dsw-elevation-${level})`\n}\n\n/**\n * An elevated surface whose edge should read as a specific hairline. Rebinding\n * the stroke colour is how a menu card picks l1 while a panel picks l3, without\n * the two growing apart by hand.\n */\nexport function officialStrokedElevation(level: OfficialElevation, color: string): string {\n return `--dsw-elevation-stroke-color: ${color}; ${officialElevation(level)}`\n}\n\n/**\n * The shared stylesheet for a plugin UI, scoped under that plugin's root class.\n *\n * Scoping is what keeps this safe to always-bundle into every client: the rules\n * can only match inside the plugin's own subtree, so two plugins can both mount\n * `dsh-ui-card` without either styling the other's markup.\n *\n * Each recipe matches the root element *and* its descendants, because the\n * commonest arrangement is one element that is both — a surface that carries\n * the root class and `dsh-ui-card`, or a portaled dialog that is the root and\n * the `dsh-ui-surface`. A descendant-only scope would silently leave those\n * unstyled, with no error anywhere.\n *\n * A caveat worth knowing: `Modal` and `Menu` portal to `document.body`, so their\n * content leaves the plugin's subtree entirely. A portaled surface therefore\n * needs its own root class on an element inside the portal.\n *\n * Only patterns that primitives do not provide live here. If a control appears\n * below that `Button`/`Input`/`Switch`/`Tag`/`Menu` already covers, that is a\n * bug in this file: use the primitive and delete the recipe.\n */\nexport function officialUiCss(roots: string | readonly string[]): string {\n // One plugin often mounts several unrelated surfaces (a settings seat, a chat\n // card, a header menu), so the caller names every root. The rules below are\n // nested under a single selector list and use `&`, which the browser expands\n // per root — so one stylesheet covers all of them without duplicating itself.\n const scope = (typeof roots === 'string' ? [roots] : roots).map(root => `.${root}`).join(', ')\n const sheet = `\n/* Official DSH Web UI contract. Generated by @klarkxy/dsh-plugin-kit/official-ui.\n * Do not hand-edit the copy inside a plugin: change this module so every plugin\n * moves together. Scope: ${scope} */\n/* The scope rule below stays open for the whole sheet: every rule after it\n * nests with the parent selector, so one stylesheet can cover several unrelated\n * roots without leaking into a neighbouring plugin. Its closing brace is last. */\n${scope} {\n color: var(--dsw-alias-label-primary);\n font-family: inherit;\n font-size: 14px;\n line-height: 22px;\n min-width: 0;\n\n& *, & *::before, & *::after { box-sizing: border-box; }\n& h1, & h2, & h3, & h4, & p, & figure { margin: 0; }\n/* Keyboard focus only: pointer input keeps the native resting appearance. The\n * ring needs no radius of its own — the outline already follows the control's\n * own border-radius, and overriding it here would flatten every control. */\n& :focus-visible { ${officialFocus()}; }\n& [hidden] { display: none !important; }\n\n/* --- Type tiers. The same 14/22 and 13/20 steps the primitives use. --- */\n& .dsh-ui-title { font-size: 16px; line-height: 24px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-heading { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-compact { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-meta { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-hint { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-error { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-warn { color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-success { color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-muted { color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n& .dsh-ui-wrap { min-width: 0; overflow-wrap: anywhere; }\n\n/* --- Layout scaffolding. --- */\n& .dsh-ui-stack { display: flex; flex-direction: column; gap: 12px; }\n& .dsh-ui-stack-lg { display: flex; flex-direction: column; gap: 20px; }\n/* Plugin detail pages share one reading column. These are layout recipes;\n * controls keep their own primitive styles. Form spacing follows the host's\n * settings-form/fields.module.css and SettingsForm.module.css. */\n& .dsh-ui-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; min-width: 0; }\n& .dsh-ui-form { display: flex; flex-direction: column; gap: 0; min-width: 0; }\n&.dsh-ui-form > .dsh-ui-field, & .dsh-ui-form > .dsh-ui-field { padding: 12px 0; }\n& .dsh-ui-form-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 16px; min-width: 0; }\n& .dsh-ui-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; min-width: 0; margin: 0; padding: 0; border: 0; }\n@media (max-width: 560px) {\n & .dsh-ui-fields-grid { grid-template-columns: minmax(0, 1fr); }\n}\n& .dsh-ui-row { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }\n& .dsh-ui-spacer { flex: 1; min-width: 0; }\n/* A 0.5px l2 rule is the host's section divider; reserve the same rhythm. */\n& .dsh-ui-divider { height: 0.5px; background: var(--dsw-alias-border-l2); }\n& .dsh-ui-section { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 0.5px solid var(--dsw-alias-border-l2); }\n\n/* --- Card: a raised surface whose edge lives in the shadow. --- */\n& .dsh-ui-card {\n ${officialElevation('stroke')}\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-primary);\n min-width: 0;\n}\n& .dsh-ui-card--flat { border: 0.5px solid var(--dsw-alias-border-l3); box-shadow: none; }\n& .dsh-ui-card--nested { background: var(--dsw-alias-bg-layer-2); }\n& .dsh-ui-card--plain { background: none; }\n\n/* --- Field: label, control, help, error. The control itself is an\n * official primitive, so this only owns the vertical rhythm. --- */\n& .dsh-ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }\n& .dsh-ui-field + .dsh-ui-field { border-top: 0.5px solid var(--dsw-alias-border-l2); padding-top: 12px; }\n/* Grid fields share a row, so the stacked-field divider must not win later in\n * the cascade. Reset it here, after the field recipe. */\n& .dsh-ui-fields-grid > .dsh-ui-field { padding: 0; border: 0; }\n& .dsh-ui-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n& .dsh-ui-help { font-size: 12px; line-height: 1.6; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-help p { margin: 0; }\n& .dsh-ui-help p + p { margin-top: 8px; }\n& .dsh-ui-required { color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-control { width: 100%; min-width: 0; }\n/* An invalid control is marked on the control, not only in the message. */\n& .dsh-ui-control[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-readonly { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-readonly > dt { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-readonly > dd { margin: 0; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }\n\n/* --- Buttons row. A no-op container: it exists so actions line up on the\n * trailing edge the way every native panel does. --- */\n& .dsh-ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }\n& .dsh-ui-actions-end { justify-content: flex-end; }\n\n/* --- Banners. A banner is a left-rail notice, the shape used for warnings,\n * deprecations and blocking instructions. --- */\n& .dsh-ui-banner {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 10px 14px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-left: 3px solid var(--dsw-alias-state-warn-primary);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-banner-title { font-weight: 500; color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-banner--info { border-left-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-banner--danger { border-left-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-banner--success { border-left-color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-banner p { margin: 0; }\n\n/* --- Inline notice: a transient confirmation with no chrome of its own. --- */\n& .dsh-ui-notice { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-notice--error { color: var(--dsw-alias-state-error-primary); }\n\n/* --- Empty and loading states. Both sit in a dashed well so an empty panel\n * reads as \"nothing here yet\" rather than as a broken layout. --- */\n& .dsh-ui-empty {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 20px 16px;\n border: 0.5px dashed var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-loading { display: flex; align-items: center; gap: 8px; padding: 20px 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n\n/* --- Selectable list. A row is a button-sized target with a hover fill and\n * a selected fill; the name carries the weight, the description does not. --- */\n& .dsh-ui-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }\n& .dsh-ui-list-scroll { max-height: min(66vh, 760px); overflow-y: auto; overflow-x: hidden; }\n& .dsh-ui-list-row { border-radius: var(--dsw-radius-md); }\n& .dsh-ui-list-row:hover { background: var(--dsw-alias-interactive-bg-hover); }\n& .dsh-ui-list-row[aria-selected='true'], & .dsh-ui-list-row[data-selected] { background: var(--dsw-alias-interactive-bg-active); }\n& .dsh-ui-list-item {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n width: 100%;\n min-width: 0;\n padding: 10px 12px;\n border: 0;\n border-radius: var(--dsw-radius-md);\n background: none;\n font: inherit;\n color: inherit;\n text-align: start;\n cursor: pointer;\n}\n& .dsh-ui-list-item:disabled { cursor: default; }\n& .dsh-ui-list-item:disabled:hover { background: none; }\n& .dsh-ui-list-name { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }\n& .dsh-ui-list-desc { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n\n/* --- Code and structured output. Wraps rather than scrolls, because a\n * feature panel is read rather than scanned. --- */\n& .dsh-ui-code {\n padding: 10px 12px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-family: var(--ds-font-family-code);\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n& .dsh-ui-scroll { max-height: 60vh; overflow: auto; overscroll-behavior: contain; }\n\n/* --- A toggle row: label on the left, switch on the trailing edge. This is\n * layout only; the switch itself is the official primitive. --- */\n& .dsh-ui-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 12px 0; }\n& .dsh-ui-toggle-row + .dsh-ui-toggle-row { border-top: 0.5px solid var(--dsw-alias-border-l2); }\n& .dsh-ui-toggle-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-toggle-label { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Floating surface: a panel anchored to a trigger. This is the material\n * a menu card is made of — the translucent fill plus its backdrop blur, with\n * the edge riding inside the prominent elevation. A plugin that hand-rolls this\n * is how tokens like --dsw-specific-menu get invented; use this instead. --- */\n& .dsh-ui-surface {\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n position: relative;\n display: flex;\n flex-direction: column;\n border: 0;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-menu-surface-fill);\n backdrop-filter: var(--dsw-menu-backdrop-filter);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n min-width: 0;\n}\n& .dsh-ui-surface-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; overflow-y: auto; }\n& .dsh-ui-surface-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-surface-title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Native select. The primitives ship no select, so a plugin that offers a\n * closed list of choices keeps the platform control and matches the official\n * settings field geometry exactly (34px, 0.5px l4, radius-md, layer-3). A\n * SegmentedControl is the primitive to reach for when the choices are few\n * enough to show at once. --- */\n& .dsh-ui-select {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 34px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n& .dsh-ui-select:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-select:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-select[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* --- Native textarea. The primitives ship no textarea either, so a settings\n * prompt keeps the platform element and the same field shell as the select:\n * 0.5px l4, radius-md, layer-3, 13/1.5 type. It grows vertically instead of\n * locking to the select's 34px row. --- */\n& .dsh-ui-textarea {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n resize: vertical;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n}\n& .dsh-ui-textarea:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-textarea:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-textarea::placeholder { color: var(--dsw-alias-label-dimmed); }\n& .dsh-ui-textarea[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* Long panels scroll inside themselves instead of growing the host page. */\n& .dsh-ui-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }\n& .dsh-ui-panel-wide { max-width: 100%; }\n\n@media (prefers-reduced-motion: reduce) {\n & *, & *::before, & *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }\n}\n}\n`\n // Widen every recipe from \"a descendant of the root\" to \"the root, or one of\n // its descendants\". Written as a transform rather than by hand so no recipe\n // can be added later with only the descendant form. The pattern is narrow on\n // purpose: a leading `&` followed by one recipe class and no combinator, so\n // sibling and child rules such as `.dsh-ui-field + .dsh-ui-field` keep their\n // own meaning and are left alone.\n return sheet.replace(/^& (\\.dsh-ui-[a-z0-9-]+)(?=\\s*\\{)/gm, (_match, className: string) =>\n `&${className}, & ${className}`)\n}\n","/** Browser-safe contracts. Shared RPC/result types stay on @klarkxy/dsh-plugin-kit. */\nimport type { RpcResult as SharedRpcResult } from '@klarkxy/dsh-plugin-kit/contracts'\nexport type RpcResult<T = unknown> = SharedRpcResult<T>\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-delegation'\nexport const RPC_CHANNEL = '/dsh-delegation'\nexport const DELEGATION_CLIENT_SERVICE = 'dshDelegationClient'\n\n/** Native delegation tools; Delegation Mode only helps presets that mount one. */\nexport const DELEGATION_TOOLS = ['subagent', 'subagent_fork'] as const\n\nexport interface DelegationSettings {\n readonly revision: number\n /** Initial delegation flag for sessions created from now on. */\n readonly defaultEnabled: boolean\n}\n\nexport const defaultSettings = (): DelegationSettings => ({ revision: 0, defaultEnabled: false })\n\nexport type DelegationRole = 'coordinator' | 'executor'\n\nexport interface DelegationSessionStatus {\n readonly sessionId: string\n /** 'executor' for subagent threads: they never carry their own switch. */\n readonly role: DelegationRole\n /** The session record's flag; false when the session has no record yet. */\n readonly enabled: boolean\n /** The session record's revision; 0 when the session has no record yet. */\n readonly revision: number\n /** No edit is allowed once the first turn starts, or while the session is cold. */\n readonly locked: boolean\n /**\n * Whether a live agent on this session sees a delegation tool; null when no\n * agent is live, so a stale answer is never shown as unavailable.\n */\n readonly capable: boolean | null\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, Switch, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { officialUiCss } from '@klarkxy/dsh-plugin-kit/official-ui'\nimport {\n DELEGATION_CLIENT_SERVICE, PLUGIN_NAME, RPC_CHANNEL,\n type DelegationSessionStatus, type DelegationSettings, type RpcResult,\n} from './contracts.ts'\n\nexport const name = 'dsh-delegation-client'\nexport const inject = ['slots', 'connection', 'locale'] as const\n\nconst NS = 'dsh-delegation.action'\n\nconst zh = {\n action: '委派',\n normal: '默认',\n mode: '委派模式',\n titleOn: '本会话将使用委派模式:主代理负责拆解、委派和验收;会话开始后保持锁定',\n titleOff: '开启委派模式:主代理把具体工作交给子代理;会话开始后保持锁定',\n locked: '请在会话开始前选择委派模式',\n incapable: '当前预设缺少子代理工具,需切换到带子代理工具的预设',\n stale: '状态已在别处更改,已刷新',\n failed: '切换失败',\n}\n\nconst en: Record<keyof typeof zh, string> = {\n action: 'Delegate',\n normal: 'Default',\n mode: 'Delegation Mode',\n titleOn: 'This session will use Delegation Mode: the main agent plans, delegates, and reviews. Locked once the session starts.',\n titleOff: 'Turn on Delegation Mode: the main agent hands the work to subagents. Locked once the session starts.',\n locked: 'Choose Delegation Mode before the session starts',\n incapable: 'Delegation Mode unavailable: this preset has no subagent tools',\n stale: 'State changed elsewhere; refreshed',\n failed: 'Could not toggle Delegation Mode',\n}\n\ntype Key = keyof typeof zh\ntype Translate = (key: Key) => string\n\n/** A failed RPC keeps its code so the view can name a rejection it understands. */\nclass RpcError extends Error {\n readonly code: string\n constructor(code: string, message: string) {\n super(message)\n this.name = 'RpcError'\n this.code = code\n }\n}\n\nasync function rpc<T>(call: (endpoint: string, payload: unknown) => Promise<unknown>, endpoint: string, payload: unknown = {}): Promise<T> {\n const result = await call(endpoint, payload) as RpcResult<T> | undefined\n if (!result || result.ok !== true) {\n const failed = result && 'error' in result ? result.error : undefined\n throw new RpcError(failed?.code ?? 'unknown', failed?.message ?? '')\n }\n return result.value\n}\n\nexport interface DelegationSessionSnapshotLike {\n openState?: string\n running?: boolean\n blank?: boolean\n awaitingFirstTurn?: boolean\n pendingSubmissions?: readonly unknown[]\n}\n\nexport interface DelegationActionProps {\n sessionId: string\n call: (endpoint: string, payload: unknown) => Promise<unknown>\n /** Host connection-generation subscription; refetches on reconnect. */\n subscribeGeneration?: (listener: () => void) => (() => void) | undefined\n /** Host per-session selector hook; a cold→open transition triggers a refetch. */\n useSession?: <T>(selector: (snapshot: DelegationSessionSnapshotLike) => T) => T\n /** Changing a blank session's preset must refresh tool availability. */\n useProjection?: (key: 'agentPreset') => string | null | undefined\n t: Translate\n}\n\n/** Brief notice shown after a toggle problem, in the tooltip and an aria-live span. */\ntype Notice = '' | 'stale' | 'failed' | 'locked'\n\nexport function DelegationAction({ sessionId, call, subscribeGeneration, useSession, useProjection, t }: DelegationActionProps) {\n const [status, setStatus] = useState<DelegationSessionStatus>()\n const [saving, setSaving] = useState(false)\n const [notice, setNotice] = useState<Notice>('')\n const generationRef = useRef(0)\n const readSeqRef = useRef(0)\n const openState = useSession?.(snapshot => snapshot.openState)\n const sessionRunning = useSession?.(snapshot => snapshot.running === true)\n const sessionBlank = useSession?.(snapshot => snapshot.blank)\n const submitting = useSession?.(snapshot => snapshot.awaitingFirstTurn === true || (snapshot.pendingSubmissions?.length ?? 0) > 0)\n const preset = useProjection?.('agentPreset')\n\n const load = useCallback(async () => {\n const generation = generationRef.current\n const seq = ++readSeqRef.current\n try {\n const next = await rpc<DelegationSessionStatus>(call, 'session.status', { sessionId })\n if (generationRef.current !== generation || seq !== readSeqRef.current) return\n // Revisions never decrease and records are never deleted, so a stale read\n // that lands after a fresher write must not roll the button back.\n setStatus(prev => prev && prev.sessionId === next.sessionId && next.revision < prev.revision ? prev : next)\n } catch {\n // A failed refetch keeps the last known state; the button stays put.\n }\n }, [call, sessionId])\n\n useEffect(() => {\n generationRef.current += 1\n readSeqRef.current += 1\n setStatus(undefined)\n setSaving(false)\n setNotice('')\n }, [sessionId])\n\n useEffect(() => { void load() }, [load, openState, sessionRunning, sessionBlank, preset])\n\n useEffect(() => {\n const off = subscribeGeneration?.(() => { void load() })\n const win = typeof window === 'undefined' ? undefined : window\n const onFocus = () => { void load() }\n win?.addEventListener('focus', onFocus)\n return () => { off?.(); win?.removeEventListener('focus', onFocus) }\n }, [load, subscribeGeneration])\n\n useEffect(() => {\n if (!notice) return\n const timer = setTimeout(() => setNotice(''), 4000)\n return () => clearTimeout(timer)\n }, [notice])\n\n const toggle = useCallback(async () => {\n if (!status || saving || status.locked || sessionBlank === false || sessionRunning || submitting || status.capable !== true) return\n const generation = generationRef.current\n readSeqRef.current += 1\n setSaving(true)\n setNotice('')\n try {\n const next = await rpc<DelegationSessionStatus>(call, 'session.update', {\n sessionId, enabled: !status.enabled, expectedRevision: status.revision,\n })\n if (generationRef.current !== generation) return\n setStatus(next)\n } catch (reason) {\n if (generationRef.current !== generation) return\n if (reason instanceof RpcError && (reason.code === 'stale' || reason.code === 'session-locked')) {\n setNotice(reason.code === 'stale' ? 'stale' : 'locked')\n void load()\n } else {\n setNotice('failed')\n }\n } finally {\n if (generationRef.current === generation) setSaving(false)\n }\n }, [call, load, saving, sessionId, status, sessionBlank, sessionRunning, submitting])\n\n if (!status || status.role === 'executor' || sessionBlank === false) return null\n const capable = status.capable === true\n const enabled = status.enabled\n const locked = status.locked || sessionRunning || submitting\n const tooltip = status.capable === false ? t('incapable') : locked ? t('locked') : notice ? t(notice) : enabled ? t('titleOn') : t('titleOff')\n return (\n <span className=\"dlg-root dlg-action\">\n <Tooltip label={tooltip} side=\"bottom\" gap={4}>\n <span className=\"dlg-mode\" data-enabled={enabled}>\n <span className=\"dlg-mode-label\">{enabled ? t('action') : t('normal')}</span>\n <Switch\n className=\"dlg-toggle\"\n checked={enabled}\n label={t('mode')}\n disabled={!capable || locked || saving}\n onChange={() => void toggle()}\n />\n </span>\n </Tooltip>\n {notice ? <span role=\"status\" className=\"dlg-note\">{t(notice)}</span> : null}\n </span>\n )\n}\n\nexport const clientCss = `${officialUiCss('dlg-root')}\n.dlg-root.dlg-action { display: inline-flex; align-items: center; gap: 6px; }\n.dlg-root .dlg-mode { display: inline-flex; align-items: center; gap: 8px; color: var(--dsw-alias-label-tertiary); }\n.dlg-root .dlg-mode-label { font-size: 13px; line-height: 20px; }\n.dlg-root .dlg-mode[data-enabled=\"true\"] { color: var(--dsw-alias-state-business-primary); }\n.dlg-root .dlg-toggle[aria-checked=\"true\"] { background: var(--dsw-alias-state-business-primary); }\n.dlg-root .dlg-note { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n`\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context { dshDelegationClient: { active: boolean } }\n}\n\ntype Client = Context & {\n connection: {\n generation?: { subscribe(listener: () => void): () => void }\n rpc: { call(channel: string, endpoint: string, payload: unknown): Promise<unknown> }\n }\n slots: {\n inject(key: string, callback: () => unknown): () => void\n register(spec: { name: string; id: string; order: number; locale: string; inject: () => unknown } | { name: string; key: string }, render: unknown): () => void\n }\n locale: {\n register(ns: string, locales: { zh: Record<string, string>; en: Record<string, string> }): () => void\n getSnapshot?(): { active: string }\n subscribe?(listener: () => void): () => void\n }\n}\n\n/** Host UI language, following live switches with the host's English fallback. */\nfunction useHostLocale(client: Client): string {\n const subscribe = useCallback(\n (listener: () => void) => client.locale.subscribe?.(listener) ?? (() => {}),\n [client],\n )\n const snapshot = useCallback(() => client.locale.getSnapshot?.().active ?? 'en', [client])\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n\nconst settingsZh = {\n default: '新会话默认启用委派',\n defaultHint: '只影响之后新建的会话;发送第一条消息前可单独选择,会话开始后保持锁定。需要预设包含子代理工具。',\n loading: '正在读取设置…',\n saved: '已保存。',\n stale: '设置已更新,请刷新后重试。',\n failed: '无法读取委派设置。',\n retry: '重试',\n refresh: '刷新设置',\n}\n\nconst settingsEn: Record<keyof typeof settingsZh, string> = {\n default: 'Enable Delegation Mode for new sessions',\n defaultHint: 'Only affects sessions created later. Choose before sending the first message; the choice stays locked once the session starts. Requires a preset with subagent tools.',\n loading: 'Loading settings…',\n saved: 'Saved.',\n stale: 'Settings changed; refresh and retry.',\n failed: 'Could not load delegation settings.',\n retry: 'Retry',\n refresh: 'Refresh settings',\n}\n\nfunction settingsCopy(locale: string): Record<keyof typeof settingsZh, string> {\n return String(locale).startsWith('zh') ? settingsZh : settingsEn\n}\n\n/** Plugin-page card: the default flag applied to sessions created from now on. */\nexport function DelegationSettingsPanel(props: { client: Client; locale?: string }) {\n const hostLocale = useHostLocale(props.client)\n const text = settingsCopy(props.locale ?? hostLocale)\n const [settings, setSettings] = useState<DelegationSettings>()\n const [error, setError] = useState<'' | 'failed' | 'stale'>('')\n const [note, setNote] = useState(false)\n const [busy, setBusy] = useState(false)\n const operation = useRef({ epoch: 0, active: false, writing: false })\n\n const call = useCallback(\n (endpoint: string, payload: unknown = {}) => props.client.connection.rpc.call(RPC_CHANNEL, endpoint, payload),\n [props.client],\n )\n\n const refresh = useCallback(() => {\n const state = operation.current\n if (!state.active || state.writing) return\n const epoch = state.epoch\n setBusy(true)\n void rpc<DelegationSettings>(call, 'settings').then(next => {\n if (!state.active || state.epoch !== epoch) return\n setSettings(next)\n setError('')\n }).catch(() => {\n if (!state.active || state.epoch !== epoch) return\n setError('failed')\n }).finally(() => {\n if (state.active && state.epoch === epoch) setBusy(false)\n })\n }, [call])\n const refreshRef = useRef(refresh)\n refreshRef.current = refresh\n useEffect(() => {\n const state = operation.current\n state.epoch++\n state.active = true\n state.writing = false\n setBusy(false)\n setSettings(undefined)\n setError('')\n setNote(false)\n refreshRef.current()\n return () => { state.active = false; state.epoch++ }\n }, [call])\n\n const save = useCallback((defaultEnabled: boolean) => {\n const state = operation.current\n if (!settings || !state.active || state.writing) return\n state.writing = true\n const epoch = state.epoch\n setBusy(true)\n setNote(false)\n setError('')\n void rpc<DelegationSettings>(call, 'settings.update', {\n defaultEnabled,\n expectedRevision: settings.revision,\n }).then(next => {\n if (!state.active || state.epoch !== epoch) return\n setSettings(next)\n setNote(true)\n }).catch(reason => {\n if (!state.active || state.epoch !== epoch) return\n setError(reason instanceof RpcError && reason.code === 'stale' ? 'stale' : 'failed')\n }).finally(() => {\n if (state.active && state.epoch === epoch) { state.writing = false; setBusy(false) }\n })\n }, [call, settings])\n\n if (!settings) {\n return (\n <section className=\"dlg-root dlg-settings dsh-ui-page\">\n {error\n ? <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>\n : <p role=\"status\" className=\"dsh-ui-hint\">{text.loading}</p>}\n <Button variant=\"ghost\" size=\"sm\" disabled={busy} onClick={() => refreshRef.current()}>{text.retry}</Button>\n </section>\n )\n }\n\n return (\n <section className=\"dlg-root dlg-settings dsh-ui-page\" data-testid=\"delegation-settings\">\n <div className=\"dlg-settings-status\">\n <Button variant=\"ghost\" size=\"sm\" disabled={busy} onClick={() => refreshRef.current()}>{text.refresh}</Button>\n {error && <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>}\n {note && <p role=\"status\" className=\"dsh-ui-notice\">{text.saved}</p>}\n </div>\n <article className=\"dlg-root dsh-ui-card\">\n <header className=\"dsh-ui-toggle-row\">\n <div className=\"dsh-ui-toggle-text\">\n <h3 className=\"dsh-ui-toggle-label\">{text.default}</h3>\n <p className=\"dsh-ui-hint\">{text.defaultHint}</p>\n </div>\n <Switch\n checked={settings.defaultEnabled}\n label={text.default}\n disabled={busy}\n onChange={next => save(next)}\n />\n </header>\n </article>\n </section>\n )\n}\n\nexport function apply(ctx: Context): void {\n const client = ctx as unknown as Client\n ctx.provide(DELEGATION_CLIENT_SERVICE, { active: true })\n ctx.effect(() => client.locale.register(NS, { zh: { ...zh }, en: { ...en } }), 'delegation.locale')\n // Style both the new-session option and the independent settings page.\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const style = document.createElement('style')\n style.setAttribute('data-plugin', PLUGIN_NAME)\n style.textContent = clientCss\n document.head.appendChild(style)\n return () => style.remove()\n }, 'delegation.styles')\n ctx.effect(() => client.slots.inject('plugins.bundle.config', () => client.slots.register(\n { name: 'plugins.bundle.config', key: PLUGIN_NAME },\n () => <DelegationSettingsPanel client={client} />,\n )), 'delegation.settings')\n ctx.effect(() => client.slots.inject('conversation.hero.options', () => client.slots.register(\n {\n name: 'conversation.hero.options',\n id: 'delegation',\n order: 20,\n locale: NS,\n inject: () => ({\n call: (endpoint: string, payload: unknown) => client.connection.rpc.call(RPC_CHANNEL, endpoint, payload),\n subscribeGeneration: (listener: () => void) => client.connection.generation?.subscribe(listener),\n }),\n },\n DelegationAction,\n )), 'delegation.slot')\n}\n"],"mappings":";;;;AAuH6D,OAAO,OAAO;;CAlFzE,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAEA,QAAQ;EAAC;EAAyB;EAAyB;EAAyB;CAAuB;;CAE3G,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAEA,aAAa;EACX;EACA;EACA;CACF;;CAEA,QAAQ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,KAAoB;CACxC,MAAM,SAAS;CACf,IAAI,QAAQ,2BAA2B,EAAE,QAAQ,KAAK,CAAC;CACvD,IAAI,aAAa,OAAO,OAAO,SAAS,IAAI;EAAE,IAAI,EAAE,GAAG,GAAG;EAAG,IAAI,EAAE,GAAG,GAAG;CAAE,CAAC,GAAG,mBAAmB;CAElG,IAAI,aAAa;EACf,IAAI,OAAO,aAAa,aAAa,aAAa,CAAC;EACnD,MAAM,QAAQ,SAAS,cAAc,OAAO;EAC5C,MAAM,aAAa,eAAe,WAAW;EAC7C,MAAM,cAAc;EACpB,SAAS,KAAK,YAAY,KAAK;EAC/B,aAAa,MAAM,OAAO;CAC5B,GAAG,mBAAmB;CACtB,IAAI,aAAa,OAAO,MAAM,OAAO,+BAA+B,OAAO,MAAM,SAC/E;EAAE,MAAM;EAAyB,KAAK;CAAY,SAC5C,iBAAA,GAAA,kBAAA,IAAA,CAAC,yBAAD,EAAiC,OAAS,CAAA,CAClD,CAAC,GAAG,qBAAqB;CACzB,IAAI,aAAa,OAAO,MAAM,OAAO,mCAAmC,OAAO,MAAM,SACnF;EACE,MAAM;EACN,IAAI;EACJ,OAAO;EACP,QAAQ;EACR,eAAe;GACb,OAAO,UAAkB,YAAqB,OAAO,WAAW,IAAI,KAAK,aAAa,UAAU,OAAO;GACvG,sBAAsB,aAAyB,OAAO,WAAW,YAAY,UAAU,QAAQ;EACjG;CACF,GACA,gBACF,CAAC,GAAG,iBAAiB;AACvB"}
|
|
1
|
+
{"version":3,"file":"client.inner.cjs","names":["useState","useRef","useCallback","Tooltip","Pill","IconUsersOutlineRegular","useSyncExternalStore","Button","Switch"],"sources":["../../dsh-plugin-kit/src/official-ui.ts","../src/contracts.ts","../src/client.tsx"],"sourcesContent":["/**\n * Shared contract that keeps every plugin's browser-side UI on the official\n * DeepSeek Harness Web design language.\n *\n * Two rules produce that language, and both are load-bearing here:\n *\n * 1. Colour, radius, elevation and focus come from the host theme's real\n * `--dsw-*` tokens, written under their own names. Plugins never invent a\n * token, never alias the official ones behind a private palette (a private\n * alias is just a second, diverging theme), and never carries a literal\n * fallback — the host publishes light and dark, and a literal would pin one\n * of them. The only non-colour custom properties used are the host's own\n * content-font axis and frame clearance.\n *\n * 2. Anything the host already ships is used, not reimplemented. Controls come\n * from `@deepseek-ai/dsh-client-ui-primitives` (`Button`, `Input`,\n * `Checkbox`, `Switch`, `Tag`, `Pill`, `SegmentedControl`, `Menu`, `Modal`,\n * `Tooltip`, `Toast`, `DisclosureRow`, `StateDot`, `PathLabel`, the settings\n * form suite). This module only styles what primitives do not cover: page\n * scaffolding, field layout, banners, empty states and scroll regions.\n *\n * The metrics below are transcribed from the primitives' own CSS modules so a\n * feature panel lines up pixel-for-pixel with a native one: the 14/22 body and\n * 13/20 compact type tiers, the 0.5px hairline scale, and the elevation family\n * that draws a surface's edge in its shadow (`border: 0`) instead of a border.\n */\n\n/**\n * Every `--dsw-*` token this repo is allowed to reference, grouped by role.\n *\n * Plugins may only colour through this list. It is exported so the guard test\n * can fail a build when a stylesheet reaches for anything else — the failure\n * mode this prevents is silent: an unknown token resolves to nothing, so a\n * border disappears or a label inherits the wrong colour with no error anywhere.\n */\nexport const OFFICIAL_THEME_TOKENS = {\n /** Surfaces, from the page up to the topmost nested card. */\n surface: [\n '--dsw-alias-bg-base',\n '--dsw-alias-bg-layer-1',\n '--dsw-alias-bg-layer-2',\n '--dsw-alias-bg-layer-3',\n '--dsw-alias-bg-layer-4',\n '--dsw-alias-bg-module-platform',\n '--dsw-alias-bg-overlay',\n ],\n /** Hairlines. l1 is near-invisible on a menu surface, so menus use l2+. */\n border: ['--dsw-alias-border-l1', '--dsw-alias-border-l2', '--dsw-alias-border-l3', '--dsw-alias-border-l4'],\n /** Text. `caption` is menu shortcut text, `dimmed` is placeholder text. */\n label: [\n '--dsw-alias-label-primary',\n '--dsw-alias-label-secondary',\n '--dsw-alias-label-tertiary',\n '--dsw-alias-label-caption',\n '--dsw-alias-label-dimmed',\n '--dsw-alias-label-error',\n '--dsw-alias-label-primary-foreground',\n ],\n /** Interactive fills. The `-danger` hover belongs to destructive rows. */\n interactive: [\n '--dsw-alias-interactive-bg-hover',\n '--dsw-alias-interactive-bg-active',\n '--dsw-alias-interactive-bg-hover-danger',\n ],\n /** Accent and status. `business` is the focus ring's default colour. */\n accent: [\n '--dsw-alias-brand-primary',\n '--dsw-alias-button-primary-fill',\n '--dsw-alias-button-primary-hover',\n '--dsw-alias-button-tool-bar-fill',\n '--dsw-alias-button-tool-bar-hover',\n '--dsw-alias-button-ghost-active-fill',\n '--dsw-alias-button-ghost-active-border',\n ],\n state: [\n '--dsw-alias-state-business-primary',\n '--dsw-alias-state-success-primary',\n '--dsw-alias-state-warn-primary',\n '--dsw-alias-state-error-primary',\n '--dsw-alias-state-idle-primary',\n ],\n /** Corner scale: sm 8, md 12, lg the large card, panel the modal. */\n radius: ['--dsw-radius-sm', '--dsw-radius-md', '--dsw-radius-lg', '--dsw-radius-panel'],\n /** An elevated surface draws its edge in the shadow, so it keeps border: 0. */\n elevation: [\n '--dsw-elevation-soft',\n '--dsw-elevation-stroke',\n '--dsw-elevation-stroke-color',\n '--dsw-elevation-panel',\n '--dsw-elevation-prominent',\n ],\n /** Floats, masks and scrollbars. */\n overlay: [\n '--dsw-menu-surface-fill',\n '--dsw-menu-backdrop-filter',\n '--dsw-mask-blur',\n '--dsw-alias-bg-mask-1',\n '--dsw-alias-menu-icon',\n '--dsw-alias-scrollbar-bg-l2',\n '--dsw-alias-scrollbar-hover-l2',\n '--dsw-shadow-lv3',\n ],\n /** Motion, focus and type axis, published by the host rather than by a component. */\n system: [\n '--dsw-focus-ring-width',\n '--dsw-focus-ring-color',\n '--dsw-font-markdown-code-font-family',\n '--ds-transition-duration',\n '--ds-ease-in-out',\n '--ds-font-family-code',\n '--dsh-scrollbar-thumb',\n '--dsh-scrollbar-thumb-hover',\n '--dsh-content-font-size-secondary',\n '--dsh-content-font-delta',\n '--dsh-frame-top-clearance',\n ],\n} as const\n\n/** Every official token name, flat. Used by the token guard test. */\nexport const OFFICIAL_THEME_TOKEN_NAMES: readonly string[] = Object.values(OFFICIAL_THEME_TOKENS).flat()\n\n/** The elevation steps a surface can be raised by, softest first. */\nexport type OfficialElevation = 'soft' | 'stroke' | 'panel' | 'prominent'\n\n/**\n * The host's focus ring shorthand, verbatim. Writing this per control is how\n * rings drift apart; a stylesheet that draws its own focus style should use\n * {@link officialFocus} instead. The colour fallback is the host's own default.\n */\nexport const OFFICIAL_FOCUS_RING =\n 'var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary))'\n\n/**\n * A complete `outline` declaration at the official geometry. `offset` defaults\n * to the 2px the native controls use; the host's inline field rules sit at 1px\n * and a segmented tab pulls the ring inside itself at -2px.\n */\nexport function officialFocus(offset = '2px'): string {\n return `outline: ${OFFICIAL_FOCUS_RING}; outline-offset: ${offset}`\n}\n\n/**\n * An elevated surface. The host draws a raised surface's edge inside its\n * shadow rather than as a border, so a card sets `border: 0` and takes the edge\n * from the elevation — which is also why its border stays off the alias-border\n * set that a flat, non-elevated rule would use.\n */\nexport function officialElevation(level: OfficialElevation): string {\n return `border: 0; box-shadow: var(--dsw-elevation-${level})`\n}\n\n/**\n * An elevated surface whose edge should read as a specific hairline. Rebinding\n * the stroke colour is how a menu card picks l1 while a panel picks l3, without\n * the two growing apart by hand.\n */\nexport function officialStrokedElevation(level: OfficialElevation, color: string): string {\n return `--dsw-elevation-stroke-color: ${color}; ${officialElevation(level)}`\n}\n\n/**\n * The shared stylesheet for a plugin UI, scoped under that plugin's root class.\n *\n * Scoping is what keeps this safe to always-bundle into every client: the rules\n * can only match inside the plugin's own subtree, so two plugins can both mount\n * `dsh-ui-card` without either styling the other's markup.\n *\n * Each recipe matches the root element *and* its descendants, because the\n * commonest arrangement is one element that is both — a surface that carries\n * the root class and `dsh-ui-card`, or a portaled dialog that is the root and\n * the `dsh-ui-surface`. A descendant-only scope would silently leave those\n * unstyled, with no error anywhere.\n *\n * A caveat worth knowing: `Modal` and `Menu` portal to `document.body`, so their\n * content leaves the plugin's subtree entirely. A portaled surface therefore\n * needs its own root class on an element inside the portal.\n *\n * Only patterns that primitives do not provide live here. If a control appears\n * below that `Button`/`Input`/`Switch`/`Tag`/`Menu` already covers, that is a\n * bug in this file: use the primitive and delete the recipe.\n */\nexport function officialUiCss(roots: string | readonly string[]): string {\n // One plugin often mounts several unrelated surfaces (a settings seat, a chat\n // card, a header menu), so the caller names every root. The rules below are\n // nested under a single selector list and use `&`, which the browser expands\n // per root — so one stylesheet covers all of them without duplicating itself.\n const scope = (typeof roots === 'string' ? [roots] : roots).map(root => `.${root}`).join(', ')\n const sheet = `\n/* Official DSH Web UI contract. Generated by @klarkxy/dsh-plugin-kit/official-ui.\n * Do not hand-edit the copy inside a plugin: change this module so every plugin\n * moves together. Scope: ${scope} */\n/* The scope rule below stays open for the whole sheet: every rule after it\n * nests with the parent selector, so one stylesheet can cover several unrelated\n * roots without leaking into a neighbouring plugin. Its closing brace is last. */\n${scope} {\n color: var(--dsw-alias-label-primary);\n font-family: inherit;\n font-size: 14px;\n line-height: 22px;\n min-width: 0;\n\n& *, & *::before, & *::after { box-sizing: border-box; }\n& h1, & h2, & h3, & h4, & p, & figure { margin: 0; }\n/* Keyboard focus only: pointer input keeps the native resting appearance. The\n * ring needs no radius of its own — the outline already follows the control's\n * own border-radius, and overriding it here would flatten every control. */\n& :focus-visible { ${officialFocus()}; }\n& [hidden] { display: none !important; }\n\n/* --- Type tiers. The same 14/22 and 13/20 steps the primitives use. --- */\n& .dsh-ui-title { font-size: 16px; line-height: 24px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-heading { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-compact { font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-meta { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-hint { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-error { font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-warn { color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-success { color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-muted { color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n& .dsh-ui-wrap { min-width: 0; overflow-wrap: anywhere; }\n\n/* --- Layout scaffolding. --- */\n& .dsh-ui-stack { display: flex; flex-direction: column; gap: 12px; }\n& .dsh-ui-stack-lg { display: flex; flex-direction: column; gap: 20px; }\n/* Plugin detail pages share one reading column. These are layout recipes;\n * controls keep their own primitive styles. Form spacing follows the host's\n * settings-form/fields.module.css and SettingsForm.module.css. */\n& .dsh-ui-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; min-width: 0; }\n& .dsh-ui-form { display: flex; flex-direction: column; gap: 0; min-width: 0; }\n&.dsh-ui-form > .dsh-ui-field, & .dsh-ui-form > .dsh-ui-field { padding: 12px 0; }\n& .dsh-ui-form-footer { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding-top: 16px; min-width: 0; }\n& .dsh-ui-fields-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; min-width: 0; margin: 0; padding: 0; border: 0; }\n@media (max-width: 560px) {\n & .dsh-ui-fields-grid { grid-template-columns: minmax(0, 1fr); }\n}\n& .dsh-ui-row { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-row-wrap { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }\n& .dsh-ui-spacer { flex: 1; min-width: 0; }\n/* A 0.5px l2 rule is the host's section divider; reserve the same rhythm. */\n& .dsh-ui-divider { height: 0.5px; background: var(--dsw-alias-border-l2); }\n& .dsh-ui-section { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 0.5px solid var(--dsw-alias-border-l2); }\n\n/* --- Card: a raised surface whose edge lives in the shadow. --- */\n& .dsh-ui-card {\n ${officialElevation('stroke')}\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding: 16px;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-alias-bg-layer-1);\n color: var(--dsw-alias-label-primary);\n min-width: 0;\n}\n& .dsh-ui-card--flat { border: 0.5px solid var(--dsw-alias-border-l3); box-shadow: none; }\n& .dsh-ui-card--nested { background: var(--dsw-alias-bg-layer-2); }\n& .dsh-ui-card--plain { background: none; }\n\n/* --- Field: label, control, help, error. The control itself is an\n * official primitive, so this only owns the vertical rhythm. --- */\n& .dsh-ui-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }\n& .dsh-ui-field + .dsh-ui-field { border-top: 0.5px solid var(--dsw-alias-border-l2); padding-top: 12px; }\n/* Grid fields share a row, so the stacked-field divider must not win later in\n * the cascade. Reset it here, after the field recipe. */\n& .dsh-ui-fields-grid > .dsh-ui-field { padding: 0; border: 0; }\n& .dsh-ui-label { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n& .dsh-ui-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }\n& .dsh-ui-help { font-size: 12px; line-height: 1.6; color: var(--dsw-alias-label-secondary); }\n& .dsh-ui-help p { margin: 0; }\n& .dsh-ui-help p + p { margin-top: 8px; }\n& .dsh-ui-required { color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-control { width: 100%; min-width: 0; }\n/* An invalid control is marked on the control, not only in the message. */\n& .dsh-ui-control[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-readonly { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-readonly > dt { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n& .dsh-ui-readonly > dd { margin: 0; font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }\n\n/* --- Buttons row. A no-op container: it exists so actions line up on the\n * trailing edge the way every native panel does. --- */\n& .dsh-ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 4px; }\n& .dsh-ui-actions-end { justify-content: flex-end; }\n\n/* --- Banners. A banner is a left-rail notice, the shape used for warnings,\n * deprecations and blocking instructions. --- */\n& .dsh-ui-banner {\n display: flex;\n flex-direction: column;\n gap: 8px;\n padding: 10px 14px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-left: 3px solid var(--dsw-alias-state-warn-primary);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-banner-title { font-weight: 500; color: var(--dsw-alias-state-warn-primary); }\n& .dsh-ui-banner--info { border-left-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-banner--danger { border-left-color: var(--dsw-alias-state-error-primary); }\n& .dsh-ui-banner--success { border-left-color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-banner p { margin: 0; }\n\n/* --- Inline notice: a transient confirmation with no chrome of its own. --- */\n& .dsh-ui-notice { display: flex; align-items: center; gap: 6px; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-success-primary); }\n& .dsh-ui-notice--error { color: var(--dsw-alias-state-error-primary); }\n\n/* --- Empty and loading states. Both sit in a dashed well so an empty panel\n * reads as \"nothing here yet\" rather than as a broken layout. --- */\n& .dsh-ui-empty {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 6px;\n padding: 20px 16px;\n border: 0.5px dashed var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n font-size: 13px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n}\n& .dsh-ui-loading { display: flex; align-items: center; gap: 8px; padding: 20px 0; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }\n\n/* --- Selectable list. A row is a button-sized target with a hover fill and\n * a selected fill; the name carries the weight, the description does not. --- */\n& .dsh-ui-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }\n& .dsh-ui-list-scroll { max-height: min(66vh, 760px); overflow-y: auto; overflow-x: hidden; }\n& .dsh-ui-list-row { border-radius: var(--dsw-radius-md); }\n& .dsh-ui-list-row:hover { background: var(--dsw-alias-interactive-bg-hover); }\n& .dsh-ui-list-row[aria-selected='true'], & .dsh-ui-list-row[data-selected] { background: var(--dsw-alias-interactive-bg-active); }\n& .dsh-ui-list-item {\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n gap: 4px;\n width: 100%;\n min-width: 0;\n padding: 10px 12px;\n border: 0;\n border-radius: var(--dsw-radius-md);\n background: none;\n font: inherit;\n color: inherit;\n text-align: start;\n cursor: pointer;\n}\n& .dsh-ui-list-item:disabled { cursor: default; }\n& .dsh-ui-list-item:disabled:hover { background: none; }\n& .dsh-ui-list-name { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; }\n& .dsh-ui-list-desc { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n\n/* --- Code and structured output. Wraps rather than scrolls, because a\n * feature panel is read rather than scanned. --- */\n& .dsh-ui-code {\n padding: 10px 12px;\n border: 0.5px solid var(--dsw-alias-border-l3);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-1);\n font-family: var(--ds-font-family-code);\n font-size: 12px;\n line-height: 20px;\n color: var(--dsw-alias-label-secondary);\n overflow-wrap: anywhere;\n white-space: pre-wrap;\n}\n& .dsh-ui-scroll { max-height: 60vh; overflow: auto; overscroll-behavior: contain; }\n\n/* --- A toggle row: label on the left, switch on the trailing edge. This is\n * layout only; the switch itself is the official primitive. --- */\n& .dsh-ui-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; padding: 12px 0; }\n& .dsh-ui-toggle-row + .dsh-ui-toggle-row { border-top: 0.5px solid var(--dsw-alias-border-l2); }\n& .dsh-ui-toggle-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }\n& .dsh-ui-toggle-label { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Floating surface: a panel anchored to a trigger. This is the material\n * a menu card is made of — the translucent fill plus its backdrop blur, with\n * the edge riding inside the prominent elevation. A plugin that hand-rolls this\n * is how tokens like --dsw-specific-menu get invented; use this instead. --- */\n& .dsh-ui-surface {\n --dsw-elevation-stroke-color: var(--dsw-alias-border-l1);\n --dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);\n --dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);\n position: relative;\n display: flex;\n flex-direction: column;\n border: 0;\n border-radius: var(--dsw-radius-lg);\n background: var(--dsw-menu-surface-fill);\n backdrop-filter: var(--dsw-menu-backdrop-filter);\n box-shadow: var(--dsw-elevation-prominent);\n color: var(--dsw-alias-label-primary);\n font-size: 13px;\n line-height: 20px;\n min-width: 0;\n}\n& .dsh-ui-surface-body { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; overflow-y: auto; }\n& .dsh-ui-surface-head { display: flex; align-items: center; gap: 8px; min-width: 0; }\n& .dsh-ui-surface-title { font-size: 14px; line-height: 22px; font-weight: 500; color: var(--dsw-alias-label-primary); }\n\n/* --- Native select. The primitives ship no select, so a plugin that offers a\n * closed list of choices keeps the platform control and matches the official\n * settings field geometry exactly (34px, 0.5px l4, radius-md, layer-3). A\n * SegmentedControl is the primitive to reach for when the choices are few\n * enough to show at once. --- */\n& .dsh-ui-select {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n height: 34px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n cursor: pointer;\n}\n& .dsh-ui-select:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-select:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-select[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* --- Native textarea. The primitives ship no textarea either, so a settings\n * prompt keeps the platform element and the same field shell as the select:\n * 0.5px l4, radius-md, layer-3, 13/1.5 type. It grows vertically instead of\n * locking to the select's 34px row. --- */\n& .dsh-ui-textarea {\n box-sizing: border-box;\n width: 100%;\n min-width: 0;\n resize: vertical;\n padding: 8px 12px;\n border: 0.5px solid var(--dsw-alias-border-l4);\n border-radius: var(--dsw-radius-md);\n background: var(--dsw-alias-bg-layer-3);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n color: var(--dsw-alias-label-primary);\n}\n& .dsh-ui-textarea:focus-visible { outline: none; border-color: var(--dsw-alias-state-business-primary); }\n& .dsh-ui-textarea:disabled { color: var(--dsw-alias-label-tertiary); cursor: default; }\n& .dsh-ui-textarea::placeholder { color: var(--dsw-alias-label-dimmed); }\n& .dsh-ui-textarea[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }\n\n/* Long panels scroll inside themselves instead of growing the host page. */\n& .dsh-ui-panel { display: flex; flex-direction: column; gap: 16px; min-width: 0; }\n& .dsh-ui-panel-wide { max-width: 100%; }\n\n@media (prefers-reduced-motion: reduce) {\n & *, & *::before, & *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }\n}\n}\n`\n // Widen every recipe from \"a descendant of the root\" to \"the root, or one of\n // its descendants\". Written as a transform rather than by hand so no recipe\n // can be added later with only the descendant form. The pattern is narrow on\n // purpose: a leading `&` followed by one recipe class and no combinator, so\n // sibling and child rules such as `.dsh-ui-field + .dsh-ui-field` keep their\n // own meaning and are left alone.\n return sheet.replace(/^& (\\.dsh-ui-[a-z0-9-]+)(?=\\s*\\{)/gm, (_match, className: string) =>\n `&${className}, & ${className}`)\n}\n","/** Browser-safe contracts. Shared RPC/result types stay on @klarkxy/dsh-plugin-kit. */\nimport type { RpcResult as SharedRpcResult } from '@klarkxy/dsh-plugin-kit/contracts'\nexport type RpcResult<T = unknown> = SharedRpcResult<T>\n\nexport const PLUGIN_NAME = '@klarkxy/dsh-delegation'\nexport const RPC_CHANNEL = '/dsh-delegation'\nexport const DELEGATION_CLIENT_SERVICE = 'dshDelegationClient'\n\n/** Native delegation tools; Delegation Mode only helps presets that mount one. */\nexport const DELEGATION_TOOLS = ['subagent', 'subagent_fork'] as const\n\nexport interface DelegationSettings {\n readonly revision: number\n /** Initial delegation flag for sessions created from now on. */\n readonly defaultEnabled: boolean\n}\n\nexport const defaultSettings = (): DelegationSettings => ({ revision: 0, defaultEnabled: false })\n\nexport type DelegationRole = 'coordinator' | 'executor'\n\nexport interface DelegationSessionStatus {\n readonly sessionId: string\n /** 'executor' for subagent threads: they never carry their own switch. */\n readonly role: DelegationRole\n /** The session record's flag; false when the session has no record yet. */\n readonly enabled: boolean\n /** The session record's revision; 0 when the session has no record yet. */\n readonly revision: number\n /** No edit is allowed once the first turn starts, or while the session is cold. */\n readonly locked: boolean\n /**\n * Whether a live agent on this session sees a delegation tool; null when no\n * agent is live, so a stale answer is never shown as unavailable.\n */\n readonly capable: boolean | null\n}\n","import type { Context } from '@deepseek-ai/cordis'\nimport { useCallback, useEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport { Button, IconUsersOutlineRegular, Pill, Switch, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { officialUiCss } from '@klarkxy/dsh-plugin-kit/official-ui'\nimport {\n DELEGATION_CLIENT_SERVICE, PLUGIN_NAME, RPC_CHANNEL,\n type DelegationSessionStatus, type DelegationSettings, type RpcResult,\n} from './contracts.ts'\n\nexport const name = 'dsh-delegation-client'\nexport const inject = ['slots', 'connection', 'locale'] as const\n\nconst NS = 'dsh-delegation.action'\n\nconst zh = {\n action: '委派',\n mode: '委派模式',\n titleOn: '本会话将使用委派模式:主代理负责拆解、委派和验收;会话开始后保持锁定',\n titleOff: '开启委派模式:主代理把具体工作交给子代理;会话开始后保持锁定',\n locked: '请在会话开始前选择委派模式',\n incapable: '当前预设缺少子代理工具,需切换到带子代理工具的预设',\n stale: '状态已在别处更改,已刷新',\n failed: '切换失败',\n}\n\nconst en: Record<keyof typeof zh, string> = {\n action: 'Delegate',\n mode: 'Delegation Mode',\n titleOn: 'This session will use Delegation Mode: the main agent plans, delegates, and reviews. Locked once the session starts.',\n titleOff: 'Turn on Delegation Mode: the main agent hands the work to subagents. Locked once the session starts.',\n locked: 'Choose Delegation Mode before the session starts',\n incapable: 'Delegation Mode unavailable: this preset has no subagent tools',\n stale: 'State changed elsewhere; refreshed',\n failed: 'Could not toggle Delegation Mode',\n}\n\ntype Key = keyof typeof zh\ntype Translate = (key: Key) => string\n\n/** A failed RPC keeps its code so the view can name a rejection it understands. */\nclass RpcError extends Error {\n readonly code: string\n constructor(code: string, message: string) {\n super(message)\n this.name = 'RpcError'\n this.code = code\n }\n}\n\nasync function rpc<T>(call: (endpoint: string, payload: unknown) => Promise<unknown>, endpoint: string, payload: unknown = {}): Promise<T> {\n const result = await call(endpoint, payload) as RpcResult<T> | undefined\n if (!result || result.ok !== true) {\n const failed = result && 'error' in result ? result.error : undefined\n throw new RpcError(failed?.code ?? 'unknown', failed?.message ?? '')\n }\n return result.value\n}\n\nexport interface DelegationSessionSnapshotLike {\n openState?: string\n running?: boolean\n blank?: boolean\n awaitingFirstTurn?: boolean\n pendingSubmissions?: readonly unknown[]\n}\n\nexport interface DelegationActionProps {\n sessionId: string\n call: (endpoint: string, payload: unknown) => Promise<unknown>\n /** Host connection-generation subscription; refetches on reconnect. */\n subscribeGeneration?: (listener: () => void) => (() => void) | undefined\n /** Host per-session selector hook; a cold→open transition triggers a refetch. */\n useSession?: <T>(selector: (snapshot: DelegationSessionSnapshotLike) => T) => T\n /** Changing a blank session's preset must refresh tool availability. */\n useProjection?: (key: 'agentPreset') => string | null | undefined\n t: Translate\n}\n\n/** Brief notice shown after a toggle problem, in the tooltip and an aria-live span. */\ntype Notice = '' | 'stale' | 'failed' | 'locked'\n\nexport function DelegationAction({ sessionId, call, subscribeGeneration, useSession, useProjection, t }: DelegationActionProps) {\n const [status, setStatus] = useState<DelegationSessionStatus>()\n const [saving, setSaving] = useState(false)\n const [notice, setNotice] = useState<Notice>('')\n const generationRef = useRef(0)\n const readSeqRef = useRef(0)\n const openState = useSession?.(snapshot => snapshot.openState)\n const sessionRunning = useSession?.(snapshot => snapshot.running === true)\n const sessionBlank = useSession?.(snapshot => snapshot.blank)\n const submitting = useSession?.(snapshot => snapshot.awaitingFirstTurn === true || (snapshot.pendingSubmissions?.length ?? 0) > 0)\n const preset = useProjection?.('agentPreset')\n\n const load = useCallback(async () => {\n const generation = generationRef.current\n const seq = ++readSeqRef.current\n try {\n const next = await rpc<DelegationSessionStatus>(call, 'session.status', { sessionId })\n if (generationRef.current !== generation || seq !== readSeqRef.current) return\n // Revisions never decrease and records are never deleted, so a stale read\n // that lands after a fresher write must not roll the button back.\n setStatus(prev => prev && prev.sessionId === next.sessionId && next.revision < prev.revision ? prev : next)\n } catch {\n // A failed refetch keeps the last known state; the button stays put.\n }\n }, [call, sessionId])\n\n useEffect(() => {\n generationRef.current += 1\n readSeqRef.current += 1\n setStatus(undefined)\n setSaving(false)\n setNotice('')\n }, [sessionId])\n\n useEffect(() => { void load() }, [load, openState, sessionRunning, sessionBlank, preset])\n\n useEffect(() => {\n const off = subscribeGeneration?.(() => { void load() })\n const win = typeof window === 'undefined' ? undefined : window\n const onFocus = () => { void load() }\n win?.addEventListener('focus', onFocus)\n return () => { off?.(); win?.removeEventListener('focus', onFocus) }\n }, [load, subscribeGeneration])\n\n useEffect(() => {\n if (!notice) return\n const timer = setTimeout(() => setNotice(''), 4000)\n return () => clearTimeout(timer)\n }, [notice])\n\n const toggle = useCallback(async () => {\n if (!status || saving || status.locked || sessionBlank === false || sessionRunning || submitting || status.capable !== true) return\n const generation = generationRef.current\n readSeqRef.current += 1\n setSaving(true)\n setNotice('')\n try {\n const next = await rpc<DelegationSessionStatus>(call, 'session.update', {\n sessionId, enabled: !status.enabled, expectedRevision: status.revision,\n })\n if (generationRef.current !== generation) return\n setStatus(next)\n } catch (reason) {\n if (generationRef.current !== generation) return\n if (reason instanceof RpcError && (reason.code === 'stale' || reason.code === 'session-locked')) {\n setNotice(reason.code === 'stale' ? 'stale' : 'locked')\n void load()\n } else {\n setNotice('failed')\n }\n } finally {\n if (generationRef.current === generation) setSaving(false)\n }\n }, [call, load, saving, sessionId, status, sessionBlank, sessionRunning, submitting])\n\n if (!status || status.role === 'executor' || sessionBlank === false) return null\n const capable = status.capable === true\n const enabled = status.enabled\n const locked = status.locked || sessionRunning || submitting\n const tooltip = status.capable === false ? t('incapable') : locked ? t('locked') : notice ? t(notice) : enabled ? t('titleOn') : t('titleOff')\n return (\n <span className=\"dlg-root dlg-action\">\n <Tooltip label={tooltip} side=\"bottom\" gap={4}>\n <Pill\n className=\"dlg-chip\"\n active={enabled}\n aria-pressed={enabled}\n aria-label={t('mode')}\n disabled={!capable || locked || saving}\n onClick={() => void toggle()}\n >\n <IconUsersOutlineRegular />\n <span className=\"dlg-chip-label\">{t('action')}</span>\n </Pill>\n </Tooltip>\n {notice ? <span role=\"status\" className=\"dlg-note\">{t(notice)}</span> : null}\n </span>\n )\n}\n\nexport const clientCss = `${officialUiCss('dlg-root')}\n.dlg-root.dlg-action { display: inline-flex; align-items: center; gap: 6px; }\n.dlg-root .dlg-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; line-height: 20px; border: 1px solid var(--dsw-alias-border-l3); background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; }\n.dlg-root .dlg-chip svg { width: 16px; height: 16px; }\n.dlg-root .dlg-chip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }\n.dlg-root .dlg-chip[aria-pressed=\"true\"] { background: var(--dsw-alias-button-primary-fill); border-color: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }\n.dlg-root .dlg-chip[aria-pressed=\"true\"]:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); border-color: var(--dsw-alias-button-primary-hover); }\n.dlg-root .dlg-chip:disabled { opacity: 0.5; cursor: default; }\n.dlg-root .dlg-note { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }\n`\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context { dshDelegationClient: { active: boolean } }\n}\n\ntype Client = Context & {\n connection: {\n generation?: { subscribe(listener: () => void): () => void }\n rpc: { call(channel: string, endpoint: string, payload: unknown): Promise<unknown> }\n }\n slots: {\n inject(key: string, callback: () => unknown): () => void\n register(spec: { name: string; id: string; order: number; locale: string; inject: () => unknown } | { name: string; key: string }, render: unknown): () => void\n }\n locale: {\n register(ns: string, locales: { zh: Record<string, string>; en: Record<string, string> }): () => void\n getSnapshot?(): { active: string }\n subscribe?(listener: () => void): () => void\n }\n}\n\n/** Host UI language, following live switches with the host's English fallback. */\nfunction useHostLocale(client: Client): string {\n const subscribe = useCallback(\n (listener: () => void) => client.locale.subscribe?.(listener) ?? (() => {}),\n [client],\n )\n const snapshot = useCallback(() => client.locale.getSnapshot?.().active ?? 'en', [client])\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n\nconst settingsZh = {\n default: '新会话默认启用委派',\n defaultHint: '只影响之后新建的会话;发送第一条消息前可单独选择,会话开始后保持锁定。需要预设包含子代理工具。',\n loading: '正在读取设置…',\n saved: '已保存。',\n stale: '设置已更新,请刷新后重试。',\n failed: '无法读取委派设置。',\n retry: '重试',\n refresh: '刷新设置',\n}\n\nconst settingsEn: Record<keyof typeof settingsZh, string> = {\n default: 'Enable Delegation Mode for new sessions',\n defaultHint: 'Only affects sessions created later. Choose before sending the first message; the choice stays locked once the session starts. Requires a preset with subagent tools.',\n loading: 'Loading settings…',\n saved: 'Saved.',\n stale: 'Settings changed; refresh and retry.',\n failed: 'Could not load delegation settings.',\n retry: 'Retry',\n refresh: 'Refresh settings',\n}\n\nfunction settingsCopy(locale: string): Record<keyof typeof settingsZh, string> {\n return String(locale).startsWith('zh') ? settingsZh : settingsEn\n}\n\n/** Plugin-page card: the default flag applied to sessions created from now on. */\nexport function DelegationSettingsPanel(props: { client: Client; locale?: string }) {\n const hostLocale = useHostLocale(props.client)\n const text = settingsCopy(props.locale ?? hostLocale)\n const [settings, setSettings] = useState<DelegationSettings>()\n const [error, setError] = useState<'' | 'failed' | 'stale'>('')\n const [note, setNote] = useState(false)\n const [busy, setBusy] = useState(false)\n const operation = useRef({ epoch: 0, active: false, writing: false })\n\n const call = useCallback(\n (endpoint: string, payload: unknown = {}) => props.client.connection.rpc.call(RPC_CHANNEL, endpoint, payload),\n [props.client],\n )\n\n const refresh = useCallback(() => {\n const state = operation.current\n if (!state.active || state.writing) return\n const epoch = state.epoch\n setBusy(true)\n void rpc<DelegationSettings>(call, 'settings').then(next => {\n if (!state.active || state.epoch !== epoch) return\n setSettings(next)\n setError('')\n }).catch(() => {\n if (!state.active || state.epoch !== epoch) return\n setError('failed')\n }).finally(() => {\n if (state.active && state.epoch === epoch) setBusy(false)\n })\n }, [call])\n const refreshRef = useRef(refresh)\n refreshRef.current = refresh\n useEffect(() => {\n const state = operation.current\n state.epoch++\n state.active = true\n state.writing = false\n setBusy(false)\n setSettings(undefined)\n setError('')\n setNote(false)\n refreshRef.current()\n return () => { state.active = false; state.epoch++ }\n }, [call])\n\n const save = useCallback((defaultEnabled: boolean) => {\n const state = operation.current\n if (!settings || !state.active || state.writing) return\n state.writing = true\n const epoch = state.epoch\n setBusy(true)\n setNote(false)\n setError('')\n void rpc<DelegationSettings>(call, 'settings.update', {\n defaultEnabled,\n expectedRevision: settings.revision,\n }).then(next => {\n if (!state.active || state.epoch !== epoch) return\n setSettings(next)\n setNote(true)\n }).catch(reason => {\n if (!state.active || state.epoch !== epoch) return\n setError(reason instanceof RpcError && reason.code === 'stale' ? 'stale' : 'failed')\n }).finally(() => {\n if (state.active && state.epoch === epoch) { state.writing = false; setBusy(false) }\n })\n }, [call, settings])\n\n if (!settings) {\n return (\n <section className=\"dlg-root dlg-settings dsh-ui-page\">\n {error\n ? <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>\n : <p role=\"status\" className=\"dsh-ui-hint\">{text.loading}</p>}\n <Button variant=\"ghost\" size=\"sm\" disabled={busy} onClick={() => refreshRef.current()}>{text.retry}</Button>\n </section>\n )\n }\n\n return (\n <section className=\"dlg-root dlg-settings dsh-ui-page\" data-testid=\"delegation-settings\">\n <div className=\"dlg-settings-status\">\n <Button variant=\"ghost\" size=\"sm\" disabled={busy} onClick={() => refreshRef.current()}>{text.refresh}</Button>\n {error && <p role=\"alert\" className=\"dsh-ui-error\">{text[error]}</p>}\n {note && <p role=\"status\" className=\"dsh-ui-notice\">{text.saved}</p>}\n </div>\n <article className=\"dlg-root dsh-ui-card\">\n <header className=\"dsh-ui-toggle-row\">\n <div className=\"dsh-ui-toggle-text\">\n <h3 className=\"dsh-ui-toggle-label\">{text.default}</h3>\n <p className=\"dsh-ui-hint\">{text.defaultHint}</p>\n </div>\n <Switch\n checked={settings.defaultEnabled}\n label={text.default}\n disabled={busy}\n onChange={next => save(next)}\n />\n </header>\n </article>\n </section>\n )\n}\n\nexport function apply(ctx: Context): void {\n const client = ctx as unknown as Client\n ctx.provide(DELEGATION_CLIENT_SERVICE, { active: true })\n ctx.effect(() => client.locale.register(NS, { zh: { ...zh }, en: { ...en } }), 'delegation.locale')\n // Style both the new-session option and the independent settings page.\n ctx.effect(() => {\n if (typeof document === 'undefined') return () => {}\n const style = document.createElement('style')\n style.setAttribute('data-plugin', PLUGIN_NAME)\n style.textContent = clientCss\n document.head.appendChild(style)\n return () => style.remove()\n }, 'delegation.styles')\n ctx.effect(() => client.slots.inject('plugins.bundle.config', () => client.slots.register(\n { name: 'plugins.bundle.config', key: PLUGIN_NAME },\n () => <DelegationSettingsPanel client={client} />,\n )), 'delegation.settings')\n ctx.effect(() => client.slots.inject('conversation.hero.options', () => client.slots.register(\n {\n name: 'conversation.hero.options',\n id: 'delegation',\n order: 20,\n locale: NS,\n inject: () => ({\n call: (endpoint: string, payload: unknown) => client.connection.rpc.call(RPC_CHANNEL, endpoint, payload),\n subscribeGeneration: (listener: () => void) => client.connection.generation?.subscribe(listener),\n }),\n },\n DelegationAction,\n )), 'delegation.slot')\n}\n"],"mappings":";;;;AAuH6D,OAAO,OAAO;;CAlFzE,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAEA,QAAQ;EAAC;EAAyB;EAAyB;EAAyB;CAAuB;;CAE3G,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAEA,aAAa;EACX;EACA;EACA;CACF;;CAEA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CACA,OAAO;EACL;EACA;EACA;EACA;EACA;CACF;;CAEA,QAAQ;EAAC;EAAmB;EAAmB;EAAmB;CAAoB;;CAEtF,WAAW;EACT;EACA;EACA;EACA;EACA;CACF;;CAEA,SAAS;EACP;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAEA,QAAQ;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AAIyE,CAAqB,CAAC,CAAC,KAAK;;;;;;AAUvG,MAAa,sBACX;;;;;;AAOF,SAAgB,cAAc,SAAS,OAAe;CACpD,OAAO,YAAY,oBAAoB,oBAAoB;AAC7D;;;;;;;AAQA,SAAgB,kBAAkB,OAAkC;CAClE,OAAO,8CAA8C,MAAM;AAC7D;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAgB,cAAc,OAA2C;CAKvE,MAAM,SAAS,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI,MAAA,CAAO,KAAI,SAAQ,IAAI,MAAM,CAAC,CAAC,KAAK,IAAI;CAqR7F,OAAO;;;4BAjRmB,MAAM;;;;EAIhC,MAAM;;;;;;;;;;;;qBAYa,cA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,OAAO;GACvG,sBAAsB,aAAyB,OAAO,WAAW,YAAY,UAAU,QAAQ;EACjG;CACF,GACA,gBACF,CAAC,GAAG,iBAAiB;AACvB"}
|
package/lib/client.js
CHANGED
|
@@ -433,7 +433,6 @@ const inject = [
|
|
|
433
433
|
const NS = "dsh-delegation.action";
|
|
434
434
|
const zh = {
|
|
435
435
|
action: "委派",
|
|
436
|
-
normal: "默认",
|
|
437
436
|
mode: "委派模式",
|
|
438
437
|
titleOn: "本会话将使用委派模式:主代理负责拆解、委派和验收;会话开始后保持锁定",
|
|
439
438
|
titleOff: "开启委派模式:主代理把具体工作交给子代理;会话开始后保持锁定",
|
|
@@ -444,7 +443,6 @@ const zh = {
|
|
|
444
443
|
};
|
|
445
444
|
const en = {
|
|
446
445
|
action: "Delegate",
|
|
447
|
-
normal: "Default",
|
|
448
446
|
mode: "Delegation Mode",
|
|
449
447
|
titleOn: "This session will use Delegation Mode: the main agent plans, delegates, and reviews. Locked once the session starts.",
|
|
450
448
|
titleOff: "Turn on Delegation Mode: the main agent hands the work to subagents. Locked once the session starts.",
|
|
@@ -569,18 +567,16 @@ function DelegationAction({ sessionId, call, subscribeGeneration, useSession, us
|
|
|
569
567
|
label: tooltip,
|
|
570
568
|
side: "bottom",
|
|
571
569
|
gap: 4,
|
|
572
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
573
|
-
className: "dlg-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
disabled: !capable || locked || saving,
|
|
583
|
-
onChange: () => void toggle()
|
|
570
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Pill, {
|
|
571
|
+
className: "dlg-chip",
|
|
572
|
+
active: enabled,
|
|
573
|
+
"aria-pressed": enabled,
|
|
574
|
+
"aria-label": t("mode"),
|
|
575
|
+
disabled: !capable || locked || saving,
|
|
576
|
+
onClick: () => void toggle(),
|
|
577
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconUsersOutlineRegular, {}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
578
|
+
className: "dlg-chip-label",
|
|
579
|
+
children: t("action")
|
|
584
580
|
})]
|
|
585
581
|
})
|
|
586
582
|
}), notice ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
@@ -592,10 +588,12 @@ function DelegationAction({ sessionId, call, subscribeGeneration, useSession, us
|
|
|
592
588
|
}
|
|
593
589
|
const clientCss = `${officialUiCss("dlg-root")}
|
|
594
590
|
.dlg-root.dlg-action { display: inline-flex; align-items: center; gap: 6px; }
|
|
595
|
-
.dlg-root .dlg-
|
|
596
|
-
.dlg-root .dlg-
|
|
597
|
-
.dlg-root .dlg-
|
|
598
|
-
.dlg-root .dlg-
|
|
591
|
+
.dlg-root .dlg-chip { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; line-height: 20px; border: 1px solid var(--dsw-alias-border-l3); background: transparent; color: var(--dsw-alias-label-secondary); cursor: pointer; }
|
|
592
|
+
.dlg-root .dlg-chip svg { width: 16px; height: 16px; }
|
|
593
|
+
.dlg-root .dlg-chip:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); }
|
|
594
|
+
.dlg-root .dlg-chip[aria-pressed="true"] { background: var(--dsw-alias-button-primary-fill); border-color: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
|
|
595
|
+
.dlg-root .dlg-chip[aria-pressed="true"]:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); border-color: var(--dsw-alias-button-primary-hover); }
|
|
596
|
+
.dlg-root .dlg-chip:disabled { opacity: 0.5; cursor: default; }
|
|
599
597
|
.dlg-root .dlg-note { font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
|
|
600
598
|
`;
|
|
601
599
|
/** Host UI language, following live switches with the host's English fallback. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarkxy/dsh-delegation",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Delegation Mode: a per-session switch where the main agent plans, delegates, and reviews while subagents carry out the work.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -148,6 +148,6 @@
|
|
|
148
148
|
"registry": "https://registry.npmjs.org/"
|
|
149
149
|
},
|
|
150
150
|
"dshRelease": {
|
|
151
|
-
"contentHash": "
|
|
151
|
+
"contentHash": "73deda9fe174094b3c3b5266f6d1a8d8033756e1da1acf6f20480b6061f64e03"
|
|
152
152
|
}
|
|
153
153
|
}
|