@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.
- package/README.md +2 -2
- package/a2aCore.js +15 -0
- package/accountErase.js +9 -3
- package/accountIndexDoc.js +24 -7
- package/accountRecord.js +6 -2
- package/accountStores.js +21 -5
- package/acctV2App.js +111 -12
- package/acctV2Client.js +11 -1
- package/acctV2UiCore.js +27 -7
- package/awsKey.js +3 -1
- package/backupRecord.js +3 -0
- package/codeAttachments.js +1 -0
- package/codeCache.js +27 -3
- package/codeCloud.js +2 -0
- package/codeComputers.js +8 -0
- package/codeSent.js +43 -2
- package/codeTransport.js +24 -5
- package/connections.js +21 -3
- package/decrypt.html +69 -9
- package/eraseFile.js +15 -0
- package/idbSeal.js +5 -2
- package/inviteReceive.js +44 -0
- package/inviteSend.js +8 -2
- package/l1-worker-src.js +1 -1
- package/l1-worker.js +30 -14
- package/laneAssociation.js +11 -1
- package/laneLinkCore.js +9 -0
- package/ledgerView.js +30 -4
- package/manifest.json +78 -72
- package/offlineBundle.js +21 -0
- package/package.json +8 -2
- package/protectedLocal.js +34 -11
- package/reactionHolders.js +86 -0
- package/roomIntake.js +324 -0
- package/roomRoster.js +9 -2
- package/scheduleNext.js +60 -0
- package/sdkA2A.js +46 -8
- package/sdkAccount.js +71 -14
- package/sdkAccountDoc.js +3 -3
- package/sdkAccountSections.js +58 -18
- package/sdkAgui.js +33 -6
- package/sdkBackup.js +21 -6
- package/sdkBackupV2.js +15 -3
- package/sdkCloudDevice.js +12 -3
- package/sdkComputers.js +118 -17
- package/sdkDictation.js +1 -1
- package/sdkErase.js +3 -1
- package/sdkExports.js +15 -6
- package/sdkInvitations.js +4 -2
- package/sdkKeptAgent.js +19 -3
- package/sdkKeptIntake.js +100 -0
- package/sdkLaneLink.js +5 -6
- package/sdkRekey.js +72 -5
- package/sdkSchedules.js +8 -1
- package/sdkSpeech.js +14 -1
- package/sdkTemporaryRooms.js +2 -1
- package/sdkTurn.js +12 -4
- package/sharedViews.js +17 -1
- package/siri.js +29 -5
- package/spaceClient.js +96 -12
- package/spaceExport.js +50 -5
- package/spaceFork.js +15 -7
- package/spaceTemplates.js +2 -2
- package/speechOut.js +17 -3
- package/store.js +51 -13
- package/sw-notif-core.js +2 -1
- package/tapTrail.js +58 -0
- package/usageReceipts.js +12 -5
- package/vault-core.js +90 -16
- package/vault-kit.mjs +2 -2
- package/vault-screens.js +25 -11
- package/vaultAtRest.js +3 -2
- package/vaultCoreLock.js +3 -1
- package/vaultCorePush.js +58 -7
- package/vaultWorkerHost.js +9 -3
- package/witbitz-admin.d.ts +3 -0
- package/witbitz-admin.mjs +10 -10
- package/witbitz-sdk.d.ts +59 -23
- package/witbitz-sdk.js +271 -64
package/vault-screens.js
CHANGED
|
@@ -206,21 +206,35 @@ export function defaultScreens({ brand = 'this app', accent = '' } = {}) {
|
|
|
206
206
|
// (30c5fb580 had put one here). The email is asked below, after the code, when the backup or the account service needs it;
|
|
207
207
|
// `signIn` / `signInLabel` are still accepted, for a builder's own screen that wants them.
|
|
208
208
|
cancel.onclick = () => { close(); reject(Object.assign(new Error('cancelled'), { code: 'cancelled' })) }
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
} catch (e) {
|
|
209
|
+
// GOOGLE AS THE EMAIL STEP (side sweep: builder-restore-missing-google): with Google on (signInLabel names it), a backup that
|
|
210
|
+
// asks for its email offered only the address field and an emailed code. "Continue with Google" signs in through the vault's
|
|
211
|
+
// own screen (signIn), and the restore is asked again with that sign-in — the vault proves the address with it (restoreBridge).
|
|
212
|
+
const google = typeof signIn === 'function' && /google/i.test(signInLabel) ? el('button', 'wbv-btn', 'Continue with Google') : null
|
|
213
|
+
if (google) { google.style.display = 'none'; c.insertBefore(google, row) }
|
|
214
|
+
const ask = (what, placeholder, type = 'text') => { step = what; input.value = ''; input.type = type; input.placeholder = placeholder; input.focus(); if (google) google.style.display = what === 'email' || what === 'emailCode' ? '' : 'none' }
|
|
215
|
+
const attempt = async (fn) => {
|
|
216
|
+
err.textContent = ''; go.disabled = true; cancel.disabled = true; if (google) google.disabled = true // no Cancel while a restore runs: it would go on and save (side sweep 2026-11-28)
|
|
217
|
+
try { await fn(); close(); resolve() } catch (e) { refused(e) }
|
|
218
|
+
go.disabled = false; cancel.disabled = false; if (google) google.disabled = false
|
|
219
|
+
}
|
|
220
|
+
if (google) google.onclick = () => attempt(async () => { const who = await signIn(); if (typeof who === 'string' && who) addr = who; await restore({ code, email: addr || undefined }) })
|
|
221
|
+
go.onclick = () => attempt(async () => {
|
|
222
|
+
if (step === 'code') code = input.value.trim()
|
|
223
|
+
else if (step === 'email') addr = input.value.trim()
|
|
224
|
+
await restore(step === 'emailCode' ? { code, email: addr, ticket, emailCode: input.value.trim() } : { code, email: addr || undefined })
|
|
225
|
+
})
|
|
226
|
+
const refused = (e) => {
|
|
227
|
+
{
|
|
218
228
|
const k = e && e.code
|
|
219
229
|
if (k === 'email_required') { c.querySelector('p').textContent = 'This backup also needs the email it was set up with.'; ask('email', 'you@example.com', 'email') }
|
|
220
230
|
else if (k === 'email_code_required') { ticket = e.ticket || ''; c.querySelector('p').textContent = 'We emailed a code to ' + addr + '.'; ask('emailCode', '6-digit code') }
|
|
221
|
-
else err.textContent = k === 'bad_code' || k === 'not_found' ? 'That recovery code did not open a backup.' : k === 'email_code_wrong' ? 'That email code did not work.'
|
|
231
|
+
else err.textContent = k === 'bad_code' || k === 'not_found' ? 'That recovery code did not open a backup.' : k === 'email_code_wrong' ? 'That email code did not work.'
|
|
232
|
+
// another app's backup: trying again here cannot help (side sweep 2026-11-28: both said "Try again")
|
|
233
|
+
: k === 'other_app' ? 'This backup was made by another app. Open the app that created it to restore it.'
|
|
234
|
+
: k === 'backup_app_unknown' ? 'The backup service cannot verify which app created this recovery code, so it was not restored.'
|
|
235
|
+
: k === 'cancelled' ? '' // the sign-in screen was closed: nothing to say
|
|
236
|
+
: 'The backup could not be restored. Try again.'
|
|
222
237
|
}
|
|
223
|
-
go.disabled = false
|
|
224
238
|
}
|
|
225
239
|
input.onkeydown = (e) => { if (e.key === 'Enter') go.click() }
|
|
226
240
|
input.focus()
|
package/vaultAtRest.js
CHANGED
|
@@ -168,7 +168,8 @@ export function createAtRest ({ storage, key, currentRoom = () => true }) {
|
|
|
168
168
|
if (clear && key) for (const [email, s] of Object.entries(out)) if (isState(raw[email])) this.putBackup(k, email, s)
|
|
169
169
|
return out
|
|
170
170
|
},
|
|
171
|
-
/** Move
|
|
171
|
+
/** Move the signed-out ('') state to the signed-in account in one storage write: an email request, or a restore made before
|
|
172
|
+
* signing in — only when its email is this account's and the account has none of its own. */
|
|
172
173
|
claimEmailMove(k, email) {
|
|
173
174
|
const owner = String(email || '').trim().toLowerCase()
|
|
174
175
|
return onDisk(async () => {
|
|
@@ -176,7 +177,7 @@ export function createAtRest ({ storage, key, currentRoom = () => true }) {
|
|
|
176
177
|
if (!owner || !slot || before[owner]) return false
|
|
177
178
|
let draft = slot
|
|
178
179
|
if (isSealed(slot) && key) { try { draft = await open(key, slot) } catch { return false } }
|
|
179
|
-
if (!isState(draft) ||
|
|
180
|
+
if (!isState(draft) || String(draft.email || '').trim().toLowerCase() !== owner) return false
|
|
180
181
|
const all = read(storage, k)
|
|
181
182
|
if (!all || all[owner] || JSON.stringify(all['']) !== JSON.stringify(slot)) return false
|
|
182
183
|
delete all['']
|
package/vaultCoreLock.js
CHANGED
|
@@ -71,7 +71,9 @@ export function createVaultLock ({ brand = 'this app', mountUi, hide, show, onSt
|
|
|
71
71
|
// A PROTECTED device whose passkey is gone can never open its sealed copy: this origin starts over (the Spaces live in the
|
|
72
72
|
// account backup and the other devices)
|
|
73
73
|
startOver: async () => {
|
|
74
|
-
|
|
74
|
+
// never a promise of recovery: the sealed copy cannot be read, so nothing here can tell whether every Space is backed up — the
|
|
75
|
+
// same words as our own apps' Start over (side sweep 11-28)
|
|
76
|
+
if (!(await confirm({ title: 'Start over on this device?', text: 'This copy can’t be unlocked anymore, so it will be cleared. Only continue if you can open your Spaces on another device or restore them from a backup. Clearing the only copy permanently loses access to those Spaces.', ok: 'Start over', cancel: 'Cancel' }).catch(() => false))) return
|
|
75
77
|
localStorage.setItem(resetMarker, '1')
|
|
76
78
|
reload()
|
|
77
79
|
},
|
package/vaultCorePush.js
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// The page learns { available, on } and, when a notification is tapped, which Space (`notifOpen`) — only one this vault holds.
|
|
13
13
|
import { swRegBounded, subscribeRobust } from './pushCore.js'
|
|
14
14
|
import { VAPID_PUBLIC_KEY } from './config.js'
|
|
15
|
+
import { watchForTap } from './tapTrail.js'
|
|
15
16
|
|
|
16
17
|
export const PUSH_KEY = 'wbvault:push' // { on, endpoint, rooms: [the Spaces this device is listed on] } — this device's setting
|
|
17
18
|
|
|
@@ -24,11 +25,12 @@ export const PUSH_KEY = 'wbvault:push' // { on, endpoint, rooms: [the Spaces thi
|
|
|
24
25
|
* @param {(room: string) => boolean} o.held
|
|
25
26
|
* @param {(room: string) => void} o.onOpen a tapped notification's Space (warm)
|
|
26
27
|
* @param {string} [o.worker] the service worker's path (default /push-sw.js, the kit's)
|
|
28
|
+
* @param {() => Promise<object|null>} [o.takeTap] reads AND clears the tap push-sw.js stashed (idb 'spaces'/'kv' notifTap)
|
|
27
29
|
*/
|
|
28
|
-
export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, held, onOpen, onChange = null, worker = '/push-sw.js', nav = (typeof navigator !== 'undefined' ? navigator : null), N = (typeof Notification !== 'undefined' ? Notification : null) }) {
|
|
30
|
+
export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, held, onOpen, onChange = null, worker = '/push-sw.js', nav = (typeof navigator !== 'undefined' ? navigator : null), N = (typeof Notification !== 'undefined' ? Notification : null), takeTap = takeStashedTap, doc = (typeof document !== 'undefined' ? document : null), search = (typeof location !== 'undefined' ? location.search : '') }) {
|
|
29
31
|
const read = () => { try { const v = JSON.parse(storage.getItem(PUSH_KEY) || 'null'); return v && typeof v === 'object' ? v : { on: false } } catch { return { on: false } } }
|
|
30
32
|
const save = (v) => { try { storage.setItem(PUSH_KEY, JSON.stringify(v)) } catch { /* a full store: on for this session */ } }
|
|
31
|
-
let sub = null, chain = Promise.resolve()
|
|
33
|
+
let sub = null, chain = Promise.resolve(), unknown = false // unknown: on, and this start could not load the subscription
|
|
32
34
|
// KNOWN: start() has finished (a subscription loaded, or found off / unsupported). Until then this device's endpoint is NOT KNOWN —
|
|
33
35
|
// the account service must not be told "none" (Codex sweep 2026-11-16 #2). `changed` runs after every change of it.
|
|
34
36
|
let readyOk = null
|
|
@@ -41,6 +43,11 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
41
43
|
// what an unsubscribe names: the live subscription, else the endpoint this device was listed under (the server drops by endpoint) —
|
|
42
44
|
// a revoked permission or a missing worker must not leave every Space tickling a device that turned notifications off (review)
|
|
43
45
|
const named = (st) => (sub ? json(sub) : st && st.endpoint ? { endpoint: st.endpoint } : null)
|
|
46
|
+
// the subscription this browser already has for the kit's worker, if any (bounded: iOS can stall a push call) — never a new one
|
|
47
|
+
const liveSub = () => Promise.race([(async () => {
|
|
48
|
+
const reg = nav && nav.serviceWorker && typeof nav.serviceWorker.getRegistration === 'function' ? await nav.serviceWorker.getRegistration(worker) : null
|
|
49
|
+
return (reg && reg.pushManager && (await reg.pushManager.getSubscription())) || null
|
|
50
|
+
})().catch(() => null), new Promise((r) => setTimeout(() => r(null), 3000))])
|
|
44
51
|
// ⛔ A SPACE IS TAKEN OFF ITS LIST ONLY WHEN THE SERVER SAYS SO (review, 2026-11-13): a failed unsubscribe (offline) is kept in
|
|
45
52
|
// `off` and tried again at the next start — three starts, then it is let go (a Space whose key is gone can never be asked).
|
|
46
53
|
// → whether it is settled (taken off, or refused for good by the server).
|
|
@@ -58,16 +65,36 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
58
65
|
save({ ...read(), rooms: [...had], ...(st.off ? { off: st.off } : {}) })
|
|
59
66
|
})
|
|
60
67
|
}
|
|
68
|
+
// ONE OPEN PER TAP: the worker's message and its stash (below) name the same tap; a cold tap is the address's (vault-core's welcome)
|
|
69
|
+
let last = { room: '', at: 0 }
|
|
70
|
+
const open = (room) => { if (!room || !held(room) || (room === last.room && Date.now() - last.at < 10000)) return; last = { room, at: Date.now() }; onOpen(room) }
|
|
61
71
|
try { // a TAP on a warm vault: sw-notif-core focuses this window and posts the room
|
|
62
72
|
nav && nav.serviceWorker && nav.serviceWorker.addEventListener('message', (e) => {
|
|
63
73
|
const d = e && e.data
|
|
64
|
-
if (d && d.ch === 'notif-open' && typeof d.room === 'string' && d.room
|
|
74
|
+
if (d && d.ch === 'notif-open' && typeof d.room === 'string' && d.room) { open(d.room); takeTap().catch(() => {}) } // this tap's stash is spent
|
|
65
75
|
})
|
|
66
76
|
} catch { /* no service workers here */ }
|
|
77
|
+
// …and when a resuming page MISSED that message (iOS drops it to a waking app), the tap push-sw.js stashed: read on each return to the
|
|
78
|
+
// screen, as our hosted vault does (side sweep 2026-11-28: a warm tap left the builder's page on its previous Space). A cold tap's
|
|
79
|
+
// stash is the address's tap, already in the welcome: dropped, not opened again.
|
|
80
|
+
const coldTap = (() => { try { const q = new URLSearchParams(search || ''); return q.get('tap') === '1' ? String(q.get('room') || '') : '' } catch { return '' } })()
|
|
81
|
+
const checkTap = async (cold) => {
|
|
82
|
+
const v = await takeTap().catch(() => null)
|
|
83
|
+
if (!v || typeof v.room !== 'string' || !v.room || !(Date.now() - Number(v.at) < 90000)) return false
|
|
84
|
+
// the stash of a tap the worker's message already opened (it may be written a beat after): never reopened later (review 11-28:
|
|
85
|
+
// the person moved on, came back within 90 s, and was taken back to the tapped Space)
|
|
86
|
+
if (v.room === last.room && Number(v.at) <= last.at) return true
|
|
87
|
+
if (cold) { if (v.room === coldTap) return true; last = { room: '', at: 0 } }
|
|
88
|
+
open(v.room)
|
|
89
|
+
return true
|
|
90
|
+
}
|
|
91
|
+
if (coldTap) { last = { room: coldTap, at: Date.now() }; checkTap(true) }
|
|
92
|
+
const watch = watchForTap(() => checkTap(false), { forMs: 5000 }) // for a few seconds: the worker stashes a beat after it routed
|
|
93
|
+
try { doc && doc.addEventListener('visibilitychange', () => { if (doc.visibilityState === 'visible') watch.start() }) } catch { /* */ }
|
|
67
94
|
return {
|
|
68
95
|
view,
|
|
69
96
|
sync,
|
|
70
|
-
endpoint: () => (sub ? sub.endpoint : ''),
|
|
97
|
+
endpoint: () => (sub ? sub.endpoint : unknown ? undefined : ''), // undefined: not known (on, but not loaded) — never reported as none
|
|
71
98
|
/** Resolves once start() knows this device's endpoint (or that there is none). */
|
|
72
99
|
ready,
|
|
73
100
|
/** A Space about to be forgotten: off its list NOW, while the key worker still holds its key (after, the request has none). */
|
|
@@ -94,7 +121,10 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
94
121
|
save({ ...read(), off })
|
|
95
122
|
})
|
|
96
123
|
try { await nav.serviceWorker.register(worker); const r = await subscribeRobust(await swRegBounded({ path: worker, sw: nav.serviceWorker }), VAPID_PUBLIC_KEY); sub = r.sub } catch { sub = null }
|
|
97
|
-
|
|
124
|
+
// ON, but the subscription could not be loaded this time: its address is UNKNOWN, not "none" — the account service would
|
|
125
|
+
// clear the stored address of a subscription that may well still be live (side sweep 2026-11-28)
|
|
126
|
+
if (!sub) { unknown = true; return }
|
|
127
|
+
unknown = false
|
|
98
128
|
setSelf(sub.endpoint)
|
|
99
129
|
if (sub.endpoint !== read().endpoint) save({ ...read(), endpoint: sub.endpoint, rooms: [] }) // a new subscription: every Space lists it again
|
|
100
130
|
return sync(rooms)
|
|
@@ -108,7 +138,7 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
108
138
|
const reg = await swRegBounded({ path: worker, sw: nav.serviceWorker })
|
|
109
139
|
const r = await subscribeRobust(reg, VAPID_PUBLIC_KEY)
|
|
110
140
|
if (!r.sub) throw Object.assign(new Error('vault: the push service did not answer — ' + r.err), { code: 'push_unavailable' })
|
|
111
|
-
sub = r.sub; setSelf(sub.endpoint)
|
|
141
|
+
sub = r.sub; unknown = false; setSelf(sub.endpoint)
|
|
112
142
|
save({ on: true, endpoint: sub.endpoint, rooms: [] })
|
|
113
143
|
await sync(rooms, { loud: true })
|
|
114
144
|
changed()
|
|
@@ -117,10 +147,12 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
117
147
|
/** Off: every Space takes this device off its list, then the subscription goes. */
|
|
118
148
|
async disable () {
|
|
119
149
|
await serial(async () => {
|
|
150
|
+
// before start() loaded it (a sign-out resumed at launch): the browser's live subscription, looked up — never made (side sweep round 2)
|
|
151
|
+
if (!sub) sub = await liveSub()
|
|
120
152
|
const st = read(), s = named(st), off = []
|
|
121
153
|
for (const r of [...(Array.isArray(st.rooms) ? st.rooms : []), ...(Array.isArray(st.off) ? st.off.map((o) => o && o.room) : [])].filter(Boolean)) if (!(await takeOff(r, s))) off.push({ room: r, n: 0 })
|
|
122
154
|
try { if (sub) await sub.unsubscribe() } catch { /* the push service forgets it on its own */ }
|
|
123
|
-
sub = null; setSelf('')
|
|
155
|
+
sub = null; unknown = false; setSelf('')
|
|
124
156
|
save(off.length && st.endpoint ? { on: false, endpoint: st.endpoint, off } : { on: false }) // what could not be reached is tried again at the next start
|
|
125
157
|
})
|
|
126
158
|
changed()
|
|
@@ -138,3 +170,22 @@ export function createVaultPush ({ storage, subscribe, unsubscribe, setSelf, hel
|
|
|
138
170
|
},
|
|
139
171
|
}
|
|
140
172
|
}
|
|
173
|
+
|
|
174
|
+
// The tap push-sw.js stashed (sw-notif-core wbxWireNotifClick, stashTap) — read and cleared in one transaction; bounded like the worker's own reads.
|
|
175
|
+
function takeStashedTap () {
|
|
176
|
+
return new Promise((resolve) => {
|
|
177
|
+
const t = setTimeout(() => resolve(null), 2500)
|
|
178
|
+
try {
|
|
179
|
+
const r = indexedDB.open('spaces', 1)
|
|
180
|
+
r.onupgradeneeded = () => { try { r.result.createObjectStore('kv') } catch { /* */ } }
|
|
181
|
+
r.onerror = () => { clearTimeout(t); resolve(null) }
|
|
182
|
+
r.onsuccess = () => {
|
|
183
|
+
try {
|
|
184
|
+
const os = r.result.transaction('kv', 'readwrite').objectStore('kv'), g = os.get('notifTap')
|
|
185
|
+
g.onsuccess = () => { clearTimeout(t); const v = g.result; if (v) { try { os.delete('notifTap') } catch { /* */ } } resolve(v || null) }
|
|
186
|
+
g.onerror = () => { clearTimeout(t); resolve(null) }
|
|
187
|
+
} catch { clearTimeout(t); resolve(null) }
|
|
188
|
+
}
|
|
189
|
+
} catch { clearTimeout(t); resolve(null) }
|
|
190
|
+
})
|
|
191
|
+
}
|
package/vaultWorkerHost.js
CHANGED
|
@@ -33,11 +33,15 @@ export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () =
|
|
|
33
33
|
const set = (w) => { worker = w; try { onCurrent(w) } catch { /* the caller's mirror; never stops the host */ } }
|
|
34
34
|
function runReplay (w) {
|
|
35
35
|
let chain = null
|
|
36
|
+
// A STEP WHOSE PROMISE REJECTS is a step that throws (side sweep: builder-worker-replay-failure-blocks-room-reads): an unseal error
|
|
37
|
+
// skipped every later step and every room read awaited the same rejection — and the worker still answered pings, so nothing retried.
|
|
38
|
+
// (The worker writes no clear key over a store it could not open: l1-worker.js persist.)
|
|
39
|
+
const settle = (r) => Promise.resolve(r).catch(() => undefined)
|
|
36
40
|
for (const { step } of steps) {
|
|
37
|
-
if (chain) { chain = chain.then(() => (worker === w ? step(w) : undefined)); continue }
|
|
41
|
+
if (chain) { chain = chain.then(() => (worker === w ? settle((() => { try { return step(w) } catch { return undefined } })()) : undefined)); continue }
|
|
38
42
|
let r
|
|
39
43
|
try { r = step(w) } catch { r = undefined } // one step that throws never keeps the others from a new worker
|
|
40
|
-
if (r && typeof r.then === 'function') chain =
|
|
44
|
+
if (r && typeof r.then === 'function') chain = settle(r)
|
|
41
45
|
}
|
|
42
46
|
return chain || Promise.resolve()
|
|
43
47
|
}
|
|
@@ -70,7 +74,9 @@ export function createWorkerHost ({ make, onMessage = () => {}, onCurrent = () =
|
|
|
70
74
|
if (at >= 0) steps[at] = { name, step }; else steps.push({ name, step })
|
|
71
75
|
return host
|
|
72
76
|
},
|
|
73
|
-
|
|
77
|
+
// after a restart whose new worker failed to start, the worker a call makes is that restart's: the frames are told, as restart() does
|
|
78
|
+
// (side sweep 2026-11-28: it was made and replayed, but nobody handed back the keys only memory held)
|
|
79
|
+
ensure () { if (worker) return worker; const was = recover; const w = make1(); if (was) { try { onRestarted(w) } catch { /* */ } } return w },
|
|
74
80
|
async ready () {
|
|
75
81
|
const current = worker
|
|
76
82
|
await started
|
package/witbitz-admin.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export interface Billing {
|
|
|
71
71
|
requireUserToken(on?: boolean): Promise<{ requireUserToken: boolean }>
|
|
72
72
|
/** Questions a day people who are not signed in may ask in your rooms — per network and in total; null turns it off (sdk-builder.md#visitor-limits). */
|
|
73
73
|
visitorLimit(limit: { perNetwork: number; total: number } | null): Promise<{ visitorLimit: { perNetwork: number; total: number } | null }>
|
|
74
|
+
/** The same as CSV text. Columns: `day,provider_usd,would_have_cost_usd,charged_usd,storage_bytes,from_day,span_days`, or with
|
|
75
|
+
* `{ byUser: true }` one line per user per day: `day,user_id,user_ref,provider_usd,would_have_cost_usd,charged_usd,from_day,span_days`.
|
|
76
|
+
* `from_day`/`span_days`: the days a line covers — after a missed daily reading one line holds several days' use (a one-day line: its own day, 1). */
|
|
74
77
|
csv(opts?: { byUser?: boolean }): Promise<string>
|
|
75
78
|
/** Your prepaid balance, or null when your app is not on prepaid billing. While `paused`, every op that spends in your rooms is refused (402 tenant_out_of_credit). */
|
|
76
79
|
/** `canBuy`: whether buying credit is open to your app now (while it is in testing, only to the apps in the test) — when false, topUp is refused.
|
package/witbitz-admin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Witbitz admin client — one file for your SERVER (https://witbitz.chat/docs/sdk#builder-calls). Never ship it in a page.
|
|
2
2
|
|
|
3
|
-
// spaces/public/sdk/4.
|
|
3
|
+
// spaces/public/sdk/4.5.0/connCatalog.js
|
|
4
4
|
var GCAL_PROVIDER = "prov_XE5FdiPdAx881HKs";
|
|
5
5
|
var CATALOG = [
|
|
6
6
|
// AN AGENT YOU SEND JOBS TO, not a service you sign in to (the owner, 2026-10-15: "Doesn't grokbot have a connector like
|
|
@@ -154,7 +154,7 @@ var CATALOG = [
|
|
|
154
154
|
{ name: "Gmail", kind: "mail", host: "mail.google.com", desc: "Forward the mail you choose into a Space of your own \u2014 the assistant reads it when you ask.", cat: "Email" }
|
|
155
155
|
];
|
|
156
156
|
|
|
157
|
-
// spaces/public/sdk/4.
|
|
157
|
+
// spaces/public/sdk/4.5.0/cbor.js
|
|
158
158
|
var MAX_LEN = 1 << 22;
|
|
159
159
|
function decode(bytes) {
|
|
160
160
|
const b = toBytes(bytes);
|
|
@@ -348,7 +348,7 @@ function concat(...parts) {
|
|
|
348
348
|
return out;
|
|
349
349
|
}
|
|
350
350
|
|
|
351
|
-
// spaces/public/sdk/4.
|
|
351
|
+
// spaces/public/sdk/4.5.0/x509.js
|
|
352
352
|
var TAG = { INT: 2, BITSTRING: 3, OID: 6, SEQ: 48, UTCTIME: 23, GENTIME: 24 };
|
|
353
353
|
var SIG_OIDS = /* @__PURE__ */ new Map([
|
|
354
354
|
["1.2.840.10045.4.3.2", { hash: "SHA-256" }],
|
|
@@ -522,7 +522,7 @@ async function verifyChain(chainDer, { now = Date.now() } = {}) {
|
|
|
522
522
|
return certs[certs.length - 1];
|
|
523
523
|
}
|
|
524
524
|
|
|
525
|
-
// spaces/public/sdk/4.
|
|
525
|
+
// spaces/public/sdk/4.5.0/nitroVerify.js
|
|
526
526
|
var NITRO_ROOT_G1_B64 = "MIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTELMAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYDVQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4MTQyODA1WjBJMQswCQYDVQQGEwJVUzEPMA0GA1UECgwGQW1hem9uMQwwCgYDVQQLDANBV1MxGzAZBgNVBAMMEmF3cy5uaXRyby1lbmNsYXZlczB2MBAGByqGSM49AgEGBSuBBAAiA2IABPwCVOumCMHzaHDimtqQvkY4MpJzbolL//Zy2YlES1BR5TSksfbb48C8WBoyt7F2Bw7eEtaaP+ohG2bnUs990d0JX28TcPQXCEPZ3BABIeTPYwEoCWZEh8l5YoQwTcU/9KNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUkCW1DdkFR+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYCMQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPWrfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6NIwLz3/Y=";
|
|
527
527
|
var COSE_ALG_ES384 = -35;
|
|
528
528
|
var MAX_DOC = 1 << 20;
|
|
@@ -646,7 +646,7 @@ async function verifyAttestation(cose, { root, now = Date.now(), maxAgeMs = 0, e
|
|
|
646
646
|
return { ok: true, ...doc, leaf };
|
|
647
647
|
}
|
|
648
648
|
|
|
649
|
-
// spaces/public/sdk/4.
|
|
649
|
+
// spaces/public/sdk/4.5.0/sentinelRelease.js
|
|
650
650
|
var BUILD_ENCLAVE_PCR0 = Object.freeze([
|
|
651
651
|
"c6a8cbd0c05d8e003e75b266f1dde2a6426b7cd61f845e4b128e59063e40968b44f30d934bbe1925582fe33bbdd0b1d7",
|
|
652
652
|
"f490096d57e4287146e8b8d7bf4c75f423984ca52199efab0ee8684fbee6cfe6ab82c72d54f05a38f24a0d4ad6e2f557",
|
|
@@ -794,7 +794,7 @@ async function recordPcrBy(r, subject, builders, verify = verifyAttestation) {
|
|
|
794
794
|
return { pcr0, builder };
|
|
795
795
|
}
|
|
796
796
|
|
|
797
|
-
// spaces/public/sdk/4.
|
|
797
|
+
// spaces/public/sdk/4.5.0/sealShare.js
|
|
798
798
|
var enc2 = new TextEncoder();
|
|
799
799
|
var b64 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
800
800
|
async function sealTo(enclaveKey, nonce, bundle) {
|
|
@@ -808,13 +808,13 @@ async function sealTo(enclaveKey, nonce, bundle) {
|
|
|
808
808
|
return { epk: b64(epk), iv: b64(iv), ct: b64(ct), nonce: b64(nonce) };
|
|
809
809
|
}
|
|
810
810
|
|
|
811
|
-
// spaces/public/sdk/4.
|
|
811
|
+
// spaces/public/sdk/4.5.0/connDisp.js
|
|
812
812
|
var enc3 = new TextEncoder();
|
|
813
813
|
var dec = new TextDecoder();
|
|
814
814
|
var SALT = enc3.encode("witbitz-sentinel-display-v1");
|
|
815
815
|
var INFO = enc3.encode("sentinel-display");
|
|
816
816
|
|
|
817
|
-
// spaces/public/sdk/4.
|
|
817
|
+
// spaces/public/sdk/4.5.0/connections.js
|
|
818
818
|
var STANDING_SENTINEL_PCR0 = ["1903ce28fc5a75efe2e57a451d667f1ce8b4b6e11872fb2b81d9e62d8cd994ed80fcfa99807f289af5f281aa4e4cc010"];
|
|
819
819
|
var b642 = (u8) => btoa(String.fromCharCode(...new Uint8Array(u8)));
|
|
820
820
|
var unb642 = (s) => Uint8Array.from(atob(s), (c) => c.charCodeAt(0));
|
|
@@ -928,7 +928,7 @@ async function attestStandingSentinel({ post, auth = {}, pins = STANDING_SENTINE
|
|
|
928
928
|
}
|
|
929
929
|
var MCP_CURATED = CATALOG.filter((c) => c.url).map((c) => ({ label: c.name, url: c.url }));
|
|
930
930
|
|
|
931
|
-
// spaces/public/sdk/4.
|
|
931
|
+
// spaces/public/sdk/4.5.0/sdkRedact.js
|
|
932
932
|
var REDACTED = "[REDACTED]";
|
|
933
933
|
var INSPECT = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
934
934
|
function hide(obj, names) {
|
|
@@ -953,7 +953,7 @@ function redacted(proto, summary) {
|
|
|
953
953
|
});
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
-
// spaces/public/sdk/4.
|
|
956
|
+
// spaces/public/sdk/4.5.0/witbitz-admin.js
|
|
957
957
|
var adminError = (code, message) => Object.assign(new Error(message), { code: String(code || "refused") });
|
|
958
958
|
var DEFAULT_ENDPOINT = "https://api.witbitz.chat/v1/space";
|
|
959
959
|
var ownerRetired = () => adminError("owner_rule_retired", "witbitz: the owner rule (rooms only your app may use) is retired \u2014 a web page cannot prove which app it is (sdk-changes.md, 4.0.0)");
|
package/witbitz-sdk.d.ts
CHANGED
|
@@ -60,8 +60,13 @@ export interface Message {
|
|
|
60
60
|
/** A lane's copy only: the original's franking record and its Space — a report of the copy names the ORIGINAL message. */
|
|
61
61
|
fr?: string
|
|
62
62
|
frRoom?: string
|
|
63
|
-
/** Reactions on this message: emoji → the names that reacted (in a verified room
|
|
63
|
+
/** Reactions on this message: emoji → the names that reacted, one per reactor (in a verified room two members may share a name,
|
|
64
|
+
* so a name can appear twice). Who reacted and whether it is yours: `space.reactionsOf(message)`. */
|
|
64
65
|
reactions?: Record<string, string[]>
|
|
66
|
+
/** Verified rooms: emoji → key id → the name that key reacted under (one reaction per key). */
|
|
67
|
+
reactBy?: Record<string, Record<string, string>>
|
|
68
|
+
/** Verified rooms, the older record: emoji → name → ONE key id that holds that name's reaction. */
|
|
69
|
+
reactKeys?: Record<string, Record<string, string>>
|
|
65
70
|
/** Agent replies: web sources, the turn's usage, and (confidential rooms) the signed turn certificate. */
|
|
66
71
|
sources?: { url: string; title?: string }[]
|
|
67
72
|
usage?: Record<string, unknown>
|
|
@@ -337,7 +342,8 @@ export declare class Space {
|
|
|
337
342
|
}
|
|
338
343
|
invokeSkill(name: string, args?: Record<string, unknown>): Promise<SendResult>
|
|
339
344
|
send(text: string, opts?: SendOptions): Promise<SendResult>
|
|
340
|
-
/** An emoji on a message, or `{ off: true }` to take yours off (sdk-rooms.md#replies). No new entry, no assistant turn.
|
|
345
|
+
/** An emoji on a message, or `{ off: true }` to take yours off (sdk-rooms.md#replies). No new entry, no assistant turn.
|
|
346
|
+
* `{ ok: false, error: 'reaction_limit', reactions }` when the message holds as many as it can (50 names on one emoji, 12 emoji) — nothing was added. */
|
|
341
347
|
react(message: Message, emoji: string, opts?: { off?: boolean; from?: string }): Promise<{ ok: boolean; reactions?: Record<string, string[]>; error?: string }>
|
|
342
348
|
/** send(), plus a handle on this turn's answer. `timeoutMs` (default 960 000, about 16 minutes — as long as the Spaces app waits; a turn may run 13) stops the turn when it passes; 0 = no timeout. */
|
|
343
349
|
turn(text: string, opts?: SendOptions & { timeoutMs?: number }): Turn
|
|
@@ -350,6 +356,12 @@ export declare class Space {
|
|
|
350
356
|
rename(name: string, opts?: { by?: string }): Promise<{ ok: boolean; title: string }>
|
|
351
357
|
setReplyMode(mode: ReplyMode): Promise<{ mode: ReplyMode }>
|
|
352
358
|
replyMode(): Promise<ReplyMode>
|
|
359
|
+
/** The room's model pick for every member — the Spaces app's model chip. It wins over the model `configure()` set, on every
|
|
360
|
+
* turn whoever sends it. `id` is a model of `wb.models()` for this Space's tier; any other id throws `unknown_model` and writes
|
|
361
|
+
* nothing. */
|
|
362
|
+
setModel(id: string): Promise<{ model: string }>
|
|
363
|
+
/** Back to the room's own model (the one `createSpace` / `configure()` set), as the chip's Default does. */
|
|
364
|
+
clearModel(): Promise<{ model: null }>
|
|
353
365
|
/** Which of the assistant's tools run on their own here, and which ask first (a card a person approves). Enforced by the server
|
|
354
366
|
* on every turn; the same setting as the Witbitz app's ⋯ → Tools. In a room with admins only an admin may set them. */
|
|
355
367
|
readonly toolRules: {
|
|
@@ -376,7 +388,8 @@ export declare class Space {
|
|
|
376
388
|
changeMembers(admission: Admission): Promise<MemberChange & { removed: string[]; added: string[]; roles?: true }>
|
|
377
389
|
/** The same members, a new key (a lost phone, a link sent to the wrong place) — sdk-people.md#members. */
|
|
378
390
|
rotateKey(): Promise<MemberChange & { rotated: true }>
|
|
379
|
-
/** Resend the current link through this app's invite directory. Does not add admission. Attested rooms use their native app.
|
|
391
|
+
/** Resend the current link through this app's invite directory. Does not add admission. Attested rooms use their native app.
|
|
392
|
+
* By email, `reason: 'not_enrolled'` = not deliverable by email: never signed in, or not findable by email (alike, on purpose). */
|
|
380
393
|
resendInvite(recipient: { email: string; username?: never } | { username: string; email?: never }): Promise<{ ok: boolean; reason?: string }>
|
|
381
394
|
/** RETIRED (3.0.0): a Space no longer moves — members change in place (`changeMembers`). Always throws `use_change_members`. */
|
|
382
395
|
fork(opts?: unknown): Promise<never>
|
|
@@ -401,18 +414,24 @@ export declare class Space {
|
|
|
401
414
|
isAdmin(email: string): Promise<boolean>
|
|
402
415
|
isOwner(email: string): Promise<boolean>
|
|
403
416
|
/** Import a public ChatGPT, Claude, Gemini or Grok share URL. The server validates the source. */
|
|
404
|
-
importChat(url: string): Promise<{ imported: number; title: string; entries: number }>
|
|
405
|
-
/** Import the text from a WhatsApp chat export (unzip the export first). */
|
|
406
|
-
importWhatsApp(text: string): Promise<{ imported: number; title: string; entries: number }>
|
|
417
|
+
importChat(url: string): Promise<{ imported: number; title: string; entries: number; /** messages cut to 8,000 characters to fit; absent when none */ shortened?: number }>
|
|
418
|
+
/** Import the text from a WhatsApp chat export (unzip the export first). `shortened`: how many messages were cut to 8,000 characters. */
|
|
419
|
+
importWhatsApp(text: string): Promise<{ imported: number; title: string; entries: number; shortened?: number }>
|
|
407
420
|
/** Sealed schedules, shared with the app. Adding/resuming needs an active always-on cloud device. */
|
|
408
421
|
readonly schedules: {
|
|
409
|
-
|
|
422
|
+
/** `next`: an active daily job's next run (ms), by this device's time zone rules — on the night the clocks skip its time, the
|
|
423
|
+
* moment they jump. Absent for every-N-minutes and paused jobs. */
|
|
424
|
+
list(): Promise<Array<{ id: string; when: { every: number } | { at: string; tz: string }; text: string; by: string; at: number; paused?: boolean; pausedAt?: number; next?: number }>>
|
|
425
|
+
/** A daily `at` with no `tz` is saved in this device's time zone (as the app does), so it keeps its local time across clock changes. */
|
|
410
426
|
add(job: { when: { every: number } | { at: string; tz?: string }; text: string }): Promise<{ id: string; when: { every: number } | { at: string; tz: string }; text: string; by: string; at: number }>
|
|
411
427
|
remove(id: string): Promise<unknown[]>
|
|
412
428
|
pause(id: string, paused?: boolean): Promise<unknown[]>
|
|
413
429
|
}
|
|
414
430
|
readonly alwaysOn: {
|
|
415
|
-
|
|
431
|
+
/** `on`: the cloud device holds the Space. `marked`: the account's saved Always on mark (absent when it could not be read) —
|
|
432
|
+
* `on: false, marked: true` = the device let the Space go while the account still keeps it: private assistants and people stay
|
|
433
|
+
* refused (`kept_space`) until `disable()` takes the mark off, or `enable()` keeps it again. */
|
|
434
|
+
status(): Promise<{ on: boolean; registered: boolean; waiting?: string; marked?: boolean }>
|
|
416
435
|
/** A backed-up solo Space; disconnectLanes explicitly turns its private assistants off first. */
|
|
417
436
|
enable(opts?: { disconnectLanes?: boolean }): Promise<{ on: true }>
|
|
418
437
|
disable(): Promise<{ on: false }>
|
|
@@ -424,6 +443,9 @@ export declare class Space {
|
|
|
424
443
|
fileNamed(name: string): { message: Message; att: Media } | null
|
|
425
444
|
/** Did this signed-in session send it? (verified with this session's key; never by a typed name). In a vault: the vault's session. */
|
|
426
445
|
isMine(message: Message): boolean
|
|
446
|
+
/** Who reacted, as the Spaces app shows it. Verified room: one reactor per signed-in member, `mine` by THIS session's key (two
|
|
447
|
+
* members may share a name; a renamed member counts once). Open room: `mine` by name — `from`, or the name this Space sends as. */
|
|
448
|
+
reactionsOf(message: Message, opts?: { from?: string }): Record<string, { count: number; names: string[]; mine: boolean }>
|
|
427
449
|
/** Who wrote it, as Block knows a person (the server's stamps and the signing key; never a typed name) — null: nothing proves it (sdk-people.md#block). */
|
|
428
450
|
blockIdentity(message: Message): BlockWho | null
|
|
429
451
|
/** Report it to Witbitz (App Store rule 1.2; sdk-people.md#report): the message, and with `context: true` the 5 before it. Signed in, a member.
|
|
@@ -432,7 +454,8 @@ export declare class Space {
|
|
|
432
454
|
static readonly REPORT_REASONS: readonly ReportReason[]
|
|
433
455
|
/** Does this Space take only a page proved to be one named app (an attested app)? From its public policy; a failed read throws `policy_unreadable`. In a vault: `vault_unsupported`. */
|
|
434
456
|
attested(): Promise<{ required: boolean; confidential: boolean }>
|
|
435
|
-
|
|
457
|
+
/** `attachmentsMissing`: attachments whose bytes could not be read — the file holds only a pointer to this room for them; export again to include them. */
|
|
458
|
+
exportFile(): Promise<{ count: number; attachmentsMissing?: number }>
|
|
436
459
|
sealedProof(): Promise<Record<string, unknown> | null>
|
|
437
460
|
/** Confidential rooms: verify every reply's turn certificate on this device. */
|
|
438
461
|
certificates(): Promise<{ verified: number; failed: Array<{ id: string; reason: string }>; unchecked: number; before: number; /** a private lane's copies of its Space's replies: not signed by the lane's enclave, so counted here and never in `failed` */ copies: number; builds: Array<{ pcr16: string; pcr17: string; audit: string; replies: number; /** the build enclave's release: rebuilt from `commit`, entry `logIndex` in Rekor (`rekor` links it); null = not in the published log; absent = the log could not be read */ source?: { commit: string; logIndex: number; rekor: string } | null }>; calls: Record<string, number>; tools: Record<string, number> }>
|
|
@@ -483,8 +506,10 @@ export declare class Lane extends Space {
|
|
|
483
506
|
turn(text: string, opts?: SendOptions & { tools?: LaneAction[]; replace?: boolean; links?: Array<Space | { space: Space; label?: string }>; timeoutMs?: number }): Turn
|
|
484
507
|
/** Synchronous: returns the link's handle. */
|
|
485
508
|
link(other: Lane, opts?: { to?: string; as?: string; cap?: number; resume?: LaneLink['state'] }): LaneLink
|
|
486
|
-
/** Connect a kept always-on Space as a job agent of this private lane. Credentials stay in the vault in vault mode.
|
|
487
|
-
|
|
509
|
+
/** Connect a kept always-on Space as a job agent of this private lane. Credentials stay in the vault in vault mode.
|
|
510
|
+
* `delivery`: 'device' — the kept Space's jobs reach the cloud device through the account's message intake; 'client' — that could
|
|
511
|
+
* not be set up (`deliveryError` says why) and its jobs wait at the agent door until a client collects them. */
|
|
512
|
+
linkKept(space: Space, opts?: { spaceName?: string; laneName?: string }): Promise<{ lane: string; space: string; connId: string; lPeer: string; sPeer: string; delivery: 'device' | 'client'; deliveryError?: string }>
|
|
488
513
|
unlinkKept(space: Space, link: { lane: string; space: string; connId: string; lPeer: string; sPeer: string }): Promise<{ disconnected: true }>
|
|
489
514
|
/** Copy the shared room's new messages into this lane now (a lane opened with `mirror`). */
|
|
490
515
|
mirrorNow(): Promise<unknown>
|
|
@@ -567,7 +592,7 @@ export declare class VaultSession {
|
|
|
567
592
|
/** The vault's origin. */
|
|
568
593
|
readonly origin: string
|
|
569
594
|
/** Connection details and the latest room, sign-in and account state reported by the vault. */
|
|
570
|
-
readonly info: { v: number; tenant: string; endpoint: string; signedIn: boolean; email: string; /** the vault session key's PUBLIC id (what `space.isMine` compares) — '' when signed out; an older vault sends none */ keyId?: string; rooms: VaultRoom[]; /** the Siri Shortcut: never its key */ siri: { key: null; hasKey: boolean; endpoint: string }; /** the backup and account, as `wb.backup` / `wb.account` read them */ account: { enabled: boolean; format: string | null; /** 'account' (the Witbitz account service) | 'legacy' | null */ service: 'account' | 'legacy' | null; /** a restore and deleting the account need the emailed code as well */ gated: boolean; deviceId: string; rooms: Array<{ room: string; kind: string; label?: string; /** a lane's Space: its room id */ shared?: string; archived?: boolean; pinned?: boolean }>; devices: unknown[]; links: unknown[]; lastError: { message: string; code?: string; status?: number } | string | null; erasure: boolean }; /** only a vault started with `lock: true` says it: the lock (a passkey at every launch) and storage protection, as the person set them */ lock?: VaultLock; /** only a vault started with `push: true` says it: notifications on this device */ push?: VaultPush; /** the Space whose notification the person tapped to open the vault */ notifOpen?: string }
|
|
595
|
+
readonly info: { v: number; tenant: string; endpoint: string; signedIn: boolean; email: string; /** the vault session key's PUBLIC id (what `space.isMine` compares) — '' when signed out; an older vault sends none */ keyId?: string; rooms: VaultRoom[]; /** the Siri Shortcut: never its key */ siri: { key: null; hasKey: boolean; endpoint: string }; /** the backup and account, as `wb.backup` / `wb.account` read them */ account: { enabled: boolean; format: string | null; /** 'account' (the Witbitz account service) | 'legacy' | null */ service: 'account' | 'legacy' | null; /** a restore and deleting the account need the emailed code as well */ gated: boolean; deviceId: string; rooms: Array<{ room: string; kind: string; label?: string; /** a lane's Space: its room id */ shared?: string; archived?: boolean; pinned?: boolean; /** when the room was last opened or recorded on any of the account's devices — at most an hour behind */ lastOpenedAt?: number }>; devices: unknown[]; links: unknown[]; lastError: { message: string; code?: string; status?: number } | string | null; erasure: boolean }; /** only a vault started with `lock: true` says it: the lock (a passkey at every launch) and storage protection, as the person set them */ lock?: VaultLock; /** only a vault started with `push: true` says it: notifications on this device */ push?: VaultPush; /** the Space whose notification the person tapped to open the vault */ notifOpen?: string }
|
|
571
596
|
/** The Spaces this vault holds, newest first. */
|
|
572
597
|
rooms(): Promise<VaultRoom[]>
|
|
573
598
|
/** A live Space for a room the vault holds; its key stays in the vault (`space.key` and `space.shareLink` are null). A private
|
|
@@ -710,7 +735,7 @@ export interface AccountBackup {
|
|
|
710
735
|
/** Where the account is kept: 'account' (the Witbitz account service — a new account in a vault that names its tenant),
|
|
711
736
|
* 'legacy' (the backup store every account used before), null when there is none on this client. */
|
|
712
737
|
readonly service: 'account' | 'legacy' | null
|
|
713
|
-
readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; laneOrigin?: 'minted'; mintedFor?: string; archived?: boolean; pinned?: boolean }>
|
|
738
|
+
readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; laneOrigin?: 'minted'; mintedFor?: string; archived?: boolean; pinned?: boolean; /** read-only: when the room was last opened or recorded on any of the account's devices (ms since 1970) — at most an hour behind; sort by it, newest first, for the app's order (sdk-accounts.md#account-index) */ lastOpenedAt?: number }>
|
|
714
739
|
onState: ((state: unknown) => void) | null
|
|
715
740
|
enable(opts?: { email?: string }): Promise<{ code: string }>
|
|
716
741
|
restore(opts: { code: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: AccountBackup['rooms'] }>
|
|
@@ -754,7 +779,9 @@ export interface AccountBackup {
|
|
|
754
779
|
export interface AccountIndex {
|
|
755
780
|
readonly enabled: boolean
|
|
756
781
|
readonly deviceId: string
|
|
757
|
-
|
|
782
|
+
/** `alwaysOn: true` — the account's saved Always on mark, as of the last sync (absent: not marked, or no sync yet). People and
|
|
783
|
+
* private assistants are refused for a marked Space (`kept_space`) even when its cloud device let it go (`alwaysOn.status()`). */
|
|
784
|
+
readonly rooms: Array<AccountBackup['rooms'][number] & { alwaysOn?: true }>
|
|
758
785
|
/** `sdk`: the SDK release a device last synced with (3.24.0 and later; an older device has none). */
|
|
759
786
|
readonly devices: Array<{ id: string; name: string; seenAt: number; signedOut: boolean; current: boolean; sdk?: string }>
|
|
760
787
|
readonly links: Array<{ a: string; b: string; cap?: number }>
|
|
@@ -778,12 +805,12 @@ export interface AccountIndex {
|
|
|
778
805
|
signOutDevice(deviceId: string, opts?: { getCode?: (address: string) => Promise<string> }): Promise<{ revoked: boolean }>
|
|
779
806
|
signOut(deviceId: string, opts?: { reason?: 'erased' | 'moved' }): this
|
|
780
807
|
/** `signedOut: true` (and empty lists) when another device signed this one out. */
|
|
781
|
-
sync(): Promise<{ ok: boolean; rooms:
|
|
808
|
+
sync(): Promise<{ ok: boolean; rooms: AccountIndex['rooms']; devices: AccountIndex['devices']; signedOut?: boolean }>
|
|
782
809
|
start(opts?: { every?: number }): this
|
|
783
810
|
stop(): this
|
|
784
811
|
/** What this account's turns cost in a month (UTC, default this one), across its rooms, whoever paid — folded from the
|
|
785
812
|
* receipts every turn carries (docs: #account-usage). Amounts in micro-dollars; `costUsd` in dollars. */
|
|
786
|
-
usage(opts?: { month?: string }): Promise<{ month: string; replies: number; costMicros: number; costUsd: number; in: number; out: number; byPayer: { you: number; admin: number; app: number; witbitz: number }; byDay: Record<string, number> }>
|
|
813
|
+
usage(opts?: { month?: string }): Promise<{ month: string; replies: number; costMicros: number; costUsd: number; in: number; out: number; /** replies whose cost counts only their priced calls (some calls reported no price): costMicros is then a floor */ unpriced: number; byPayer: { you: number; admin: number; app: number; witbitz: number }; byDay: Record<string, number> }>
|
|
787
814
|
/** Optional sections (3.24.0), kept as the Spaces app keeps them: nothing is read until you use one (sdk-accounts.md#account-sections). */
|
|
788
815
|
readonly contacts: AccountContacts
|
|
789
816
|
readonly name: AccountSection<string>
|
|
@@ -800,8 +827,8 @@ export interface AccountIndex {
|
|
|
800
827
|
remove(lock: { lockId: string }): Promise<Record<string, unknown> | null>
|
|
801
828
|
changePin(lock: { lockId: string; pin: string; newPin: string }): Promise<Record<string, unknown> | null>
|
|
802
829
|
previewDeleteAll(): Promise<{ targets: { lockId: string; kind: 'room' | 'code'; target: string }[]; privateAssistants: { room: string; parent: string; title: string }[] }>
|
|
803
|
-
/** Removes the listed targets without requiring their PIN. */
|
|
804
|
-
deleteAll(opts?: { includePrivateAssistants?: boolean; privateAssistantRooms?: readonly string[] }): Promise<{ lockId: string; kind: 'code' | 'room'; target: string; deleted: boolean }[]>
|
|
830
|
+
/** Removes the listed targets without requiring their PIN. Pass `lockIds` from previewDeleteAll so a lock added since is not deleted; without them, a call right after a preview fails `changed_meanwhile` (`added`) when a lock was added since. */
|
|
831
|
+
deleteAll(opts?: { includePrivateAssistants?: boolean; privateAssistantRooms?: readonly string[]; lockIds?: readonly string[] }): Promise<{ lockId: string; kind: 'code' | 'room'; target: string; deleted: boolean }[]>
|
|
805
832
|
/** Uses the app's synced wrong-PIN backoff. Does not isolate or encrypt room data. */
|
|
806
833
|
match(attempt: { pin: string }): Promise<{ ok: boolean; next: number; matches: { lockId: string; kind: 'code' | 'room'; target: string; title: string }[] }>
|
|
807
834
|
/** Uses the app's synced wrong-PIN backoff. Does not isolate or encrypt room data. */
|
|
@@ -865,6 +892,14 @@ export interface InviteAccount {
|
|
|
865
892
|
restore(state: unknown): this
|
|
866
893
|
/** Publish it (signIn and refreshSession do). → the status */
|
|
867
894
|
enroll(): Promise<InviteAccount['status']>
|
|
895
|
+
/** The invitations delivered to this account for this app (`resendInvite`, a member change's invite), newest per room, opened with
|
|
896
|
+
* this device's invite key. The inbox keeps them all: every call returns every one. Open one with `openSpace(link)`. In vault
|
|
897
|
+
* mode the vault opens them, asks the person before joining a Space it does not hold, and returns only the rooms it holds, each
|
|
898
|
+
* with `link: ''` — open one with `wb.vault.openRoom(room)` (an older vault kit: `vault_unsupported`). Throws
|
|
899
|
+
* `no_invite_key`, `unreachable`. Anyone who finds the inbox can drop an invitation: `link` is
|
|
900
|
+
* always an https address of `room` carrying its key (others are skipped), but `title` and `from` are the sender's own words —
|
|
901
|
+
* show them as text, never as markup. */
|
|
902
|
+
collect(): Promise<Array<{ room: string; link: string; title: string; from: string; at: number }>>
|
|
868
903
|
}
|
|
869
904
|
|
|
870
905
|
/** `wb.a2a` — the account's A2A record. Persist `state` (it holds the lanes' inbox private keys). */
|
|
@@ -1031,7 +1066,8 @@ export interface Computer {
|
|
|
1031
1066
|
setDefaultPrivate(on: boolean): Promise<void>
|
|
1032
1067
|
setSessionPrivate(session: string, on: boolean): Promise<true>
|
|
1033
1068
|
}
|
|
1034
|
-
/** What a reply produced: files it wrote, the browser's screenshots, files its answer names that changed. `messages` omitted = the latest reply.
|
|
1069
|
+
/** What a reply produced: files it wrote, the browser's screenshots, files its answer names that changed. `messages` omitted = the latest reply.
|
|
1070
|
+
* A named file is listed only once the computer says it is there (and, for the latest reply, changed since its prompt). */
|
|
1035
1071
|
outputs(sessionId: string, messages?: unknown[]): Promise<Array<{ path: string; kind: 'pdf' | 'image' | 'table' | 'text' | 'file'; source: 'wrote' | 'shot' | 'named' }>>
|
|
1036
1072
|
readonly egress: { get(): unknown }
|
|
1037
1073
|
/** Live events (OpenCode's): a type such as 'message.part.updated', 'permission.asked', 'session.idle', or '*'. → off
|
|
@@ -1084,7 +1120,7 @@ import type { Origins, DeclaredHosts, Providers, TenantRooms, Customers, Billing
|
|
|
1084
1120
|
export type VaultAccountIndex = Omit<AccountIndex, 'rooms' | 'onChange' | 'archive' | 'pin' | 'rename' | 'forget' | 'signOut' | 'sync' | 'start' | 'stop' | 'signOutDevice' | 'chatLocks'> & {
|
|
1085
1121
|
readonly chatLocks: Omit<AccountIndex['chatLocks'], 'deleteAll'> & { deleteAll(): ReturnType<AccountIndex['chatLocks']['deleteAll']> }
|
|
1086
1122
|
signOutDevice(deviceId: string): Promise<{ revoked: boolean }>
|
|
1087
|
-
readonly rooms: ReadonlyArray<Omit<AccountBackup['rooms'][number], 'link'
|
|
1123
|
+
readonly rooms: ReadonlyArray<Omit<AccountBackup['rooms'][number], 'link'> & { alwaysOn?: true }>
|
|
1088
1124
|
onChange: ((index: Pick<VaultAccountIndex, 'rooms' | 'devices'>) => void) | null
|
|
1089
1125
|
archive(room: string, on?: boolean): Promise<object>
|
|
1090
1126
|
pin(room: string, on?: boolean): Promise<object>
|
|
@@ -1136,7 +1172,7 @@ export declare class Witbitz {
|
|
|
1136
1172
|
readonly usernames: Usernames
|
|
1137
1173
|
recreateSpace(bundle: { kind: string; entries: unknown[]; config?: Record<string, unknown>; tier?: Tier }, opts?: { tier?: Tier }): Promise<{ space: Space; carried: number; total: number; titleWarning?: string }>
|
|
1138
1174
|
saveOfflineReader(): Promise<void>
|
|
1139
|
-
exportOfflineArchive(opts?: { recoveryKeys?: boolean; rooms?: Space[]; destination?: 'download' | 'clipboard' }): Promise<{ saved: number; unavailable: string[] }>
|
|
1175
|
+
exportOfflineArchive(opts?: { recoveryKeys?: boolean; rooms?: Space[]; destination?: 'download' | 'clipboard' }): Promise<{ saved: number; unavailable: string[]; /** stored photos and documents: how many went into the file (sealed), how many were left out — past the 50 MB cap, or unreadable */ attachments?: { included: number; tooLarge: number; failed: number } }>
|
|
1140
1176
|
createSpace(opts: { /** @deprecated retired in 4.0.0 — `owner` rejects with `owner_rule_retired` */ owner?: never; skills?: Record<string, { in: Record<string, 'string' | 'number' | 'boolean' | 'array' | 'object'>; out?: Record<string, 'string' | 'number' | 'boolean' | 'array' | 'object'> }>; clientTools?: ToolDef[]; agentReplies?: boolean; agent?: AgentSpec; tools?: ToolDef[]; immediateTools?: string[]; model?: AgentSpec['model']; data?: Record<string, unknown>; platformTools?: PlatformTools; framing?: Framing; dataWrites?: boolean; /** a direct chat with this address (sdk-people.md#direct-chats) — instead of admission */ direct?: string; usernames?: boolean; admission?: Admission; tier?: Tier; key?: 'split'; region?: string; /** a room wiped when idle: true (≈30 min), or { days } (1–7) after its last question (sdk-rooms.md#temporary) */ temporary?: true | { days: number; title?: string }; /** others' photos and PDFs shown only from copies an attested enclave made safe (sdk-rooms.md#safe-media) */ safeMedia?: boolean; /** every member gets a private assistant (sdk-agents.md#lanes-for-everyone) */ lanes?: boolean }): Promise<Space>
|
|
1141
1177
|
/** `link` is REQUIRED (a share link: `<viewer>/space?room=…#mk=…`); the current page URL is not read for you. */
|
|
1142
1178
|
openSpace(link: string, opts?: { resume?: Snapshot; tier?: Tier }): Promise<Space>
|
|
@@ -1184,8 +1220,8 @@ export declare function checkDataSchema(data: Record<string, unknown>): void
|
|
|
1184
1220
|
export declare function isLaneCopy(m: Message | Record<string, unknown>): boolean
|
|
1185
1221
|
|
|
1186
1222
|
// AG-UI 1.0 (sdk-agents.md#ag-ui)
|
|
1187
|
-
export declare function aguiRun(space: Space, input: { threadId?: string; runId?: string; messages?: unknown[]; context?: unknown[]; resume?: unknown }, opts?: { from?: string; mode?: ReplyMode; timeoutMs?: number; graceMs?: number; signal?: AbortSignal }): AsyncIterable<Record<string, unknown>>
|
|
1188
|
-
export declare function aguiHistory(space: Space):
|
|
1223
|
+
export declare function aguiRun(space: Space, input: { threadId?: string; runId?: string; messages?: unknown[]; context?: unknown[]; resume?: unknown }, opts?: { from?: string; mode?: ReplyMode; timeoutMs?: number; graceMs?: number; pendingWaitMs?: number; signal?: AbortSignal }): AsyncIterable<Record<string, unknown>>
|
|
1224
|
+
export declare function aguiHistory(space: Space): { type: 'MESSAGES_SNAPSHOT'; timestamp: number; messages: { id: string; role: 'assistant' | 'user'; content: string; name?: string }[] }
|
|
1189
1225
|
export declare function aguiAgent(lib: { AbstractAgent: unknown; Observable: unknown }, space: Space, opts?: { threadId?: string; agentConfig?: Record<string, unknown>; [k: string]: unknown }): unknown
|
|
1190
1226
|
|
|
1191
1227
|
// RATS / EAT (sdk-keys.md#eat)
|