dsh-plugin-subscriptions 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +93 -0
  2. package/README.zh.md +93 -0
  3. package/cordis.patch.yml +12 -0
  4. package/lib/auth/jwt.d.ts +10 -0
  5. package/lib/auth/jwt.js +25 -0
  6. package/lib/auth/oauth-flow.d.ts +91 -0
  7. package/lib/auth/oauth-flow.js +227 -0
  8. package/lib/auth/pkce.d.ts +31 -0
  9. package/lib/auth/pkce.js +35 -0
  10. package/lib/auth/rpc.d.ts +51 -0
  11. package/lib/auth/rpc.js +83 -0
  12. package/lib/auth/store.d.ts +90 -0
  13. package/lib/auth/store.js +137 -0
  14. package/lib/client/SubscriptionsSection.d.ts +30 -0
  15. package/lib/client/SubscriptionsSection.js +290 -0
  16. package/lib/client/index.d.ts +31 -0
  17. package/lib/client/index.js +35 -0
  18. package/lib/client/locales.d.ts +45 -0
  19. package/lib/client/locales.js +43 -0
  20. package/lib/client.js +546 -0
  21. package/lib/client.js.map +1 -0
  22. package/lib/index.d.ts +34 -0
  23. package/lib/index.js +2932 -0
  24. package/lib/providers/claude.d.ts +60 -0
  25. package/lib/providers/claude.js +243 -0
  26. package/lib/providers/codex.d.ts +96 -0
  27. package/lib/providers/codex.js +391 -0
  28. package/lib/providers/common.d.ts +185 -0
  29. package/lib/providers/common.js +302 -0
  30. package/lib/providers/grok.d.ts +90 -0
  31. package/lib/providers/grok.js +337 -0
  32. package/lib/tools/image-generate.d.ts +60 -0
  33. package/lib/tools/image-generate.js +142 -0
  34. package/lib/tools/x-search.d.ts +58 -0
  35. package/lib/tools/x-search.js +195 -0
  36. package/lib/translate/anthropic.d.ts +120 -0
  37. package/lib/translate/anthropic.js +370 -0
  38. package/lib/translate/resolved.d.ts +35 -0
  39. package/lib/translate/resolved.js +40 -0
  40. package/lib/translate/responses.d.ts +127 -0
  41. package/lib/translate/responses.js +352 -0
  42. package/lib/translate/sse.d.ts +21 -0
  43. package/lib/translate/sse.js +56 -0
  44. package/package.json +83 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":["PROVIDERS: readonly { id: SubscriptionProvider; name: string }[]","result: RpcResult<unknown>","text: string","styles: Record<string, CSSProperties>","params: Record<string, unknown>","response: StatusResponse"],"sources":["../src/client/locales.ts","../src/client/SubscriptionsSection.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} 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} 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'\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/** `login` endpoint value: the URL the user completes OAuth at. */\ninterface LoginResponse {\n authorizeUrl: 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]\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 * @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 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 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}\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 * 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: '',\n })\n const mountedRef = useRef(true)\n const pollersRef = useRef(new Map<SubscriptionProvider, ReturnType<typeof setInterval>>())\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) stopPolling(id)\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 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 throw new SubscriptionsAuthError(t('loginMissingUrl'))\n }\n window.open(response.authorizeUrl, '_blank', 'noopener')\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 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 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 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 {busy && (\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 * 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 } 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 the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/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 { en, zh } from './locales.js'\nimport type { SubscriptionsKey } from './locales.js'\n\nexport type { SubscriptionsSectionInjected, SubscriptionsSectionProps } from './SubscriptionsSection.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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAa,KAAK;CAChB,KAAK;CACL,OAAO;CACP,aAAa;CACb,UAAU;CACV,iBAAiB;CACjB,UAAU;CACV,iBAAiB;CACjB,iBAAiB;CACjB,wBAAwB;CACxB,aAAa;CACb,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,QAAQ;CACR,iBAAiB;CAClB;;AAGD,MAAa,KAAK;CAChB,KAAK;CACL,OAAO;CACP,aAAa;CACb,UAAU;CACV,iBAAiB;CACjB,UAAU;CACV,iBAAiB;CACjB,iBAAiB;CACjB,wBAAwB;CACxB,aAAa;CACb,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,eAAe;CACf,eAAe;CACf,mBAAmB;CACnB,QAAQ;CACR,iBAAiB;CAClB;;;;;ACvBD,MAAM,6BAA6B;;AAGnC,MAAM,mBAAmB;;AAuCzB,MAAMA,YAAmE;CACvE;EAAE,IAAI;EAAS,MAAM;EAAmB;CACxC;EAAE,IAAI;EAAU,M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G,MAAM,aAAa,IAAI,IAAI,aAAa;CACxC,MAAM,IAAI,IAAI,OAAO,KAAK,GAAG;CAC7B,MAAM,kBAAgD;EAAE,KAAK,WAAW;EAAK;EAAG;AAChF,KAAI,MAAM,OAAO,0BAA0B,IAAI,MAAM,SAAS;EAC5D,MAAM;EACN,IAAI;EACJ,OAAO;EAEP,aAAa,EAAE,MAAM;EACrB,QAAQ;EACT,EAAE,qBAAqB,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ /**
2
+ * dsh-plugin-subscriptions: register OAuth-subscription LLM providers
3
+ * (ChatGPT/Codex, Claude, Grok) on `ctx.llm`, and expose the `/subscriptions-auth`
4
+ * RPC channel the web Settings page uses to run the logins. The token store
5
+ * lives at `~/.dsh/plugins/subscriptions/auth.json`; the channel registers only when
6
+ * a host `connection` service exists, so headless compositions load fine.
7
+ * @module dsh-plugin-subscriptions
8
+ */
9
+ import type { Context } from '@deepseek-ai/cordis';
10
+ import z from '@deepseek-ai/schemastery';
11
+ import type { ProviderId } from './auth/store.js';
12
+ import type { ModelEntry } from './providers/common.js';
13
+ export type { ModelEntry } from './providers/common.js';
14
+ export type { ProviderStatus } from './auth/rpc.js';
15
+ export type { ClaudeSession, CodexSession, GrokSession, ProviderId } from './auth/store.js';
16
+ export declare const name = "dsh-plugin-subscriptions";
17
+ export declare const inject: string[];
18
+ /** Default maximum provider idle time while one stream read is outstanding. */
19
+ export declare const DEFAULT_STREAM_IDLE_TIMEOUT_MS = 300000;
20
+ /** Plugin config, validated by the same-named schemastery schema. */
21
+ export interface Config {
22
+ /** Provider routes to register; defaults to all three. */
23
+ providers?: ProviderId[];
24
+ /** Maximum provider idle time while one stream read is outstanding (default five minutes). */
25
+ streamIdleTimeoutMs?: number;
26
+ /** Advisory model catalogs overriding the built-in defaults, per provider. */
27
+ models?: {
28
+ codex?: ModelEntry[];
29
+ claude?: ModelEntry[];
30
+ grok?: ModelEntry[];
31
+ };
32
+ }
33
+ export declare const Config: z<Config>;
34
+ export declare function apply(ctx: Context, config: Config): void;