@gatemux/dsh-gatemux-login-core 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/account.js +48 -25
  2. package/package.json +17 -17
  3. package/search.js +26 -0
package/account.js CHANGED
@@ -251,7 +251,7 @@ export class GateMuxAccount extends DeepSeekAccount {
251
251
  ctx.on('credentials/record-updated', (key) => {
252
252
  if (key !== KEY) return
253
253
  this.invalidateDetails()
254
- this.changed()
254
+ this.changed('credentials-changed')
255
255
  })
256
256
  ctx.effect(() => async () => {
257
257
  this.closed = true
@@ -333,21 +333,14 @@ export class GateMuxAccount extends DeepSeekAccount {
333
333
  return { status: 'ready', value: [{ currency, balance }], bonusWallets: [] }
334
334
  }
335
335
 
336
- /** GateMux grants no campaign bonuses; the contract reports an empty batch. */
337
- async getUnnotifiedBonuses(client) {
338
- const lifetime = this.detailsLifetime
339
- const grant = await this.readGrant(lifetime)
340
- if (grant === null || lifetime.signal.aborted) return null
341
- const profile = this.lastProfile?.token === grant.accessToken ? this.lastProfile.profile : null
342
- const accountId = profile?.id ?? (await this.getProfile(client))?.value?.id ?? null
343
- if (accountId === null) return null
344
- return { accountId, bonuses: [] }
345
- }
336
+ /** GateMux has no notification feed; the account UI shows none. */
337
+ async getNotifications() { return null }
346
338
 
347
- /** No bonus can be acknowledged because none is ever granted. */
348
- async ackBonusNotified() {
349
- return false
350
- }
339
+ /** GateMux has no notification content. */
340
+ async getNotificationContent() { return null }
341
+
342
+ /** GateMux has no notification events to report. */
343
+ async reportNotificationEvent() { return false }
351
344
 
352
345
  async startSignIn(_client, callbackOrigin, loginSource) {
353
346
  if (this.removing !== undefined) await this.removing
@@ -357,6 +350,16 @@ export class GateMuxAccount extends DeepSeekAccount {
357
350
  if (active !== undefined && ['initializing', 'waiting-browser', 'exchanging', 'committing'].includes(active.view.phase)) {
358
351
  return this.getState()
359
352
  }
353
+ // A failed or cancelled attempt still owns the `/callback` route until its
354
+ // cleanup runs. Starting the next attempt without awaiting it registers the
355
+ // same route twice and the web server rejects the sign-in, which the account
356
+ // UI reports as "please retry". The concrete 0.2.2 service awaits the
357
+ // previous attempt the same way.
358
+ if (active !== undefined) {
359
+ await active.done
360
+ if (this.closed) throw new GateMuxAuthError('provider is closed', 'protocol')
361
+ if (this.attempt !== active) return this.getState()
362
+ }
360
363
  const attempt = {
361
364
  origin,
362
365
  loginSource,
@@ -432,26 +435,45 @@ export class GateMuxAccount extends DeepSeekAccount {
432
435
  }
433
436
  this.attempt = undefined
434
437
  this.ctx.emit('deepseek-account/signed-out')
435
- this.changed()
438
+ this.changed('credentials-changed')
436
439
  return this.getState()
437
440
  })().finally(() => { this.removing = undefined })
438
441
  return this.removing
439
442
  }
440
443
 
441
- async *watch(signal) {
442
- let dirty = true
444
+ /**
445
+ * Host-side update stream in the DSH 0.2.2 `AccountUpdate` shape. The concrete
446
+ * service's Remote `watchState` uses its own observer; this keeps Host consumers
447
+ * on the same shape as the new base class.
448
+ * @param signal - subscription lifetime.
449
+ * @param includeIdentityChanges - also emit identity-only profile changes.
450
+ */
451
+ async *watch(signal, includeIdentityChanges = false) {
452
+ let pending = 'snapshot'
443
453
  let wake
444
- const changed = () => { dirty = true; wake?.() }
454
+ const abort = () => { wake?.() }
455
+ const changed = (kind = 'snapshot') => {
456
+ if (kind === 'identity' && !includeIdentityChanges) return
457
+ if (kind === 'credentials-changed' || pending === undefined) {
458
+ pending = kind === 'credentials-changed' ? 'credentials-changed' : 'snapshot'
459
+ }
460
+ wake?.()
461
+ }
445
462
  this.listeners.add(changed)
446
- signal.addEventListener('abort', changed, { once: true })
463
+ signal.addEventListener('abort', abort, { once: true })
447
464
  try {
448
465
  while (!this.closed && !signal.aborted) {
449
- if (dirty) { dirty = false; yield await this.getState(); continue }
466
+ if (pending !== undefined) {
467
+ const type = pending
468
+ pending = undefined
469
+ yield { type, state: await this.getState() }
470
+ continue
471
+ }
450
472
  await new Promise((resolve) => { wake = resolve })
451
473
  }
452
474
  } finally {
453
475
  this.listeners.delete(changed)
454
- signal.removeEventListener('abort', changed)
476
+ signal.removeEventListener('abort', abort)
455
477
  }
456
478
  }
457
479
 
@@ -659,6 +681,7 @@ export class GateMuxAccount extends DeepSeekAccount {
659
681
  ? { kind: 'grant', payload: next }
660
682
  : undefined,
661
683
  ))
684
+ this.changed('credentials-changed')
662
685
  return next
663
686
  }
664
687
 
@@ -737,7 +760,7 @@ export class GateMuxAccount extends DeepSeekAccount {
737
760
  cacheProfile(token, profile) {
738
761
  const previous = this.lastProfile?.profile.id ?? null
739
762
  this.lastProfile = { token, profile }
740
- if (previous !== profile.id) this.changed()
763
+ if (previous !== profile.id) this.changed('identity')
741
764
  }
742
765
 
743
766
  async readGrant(lifetime) {
@@ -762,7 +785,7 @@ export class GateMuxAccount extends DeepSeekAccount {
762
785
  this.ctx.emit('deepseek-account/session-expired')
763
786
  this.attempt = undefined
764
787
  this.ctx.emit('deepseek-account/signed-out')
765
- this.changed()
788
+ this.changed('credentials-changed')
766
789
  return this.getState()
767
790
  })().finally(() => { this.removing = undefined })
768
791
  await this.removing
@@ -790,7 +813,7 @@ export class GateMuxAccount extends DeepSeekAccount {
790
813
  this.detailsLifetime = new AbortController()
791
814
  }
792
815
 
793
- changed() { for (const listener of this.listeners) listener() }
816
+ changed(kind = 'snapshot') { for (const listener of this.listeners) listener(kind) }
794
817
 
795
818
  update(attempt, value) {
796
819
  const { authorizeUrl: _url, ...rest } = attempt.view
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gatemux/dsh-gatemux-login-core",
3
- "version": "1.1.3",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "GateMux account provider and model route for DeepSeek Harness. Shared code; install a region bundle instead of this package.",
6
6
  "publishConfig": {
@@ -24,26 +24,26 @@
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@deepseek-ai/cordis": "^4.0.4",
27
- "@deepseek-ai/dsh-authorization": "^0.1.7-rc.2 || ^0.2.0-rc.2",
28
- "@deepseek-ai/dsh-credentials": "^0.1.7-rc.2 || ^0.2.0-rc.2",
29
- "@deepseek-ai/dsh-deepseek-account": "^0.1.7-rc.2 || ^0.2.0-rc.2",
30
- "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2 || ^0.2.0-rc.2",
31
- "@deepseek-ai/dsh-launch-environment": "^0.1.7-rc.2 || ^0.2.0-rc.2",
32
- "@deepseek-ai/dsh-llm": "^0.1.7-rc.2 || ^0.2.0-rc.2",
33
- "@deepseek-ai/dsh-llm-deepseek": "^0.1.7-rc.2 || ^0.2.0-rc.2",
34
- "@deepseek-ai/dsh-web": "^0.1.7-rc.2 || ^0.2.0-rc.2",
27
+ "@deepseek-ai/dsh-authorization": "^0.2.2-rc.2",
28
+ "@deepseek-ai/dsh-credentials": "^0.2.2-rc.2",
29
+ "@deepseek-ai/dsh-deepseek-account": "^0.2.2-rc.2",
30
+ "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
31
+ "@deepseek-ai/dsh-launch-environment": "^0.2.2-rc.2",
32
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.2",
33
+ "@deepseek-ai/dsh-llm-deepseek": "^0.2.2-rc.2",
34
+ "@deepseek-ai/dsh-web": "^0.2.2-rc.2",
35
35
  "@deepseek-ai/schemastery": "^3.18.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@deepseek-ai/cordis": "^4.0.4",
39
- "@deepseek-ai/dsh-authorization": "^0.1.7-rc.2 || ^0.2.0-rc.2",
40
- "@deepseek-ai/dsh-credentials": "^0.1.7-rc.2 || ^0.2.0-rc.2",
41
- "@deepseek-ai/dsh-deepseek-account": "^0.1.7-rc.2 || ^0.2.0-rc.2",
42
- "@deepseek-ai/dsh-host-webserver": "^0.1.7-rc.2 || ^0.2.0-rc.2",
43
- "@deepseek-ai/dsh-launch-environment": "^0.1.7-rc.2 || ^0.2.0-rc.2",
44
- "@deepseek-ai/dsh-llm": "^0.1.7-rc.2 || ^0.2.0-rc.2",
45
- "@deepseek-ai/dsh-llm-deepseek": "^0.1.7-rc.2 || ^0.2.0-rc.2",
46
- "@deepseek-ai/dsh-web": "^0.1.7-rc.2 || ^0.2.0-rc.2",
39
+ "@deepseek-ai/dsh-authorization": "^0.2.2-rc.2",
40
+ "@deepseek-ai/dsh-credentials": "^0.2.2-rc.2",
41
+ "@deepseek-ai/dsh-deepseek-account": "^0.2.2-rc.2",
42
+ "@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.2",
43
+ "@deepseek-ai/dsh-launch-environment": "^0.2.2-rc.2",
44
+ "@deepseek-ai/dsh-llm": "^0.2.2-rc.2",
45
+ "@deepseek-ai/dsh-llm-deepseek": "^0.2.2-rc.2",
46
+ "@deepseek-ai/dsh-web": "^0.2.2-rc.2",
47
47
  "@deepseek-ai/schemastery": "^3.18.4"
48
48
  }
49
49
  }
package/search.js CHANGED
@@ -109,6 +109,21 @@ export class GateMuxSearchProvider {
109
109
  /** Stable id selected by the `web` row. */
110
110
  id = PROVIDER
111
111
 
112
+ /** Picker label; the bare id reads as a route name rather than a search backend. */
113
+ title = 'GateMux (account)'
114
+
115
+ /** Picker description: what this provider suits and what it costs or cannot do. */
116
+ description = {
117
+ en: "Runs GateMux's native server-side web search (the Anthropic web_search tool) through the signed-in GateMux account; every search bills the same GateMux balance. Requires signing in.",
118
+ zh: '通过已登录的 GateMux 账号执行 GateMux 原生服务端网页搜索(Anthropic web_search 工具),每次搜索计入同一 GateMux 余额。需先登录。',
119
+ ja: 'サインイン済みの GateMux アカウントで GateMux ネイティブのサーバーサイド Web 検索(Anthropic の web_search ツール)を実行し、毎回同じ GateMux 残高に課金されます。サインインが必要です。',
120
+ es: 'Ejecuta la búsqueda web nativa de GateMux (la herramienta web_search de Anthropic) con la cuenta de GateMux iniciada; cada búsqueda se factura en el mismo saldo de GateMux. Requiere iniciar sesión.',
121
+ fr: 'Exécute la recherche web native de GateMux (l\'outil web_search d\'Anthropic) via le compte GateMux connecté ; chaque recherche est facturée sur le même solde GateMux. Connexion requise.',
122
+ de: 'Führt die native serverseitige Websuche von GateMux (das Anthropic-web_search-Tool) über das angemeldete GateMux-Konto aus; jede Suche wird auf dasselbe GateMux-Guthaben gebucht. Anmeldung erforderlich.',
123
+ ru: 'Выполняет собственный серверный веб-поиск GateMux (инструмент web_search Anthropic) через вошедшую учётную запись GateMux; каждый поиск списывается с того же баланса GateMux. Требуется вход.',
124
+ pt: 'Executa a pesquisa web nativa do GateMux (a ferramenta web_search da Anthropic) com a conta GateMux iniciada; cada pesquisa é cobrada do mesmo saldo GateMux. Requer login.',
125
+ }
126
+
112
127
  /**
113
128
  * @param ctx - Host with the optional GateMux account service.
114
129
  * @param config - this row's resolved endpoint, model, and bounds.
@@ -124,6 +139,17 @@ export class GateMuxSearchProvider {
124
139
  return this.ctx.get('deepseekAccount') !== undefined
125
140
  }
126
141
 
142
+ /**
143
+ * Local preflight for operations that ask whether this provider can authenticate:
144
+ * stored grant present and the account service loaded; never touches the network.
145
+ * @returns false when a search would have to fail with sign-in-required.
146
+ */
147
+ async ready() {
148
+ const account = this.ctx.get('deepseekAccount')
149
+ if (account === undefined) return false
150
+ return (await account.getState()).status === 'credential-stored'
151
+ }
152
+
127
153
  /**
128
154
  * Run one native search through GateMux.
129
155
  * @param request - the query the conversation model asked for.