@goodandready/dsh-subscriptions 0.7.47 → 0.7.49

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.
@@ -69,6 +69,10 @@ export function createUsageLoader({ load } = {}) {
69
69
  }
70
70
  }
71
71
 
72
+ export function supportsFastTier(model) {
73
+ return /(?:^|[-_.])(gpt-5|gpt-6|codex|o3|o4)(?:[-_.]|$)/i.test(String(model || ''))
74
+ }
75
+
72
76
  /** #802: explicit child choice > subagent default > session choice > global. */
73
77
  export function resolveSpeed({ childSpeed, sessionSpeed, subagentSpeed, modelSupportsFast = true } = {}) {
74
78
  const pick = [childSpeed, subagentSpeed, sessionSpeed].find((value) => value === 'standard' || value === 'fast')
package/lib/accounts.js CHANGED
@@ -51,6 +51,7 @@ import { recordSwitch, recordExhaust, recordBroken, computeHealthScore, healthBa
51
51
  import { executeWithRetry } from './backoff.js'
52
52
  import { getVendor } from './vendors/index.js'
53
53
  import { versionForProvider } from './client-version-service.js'
54
+ import { writeClaudeKeychain } from './claude-keychain.js'
54
55
 
55
56
  const SKEW_MS = 60 * 1000
56
57
  const USAGE_TTL_MS = 2 * 60 * 1000
@@ -508,6 +509,9 @@ export function createAccountStore({ credentials, getConfig, fetchImpl, fetchFor
508
509
  accountId: next.accountId || blob.accountId,
509
510
  }
510
511
  if (ref) await saveBlob(ref, merged)
512
+ if (ref && provider === 'claude' && blob.accessToken && merged.accessToken !== blob.accessToken) {
513
+ writeClaudeKeychain(merged, blob.accessToken).catch(() => {})
514
+ }
511
515
  if (ref) refreshFailures.delete(ref)
512
516
  return merged
513
517
  } catch (e) {
@@ -56,6 +56,7 @@ export function createAdapterManager({
56
56
  switchAtRemaining: () => live().switchAtRemaining,
57
57
  rotationStrategy: () => live().rotationStrategy,
58
58
  modelAccountRules: () => live().modelAccountRules || [],
59
+ subagentSpeed: () => live().codexSubagentSpeed,
59
60
  rateLimitWait: () => live().rateLimitWait,
60
61
  rateLimitMaxWaitMs: () => live().rateLimitMaxWaitMs,
61
62
  enableSoftFailureSentinel: () => live().enableSoftFailureSentinel,
package/lib/adapter.js CHANGED
@@ -6,6 +6,7 @@ import { LlmAdapter, LlmError, attributionHeaders } from '@deepseek-ai/dsh-llm'
6
6
  import { displayName } from './refs.js'
7
7
  import { applyModelSettings, bestAccountPlan } from './model-settings.js'
8
8
  import { getSpeedMode } from './speed-mode.js'
9
+ import { resolveSpeed, supportsFastTier } from './account-features.js'
9
10
  import { getVendor } from './vendors/index.js'
10
11
  import { modelCatalog } from './messages.js'
11
12
  import { streamWithRotation } from './stream-rotate.js'
@@ -203,9 +204,17 @@ export class SubscriptionAdapter extends LlmAdapter {
203
204
  }
204
205
  const poolEnabled = typeof deps.poolEnabled === 'function' ? deps.poolEnabled() !== false : true
205
206
  const defaultRef = typeof deps.defaultAccountRef === 'function' ? deps.defaultAccountRef(provider) : null
207
+ const effectiveSpeed = provider === 'codex'
208
+ ? resolveSpeed({
209
+ childSpeed: options.speed,
210
+ sessionSpeed: getSpeedMode(sessionId),
211
+ subagentSpeed: (options.subagent || options.parentSessionId) && typeof deps.subagentSpeed === 'function' ? deps.subagentSpeed() : undefined,
212
+ modelSupportsFast: supportsFastTier(options.model),
213
+ })
214
+ : 'standard'
206
215
  const streamOptions = {
207
216
  ...hydratedOptions,
208
- ...(provider === 'codex' && getSpeedMode(sessionId) === 'fast' ? { service_tier: 'priority' } : {}),
217
+ ...(provider === 'codex' && effectiveSpeed === 'fast' ? { service_tier: 'priority' } : {}),
209
218
  ...(effectiveReasoning.effort ? { reasoningEffort: effectiveReasoning.effort } : {}),
210
219
  ...(effectiveReasoning.budgetTokens ? { thinkingBudget: effectiveReasoning.budgetTokens } : {}),
211
220
  // #830: kill switch. With no default account, use a sentinel that
package/lib/client.js CHANGED
@@ -1089,6 +1089,7 @@ window.__ModuleLoader__.load({
1089
1089
  const ProviderPacksPanel = lazyPanel('ProviderPacksPanel')
1090
1090
  const SourcesPanel = lazyPanel('SourcesPanel')
1091
1091
  const AccountsDashboardPanel = lazyPanel('AccountsDashboardPanel')
1092
+ const SpeedToggle = lazyPanel('SpeedToggle')
1092
1093
 
1093
1094
  // #839 model-list helpers
1094
1095
  function modelListSearchText(model) {
@@ -3900,6 +3901,17 @@ h('div', { className: 'dsub-row' },
3900
3901
  }, 'dsh-subscriptions: locales')
3901
3902
  setT(ctx.locale.bind(NS))
3902
3903
 
3904
+ ctx.effect(() => {
3905
+ if (!ctx.slots || typeof ctx.slots.inject !== 'function') return () => {}
3906
+ return ctx.slots.inject('conversation.input.right', () => ctx.slots.register({
3907
+ name: 'conversation.input.right',
3908
+ id: 'subscriptions-speed',
3909
+ order: 50,
3910
+ locale: NS,
3911
+ inject: () => ({}),
3912
+ }, SpeedToggle))
3913
+ }, 'dsh-subscriptions: composer speed toggle')
3914
+
3903
3915
  ctx.effect(() => {
3904
3916
  const cleanups = []
3905
3917
  const registerLegacySeats = () => {
@@ -280,8 +280,8 @@ window.__ModuleLoader__.load({
280
280
  h('div', { className: 'dsub-row' },
281
281
  h('span', { className: 'dsub-h' }, '#' + row.index + ' ' + (row.label || row.email || row.ref)),
282
282
  h('span', { className: 'dsub-pillTag' }, row.quarantineUntil > Date.now() ? t('statusQuarantined') : (row.cooldownUntil > Date.now() ? t('statusCooling') : t('statusHealthy')))),
283
- h('div', { className: 'dsub-sub' }, t('quotaUsed') + ': ' + (row.usagePercent == null ? '—' : row.usagePercent + '%') + ' · ' + t('requests') + ' ' + (row.requests || 0) + ' · ' + t('errors') + ' ' + (row.errors || 0)),
284
- h('div', { className: 'dsub-row' },
283
+ compact ? null : h('div', { className: 'dsub-sub' }, t('quotaUsed') + ': ' + (row.usagePercent == null ? '—' : row.usagePercent + '%') + ' · ' + t('requests') + ' ' + (row.requests || 0) + ' · ' + t('errors') + ' ' + (row.errors || 0)),
284
+ compact ? null : h('div', { className: 'dsub-row' },
285
285
  h('button', { type: 'button', className: 'dsub-mini', onClick: () => loadUsage(row) }, u && u.loading ? '…' : t('loadUsage')),
286
286
  u && u.error ? h('span', { className: 'dsub-bad' }, u.error) : null,
287
287
  u && u.value ? h('span', { className: 'dsub-dim' }, JSON.stringify(u.value).slice(0, 180)) : null),
@@ -337,6 +337,33 @@ window.__ModuleLoader__.load({
337
337
  )
338
338
  }
339
339
 
340
- return { WebhookTestButton, VaultSnapshotsPanel, ProviderPacksPanel, SourcesPanel, AccountsDashboardPanel }
340
+ // #802: composer Speed toggle, scoped to the current session.
341
+ function SpeedToggle(props) {
342
+ const sessionId = (props && (props.sessionId || (props.session && props.session.id))) || 'default'
343
+ const [mode, setMode] = React.useState('standard')
344
+ React.useEffect(() => {
345
+ fetch('/dsh-subscriptions/speed?sessionId=' + encodeURIComponent(sessionId), { cache: 'no-store' })
346
+ .then((res) => res.json())
347
+ .then((out) => setMode((out && out.mode) || 'standard'))
348
+ .catch(() => {})
349
+ }, [sessionId])
350
+ const toggle = () => {
351
+ const next = mode === 'fast' ? 'standard' : 'fast'
352
+ setMode(next)
353
+ fetch('/dsh-subscriptions/speed', {
354
+ method: 'POST',
355
+ headers: { 'content-type': 'application/json' },
356
+ body: JSON.stringify({ sessionId, mode: next }),
357
+ }).then((res) => res.json()).then((out) => { if (out && out.mode) setMode(out.mode) }).catch(() => {})
358
+ }
359
+ return h('button', {
360
+ type: 'button',
361
+ className: 'dsub-mini',
362
+ title: 'Codex Speed',
363
+ onClick: toggle,
364
+ }, mode === 'fast' ? '⚡ FAST' : 'Speed')
365
+ }
366
+
367
+ return { WebhookTestButton, VaultSnapshotsPanel, ProviderPacksPanel, SourcesPanel, AccountsDashboardPanel, SpeedToggle }
341
368
  }
342
369
  })
package/lib/images.js CHANGED
@@ -28,7 +28,7 @@ const GROK_ASPECT = {
28
28
  auto: 'auto',
29
29
  }
30
30
 
31
- export function codexBody({ prompt, size, quality }) {
31
+ export function codexBody({ prompt, size, quality, referenceImages = [] }) {
32
32
  const text = String(prompt || '').trim()
33
33
  if (!text) throw new Error('prompt must be a non-empty string')
34
34
  return {
@@ -36,10 +36,13 @@ export function codexBody({ prompt, size, quality }) {
36
36
  model: CODEX_MODEL,
37
37
  ...(size ? { size } : {}),
38
38
  ...(quality ? { quality } : {}),
39
+ ...(Array.isArray(referenceImages) && referenceImages.length
40
+ ? { images: referenceImages.map((ref) => ({ image_url: ref })) }
41
+ : {}),
39
42
  }
40
43
  }
41
44
 
42
- export function grokBody({ prompt, size, quality }) {
45
+ export function grokBody({ prompt, size, quality, referenceImages = [] }) {
43
46
  const text = String(prompt || '').trim()
44
47
  if (!text) throw new Error('prompt must be a non-empty string')
45
48
  // Grok has only two quality tiers: high is composed from medium.
@@ -52,6 +55,7 @@ export function grokBody({ prompt, size, quality }) {
52
55
  response_format: 'b64_json',
53
56
  ...(size && GROK_ASPECT[size] ? { aspect_ratio: GROK_ASPECT[size] } : {}),
54
57
  ...(level ? { quality: level } : {}),
58
+ ...(Array.isArray(referenceImages) && referenceImages.length ? { image_urls: referenceImages } : {}),
55
59
  }
56
60
  }
57
61
 
package/lib/index.js CHANGED
@@ -471,6 +471,7 @@ export function apply(ctx, rawConfig) {
471
471
  prompt: request.prompt,
472
472
  size: request.size,
473
473
  quality: request.quality,
474
+ referenceImages: request.referenceImages,
474
475
  session,
475
476
  fetchImpl: fetchFn,
476
477
  signal: request.signal,
@@ -1,5 +1,6 @@
1
1
  import { mkdir, writeFile } from 'node:fs/promises'
2
2
  import path from 'node:path'
3
+ import { validateReferenceImages } from './media-reference.js'
3
4
 
4
5
  const TOOL_OUTPUT = {
5
6
  schema: {
@@ -86,12 +87,15 @@ export function registerSubscriptionTools(ctx, deps, options = {}) {
86
87
  provider: { type: 'string', enum: ['gpt', 'codex', 'grok'], description: 'Preferred provider' },
87
88
  size: { type: 'string', description: 'Image size, e.g. 1024x1024' },
88
89
  quality: { type: 'string', description: 'low, medium or high' },
90
+ referenceImages: { type: 'array', items: { type: 'string' }, maxItems: 5, description: '1–5 attachment refs for image editing' },
89
91
  },
90
92
  required: ['prompt'],
91
93
  },
92
94
  async execute(args, exec) {
93
95
  const images = deps.images && deps.images()
94
96
  if (!images || typeof images.generate !== 'function') throw new Error('subscription image service is unavailable')
97
+ const references = validateReferenceImages(args && args.referenceImages)
98
+ if (!references.ok) throw new Error(references.error)
95
99
  const preferred = String((args && args.provider) || 'gpt').toLowerCase()
96
100
  const order = preferred === 'grok' ? ['grok', 'codex'] : ['codex', 'grok']
97
101
  let lastError = null
@@ -102,6 +106,7 @@ export function registerSubscriptionTools(ctx, deps, options = {}) {
102
106
  prompt: args && args.prompt,
103
107
  size: args && args.size,
104
108
  quality: args && args.quality,
109
+ referenceImages: references.refs,
105
110
  signal: exec && exec.signal,
106
111
  })
107
112
  const files = await saveImages(rows, exec)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-subscriptions",
3
- "version": "0.7.47",
3
+ "version": "0.7.49",
4
4
  "description": "Use ChatGPT Codex, Claude, Grok, Antigravity, Kimi, GLM, Cursor, Kiro, Copilot, Qwen, ERNIE, Spark, JetBrains, Perplexity, Replit, and Cody subscriptions as DeepSeek Harness LLM providers via OAuth.",
5
5
  "license": "MIT",
6
6
  "type": "module",