@witbitz/sdk 4.4.0 → 4.5.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 (79) hide show
  1. package/README.md +2 -2
  2. package/a2aCore.js +15 -0
  3. package/accountErase.js +9 -3
  4. package/accountIndexDoc.js +24 -7
  5. package/accountRecord.js +6 -2
  6. package/accountStores.js +21 -5
  7. package/acctV2App.js +111 -12
  8. package/acctV2Client.js +11 -1
  9. package/acctV2UiCore.js +27 -7
  10. package/awsKey.js +3 -1
  11. package/backupRecord.js +3 -0
  12. package/codeAttachments.js +1 -0
  13. package/codeCache.js +27 -3
  14. package/codeCloud.js +2 -0
  15. package/codeComputers.js +8 -0
  16. package/codeSent.js +43 -2
  17. package/codeTransport.js +24 -5
  18. package/connections.js +21 -3
  19. package/decrypt.html +69 -9
  20. package/eraseFile.js +15 -0
  21. package/idbSeal.js +5 -2
  22. package/inviteReceive.js +44 -0
  23. package/inviteSend.js +8 -2
  24. package/l1-worker-src.js +1 -1
  25. package/l1-worker.js +30 -14
  26. package/laneAssociation.js +11 -1
  27. package/laneLinkCore.js +9 -0
  28. package/ledgerView.js +30 -4
  29. package/manifest.json +78 -72
  30. package/offlineBundle.js +21 -0
  31. package/package.json +8 -2
  32. package/protectedLocal.js +34 -11
  33. package/reactionHolders.js +86 -0
  34. package/roomIntake.js +324 -0
  35. package/roomRoster.js +9 -2
  36. package/scheduleNext.js +60 -0
  37. package/sdkA2A.js +46 -8
  38. package/sdkAccount.js +71 -14
  39. package/sdkAccountDoc.js +3 -3
  40. package/sdkAccountSections.js +58 -18
  41. package/sdkAgui.js +33 -6
  42. package/sdkBackup.js +21 -6
  43. package/sdkBackupV2.js +15 -3
  44. package/sdkCloudDevice.js +12 -3
  45. package/sdkComputers.js +118 -17
  46. package/sdkDictation.js +1 -1
  47. package/sdkErase.js +3 -1
  48. package/sdkExports.js +15 -6
  49. package/sdkInvitations.js +4 -2
  50. package/sdkKeptAgent.js +19 -3
  51. package/sdkKeptIntake.js +100 -0
  52. package/sdkLaneLink.js +5 -6
  53. package/sdkRekey.js +72 -5
  54. package/sdkSchedules.js +8 -1
  55. package/sdkSpeech.js +14 -1
  56. package/sdkTemporaryRooms.js +2 -1
  57. package/sdkTurn.js +12 -4
  58. package/sharedViews.js +17 -1
  59. package/siri.js +29 -5
  60. package/spaceClient.js +96 -12
  61. package/spaceExport.js +50 -5
  62. package/spaceFork.js +15 -7
  63. package/spaceTemplates.js +2 -2
  64. package/speechOut.js +17 -3
  65. package/store.js +51 -13
  66. package/sw-notif-core.js +2 -1
  67. package/tapTrail.js +58 -0
  68. package/usageReceipts.js +12 -5
  69. package/vault-core.js +90 -16
  70. package/vault-kit.mjs +2 -2
  71. package/vault-screens.js +25 -11
  72. package/vaultAtRest.js +3 -2
  73. package/vaultCoreLock.js +3 -1
  74. package/vaultCorePush.js +58 -7
  75. package/vaultWorkerHost.js +9 -3
  76. package/witbitz-admin.d.ts +3 -0
  77. package/witbitz-admin.mjs +10 -10
  78. package/witbitz-sdk.d.ts +59 -23
  79. package/witbitz-sdk.js +271 -64
@@ -27,7 +27,7 @@ const obj = (x) => (x && typeof x === 'object' && !Array.isArray(x) ? x : null)
27
27
 
28
28
  class Section {
29
29
  /** @param {object} spec { doc, of(doc) → value, apply(doc, change) → the doc to write, or null when nothing moves, calls } */
30
- constructor (ix, spec) { this._ix = ix; this._spec = spec; this._calls = spec.calls; this._val = null; this._master = null; this._used = false; this._fns = new Set(); this._remote = false }
30
+ constructor (ix, spec) { this._ix = ix; this._spec = spec; this._calls = spec.calls; this._val = null; this._master = null; this._used = false; this._fns = new Set(); this._remote = false; this._have = false }
31
31
  /** What this device last read (null before the first read, and for another account). */
32
32
  get value () { if (this._remote) return copy(this._val); const s = this._ix._backup._s; return s && s.master === this._master ? copy(this._val) : null }
33
33
  /** Read it now. */
@@ -36,7 +36,7 @@ class Section {
36
36
  on (ev, fn) { if (ev === 'change' && typeof fn === 'function') { this._fns.add(fn); if (!this._used && this._ix.enabled) this._pass(null).catch(() => null) } return this }
37
37
  off (ev, fn) { this._fns.delete(fn); return this }
38
38
  _seen (v, fire = false) { const was = this._val; this._remote = true; this._val = v; if (fire && canon(was) !== canon(v)) this._fire(v) } // in a vault: what the vault read
39
- _fire (v) { for (const fn of this._fns) { try { fn(copy(v)) } catch { /* the app's callback */ } } }
39
+ _fire (v) { for (const fn of [...this._fns]) { try { fn(copy(v)) } catch { /* the app's callback */ } } } // a copy of the set: a listener that rebinds itself must not hear this change twice
40
40
  async _pass (change) {
41
41
  const ix = this._ix, d = this._spec.doc
42
42
  if (!ix.enabled) throw fail('not_enabled', 'turn the account on first (wb.backup.enable or restore)')
@@ -44,20 +44,24 @@ class Section {
44
44
  const s0 = ix._backup._s, moved = () => { if (ix._backup._s !== s0) throw fail('account_changed', 'the account changed on this device during the call') }
45
45
  for (let i = 0; i < 5; i++) {
46
46
  const loc = await ix._where(); moved()
47
- if (this._master !== loc.master) { this._master = loc.master; this._val = null }
47
+ if (this._master !== loc.master) { this._master = loc.master; this._val = null; this._have = false }
48
48
  if (!loc.made && !(s0.device && s0.device.made)) { await ix._ensureRoom(loc); moved() } // the index room, made once (as the sync does)
49
49
  const got = await ix._read(loc, d, loc.app); moved()
50
50
  if (!got.ok) throw fail(got.unopenable ? 'unopenable' : 'unreadable', `the account's ${d} could not be ${got.unopenable ? 'opened' : 'read'}`, { status: got.status })
51
51
  const next = change === null ? null : this._spec.apply(got.doc, change)
52
52
  if (next) {
53
- const w = await ix._client().state(loc.room, loc.mk, d, await sealDoc(loc.app, next), 'account ' + d, 'device', got.v); moved()
53
+ const sealed = await sealDoc(loc.app, next)
54
+ // a dropped connection is a failed save too, with the same code as a refused one (side sweep 2026-11-28: it threw uncoded / vault_error)
55
+ let w; try { w = await ix._client().state(loc.room, loc.mk, d, sealed, 'account ' + d, 'device', got.v) } catch (e) { moved(); if (e && e.code) throw e; throw fail('save_failed', `the account's ${d} could not be saved`, { status: 0 }) } // a coded refusal (sign_in_required, …) stays itself; only a dropped transport becomes save_failed
56
+ moved()
54
57
  if (w && w.status === 409) { await new Promise((r) => setTimeout(r, 10 + Math.floor(Math.random() * 40) * (i + 1))); continue } // another device wrote: merge over it
55
58
  if (!w || w.status !== 200) throw fail('save_failed', `the account's ${d} could not be saved`, { status: w && w.status })
56
- this._val = this._spec.of(next); return copy(this._val)
59
+ this._val = this._spec.of(next); this._have = true; return copy(this._val)
57
60
  }
58
- const was = this._val, now = this._spec.of(got.doc)
59
- this._val = now
60
- if (was !== null && canon(was) !== canon(now)) this._fire(now)
61
+ const was = this._val, had = this._have, now = this._spec.of(got.doc)
62
+ this._val = now; this._have = true
63
+ // after a first read, even of an empty section (null), another device's first value is a change (side sweep 2026-11-28: it arrived silently)
64
+ if (had && canon(was) !== canon(now)) this._fire(now)
61
65
  return copy(now)
62
66
  }
63
67
  throw fail('save_failed', `the account's ${d} kept changing under this device — try again`, { status: 409 })
@@ -102,8 +106,11 @@ const withContacts = (doc, rows) => {
102
106
  }
103
107
  const live = (list) => list && list.filter((c) => !c.deleted).map(({ deleted: _d, ...c }) => c)
104
108
  // one row, stamped against the list each try read: newer than any copy of it (the app's LWW), a removal its tombstone
109
+ // the same person by either address: a row keyed by its email is found by its @username too, as the app's forgetContact finds it
110
+ // (side sweep 2026-11-28: remove({ username }) of a row with an email wrote no tombstone)
111
+ const samePerson = (x, c) => contactKey(x) === contactKey(c) || (x.kind !== 'agent' && c.kind !== 'agent' && ((!!c.username && x.username === c.username) || (!!c.email && x.email === c.email)))
105
112
  const stamped = (c, gone) => (cur) => {
106
- const ex = cur.find((x) => contactKey(x) === contactKey(c))
113
+ const ex = cur.find((x) => samePerson(x, c))
107
114
  if (gone && !ex) return []
108
115
  return [{ ...(gone ? ex : c), ...(gone ? { deleted: true } : {}), at: Math.max(Date.now(), ((ex && ex.at) || 0) + 1) }]
109
116
  }
@@ -112,7 +119,7 @@ class Contacts extends Section {
112
119
  constructor (ix) { super(ix, { doc: 'xindex2', of: contactsOf, calls: ['get', 'set', 'remove', 'merge'], apply: (doc, rows) => withContacts(doc, typeof rows === 'function' ? rows(contactsOf(doc)) : rows) }) }
113
120
  get value () { return live(super.value) }
114
121
  async get () { return live(await super.get()) }
115
- _fire (v) { super._fire(live(v)) } // the app keeps a removal as a row; the builder sees the people
122
+ _fire (v) { super._fire(live(v) || []) } // the app keeps a removal as a row; the builder sees the people (a sign-out: [] — side sweep 2026-11-28, it sent null)
116
123
  /** Add or edit one contact ({ email | username, fn?, tel? } or a saved assistant { kind: 'agent', id, fn, persona? }); it wins over older copies. */
117
124
  async set (contact) { return live(await this._pass(stamped(oneContact(contact), false))) }
118
125
  /** Remove one (by its email, @username or assistant id) on every device — the app's tombstone row. */
@@ -124,7 +131,8 @@ class Contacts extends Section {
124
131
  // ── name: xindex.name ──
125
132
  class Name extends Section {
126
133
  constructor (ix) { super(ix, { doc: 'xindex', of: (doc) => (obj(doc) && typeof doc.name === 'string' ? doc.name : ''), calls: ['get', 'set'],
127
- apply: (doc, name) => (obj(doc) && doc.name === name ? null : { v: 2, rooms: {}, devices: {}, signouts: {}, ...(obj(doc) || {}), name, at: Date.now() }) }) }
134
+ apply: (doc, name) => (obj(doc) && doc.name === name ? null : { v: 2, rooms: {}, devices: {}, signouts: {}, ...(obj(doc) || {}), name, nameAt: Date.now(), at: Date.now() }) }) } // nameAt: when the name was typed — the app keeps the newer name by it (side sweep: app-index-push-reverts-account-display-name)
135
+ _fire (v) { super._fire(typeof v === 'string' ? v : '') } // a sign-out clears it to '' (side sweep 2026-11-28: null, which the type excludes)
128
136
  /** The person's name, for every device of the account (the app keeps 24 characters). An empty name is refused, as the app never writes one over a name. */
129
137
  async set (name) { const n = String(typeof name === 'string' ? name : '').trim().slice(0, 24); if (!n) throw fail('invalid_argument', 'a name is needed'); return this._pass(n) }
130
138
  }
@@ -134,7 +142,12 @@ const memStore = (v) => { const m = new Map(v ? [['space:default-room', JSON.str
134
142
  const optionsOf = (doc) => { const c = cleanRoomDefaults(doc); if (!c) return null; const { v: _v, mods: _m, ...o } = c; return o }
135
143
  class RoomDefaults extends Section {
136
144
  constructor (ix) { super(ix, { doc: 'x' + ROOM_DEFAULTS_DOC, of: optionsOf, calls: ['get', 'set'],
137
- apply: (doc, patch) => { const cur = cleanRoomDefaults(doc), next = writeRoomDefaults(patch, {}, memStore(cur), Date.now()); return next && canon(optionsOf(next)) !== canon(optionsOf(cur)) ? next : null } }) }
145
+ apply: (doc, patch) => {
146
+ const cur = cleanRoomDefaults(doc)
147
+ // a doc this SDK cannot read (a newer app's version) is never replaced by the patch alone (side sweep 2026-11-28), as the app's sync refuses it
148
+ // — nor one whose version is not 1 at all (0, a string): only a v:1 doc with no options is an empty one to fill
149
+ if (!cur && obj(doc) && doc.v !== 1 && Object.keys(doc).length) throw fail('unreadable', "the account's room defaults are in a format this app cannot read — nothing was written")
150
+ const next = writeRoomDefaults(patch, {}, memStore(cur), Date.now()); return next && canon(optionsOf(next)) !== canon(optionsOf(cur)) ? next : null } }) }
138
151
  /** Change some of the New-Space defaults ({ quick, enclave, verified, lanes, temporary }: booleans; { assistant, model }: strings).
139
152
  * `verified` is kept for older apps: today's app makes every new Space verified and ignores it (sync sweep 11-21 #11). */
140
153
  async set (patch) {
@@ -156,7 +169,7 @@ class Blocks extends Section {
156
169
  constructor (ix) { super(ix, { doc: 'x' + BLOCKS_DOC, of: blocksOf, calls: ['get', 'block', 'unblock', 'merge'], apply: (doc, add) => withBlocks(doc, typeof add === 'function' ? add(blocksOf(doc)) : add) }) }
157
170
  get value () { return liveBlocks(super.value) }
158
171
  async get () { return liveBlocks(await super.get()) }
159
- _fire (v) { super._fire(liveBlocks(v)) } // the app keeps an unblock as a row; the builder sees who is blocked
172
+ _fire (v) { super._fire(liveBlocks(v) || []) } // the app keeps an unblock as a row; the builder sees who is blocked (a sign-out: [])
160
173
  /** Block a person on every device of the account ({ email?, user?, room?, sid?, name? } — space.blockIdentity(message), plus the name to show). */
161
174
  async block (who) { const w = oneWho(who); return liveBlocks(await this._pass((cur) => [{ ...w, at: nextAt(cur) }])) }
162
175
  /** Unblock: every live entry that names them by any proof goes, kept as a tombstone so another device does not bring them back. */
@@ -175,13 +188,24 @@ class ChatLocks extends Section {
175
188
  constructor(ix) { super(ix, { doc: 'x' + CHAT_LOCKS_DOC, of: cleanChatLocks, calls: ['get', 'merge', 'set', 'remove', 'check', 'match', 'changePin', 'previewDeleteAll', 'deleteAll'], apply: (doc, incoming) => { const next = typeof incoming === 'function' ? incoming(cleanChatLocks(doc)) : mergeChatLocks(doc, incoming); return canon(next) === canon(cleanChatLocks(doc)) ? null : next } }) }
176
189
  async merge(doc) {
177
190
  const clean = cleanChatLocks(doc); if (!clean) throw fail('invalid_argument', 'chatLocks.merge needs a chat-locks document')
178
- return this._write(clean)
191
+ return this._write(clean, { retryMarker: true }) // the presence mark retried at the next sync, as the removal does (side sweep 2026-11-28)
179
192
  }
180
193
  async set({ kind, target, pin, title } = {}) {
181
194
  if (!['room', 'code'].includes(kind) || typeof target !== 'string' || !target || target.length > 300 || !validPin(pin)) throw fail('invalid_argument', 'chatLocks.set needs kind, target and a PIN of 4–12 digits')
182
195
  const s0 = this._ix._backup._s, salt = saltsOf(await this.get())[0] || newSalt(), fingerprint = await pinIdFor(await stretchPin(pin, salt)), id = newLockId()
183
196
  if (this._ix._backup._s !== s0) throw fail('account_changed', 'the account changed during PIN setup')
184
- return this._write((doc) => { if (lockOfTarget(doc, kind, target)) throw fail('locked', 'this chat is already locked'); return addLock(doc, id, { kind, target, salt, pin: fingerprint, title }) })
197
+ try {
198
+ return await this._write((doc) => { if (lockOfTarget(doc, kind, target)) throw fail('locked', 'this chat is already locked'); return addLock(doc, id, { kind, target, salt, pin: fingerprint, title }) }, { retryMarker: true }) // a failed mark: retried at the next sync, not a failed setup that then says 'locked'
199
+ } catch (error) {
200
+ // ALREADY LOCKED: the presence mark is (re)written too (side sweep: sdk-first-chat-lock-marker-retry) — a lock an older release saved
201
+ // without its mark, and with nothing pending, otherwise left every other device's sync skipping the lock document for good
202
+ if (error && error.code === 'locked' && this._ix._backup._s === s0 && s0) {
203
+ s0.chatLockMarkPending = Math.max(Date.now(), (s0.chatLockMarkPending || 0) + 1)
204
+ this._ix._backup._changed?.()
205
+ await this._mark(s0).catch(() => {}) // failed: retried at the next sync (refreshSections)
206
+ }
207
+ throw error
208
+ }
185
209
  }
186
210
  async remove({ lockId } = {}) {
187
211
  if (typeof lockId !== 'string' || !/^lk_[A-Za-z0-9_-]{22}$/.test(lockId)) throw fail('invalid_argument', 'chatLocks.remove needs a lockId')
@@ -199,13 +223,18 @@ class ChatLocks extends Section {
199
223
  const current = liveLocks(cur).find((l) => l.lockId === lockId)
200
224
  if (!current || current.pin !== lock.pin || current.salt !== lock.salt) throw fail('changed_meanwhile', 'the display lock changed; try again')
201
225
  return addLock(cur, lockId, { kind: current.kind, target: current.target, salt: current.salt, title: current.title, pin: fingerprint })
202
- })
226
+ }, { retryMarker: true })
203
227
  }
204
228
  _mintedAssistants(targets) {
205
229
  const parents = new Set(targets.filter(t => t.kind === 'room').map(t => t.target))
206
230
  return (this._ix._backup.rooms || []).filter(r => r.shared && parents.has(r.shared) && !r.detachedLane && r.laneOrigin === 'minted')
207
231
  }
208
232
  async previewDeleteAll() {
233
+ const plan = await this._planDeleteAll()
234
+ this._shown = { owner: this._ix._backup._s, lockIds: plan.targets.map(t => t.lockId) } // what the caller was shown (deleteAll below)
235
+ return plan
236
+ }
237
+ async _planDeleteAll() {
209
238
  const owner = this._ix._backup._s
210
239
  if (!(await this._ix.sync())?.ok || this._ix._backup._s !== owner) throw fail('index_unavailable', 'the account could not be synced')
211
240
  const targets = liveLocks(await this.get()).map(({ kind, target, lockId }) => ({ kind, target, lockId }))
@@ -215,9 +244,20 @@ class ChatLocks extends Section {
215
244
  .map(r => ({ room: r.room, parent: r.shared, title: r.label || '' }))
216
245
  return { targets, privateAssistants }
217
246
  }
218
- async deleteAll({ includePrivateAssistants = false, privateAssistantRooms } = {}) {
247
+ // `lockIds` (side sweep: sdk-bulk-preview): the locks previewDeleteAll showed — a lock added since (another device) is not deleted
248
+ async deleteAll({ includePrivateAssistants = false, privateAssistantRooms, lockIds } = {}) {
219
249
  if (privateAssistantRooms !== undefined && (!Array.isArray(privateAssistantRooms) || !privateAssistantRooms.every(r => typeof r === 'string'))) throw fail('invalid_argument', 'privateAssistantRooms must contain room IDs')
220
- const owner = this._ix._backup._s, { targets, privateAssistants } = await this.previewDeleteAll()
250
+ if (lockIds !== undefined && (!Array.isArray(lockIds) || !lockIds.every(id => typeof id === 'string'))) throw fail('invalid_argument', 'lockIds must contain lock IDs from previewDeleteAll')
251
+ // A bare deleteAll() right after previewDeleteAll() on this handle: a lock added since (another device) was never shown, so
252
+ // it is refused, not deleted (side sweep: sdk-bulk-preview) — preview again, or pass lockIds. The preview is used once; with
253
+ // no preview, deleteAll() stays "every live lock", as documented.
254
+ const shown = this._shown; this._shown = null
255
+ const owner = this._ix._backup._s, { targets: live, privateAssistants } = await this._planDeleteAll()
256
+ if (!lockIds && shown && shown.owner === owner) {
257
+ const added = live.filter(t => !shown.lockIds.includes(t.lockId))
258
+ if (added.length) throw fail('changed_meanwhile', 'a display lock was added after previewDeleteAll; preview again or pass lockIds', { added: added.map(t => t.target) })
259
+ }
260
+ const targets = lockIds ? live.filter(t => lockIds.includes(t.lockId)) : live
221
261
  const approved = privateAssistants.filter(r => privateAssistantRooms ? privateAssistantRooms.includes(r.room) : includePrivateAssistants === true).map(r => r.room)
222
262
  return this._deleteTargets(targets, owner, undefined, approved)
223
263
  }
package/sdkAgui.js CHANGED
@@ -23,11 +23,12 @@ const contextText = (ctx) => (Array.isArray(ctx) && ctx.length ? 'Context from t
23
23
  * Run one AG-UI run against a Space. → an async iterator of AG-UI 1.0 events, ending with RUN_FINISHED or RUN_ERROR.
24
24
  * @param space a Space (or Lane) from the SDK
25
25
  * @param input an AG-UI RunAgentInput ({ threadId, runId, messages, context?, resume? })
26
- * @param opts { from, mode = 'always', timeoutMs = TURN_TIMEOUT_MS (~16 min, as space.turn()), graceMs = 1500, signal }
26
+ * @param opts { from, mode = 'always', timeoutMs = TURN_TIMEOUT_MS (~16 min, as space.turn()), graceMs = 1500, pendingWaitMs = 15000 (how long the waiting-approvals read may take after the reply; past it the run ends
27
+ * in RUN_ERROR 'pending_unread', never success), signal }
27
28
  */
28
29
  import { isLaneCopy } from './roomName.js'
29
30
  import { TURN_TIMEOUT_MS } from './sdkTurn.js' // the same wait as space.turn() and the app (~16 min) // the one test for a lane's copy of its shared room's line
30
- export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_TIMEOUT_MS, graceMs = 1500, signal } = {}) {
31
+ export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_TIMEOUT_MS, graceMs = 1500, pendingWaitMs = 15_000, signal } = {}) {
31
32
  const queue = [], waiters = []
32
33
  let done = false
33
34
  const push = (e) => { if (done) return; const ev = { ...e, timestamp: now() }; const w = waiters.shift(); if (w) w({ value: ev, done: false }); else queue.push(ev) }
@@ -37,13 +38,28 @@ export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_
37
38
  const listen = (ev, cb) => { space.on(ev, cb); subs.push([ev, cb]) }
38
39
  const unlisten = () => { for (const [ev, cb] of subs.splice(0)) { try { space.off(ev, cb) } catch { /* an older Space without off() */ } } }
39
40
  let timer = null
40
- const finish = (e) => { if (done) return; clearTimeout(timer); unlisten(); push(e); end() }
41
+ // CLOSING THE SPACE ENDS THE RUN (side sweep: agui-run-waits-after-room-close): space.close() settles the handles in its
42
+ // `_turns` set, but this adapter sends with space.send(), so it waited out its own ~16-minute timeout. It joins that set.
43
+ const closeWatch = { _settle: () => fail('the Space was closed before its reply', 'closed') }
44
+ try { if (space && typeof space === 'object' && !space._stopped) (space._turns ||= new Set()).add(closeWatch) } catch { /* a Space without the set */ }
45
+ const finish = (e) => { if (done) return; clearTimeout(timer); unlisten(); try { space._turns?.delete(closeWatch) } catch { /* */ } push(e); end() }
41
46
  const fail = (message, code) => finish({ type: 'RUN_ERROR', message, code })
42
47
 
43
48
  ;(async () => {
44
49
  push({ type: 'RUN_STARTED', threadId, runId })
45
50
  if (signal) { if (signal.aborted) return finish({ type: 'RUN_FINISHED', threadId, runId, outcome: { type: 'cancelled' } }); signal.addEventListener('abort', () => finish({ type: 'RUN_FINISHED', threadId, runId, outcome: { type: 'cancelled' } }), { once: true }) }
46
51
 
52
+ // 0. THE ROOM'S HISTORY FIRST (side sweep: agui-example-starts-before-room-history): a Space just opened may still be reading
53
+ // it, and an assistant message that read delivers would be taken below as this run's answer. Wait for `ready` (bounded by
54
+ // the run's own timeout); a Space that cannot open its history ends the run, nothing sent.
55
+ if (space && space.ready && typeof space.ready.then === 'function') {
56
+ let cap = null
57
+ const why = await Promise.race([Promise.resolve(space.ready).then(() => null, (e) => e || new Error('cannot_open')), new Promise((r) => { cap = setTimeout(() => r(Object.assign(new Error('the room\'s history was not read in time'), { code: 'timeout' })), timeoutMs) })])
58
+ clearTimeout(cap)
59
+ if (done) return
60
+ if (why) return fail(`the room could not be opened: ${(why && why.message) || why}`, (why && why.code) || 'cannot_open')
61
+ }
62
+
47
63
  // 1. Resume: the person answered an interrupt — approve or deny the proposal in the room.
48
64
  const resume = Array.isArray(input.resume) ? input.resume : []
49
65
  for (const r of resume) {
@@ -53,6 +69,8 @@ export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_
53
69
  else { await space.deny(id); push({ type: 'TOOL_CALL_RESULT', messageId: 'wb-res-' + id, toolCallId: id, role: 'tool', content: JSON.stringify({ approved: false }) }) }
54
70
  } catch (e) { return fail(`the room refused ${r.status === 'resolved' ? 'the approval' : 'the denial'}: ${(e && e.message) || e}`, (e && e.code) || 'refused') }
55
71
  }
72
+ // cancelled (unsubscribed, aborted) while a decision was in flight: no listeners put back, nothing sent (side sweep: agui-unsubscribed-resume-reinstalls-listeners)
73
+ if (done) return
56
74
 
57
75
  // 2. The new user message, if there is one this Space has not been sent yet.
58
76
  const msgs = Array.isArray(input.messages) ? input.messages : []
@@ -77,10 +95,17 @@ export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_
77
95
  start()
78
96
  content(final.startsWith(streamed) ? final.slice(streamed.length) : streamed ? '' : final)
79
97
  push({ type: 'TEXT_MESSAGE_END', messageId: mid })
80
- try { if (typeof space._pollPending === 'function') space._pollPending() } catch { /* the proposals poll still runs */ } // ask NOW: a card made during the turn sits on its own channel
98
+ // ask NOW: a card made during the turn sits on its own channel — and WAIT for the answer (side sweep 2026-11-28: a read slower than
99
+ // the grace ended the run as success, and the UI never saw the approval). A read already out is waited for, then one more.
100
+ let asked = Promise.resolve()
101
+ try { if (typeof space._pollPending === 'function') asked = Promise.resolve(space._inflightPending || null).then(() => space._pollPending()).catch(() => {}) } catch { /* the proposals poll still runs */ }
102
+ let cap = null, read = false
103
+ const answered = Promise.race([asked.then(() => { read = true }), new Promise((r) => { cap = setTimeout(r, pendingWaitMs) })]).then(() => clearTimeout(cap)) // a read that hangs does not hold the run for ever
81
104
  // A proposal made during the turn can reach the device just after the reply (its own channel): wait a beat for it.
82
- setTimeout(() => {
105
+ const decide = () => {
83
106
  if (done) return
107
+ // the read still out at the cap: the list is UNKNOWN, not empty — never "success" on it (side sweep: agui-late-approval-reported-as-success)
108
+ if (!proposals.length && !read) return fail('the reply came, but whether it waits for an approval could not be read — look at the Space', 'pending_unread')
84
109
  if (!proposals.length) return finish({ type: 'RUN_FINISHED', threadId, runId, outcome: { type: 'success' } })
85
110
  for (const p of proposals) {
86
111
  push({ type: 'TOOL_CALL_START', toolCallId: p.id, toolCallName: p.action || 'proposal', parentMessageId: mid })
@@ -88,7 +113,9 @@ export function aguiRun(space, input, { from, mode = 'always', timeoutMs = TURN_
88
113
  push({ type: 'TOOL_CALL_END', toolCallId: p.id })
89
114
  }
90
115
  finish({ type: 'RUN_FINISHED', threadId, runId, outcome: { type: 'interrupt', interrupts: proposals.map((p) => ({ id: p.id, reason: 'approval_required', toolCallId: p.id, ...(p.text ? { message: String(p.text) } : {}) })) } })
91
- }, proposals.length ? 0 : graceMs)
116
+ }
117
+ if (proposals.length) setTimeout(decide, 0)
118
+ else Promise.all([answered, new Promise((r) => setTimeout(r, graceMs))]).then(decide)
92
119
  })
93
120
  timer = setTimeout(() => fail(`no reply from the room within ${Math.round(timeoutMs / 1000)} s`, 'timeout'), timeoutMs)
94
121
  sent.add(fresh.id)
package/sdkBackup.js CHANGED
@@ -28,6 +28,7 @@ import { newMasterSecret, backupLocation, wrapperLocation, enrollCredential, ope
28
28
  export const DEFAULT_VAULT_API = 'https://api.witbitz.chat/v1/vault'
29
29
  const KIND = LEGACY_SDK_KIND
30
30
  const MAX_ROOMS = 500
31
+ const OPENED_AT_EVERY_MS = 3600_000 // a reopened room's time moves at most once an hour (add; as the account index — accountIndexDoc.js)
31
32
 
32
33
  const b64 = (u8) => { let s = ''; for (let i = 0; i < u8.length; i++) s += String.fromCharCode(u8[i]); return btoa(s) }
33
34
  const ub64 = (s) => { const b = atob(s); const u = new Uint8Array(b.length); for (let i = 0; i < b.length; i++) u[i] = b.charCodeAt(i); return u }
@@ -71,7 +72,7 @@ const notOnService = () => fail('not_on_service', 'this call is for an account o
71
72
 
72
73
  /** One room as the backup records it. `link` carries the room key (the fragment), so the whole list is sealed. */
73
74
  const roomOf = (r) => (r && typeof r === 'object' && typeof r.room === 'string' && r.room && typeof r.link === 'string' && r.link
74
- ? { room: r.room.slice(0, 120), ...roomPin(r), ...(typeof r.mintedFor === 'string' && r.mintedFor ? { mintedFor: r.mintedFor } : r.laneOrigin === 'minted' && r.shared ? { mintedFor: r.shared } : {}), ...(r.laneOrigin === 'minted' && !r.detachedLane ? { laneOrigin: 'minted' } : {}), ...(Number(r.associationAt) > 0 ? { associationAt: Number(r.associationAt) } : {}), ...(typeof r.renamed === 'boolean' ? { renamed: r.renamed } : {}), ...(Number.isFinite(r.at) && r.at > 0 ? { at: r.at } : {}), ...(r.archived ? { archived: true } : {}), ...(r.detachedLane ? { detachedLane: true } : {}), link: r.link.slice(0, 4000), kind: !r.detachedLane && r.kind === 'lane' ? 'lane' : 'space', ...(r.label ? { label: String(r.label).slice(0, 120) } : {}), ...(!r.detachedLane && r.kind === 'lane' && r.shared ? { shared: String(r.shared).slice(0, 120) } : {}), ...(typeof r.mk === 'string' && r.mk && r.mk.length <= 200 ? { mk: r.mk } : {}) }
75
+ ? { room: r.room.slice(0, 120), ...roomPin(r), ...(typeof r.mintedFor === 'string' && r.mintedFor ? { mintedFor: r.mintedFor } : r.laneOrigin === 'minted' && r.shared ? { mintedFor: r.shared } : {}), ...(r.laneOrigin === 'minted' && !r.detachedLane ? { laneOrigin: 'minted' } : {}), ...(Number(r.associationAt) > 0 ? { associationAt: Number(r.associationAt) } : {}), ...(typeof r.renamed === 'boolean' ? { renamed: r.renamed } : {}), ...(Number.isFinite(r.at) && r.at > 0 ? { at: r.at } : {}), ...(r.archived ? { archived: true } : {}), ...(Number.isFinite(r.labelAt) && r.labelAt > 0 ? { labelAt: r.labelAt } : {}), ...(Number.isFinite(r.archivedAt) && r.archivedAt > 0 ? { archivedAt: r.archivedAt } : {}), ...(r.detachedLane ? { detachedLane: true } : {}), link: r.link.slice(0, 4000), kind: !r.detachedLane && r.kind === 'lane' ? 'lane' : 'space', ...(r.label ? { label: String(r.label).slice(0, 120) } : {}), ...(!r.detachedLane && r.kind === 'lane' && r.shared ? { shared: String(r.shared).slice(0, 120) } : {}), ...(typeof r.mk === 'string' && r.mk && r.mk.length <= 200 ? { mk: r.mk } : {}) }
75
76
  : null)
76
77
 
77
78
  function stateOf(x) {
@@ -84,7 +85,9 @@ function stateOf(x) {
84
85
  const links = (Array.isArray(o.links) ? o.links : []).filter((l) => l && typeof l.a === 'string' && typeof l.b === 'string' && Number.isFinite(l.at)).map((l) => ({ a: l.a.slice(0, 120), b: l.b.slice(0, 120), at: l.at, ...(Number.isFinite(l.cap) ? { cap: l.cap } : {}), ...(l.removed ? { removed: true } : {}) })).slice(-200)
85
86
  // `outs`: sign-outs of OTHER devices this device made, kept until the index carries them (sdkAccount.js signOut; pass 6, K#7)
86
87
  const outs = o.outs && typeof o.outs === 'object' ? Object.fromEntries(Object.entries(o.outs).filter(([id, at]) => typeof id === 'string' && id.length <= 40 && Number.isFinite(at)).slice(-50)) : {}
87
- return { v: 1, ...(Number.isSafeInteger(o.chatLockMarkPending) && o.chatLockMarkPending > 0 ? { chatLockMarkPending: o.chatLockMarkPending } : {}), ...(o.format === 'account' ? { format: 'account' } : {}), ...(Object.keys(outs).length ? { outs } : {}), master: o.master, ...(typeof o.savedVersion === 'string' && o.savedVersion.length <= 200 ? { savedVersion: o.savedVersion } : {}), rooms: (Array.isArray(o.rooms) ? o.rooms : []).map(roomOf).filter(Boolean).slice(0, MAX_ROOMS), ...(tomb.length ? { tomb } : {}), ...(links.length ? { links } : {}), ...(device ? { device } : {}), ...(o.email ? { email: String(o.email) } : {}), ...(inviteOf(o.invite) ? { invite: inviteOf(o.invite) } : {}), ...(normUsageKey(o.usage) ? { usage: normUsageKey(o.usage) } : {}), ...(usageOldOf(o.usageOld).length ? { usageOld: usageOldOf(o.usageOld) } : {}), ...(o.erased ? { erased: true } : {}), ...(v2Of(o.v2) ? { v2: v2Of(o.v2) } : {}) }
88
+ // `indexGoneAt`: the first 410 on the account's index (indexGone.js) — kept, or each short visit restarted the minute (side sweep:
89
+ // sdk-deleted-account-check-restarts-on-reopen)
90
+ return { v: 1, ...(Number.isSafeInteger(o.chatLockMarkPending) && o.chatLockMarkPending > 0 ? { chatLockMarkPending: o.chatLockMarkPending } : {}), ...(Number.isSafeInteger(o.indexGoneAt) && o.indexGoneAt > 0 ? { indexGoneAt: o.indexGoneAt } : {}), ...(o.savePending ? { savePending: 1 } : {}),...(o.format === 'account' ? { format: 'account' } : {}), ...(Object.keys(outs).length ? { outs } : {}), master: o.master, ...(typeof o.savedVersion === 'string' && o.savedVersion.length <= 200 ? { savedVersion: o.savedVersion } : {}), rooms: (Array.isArray(o.rooms) ? o.rooms : []).map(roomOf).filter(Boolean).slice(0, MAX_ROOMS), ...(tomb.length ? { tomb } : {}), ...(links.length ? { links } : {}), ...(device ? { device } : {}), ...(o.email ? { email: String(o.email) } : {}), ...(inviteOf(o.invite) ? { invite: inviteOf(o.invite) } : {}), ...(normUsageKey(o.usage) ? { usage: normUsageKey(o.usage) } : {}), ...(usageOldOf(o.usageOld).length ? { usageOld: usageOldOf(o.usageOld) } : {}), ...(o.erased ? { erased: true } : {}), ...(v2Of(o.v2) ? { v2: v2Of(o.v2) } : {}) }
88
91
  }
89
92
  // the account's USAGE key (usageReceipts.js; the owner, 2026-10-23: a builder's app records the account's usage too) and the
90
93
  // ones it replaced — kept in step between the devices by the live index (sdkAccount.js)
@@ -116,8 +119,10 @@ export class AccountBackup {
116
119
  * meanwhile is queued in it) but is handed to nobody — not the app (onState), not the live index — until the vault copy,
117
120
  * the recovery code and the gate are all saved. A failed enable then leaves nothing behind that reads "enabled". */
118
121
  _isEnabling() { return !!this._enabling && this._enabling === this._s }
119
- /** The rooms the backup holds: [{ room, link, kind: 'space'|'lane', label?, shared?, archived? }]. */
120
- get rooms() { return this._s ? this._s.rooms.map(({ at, ...r }) => r) : [] } // `at` is the live index's bookkeeping
122
+ /** The rooms the backup holds: [{ room, link, kind: 'space'|'lane', label?, shared?, archived?, pinned?, lastOpenedAt? }]. */
123
+ // `at` is the live index's bookkeeping (the newer of each entry wins); it reaches the app READ-ONLY as `lastOpenedAt` — when the room
124
+ // was last opened or recorded on any of the account's devices, at most an hour behind (side sweep: sdk-account-room-list-omits-recency)
125
+ get rooms() { return this._s ? this._s.rooms.map(({ at, ...r }) => (Number.isFinite(at) && at > 0 ? { ...r, lastOpenedAt: at } : r)) : [] }
121
126
 
122
127
  /** Set up the backup → `{ code }`. Show the code ONCE: it is the only way back if this device is lost. With an email
123
128
  * (default: the signed-in session's), the recovery gate is enrolled too, so a restore can also be made to need it. */
@@ -181,7 +186,14 @@ export class AccountBackup {
181
186
  if (!r) return this
182
187
  const i = this._s.rooms.findIndex((x) => x.room === r.room)
183
188
  const prev = i >= 0 ? this._s.rooms[i] : null
184
- if (prev && prev.link === r.link && prev.kind === r.kind && prev.shared === r.shared && prev.laneOrigin === r.laneOrigin && prev.associationAt === r.associationAt && !!prev.detachedLane === !!r.detachedLane && prev.mk === r.mk && (!label || prev.label === r.label)) return this
189
+ if (prev && prev.link === r.link && prev.kind === r.kind && prev.shared === r.shared && prev.laneOrigin === r.laneOrigin && prev.associationAt === r.associationAt && !!prev.detachedLane === !!r.detachedLane && prev.mk === r.mk && (!label || prev.label === r.label)) {
190
+ // REOPENED, UNCHANGED: its time (`lastOpenedAt`) moves at most once an hour — not a vault and index write per open (side sweep:
191
+ // sdk-account-room-list-omits-recency; it returned before stamping, so the time stayed at the room's first record)
192
+ if (Date.now() - (Number(prev.at) || 0) < OPENED_AT_EVERY_MS) return this
193
+ this._s.rooms[i] = { ...prev, at: Date.now() }
194
+ this._schedule()
195
+ return this
196
+ }
185
197
  const next = { ...(prev ? { ...prev, ...r, ...(label ? {} : prev.label ? { label: prev.label } : {}), ...(prev.archived ? { archived: true } : {}) } : r), at: Date.now() } // `at`: the live index keeps the newer of each entry
186
198
  if (next.detachedLane) { delete next.shared; delete next.laneOrigin }
187
199
  if (i >= 0) this._s.rooms[i] = next; else { if (this._s.rooms.length >= MAX_ROOMS) return this; this._s.rooms.push(next) }
@@ -395,7 +407,10 @@ export class AccountBackup {
395
407
  // ── internals ──────────────────────────────────────────────────────────────────────────────────────────────────
396
408
  _schedule() { if (this._isEnabling()) { this._enablingDirty = true; return } this._persist(); if (typeof this._onLocal === 'function') { try { this._onLocal() } catch { /* the live index */ } } }
397
409
  /** Write the vault copy soon and hand the app the new state — without telling the live index (it is the caller). */
398
- _persist() { if (this._isEnabling()) { this._enablingDirty = true; return } if (this._s && this._s.erased) { this._changed(); return } clearTimeout(this._timer); this._timer = setTimeout(() => { this._timer = null; if (this._s) this._write().catch((e) => { this.lastError = e }) }, 400); this._changed() }
410
+ _persist() { if (this._isEnabling()) { this._enablingDirty = true; return } if (this._s && this._s.erased) { this._changed(); return } clearTimeout(this._timer); this._timer = setTimeout(() => { this._timer = null; const s0 = this._s; if (s0) this._write().then(() => { if (s0.savePending && this._s === s0) { delete s0.savePending; this._changed() } }).catch((e) => { this.lastError = e; if (this._s === s0 && !s0.erased && !s0.savePending) { s0.savePending = 1; this._changed() } }) }, 400); this._changed() }
411
+ /** @private a scheduled save that failed is OWED (`savePending`, kept in the state): the account's next sync tries it again — the merge
412
+ * alone may change nothing and so schedule nothing (side sweep: sdk-resume-misses-pending-backup-save). */
413
+ _retryOwedSave() { if (this._s && this._s.savePending && !this._timer && !this._isEnabling()) this._persist() }
399
414
  /** This device was signed out of the account (wb.account): forget it here, and tell the app to persist that. */
400
415
  _drop() { this._restoreEpoch = (this._restoreEpoch || 0) + 1; clearTimeout(this._timer); this._timer = null; this._s = null; this._changed() }
401
416
  /** @private take another persisted state in place (a vault switching accounts keeps one backup per account) */
package/sdkBackupV2.js CHANGED
@@ -299,7 +299,7 @@ export function accountService({ tenant, base = ACCOUNT_SERVICE, fetch: f = (...
299
299
  const a = client(s, { changed })
300
300
  await save()
301
301
  const existing = a.pendingReset()
302
- if (existing) return moveDates(existing)
302
+ if (existing && existing.expires) return moveDates(existing) // one kept without its dates (its start's answer lost): resetBegin asks the service first (side sweep: email-move-start-reply-loses-pending-request)
303
303
  try {
304
304
  const pending = await a.resetBegin({ address, getCode: screen(getCode) })
305
305
  await save()
@@ -406,7 +406,13 @@ export function accountService({ tenant, base = ACCOUNT_SERVICE, fetch: f = (...
406
406
  if (!(await persistNow(s))) throw fail('save_failed', 'the migration state could not be kept on this device')
407
407
  current()
408
408
  if (silent) await a.silentMove({ address })
409
- else await a.migrate({ address, typedCode: code, getCode: async () => { current(); const c = await getCode(); current(); return c } })
409
+ else {
410
+ try { await a.migrate({ address, typedCode: code, getCode: async () => { current(); const c = await getCode(); current(); return c } }) } catch (e) {
411
+ // a wrong or cancelled email code: nothing was committed — drop the move as legacyAborted does, or every later save stops
412
+ if ((e?.code === 'email_code_wrong' || e?.code === 'cancelled') && b._s === s) { delete s.v2; b._changed(); try { await persistNow(s) } catch { /* the error below is the one to tell */ } }
413
+ throw e
414
+ }
415
+ }
410
416
  current(); b._changed()
411
417
  if (!(await persistNow(s))) throw fail('save_failed', 'the migrated account state could not be kept')
412
418
  }
@@ -482,7 +488,12 @@ export function accountService({ tenant, base = ACCOUNT_SERVICE, fetch: f = (...
482
488
  let typed
483
489
  try { codeSecret(code); typed = code } catch { throw fail('bad_code', 'that is not a recovery code') }
484
490
  if (typeof getCode !== 'function') return null // no screen for the emailed code (a page outside a vault): the old store only
485
- const s1 = { v: 1, format: 'account', master: '', rooms: [], v2: {} }
491
+ // ONE DRAFT PER VAULT PAGE, kept until a restore succeeds (side sweep: restore-finish-duplicate-device): each attempt made a fresh
492
+ // state — a fresh device key (`dk`) and no memory of the finish it had sent — so a retry after a lost finish reply registered a
493
+ // second active device. The draft keeps the attempt's key and its restoring mark (acctV2App RESTORING_KEY, held per state).
494
+ // Held in memory: a reload starts a new draft (its key is not kept), as before.
495
+ if (!b._restoreDraft || b._restoreDraft.v2.svc) b._restoreDraft = { v: 1, format: 'account', master: '', rooms: [], v2: {} }
496
+ const s1 = b._restoreDraft
486
497
  let found = false, done = null
487
498
  const address = async () => {
488
499
  found = true // the service knows this code
@@ -509,6 +520,7 @@ export function accountService({ tenant, base = ACCOUNT_SERVICE, fetch: f = (...
509
520
  throw e
510
521
  }
511
522
  if (!done) throw fail('unopenable', 'the backup could not be opened')
523
+ b._restoreDraft = null // restored: the next restore is a new one
512
524
  return done
513
525
  },
514
526
 
package/sdkCloudDevice.js CHANGED
@@ -24,12 +24,16 @@ export async function isKeptSpace(space) {
24
24
  try { return (await w.cloudDevice.status()).rooms.some((r) => r.room === space.room) }
25
25
  catch (e) { if (['not_available', 'cloud_device_unavailable', 'not_enrolled', 'not_in_dev_server', 'sign_in_required'].includes(e.code)) return false; throw e } // sign_in_required: a lapsed sign-in cannot ask — and it blocked every lane and member change of an OPEN room, kept or not (second review, 2026-11-27); // cloud_device_unavailable: this deployment runs no cloud device (agent/cloudDeviceRoute.mjs, 501), so nothing here is kept
26
26
  }
27
- const session = w._session, state = w.backup._s, loc = await a._where()
27
+ return accountMark(w, space.room)
28
+ }
29
+ /** The account's saved always-on mark for `room` (the app's and the SDK's `xindex` row) — the mark assertNotKept refuses on. */
30
+ async function accountMark(w, room) {
31
+ const a = w.account, session = w._session, state = w.backup._s, loc = await a._where()
28
32
  current(w, session, state)
29
33
  const r = await a._read(loc, 'xindex', loc.app)
30
34
  current(w, session, state)
31
35
  if (!r.ok) throw fail('index_unavailable', 'the account’s always-on mark could not be read')
32
- return !!r.doc?.rooms?.[space.room]?.alwaysOn
36
+ return !!r.doc?.rooms?.[room]?.alwaysOn
33
37
  }
34
38
 
35
39
  export async function disconnectRoomLanes(w, room) {
@@ -151,6 +155,7 @@ async function markKept(w, room, on) {
151
155
  current(w, session, s)
152
156
  if (r && r.status === 409) continue
153
157
  if (!r || r.status !== 200) throw fail('save_failed', 'the cloud-device account mark could not be saved')
158
+ if (typeof a._noteKeptMarks === 'function') a._noteKeptMarks(next) // account.rooms shows the mark at once, not at the next sync
154
159
  return
155
160
  }
156
161
  throw fail('version_conflict', 'the account kept changing; check the cloud-device status and retry')
@@ -163,7 +168,11 @@ export class SpaceAlwaysOn {
163
168
  const w = this._client(), s = this._sp
164
169
  if (w.vault) return w.vault._c.roomAccount(s.room, 'alwaysOn', 'status')
165
170
  const h = await w.cloudDevice.status(), entry = h.rooms.find((r) => r.room === s.room)
166
- return { on: !!entry, registered: h.registered, ...(entry && entry.waiting ? { waiting: entry.waiting } : {}) }
171
+ // `marked`: the account's saved mark, beside what the device holds — on: false with marked: true is a Space the device let go
172
+ // while the account still keeps it (the guard still refuses private assistants for it); disable() takes the mark off. Unknown
173
+ // (no account index, or it could not be read) → left out (side sweep: sdk-always-on-status-omits-saved-choice)
174
+ let marked; if (w.account?.enabled && typeof w.account._read === 'function') { try { marked = await accountMark(w, s.room) } catch (e) { if (e && e.code === 'account_changed') throw e } }
175
+ return { on: !!entry, registered: h.registered, ...(entry && entry.waiting ? { waiting: entry.waiting } : {}), ...(typeof marked === 'boolean' ? { marked } : {}) }
167
176
  }
168
177
  async enable({ disconnectLanes = false } = {}) {
169
178
  const w = this._client(), s = this._sp