dsh-plugin-subscriptions 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +42 -1
  2. package/README.zh.md +42 -1
  3. package/lib/auth/device-flow.d.ts +0 -9
  4. package/lib/auth/device-flow.js +2 -1
  5. package/lib/auth/rpc.d.ts +44 -13
  6. package/lib/auth/rpc.js +127 -9
  7. package/lib/auth/store.d.ts +75 -17
  8. package/lib/auth/store.js +148 -27
  9. package/lib/client/SubscriptionsSection.d.ts +26 -3
  10. package/lib/client/SubscriptionsSection.js +263 -67
  11. package/lib/client/index.js +11 -0
  12. package/lib/client/locales.d.ts +82 -10
  13. package/lib/client/locales.js +82 -10
  14. package/lib/client.js +837 -223
  15. package/lib/client.js.map +1 -1
  16. package/lib/http.d.ts +114 -0
  17. package/lib/http.js +402 -0
  18. package/lib/index.d.ts +21 -0
  19. package/lib/index.js +1938 -208
  20. package/lib/providers/accounts.d.ts +102 -0
  21. package/lib/providers/accounts.js +123 -0
  22. package/lib/providers/antigravity.d.ts +90 -0
  23. package/lib/providers/antigravity.js +392 -0
  24. package/lib/providers/claude.d.ts +22 -4
  25. package/lib/providers/claude.js +97 -16
  26. package/lib/providers/codex.d.ts +24 -3
  27. package/lib/providers/codex.js +121 -21
  28. package/lib/providers/common.d.ts +17 -0
  29. package/lib/providers/common.js +67 -3
  30. package/lib/providers/copilot.d.ts +23 -4
  31. package/lib/providers/copilot.js +99 -19
  32. package/lib/providers/grok.d.ts +24 -4
  33. package/lib/providers/grok.js +106 -19
  34. package/lib/providers/pool-family.d.ts +56 -0
  35. package/lib/providers/pool-family.js +45 -0
  36. package/lib/providers/pool-health.d.ts +74 -0
  37. package/lib/providers/pool-health.js +148 -0
  38. package/lib/providers/pool-usage.d.ts +57 -0
  39. package/lib/providers/pool-usage.js +130 -0
  40. package/lib/providers/pool.d.ts +107 -0
  41. package/lib/providers/pool.js +371 -0
  42. package/lib/tools/image-generate.d.ts +3 -3
  43. package/lib/tools/image-generate.js +4 -2
  44. package/lib/tools/video-generate.d.ts +2 -2
  45. package/lib/tools/video-generate.js +4 -2
  46. package/lib/tools/x-search.d.ts +2 -2
  47. package/lib/tools/x-search.js +4 -2
  48. package/lib/translate/antigravity.d.ts +110 -0
  49. package/lib/translate/antigravity.js +303 -0
  50. package/package.json +14 -9
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["SUBSCRIPTIONS_AUTH_CHANNEL","POLL_INTERVAL_MS","PROVIDERS: readonly { id: SubscriptionProvider; name: string }[]","result: RpcResult<unknown>","fallbackTranslate","text: string","styles: Record<string, CSSProperties>","params: Record<string, unknown>","window","response: StatusResponse","styles","styles: Record<string, CSSProperties>","styles","SUBSCRIPTIONS_AUTH_CHANNEL","PROMPT_MAX_LENGTH","callSubscriptionsAuth","result: RpcResult<unknown>","fallbackTranslate","text: string","derivePrompt","parsed: unknown","prompt: string | undefined","resultText","parts: string[]","images: { attachment: ImageAttachmentRef }[]","styles: Record<string, CSSProperties>","labels: MessageImageLabels","styles","IconSparkle16","result: RpcResult<unknown>","fallbackTranslate","text: string","parsed: unknown","prompt: string | undefined","parts: string[]","styles: Record<string, CSSProperties>","objectUrl: string | undefined","styles","IconSparkle16","TIERS: readonly SpeedTier[]","styles: Record<string, CSSProperties>"],"sources":["../src/client/locales.ts","../src/client/SubscriptionsSection.tsx","../src/client/ImageGallery.tsx","../src/client/ImageGenerateToolview.tsx","../src/client/VideoGenerateToolview.tsx","../src/client/SpeedSelect.tsx","../src/client/index.ts"],"sourcesContent":["/** Copy dictionaries for the Subscriptions settings section. */\n\n/** English strings (the key-set source of truth for this pair). */\nexport const en = {\n nav: 'Subscriptions',\n intro: 'Log a subscription provider in or out. Login opens the provider’s authorization page in a new tab; headless setups can paste the callback URL or code instead.',\n unavailable: 'Connection unavailable; subscription status cannot be loaded.',\n checking: 'Checking…',\n loginInProgress: 'Login in progress…',\n loggedIn: 'Logged in',\n loggedInAccount: 'Logged in as {account}',\n loggedInExpires: 'Logged in · expires {date}',\n loggedInAccountExpires: 'Logged in as {account} · expires {date}',\n notLoggedIn: 'Not logged in',\n login: 'Log in',\n cancel: 'Cancel',\n logout: 'Log out',\n logoutConfirm: 'Log out of {provider}?',\n manualSummary: 'Browser flow not working? Paste the callback URL or code',\n manualPlaceholder: 'Paste the callback URL or code',\n submit: 'Submit',\n loginMissingUrl: 'login answered without an authorizeUrl',\n deviceCodePrompt: 'Enter this code on the GitHub verification page:',\n deviceCodeCopy: 'Copy code',\n deviceCodeCopied: 'Copied',\n deviceCodeOpenPage: 'Open GitHub verification page',\n usageTitle: 'Usage',\n usageRefresh: 'Refresh',\n usageLoading: 'Loading usage…',\n usageEmpty: 'No usage windows reported.',\n usageError: 'Usage lookup failed: {message}',\n usageSession: '5-hour window',\n usageWeekly: 'Weekly',\n usageWindow: 'Window',\n usageResets: 'resets {date}',\n usagePlan: 'Plan: {plan}',\n generating: 'Generating image…',\n image: 'image',\n viewImage: 'View image',\n viewImageNamed: 'View {name}',\n imageLoading: 'Loading…',\n imageLoadFailed: 'Retry',\n imagePreview: 'Image preview',\n imageClose: 'Close',\n generatingVideo: 'Generating video…',\n videoLoading: 'Loading video…',\n videoLoadFailed: 'Video failed to load: {message}',\n speed: 'Speed',\n speedStandard: 'Standard',\n speedStandardDescription: 'Default speed',\n speedFast: 'Fast',\n speedFastDescription: '1.5x speed, more usage',\n commandFast: 'Switch the Codex speed tier (Standard/Fast)',\n commandFastUnavailable: 'The current model has no fast tier; /fast only works on Codex models whose catalog advertises one',\n} satisfies Record<string, string>\n\n/** zh strings, one per {@link en} key. */\nexport const zh = {\n nav: '订阅',\n intro: '在此登录或退出订阅服务商。点击登录会在新标签页打开服务商的授权页面;无浏览器环境可改为粘贴回调 URL 或授权码。',\n unavailable: '连接不可用,无法加载订阅状态。',\n checking: '查询中…',\n loginInProgress: '登录中…',\n loggedIn: '已登录',\n loggedInAccount: '已登录:{account}',\n loggedInExpires: '已登录 · 过期时间 {date}',\n loggedInAccountExpires: '已登录:{account} · 过期时间 {date}',\n notLoggedIn: '未登录',\n login: '登录',\n cancel: '取消',\n logout: '退出登录',\n logoutConfirm: '确定退出 {provider} 的登录吗?',\n manualSummary: '浏览器流程无法完成?粘贴回调 URL 或授权码',\n manualPlaceholder: '粘贴回调 URL 或授权码',\n submit: '提交',\n loginMissingUrl: 'login 响应缺少 authorizeUrl',\n deviceCodePrompt: '在 GitHub 验证页面输入此验证码:',\n deviceCodeCopy: '复制验证码',\n deviceCodeCopied: '已复制',\n deviceCodeOpenPage: '打开 GitHub 验证页面',\n usageTitle: '用量',\n usageRefresh: '刷新',\n usageLoading: '用量加载中…',\n usageEmpty: '服务商未返回任何用量窗口。',\n usageError: '用量查询失败:{message}',\n usageSession: '5 小时窗口',\n usageWeekly: '每周',\n usageWindow: '窗口',\n usageResets: '{date} 重置',\n usagePlan: '计划:{plan}',\n generating: '正在生成图片…',\n image: '图片',\n viewImage: '查看图片',\n viewImageNamed: '查看 {name}',\n imageLoading: '加载中…',\n imageLoadFailed: '重试',\n imagePreview: '图片预览',\n imageClose: '关闭',\n generatingVideo: '正在生成视频…',\n videoLoading: '视频加载中…',\n videoLoadFailed: '视频加载失败:{message}',\n speed: '速度',\n speedStandard: '标准',\n speedStandardDescription: '默认速度',\n speedFast: '快速',\n speedFastDescription: '约 1.5 倍速度,消耗更多用量',\n commandFast: '切换 Codex 速度档(标准/快速)',\n commandFastUnavailable: '当前模型不支持快速档;/fast 仅对目录声明了 fast tier 的 Codex 模型可用',\n} satisfies Record<keyof typeof en, string>\n\n/** The Subscriptions namespace key union (en is the key-set source of truth). */\nexport type SubscriptionsKey = keyof typeof en\n","/**\n * Subscriptions settings section: one card per subscription provider with an\n * OAuth login/logout flow driven by the node half's `/subscriptions-auth` RPC\n * channel. Login state lives server-side; the page polls `status` only while\n * a login attempt is busy, so an idle page never polls. All state is local\n * React state — the page has no store.\n *\n * Every color resolves through a `--dsw-alias-*` design token (the ui-theme\n * design-platform.css values flip under `body[data-ds-dark-theme]`), and\n * every user-visible string goes through the locale-bound `t` of the\n * 'settings.subscriptions' namespace. Buttons and inputs take the\n * ModelsSection vocabulary minus hover rules, which inline styles cannot\n * express.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Poll cadence while a provider login attempt is busy. */\nconst POLL_INTERVAL_MS = 2000\n\n/** Subscription provider ids, fixed by the node half's OAuth adapters. */\nexport type SubscriptionProvider = 'codex' | 'claude' | 'grok' | 'copilot'\n\n/** One provider's login state as answered by the `status` endpoint. */\nexport interface ProviderStatus {\n loggedIn: boolean\n busy: boolean\n expiresAt?: number\n account?: string\n detail?: string\n}\n\n/** `status` endpoint value: the node half owns this shape. */\ninterface StatusResponse {\n providers: Record<SubscriptionProvider, ProviderStatus>\n}\n\n/** One rate-limit window as answered by the `usage` endpoint. */\nexport interface UsageWindow {\n kind: 'session' | 'weekly' | 'other'\n scope?: string\n usedPercent: number\n resetsAt?: number\n}\n\n/** `usage` endpoint value: the node half owns this shape. */\nexport interface ProviderUsage {\n supported: boolean\n windows?: UsageWindow[]\n plan?: string\n}\n\n/** `login` endpoint value: the URL the user completes OAuth at. */\ninterface LoginResponse {\n authorizeUrl: string\n /** Device-flow providers (copilot): the code the user types at authorizeUrl. */\n userCode?: string\n}\n\n/** Injected dependencies of {@link SubscriptionsSection} (slot `inject`). */\nexport interface SubscriptionsSectionInjected {\n /** Generic logical-RPC caller over the Connection transport. */\n rpc: ConnectionHandle['rpc']\n /** Section copy: translate a 'settings.subscriptions' key with `{name}` template params. */\n t: (key: SubscriptionsKey, params?: Record<string, unknown>) => string\n}\n\n/**\n * Props delivered by the slot outlet: the inject face spread flat (the\n * renderer erases the share boundary at the render call).\n */\nexport type SubscriptionsSectionProps = Partial<SubscriptionsSectionInjected>\n\n/** Card display metadata, in page order (names are brand names, not translated). */\nconst PROVIDERS: readonly { id: SubscriptionProvider; name: string }[] = [\n { id: 'codex', name: 'Codex (ChatGPT)' },\n { id: 'claude', name: 'Claude' },\n { id: 'grok', name: 'Grok (X Premium)' },\n { id: 'copilot', name: 'GitHub Copilot' },\n]\n\n/** Business error returned by the `/subscriptions-auth` channel (error branch message). */\nclass SubscriptionsAuthError extends Error {}\n\n/**\n * Call one `/subscriptions-auth` endpoint and unwrap the business result.\n * Shared by the settings section and the composer Speed toggle.\n * @param rpc - Connection RPC caller.\n * @param endpoint - channel-relative endpoint.\n * @param payload - channel-owned request payload.\n * @returns the success value, cast by the caller to the endpoint's shape.\n */\nexport async function callSubscriptionsAuth<T>(rpc: ConnectionHandle['rpc'], endpoint: string, payload: unknown): Promise<T> {\n let result: RpcResult<unknown>\n try {\n result = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, endpoint, payload)\n } catch (error) {\n // The transport rejected rather than answering; surface the same way.\n throw new SubscriptionsAuthError(error instanceof Error ? error.message : String(error))\n }\n if (!result.ok) throw new SubscriptionsAuthError(result.error.message)\n return result.value as T\n}\n\n/** Human text of an action failure, SubscriptionsAuthError or not. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/**\n * English-dictionary fallback for a missing inject `t` (standalone renders);\n * the slot inject always supplies the locale-bound one.\n * @param key - dictionary key.\n * @param params - `{name}` template params.\n * @returns the template with params substituted.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\nconst styles: Record<string, CSSProperties> = {\n section: {\n display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560,\n color: 'var(--dsw-alias-label-primary)',\n },\n intro: { margin: 0, color: 'var(--dsw-alias-label-tertiary)', fontSize: 14, lineHeight: '22px' },\n card: {\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12,\n padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 6,\n },\n cardHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n dot: { width: 8, height: 8, borderRadius: '50%', flexShrink: 0 },\n name: { fontWeight: 500, fontSize: 14, lineHeight: '22px', color: 'var(--dsw-alias-label-primary)' },\n statusLine: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n errorLine: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n actions: { display: 'flex', gap: 8, marginTop: 4, alignItems: 'center', flexWrap: 'wrap' },\n button: {\n boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',\n height: 28, padding: '0 10px', borderRadius: 14,\n border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',\n color: 'var(--dsw-alias-label-primary)', font: 'inherit', fontSize: 12, lineHeight: '18px',\n cursor: 'pointer',\n },\n usage: {\n display: 'flex', flexDirection: 'column', gap: 6, marginTop: 4,\n borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 8,\n },\n usageHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n usageTitle: { fontSize: 12, lineHeight: '18px', fontWeight: 500, color: 'var(--dsw-alias-label-secondary)' },\n usagePlan: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n usageRefresh: {\n boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',\n height: 22, padding: '0 8px', borderRadius: 11, marginLeft: 'auto',\n border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',\n color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 12, lineHeight: '18px',\n cursor: 'pointer',\n },\n usageRow: { display: 'flex', flexDirection: 'column', gap: 3 },\n usageMeta: {\n display: 'flex', justifyContent: 'space-between', gap: 8,\n fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)',\n },\n usageTrack: {\n height: 6, borderRadius: 3, overflow: 'hidden',\n background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l2)',\n },\n usageFill: { height: '100%', borderRadius: 3 },\n manual: { marginTop: 4, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },\n manualRow: { display: 'flex', gap: 8, marginTop: 6 },\n manualInput: {\n flex: 1, height: 32, boxSizing: 'border-box',\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '0 10px', font: 'inherit', fontSize: 14, lineHeight: '22px',\n background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)',\n },\n deviceCode: {\n marginTop: 4, display: 'flex', flexDirection: 'column', gap: 6,\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '10px 12px', background: 'var(--dsw-alias-bg-layer-1)',\n },\n deviceCodeText: {\n fontFamily: 'monospace', fontSize: 18, lineHeight: '24px', letterSpacing: 2,\n color: 'var(--dsw-alias-label-primary)', userSelect: 'all',\n },\n}\n\n/** Status dot color for one provider state. */\nfunction dotColor(status: ProviderStatus | undefined): string {\n if (status?.busy === true) return 'var(--dsw-alias-state-warn-label)'\n if (status?.loggedIn === true) return 'var(--dsw-alias-state-success-primary)'\n return 'var(--dsw-alias-label-dimmed)'\n}\n\n/**\n * One-line status text for one provider state.\n * @param t - section translate.\n * @param status - the provider's last reported state.\n * @returns the localized status line.\n */\nfunction statusText(t: SubscriptionsSectionInjected['t'], status: ProviderStatus | undefined): string {\n if (status === undefined) return t('checking')\n if (status.busy) return t('loginInProgress')\n if (status.loggedIn) {\n const params: Record<string, unknown> = {}\n if (status.account !== undefined) params.account = status.account\n if (status.expiresAt !== undefined) params.date = new Date(status.expiresAt).toLocaleString()\n if (params.account !== undefined && params.date !== undefined) return t('loggedInAccountExpires', params)\n if (params.account !== undefined) return t('loggedInAccount', params)\n if (params.date !== undefined) return t('loggedInExpires', params)\n return t('loggedIn')\n }\n return t('notLoggedIn')\n}\n\n/**\n * Localized label of one usage window (kind, plus the model scope when named).\n * @param t - section translate.\n * @param window - the reported window.\n * @returns e.g. \"5-hour window\" or \"Weekly · Opus\".\n */\nfunction usageWindowLabel(t: SubscriptionsSectionInjected['t'], window: UsageWindow): string {\n const base = window.kind === 'session'\n ? t('usageSession')\n : window.kind === 'weekly' ? t('usageWeekly') : t('usageWindow')\n return window.scope !== undefined && window.scope !== '' ? `${base} · ${window.scope}` : base\n}\n\n/** Bar fill color: success normally, warn from 80%, error from 95%. */\nfunction usageBarColor(usedPercent: number): string {\n if (usedPercent >= 95) return 'var(--dsw-alias-state-error-primary)'\n if (usedPercent >= 80) return 'var(--dsw-alias-state-warn-label)'\n return 'var(--dsw-alias-state-success-primary)'\n}\n\n/**\n * The Subscriptions settings page component.\n * @param props - the slot inject face ({@link SubscriptionsSectionInjected}).\n * @returns the section body, or a notice while the RPC face is absent.\n */\nexport function SubscriptionsSection(props: SubscriptionsSectionProps) {\n const { rpc } = props\n const t = props.t ?? fallbackTranslate\n const [statuses, setStatuses] = useState<Partial<Record<SubscriptionProvider, ProviderStatus>>>({})\n const [errors, setErrors] = useState<Partial<Record<SubscriptionProvider, string>>>({})\n const [manualDrafts, setManualDrafts] = useState<Record<SubscriptionProvider, string>>({\n codex: '', claude: '', grok: '', copilot: '',\n })\n /** Pending device-flow codes (copilot), shown while the attempt polls. */\n const [deviceCodes, setDeviceCodes] = useState<Partial<Record<SubscriptionProvider, { userCode: string; verificationUrl: string }>>>({})\n const [copiedCode, setCopiedCode] = useState<SubscriptionProvider | undefined>(undefined)\n const [usages, setUsages] = useState<Partial<Record<SubscriptionProvider, ProviderUsage>>>({})\n const [usageErrors, setUsageErrors] = useState<Partial<Record<SubscriptionProvider, string>>>({})\n const [usageLoading, setUsageLoading] = useState<Partial<Record<SubscriptionProvider, boolean>>>({})\n const mountedRef = useRef(true)\n const pollersRef = useRef(new Map<SubscriptionProvider, ReturnType<typeof setInterval>>())\n /** Providers with a `usage` call in flight; guards the auto-fetch effect against re-entry. */\n const usageInflightRef = useRef(new Set<SubscriptionProvider>())\n\n const setProviderError = useCallback((provider: SubscriptionProvider, message: string | undefined): void => {\n if (!mountedRef.current) return\n setErrors((prev) => {\n const next = { ...prev }\n if (message === undefined) delete next[provider]\n else next[provider] = message\n return next\n })\n }, [])\n\n const stopPolling = useCallback((provider: SubscriptionProvider): void => {\n const poller = pollersRef.current.get(provider)\n if (poller !== undefined) {\n clearInterval(poller)\n pollersRef.current.delete(provider)\n }\n }, [])\n\n /** Refetch every provider's status; stop a provider's poller once its attempt settles. */\n const refresh = useCallback(async (): Promise<void> => {\n if (rpc === undefined) return\n let response: StatusResponse\n try {\n response = await callSubscriptionsAuth<StatusResponse>(rpc, 'status', {})\n } catch {\n // A failed poll must not kill the page; busy providers keep polling and\n // the action paths report their own errors.\n return\n }\n if (!mountedRef.current) return\n setStatuses(response.providers)\n for (const { id } of PROVIDERS) {\n const status = response.providers[id]\n if (status.loggedIn || !status.busy) {\n stopPolling(id)\n // The attempt settled (success, timeout, or cancel): drop the code card.\n setDeviceCodes((prev) => {\n if (prev[id] === undefined) return prev\n const next = { ...prev }\n delete next[id]\n return next\n })\n }\n }\n }, [rpc, stopPolling])\n\n const startPolling = useCallback((provider: SubscriptionProvider): void => {\n if (pollersRef.current.has(provider)) return\n pollersRef.current.set(provider, setInterval(() => { void refresh() }, POLL_INTERVAL_MS))\n }, [refresh])\n\n // Initial load; every busy provider (e.g. an attempt started before a page\n // reload) resumes polling. Teardown clears pollers and the mounted guard.\n useEffect(() => {\n mountedRef.current = true\n void refresh().then(() => {\n if (!mountedRef.current) return\n setStatuses((current) => {\n for (const { id } of PROVIDERS) {\n if (current[id]?.busy === true) startPolling(id)\n }\n return current\n })\n })\n return () => {\n mountedRef.current = false\n for (const poller of pollersRef.current.values()) clearInterval(poller)\n pollersRef.current.clear()\n }\n }, [refresh, startPolling])\n\n const loadUsage = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined || usageInflightRef.current.has(provider)) return\n usageInflightRef.current.add(provider)\n setUsageLoading(prev => ({ ...prev, [provider]: true }))\n try {\n const usage = await callSubscriptionsAuth<ProviderUsage>(rpc, 'usage', { provider })\n if (!mountedRef.current) return\n setUsages(prev => ({ ...prev, [provider]: usage }))\n setUsageErrors((prev) => {\n const next = { ...prev }\n delete next[provider]\n return next\n })\n } catch (error) {\n if (mountedRef.current) setUsageErrors(prev => ({ ...prev, [provider]: messageOf(error) }))\n } finally {\n usageInflightRef.current.delete(provider)\n if (mountedRef.current) setUsageLoading(prev => ({ ...prev, [provider]: false }))\n }\n }, [rpc])\n\n // Fetch usage once a provider is logged in; drop the cached snapshot on\n // logout so a re-login refetches. A failed lookup does not auto-retry — the\n // per-card Refresh button is the retry path.\n useEffect(() => {\n for (const { id } of PROVIDERS) {\n const status = statuses[id]\n if (status === undefined) continue\n if (status.loggedIn) {\n if (usages[id] === undefined && usageErrors[id] === undefined) void loadUsage(id)\n } else if (usages[id] !== undefined || usageErrors[id] !== undefined) {\n setUsages((prev) => {\n const next = { ...prev }\n delete next[id]\n return next\n })\n setUsageErrors((prev) => {\n const next = { ...prev }\n delete next[id]\n return next\n })\n }\n }\n }, [statuses, usages, usageErrors, loadUsage])\n\n const login = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined) return\n setProviderError(provider, undefined)\n try {\n const response = await callSubscriptionsAuth<LoginResponse>(rpc, 'login', { provider })\n if (typeof response.authorizeUrl === 'string' && response.authorizeUrl === '') {\n // Instant login (e.g. imported from Claude Code credentials)\n await refresh()\n return\n }\n if (typeof response.authorizeUrl !== 'string') {\n throw new SubscriptionsAuthError(t('loginMissingUrl'))\n }\n if (!mountedRef.current) return\n // Optimistic busy so Cancel and the manual fallback appear before the first poll tick.\n setStatuses(prev => ({ ...prev, [provider]: { ...prev[provider], busy: true, loggedIn: false } }))\n if (typeof response.userCode === 'string' && response.userCode.length > 0) {\n // Device flow: show the code card instead of opening the page blind —\n // the user copies the code first, then opens the verification page.\n setDeviceCodes(prev => ({ ...prev, [provider]: { userCode: response.userCode as string, verificationUrl: response.authorizeUrl } }))\n } else {\n window.open(response.authorizeUrl, '_blank', 'noopener')\n }\n startPolling(provider)\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n }, [rpc, t, setProviderError, startPolling])\n\n const cancel = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined) return\n stopPolling(provider)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'cancel', { provider })\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, stopPolling, setProviderError, refresh])\n\n const submitManual = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined) return\n const input = manualDrafts[provider].trim()\n if (input === '') return\n setProviderError(provider, undefined)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'manual', { provider, input })\n if (mountedRef.current) setManualDrafts(prev => ({ ...prev, [provider]: '' }))\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, manualDrafts, setProviderError, refresh])\n\n const logout = useCallback(async (provider: SubscriptionProvider, name: string): Promise<void> => {\n if (rpc === undefined) return\n if (!window.confirm(t('logoutConfirm', { provider: name }))) return\n setProviderError(provider, undefined)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'logout', { provider })\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, t, setProviderError, refresh])\n\n const copyDeviceCode = useCallback((provider: SubscriptionProvider, userCode: string): void => {\n void navigator.clipboard?.writeText(userCode).then(() => {\n if (!mountedRef.current) return\n setCopiedCode(provider)\n setTimeout(() => {\n if (mountedRef.current) {\n setCopiedCode(current => current === provider ? undefined : current)\n }\n }, 1500)\n }).catch(() => undefined)\n }, [])\n\n if (rpc === undefined) {\n return <p style={styles.intro}>{t('unavailable')}</p>\n }\n\n return (\n <div style={styles.section}>\n <p style={styles.intro}>{t('intro')}</p>\n {PROVIDERS.map(({ id, name }) => {\n const status = statuses[id]\n const busy = status?.busy === true\n const deviceCode = deviceCodes[id]\n const usage = usages[id]\n const usageError = usageErrors[id]\n // Providers without a usage endpoint answer supported:false — no block.\n const showUsage = status?.loggedIn === true && usage?.supported !== false\n && (usage !== undefined || usageError !== undefined || usageLoading[id] === true)\n return (\n <div key={id} style={styles.card}>\n <div style={styles.cardHeader}>\n <span style={{ ...styles.dot, background: dotColor(status) }} />\n <span style={styles.name}>{name}</span>\n </div>\n <p style={styles.statusLine}>{statusText(t, status)}</p>\n {status?.detail !== undefined && status.detail !== '' && (\n <p style={styles.statusLine}>{status.detail}</p>\n )}\n {errors[id] !== undefined && <p style={styles.errorLine}>{errors[id]}</p>}\n <div style={styles.actions}>\n {!busy && status?.loggedIn !== true && (\n <button type=\"button\" style={styles.button} onClick={() => { void login(id) }}>\n {t('login')}\n </button>\n )}\n {busy && (\n <button type=\"button\" style={styles.button} onClick={() => { void cancel(id) }}>\n {t('cancel')}\n </button>\n )}\n {status?.loggedIn === true && (\n <button type=\"button\" style={styles.button} onClick={() => { void logout(id, name) }}>\n {t('logout')}\n </button>\n )}\n </div>\n {showUsage && (\n <div style={styles.usage}>\n <div style={styles.usageHeader}>\n <span style={styles.usageTitle}>{t('usageTitle')}</span>\n {usage?.plan !== undefined && (\n <span style={styles.usagePlan}>{t('usagePlan', { plan: usage.plan })}</span>\n )}\n <button\n type=\"button\"\n style={{ ...styles.usageRefresh, ...usageLoading[id] === true ? { opacity: 0.5, cursor: 'default' } : {} }}\n disabled={usageLoading[id] === true}\n onClick={() => { void loadUsage(id) }}\n >\n {t('usageRefresh')}\n </button>\n </div>\n {usage === undefined && usageError === undefined && (\n <p style={styles.statusLine}>{t('usageLoading')}</p>\n )}\n {usageError !== undefined && (\n <p style={styles.errorLine}>{t('usageError', { message: usageError })}</p>\n )}\n {usage?.windows !== undefined && usage.windows.length === 0 && (\n <p style={styles.statusLine}>{t('usageEmpty')}</p>\n )}\n {(usage?.windows ?? []).map((window, index) => {\n const percent = Math.min(100, Math.max(0, window.usedPercent))\n return (\n <div key={index} style={styles.usageRow}>\n <div style={styles.usageMeta}>\n <span>{usageWindowLabel(t, window)}</span>\n <span>\n {`${String(Math.round(percent))}%`}\n {window.resetsAt !== undefined\n && ` · ${t('usageResets', { date: new Date(window.resetsAt).toLocaleString() })}`}\n </span>\n </div>\n <div style={styles.usageTrack}>\n <div style={{ ...styles.usageFill, width: `${String(percent)}%`, background: usageBarColor(percent) }} />\n </div>\n </div>\n )\n })}\n </div>\n )}\n {busy && deviceCode !== undefined && (\n <div style={styles.deviceCode}>\n <span style={styles.statusLine}>{t('deviceCodePrompt')}</span>\n <span style={styles.deviceCodeText}>{deviceCode.userCode}</span>\n <div style={styles.actions}>\n <button type=\"button\" style={styles.button} onClick={() => { copyDeviceCode(id, deviceCode.userCode) }}>\n {copiedCode === id ? t('deviceCodeCopied') : t('deviceCodeCopy')}\n </button>\n <button\n type=\"button\"\n style={styles.button}\n onClick={() => { window.open(deviceCode.verificationUrl, '_blank', 'noopener') }}\n >\n {t('deviceCodeOpenPage')}\n </button>\n </div>\n </div>\n )}\n {busy && deviceCode === undefined && (\n <details style={styles.manual}>\n <summary>{t('manualSummary')}</summary>\n <div style={styles.manualRow}>\n <input\n style={styles.manualInput}\n value={manualDrafts[id]}\n placeholder={t('manualPlaceholder')}\n onChange={event => setManualDrafts(prev => ({ ...prev, [id]: event.target.value }))}\n />\n <button type=\"button\" style={styles.button} onClick={() => { void submitManual(id) }}>\n {t('submit')}\n </button>\n </div>\n </details>\n )}\n </div>\n )\n })}\n </div>\n )\n}\n","/**\n * Plugin-local image gallery for generated-image toolviews.\n *\n * Since web-app rc.8, `@deepseek-ai/dsh-client-ui-attachment`'s browser module\n * exports only its cordis plugin surface (`apply`/`inject`) — the React\n * components are no longer package values, so importing `ImageGallery` from it\n * yields `undefined` at runtime and crashes the toolview inside the slot error\n * boundary (the whole call row disappears). This module re-implements the\n * gallery contract the toolview needs (loader-driven thumbnails, retry on\n * failure, click-to-open lightbox) with the same sizing rules as the platform\n * component, keeping this plugin independent of harness component exports.\n */\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { CSSProperties } from 'react'\n\n/**\n * Mirror of ImageAttachmentRef (packages/attachment/attachment/src/types.ts);\n * the brand on attachmentId is compile-time only, so string suffices here.\n */\nexport interface ImageAttachmentRef {\n attachmentId: string\n mediaType: string\n bytes: number\n width: number\n height: number\n name?: string\n}\n\n/** Loads a session-authorized durable image URL (resolves to a data/blob URL). */\nexport type ImageLoader = (attachment: ImageAttachmentRef) => Promise<string>\n\n/** Lightbox strings forwarded to the opened preview. */\nexport interface ImageLightboxLabels {\n dialog: string\n close: string\n}\n\n/** Message-image strings the owner resolves from its own locale namespace. */\nexport interface MessageImageLabels {\n /** Fallback display name for an unnamed image. */\n image: string\n /** Thumbnail tooltip inviting the original-image preview. */\n open: string\n /** Accessible thumbnail label; receives the image's display name. */\n openNamed: (label: string) => string\n /** Loading placeholder shown until bytes resolve. */\n loading: string\n /** Retry-control label shown when the load fails. */\n loadFailed: string\n /** Lightbox strings forwarded to the opened preview. */\n lightbox: ImageLightboxLabels\n}\n\n/** Display box for a lone image (platform rule): long edge 240px with the\n * rendered aspect ratio clamped to [0.25, 4] — the overflow is cropped by\n * `object-fit: cover` — and never upscaled past the image's natural size. The\n * crop anchor keeps the top of very tall images and the left of very wide\n * ones, where the informative content usually starts. */\nfunction singleFit(attachment: ImageAttachmentRef): { width: number; height: number; objectPosition: string } {\n const natural = attachment.width / attachment.height\n const ratio = Math.min(4, Math.max(0.25, natural))\n const box = ratio >= 1 ? { width: 240, height: 240 / ratio } : { width: 240 * ratio, height: 240 }\n const scale = Math.min(1, attachment.width / box.width, attachment.height / box.height)\n return {\n width: Math.max(1, Math.round(box.width * scale)),\n height: Math.max(1, Math.round(box.height * scale)),\n objectPosition: natural < 0.25 ? 'center top' : natural > 4 ? 'left center' : 'center',\n }\n}\n\nconst styles: Record<string, CSSProperties> = {\n gallery: { display: 'flex', flexWrap: 'wrap', gap: 8, justifyContent: 'flex-start' },\n frame: {\n display: 'grid', placeItems: 'center', overflow: 'hidden', padding: 0,\n border: '1px solid var(--dsw-alias-border-l2-darkmode-thin)', borderRadius: 8,\n background: 'var(--dsw-alias-interactive-bg-hover-solid)', cursor: 'zoom-in',\n },\n tile: { width: 64, height: 64 },\n img: { width: '100%', height: '100%', objectFit: 'cover', display: 'block' },\n loading: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary)', padding: '0 8px' },\n error: {\n fontSize: 12, color: 'var(--dsw-alias-state-error-primary)', cursor: 'pointer',\n border: '1px solid var(--dsw-alias-border-l2-darkmode-thin)', borderRadius: 8,\n background: 'transparent', padding: '6px 10px',\n },\n overlay: {\n position: 'fixed', inset: 0, zIndex: 1000, display: 'grid', placeItems: 'center',\n background: 'rgba(0, 0, 0, 0.72)', padding: 24,\n },\n overlayImg: { maxWidth: '92vw', maxHeight: '92vh', objectFit: 'contain', borderRadius: 4 },\n close: {\n position: 'absolute', top: 12, right: 12, width: 32, height: 32, display: 'grid',\n placeItems: 'center', border: 'none', borderRadius: '50%', cursor: 'pointer',\n background: 'rgba(255, 255, 255, 0.16)', color: '#fff', fontSize: 16, lineHeight: 1,\n },\n}\n\n/**\n * Full-viewport original-image preview: backdrop or close-control click and\n * Escape all dismiss; the image itself is inert so a click on it does not\n * fall through to the backdrop dismissal.\n */\nfunction ImageLightbox({ src, alt, labels, onClose }: {\n src: string\n alt: string\n labels: ImageLightboxLabels\n onClose: () => void\n}) {\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') onClose() }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [onClose])\n return (\n <div role=\"dialog\" aria-label={labels.dialog} style={styles.overlay} onClick={onClose}>\n <img src={src} alt={alt} style={styles.overlayImg} onClick={event => { event.stopPropagation() }} />\n <button type=\"button\" aria-label={labels.close} style={styles.close} onClick={onClose}>×</button>\n </div>\n )\n}\n\n/**\n * Compact history renderer with retryable loading and click-to-open original\n * preview. A lone image renders at its `singleFit` size; an image among\n * several renders as a fixed 64px square tile.\n */\nexport function MessageImage({ attachment, load, variant, labels }: {\n attachment: ImageAttachmentRef\n load: ImageLoader\n variant: 'single' | 'tile'\n labels: MessageImageLabels\n}) {\n const [src, setSrc] = useState<string | null>(null)\n const [error, setError] = useState(false)\n const [open, setOpen] = useState(false)\n // Retry re-arms the one load effect below, so every attempt — first load or\n // retry — runs under the same liveness guard and the same reset.\n const [attempt, setAttempt] = useState(0)\n const retry = useCallback(() => { setAttempt(a => a + 1) }, [])\n const close = useCallback(() => { setOpen(false) }, [])\n const fit = useMemo(\n () => (variant === 'single' ? singleFit(attachment) : undefined),\n [attachment, variant],\n )\n\n useEffect(() => {\n let live = true\n setError(false)\n setSrc(null)\n void load(attachment).then((url) => { if (live) setSrc(url) }).catch(() => { if (live) setError(true) })\n return () => { live = false }\n }, [attachment, load, attempt])\n\n const label = attachment.name ?? labels.image\n if (error) {\n return <button type=\"button\" style={styles.error} onClick={retry}>{labels.loadFailed}</button>\n }\n const box = fit === undefined ? styles.tile : { width: fit.width, height: fit.height }\n return (\n <>\n <button\n type=\"button\"\n style={{ ...styles.frame, ...box }}\n title={labels.open}\n aria-label={labels.openNamed(label)}\n onClick={() => { if (src !== null) setOpen(true) }}\n >\n {src === null\n ? <span style={styles.loading}>{labels.loading}</span>\n : <img src={src} alt={label} style={{ ...styles.img, objectPosition: fit?.objectPosition }} />}\n </button>\n {open && src !== null && <ImageLightbox src={src} alt={label} labels={labels.lightbox} onClose={close} />}\n </>\n )\n}\n\n/** Wrapping image group: a lone image renders large, several render as 64px\n * square tiles (same rule as the platform gallery). */\nexport function ImageGallery({ images, load, labels }: {\n images: readonly { attachment: ImageAttachmentRef }[]\n load: ImageLoader\n labels: MessageImageLabels\n}) {\n if (images.length === 0) return null\n const variant = images.length === 1 ? 'single' : 'tile'\n return (\n <div style={styles.gallery}>\n {images.map((image, index) => (\n <MessageImage key={`${image.attachment.attachmentId}:${index}`} attachment={image.attachment} load={load} variant={variant} labels={labels} />\n ))}\n </div>\n )\n}\n","/**\n * Keyed toolview for the `image_generate` tool: renders generated images\n * inline in the conversation. The row shows the call's prompt while running\n * and after settling; a settled result with image blocks renders them through\n * this plugin's own ImageGallery (harness rc.8 stopped exporting the platform\n * one as a package value), whose bytes load through the node half's\n * `/subscriptions-auth` RPC channel (the durable ImageAttachmentRef is never\n * a fetchable URL on its own). A text-only settled result (degraded route)\n * renders its text; an error result renders the first error line.\n *\n * The 'tool.call.toolview' slot contract is owned by ui-tool\n * (packages/client/ui-tool/src/client/contract/slots.ts), which this package\n * does not resolve; the SlotMap merge and ToolCallOwnerProps below mirror it\n * structurally (same discipline as platform-modules.d.ts).\n */\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport type { ToolCallBlock } from '@deepseek-ai/dsh-client-runtime/client'\nimport { IconSparkle16 } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { ImageGallery } from './ImageGallery.js'\nimport type { ImageAttachmentRef, ImageLoader, MessageImageLabels } from './ImageGallery.js'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Title prompt truncation budget (characters). */\nconst PROMPT_MAX_LENGTH = 60\n\n/** Mirror of ui-tool's ToolCallOwnerProps (see the module header). */\ninterface ToolCallOwnerProps {\n callId: string\n toolName: string\n block: ToolCallBlock\n cwd?: string | undefined\n openFile: (path: string) => void\n inspect?: (() => void) | undefined\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /** Mirror of ui-tool's keyed atomic Tool view declaration (see the module header). */\n 'tool.call.toolview': { kind: 'keyed'; scope: 'session'; owner: ToolCallOwnerProps }\n }\n}\n\n/** Injected dependencies of {@link ImageGenerateToolview} (slot `inject`). */\nexport interface ImageGenerateToolviewInjected {\n /** Session-authorized image URL loader riding the `/subscriptions-auth` channel. */\n load: ImageLoader\n}\n\n/**\n * Props delivered by the toolview outlet: the owner share plus the inject\n * face and the framework locale seat, spread flat.\n */\nexport type ImageGenerateToolviewProps =\n Partial<ToolCallOwnerProps>\n & Partial<ImageGenerateToolviewInjected>\n & { t?: ((key: SubscriptionsKey, params?: Record<string, unknown>) => string) | undefined }\n\n/** `image` endpoint result: the node half owns this shape. */\ninterface ImageEndpointResult {\n mediaType: string\n dataBase64: string\n}\n\n/**\n * Call one `/subscriptions-auth` endpoint and unwrap the business result.\n * @param rpc - Connection RPC caller.\n * @param endpoint - channel-relative endpoint.\n * @param payload - channel-owned request payload.\n * @returns the success value, cast by the caller to the endpoint's shape.\n */\nasync function callSubscriptionsAuth<T>(rpc: ConnectionHandle['rpc'], endpoint: string, payload: unknown): Promise<T> {\n const result: RpcResult<unknown> = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, endpoint, payload)\n if (!result.ok) throw new Error(result.error.message)\n return result.value as T\n}\n\n/**\n * Build the ImageGallery loader over the `image` endpoint.\n * @param rpc - Connection RPC caller.\n * @returns loader resolving an attachment ref to a data URL.\n */\nexport function createImageLoader(rpc: ConnectionHandle['rpc']): ImageLoader {\n // The host validates a full ImageAttachmentRef payload (readImage takes the\n // whole ref), so forward the attachment verbatim.\n return attachment =>\n callSubscriptionsAuth<ImageEndpointResult>(rpc, 'image', { ...attachment })\n .then(result => `data:${result.mediaType};base64,${result.dataBase64}`)\n}\n\n/**\n * English-dictionary fallback for a missing locale seat (standalone renders);\n * the framework always supplies the namespace-bound one.\n * @param key - dictionary key.\n * @param params - `{name}` template params.\n * @returns the template with params substituted.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\n/** Extract the prompt from the call's raw args JSON; falls back to the first string value, then the raw line. */\nfunction derivePrompt(argsRaw: string): string {\n let parsed: unknown\n try {\n parsed = JSON.parse(argsRaw)\n } catch {\n // Non-JSON args (mid-stream truncation): fall back to the raw string below.\n parsed = undefined\n }\n let prompt: string | undefined\n if (typeof parsed === 'object' && parsed !== null) {\n const args = parsed as Record<string, unknown>\n if (typeof args.prompt === 'string' && args.prompt !== '') prompt = args.prompt\n else {\n for (const value of Object.values(args)) {\n if (typeof value === 'string' && value !== '') { prompt = value; break }\n }\n }\n }\n const line = (prompt ?? argsRaw).split('\\n', 1)[0] ?? ''\n return line.length > PROMPT_MAX_LENGTH ? `${line.slice(0, PROMPT_MAX_LENGTH)}…` : line\n}\n\n/** Flatten a settled result's text blocks (the degraded text-only route and the error line). */\nfunction resultText(block: ToolCallBlock): string {\n if (!('kind' in block)) return ''\n const parts: string[] = []\n for (const part of block.content) {\n if (part.type === 'text') parts.push(part.text)\n }\n if (parts.length === 0 && block.error !== undefined) parts.push(`${block.error.name}: ${block.error.code}`)\n return parts.join('\\n')\n}\n\n/** Image attachments of a settled result; empty while running or on the text-only route. */\nfunction resultImages(block: ToolCallBlock): { attachment: ImageAttachmentRef }[] {\n if (!('kind' in block)) return []\n const images: { attachment: ImageAttachmentRef }[] = []\n for (const part of block.content) {\n if (part.type === 'image') images.push({ attachment: part.attachment as ImageAttachmentRef })\n }\n return images\n}\n\nconst styles: Record<string, CSSProperties> = {\n container: { display: 'flex', flexDirection: 'column', gap: 6, padding: '4px 0' },\n row: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 },\n icon: { display: 'inline-flex', flexShrink: 0, color: 'var(--dsw-alias-label-tertiary)' },\n title: {\n fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)',\n overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',\n },\n subtle: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n output: {\n margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)',\n whiteSpace: 'pre-wrap', overflowWrap: 'anywhere',\n },\n error: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n}\n\n/**\n * The `image_generate` keyed toolview component.\n * @param props - owner share, inject face, and locale seat (spread flat).\n * @returns the call row plus, once settled, the gallery / text / error body.\n */\nexport function ImageGenerateToolview(props: ImageGenerateToolviewProps) {\n const { block, load } = props\n const t = props.t ?? fallbackTranslate\n if (block === undefined) return null\n const settled = 'kind' in block\n const argsRaw = (settled ? block.call?.argsRaw : block.argsRaw) ?? ''\n const title = `image_generate: ${derivePrompt(argsRaw)}`\n const images = resultImages(block)\n const text = settled ? resultText(block) : ''\n const labels: MessageImageLabels = {\n image: t('image'),\n open: t('viewImage'),\n openNamed: name => t('viewImageNamed', { name }),\n loading: t('imageLoading'),\n loadFailed: t('imageLoadFailed'),\n lightbox: { dialog: t('imagePreview'), close: t('imageClose') },\n }\n return (\n <div style={styles.container}>\n <div style={styles.row}>\n <span style={styles.icon}><IconSparkle16 size={14} /></span>\n <span style={styles.title}>{title}</span>\n </div>\n {!settled && <p style={styles.subtle}>{t('generating')}</p>}\n {settled && block.isError && text !== '' && (\n <p style={styles.error}>{text.split('\\n', 1)[0]}</p>\n )}\n {settled && !block.isError && images.length > 0 && load !== undefined && (\n <ImageGallery images={images} load={load} labels={labels} />\n )}\n {settled && !block.isError && images.length === 0 && text !== '' && (\n <p style={styles.output}>{text}</p>\n )}\n </div>\n )\n}\n","/**\n * Keyed toolview for the `video_generate` tool: renders the generated video\n * inline in the conversation. The row shows the call's prompt while running\n * and after settling; a settled success loads the MP4 bytes through the node\n * half's `/subscriptions-auth` `video` endpoint (by bare file name), builds a\n * Blob URL, and plays it in a native `<video controls>` element. The file\n * name comes from the result's presentation meta when the dispatch was\n * top-level, and is recovered from the \"Saved video to …\" text line for\n * nested (Code Mode) dispatches, where the harness computes no meta. A result\n * with neither renders its text; an error result renders the first error line.\n *\n * The 'tool.call.toolview' SlotMap entry is declared by\n * ImageGenerateToolview.tsx in this same package (one declaration per\n * augmentation), so this file only mirrors the owner-props shape.\n */\nimport { useEffect, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport type { ToolCallBlock } from '@deepseek-ai/dsh-client-runtime/client'\nimport { IconSparkle16 } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Title prompt truncation budget (characters). */\nconst PROMPT_MAX_LENGTH = 60\n\n/** Mirror of ui-tool's ToolCallOwnerProps (see ImageGenerateToolview). */\ninterface ToolCallOwnerProps {\n callId: string\n toolName: string\n block: ToolCallBlock\n cwd?: string | undefined\n openFile: (path: string) => void\n inspect?: (() => void) | undefined\n}\n\n/** Decoded video bytes as the node half's `video` endpoint answers them. */\nexport interface VideoBytes {\n mediaType: string\n dataBase64: string\n}\n\n/** Injected dependencies of {@link VideoGenerateToolview} (slot `inject`). */\nexport interface VideoGenerateToolviewInjected {\n /** Loads one generated video's bytes by bare file name. */\n loadVideo: (name: string) => Promise<VideoBytes>\n}\n\n/**\n * Props delivered by the toolview outlet: the owner share plus the inject\n * face and the framework locale seat, spread flat.\n */\nexport type VideoGenerateToolviewProps =\n Partial<ToolCallOwnerProps>\n & Partial<VideoGenerateToolviewInjected>\n & { t?: ((key: SubscriptionsKey, params?: Record<string, unknown>) => string) | undefined }\n\n/**\n * Build the video loader over the `/subscriptions-auth` `video` endpoint.\n * @param rpc - Connection RPC caller.\n * @returns loader resolving a bare file name to the decoded bytes.\n */\nexport function createVideoLoader(rpc: ConnectionHandle['rpc']): (name: string) => Promise<VideoBytes> {\n return async (name) => {\n const result: RpcResult<unknown> = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, 'video', { name })\n if (!result.ok) throw new Error(result.error.message)\n return result.value as VideoBytes\n }\n}\n\n/**\n * English-dictionary fallback for a missing locale seat (standalone renders);\n * the framework always supplies the namespace-bound one.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\n/** Extract the prompt from the call's raw args JSON; falls back to the first string value, then the raw line. */\nfunction derivePrompt(argsRaw: string): string {\n let parsed: unknown\n try {\n parsed = JSON.parse(argsRaw)\n } catch {\n // Non-JSON args (mid-stream truncation): fall back to the raw string below.\n parsed = undefined\n }\n let prompt: string | undefined\n if (typeof parsed === 'object' && parsed !== null) {\n const args = parsed as Record<string, unknown>\n if (typeof args.prompt === 'string' && args.prompt !== '') prompt = args.prompt\n else {\n for (const value of Object.values(args)) {\n if (typeof value === 'string' && value !== '') { prompt = value; break }\n }\n }\n }\n const line = (prompt ?? argsRaw).split('\\n', 1)[0] ?? ''\n return line.length > PROMPT_MAX_LENGTH ? `${line.slice(0, PROMPT_MAX_LENGTH)}…` : line\n}\n\n/** Flatten a settled result's text blocks (the fallback body and the error line). */\nfunction resultText(block: ToolCallBlock): string {\n if (!('kind' in block)) return ''\n const parts: string[] = []\n for (const part of block.content) {\n if (part.type === 'text') parts.push(part.text)\n }\n if (parts.length === 0 && block.error !== undefined) parts.push(`${block.error.name}: ${block.error.code}`)\n return parts.join('\\n')\n}\n\n/**\n * The generated video's bare file name: presentation meta first (top-level\n * dispatches), then the render text's \"Saved video to …\" line (nested\n * dispatches compute no meta).\n */\nfunction resolveFileName(block: ToolCallBlock): string | undefined {\n if (!('kind' in block)) return undefined\n const meta = block.meta\n if (typeof meta === 'object' && meta !== null) {\n const fileName = (meta as Record<string, unknown>).fileName\n if (typeof fileName === 'string' && fileName.length > 0) return fileName\n }\n const match = /^Saved video to (.+\\.mp4)/m.exec(resultText(block))\n if (match === null) return undefined\n const path = match[1]\n return path.slice(path.lastIndexOf('/') + 1)\n}\n\n/** Decode a base64 payload into bytes (browser-side; no Buffer). */\nfunction base64Bytes(dataBase64: string): Uint8Array {\n const binary = atob(dataBase64)\n const bytes = new Uint8Array(binary.length)\n for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index)\n return bytes\n}\n\n/** Loading lifecycle of the Blob URL. */\ntype LoadState =\n | { phase: 'loading' }\n | { phase: 'ready'; url: string }\n | { phase: 'failed'; message: string }\n\nconst styles: Record<string, CSSProperties> = {\n container: { display: 'flex', flexDirection: 'column', gap: 6, padding: '4px 0' },\n row: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 },\n icon: { display: 'inline-flex', flexShrink: 0, color: 'var(--dsw-alias-label-tertiary)' },\n title: {\n fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)',\n overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',\n },\n subtle: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n output: {\n margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)',\n whiteSpace: 'pre-wrap', overflowWrap: 'anywhere',\n },\n error: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n video: {\n display: 'block', maxWidth: 480, width: '100%', borderRadius: 8,\n backgroundColor: 'var(--dsw-alias-fill-tertiary)',\n },\n}\n\n/**\n * The `video_generate` keyed toolview component.\n * @param props - owner share, inject face, and locale seat (spread flat).\n * @returns the call row plus, once settled, the player / text / error body.\n */\nexport function VideoGenerateToolview(props: VideoGenerateToolviewProps) {\n const { block, loadVideo } = props\n const t = props.t ?? fallbackTranslate\n const settled = block !== undefined && 'kind' in block\n const isError = settled && block.isError\n const fileName = block !== undefined && settled && !isError ? resolveFileName(block) : undefined\n const [load, setLoad] = useState<LoadState>({ phase: 'loading' })\n\n useEffect(() => {\n if (fileName === undefined || loadVideo === undefined) return\n let cancelled = false\n let objectUrl: string | undefined\n setLoad({ phase: 'loading' })\n loadVideo(fileName).then(\n (video) => {\n if (cancelled) return\n // Uint8Array#slice detaches a plain ArrayBuffer view for BlobPart.\n objectUrl = URL.createObjectURL(new Blob([base64Bytes(video.dataBase64).slice()], { type: video.mediaType }))\n setLoad({ phase: 'ready', url: objectUrl })\n },\n (error: unknown) => {\n if (cancelled) return\n setLoad({ phase: 'failed', message: error instanceof Error ? error.message : String(error) })\n },\n )\n return () => {\n cancelled = true\n if (objectUrl !== undefined) URL.revokeObjectURL(objectUrl)\n }\n }, [fileName, loadVideo])\n\n if (block === undefined) return null\n const argsRaw = (settled ? block.call?.argsRaw : block.argsRaw) ?? ''\n const title = `video_generate: ${derivePrompt(argsRaw)}`\n const text = settled ? resultText(block) : ''\n return (\n <div style={styles.container}>\n <div style={styles.row}>\n <span style={styles.icon}><IconSparkle16 size={14} /></span>\n <span style={styles.title}>{title}</span>\n </div>\n {!settled && <p style={styles.subtle}>{t('generatingVideo')}</p>}\n {settled && isError && text !== '' && (\n <p style={styles.error}>{text.split('\\n', 1)[0]}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'loading' && (\n <p style={styles.subtle}>{t('videoLoading')}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'failed' && (\n <p style={styles.error}>{t('videoLoadFailed', { message: load.message })}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'ready' && (\n // eslint-disable-next-line jsx-a11y/media-has-caption -- generated clip; no caption track exists.\n <video style={styles.video} src={load.url} controls preload=\"metadata\" />\n )}\n {settled && !isError && fileName === undefined && text !== '' && (\n <p style={styles.output}>{text}</p>\n )}\n </div>\n )\n}\n","/**\n * Codex Speed toggle: one small control in the composer's right tool row\n * (`conversation.input.right`), switching the session between standard routing\n * and the fast (priority) service tier — the Codex desktop app's Speed menu.\n * The choice is per session and lives in the node half (in-memory); this\n * component holds only viewing state. The control renders nothing until the\n * first load proves the session's current model is a codex model whose catalog\n * advertises the fast tier.\n *\n * Every color resolves through a `--dsw-alias-*` design token and every\n * user-visible string goes through the locale `t` of the\n * 'settings.subscriptions' namespace, same as the settings section.\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { ConnectionHandle, SessionId } from '@deepseek-ai/dsh-api-remotes/client'\nimport { callSubscriptionsAuth } from './SubscriptionsSection.js'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** One session's speed choice: standard routing or the fast (priority) tier. */\nexport type SpeedTier = 'standard' | 'fast'\n\n/** `speed` endpoint value, mirrored from the node half. */\nexport interface SpeedState {\n tier: SpeedTier\n fastModels: string[]\n}\n\n/** What {@link SpeedSelect} renders from: visibility plus the current tier. */\nexport interface SpeedSelectState {\n visible: boolean\n tier: SpeedTier\n}\n\n/** Injected dependencies of {@link SpeedSelect} (slot `inject`, session-bound). */\nexport interface SpeedSelectInjected {\n /** Load the session's speed state; `visible` false keeps the control hidden. */\n loadSpeed: () => Promise<SpeedSelectState>\n /** Set the session's speed tier; resolves false when the write failed. */\n setSpeed: (tier: SpeedTier) => Promise<boolean>\n}\n\n/**\n * Props delivered by the slot outlet: the framework session kit and InputZone\n * owner share (unused — everything arrives session-bound through the inject\n * face), the injected callbacks, and the locale seat.\n */\nexport type SpeedSelectProps = PropsRuntime<'conversation.input.right'>\n & Partial<SpeedSelectInjected>\n & Partial<PropsLocale<'settings.subscriptions'>>\n\n/**\n * The `loadSpeed` half of the inject face: the plugin's own speed state plus\n * the host's current model selection (the visibility gate). A model-RPC\n * failure throws rather than answering \"hidden\" — the caller keeps its last\n * known state, so a transient failure never locks the toggle away.\n *\n * `sessionId` is a plain string: slot and command contexts brand it through\n * different dsh-session copies, and only the API-client boundary needs one.\n */\nexport function createSpeedLoader(\n connection: ConnectionHandle,\n sessionId: string,\n): SpeedSelectInjected['loadSpeed'] {\n return async () => {\n const state = await callSubscriptionsAuth<SpeedState>(connection.rpc, 'speed', { sessionId })\n const { result } = await connection.api.sessions.models({ sessionId: sessionId as SessionId })\n if (!result.ok) throw new Error(`session.models failed: ${result.error.code}: ${result.error.message}`)\n const current = result.value.current\n const visible = current !== null && current.provider === 'codex'\n && state.fastModels.includes(current.model)\n return { visible, tier: state.tier }\n }\n}\n\n/** The `setSpeed` half of the inject face: boolean outcome for the component's busy state. */\nexport function createSpeedSetter(\n connection: ConnectionHandle,\n sessionId: string,\n): SpeedSelectInjected['setSpeed'] {\n return tier => callSubscriptionsAuth(connection.rpc, 'setSpeed', { sessionId, tier })\n .then(() => true, () => false)\n}\n\n/** English-dictionary fallback for a missing inject `t` (standalone renders). */\nfunction fallbackTranslate(key: SubscriptionsKey): string {\n return en[key]\n}\n\nconst TIERS: readonly SpeedTier[] = ['standard', 'fast']\n\n/**\n * The composer Speed control: a trigger reading `速度 · 快速`/`速度 · 标准`\n * that opens a two-row menu (standard/fast with descriptions, check mark on\n * the current tier). Mount and every open reload the host state so a model\n * switch made since the last open self-corrects.\n */\n/** How often the control re-reads the host state (model switches arrive only by asking). */\nconst POLL_INTERVAL_MS = 3000\n\n/**\n * The composer Speed control: a trigger reading `速度 · 快速`/`速度 · 标准`\n * that opens a two-row menu (standard/fast with descriptions, check mark on\n * the current tier). The host pushes nothing on a model switch, so the\n * control re-reads on a slow poll with a single-flight guard; a failed read\n * keeps the last known state, so a transient RPC failure can never lock the\n * toggle away (the earlier mount-only load had no recovery path).\n */\nexport function SpeedSelect({ loadSpeed, setSpeed, t }: SpeedSelectProps) {\n const translate = t ?? fallbackTranslate\n const [state, setState] = useState<SpeedSelectState | null>(null)\n const [open, setOpen] = useState(false)\n const [busy, setBusy] = useState(false)\n const rootRef = useRef<HTMLDivElement | null>(null)\n // The inject face may be re-evaluated (new callback identities) on re-render;\n // the poll effect mounts once and reads through this ref, so identity churn\n // neither resets the interval nor multiplies in-flight loads.\n const loadRef = useRef(loadSpeed)\n loadRef.current = loadSpeed\n\n useEffect(() => {\n if (loadRef.current === undefined) return\n let cancelled = false\n let inflight = false\n const reload = (): void => {\n const load = loadRef.current\n if (load === undefined || inflight) return\n inflight = true\n void load().then(\n (loaded) => { if (!cancelled) setState(loaded) },\n () => { /* keep the last known state; the next tick retries */ },\n ).finally(() => { inflight = false })\n }\n reload()\n const timer = setInterval(reload, POLL_INTERVAL_MS)\n return () => {\n cancelled = true\n clearInterval(timer)\n }\n }, [])\n\n useEffect(() => {\n if (!open) return\n const closeOutside = (event: MouseEvent): void => {\n if (!rootRef.current?.contains(event.target as Node)) setOpen(false)\n }\n document.addEventListener('mousedown', closeOutside)\n return () => { document.removeEventListener('mousedown', closeOutside) }\n }, [open])\n\n if (loadSpeed === undefined || setSpeed === undefined || state === null || !state.visible) {\n return null\n }\n\n const choose = (tier: SpeedTier): void => {\n if (busy) return\n if (tier === state.tier) {\n setOpen(false)\n return\n }\n setBusy(true)\n void setSpeed(tier).then((ok) => {\n setBusy(false)\n if (ok) {\n setState({ visible: true, tier })\n setOpen(false)\n }\n })\n }\n\n const show = (): void => {\n setOpen(true)\n const load = loadRef.current\n if (load === undefined) return\n void load().then(setState, () => { /* keep showing the last good state */ })\n }\n\n const tierName = (tier: SpeedTier): string =>\n translate(tier === 'fast' ? 'speedFast' : 'speedStandard')\n const tierDescription = (tier: SpeedTier): string =>\n translate(tier === 'fast' ? 'speedFastDescription' : 'speedStandardDescription')\n const triggerLabel = `${translate('speed')} · ${tierName(state.tier)}`\n\n return (\n <div\n ref={rootRef}\n style={styles.root}\n onKeyDown={(event) => {\n if (event.key === 'Escape' && open) {\n event.preventDefault()\n setOpen(false)\n }\n }}\n >\n {open && (\n <div style={styles.menu} role=\"menu\" aria-label={translate('speed')}>\n {TIERS.map(tier => (\n <button\n key={tier}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={tier === state.tier}\n style={styles.item}\n disabled={busy}\n onClick={() => { choose(tier) }}\n >\n <span style={styles.itemCheck}>{tier === state.tier ? '✓' : ''}</span>\n <span style={styles.itemText}>\n <span style={styles.itemName}>{tierName(tier)}</span>\n <span style={styles.itemDescription}>{tierDescription(tier)}</span>\n </span>\n </button>\n ))}\n </div>\n )}\n <button\n type=\"button\"\n style={styles.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n title={triggerLabel}\n disabled={busy}\n onClick={() => {\n if (open) setOpen(false)\n else show()\n }}\n >\n {triggerLabel}\n </button>\n </div>\n )\n}\n\nconst styles: Record<string, CSSProperties> = {\n root: { position: 'relative', display: 'inline-flex' },\n trigger: {\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n background: 'transparent', color: 'var(--dsw-alias-label-secondary)',\n font: 'inherit', fontSize: 12, lineHeight: '18px',\n padding: '2px 8px', cursor: 'pointer', whiteSpace: 'nowrap',\n },\n menu: {\n position: 'absolute', bottom: '100%', right: 0, marginBottom: 4,\n minWidth: 180, padding: 4, zIndex: 20,\n background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l2)',\n borderRadius: 8, display: 'flex', flexDirection: 'column', gap: 2,\n },\n item: {\n display: 'flex', alignItems: 'flex-start', gap: 6, width: '100%',\n border: 'none', borderRadius: 6, background: 'transparent',\n padding: '6px 8px', cursor: 'pointer', font: 'inherit', textAlign: 'left',\n },\n itemCheck: {\n width: 14, flexShrink: 0, fontSize: 12, lineHeight: '18px',\n color: 'var(--dsw-alias-label-primary)',\n },\n itemText: { display: 'flex', flexDirection: 'column' },\n itemName: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-primary)' },\n itemDescription: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-tertiary)' },\n}\n","/**\n * Subscription OAuth login page, browser half. Registers the Subscriptions\n * settings section; every login state fact arrives through the node half's\n * `/subscriptions-auth` RPC channel — this plugin holds no credential state of its\n * own. Section copy rides the client locale service: one 'settings.subscriptions'\n * namespace with zh/en dictionaries, rebound per read so the nav label and\n * page text follow the active locale.\n */\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle, SessionId } from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: pulls the shell's SlotMap merge (the 'settings.section' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n// Type-only: pulls ui-conversation's SlotMap merge (the 'conversation.input.right' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: the slash-command registry contract (the /fast contribution).\nimport type { CommandUiContract } from '@deepseek-ai/dsh-client-ui-commands/client'\n// `.js` extension: this package's tsconfig lacks the reference repo's\n// allowImportingTsExtensions/rewriteRelativeImportExtensions pair; under\n// nodenext the .js specifier resolves to the .tsx source (see README note).\nimport { SubscriptionsSection } from './SubscriptionsSection.js'\nimport type { SubscriptionsSectionInjected } from './SubscriptionsSection.js'\nimport { ImageGenerateToolview, createImageLoader } from './ImageGenerateToolview.js'\nimport type { ImageGenerateToolviewInjected } from './ImageGenerateToolview.js'\nimport { VideoGenerateToolview, createVideoLoader } from './VideoGenerateToolview.js'\nimport type { VideoGenerateToolviewInjected } from './VideoGenerateToolview.js'\nimport { SpeedSelect, createSpeedLoader, createSpeedSetter } from './SpeedSelect.js'\nimport type { SpeedSelectInjected } from './SpeedSelect.js'\nimport { en, zh } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\nexport type { SubscriptionsSectionInjected, SubscriptionsSectionProps } from './SubscriptionsSection.js'\nexport type { ImageGenerateToolviewInjected, ImageGenerateToolviewProps } from './ImageGenerateToolview.js'\nexport type { VideoGenerateToolviewInjected, VideoGenerateToolviewProps } from './VideoGenerateToolview.js'\nexport type { SpeedSelectInjected, SpeedSelectProps, SpeedState, SpeedTier } from './SpeedSelect.js'\nexport type { SubscriptionsKey } from './locales.js'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** The Subscriptions settings page copy. */\n 'settings.subscriptions': SubscriptionsKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nconst NS = 'settings.subscriptions'\n\n/**\n * Required services (cordis fiber inject): `slots` carries the registration\n * seat, `connection` the `/subscriptions-auth` RPC caller, and `locale` the copy\n * dictionaries.\n */\nexport const inject = ['slots', 'connection', 'locale']\n\n/**\n * Register the Subscriptions section once the `settings.section` declaration\n * is on the ledger (the shell's apply order relative to this one is NOT\n * constrained; registration depends on the slot through `slots.inject()`).\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-plugin-subscriptions: copy dictionaries')\n // The client-runtime Context merge types `connection` as the host handle;\n // in the browser shell the same key holds the full client ConnectionHandle.\n const connection = ctx.get('connection') as unknown as ConnectionHandle\n const t = ctx.locale.bind(NS) as SubscriptionsSectionInjected['t']\n const injected = (): SubscriptionsSectionInjected => ({ rpc: connection.rpc, t })\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section',\n id: 'subscriptions',\n order: 90,\n // A thunk re-evaluated per read, so the nav label follows the active locale.\n label: () => t('nav'),\n inject: injected,\n }, SubscriptionsSection))\n\n // The image_generate keyed toolview owns how image calls render inline; its\n // gallery bytes ride the same channel through the injected loader. The\n // framework synthesizes the toolview's own `t` seat from `locale: NS`.\n const toolviewInjected = (): ImageGenerateToolviewInjected => ({ load: createImageLoader(connection.rpc) })\n ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({\n name: 'tool.call.toolview',\n key: 'image_generate',\n locale: NS,\n inject: toolviewInjected,\n }, ImageGenerateToolview))\n\n // The video_generate keyed toolview plays the saved MP4 inline; its bytes\n // ride the same channel's `video` endpoint through the injected loader.\n const videoToolviewInjected = (): VideoGenerateToolviewInjected => ({ loadVideo: createVideoLoader(connection.rpc) })\n ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({\n name: 'tool.call.toolview',\n key: 'video_generate',\n locale: NS,\n inject: videoToolviewInjected,\n }, VideoGenerateToolview))\n\n // The composer Speed toggle (codex fast tier) sits in the right tool row,\n // just left of the model selector; the framework synthesizes its `t` seat\n // from `locale: NS`, and the inject face binds each session's RPC calls.\n ctx.slots.inject('conversation.input.right', () => ctx.slots.register({\n name: 'conversation.input.right',\n id: 'codex-speed',\n order: 0,\n locale: NS,\n inject: (sessionId: SessionId): SpeedSelectInjected => ({\n loadSpeed: createSpeedLoader(connection, sessionId),\n setSpeed: createSpeedSetter(connection, sessionId),\n }),\n }, SpeedSelect))\n\n // The /fast slash command offers the same Standard/Fast choice as a popup.\n // `available` is synchronous and sees only the session id, so the command\n // stays listed everywhere; `options` throws the friendly gate when the\n // session's current model is not a fast-capable codex model (the same\n // in-popup error posture the /model contribution uses for its guards).\n ctx.inject(['commandUi'], (scope) => {\n const command = scope.get('commandUi') as CommandUiContract\n scope.effect(() => command.register({\n name: 'fast',\n description: t('commandFast'),\n available: () => true,\n ui: {\n kind: 'popupSelect',\n options: async (session) => {\n const state = await createSpeedLoader(connection, session.sessionId)()\n if (!state.visible) throw new Error(t('commandFastUnavailable'))\n return ([\n { id: 'standard', label: t('speedStandard'), detail: t('speedStandardDescription') },\n { id: 'fast', label: t('speedFast'), detail: t('speedFastDescription') },\n ] as const).map(option => ({ ...option, active: option.id === state.tier }))\n },\n onSelect: async (option, session) => {\n await createSpeedSetter(connection, session.sessionId)(option.id as 'standard' | 'fast')\n },\n },\n }), 'dsh-plugin-subscriptions: /fast contribution')\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAa,KAAK;CAChB,KAAK;CACL,OAAO;CACP,aAAa;CACb,UAAU;CACV,iBAAiB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L","POLL_INTERVAL_MS","PROVIDERS: readonly { id: SubscriptionProvider; name: string }[]","result: RpcResult<unknown>","fallbackTranslate","text: string","styles: Record<string, CSSProperties>","window","response: StatusResponse","styles","styles: Record<string, CSSProperties>","styles","SUBSCRIPTIONS_AUTH_CHANNEL","PROMPT_MAX_LENGTH","callSubscriptionsAuth","result: RpcResult<unknown>","fallbackTranslate","text: string","derivePrompt","parsed: unknown","prompt: string | undefined","resultText","parts: string[]","images: { attachment: ImageAttachmentRef }[]","styles: Record<string, CSSProperties>","labels: MessageImageLabels","styles","IconSparkle16","result: RpcResult<unknown>","fallbackTranslate","text: string","parsed: unknown","prompt: string | undefined","parts: string[]","styles: Record<string, CSSProperties>","objectUrl: string | undefined","styles","IconSparkle16","TIERS: readonly SpeedTier[]","styles: Record<string, CSSProperties>"],"sources":["../src/client/locales.ts","../src/client/SubscriptionsSection.tsx","../src/client/ImageGallery.tsx","../src/client/ImageGenerateToolview.tsx","../src/client/VideoGenerateToolview.tsx","../src/client/SpeedSelect.tsx","../src/client/index.ts"],"sourcesContent":["/** Copy dictionaries for the Subscriptions settings section. */\n\n/** English strings (the key-set source of truth for this pair). */\nexport const en = {\n nav: 'Subscriptions',\n intro: 'Log a subscription provider in or out. Login opens the provider’s authorization page in a new tab; headless setups can paste the callback URL or code instead.',\n unavailable: 'Connection unavailable; subscription status cannot be loaded.',\n checking: 'Checking…',\n loginInProgress: 'Login in progress…',\n notLoggedIn: 'Not logged in',\n loggedInCount: '{count} account(s) connected',\n accountExpires: 'expires {date}',\n defaultBadge: 'Default',\n setDefault: 'Set as default',\n addAccount: 'Add account',\n addAccountOAuth: 'Browser authorization',\n addAccountKeychain: 'Import Claude Code',\n addAccountHint: 'Browser authorization signs in whichever account the browser currently uses — switch accounts there first (or use an incognito window with the manual code below) to add a different one.',\n login: 'Log in',\n cancel: 'Cancel',\n logout: 'Log out',\n logoutAccountConfirm: 'Log out {account} of {provider}?',\n manualSummary: 'Browser flow not working? Paste the callback URL or code',\n manualPlaceholder: 'Paste the callback URL or code',\n submit: 'Submit',\n loginMissingUrl: 'login answered without an authorizeUrl',\n deviceCodePrompt: 'Enter this code on the GitHub verification page:',\n deviceCodeCopy: 'Copy code',\n deviceCodeCopied: 'Copied',\n deviceCodeOpenPage: 'Open GitHub verification page',\n usageTitle: 'Usage',\n usageRefresh: 'Refresh',\n usageLoading: 'Loading usage…',\n usageEmpty: 'No usage windows reported.',\n usageError: 'Usage lookup failed: {message}',\n usageSession: '5-hour window',\n usageWeekly: 'Weekly',\n usageWindow: 'Window',\n usageResets: 'resets {date}',\n usagePlan: 'Plan: {plan}',\n generating: 'Generating image…',\n image: 'image',\n viewImage: 'View image',\n viewImageNamed: 'View {name}',\n imageLoading: 'Loading…',\n imageLoadFailed: 'Retry',\n imagePreview: 'Image preview',\n imageClose: 'Close',\n generatingVideo: 'Generating video…',\n videoLoading: 'Loading video…',\n videoLoadFailed: 'Video failed to load: {message}',\n speed: 'Speed',\n speedStandard: 'Standard',\n speedStandardDescription: 'Default speed',\n speedFast: 'Fast',\n speedFastDescription: '1.5x speed, more usage',\n commandFast: 'Switch the Codex speed tier (Standard/Fast)',\n commandFastUnavailable: 'The current model has no fast tier; /fast only works on Codex models whose catalog advertises one',\n proxyTitle: 'Proxy',\n proxyStatusNone: 'Not configured — subscription requests go direct.',\n proxyStatusEnabled: 'Enabled · {url}',\n proxyStatusError: 'Config error: {message}',\n proxyConfigure: 'Configure…',\n proxyDialogTitle: 'Proxy settings',\n proxyDialogClose: 'Close',\n proxyEnabled: 'Route subscription requests through a proxy',\n proxyUrl: 'Proxy URL',\n proxyUrlPlaceholder: 'http://localhost:7890',\n proxyUrlHint: 'HTTP or HTTPS proxy only (Clash/mihomo, v2rayN…); socks is not supported.',\n proxyUsername: 'Username (optional)',\n proxyUsernamePlaceholder: 'Proxy username',\n proxyPassword: 'Password',\n proxyPasswordPlaceholder: 'Leave blank to keep the saved password',\n proxyClearPassword: 'Clear the saved password',\n proxyBypass: 'Bypass hosts',\n proxyBypassPlaceholder: '127.0.0.1, localhost, *.example.com',\n proxyBypassHint: 'Comma-separated hostnames that keep going direct.',\n proxyTest: 'Test',\n proxyTesting: 'Testing…',\n proxyTestOk: 'OK · HTTP {status} · {ms} ms',\n proxyTestOkDirect: 'OK (direct, bypassed) · HTTP {status} · {ms} ms',\n proxyTestFail: 'Failed: {message}',\n proxySave: 'Save',\n proxyCancel: 'Cancel',\n proxySaving: 'Saving…',\n proxyLoading: 'Loading proxy settings…',\n proxyLoadFailed: 'Failed to load proxy settings: {message}',\n proxySaved: 'Saved — new requests use the proxy.',\n proxySaveFailed: 'Save failed: {message}',\n proxyNote: 'Applies to token exchange, model APIs, usage lookups, image/video generation and x_search. The OAuth authorization page opens in your browser and follows the browser/system proxy, not this setting.',\n} satisfies Record<string, string>\n\n/** zh strings, one per {@link en} key. */\nexport const zh = {\n nav: '订阅',\n intro: '在此登录或退出订阅服务商。点击登录会在新标签页打开服务商的授权页面;无浏览器环境可改为粘贴回调 URL 或授权码。',\n unavailable: '连接不可用,无法加载订阅状态。',\n checking: '查询中…',\n loginInProgress: '登录中…',\n notLoggedIn: '未登录',\n loggedInCount: '已连接 {count} 个账号',\n accountExpires: '过期时间 {date}',\n defaultBadge: '默认',\n setDefault: '设为默认',\n addAccount: '添加账号',\n addAccountOAuth: '浏览器授权',\n addAccountKeychain: '导入 Claude Code',\n addAccountHint: '浏览器授权以浏览器当前登录的账号为准;要添加不同账号,请先在浏览器里切换账号,或用无痕窗口走下方手动授权码。',\n login: '登录',\n cancel: '取消',\n logout: '退出登录',\n logoutAccountConfirm: '确定退出 {provider} 的账号 {account} 吗?',\n manualSummary: '浏览器流程无法完成?粘贴回调 URL 或授权码',\n manualPlaceholder: '粘贴回调 URL 或授权码',\n submit: '提交',\n loginMissingUrl: 'login 响应缺少 authorizeUrl',\n deviceCodePrompt: '在 GitHub 验证页面输入此验证码:',\n deviceCodeCopy: '复制验证码',\n deviceCodeCopied: '已复制',\n deviceCodeOpenPage: '打开 GitHub 验证页面',\n usageTitle: '用量',\n usageRefresh: '刷新',\n usageLoading: '用量加载中…',\n usageEmpty: '服务商未返回任何用量窗口。',\n usageError: '用量查询失败:{message}',\n usageSession: '5 小时窗口',\n usageWeekly: '每周',\n usageWindow: '窗口',\n usageResets: '{date} 重置',\n usagePlan: '计划:{plan}',\n generating: '正在生成图片…',\n image: '图片',\n viewImage: '查看图片',\n viewImageNamed: '查看 {name}',\n imageLoading: '加载中…',\n imageLoadFailed: '重试',\n imagePreview: '图片预览',\n imageClose: '关闭',\n generatingVideo: '正在生成视频…',\n videoLoading: '视频加载中…',\n videoLoadFailed: '视频加载失败:{message}',\n speed: '速度',\n speedStandard: '标准',\n speedStandardDescription: '默认速度',\n speedFast: '快速',\n speedFastDescription: '约 1.5 倍速度,消耗更多用量',\n commandFast: '切换 Codex 速度档(标准/快速)',\n commandFastUnavailable: '当前模型不支持快速档;/fast 仅对目录声明了 fast tier 的 Codex 模型可用',\n proxyTitle: '代理',\n proxyStatusNone: '未配置 —— 订阅请求直连。',\n proxyStatusEnabled: '已启用 · {url}',\n proxyStatusError: '配置错误:{message}',\n proxyConfigure: '配置…',\n proxyDialogTitle: '代理设置',\n proxyDialogClose: '关闭',\n proxyEnabled: '让订阅相关请求走代理',\n proxyUrl: '代理地址',\n proxyUrlPlaceholder: 'http://localhost:7890',\n proxyUrlHint: '仅支持 HTTP/HTTPS 代理(Clash/mihomo、v2rayN 等);不支持 socks。',\n proxyUsername: '用户名(可选)',\n proxyUsernamePlaceholder: '代理用户名',\n proxyPassword: '密码',\n proxyPasswordPlaceholder: '留空则保留已保存的密码',\n proxyClearPassword: '清除已保存的密码',\n proxyBypass: '绕过主机',\n proxyBypassPlaceholder: '127.0.0.1, localhost, *.example.com',\n proxyBypassHint: '逗号分隔的主机名,这些主机保持直连。',\n proxyTest: '测试',\n proxyTesting: '测试中…',\n proxyTestOk: '成功 · HTTP {status} · {ms} ms',\n proxyTestOkDirect: '成功(直连,已绕过)· HTTP {status} · {ms} ms',\n proxyTestFail: '失败:{message}',\n proxySave: '保存',\n proxyCancel: '取消',\n proxySaving: '保存中…',\n proxyLoading: '代理设置加载中…',\n proxyLoadFailed: '代理设置加载失败:{message}',\n proxySaved: '已保存 —— 后续请求将走代理。',\n proxySaveFailed: '保存失败:{message}',\n proxyNote: '作用于 token 交换、模型 API、用量查询、图片/视频生成与 x_search。OAuth 授权页在浏览器中打开,走的是浏览器/系统代理,不受此设置影响。',\n} satisfies Record<keyof typeof en, string>\n\n/** The Subscriptions namespace key union (en is the key-set source of truth). */\nexport type SubscriptionsKey = keyof typeof en\n","/**\n * Subscriptions settings section: one card per subscription provider with an\n * OAuth login/logout flow driven by the node half's `/subscriptions-auth` RPC\n * channel. Login state lives server-side; the page polls `status` only while\n * a login attempt is busy, so an idle page never polls. All state is local\n * React state — the page has no store.\n *\n * Every color resolves through a `--dsw-alias-*` design token (the ui-theme\n * design-platform.css values flip under `body[data-ds-dark-theme]`), and\n * every user-visible string goes through the locale-bound `t` of the\n * 'settings.subscriptions' namespace. Buttons and inputs take the\n * ModelsSection vocabulary minus hover rules, which inline styles cannot\n * express.\n */\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Poll cadence while a provider login attempt is busy. */\nconst POLL_INTERVAL_MS = 2000\n\n/** Subscription provider ids, fixed by the node half's OAuth adapters. */\nexport type SubscriptionProvider = 'codex' | 'claude' | 'grok' | 'copilot'\n\n/** One logged-in account as answered by the `status` endpoint. */\nexport interface AccountStatus {\n key: string\n account?: string\n expiresAt?: number\n plan?: string\n isDefault: boolean\n}\n\n/** One provider's login state as answered by the `status` endpoint. */\nexport interface ProviderStatus {\n busy: boolean\n accounts: AccountStatus[]\n detail?: string\n}\n\n/** `status` endpoint value: the node half owns this shape. */\ninterface StatusResponse {\n providers: Record<SubscriptionProvider, ProviderStatus>\n}\n\n/** One rate-limit window as answered by the `usage` endpoint. */\nexport interface UsageWindow {\n kind: 'session' | 'weekly' | 'other'\n scope?: string\n usedPercent: number\n resetsAt?: number\n}\n\n/** `usage` endpoint value: the node half owns this shape. */\nexport interface ProviderUsage {\n supported: boolean\n windows?: UsageWindow[]\n plan?: string\n}\n\n/** `proxyGet` endpoint value: the node half owns this shape (no secrets). */\nexport interface ProxyConfigView {\n enabled: boolean\n url: string\n username?: string\n passwordSet: boolean\n bypass: string[]\n error?: string\n}\n\n/** `proxyTest` endpoint value. */\nexport interface ProxyTestResult {\n ok: boolean\n viaProxy: boolean\n status?: number\n latencyMs?: number\n error?: string\n}\n\n/** `login` endpoint value: the URL the user completes OAuth at. */\ninterface LoginResponse {\n authorizeUrl: string\n /** Device-flow providers (copilot): the code the user types at authorizeUrl. */\n userCode?: string\n}\n\n/** Injected dependencies of {@link SubscriptionsSection} (slot `inject`). */\nexport interface SubscriptionsSectionInjected {\n /** Generic logical-RPC caller over the Connection transport. */\n rpc: ConnectionHandle['rpc']\n /** Section copy: translate a 'settings.subscriptions' key with `{name}` template params. */\n t: (key: SubscriptionsKey, params?: Record<string, unknown>) => string\n}\n\n/**\n * Props delivered by the slot outlet: the inject face spread flat (the\n * renderer erases the share boundary at the render call).\n */\nexport type SubscriptionsSectionProps = Partial<SubscriptionsSectionInjected>\n\n/** Card display metadata, in page order (names are brand names, not translated). */\nconst PROVIDERS: readonly { id: SubscriptionProvider; name: string }[] = [\n { id: 'codex', name: 'Codex (ChatGPT)' },\n { id: 'claude', name: 'Claude' },\n { id: 'grok', name: 'Grok (X Premium)' },\n { id: 'copilot', name: 'GitHub Copilot' },\n]\n\n/** Business error returned by the `/subscriptions-auth` channel (error branch message). */\nclass SubscriptionsAuthError extends Error {}\n\n/**\n * Call one `/subscriptions-auth` endpoint and unwrap the business result.\n * Shared by the settings section and the composer Speed toggle.\n * @param rpc - Connection RPC caller.\n * @param endpoint - channel-relative endpoint.\n * @param payload - channel-owned request payload.\n * @returns the success value, cast by the caller to the endpoint's shape.\n */\nexport async function callSubscriptionsAuth<T>(rpc: ConnectionHandle['rpc'], endpoint: string, payload: unknown): Promise<T> {\n let result: RpcResult<unknown>\n try {\n result = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, endpoint, payload)\n } catch (error) {\n // The transport rejected rather than answering; surface the same way.\n throw new SubscriptionsAuthError(error instanceof Error ? error.message : String(error))\n }\n if (!result.ok) throw new SubscriptionsAuthError(result.error.message)\n return result.value as T\n}\n\n/** Human text of an action failure, SubscriptionsAuthError or not. */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error)\n}\n\n/** Copy a keyed map without the entries whose key is not in `live`. */\nfunction dropStale<T>(map: Record<string, T>, live: ReadonlySet<string>): Record<string, T> {\n const stale = Object.keys(map).filter(key => !live.has(key))\n if (stale.length === 0) return map\n const next = { ...map }\n for (const key of stale) delete next[key]\n return next\n}\n\n/**\n * English-dictionary fallback for a missing inject `t` (standalone renders);\n * the slot inject always supplies the locale-bound one.\n * @param key - dictionary key.\n * @param params - `{name}` template params.\n * @returns the template with params substituted.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\nconst styles: Record<string, CSSProperties> = {\n section: {\n display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560,\n color: 'var(--dsw-alias-label-primary)',\n },\n intro: { margin: 0, color: 'var(--dsw-alias-label-tertiary)', fontSize: 14, lineHeight: '22px' },\n card: {\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 12,\n padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 6,\n },\n proxyCard: {\n padding: '12px 14px', display: 'flex', flexDirection: 'column', gap: 6,\n },\n separator: { borderTop: '1px solid var(--dsw-alias-border-l2)' },\n cardHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n dot: { width: 8, height: 8, borderRadius: '50%', flexShrink: 0 },\n name: { fontWeight: 500, fontSize: 14, lineHeight: '22px', color: 'var(--dsw-alias-label-primary)' },\n statusLine: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n errorLine: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n actions: { display: 'flex', gap: 8, marginTop: 4, alignItems: 'center', flexWrap: 'wrap' },\n button: {\n boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',\n height: 28, padding: '0 10px', borderRadius: 14,\n border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',\n color: 'var(--dsw-alias-label-primary)', font: 'inherit', fontSize: 12, lineHeight: '18px',\n cursor: 'pointer',\n },\n usage: {\n display: 'flex', flexDirection: 'column', gap: 6, marginTop: 4,\n borderTop: '1px solid var(--dsw-alias-border-l2)', paddingTop: 8,\n },\n usageHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n usageTitle: { fontSize: 12, lineHeight: '18px', fontWeight: 500, color: 'var(--dsw-alias-label-secondary)' },\n usagePlan: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n usageRefresh: {\n boxSizing: 'border-box', display: 'inline-flex', alignItems: 'center', justifyContent: 'center',\n height: 22, padding: '0 8px', borderRadius: 11, marginLeft: 'auto',\n border: '1px solid var(--dsw-alias-border-l2)', background: 'transparent',\n color: 'var(--dsw-alias-label-secondary)', font: 'inherit', fontSize: 12, lineHeight: '18px',\n cursor: 'pointer',\n },\n usageRow: { display: 'flex', flexDirection: 'column', gap: 3 },\n usageMeta: {\n display: 'flex', justifyContent: 'space-between', gap: 8,\n fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)',\n },\n accountRow: {\n display: 'flex', flexDirection: 'column', gap: 6,\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '8px 10px', marginTop: 4,\n },\n accountHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n accountName: { fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)', userSelect: 'all' },\n starButton: {\n border: 'none', background: 'transparent', padding: 0,\n font: 'inherit', fontSize: 14, lineHeight: '20px', cursor: 'pointer',\n color: 'var(--dsw-alias-state-warn-label)',\n },\n usageTrack: {\n height: 6, borderRadius: 3, overflow: 'hidden',\n background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l2)',\n },\n usageFill: { height: '100%', borderRadius: 3 },\n manual: { marginTop: 4, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },\n manualRow: { display: 'flex', gap: 8, marginTop: 6 },\n manualInput: {\n flex: 1, height: 32, boxSizing: 'border-box',\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '0 10px', font: 'inherit', fontSize: 14, lineHeight: '22px',\n background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)',\n },\n deviceCode: {\n marginTop: 4, display: 'flex', flexDirection: 'column', gap: 6,\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '10px 12px', background: 'var(--dsw-alias-bg-layer-1)',\n },\n deviceCodeText: {\n fontFamily: 'monospace', fontSize: 18, lineHeight: '24px', letterSpacing: 2,\n color: 'var(--dsw-alias-label-primary)', userSelect: 'all',\n },\n proxyField: { display: 'flex', flexDirection: 'column', gap: 4 },\n proxyLabel: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)' },\n proxyInput: {\n height: 32, width: '100%', boxSizing: 'border-box',\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n padding: '0 10px', font: 'inherit', fontSize: 14, lineHeight: '22px',\n background: 'var(--dsw-alias-bg-layer-1)', color: 'var(--dsw-alias-label-primary)',\n },\n proxyHint: {\n margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)',\n },\n proxyCheck: {\n display: 'flex', alignItems: 'center', gap: 8,\n fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)', cursor: 'pointer',\n },\n proxyMessage: { margin: 0, fontSize: 12, lineHeight: '18px' },\n proxyActions: { display: 'flex', gap: 8, alignItems: 'center', justifyContent: 'flex-end', marginTop: 2 },\n modalOverlay: {\n position: 'fixed', inset: 0, zIndex: 1000,\n display: 'flex', alignItems: 'center', justifyContent: 'center', padding: 16,\n background: 'rgba(0, 0, 0, 0.45)',\n },\n modal: {\n width: 460, maxWidth: '100%', maxHeight: '90vh', overflowY: 'auto',\n boxSizing: 'border-box', display: 'flex', flexDirection: 'column', gap: 12,\n padding: '16px 18px', borderRadius: 12,\n background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l2)',\n },\n modalHeader: { display: 'flex', alignItems: 'center', gap: 8 },\n modalTitle: { fontWeight: 600, fontSize: 15, lineHeight: '22px', color: 'var(--dsw-alias-label-primary)' },\n}\n\n/** Status dot color for one provider state. */\nfunction dotColor(status: ProviderStatus | undefined): string {\n if (status?.busy === true) return 'var(--dsw-alias-state-warn-label)'\n if ((status?.accounts.length ?? 0) > 0) return 'var(--dsw-alias-state-success-primary)'\n return 'var(--dsw-alias-label-dimmed)'\n}\n\n/**\n * One-line status text for one provider state.\n * @param t - section translate.\n * @param status - the provider's last reported state.\n * @returns the localized status line.\n */\nfunction statusText(t: SubscriptionsSectionInjected['t'], status: ProviderStatus | undefined): string {\n if (status === undefined) return t('checking')\n if (status.busy) return t('loginInProgress')\n if (status.accounts.length > 0) return t('loggedInCount', { count: status.accounts.length })\n return t('notLoggedIn')\n}\n\n/**\n * Localized label of one usage window (kind, plus the model scope when named).\n * @param t - section translate.\n * @param window - the reported window.\n * @returns e.g. \"5-hour window\" or \"Weekly · Opus\".\n */\nfunction usageWindowLabel(t: SubscriptionsSectionInjected['t'], window: UsageWindow): string {\n const base = window.kind === 'session'\n ? t('usageSession')\n : window.kind === 'weekly' ? t('usageWeekly') : t('usageWindow')\n return window.scope !== undefined && window.scope !== '' ? `${base} · ${window.scope}` : base\n}\n\n/** Bar fill color: success normally, warn from 80%, error from 95%. */\nfunction usageBarColor(usedPercent: number): string {\n if (usedPercent >= 95) return 'var(--dsw-alias-state-error-primary)'\n if (usedPercent >= 80) return 'var(--dsw-alias-state-warn-label)'\n return 'var(--dsw-alias-state-success-primary)'\n}\n\n/** One-line status text of the proxy config card. */\nfunction proxyStatusText(\n t: SubscriptionsSectionInjected['t'],\n proxy: ProxyConfigView | undefined,\n loadError: string | undefined,\n): string {\n if (loadError !== undefined) return t('proxyLoadFailed', { message: loadError })\n if (proxy === undefined) return t('proxyLoading')\n if (proxy.error !== undefined) return t('proxyStatusError', { message: proxy.error })\n if (proxy.enabled) return t('proxyStatusEnabled', { url: proxy.url })\n return t('proxyStatusNone')\n}\n\n/** Feedback-line color of the proxy dialog. */\nfunction messageColor(tone: 'success' | 'error'): string {\n return tone === 'error'\n ? 'var(--dsw-alias-state-error-primary)'\n : 'var(--dsw-alias-state-success-primary)'\n}\n\n/**\n * The Subscriptions settings page component.\n * @param props - the slot inject face ({@link SubscriptionsSectionInjected}).\n * @returns the section body, or a notice while the RPC face is absent.\n */\nexport function SubscriptionsSection(props: SubscriptionsSectionProps) {\n const { rpc } = props\n const t = props.t ?? fallbackTranslate\n const [statuses, setStatuses] = useState<Partial<Record<SubscriptionProvider, ProviderStatus>>>({})\n const [errors, setErrors] = useState<Partial<Record<SubscriptionProvider, string>>>({})\n const [manualDrafts, setManualDrafts] = useState<Record<SubscriptionProvider, string>>({\n codex: '', claude: '', grok: '', copilot: '',\n })\n /** Pending device-flow codes (copilot), shown while the attempt polls. */\n const [deviceCodes, setDeviceCodes] = useState<Partial<Record<SubscriptionProvider, { userCode: string; verificationUrl: string }>>>({})\n const [copiedCode, setCopiedCode] = useState<SubscriptionProvider | undefined>(undefined)\n /** Usage snapshots keyed `${provider}:${accountKey}` — every account tracks its own windows. */\n const [usages, setUsages] = useState<Record<string, ProviderUsage>>({})\n const [usageErrors, setUsageErrors] = useState<Record<string, string>>({})\n const [usageLoading, setUsageLoading] = useState<Record<string, boolean>>({})\n const mountedRef = useRef(true)\n const pollersRef = useRef(new Map<SubscriptionProvider, ReturnType<typeof setInterval>>())\n /** Accounts with a `usage` call in flight; guards the auto-fetch effect against re-entry. */\n const usageInflightRef = useRef(new Set<string>())\n /** Proxy config as last answered by `proxyGet`/`proxySet`. */\n const [proxy, setProxy] = useState<ProxyConfigView | undefined>(undefined)\n const [proxyLoadError, setProxyLoadError] = useState<string | undefined>(undefined)\n /** Proxy dialog state (draft fields; the password never pre-fills). */\n const [proxyOpen, setProxyOpen] = useState(false)\n const [proxyEnabled, setProxyEnabled] = useState(false)\n const [proxyUrl, setProxyUrl] = useState('')\n const [proxyUsername, setProxyUsername] = useState('')\n const [proxyPassword, setProxyPassword] = useState('')\n const [proxyClearPassword, setProxyClearPassword] = useState(false)\n const [proxyBypass, setProxyBypass] = useState('')\n const [proxySaving, setProxySaving] = useState(false)\n const [proxyTesting, setProxyTesting] = useState(false)\n const [proxyMessage, setProxyMessage] = useState<{ tone: 'success' | 'error'; text: string } | undefined>(undefined)\n const [proxyTestResult, setProxyTestResult] = useState<ProxyTestResult | undefined>(undefined)\n\n const setProviderError = useCallback((provider: SubscriptionProvider, message: string | undefined): void => {\n if (!mountedRef.current) return\n setErrors((prev) => {\n const next = { ...prev }\n if (message === undefined) delete next[provider]\n else next[provider] = message\n return next\n })\n }, [])\n\n const stopPolling = useCallback((provider: SubscriptionProvider): void => {\n const poller = pollersRef.current.get(provider)\n if (poller !== undefined) {\n clearInterval(poller)\n pollersRef.current.delete(provider)\n }\n }, [])\n\n /** Refetch every provider's status; stop a provider's poller once its attempt settles. */\n const refresh = useCallback(async (): Promise<void> => {\n if (rpc === undefined) return\n let response: StatusResponse\n try {\n response = await callSubscriptionsAuth<StatusResponse>(rpc, 'status', {})\n } catch {\n // A failed poll must not kill the page; busy providers keep polling and\n // the action paths report their own errors.\n return\n }\n if (!mountedRef.current) return\n setStatuses(response.providers)\n for (const { id } of PROVIDERS) {\n const status = response.providers[id]\n if (status.accounts.length > 0 || !status.busy) {\n stopPolling(id)\n // The attempt settled (success, timeout, or cancel): drop the code card.\n setDeviceCodes((prev) => {\n if (prev[id] === undefined) return prev\n const next = { ...prev }\n delete next[id]\n return next\n })\n }\n }\n }, [rpc, stopPolling])\n\n const startPolling = useCallback((provider: SubscriptionProvider): void => {\n if (pollersRef.current.has(provider)) return\n pollersRef.current.set(provider, setInterval(() => { void refresh() }, POLL_INTERVAL_MS))\n }, [refresh])\n\n // Initial load; every busy provider (e.g. an attempt started before a page\n // reload) resumes polling. Teardown clears pollers and the mounted guard.\n useEffect(() => {\n mountedRef.current = true\n void refresh().then(() => {\n if (!mountedRef.current) return\n setStatuses((current) => {\n for (const { id } of PROVIDERS) {\n if (current[id]?.busy === true) startPolling(id)\n }\n return current\n })\n })\n return () => {\n mountedRef.current = false\n for (const poller of pollersRef.current.values()) clearInterval(poller)\n pollersRef.current.clear()\n }\n }, [refresh, startPolling])\n\n const loadUsage = useCallback(async (provider: SubscriptionProvider, account: string): Promise<void> => {\n const key = `${provider}:${account}`\n if (rpc === undefined || usageInflightRef.current.has(key)) return\n usageInflightRef.current.add(key)\n setUsageLoading(prev => ({ ...prev, [key]: true }))\n try {\n const usage = await callSubscriptionsAuth<ProviderUsage>(rpc, 'usage', { provider, account })\n if (!mountedRef.current) return\n setUsages(prev => ({ ...prev, [key]: usage }))\n setUsageErrors((prev) => {\n const next = { ...prev }\n delete next[key]\n return next\n })\n } catch (error) {\n if (mountedRef.current) setUsageErrors(prev => ({ ...prev, [key]: messageOf(error) }))\n } finally {\n usageInflightRef.current.delete(key)\n if (mountedRef.current) setUsageLoading(prev => ({ ...prev, [key]: false }))\n }\n }, [rpc])\n\n // Fetch usage once an account is logged in; drop the snapshots of accounts\n // that vanished so a re-login refetches. A failed lookup does not auto-retry\n // — the per-account Refresh button is the retry path.\n useEffect(() => {\n const live = new Set<string>()\n for (const { id } of PROVIDERS) {\n for (const account of statuses[id]?.accounts ?? []) {\n const key = `${id}:${account.key}`\n live.add(key)\n if (usages[key] === undefined && usageErrors[key] === undefined) void loadUsage(id, account.key)\n }\n }\n setUsages(prev => dropStale(prev, live))\n setUsageErrors(prev => dropStale(prev, live))\n }, [statuses, usages, usageErrors, loadUsage])\n\n const login = useCallback(async (provider: SubscriptionProvider, method?: 'oauth' | 'keychain'): Promise<void> => {\n if (rpc === undefined) return\n setProviderError(provider, undefined)\n try {\n const response = await callSubscriptionsAuth<LoginResponse>(rpc, 'login', {\n provider,\n ...method === undefined ? {} : { method },\n })\n if (typeof response.authorizeUrl === 'string' && response.authorizeUrl === '') {\n // Instant login (e.g. imported from Claude Code credentials)\n await refresh()\n return\n }\n if (typeof response.authorizeUrl !== 'string') {\n throw new SubscriptionsAuthError(t('loginMissingUrl'))\n }\n if (!mountedRef.current) return\n // Optimistic busy so Cancel and the manual fallback appear before the first poll tick.\n setStatuses(prev => ({\n ...prev,\n [provider]: { accounts: prev[provider]?.accounts ?? [], ...prev[provider], busy: true },\n }))\n if (typeof response.userCode === 'string' && response.userCode.length > 0) {\n // Device flow: show the code card instead of opening the page blind —\n // the user copies the code first, then opens the verification page.\n setDeviceCodes(prev => ({ ...prev, [provider]: { userCode: response.userCode as string, verificationUrl: response.authorizeUrl } }))\n } else {\n window.open(response.authorizeUrl, '_blank', 'noopener')\n }\n startPolling(provider)\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n }, [rpc, t, setProviderError, startPolling])\n\n const cancel = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined) return\n stopPolling(provider)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'cancel', { provider })\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, stopPolling, setProviderError, refresh])\n\n const submitManual = useCallback(async (provider: SubscriptionProvider): Promise<void> => {\n if (rpc === undefined) return\n const input = manualDrafts[provider].trim()\n if (input === '') return\n setProviderError(provider, undefined)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'manual', { provider, input })\n if (mountedRef.current) setManualDrafts(prev => ({ ...prev, [provider]: '' }))\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, manualDrafts, setProviderError, refresh])\n\n const logout = useCallback(async (provider: SubscriptionProvider, account: string, display: string, name: string): Promise<void> => {\n if (rpc === undefined) return\n if (!window.confirm(t('logoutAccountConfirm', { provider: name, account: display }))) return\n setProviderError(provider, undefined)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'logout', { provider, account })\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, t, setProviderError, refresh])\n\n const setDefault = useCallback(async (provider: SubscriptionProvider, account: string): Promise<void> => {\n if (rpc === undefined) return\n setProviderError(provider, undefined)\n try {\n await callSubscriptionsAuth<{ ok: true }>(rpc, 'setDefault', { provider, account })\n } catch (error) {\n setProviderError(provider, messageOf(error))\n }\n await refresh()\n }, [rpc, setProviderError, refresh])\n\n const copyDeviceCode = useCallback((provider: SubscriptionProvider, userCode: string): void => {\n void navigator.clipboard?.writeText(userCode).then(() => {\n if (!mountedRef.current) return\n setCopiedCode(provider)\n setTimeout(() => {\n if (mountedRef.current) {\n setCopiedCode(current => current === provider ? undefined : current)\n }\n }, 1500)\n }).catch(() => undefined)\n }, [])\n\n // Proxy configuration: load once on mount; the dialog drives proxySet/proxyTest.\n useEffect(() => {\n if (rpc === undefined) return\n let alive = true\n void callSubscriptionsAuth<ProxyConfigView>(rpc, 'proxyGet', {}).then((view) => {\n if (!alive) return\n setProxy(view)\n setProxyLoadError(undefined)\n }).catch((error) => {\n if (alive) setProxyLoadError(messageOf(error))\n })\n return () => { alive = false }\n }, [rpc])\n\n useEffect(() => {\n if (!proxyOpen) return\n const onKey = (event: KeyboardEvent): void => {\n if (event.key === 'Escape') setProxyOpen(false)\n }\n window.addEventListener('keydown', onKey)\n return () => window.removeEventListener('keydown', onKey)\n }, [proxyOpen])\n\n const openProxyDialog = useCallback((): void => {\n if (proxy === undefined) return\n setProxyEnabled(proxy.enabled)\n setProxyUrl(proxy.url)\n setProxyUsername(proxy.username ?? '')\n setProxyPassword('')\n setProxyClearPassword(false)\n setProxyBypass(proxy.bypass.join(', '))\n setProxyMessage(undefined)\n setProxyTestResult(undefined)\n setProxyOpen(true)\n }, [proxy])\n\n const saveProxy = useCallback(async (): Promise<void> => {\n if (rpc === undefined) return\n setProxySaving(true)\n setProxyMessage(undefined)\n try {\n const view = await callSubscriptionsAuth<ProxyConfigView>(rpc, 'proxySet', {\n enabled: proxyEnabled,\n url: proxyUrl.trim(),\n username: proxyUsername,\n ...proxyClearPassword ? { password: null } : proxyPassword !== '' ? { password: proxyPassword } : {},\n bypass: proxyBypass.split(/[,\\n]/).map(entry => entry.trim()).filter(entry => entry !== ''),\n })\n setProxy(view)\n setProxyLoadError(undefined)\n setProxyMessage({ tone: 'success', text: t('proxySaved') })\n setProxyOpen(false)\n } catch (error) {\n setProxyMessage({ tone: 'error', text: t('proxySaveFailed', { message: messageOf(error) }) })\n } finally {\n setProxySaving(false)\n }\n }, [rpc, proxyEnabled, proxyUrl, proxyUsername, proxyPassword, proxyClearPassword, proxyBypass, t])\n\n const testProxy = useCallback(async (): Promise<void> => {\n if (rpc === undefined || proxyTesting) return\n setProxyTesting(true)\n setProxyTestResult(undefined)\n try {\n // Test the dialog's current inputs (they do not need to be saved first);\n // the host builds a throwaway agent for the probe.\n setProxyTestResult(await callSubscriptionsAuth<ProxyTestResult>(rpc, 'proxyTest', {\n proxy: {\n url: proxyUrl.trim(),\n ...proxyUsername.trim() !== '' ? { username: proxyUsername.trim() } : {},\n ...proxyPassword !== '' ? { password: proxyPassword } : {},\n },\n }))\n } catch (error) {\n setProxyTestResult({ ok: false, viaProxy: false, error: messageOf(error) })\n } finally {\n setProxyTesting(false)\n }\n }, [rpc, proxyTesting, proxyUrl, proxyUsername, proxyPassword])\n\n if (rpc === undefined) {\n return <p style={styles.intro}>{t('unavailable')}</p>\n }\n\n return (\n <div style={styles.section}>\n <p style={styles.intro}>{t('intro')}</p>\n <div style={styles.proxyCard}>\n <div style={styles.cardHeader}>\n <span style={{\n ...styles.dot,\n background: proxy?.enabled === true\n ? 'var(--dsw-alias-state-success-primary)'\n : 'var(--dsw-alias-label-dimmed)',\n }} />\n <span style={styles.name}>{t('proxyTitle')}</span>\n <button\n type=\"button\"\n style={{ ...styles.button, marginLeft: 'auto', flexShrink: 0 }}\n onClick={openProxyDialog}\n >\n {t('proxyConfigure')}\n </button>\n </div>\n <p style={styles.statusLine}>{proxyStatusText(t, proxy, proxyLoadError)}</p>\n </div>\n <div style={styles.separator} />\n {PROVIDERS.map(({ id, name }) => {\n const status = statuses[id]\n const busy = status?.busy === true\n const deviceCode = deviceCodes[id]\n const accounts = status?.accounts ?? []\n return (\n <div key={id} style={styles.card}>\n <div style={styles.cardHeader}>\n <span style={{ ...styles.dot, background: dotColor(status) }} />\n <span style={styles.name}>{name}</span>\n </div>\n <p style={styles.statusLine}>{statusText(t, status)}</p>\n {status?.detail !== undefined && status.detail !== '' && (\n <p style={styles.statusLine}>{status.detail}</p>\n )}\n {errors[id] !== undefined && <p style={styles.errorLine}>{errors[id]}</p>}\n {accounts.map((account) => {\n const usageKey = `${id}:${account.key}`\n const usage = usages[usageKey]\n const usageError = usageErrors[usageKey]\n const display = account.account ?? account.key\n // Providers without a usage endpoint answer supported:false — no block.\n const showUsage = usage?.supported !== false\n && (usage !== undefined || usageError !== undefined || usageLoading[usageKey] === true)\n return (\n <div key={account.key} style={styles.accountRow}>\n <div style={styles.accountHeader}>\n <button\n type=\"button\"\n style={styles.starButton}\n title={account.isDefault ? t('defaultBadge') : t('setDefault')}\n onClick={() => {\n if (!account.isDefault) void setDefault(id, account.key)\n }}\n >\n {account.isDefault ? '★' : '☆'}\n </button>\n <span style={styles.accountName}>{display}</span>\n {account.plan !== undefined && (\n <span style={styles.usagePlan}>{account.plan}</span>\n )}\n {account.expiresAt !== undefined && (\n <span style={styles.statusLine}>\n {t('accountExpires', { date: new Date(account.expiresAt).toLocaleString() })}\n </span>\n )}\n <button\n type=\"button\"\n style={{ ...styles.button, marginLeft: 'auto', flexShrink: 0 }}\n onClick={() => { void logout(id, account.key, display, name) }}\n >\n {t('logout')}\n </button>\n </div>\n {showUsage && (\n <div style={styles.usage}>\n <div style={styles.usageHeader}>\n <span style={styles.usageTitle}>{t('usageTitle')}</span>\n {usage?.plan !== undefined && (\n <span style={styles.usagePlan}>{t('usagePlan', { plan: usage.plan })}</span>\n )}\n <button\n type=\"button\"\n style={{ ...styles.usageRefresh, ...usageLoading[usageKey] === true ? { opacity: 0.5, cursor: 'default' } : {} }}\n disabled={usageLoading[usageKey] === true}\n onClick={() => { void loadUsage(id, account.key) }}\n >\n {t('usageRefresh')}\n </button>\n </div>\n {usage === undefined && usageError === undefined && (\n <p style={styles.statusLine}>{t('usageLoading')}</p>\n )}\n {usageError !== undefined && (\n <p style={styles.errorLine}>{t('usageError', { message: usageError })}</p>\n )}\n {usage?.windows !== undefined && usage.windows.length === 0 && (\n <p style={styles.statusLine}>{t('usageEmpty')}</p>\n )}\n {(usage?.windows ?? []).map((window, index) => {\n const percent = Math.min(100, Math.max(0, window.usedPercent))\n return (\n <div key={index} style={styles.usageRow}>\n <div style={styles.usageMeta}>\n <span>{usageWindowLabel(t, window)}</span>\n <span>\n {`${String(Math.round(percent))}%`}\n {window.resetsAt !== undefined\n && ` · ${t('usageResets', { date: new Date(window.resetsAt).toLocaleString() })}`}\n </span>\n </div>\n <div style={styles.usageTrack}>\n <div style={{ ...styles.usageFill, width: `${String(percent)}%`, background: usageBarColor(percent) }} />\n </div>\n </div>\n )\n })}\n </div>\n )}\n </div>\n )\n })}\n <div style={styles.actions}>\n {!busy && accounts.length === 0 && (\n <button type=\"button\" style={styles.button} onClick={() => { void login(id) }}>\n {t('login')}\n </button>\n )}\n {!busy && accounts.length > 0 && id === 'claude' && (\n <>\n <button type=\"button\" style={styles.button} onClick={() => { void login(id, 'oauth') }}>\n {t('addAccountOAuth')}\n </button>\n <button type=\"button\" style={styles.button} onClick={() => { void login(id, 'keychain') }}>\n {t('addAccountKeychain')}\n </button>\n </>\n )}\n {!busy && accounts.length > 0 && id !== 'claude' && (\n <button type=\"button\" style={styles.button} onClick={() => { void login(id) }}>\n {t('addAccount')}\n </button>\n )}\n {busy && (\n <button type=\"button\" style={styles.button} onClick={() => { void cancel(id) }}>\n {t('cancel')}\n </button>\n )}\n </div>\n {!busy && accounts.length > 0 && (\n <p style={styles.statusLine}>{t('addAccountHint')}</p>\n )}\n {busy && deviceCode !== undefined && (\n <div style={styles.deviceCode}>\n <span style={styles.statusLine}>{t('deviceCodePrompt')}</span>\n <span style={styles.deviceCodeText}>{deviceCode.userCode}</span>\n <div style={styles.actions}>\n <button type=\"button\" style={styles.button} onClick={() => { copyDeviceCode(id, deviceCode.userCode) }}>\n {copiedCode === id ? t('deviceCodeCopied') : t('deviceCodeCopy')}\n </button>\n <button\n type=\"button\"\n style={styles.button}\n onClick={() => { window.open(deviceCode.verificationUrl, '_blank', 'noopener') }}\n >\n {t('deviceCodeOpenPage')}\n </button>\n </div>\n </div>\n )}\n {busy && deviceCode === undefined && (\n <details style={styles.manual}>\n <summary>{t('manualSummary')}</summary>\n <div style={styles.manualRow}>\n <input\n style={styles.manualInput}\n value={manualDrafts[id]}\n placeholder={t('manualPlaceholder')}\n onChange={event => setManualDrafts(prev => ({ ...prev, [id]: event.target.value }))}\n />\n <button type=\"button\" style={styles.button} onClick={() => { void submitManual(id) }}>\n {t('submit')}\n </button>\n </div>\n </details>\n )}\n </div>\n )\n })}\n {proxyOpen && (\n <div style={styles.modalOverlay} onClick={() => setProxyOpen(false)}>\n <div style={styles.modal} onClick={event => event.stopPropagation()}>\n <div style={styles.modalHeader}>\n <span style={styles.modalTitle}>{t('proxyDialogTitle')}</span>\n <button type=\"button\" style={{ ...styles.button, marginLeft: 'auto' }} onClick={() => setProxyOpen(false)}>\n {t('proxyDialogClose')}\n </button>\n </div>\n <label style={styles.proxyCheck}>\n <input type=\"checkbox\" checked={proxyEnabled} onChange={event => setProxyEnabled(event.target.checked)} />\n <span>{t('proxyEnabled')}</span>\n </label>\n <label style={styles.proxyField}>\n <span style={styles.proxyLabel}>{t('proxyUrl')}</span>\n <input\n style={styles.proxyInput}\n value={proxyUrl}\n placeholder={t('proxyUrlPlaceholder')}\n onChange={event => setProxyUrl(event.target.value)}\n />\n <p style={styles.proxyHint}>{t('proxyUrlHint')}</p>\n </label>\n <label style={styles.proxyField}>\n <span style={styles.proxyLabel}>{t('proxyUsername')}</span>\n <input\n style={styles.proxyInput}\n value={proxyUsername}\n placeholder={t('proxyUsernamePlaceholder')}\n onChange={event => setProxyUsername(event.target.value)}\n />\n </label>\n <div style={styles.proxyField}>\n <span style={styles.proxyLabel}>{t('proxyPassword')}</span>\n <input\n type=\"password\"\n style={styles.proxyInput}\n value={proxyPassword}\n placeholder={t('proxyPasswordPlaceholder')}\n onChange={event => setProxyPassword(event.target.value)}\n />\n <label style={styles.proxyCheck}>\n <input\n type=\"checkbox\"\n checked={proxyClearPassword}\n onChange={event => setProxyClearPassword(event.target.checked)}\n />\n <span>{t('proxyClearPassword')}</span>\n </label>\n </div>\n <label style={styles.proxyField}>\n <span style={styles.proxyLabel}>{t('proxyBypass')}</span>\n <input\n style={styles.proxyInput}\n value={proxyBypass}\n placeholder={t('proxyBypassPlaceholder')}\n onChange={event => setProxyBypass(event.target.value)}\n />\n <p style={styles.proxyHint}>{t('proxyBypassHint')}</p>\n </label>\n <p style={styles.proxyHint}>{t('proxyNote')}</p>\n {proxyMessage !== undefined && (\n <p style={{ ...styles.proxyMessage, color: messageColor(proxyMessage.tone) }}>{proxyMessage.text}</p>\n )}\n {proxyTestResult !== undefined && (\n <p style={{\n ...styles.proxyMessage,\n color: proxyTestResult.ok\n ? 'var(--dsw-alias-state-success-primary)'\n : 'var(--dsw-alias-state-error-primary)',\n }}>\n {proxyTestResult.ok\n ? (proxyTestResult.viaProxy\n ? t('proxyTestOk', { status: String(proxyTestResult.status), ms: String(proxyTestResult.latencyMs) })\n : t('proxyTestOkDirect', { status: String(proxyTestResult.status), ms: String(proxyTestResult.latencyMs) }))\n : t('proxyTestFail', { message: proxyTestResult.error ?? '' })}\n </p>\n )}\n <div style={styles.proxyActions}>\n <button\n type=\"button\"\n style={{ ...styles.button, ...proxyTesting ? { opacity: 0.5, cursor: 'default' } : {} }}\n disabled={proxyTesting}\n onClick={() => { void testProxy() }}\n >\n {proxyTesting ? t('proxyTesting') : t('proxyTest')}\n </button>\n <button\n type=\"button\"\n style={{ ...styles.button, ...proxySaving ? { opacity: 0.5, cursor: 'default' } : {} }}\n disabled={proxySaving}\n onClick={() => { void saveProxy() }}\n >\n {proxySaving ? t('proxySaving') : t('proxySave')}\n </button>\n <button type=\"button\" style={styles.button} onClick={() => setProxyOpen(false)}>\n {t('proxyCancel')}\n </button>\n </div>\n </div>\n </div>\n )}\n </div>\n )\n}\n","/**\n * Plugin-local image gallery for generated-image toolviews.\n *\n * Since web-app rc.8, `@deepseek-ai/dsh-client-ui-attachment`'s browser module\n * exports only its cordis plugin surface (`apply`/`inject`) — the React\n * components are no longer package values, so importing `ImageGallery` from it\n * yields `undefined` at runtime and crashes the toolview inside the slot error\n * boundary (the whole call row disappears). This module re-implements the\n * gallery contract the toolview needs (loader-driven thumbnails, retry on\n * failure, click-to-open lightbox) with the same sizing rules as the platform\n * component, keeping this plugin independent of harness component exports.\n */\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport type { CSSProperties } from 'react'\n\n/**\n * Mirror of ImageAttachmentRef (packages/attachment/attachment/src/types.ts);\n * the brand on attachmentId is compile-time only, so string suffices here.\n */\nexport interface ImageAttachmentRef {\n attachmentId: string\n mediaType: string\n bytes: number\n width: number\n height: number\n name?: string\n}\n\n/** Loads a session-authorized durable image URL (resolves to a data/blob URL). */\nexport type ImageLoader = (attachment: ImageAttachmentRef) => Promise<string>\n\n/** Lightbox strings forwarded to the opened preview. */\nexport interface ImageLightboxLabels {\n dialog: string\n close: string\n}\n\n/** Message-image strings the owner resolves from its own locale namespace. */\nexport interface MessageImageLabels {\n /** Fallback display name for an unnamed image. */\n image: string\n /** Thumbnail tooltip inviting the original-image preview. */\n open: string\n /** Accessible thumbnail label; receives the image's display name. */\n openNamed: (label: string) => string\n /** Loading placeholder shown until bytes resolve. */\n loading: string\n /** Retry-control label shown when the load fails. */\n loadFailed: string\n /** Lightbox strings forwarded to the opened preview. */\n lightbox: ImageLightboxLabels\n}\n\n/** Display box for a lone image (platform rule): long edge 240px with the\n * rendered aspect ratio clamped to [0.25, 4] — the overflow is cropped by\n * `object-fit: cover` — and never upscaled past the image's natural size. The\n * crop anchor keeps the top of very tall images and the left of very wide\n * ones, where the informative content usually starts. */\nfunction singleFit(attachment: ImageAttachmentRef): { width: number; height: number; objectPosition: string } {\n const natural = attachment.width / attachment.height\n const ratio = Math.min(4, Math.max(0.25, natural))\n const box = ratio >= 1 ? { width: 240, height: 240 / ratio } : { width: 240 * ratio, height: 240 }\n const scale = Math.min(1, attachment.width / box.width, attachment.height / box.height)\n return {\n width: Math.max(1, Math.round(box.width * scale)),\n height: Math.max(1, Math.round(box.height * scale)),\n objectPosition: natural < 0.25 ? 'center top' : natural > 4 ? 'left center' : 'center',\n }\n}\n\nconst styles: Record<string, CSSProperties> = {\n gallery: { display: 'flex', flexWrap: 'wrap', gap: 8, justifyContent: 'flex-start' },\n frame: {\n display: 'grid', placeItems: 'center', overflow: 'hidden', padding: 0,\n border: '1px solid var(--dsw-alias-border-l2-darkmode-thin)', borderRadius: 8,\n background: 'var(--dsw-alias-interactive-bg-hover-solid)', cursor: 'zoom-in',\n },\n tile: { width: 64, height: 64 },\n img: { width: '100%', height: '100%', objectFit: 'cover', display: 'block' },\n loading: { fontSize: 12, color: 'var(--dsw-alias-label-tertiary)', padding: '0 8px' },\n error: {\n fontSize: 12, color: 'var(--dsw-alias-state-error-primary)', cursor: 'pointer',\n border: '1px solid var(--dsw-alias-border-l2-darkmode-thin)', borderRadius: 8,\n background: 'transparent', padding: '6px 10px',\n },\n overlay: {\n position: 'fixed', inset: 0, zIndex: 1000, display: 'grid', placeItems: 'center',\n background: 'rgba(0, 0, 0, 0.72)', padding: 24,\n },\n overlayImg: { maxWidth: '92vw', maxHeight: '92vh', objectFit: 'contain', borderRadius: 4 },\n close: {\n position: 'absolute', top: 12, right: 12, width: 32, height: 32, display: 'grid',\n placeItems: 'center', border: 'none', borderRadius: '50%', cursor: 'pointer',\n background: 'rgba(255, 255, 255, 0.16)', color: '#fff', fontSize: 16, lineHeight: 1,\n },\n}\n\n/**\n * Full-viewport original-image preview: backdrop or close-control click and\n * Escape all dismiss; the image itself is inert so a click on it does not\n * fall through to the backdrop dismissal.\n */\nfunction ImageLightbox({ src, alt, labels, onClose }: {\n src: string\n alt: string\n labels: ImageLightboxLabels\n onClose: () => void\n}) {\n useEffect(() => {\n const onKey = (event: KeyboardEvent) => { if (event.key === 'Escape') onClose() }\n window.addEventListener('keydown', onKey)\n return () => { window.removeEventListener('keydown', onKey) }\n }, [onClose])\n return (\n <div role=\"dialog\" aria-label={labels.dialog} style={styles.overlay} onClick={onClose}>\n <img src={src} alt={alt} style={styles.overlayImg} onClick={event => { event.stopPropagation() }} />\n <button type=\"button\" aria-label={labels.close} style={styles.close} onClick={onClose}>×</button>\n </div>\n )\n}\n\n/**\n * Compact history renderer with retryable loading and click-to-open original\n * preview. A lone image renders at its `singleFit` size; an image among\n * several renders as a fixed 64px square tile.\n */\nexport function MessageImage({ attachment, load, variant, labels }: {\n attachment: ImageAttachmentRef\n load: ImageLoader\n variant: 'single' | 'tile'\n labels: MessageImageLabels\n}) {\n const [src, setSrc] = useState<string | null>(null)\n const [error, setError] = useState(false)\n const [open, setOpen] = useState(false)\n // Retry re-arms the one load effect below, so every attempt — first load or\n // retry — runs under the same liveness guard and the same reset.\n const [attempt, setAttempt] = useState(0)\n const retry = useCallback(() => { setAttempt(a => a + 1) }, [])\n const close = useCallback(() => { setOpen(false) }, [])\n const fit = useMemo(\n () => (variant === 'single' ? singleFit(attachment) : undefined),\n [attachment, variant],\n )\n\n useEffect(() => {\n let live = true\n setError(false)\n setSrc(null)\n void load(attachment).then((url) => { if (live) setSrc(url) }).catch(() => { if (live) setError(true) })\n return () => { live = false }\n }, [attachment, load, attempt])\n\n const label = attachment.name ?? labels.image\n if (error) {\n return <button type=\"button\" style={styles.error} onClick={retry}>{labels.loadFailed}</button>\n }\n const box = fit === undefined ? styles.tile : { width: fit.width, height: fit.height }\n return (\n <>\n <button\n type=\"button\"\n style={{ ...styles.frame, ...box }}\n title={labels.open}\n aria-label={labels.openNamed(label)}\n onClick={() => { if (src !== null) setOpen(true) }}\n >\n {src === null\n ? <span style={styles.loading}>{labels.loading}</span>\n : <img src={src} alt={label} style={{ ...styles.img, objectPosition: fit?.objectPosition }} />}\n </button>\n {open && src !== null && <ImageLightbox src={src} alt={label} labels={labels.lightbox} onClose={close} />}\n </>\n )\n}\n\n/** Wrapping image group: a lone image renders large, several render as 64px\n * square tiles (same rule as the platform gallery). */\nexport function ImageGallery({ images, load, labels }: {\n images: readonly { attachment: ImageAttachmentRef }[]\n load: ImageLoader\n labels: MessageImageLabels\n}) {\n if (images.length === 0) return null\n const variant = images.length === 1 ? 'single' : 'tile'\n return (\n <div style={styles.gallery}>\n {images.map((image, index) => (\n <MessageImage key={`${image.attachment.attachmentId}:${index}`} attachment={image.attachment} load={load} variant={variant} labels={labels} />\n ))}\n </div>\n )\n}\n","/**\n * Keyed toolview for the `image_generate` tool: renders generated images\n * inline in the conversation. The row shows the call's prompt while running\n * and after settling; a settled result with image blocks renders them through\n * this plugin's own ImageGallery (harness rc.8 stopped exporting the platform\n * one as a package value), whose bytes load through the node half's\n * `/subscriptions-auth` RPC channel (the durable ImageAttachmentRef is never\n * a fetchable URL on its own). A text-only settled result (degraded route)\n * renders its text; an error result renders the first error line.\n *\n * The 'tool.call.toolview' slot contract is owned by ui-tool\n * (packages/client/ui-tool/src/client/contract/slots.ts), which this package\n * does not resolve; the SlotMap merge and ToolCallOwnerProps below mirror it\n * structurally (same discipline as platform-modules.d.ts).\n */\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport type { ToolCallBlock } from '@deepseek-ai/dsh-client-runtime/client'\nimport { IconSparkle16 } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { ImageGallery } from './ImageGallery.js'\nimport type { ImageAttachmentRef, ImageLoader, MessageImageLabels } from './ImageGallery.js'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Title prompt truncation budget (characters). */\nconst PROMPT_MAX_LENGTH = 60\n\n/** Mirror of ui-tool's ToolCallOwnerProps (see the module header). */\ninterface ToolCallOwnerProps {\n callId: string\n toolName: string\n block: ToolCallBlock\n cwd?: string | undefined\n openFile: (path: string) => void\n inspect?: (() => void) | undefined\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface SlotMap {\n /** Mirror of ui-tool's keyed atomic Tool view declaration (see the module header). */\n 'tool.call.toolview': { kind: 'keyed'; scope: 'session'; owner: ToolCallOwnerProps }\n }\n}\n\n/** Injected dependencies of {@link ImageGenerateToolview} (slot `inject`). */\nexport interface ImageGenerateToolviewInjected {\n /** Session-authorized image URL loader riding the `/subscriptions-auth` channel. */\n load: ImageLoader\n}\n\n/**\n * Props delivered by the toolview outlet: the owner share plus the inject\n * face and the framework locale seat, spread flat.\n */\nexport type ImageGenerateToolviewProps =\n Partial<ToolCallOwnerProps>\n & Partial<ImageGenerateToolviewInjected>\n & { t?: ((key: SubscriptionsKey, params?: Record<string, unknown>) => string) | undefined }\n\n/** `image` endpoint result: the node half owns this shape. */\ninterface ImageEndpointResult {\n mediaType: string\n dataBase64: string\n}\n\n/**\n * Call one `/subscriptions-auth` endpoint and unwrap the business result.\n * @param rpc - Connection RPC caller.\n * @param endpoint - channel-relative endpoint.\n * @param payload - channel-owned request payload.\n * @returns the success value, cast by the caller to the endpoint's shape.\n */\nasync function callSubscriptionsAuth<T>(rpc: ConnectionHandle['rpc'], endpoint: string, payload: unknown): Promise<T> {\n const result: RpcResult<unknown> = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, endpoint, payload)\n if (!result.ok) throw new Error(result.error.message)\n return result.value as T\n}\n\n/**\n * Build the ImageGallery loader over the `image` endpoint.\n * @param rpc - Connection RPC caller.\n * @returns loader resolving an attachment ref to a data URL.\n */\nexport function createImageLoader(rpc: ConnectionHandle['rpc']): ImageLoader {\n // The host validates a full ImageAttachmentRef payload (readImage takes the\n // whole ref), so forward the attachment verbatim.\n return attachment =>\n callSubscriptionsAuth<ImageEndpointResult>(rpc, 'image', { ...attachment })\n .then(result => `data:${result.mediaType};base64,${result.dataBase64}`)\n}\n\n/**\n * English-dictionary fallback for a missing locale seat (standalone renders);\n * the framework always supplies the namespace-bound one.\n * @param key - dictionary key.\n * @param params - `{name}` template params.\n * @returns the template with params substituted.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\n/** Extract the prompt from the call's raw args JSON; falls back to the first string value, then the raw line. */\nfunction derivePrompt(argsRaw: string): string {\n let parsed: unknown\n try {\n parsed = JSON.parse(argsRaw)\n } catch {\n // Non-JSON args (mid-stream truncation): fall back to the raw string below.\n parsed = undefined\n }\n let prompt: string | undefined\n if (typeof parsed === 'object' && parsed !== null) {\n const args = parsed as Record<string, unknown>\n if (typeof args.prompt === 'string' && args.prompt !== '') prompt = args.prompt\n else {\n for (const value of Object.values(args)) {\n if (typeof value === 'string' && value !== '') { prompt = value; break }\n }\n }\n }\n const line = (prompt ?? argsRaw).split('\\n', 1)[0] ?? ''\n return line.length > PROMPT_MAX_LENGTH ? `${line.slice(0, PROMPT_MAX_LENGTH)}…` : line\n}\n\n/** Flatten a settled result's text blocks (the degraded text-only route and the error line). */\nfunction resultText(block: ToolCallBlock): string {\n if (!('kind' in block)) return ''\n const parts: string[] = []\n for (const part of block.content) {\n if (part.type === 'text') parts.push(part.text)\n }\n if (parts.length === 0 && block.error !== undefined) parts.push(`${block.error.name}: ${block.error.code}`)\n return parts.join('\\n')\n}\n\n/** Image attachments of a settled result; empty while running or on the text-only route. */\nfunction resultImages(block: ToolCallBlock): { attachment: ImageAttachmentRef }[] {\n if (!('kind' in block)) return []\n const images: { attachment: ImageAttachmentRef }[] = []\n for (const part of block.content) {\n if (part.type === 'image') images.push({ attachment: part.attachment as ImageAttachmentRef })\n }\n return images\n}\n\nconst styles: Record<string, CSSProperties> = {\n container: { display: 'flex', flexDirection: 'column', gap: 6, padding: '4px 0' },\n row: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 },\n icon: { display: 'inline-flex', flexShrink: 0, color: 'var(--dsw-alias-label-tertiary)' },\n title: {\n fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)',\n overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',\n },\n subtle: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n output: {\n margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)',\n whiteSpace: 'pre-wrap', overflowWrap: 'anywhere',\n },\n error: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n}\n\n/**\n * The `image_generate` keyed toolview component.\n * @param props - owner share, inject face, and locale seat (spread flat).\n * @returns the call row plus, once settled, the gallery / text / error body.\n */\nexport function ImageGenerateToolview(props: ImageGenerateToolviewProps) {\n const { block, load } = props\n const t = props.t ?? fallbackTranslate\n if (block === undefined) return null\n const settled = 'kind' in block\n const argsRaw = (settled ? block.call?.argsRaw : block.argsRaw) ?? ''\n const title = `image_generate: ${derivePrompt(argsRaw)}`\n const images = resultImages(block)\n const text = settled ? resultText(block) : ''\n const labels: MessageImageLabels = {\n image: t('image'),\n open: t('viewImage'),\n openNamed: name => t('viewImageNamed', { name }),\n loading: t('imageLoading'),\n loadFailed: t('imageLoadFailed'),\n lightbox: { dialog: t('imagePreview'), close: t('imageClose') },\n }\n return (\n <div style={styles.container}>\n <div style={styles.row}>\n <span style={styles.icon}><IconSparkle16 size={14} /></span>\n <span style={styles.title}>{title}</span>\n </div>\n {!settled && <p style={styles.subtle}>{t('generating')}</p>}\n {settled && block.isError && text !== '' && (\n <p style={styles.error}>{text.split('\\n', 1)[0]}</p>\n )}\n {settled && !block.isError && images.length > 0 && load !== undefined && (\n <ImageGallery images={images} load={load} labels={labels} />\n )}\n {settled && !block.isError && images.length === 0 && text !== '' && (\n <p style={styles.output}>{text}</p>\n )}\n </div>\n )\n}\n","/**\n * Keyed toolview for the `video_generate` tool: renders the generated video\n * inline in the conversation. The row shows the call's prompt while running\n * and after settling; a settled success loads the MP4 bytes through the node\n * half's `/subscriptions-auth` `video` endpoint (by bare file name), builds a\n * Blob URL, and plays it in a native `<video controls>` element. The file\n * name comes from the result's presentation meta when the dispatch was\n * top-level, and is recovered from the \"Saved video to …\" text line for\n * nested (Code Mode) dispatches, where the harness computes no meta. A result\n * with neither renders its text; an error result renders the first error line.\n *\n * The 'tool.call.toolview' SlotMap entry is declared by\n * ImageGenerateToolview.tsx in this same package (one declaration per\n * augmentation), so this file only mirrors the owner-props shape.\n */\nimport { useEffect, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { ConnectionHandle, RpcResult } from '@deepseek-ai/dsh-api-remotes/client'\nimport type { ToolCallBlock } from '@deepseek-ai/dsh-client-runtime/client'\nimport { IconSparkle16 } from '@deepseek-ai/dsh-client-ui-primitives'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** Logical RPC channel served by the node half of this plugin. */\nconst SUBSCRIPTIONS_AUTH_CHANNEL = '/subscriptions-auth'\n\n/** Title prompt truncation budget (characters). */\nconst PROMPT_MAX_LENGTH = 60\n\n/** Mirror of ui-tool's ToolCallOwnerProps (see ImageGenerateToolview). */\ninterface ToolCallOwnerProps {\n callId: string\n toolName: string\n block: ToolCallBlock\n cwd?: string | undefined\n openFile: (path: string) => void\n inspect?: (() => void) | undefined\n}\n\n/** Decoded video bytes as the node half's `video` endpoint answers them. */\nexport interface VideoBytes {\n mediaType: string\n dataBase64: string\n}\n\n/** Injected dependencies of {@link VideoGenerateToolview} (slot `inject`). */\nexport interface VideoGenerateToolviewInjected {\n /** Loads one generated video's bytes by bare file name. */\n loadVideo: (name: string) => Promise<VideoBytes>\n}\n\n/**\n * Props delivered by the toolview outlet: the owner share plus the inject\n * face and the framework locale seat, spread flat.\n */\nexport type VideoGenerateToolviewProps =\n Partial<ToolCallOwnerProps>\n & Partial<VideoGenerateToolviewInjected>\n & { t?: ((key: SubscriptionsKey, params?: Record<string, unknown>) => string) | undefined }\n\n/**\n * Build the video loader over the `/subscriptions-auth` `video` endpoint.\n * @param rpc - Connection RPC caller.\n * @returns loader resolving a bare file name to the decoded bytes.\n */\nexport function createVideoLoader(rpc: ConnectionHandle['rpc']): (name: string) => Promise<VideoBytes> {\n return async (name) => {\n const result: RpcResult<unknown> = await rpc.call(SUBSCRIPTIONS_AUTH_CHANNEL, 'video', { name })\n if (!result.ok) throw new Error(result.error.message)\n return result.value as VideoBytes\n }\n}\n\n/**\n * English-dictionary fallback for a missing locale seat (standalone renders);\n * the framework always supplies the namespace-bound one.\n */\nfunction fallbackTranslate(key: SubscriptionsKey, params?: Record<string, unknown>): string {\n let text: string = en[key]\n for (const [name, value] of Object.entries(params ?? {})) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n return text\n}\n\n/** Extract the prompt from the call's raw args JSON; falls back to the first string value, then the raw line. */\nfunction derivePrompt(argsRaw: string): string {\n let parsed: unknown\n try {\n parsed = JSON.parse(argsRaw)\n } catch {\n // Non-JSON args (mid-stream truncation): fall back to the raw string below.\n parsed = undefined\n }\n let prompt: string | undefined\n if (typeof parsed === 'object' && parsed !== null) {\n const args = parsed as Record<string, unknown>\n if (typeof args.prompt === 'string' && args.prompt !== '') prompt = args.prompt\n else {\n for (const value of Object.values(args)) {\n if (typeof value === 'string' && value !== '') { prompt = value; break }\n }\n }\n }\n const line = (prompt ?? argsRaw).split('\\n', 1)[0] ?? ''\n return line.length > PROMPT_MAX_LENGTH ? `${line.slice(0, PROMPT_MAX_LENGTH)}…` : line\n}\n\n/** Flatten a settled result's text blocks (the fallback body and the error line). */\nfunction resultText(block: ToolCallBlock): string {\n if (!('kind' in block)) return ''\n const parts: string[] = []\n for (const part of block.content) {\n if (part.type === 'text') parts.push(part.text)\n }\n if (parts.length === 0 && block.error !== undefined) parts.push(`${block.error.name}: ${block.error.code}`)\n return parts.join('\\n')\n}\n\n/**\n * The generated video's bare file name: presentation meta first (top-level\n * dispatches), then the render text's \"Saved video to …\" line (nested\n * dispatches compute no meta).\n */\nfunction resolveFileName(block: ToolCallBlock): string | undefined {\n if (!('kind' in block)) return undefined\n const meta = block.meta\n if (typeof meta === 'object' && meta !== null) {\n const fileName = (meta as Record<string, unknown>).fileName\n if (typeof fileName === 'string' && fileName.length > 0) return fileName\n }\n const match = /^Saved video to (.+\\.mp4)/m.exec(resultText(block))\n if (match === null) return undefined\n const path = match[1]\n return path.slice(path.lastIndexOf('/') + 1)\n}\n\n/** Decode a base64 payload into bytes (browser-side; no Buffer). */\nfunction base64Bytes(dataBase64: string): Uint8Array {\n const binary = atob(dataBase64)\n const bytes = new Uint8Array(binary.length)\n for (let index = 0; index < binary.length; index++) bytes[index] = binary.charCodeAt(index)\n return bytes\n}\n\n/** Loading lifecycle of the Blob URL. */\ntype LoadState =\n | { phase: 'loading' }\n | { phase: 'ready'; url: string }\n | { phase: 'failed'; message: string }\n\nconst styles: Record<string, CSSProperties> = {\n container: { display: 'flex', flexDirection: 'column', gap: 6, padding: '4px 0' },\n row: { display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 },\n icon: { display: 'inline-flex', flexShrink: 0, color: 'var(--dsw-alias-label-tertiary)' },\n title: {\n fontSize: 13, lineHeight: '20px', color: 'var(--dsw-alias-label-primary)',\n overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap',\n },\n subtle: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-tertiary)' },\n output: {\n margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-secondary)',\n whiteSpace: 'pre-wrap', overflowWrap: 'anywhere',\n },\n error: { margin: 0, fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-state-error-primary)' },\n video: {\n display: 'block', maxWidth: 480, width: '100%', borderRadius: 8,\n backgroundColor: 'var(--dsw-alias-fill-tertiary)',\n },\n}\n\n/**\n * The `video_generate` keyed toolview component.\n * @param props - owner share, inject face, and locale seat (spread flat).\n * @returns the call row plus, once settled, the player / text / error body.\n */\nexport function VideoGenerateToolview(props: VideoGenerateToolviewProps) {\n const { block, loadVideo } = props\n const t = props.t ?? fallbackTranslate\n const settled = block !== undefined && 'kind' in block\n const isError = settled && block.isError\n const fileName = block !== undefined && settled && !isError ? resolveFileName(block) : undefined\n const [load, setLoad] = useState<LoadState>({ phase: 'loading' })\n\n useEffect(() => {\n if (fileName === undefined || loadVideo === undefined) return\n let cancelled = false\n let objectUrl: string | undefined\n setLoad({ phase: 'loading' })\n loadVideo(fileName).then(\n (video) => {\n if (cancelled) return\n // Uint8Array#slice detaches a plain ArrayBuffer view for BlobPart.\n objectUrl = URL.createObjectURL(new Blob([base64Bytes(video.dataBase64).slice()], { type: video.mediaType }))\n setLoad({ phase: 'ready', url: objectUrl })\n },\n (error: unknown) => {\n if (cancelled) return\n setLoad({ phase: 'failed', message: error instanceof Error ? error.message : String(error) })\n },\n )\n return () => {\n cancelled = true\n if (objectUrl !== undefined) URL.revokeObjectURL(objectUrl)\n }\n }, [fileName, loadVideo])\n\n if (block === undefined) return null\n const argsRaw = (settled ? block.call?.argsRaw : block.argsRaw) ?? ''\n const title = `video_generate: ${derivePrompt(argsRaw)}`\n const text = settled ? resultText(block) : ''\n return (\n <div style={styles.container}>\n <div style={styles.row}>\n <span style={styles.icon}><IconSparkle16 size={14} /></span>\n <span style={styles.title}>{title}</span>\n </div>\n {!settled && <p style={styles.subtle}>{t('generatingVideo')}</p>}\n {settled && isError && text !== '' && (\n <p style={styles.error}>{text.split('\\n', 1)[0]}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'loading' && (\n <p style={styles.subtle}>{t('videoLoading')}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'failed' && (\n <p style={styles.error}>{t('videoLoadFailed', { message: load.message })}</p>\n )}\n {settled && !isError && fileName !== undefined && load.phase === 'ready' && (\n // eslint-disable-next-line jsx-a11y/media-has-caption -- generated clip; no caption track exists.\n <video style={styles.video} src={load.url} controls preload=\"metadata\" />\n )}\n {settled && !isError && fileName === undefined && text !== '' && (\n <p style={styles.output}>{text}</p>\n )}\n </div>\n )\n}\n","/**\n * Codex Speed toggle: one small control in the composer's right tool row\n * (`conversation.input.right`), switching the session between standard routing\n * and the fast (priority) service tier — the Codex desktop app's Speed menu.\n * The choice is per session and lives in the node half (in-memory); this\n * component holds only viewing state. The control renders nothing until the\n * first load proves the session's current model is a codex model whose catalog\n * advertises the fast tier.\n *\n * Every color resolves through a `--dsw-alias-*` design token and every\n * user-visible string goes through the locale `t` of the\n * 'settings.subscriptions' namespace, same as the settings section.\n */\nimport { useEffect, useRef, useState } from 'react'\nimport type { CSSProperties } from 'react'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { ConnectionHandle, SessionId } from '@deepseek-ai/dsh-api-remotes/client'\nimport { callSubscriptionsAuth } from './SubscriptionsSection.js'\nimport { en } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\n/** One session's speed choice: standard routing or the fast (priority) tier. */\nexport type SpeedTier = 'standard' | 'fast'\n\n/** `speed` endpoint value, mirrored from the node half. */\nexport interface SpeedState {\n tier: SpeedTier\n fastModels: string[]\n}\n\n/** What {@link SpeedSelect} renders from: visibility plus the current tier. */\nexport interface SpeedSelectState {\n visible: boolean\n tier: SpeedTier\n}\n\n/** Injected dependencies of {@link SpeedSelect} (slot `inject`, session-bound). */\nexport interface SpeedSelectInjected {\n /** Load the session's speed state; `visible` false keeps the control hidden. */\n loadSpeed: () => Promise<SpeedSelectState>\n /** Set the session's speed tier; resolves false when the write failed. */\n setSpeed: (tier: SpeedTier) => Promise<boolean>\n}\n\n/**\n * Props delivered by the slot outlet: the framework session kit and InputZone\n * owner share (unused — everything arrives session-bound through the inject\n * face), the injected callbacks, and the locale seat.\n */\nexport type SpeedSelectProps = PropsRuntime<'conversation.input.right'>\n & Partial<SpeedSelectInjected>\n & Partial<PropsLocale<'settings.subscriptions'>>\n\n/**\n * The `loadSpeed` half of the inject face: the plugin's own speed state plus\n * the host's current model selection (the visibility gate). A model-RPC\n * failure throws rather than answering \"hidden\" — the caller keeps its last\n * known state, so a transient failure never locks the toggle away.\n *\n * `sessionId` is a plain string: slot and command contexts brand it through\n * different dsh-session copies, and only the API-client boundary needs one.\n */\nexport function createSpeedLoader(\n connection: ConnectionHandle,\n sessionId: string,\n): SpeedSelectInjected['loadSpeed'] {\n return async () => {\n const state = await callSubscriptionsAuth<SpeedState>(connection.rpc, 'speed', { sessionId })\n const { result } = await connection.api.sessions.models({ sessionId: sessionId as SessionId })\n if (!result.ok) throw new Error(`session.models failed: ${result.error.code}: ${result.error.message}`)\n const current = result.value.current\n const visible = current !== null && current.provider === 'codex'\n && state.fastModels.includes(current.model)\n return { visible, tier: state.tier }\n }\n}\n\n/** The `setSpeed` half of the inject face: boolean outcome for the component's busy state. */\nexport function createSpeedSetter(\n connection: ConnectionHandle,\n sessionId: string,\n): SpeedSelectInjected['setSpeed'] {\n return tier => callSubscriptionsAuth(connection.rpc, 'setSpeed', { sessionId, tier })\n .then(() => true, () => false)\n}\n\n/** English-dictionary fallback for a missing inject `t` (standalone renders). */\nfunction fallbackTranslate(key: SubscriptionsKey): string {\n return en[key]\n}\n\nconst TIERS: readonly SpeedTier[] = ['standard', 'fast']\n\n/**\n * The composer Speed control: a trigger reading `速度 · 快速`/`速度 · 标准`\n * that opens a two-row menu (standard/fast with descriptions, check mark on\n * the current tier). Mount and every open reload the host state so a model\n * switch made since the last open self-corrects.\n */\n/** How often the control re-reads the host state (model switches arrive only by asking). */\nconst POLL_INTERVAL_MS = 3000\n\n/**\n * The composer Speed control: a trigger reading `速度 · 快速`/`速度 · 标准`\n * that opens a two-row menu (standard/fast with descriptions, check mark on\n * the current tier). The host pushes nothing on a model switch, so the\n * control re-reads on a slow poll with a single-flight guard; a failed read\n * keeps the last known state, so a transient RPC failure can never lock the\n * toggle away (the earlier mount-only load had no recovery path).\n */\nexport function SpeedSelect({ loadSpeed, setSpeed, t }: SpeedSelectProps) {\n const translate = t ?? fallbackTranslate\n const [state, setState] = useState<SpeedSelectState | null>(null)\n const [open, setOpen] = useState(false)\n const [busy, setBusy] = useState(false)\n const rootRef = useRef<HTMLDivElement | null>(null)\n // The inject face may be re-evaluated (new callback identities) on re-render;\n // the poll effect mounts once and reads through this ref, so identity churn\n // neither resets the interval nor multiplies in-flight loads.\n const loadRef = useRef(loadSpeed)\n loadRef.current = loadSpeed\n\n useEffect(() => {\n if (loadRef.current === undefined) return\n let cancelled = false\n let inflight = false\n const reload = (): void => {\n const load = loadRef.current\n if (load === undefined || inflight) return\n inflight = true\n void load().then(\n (loaded) => { if (!cancelled) setState(loaded) },\n () => { /* keep the last known state; the next tick retries */ },\n ).finally(() => { inflight = false })\n }\n reload()\n const timer = setInterval(reload, POLL_INTERVAL_MS)\n return () => {\n cancelled = true\n clearInterval(timer)\n }\n }, [])\n\n useEffect(() => {\n if (!open) return\n const closeOutside = (event: MouseEvent): void => {\n if (!rootRef.current?.contains(event.target as Node)) setOpen(false)\n }\n document.addEventListener('mousedown', closeOutside)\n return () => { document.removeEventListener('mousedown', closeOutside) }\n }, [open])\n\n if (loadSpeed === undefined || setSpeed === undefined || state === null || !state.visible) {\n return null\n }\n\n const choose = (tier: SpeedTier): void => {\n if (busy) return\n if (tier === state.tier) {\n setOpen(false)\n return\n }\n setBusy(true)\n void setSpeed(tier).then((ok) => {\n setBusy(false)\n if (ok) {\n setState({ visible: true, tier })\n setOpen(false)\n }\n })\n }\n\n const show = (): void => {\n setOpen(true)\n const load = loadRef.current\n if (load === undefined) return\n void load().then(setState, () => { /* keep showing the last good state */ })\n }\n\n const tierName = (tier: SpeedTier): string =>\n translate(tier === 'fast' ? 'speedFast' : 'speedStandard')\n const tierDescription = (tier: SpeedTier): string =>\n translate(tier === 'fast' ? 'speedFastDescription' : 'speedStandardDescription')\n const triggerLabel = `${translate('speed')} · ${tierName(state.tier)}`\n\n return (\n <div\n ref={rootRef}\n style={styles.root}\n onKeyDown={(event) => {\n if (event.key === 'Escape' && open) {\n event.preventDefault()\n setOpen(false)\n }\n }}\n >\n {open && (\n <div style={styles.menu} role=\"menu\" aria-label={translate('speed')}>\n {TIERS.map(tier => (\n <button\n key={tier}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={tier === state.tier}\n style={styles.item}\n disabled={busy}\n onClick={() => { choose(tier) }}\n >\n <span style={styles.itemCheck}>{tier === state.tier ? '✓' : ''}</span>\n <span style={styles.itemText}>\n <span style={styles.itemName}>{tierName(tier)}</span>\n <span style={styles.itemDescription}>{tierDescription(tier)}</span>\n </span>\n </button>\n ))}\n </div>\n )}\n <button\n type=\"button\"\n style={styles.trigger}\n aria-haspopup=\"menu\"\n aria-expanded={open}\n title={triggerLabel}\n disabled={busy}\n onClick={() => {\n if (open) setOpen(false)\n else show()\n }}\n >\n {triggerLabel}\n </button>\n </div>\n )\n}\n\nconst styles: Record<string, CSSProperties> = {\n root: { position: 'relative', display: 'inline-flex' },\n trigger: {\n border: '1px solid var(--dsw-alias-border-l2)', borderRadius: 8,\n background: 'transparent', color: 'var(--dsw-alias-label-secondary)',\n font: 'inherit', fontSize: 12, lineHeight: '18px',\n padding: '2px 8px', cursor: 'pointer', whiteSpace: 'nowrap',\n },\n menu: {\n position: 'absolute', bottom: '100%', right: 0, marginBottom: 4,\n minWidth: 180, padding: 4, zIndex: 20,\n background: 'var(--dsw-alias-bg-layer-1)', border: '1px solid var(--dsw-alias-border-l2)',\n borderRadius: 8, display: 'flex', flexDirection: 'column', gap: 2,\n },\n item: {\n display: 'flex', alignItems: 'flex-start', gap: 6, width: '100%',\n border: 'none', borderRadius: 6, background: 'transparent',\n padding: '6px 8px', cursor: 'pointer', font: 'inherit', textAlign: 'left',\n },\n itemCheck: {\n width: 14, flexShrink: 0, fontSize: 12, lineHeight: '18px',\n color: 'var(--dsw-alias-label-primary)',\n },\n itemText: { display: 'flex', flexDirection: 'column' },\n itemName: { fontSize: 12, lineHeight: '18px', color: 'var(--dsw-alias-label-primary)' },\n itemDescription: { fontSize: 11, lineHeight: '16px', color: 'var(--dsw-alias-label-tertiary)' },\n}\n","/**\n * Subscription OAuth login page, browser half. Registers the Subscriptions\n * settings section; every login state fact arrives through the node half's\n * `/subscriptions-auth` RPC channel — this plugin holds no credential state of its\n * own. Section copy rides the client locale service: one 'settings.subscriptions'\n * namespace with zh/en dictionaries, rebound per read so the nav label and\n * page text follow the active locale.\n */\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { ConnectionHandle, SessionId } from '@deepseek-ai/dsh-api-remotes/client'\n// Type-only: pulls the shell's SlotMap merge (the 'settings.section' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\n// Type-only: pulls ui-conversation's SlotMap merge (the 'conversation.input.right' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: the slash-command registry contract (the /fast contribution).\nimport type { CommandUiContract } from '@deepseek-ai/dsh-client-ui-commands/client'\n// `.js` extension: this package's tsconfig lacks the reference repo's\n// allowImportingTsExtensions/rewriteRelativeImportExtensions pair; under\n// nodenext the .js specifier resolves to the .tsx source (see README note).\nimport { SubscriptionsSection } from './SubscriptionsSection.js'\nimport type { SubscriptionsSectionInjected } from './SubscriptionsSection.js'\nimport { ImageGenerateToolview, createImageLoader } from './ImageGenerateToolview.js'\nimport type { ImageGenerateToolviewInjected } from './ImageGenerateToolview.js'\nimport { VideoGenerateToolview, createVideoLoader } from './VideoGenerateToolview.js'\nimport type { VideoGenerateToolviewInjected } from './VideoGenerateToolview.js'\nimport { SpeedSelect, createSpeedLoader, createSpeedSetter } from './SpeedSelect.js'\nimport type { SpeedSelectInjected } from './SpeedSelect.js'\nimport { en, zh } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\nexport type { SubscriptionsSectionInjected, SubscriptionsSectionProps } from './SubscriptionsSection.js'\nexport type { ImageGenerateToolviewInjected, ImageGenerateToolviewProps } from './ImageGenerateToolview.js'\nexport type { VideoGenerateToolviewInjected, VideoGenerateToolviewProps } from './VideoGenerateToolview.js'\nexport type { SpeedSelectInjected, SpeedSelectProps, SpeedState, SpeedTier } from './SpeedSelect.js'\nexport type { SubscriptionsKey } from './locales.js'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** The Subscriptions settings page copy. */\n 'settings.subscriptions': SubscriptionsKey\n }\n}\n\n/** Dictionary namespace owned by this plugin. */\nconst NS = 'settings.subscriptions'\n\n/**\n * Required services (cordis fiber inject): `slots` carries the registration\n * seat, `connection` the `/subscriptions-auth` RPC caller, and `locale` the copy\n * dictionaries.\n */\nexport const inject = ['slots', 'connection', 'locale']\n\n/**\n * Register the Subscriptions section once the `settings.section` declaration\n * is on the ledger (the shell's apply order relative to this one is NOT\n * constrained; registration depends on the slot through `slots.inject()`).\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-plugin-subscriptions: copy dictionaries')\n // Settings-shell nudge: the panel (nav title + header row + section body)\n // sits flush against the panel's top edge; push it down a little to leave\n // breathing room. Scoped by the settings panel's own dialog role + nav child\n // so other aria-modal dialogs (e.g. the attachment lightbox) are untouched.\n ctx.effect(() => {\n const style = document.createElement('style')\n style.setAttribute('data-plugin', 'dsh-plugin-subscriptions')\n style.textContent = 'div[role=\"dialog\"][aria-modal=\"true\"]:has(> nav) { padding-top: 14px; }'\n document.head.appendChild(style)\n return () => style.remove()\n }, 'dsh-plugin-subscriptions: settings panel breathing room')\n // The client-runtime Context merge types `connection` as the host handle;\n // in the browser shell the same key holds the full client ConnectionHandle.\n const connection = ctx.get('connection') as unknown as ConnectionHandle\n const t = ctx.locale.bind(NS) as SubscriptionsSectionInjected['t']\n const injected = (): SubscriptionsSectionInjected => ({ rpc: connection.rpc, t })\n ctx.slots.inject('settings.section', () => ctx.slots.register({\n name: 'settings.section',\n id: 'subscriptions',\n order: 90,\n // A thunk re-evaluated per read, so the nav label follows the active locale.\n label: () => t('nav'),\n inject: injected,\n }, SubscriptionsSection))\n\n // The image_generate keyed toolview owns how image calls render inline; its\n // gallery bytes ride the same channel through the injected loader. The\n // framework synthesizes the toolview's own `t` seat from `locale: NS`.\n const toolviewInjected = (): ImageGenerateToolviewInjected => ({ load: createImageLoader(connection.rpc) })\n ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({\n name: 'tool.call.toolview',\n key: 'image_generate',\n locale: NS,\n inject: toolviewInjected,\n }, ImageGenerateToolview))\n\n // The video_generate keyed toolview plays the saved MP4 inline; its bytes\n // ride the same channel's `video` endpoint through the injected loader.\n const videoToolviewInjected = (): VideoGenerateToolviewInjected => ({ loadVideo: createVideoLoader(connection.rpc) })\n ctx.slots.inject('tool.call.toolview', () => ctx.slots.register({\n name: 'tool.call.toolview',\n key: 'video_generate',\n locale: NS,\n inject: videoToolviewInjected,\n }, VideoGenerateToolview))\n\n // The composer Speed toggle (codex fast tier) sits in the right tool row,\n // just left of the model selector; the framework synthesizes its `t` seat\n // from `locale: NS`, and the inject face binds each session's RPC calls.\n ctx.slots.inject('conversation.input.right', () => ctx.slots.register({\n name: 'conversation.input.right',\n id: 'codex-speed',\n order: 0,\n locale: NS,\n inject: (sessionId: SessionId): SpeedSelectInjected => ({\n loadSpeed: createSpeedLoader(connection, sessionId),\n setSpeed: createSpeedSetter(connection, sessionId),\n }),\n }, SpeedSelect))\n\n // The /fast slash command offers the same Standard/Fast choice as a popup.\n // `available` is synchronous and sees only the session id, so the command\n // stays listed everywhere; `options` throws the friendly gate when the\n // session's current model is not a fast-capable codex model (the same\n // in-popup error posture the /model contribution uses for its guards).\n ctx.inject(['commandUi'], (scope) => {\n const command = scope.get('commandUi') as CommandUiContract\n scope.effect(() => command.register({\n name: 'fast',\n description: t('commandFast'),\n available: () => true,\n ui: {\n kind: 'popupSelect',\n options: async (session) => {\n const state = await createSpeedLoader(connection, session.sessionId)()\n if (!state.visible) throw new Error(t('commandFastUnavailable'))\n return ([\n { id: 'standard', label: t('speedStandard'), detail: t('speedStandardDescription') },\n { id: 'fast', label: t('speedFast'), detail: t('speedFastDescription') },\n ] as const).map(option => ({ ...option, active: option.id === state.tier }))\n },\n onSelect: async (option, session) => {\n await createSpeedSetter(connection, session.sessionId)(option.id as 'standard' | 'fast')\n },\n },\n }), 'dsh-plugin-subscriptions: /fast contribution')\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAa,KAAK;CAChB,KAAK;CACL,OAAO;CACP,aAAa;CACb,UAAU;CACV,iBAAiB;CACjB,aAAa;CACb,eAAe;CACf,gBAAgB;CAChB,cAAc;C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