@witbitz/sdk 4.6.0 → 4.7.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/acctV2Switch.js +3 -2
- package/acctV2UiCore.js +2 -2
- package/codeBrowse.js +3 -3
- package/codeCache.js +4 -3
- package/codeCloud.js +4 -0
- package/earlierHistory.js +32 -0
- package/emailFork.js +3 -1
- package/l1-worker-src.js +1 -1
- package/manifest.json +24 -22
- package/memberChange.js +9 -2
- package/package.json +4 -2
- package/roomRoles.js +116 -0
- package/roomRoster.js +4 -1
- package/sdkA2A.js +2 -2
- package/sdkBackup.js +1 -0
- package/sdkComputers.js +1 -0
- package/sdkExports.js +11 -3
- package/sdkRekey.js +51 -4
- package/spaceClient.js +6 -3
- package/vault-core.js +51 -28
- package/vault-kit.mjs +1 -1
- package/witbitz-admin.mjs +10 -10
- package/witbitz-sdk.d.ts +20 -6
- package/witbitz-sdk.js +101 -16
package/vault-core.js
CHANGED
|
@@ -778,17 +778,20 @@ export async function startVault(o = {}) {
|
|
|
778
778
|
const get = () => read(st, key, {}) || {}
|
|
779
779
|
const unchanged = () => who() === owner && privacyEpoch === epoch && JSON.stringify(get()[pending]) === JSON.stringify(entry)
|
|
780
780
|
if (!unchanged()) return
|
|
781
|
+
// ★ A DROPPED SIRI ENTRY MAY ALREADY BE AT THE SENTINEL (its answer was lost — why it was pending), naming an inbox key only it held:
|
|
782
|
+
// captures nobody here could open. The record this vault DOES hold is sent at once, as the app's siri.js converge (sync sweep 11-28 P8)
|
|
783
|
+
const converge = async () => { const held = (read(st, key, {}) || {})[owner]; if (key === KEYS.siri && held?.token && who() === owner && privacyEpoch === epoch) await api._push(held).catch(() => {}) }
|
|
781
784
|
for (let attempt = 0; attempt < 3 && unchanged(); attempt++) {
|
|
782
785
|
const current = get()[owner] || null
|
|
783
786
|
if (key === KEYS.siri && entry.next && ((current?.rev || 0) > (entry.base?.rev || 0) || (entry.base?.token && current?.token && entry.base.token !== current.token) || ((entry.base?.token || entry.base?.tokenHash) && !current?.token && !current?.tokenHash))) {
|
|
784
|
-
const kept = get(); delete kept[pending]; put(key, kept); return
|
|
787
|
+
const kept = get(); delete kept[pending]; put(key, kept); await converge(); return
|
|
785
788
|
}
|
|
786
789
|
const next = applyEdit(entry.next ? entry.base : committed, entry.next || entry, current)
|
|
787
790
|
if (!next) return
|
|
788
791
|
try {
|
|
789
792
|
await api._push(next)
|
|
790
793
|
} catch (error) {
|
|
791
|
-
if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept) }
|
|
794
|
+
if (unchanged() && error.definiteRefusal) { const kept = get(); delete kept[pending]; put(key, kept); await converge() }
|
|
792
795
|
return
|
|
793
796
|
}
|
|
794
797
|
if (!unchanged()) return
|
|
@@ -807,7 +810,7 @@ export async function startVault(o = {}) {
|
|
|
807
810
|
const saveA2A = () => { const w = who(); if (!w) return; const all = read(st, KEYS.a2a, {}); all[w] = sdk.a2a.state; put(KEYS.a2a, all); keepSoon() }
|
|
808
811
|
// A LANE GIVEN A NEW ADDRESS mid-grant (handle_taken: the old one was the person's other Witbitz app's account's; sdkA2A _readdress):
|
|
809
812
|
// kept in the vault's store BEFORE the grant is sent again, and the page's lane views read again (cardUrl / mcpUrl move with it)
|
|
810
|
-
sdk.a2a.onReaddressed = (lanes) => { saveA2A(); emit({ ev: 'a2aChanged', readdressed: lanes.map((l) => l.room) }) }
|
|
813
|
+
sdk.a2a.onReaddressed = (lanes) => { saveA2A(); emit({ ev: 'a2aChanged', readdressed: lanes.map((l) => l.room), addresses: lanes.map(({ room, cardUrl, mcpUrl }) => ({ room, cardUrl, mcpUrl })) }) } // addresses: public, the page's wb.a2a.onReaddressed (sync sweep 11-29 #12)
|
|
811
814
|
// ── THE SAME THREE ON EVERY DEVICE OF THE ACCOUNT (vaultKeep.js; sync sweep 2026-11-11 P7): a second device listed this account's
|
|
812
815
|
// connections but could not use one (`not_in_vault`), and could not open Siri or an outside agent's message. Synced, sealed,
|
|
813
816
|
// through the account's index room — only while the backup is on (it is what derives that room). One pass at a time; a pass
|
|
@@ -1229,7 +1232,7 @@ export async function startVault(o = {}) {
|
|
|
1229
1232
|
const syncError = a.lastError || (lastKeepFailure?.owner === who() && lastKeepFailure?.master === b._s?.master ? lastKeepFailure?.error : null)
|
|
1230
1233
|
return {
|
|
1231
1234
|
enabled: b.enabled, format: b.format, service: b.service, deviceId: a.deviceId, // service: 'account' (the Witbitz account service) | 'legacy' | null
|
|
1232
|
-
rooms: b.rooms.map(({ room, kind, label, shared, detachedLane, archived, pinned, lastOpenedAt }) => ({ room, kind, ...(detachedLane ? { detachedLane: true } : {}), ...(pinned ? { pinned: true } : {}), ...(label ? { label } : {}), ...(shared ? { shared } : {}), ...(archived ? { archived: true } : {}), ...(lastOpenedAt > 0 ? { lastOpenedAt } : {}), ...(a._keptMarks && a._keptMarks.has(room) ? { alwaysOn: true } : {}) })), // lastOpenedAt: read-only, as the direct SDK (side sweep: sdk-account-room-list-omits-recency)
|
|
1235
|
+
rooms: b.rooms.map(({ room, kind, label, shared, laneOrigin, mintedFor, detachedLane, archived, pinned, lastOpenedAt }) => ({ room, kind, ...(detachedLane ? { detachedLane: true } : {}), ...(pinned ? { pinned: true } : {}), ...(label ? { label } : {}), ...(shared ? { shared } : {}), ...(laneOrigin ? { laneOrigin } : {}), ...(mintedFor ? { mintedFor } : {}), ...(archived ? { archived: true } : {}), ...(lastOpenedAt > 0 ? { lastOpenedAt } : {}), ...(a._keptMarks && a._keptMarks.has(room) ? { alwaysOn: true } : {}) })), // lastOpenedAt: read-only, as the direct SDK (side sweep: sdk-account-room-list-omits-recency)
|
|
1233
1236
|
devices: a.devices, links: a.links, lastError: syncError ? { message: String(syncError.message || syncError).slice(0, 200), ...(typeof syncError.code === 'string' ? { code: syncError.code.slice(0, 60) } : {}), ...(Number.isInteger(syncError.status) ? { status: syncError.status } : {}) } : null,
|
|
1234
1237
|
erasure: sdk.erasure.available,
|
|
1235
1238
|
gated: !!b.gated, // a restore and deleting the account need the emailed code as well (sync sweep 11-09 #24)
|
|
@@ -1446,7 +1449,12 @@ export async function startVault(o = {}) {
|
|
|
1446
1449
|
if (forgetMark(room) !== mark) throw new Error('vault could not save the room removal')
|
|
1447
1450
|
pendingForget.add(room)
|
|
1448
1451
|
write(st, KEYS.pendingForget, [...pendingForget])
|
|
1449
|
-
rooms
|
|
1452
|
+
// its private lanes stay as rooms of their own — never lanes of a Space this device no longer holds (as backup.remove, sdkBackup.js)
|
|
1453
|
+
rooms = rooms.filter(r => r.room !== room).map(r => {
|
|
1454
|
+
if (r.lane !== room) return r
|
|
1455
|
+
const { lane, laneOrigin, ...rest } = r
|
|
1456
|
+
return { ...rest, ...(laneOrigin === 'minted' && !r.mintedFor ? { mintedFor: lane } : {}), detachedLane: true, associationAt: Math.max(Date.now(), Number(r.associationAt) || 0) }
|
|
1457
|
+
})
|
|
1450
1458
|
emit({ ev: 'rooms', rooms: publicRooms() })
|
|
1451
1459
|
streamGrants.delete(room)
|
|
1452
1460
|
if (streaming.delete(room)) syncStream(worker, room, null)
|
|
@@ -1764,26 +1772,29 @@ export async function startVault(o = {}) {
|
|
|
1764
1772
|
if (!sec || !sec._calls.includes(op)) throw Object.assign(new Error('vault: account.' + String(name).slice(0, 20) + '.' + String(op).slice(0, 20) + ' is not available to the page'), { code: 'vault_refused' })
|
|
1765
1773
|
if (!watchedSections.has(name)) { watchedSections.add(name); sec.on('change', (value) => emit({ ev: 'accountSection', section: name, value })) } // another device's change reaches the page
|
|
1766
1774
|
let result
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
if (
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1775
|
+
// the page's chatLocks.value follows every call, a refused or cancelled one too: a preview's sync or a wrong PIN's try changed it
|
|
1776
|
+
// (sync sweep 11-27 P7) — never another account's
|
|
1777
|
+
const shown0 = sdk.backup._s, shownEpoch = privacyEpoch
|
|
1778
|
+
try {
|
|
1779
|
+
if (name === 'chatLocks' && op === 'deleteAll') {
|
|
1780
|
+
const owner = sdk.backup._s, epoch = privacyEpoch, { targets: locks, privateAssistants: assistants } = await sec.previewDeleteAll()
|
|
1781
|
+
if (!locks.length) return []
|
|
1782
|
+
const lockedRooms = new Set(locks.filter(l => l.kind === 'room').map(l => l.target))
|
|
1783
|
+
const extra = assistants.length ? ' Their private assistants will also be removed: ' + assistants.map(r => r.title || r.room).join(', ') + '.' : ''
|
|
1784
|
+
const roomCount = lockedRooms.size
|
|
1785
|
+
const confirmed = await confirmWith({ title: 'Delete all locked chats?', text: 'Remove ' + roomCount + ' locked Spaces from this account and delete ' + (locks.length - roomCount) + ' Code sessions on their computers? Forgetting a Space leaves its sealed messages on the server. Independently linked rooms keep their copies.' + extra, ok: 'Delete all', cancel: 'Cancel' })
|
|
1786
|
+
if (!confirmed) throw Object.assign(new Error('Cancelled'), { code: 'cancelled' })
|
|
1787
|
+
if (epoch !== privacyEpoch || owner !== sdk.backup._s) throw Object.assign(new Error('The account changed.'), { code: 'account_changed' })
|
|
1788
|
+
result = await sec._deleteTargets(locks, owner, async (kind, room) => {
|
|
1789
|
+
if (epoch !== privacyEpoch) throw new Error('Account changed')
|
|
1790
|
+
if (kind === 'room' && held(room)) await dropRoom(room)
|
|
1791
|
+
}, assistants.map(r => r.room))
|
|
1792
|
+
if (epoch === privacyEpoch && owner === sdk.backup._s) await fromBackup()
|
|
1793
|
+
} else {
|
|
1794
|
+
result = await sec[op](...rest.slice(0, 1))
|
|
1783
1795
|
}
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
if (name === 'chatLocks' && (op === 'match' || op === 'check')) emit({ ev: 'accountSection', section: name, value: sec.value })
|
|
1796
|
+
} finally {
|
|
1797
|
+
if (name === 'chatLocks' && shownEpoch === privacyEpoch && shown0 === sdk.backup._s) emit({ ev: 'accountSection', section: name, value: sec.value })
|
|
1787
1798
|
}
|
|
1788
1799
|
if (name === 'blocks' || name === 'chatLocks') {
|
|
1789
1800
|
// A refresh already in flight may have read the list before this change.
|
|
@@ -1825,9 +1836,9 @@ export async function startVault(o = {}) {
|
|
|
1825
1836
|
if (ns === 'backup' && SERVICE_CALLS.has(m) && !(sdk.backup._v2 && sdk.backup.service === 'account' && sdk.backup.enabled)) throw Object.assign(new Error('witbitz: this call is for an account on the Witbitz account service, in a vault that names its tenant (wb.backup.service === \'account\')'), { code: 'not_on_service' })
|
|
1826
1837
|
if (ns === 'cloudDevice' && m === 'register' && !(sdk.backup._v2 && sdk.backup.service === 'account' && sdk.backup.enabled)) throw Object.assign(new Error('register the cloud device from an account on the account service'), { code: 'not_on_service' })
|
|
1827
1838
|
if (spec.confirm) {
|
|
1828
|
-
const epoch = privacyEpoch, owner = who()
|
|
1839
|
+
const epoch = privacyEpoch, owner = who(), account = sdk.backup._s
|
|
1829
1840
|
await confirmCall(ns, m, args)
|
|
1830
|
-
if (epoch !== privacyEpoch || owner !== who()) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
|
|
1841
|
+
if (epoch !== privacyEpoch || owner !== who() || account !== sdk.backup._s) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
|
|
1831
1842
|
}
|
|
1832
1843
|
if (ns === 'cloudDevice' && (m === 'enroll' || m === 'register')) return sdk.cloudDevice[m]({ getCode: await emailCodeAsker('cloud-device', accountAddress) })
|
|
1833
1844
|
if (ns === 'backup') return backupCall(m, args)
|
|
@@ -1926,7 +1937,8 @@ export async function startVault(o = {}) {
|
|
|
1926
1937
|
if (ns === 'portable') {
|
|
1927
1938
|
const { saveRoomExport } = await import('./sdkExports.js')
|
|
1928
1939
|
const epoch = privacyEpoch, it = held(room) && rooms.find((r) => r.room === room)
|
|
1929
|
-
|
|
1940
|
+
const earlierKeys = Object.fromEntries(rooms.filter((r) => currentRoom(r) && r.room !== room).map((r) => [r.room, 'held'])) // the worker reads each with its own key
|
|
1941
|
+
return await saveRoomExport(sp, it?.enc ? 'enclave' : 'standard', () => epoch === privacyEpoch && !!held(room), it?.title || '', earlierKeys)
|
|
1930
1942
|
}
|
|
1931
1943
|
if (ns === 'privateRoom') {
|
|
1932
1944
|
const target = rooms.find(r => currentRoom(r) && r.room === args[0])
|
|
@@ -2163,6 +2175,15 @@ export async function startVault(o = {}) {
|
|
|
2163
2175
|
creates.push(now)
|
|
2164
2176
|
if (cfg.usernames !== undefined && (cfg.usernames !== false || cfg.admission !== 'email')) throw Object.assign(new Error('vault: only verified Spaces can hide usernames'), { code: 'invalid_argument' })
|
|
2165
2177
|
if (cfg.direct !== undefined && (cfg.direct !== true || cfg.admission !== 'email')) throw Object.assign(new Error('vault: a direct chat is an email-gated Space'), { code: 'invalid_argument' })
|
|
2178
|
+
// OWNERS AND ADMINS AS THEY PREFER (docs/spaces-usernames.md § 13.1): the vault's signed-in member, and anyone made owner or admin, by
|
|
2179
|
+
// the room's tag for their @username when they prefer it (the SDK's own rule, _rolesAsPreferred) — chosen HERE, never by the page
|
|
2180
|
+
// …and the hidden addresses whose person prefers their @username go on the list as that name's tag (§ 13; the SDK's _addAsPreferred —
|
|
2181
|
+
// the page sent the emails as typed: sync sweep 11-29 #6)
|
|
2182
|
+
if (cfg.admission === 'email' && cfg.allow) {
|
|
2183
|
+
cfg = { ...cfg, allow: { ...cfg.allow } }
|
|
2184
|
+
if (cfg.direct !== true) { try { await sdk._addAsPreferred(cfg) } catch { /* a lookup that fails: the addresses stay as typed */ } }
|
|
2185
|
+
try { await sdk._rolesAsPreferred(cfg) } catch { /* a lookup that fails: the roles name the emails, as before */ }
|
|
2186
|
+
}
|
|
2166
2187
|
// Attest FIRST — loud on a configuration failure (no published claim: never mint a confidential room that pins
|
|
2167
2188
|
// nothing), soft on a cold enclave (woken below) — then mint, wake, and hand the enclave its own sealed config.
|
|
2168
2189
|
if (enclave) { await sdk._encAttestSoft(); pushEnclave() }
|
|
@@ -2355,8 +2376,10 @@ export async function startVault(o = {}) {
|
|
|
2355
2376
|
if (!held(room)) return { forgotten: false }
|
|
2356
2377
|
// removing a Space's key from this device can lose it for good (no other copy): the PERSON confirms it (security review)
|
|
2357
2378
|
const it = rooms.find((x) => x.room === room)
|
|
2358
|
-
const accountWide = sdk.backup.enabled
|
|
2379
|
+
const accountWide = sdk.backup.enabled, epoch = privacyEpoch, owner = who(), account = sdk.backup._s
|
|
2359
2380
|
if (!(await confirmWith({ title: 'Remove ' + (it && it.title ? '“' + it.title + '”' : 'this Space') + (accountWide ? ' from your account?' : ' from this device?'), text: accountWide ? 'This removes it from every device that syncs this account.' : 'Without its invite link you cannot open it here again.', ok: 'Remove', cancel: 'Keep' }).catch(() => false))) throw Object.assign(new Error('cancelled'), { code: 'cancelled' })
|
|
2381
|
+
// what the person confirmed was THIS account's room: a sign-in, a restore or a backup turned on meanwhile is another (sync sweep 11-27 P7)
|
|
2382
|
+
if (epoch !== privacyEpoch || owner !== who() || account !== sdk.backup._s || accountWide !== sdk.backup.enabled || !held(room)) throw Object.assign(new Error('the account changed during confirmation'), { code: 'account_changed' })
|
|
2360
2383
|
if (accountWide && sdk.backup.enabled) { sdk.account.forget(room); await fromBackup() }
|
|
2361
2384
|
await dropRoom(room) // and from the account, on every device
|
|
2362
2385
|
return { forgotten: true }
|
package/vault-kit.mjs
CHANGED
|
@@ -20,7 +20,7 @@ import { createHash } from 'node:crypto'
|
|
|
20
20
|
import { join, dirname } from 'node:path'
|
|
21
21
|
|
|
22
22
|
export const DEFAULTS = { endpoint: 'https://api.witbitz.chat/v1/space', loginBase: 'https://witbitz-spaces.pages.dev', from: 'https://witbitz.chat/sdk/latest/', enclaveClaim: 'https://witbitz-spaces.pages.dev/enclave-claim.json', accountService: 'https://api.witbitz.chat/v1' } // enclaveClaim: the confidential tier's published measurement (and its policy text, beside it)
|
|
23
|
-
export const KIT_RELEASE = '4.
|
|
23
|
+
export const KIT_RELEASE = '4.7.0' // tools/sdk-release.mjs stamps the version here, so a downloaded copy builds from ITS release
|
|
24
24
|
export function stampSdkAuth(src) {
|
|
25
25
|
return src.replaceAll('__' + 'SPACE_AUTH_BROKER' + '__', 'https://auth.witbitz.chat').replaceAll('__' + 'SPACE_AUTH_FORCE_BROKER' + '__', '0')
|
|
26
26
|
}
|
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.7.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.7.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.7.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.7.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.7.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.7.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.7.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.7.0/connections.js
|
|
818
818
|
var STANDING_SENTINEL_PCR0 = ["0e424db41977965bc6edf225229eae70fe162dd8264b1ac0b5670cb3f71bf8b923001341e85a665354b25cd8418ac6d3"];
|
|
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.7.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.7.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
|
@@ -137,9 +137,14 @@ export interface Admission {
|
|
|
137
137
|
domains?: string[]
|
|
138
138
|
/** true: every address is readable to members; an array: just those (each must be in `emails`). Else room-salted hashes. */
|
|
139
139
|
advertise?: boolean | string[]
|
|
140
|
-
/** Admins and owners, by email; each must also be admitted by the gate.
|
|
140
|
+
/** Admins and owners, by email; each must also be admitted by the gate. One who prefers their @username ("Add me to Spaces as
|
|
141
|
+
* @username") is named in the role by the room's tag for it instead of the email, once the service takes such roles. */
|
|
141
142
|
admins?: string[]
|
|
142
143
|
owners?: string[]
|
|
144
|
+
/** changeMembers only: the roles held by @username tag, stated in full (as `admission()` reports them). Unstated: kept, less a holder
|
|
145
|
+
* whose email the guest book knows and `owners`/`admins` leave out. */
|
|
146
|
+
ownerTags?: string[]
|
|
147
|
+
adminTags?: string[]
|
|
143
148
|
}
|
|
144
149
|
/** What `space.admission()` reads back from the room's sealed config. */
|
|
145
150
|
export interface AdmissionInfo {
|
|
@@ -152,6 +157,12 @@ export interface AdmissionInfo {
|
|
|
152
157
|
unopenedPrivateInvites?: number
|
|
153
158
|
admins?: string[]
|
|
154
159
|
owners?: string[]
|
|
160
|
+
/** Owners and admins named by their @username's tag (not their email) — present only when some are. `ownerUsers`/`adminUsers`: the
|
|
161
|
+
* @usernames matched to those tags (a holder not matched yet is counted in the tags only). */
|
|
162
|
+
ownerTags?: string[]
|
|
163
|
+
adminTags?: string[]
|
|
164
|
+
ownerUsers?: string[]
|
|
165
|
+
adminUsers?: string[]
|
|
155
166
|
/** This room is a member's private lane (not a Space). */
|
|
156
167
|
lane?: true
|
|
157
168
|
/** This Space gives every member a private lane (`createSpace({ lanes: true })`, the app's option). */
|
|
@@ -411,6 +422,7 @@ export declare class Space {
|
|
|
411
422
|
}>
|
|
412
423
|
admission(): Promise<AdmissionInfo>
|
|
413
424
|
admits(email: string): Promise<boolean>
|
|
425
|
+
/** `email` or `'@username'` — an owner or admin named by their @username's tag is found by the name. */
|
|
414
426
|
isAdmin(email: string): Promise<boolean>
|
|
415
427
|
isOwner(email: string): Promise<boolean>
|
|
416
428
|
/** Import a public ChatGPT, Claude, Gemini or Grok share URL. The server validates the source. */
|
|
@@ -454,8 +466,10 @@ export declare class Space {
|
|
|
454
466
|
static readonly REPORT_REASONS: readonly ReportReason[]
|
|
455
467
|
/** 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`. */
|
|
456
468
|
attested(): Promise<{ required: boolean; confidential: boolean }>
|
|
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
|
-
|
|
469
|
+
/** `attachmentsMissing`: attachments whose bytes could not be read — the file holds only a pointer to this room for them; export again to include them.
|
|
470
|
+
* A linked continuation (a Space that replaced an earlier version of itself): `earlierCount` — its earlier versions' messages, included in the
|
|
471
|
+
* file's `earlier`; or `historyIncomplete` — a sentence saying why they are not in it (no key for them on this client, or they could not be read). */
|
|
472
|
+
exportFile(): Promise<{ count: number; attachmentsMissing?: number; earlierCount?: number; historyIncomplete?: string }>
|
|
459
473
|
sealedProof(): Promise<Record<string, unknown> | null>
|
|
460
474
|
/** Confidential rooms: verify every reply's turn certificate on this device. */
|
|
461
475
|
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> }>
|
|
@@ -592,7 +606,7 @@ export declare class VaultSession {
|
|
|
592
606
|
/** The vault's origin. */
|
|
593
607
|
readonly origin: string
|
|
594
608
|
/** Connection details and the latest room, sign-in and account state reported by the vault. */
|
|
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 }
|
|
609
|
+
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; /** 'minted': the lane was made for its Space (it goes when that Space is deleted) */ laneOrigin?: 'minted'; /** the Space this room was first made as a lane of */ mintedFor?: 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 }
|
|
596
610
|
/** The Spaces this vault holds, newest first. */
|
|
597
611
|
rooms(): Promise<VaultRoom[]>
|
|
598
612
|
/** A live Space for a room the vault holds; its key stays in the vault (`space.key` and `space.shareLink` are null). A private
|
|
@@ -735,7 +749,7 @@ export interface AccountBackup {
|
|
|
735
749
|
/** Where the account is kept: 'account' (the Witbitz account service — a new account in a vault that names its tenant),
|
|
736
750
|
* 'legacy' (the backup store every account used before), null when there is none on this client. */
|
|
737
751
|
readonly service: 'account' | 'legacy' | null
|
|
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;
|
|
752
|
+
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; sorting by it orders by the last OPEN — the Spaces app also counts new messages its device saw, which the account does not hold (sdk-accounts.md#account-index) */ lastOpenedAt?: number }>
|
|
739
753
|
onState: ((state: unknown) => void) | null
|
|
740
754
|
enable(opts?: { email?: string }): Promise<{ code: string }>
|
|
741
755
|
restore(opts: { code: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: AccountBackup['rooms'] }>
|
|
@@ -896,7 +910,7 @@ export interface InviteAccount {
|
|
|
896
910
|
* this device's invite key. The inbox keeps them all: every call returns every one. Open one with `openSpace(link)`. In vault
|
|
897
911
|
* 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
912
|
* with `link: ''` — open one with `wb.vault.openRoom(room)` (an older vault kit: `vault_unsupported`). Throws
|
|
899
|
-
* `no_invite_key`, `unreachable
|
|
913
|
+
* `no_invite_key`, `unreachable`, `account_changed` (another account signed in during the read). Anyone who finds the inbox can drop an invitation: `link` is
|
|
900
914
|
* always an https address of `room` carrying its key (others are skipped), but `title` and `from` are the sender's own words —
|
|
901
915
|
* show them as text, never as markup. */
|
|
902
916
|
collect(): Promise<Array<{ room: string; link: string; title: string; from: string; at: number }>>
|
package/witbitz-sdk.js
CHANGED
|
@@ -51,6 +51,7 @@ import { Dictation, voiceForDictation } from './sdkDictation.js' // wb.dictation
|
|
|
51
51
|
import { Protect } from './sdkProtect.js' // wb.protect: what the app keeps on the device, sealed under a passkey-derived key
|
|
52
52
|
import { boxesHash, bareEC, jkey } from './spaceFork.js' // the membership fork's notice format, shared with the app
|
|
53
53
|
import { preferredAddresses } from './addPreferred.js' // "Add me to Spaces as @username" (docs/spaces-usernames.md § 13)
|
|
54
|
+
import { placeRoles, roleEmails, rolesOf, roleTagHolders } from './roomRoles.js' // owners and admins by @username tag (docs/spaces-usernames.md § 13.1)
|
|
54
55
|
import { normAdmission, checkAdminCollections, judgeMove, newRoomKeepsGov } from './emailFork.js' // the gate's rules with the app; following a move an OLDER client made (a Space no longer moves: #members)
|
|
55
56
|
import { deleteOwnRoom } from './roomDelete.js'
|
|
56
57
|
import { sealTo, openBox, commit as keyCommit } from './e2ee.js'
|
|
@@ -200,7 +201,7 @@ const perTurn = (instructions) => (typeof instructions === 'string' && instructi
|
|
|
200
201
|
/** This SDK's version: 'dev' on the live build, the release number in /sdk/<version>/ (tools/sdk-release.mjs sets it). */
|
|
201
202
|
export { isLaneCopy } from './roomName.js' // is this message a lane's copy of its shared room's line? (the app's own test, sdk-agents.md#lanes)
|
|
202
203
|
export { Protect } // device storage protection, usable before a client exists (sdkProtect.js, #protect)
|
|
203
|
-
export const SDK_VERSION = '4.
|
|
204
|
+
export const SDK_VERSION = '4.7.0'
|
|
204
205
|
// Every error the SDK throws carries a `code` (sdk-reference.md#errors): an argument it cannot use is `invalid_argument`.
|
|
205
206
|
const sdkError = (message, code = 'invalid_argument') => Object.assign(new Error(message), { code })
|
|
206
207
|
/** What this SDK build can do — for feature detection (wb.capabilities()). Names only grow; a removed one is a major version. */
|
|
@@ -1078,6 +1079,9 @@ export class Witbitz {
|
|
|
1078
1079
|
// A DIRECT CHAT (the Spaces app's, directChat.js): a verified Space with exactly you and one other person, you its owner,
|
|
1079
1080
|
// `direct: true` sealed in — the server refuses its rename and each side calls it by the other person (space.directPeer).
|
|
1080
1081
|
if (direct !== undefined) admission = directAdmission(direct, admission, this._session)
|
|
1082
|
+
// The account this create began under: a restore or sign-in that lands while the room is being made — the invitee lookups below
|
|
1083
|
+
// included (sync sweep 11-29 #4) — must not have the new room's link recorded in ITS backup (side sweep: sdk-pending-create-follows-account-switch).
|
|
1084
|
+
const began = { generation: this._archiveGeneration, email: this._session?.email || '', master: this.backup._s?.master || null }
|
|
1081
1085
|
// ★ THE CREATOR IS THE OWNER, as in the app (space.js gatedBase; docs/verified-room-members.md): a verified room names its
|
|
1082
1086
|
// signed-in creator as its first owner when they are on its list and no owners were given — authority then follows that
|
|
1083
1087
|
// email onto every device (sync sweep, 10-12). Not on the list, or not signed in: unchanged (an owner who cannot open it
|
|
@@ -1090,9 +1094,6 @@ export class Witbitz {
|
|
|
1090
1094
|
const enc = tierIsEnclave(tier)
|
|
1091
1095
|
const split = splitKeyChoice(key)
|
|
1092
1096
|
if (split && !this._appShareUrl && !this._clientOpts.tenant) throw Object.assign(new Error("witbitz: a split-key room needs your app-half function — new Witbitz({ appShare: '/api/appshare' }) — or, with the Witbitz-held key, your tenant — new Witbitz({ tenant: 't_…' })"), { code: 'tenant_required' })
|
|
1093
|
-
// The account this create began under: a restore or sign-in that lands while the room is being made must not have the new
|
|
1094
|
-
// room's link recorded in ITS backup (side sweep: sdk-pending-create-follows-account-switch).
|
|
1095
|
-
const began = { generation: this._archiveGeneration, email: this._session?.email || '', master: this.backup._s?.master || null }
|
|
1096
1097
|
await this._checkModel(model || agent.model)
|
|
1097
1098
|
const cfg = roomConfig({ agent, tools, immediateTools, model, data, gate, platformTools, framing, dataWrites }, { agentName: 'Assistant', persona: '' })
|
|
1098
1099
|
applySkills(cfg, skills)
|
|
@@ -1108,6 +1109,7 @@ export class Witbitz {
|
|
|
1108
1109
|
if (!(all && all.tempRooms)) throw sdkError('witbitz: temporary rooms are not available on this deployment', 'temporary_unavailable')
|
|
1109
1110
|
cfg.room = newRoomId(cfg.region, { prefix: 'tmp' }) // the whole stack keys off the prefix (the app's tempRooms.js mints the same shape)
|
|
1110
1111
|
}
|
|
1112
|
+
if (gate) await this._rolesAsPreferred(cfg) // owners and admins who prefer their @username are named by its tag (§ 13.1)
|
|
1111
1113
|
// Attest FIRST (a configuration failure is loud, a cold enclave is not — _encAttestSoft); mint; only then wake and hand
|
|
1112
1114
|
// the enclave its config.
|
|
1113
1115
|
if (enc) await this._encAttestSoft()
|
|
@@ -1151,6 +1153,40 @@ export class Witbitz {
|
|
|
1151
1153
|
al.tagUsers = [...new Set([...(al.tagUsers || []), ...learned.map((x) => x.username)])]
|
|
1152
1154
|
}
|
|
1153
1155
|
|
|
1156
|
+
/** @private OWNERS AND ADMINS AS THEY PREFER (docs/spaces-usernames.md § 13.1; the owner, 2026-11-29): a new Space's owner or admin whose
|
|
1157
|
+
* address is HIDDEN (not advertised) and who prefers their @username — the signed-in creator by whoami, anyone else past the email door
|
|
1158
|
+
* (only where "find me by email" is on) — is named in the role, and put on the list, by the room's tag for that name; the email leaves
|
|
1159
|
+
* both. Only where the server takes tag roles (roomRoles.roleTagFor: `roles: true`); otherwise the role names the email, as before.
|
|
1160
|
+
* The room id is chosen here so the tag can be asked for it. Changes `cfg` in place; a lookup that fails leaves it as it was. */
|
|
1161
|
+
async _rolesAsPreferred(cfg) {
|
|
1162
|
+
const al = cfg && cfg.admission === 'email' && cfg.allow
|
|
1163
|
+
if (!al) return
|
|
1164
|
+
const lc = (x) => String(x || '').trim().toLowerCase()
|
|
1165
|
+
const hidden = new Set((Array.isArray(al.hidden) ? al.hidden : (al.emails || [])).map(lc)) // with `hidden`, `emails` are the advertised ones (normAdmission)
|
|
1166
|
+
const owners = roleEmails(cfg.owners), mgr = [...owners.map((email) => ({ role: 'owners', email })), ...roleEmails(cfg.admins).filter((e) => !owners.includes(e)).map((email) => ({ role: 'admins', email }))].filter((m) => hidden.has(m.email))
|
|
1167
|
+
if (!mgr.length) return
|
|
1168
|
+
const me = lc(this._session && !(this._session.exp && this._session.exp <= Date.now()) ? this._session.email : '')
|
|
1169
|
+
const people = []
|
|
1170
|
+
if (me && mgr.some((m) => m.email === me)) {
|
|
1171
|
+
const w = await this.usernames.mine().catch(() => null)
|
|
1172
|
+
if (w && w.username && w.addAsUsername !== false) people.push(...mgr.filter((m) => m.email === me).map((m) => ({ ...m, username: w.username })))
|
|
1173
|
+
}
|
|
1174
|
+
const others = mgr.filter((m) => m.email !== me)
|
|
1175
|
+
if (others.length) {
|
|
1176
|
+
const pref = await preferredAddresses([...new Set(others.map((m) => m.email))], { client: this._client }).catch(() => null)
|
|
1177
|
+
const name = new Map(((pref && pref.learned) || []).map((x) => [x.email, x.username]))
|
|
1178
|
+
for (const m of others) if (name.has(m.email)) people.push({ ...m, username: name.get(m.email) })
|
|
1179
|
+
}
|
|
1180
|
+
if (!people.length) return
|
|
1181
|
+
const room = cfg.room || newRoomId(cfg.region)
|
|
1182
|
+
const pr = await placeRoles({ room, owners: cfg.owners, admins: cfg.admins, allow: al }, people, { client: this._client }).catch(() => null)
|
|
1183
|
+
if (!pr || !pr.placed.length) return
|
|
1184
|
+
cfg.room = room
|
|
1185
|
+
cfg.allow = pr.allow
|
|
1186
|
+
cfg.owners = pr.owners
|
|
1187
|
+
if (cfg.admins || pr.admins.emails.length || pr.admins.tags) cfg.admins = pr.admins
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1154
1190
|
/** @private how a split room is created: through the builder's function when there is one (`via`), else here. */
|
|
1155
1191
|
setAssistantMemory(spaces = []) {
|
|
1156
1192
|
if (!Array.isArray(spaces) || spaces.length > LIMITS.links + 1) throw sdkError('witbitz: choose a bounded list of Spaces for assistant memory', 'invalid_argument')
|
|
@@ -1855,7 +1891,11 @@ export class Space {
|
|
|
1855
1891
|
const rows = await this._wb.models({ tier: this._isEnclave() ? 'enclave' : 'standard' })
|
|
1856
1892
|
const row = (rows || []).find((m) => m && m.id === id)
|
|
1857
1893
|
if (!row) throw sdkError(`witbitz: ${JSON.stringify(id)} is not a model offered for this Space — see wb.models()`, 'unknown_model')
|
|
1858
|
-
|
|
1894
|
+
// the room's effort is kept when the new model takes it too, as the app's model chip does (modelChip.js); else the model's own default
|
|
1895
|
+
await this._freshSettings()
|
|
1896
|
+
const was = this._modelPick, efforts = Array.isArray(row.efforts) ? row.efforts.map(String) : []
|
|
1897
|
+
const effort = was && was.effort && efforts.includes(String(was.effort)) ? String(was.effort) : ''
|
|
1898
|
+
const pick = { catalog: String(row.id), wire: String(row.wire || ''), label: String(row.label || ''), ...(effort ? { effort } : {}) }
|
|
1859
1899
|
this._modelGen = (this._modelGen || 0) + 1
|
|
1860
1900
|
const r = await this._client.state(this.room, this._mk, 'model', modelDocOf(pick), pick.label || pick.catalog)
|
|
1861
1901
|
if (!r || r.status !== 200) throw refused('setModel', r)
|
|
@@ -2026,7 +2066,10 @@ export class Space {
|
|
|
2026
2066
|
if (this._wb?.vault) return this._wb.vault._c.roomAccount(this.room, 'portable', 'export')
|
|
2027
2067
|
const { saveRoomExport } = await import('./sdkExports.js')
|
|
2028
2068
|
const generation = this._wb?._archiveGeneration
|
|
2029
|
-
|
|
2069
|
+
// a linked continuation's earlier versions: read with the keys this account's rooms carry (their saved links)
|
|
2070
|
+
const keys = {}
|
|
2071
|
+
for (const r of this._wb?.backup?.rooms || []) { let mk = typeof r.mk === 'string' ? r.mk : ''; try { mk ||= new URLSearchParams(new URL(r.link).hash.slice(1)).get('mk') || '' } catch { /* no key in it */ } if (mk && r.room !== this.room) keys[r.room] = mk }
|
|
2072
|
+
return saveRoomExport(this, this._wb?._enc?.rooms.has(this.room) || ENC_MARK.test(this.shareLink || '') ? 'enclave' : 'standard', () => this._wb?._archiveGeneration === generation, this.title, keys)
|
|
2030
2073
|
}
|
|
2031
2074
|
async sealedProof() {
|
|
2032
2075
|
if (!(this._client && this._client.vault)) this._needKey('sealedProof') // a vault reads the stored boxes for the page (ciphertext only)
|
|
@@ -2297,7 +2340,18 @@ export class Space {
|
|
|
2297
2340
|
}
|
|
2298
2341
|
}
|
|
2299
2342
|
}
|
|
2300
|
-
|
|
2343
|
+
// ROLES BY @USERNAME TAG (docs/spaces-usernames.md § 13.1): an owner or admin who prefers their @username is named by the room's tag for
|
|
2344
|
+
// it — `ownerTags` / `adminTags` (what changeMembers takes back), and `ownerUsers` / `adminUsers`: the @usernames of those the guest book
|
|
2345
|
+
// and the names' own tags match (a holder not matched yet is in the tags, not the names). Absent in a room with no tag roles.
|
|
2346
|
+
const rt = rolesOf(cfg)
|
|
2347
|
+
let tagRoles = {}
|
|
2348
|
+
if (rt.ownerTags.length || rt.adminTags.length) {
|
|
2349
|
+
const book = await Promise.resolve().then(() => this._client.state(this.room, this._mk, ROSTER_DOC)).catch(() => null)
|
|
2350
|
+
const held = book && book.status === 200 ? await roleTagHolders(Object.values(book.seen || {}), [...rt.ownerTags, ...rt.adminTags], { room: this.room, userTag: typeof this._client.userTag === 'function' ? (n, r) => this._client.userTag(n, r) : null }).catch(() => new Map()) : new Map()
|
|
2351
|
+
const names = (tags) => [...new Set(tags.map((t) => held.get(t) && held.get(t).user).filter(Boolean).map((u) => '@' + u))]
|
|
2352
|
+
tagRoles = { ownerTags: rt.ownerTags, adminTags: rt.adminTags, ownerUsers: names(rt.ownerTags), adminUsers: names(rt.adminTags) }
|
|
2353
|
+
}
|
|
2354
|
+
return { ...(unopenedPrivateInvites !== undefined ? { unopenedPrivateInvites } : {}), gated: true, emails: list(a.emails), domains: list(a.domains), hidden: list(a.mh).length + legacy, admins, owners, ...tagRoles, ...(cfg.lane === true || cfg.bridge ? { lane: true } : {}), ...lanesOn } // lane: a private lane, not a Space (laneConfig.js)
|
|
2301
2355
|
}
|
|
2302
2356
|
|
|
2303
2357
|
/** Is `email` one of this room's ADMINS? The room enforces it (2026-10-02): with admins, only they change the
|
|
@@ -2308,7 +2362,16 @@ export class Space {
|
|
|
2308
2362
|
const e = String(email || '').trim().toLowerCase()
|
|
2309
2363
|
const cfg = await this._gateConfig({ plainMark: true })
|
|
2310
2364
|
const has = (o) => !!(o && Array.isArray(o.emails) && o.emails.some((x) => String(x).trim().toLowerCase() === e))
|
|
2311
|
-
return has(cfg.admins) || has(cfg.owners) // an owner is an admin
|
|
2365
|
+
return has(cfg.admins) || has(cfg.owners) || !!(await this._roleByTag(cfg, e)) // an owner is an admin; '@username' — a role held by its tag (§ 13.1)
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
/** @private A role held by an @username's tag (docs/spaces-usernames.md § 13.1): `who` = '@name' → 'owner' | 'admin' | ''. */
|
|
2369
|
+
async _roleByTag(cfg, who) {
|
|
2370
|
+
const rt = rolesOf(cfg)
|
|
2371
|
+
if (!String(who).startsWith('@') || !(rt.ownerTags.length || rt.adminTags.length) || typeof this._client.userTag !== 'function') return ''
|
|
2372
|
+
const t = await this._client.userTag(String(who).slice(1), this.room).catch(() => null)
|
|
2373
|
+
const tag = t && t.status === 200 ? t.tag : ''
|
|
2374
|
+
return !tag ? '' : rt.ownerTags.includes(tag) ? 'owner' : rt.adminTags.includes(tag) ? 'admin' : ''
|
|
2312
2375
|
}
|
|
2313
2376
|
|
|
2314
2377
|
/** Is `email` one of this room's OWNERS (a level above admins, enforced by the room)? An owner can do all an admin can,
|
|
@@ -2316,7 +2379,7 @@ export class Space {
|
|
|
2316
2379
|
async isOwner(email) {
|
|
2317
2380
|
const e = String(email || '').trim().toLowerCase()
|
|
2318
2381
|
const cfg = await this._gateConfig({ plainMark: true })
|
|
2319
|
-
return !!(cfg.owners && Array.isArray(cfg.owners.emails) && cfg.owners.emails.some((x) => String(x).trim().toLowerCase() === e))
|
|
2382
|
+
return !!(cfg.owners && Array.isArray(cfg.owners.emails) && cfg.owners.emails.some((x) => String(x).trim().toLowerCase() === e)) || (await this._roleByTag(cfg, e)) === 'owner' // '@username': by its tag (§ 13.1)
|
|
2320
2383
|
}
|
|
2321
2384
|
|
|
2322
2385
|
/** Does this Space's gate admit `email`? Checked on this device against the sealed list: an advertised address, a
|
|
@@ -3243,7 +3306,12 @@ export class Lane extends Space {
|
|
|
3243
3306
|
const canReadConfig = typeof from._client.getConfig === 'function'
|
|
3244
3307
|
const cfg = canReadConfig ? await from._client.getConfig(from.room, from._mk, { plainMark: true }) : {}
|
|
3245
3308
|
if (!cfg || gatedStub(cfg)) return { mirrored: 0 }
|
|
3246
|
-
if (cfg.lanes === false) {
|
|
3309
|
+
if (cfg.lanes === false) {
|
|
3310
|
+
from._lanesSetting = false; this._detachShared()
|
|
3311
|
+
// …and the account forgets the association, as the app's mirror does (deleteNegotiation) — a vault's lanes are its own (sync sweep 11-27 P1)
|
|
3312
|
+
if (this._wb && !this._wb.vault) disconnectRoomLanes(this._wb, from.room).catch(() => {})
|
|
3313
|
+
return { mirrored: 0 }
|
|
3314
|
+
}
|
|
3247
3315
|
const all = (from.messages || []).filter((e) => e && !e.sys && !e.mcp && e.kind !== 'mcp' && e.kind !== 'fork' && (e.text || (Array.isArray(e.files) && e.files.length) || (Array.isArray(e.images) && e.images.length)))
|
|
3248
3316
|
if (from._more || !(from._historyRead || from._hostDriven)) return { mirrored: 0 } // not the whole shared history yet (a failed page leaves _more false) // the shared room is still loading its pages: a cursor past what has arrived is not another history
|
|
3249
3317
|
const anchorOf = e => e ? removedEntryKey(e) : null
|
|
@@ -3251,6 +3319,8 @@ export class Lane extends Space {
|
|
|
3251
3319
|
const anchor = this._mirrorAnchor ? all.findIndex(e => anchorOf(e) === this._mirrorAnchor) : -1
|
|
3252
3320
|
this._mirrorCursor = anchor + 1
|
|
3253
3321
|
} // a cursor from another history: start over; the server's id-dedup makes it a resend, never a double
|
|
3322
|
+
const sharedAgent = typeof cfg.agentName === 'string' ? cfg.agentName.trim() : ''
|
|
3323
|
+
const addressedOf = (e) => (sharedAgent && e.self !== true && typeof e.text === 'string' && e.text.trimStart().toLowerCase().startsWith('@' + sharedAgent.toLowerCase()) ? { addressed: sharedAgent.slice(0, 80) } : {})
|
|
3254
3324
|
const copyEntry = async e => ({
|
|
3255
3325
|
sourceRoom: from.room,
|
|
3256
3326
|
id: 'sh:' + (e.id || ('t' + e.ts)), // the entry id alone, no room prefix — stable across a fork (the app's rule)
|
|
@@ -3259,6 +3329,7 @@ export class Lane extends Space {
|
|
|
3259
3329
|
...(e.self && Array.isArray(e.sources) ? { sources: e.sources.slice(0, 12) } : {}),
|
|
3260
3330
|
...mirrorBy(from.room, e), // WHO WROTE IT, as the Space verified them — Block collapses their copy in the lane too (the app's mirrorLoop.js byOf; sync sweep 11-08)
|
|
3261
3331
|
...(Number.isFinite(e.ts) ? { ts: e.ts } : {}), ...(e.replyTo && e.replyTo.key ? { replyTo: e.replyTo } : {}), // when it was said, and what it answers (sync sweep, 2026-10-10)
|
|
3332
|
+
...addressedOf(e), // the Space's assistant a person's line opens by addressing: the lane strips it before reading the direction (mirrorLoop.js)
|
|
3262
3333
|
text: e.text, files: await withBytes(from, e.files), images: await withBytes(from, e.images),
|
|
3263
3334
|
...(e.removedByWitbitz ? { sourceRemoved: true } : {}),
|
|
3264
3335
|
})
|
|
@@ -3686,7 +3757,12 @@ function refuseInVault(wb) {
|
|
|
3686
3757
|
const vaultLiveLinks = new Set() // the lane links open in THIS page (Lane#link → _noteLink)
|
|
3687
3758
|
const pairKey = (a, b) => [String(a), String(b)].sort().join('|')
|
|
3688
3759
|
conn.on((ev) => {
|
|
3689
|
-
if (ev?.ev === 'a2aChanged')
|
|
3760
|
+
if (ev?.ev === 'a2aChanged') {
|
|
3761
|
+
refreshVaultA2AViews(conn, ev)
|
|
3762
|
+
// an outside agent's lane given a new address in the vault: the page hears it as outside a vault (sdk-agents.md)
|
|
3763
|
+
const moved = Array.isArray(ev.addresses) ? ev.addresses.filter((l) => l && typeof l.room === 'string' && typeof l.cardUrl === 'string' && typeof l.mcpUrl === 'string').map(({ room, cardUrl, mcpUrl }) => ({ room, cardUrl, mcpUrl })) : []
|
|
3764
|
+
if (moved.length && typeof wb.a2a.onReaddressed === 'function') { try { wb.a2a.onReaddressed(moved) } catch { /* the app's callback */ } }
|
|
3765
|
+
}
|
|
3690
3766
|
if (ev?.ev === 'siri' && ev.siri) wb._vaultSiri = { ...ev.siri, key: null }
|
|
3691
3767
|
const expired = ev?.ev === 'signedOut' && ev.reason === 'expired'
|
|
3692
3768
|
if (expired) wb.a2a._draftsSuspended = true
|
|
@@ -4349,13 +4425,18 @@ class SiriAccount {
|
|
|
4349
4425
|
// …and a restore() that landed while the push was out (a vault keep applying the account's merged Siri) is NOT
|
|
4350
4426
|
// overwritten (sync sweep 2026-11-13 #2: the next keep pass then stamped the other devices' Spaces `gone` everywhere): the
|
|
4351
4427
|
// change is made again on top of what landed and that is pushed — at most a few times, then the latest state stands.
|
|
4352
|
-
|
|
4428
|
+
// `guard`: the Spaces this edit is about — when another device changed one of them while this edit was out, the edit is not made
|
|
4429
|
+
// again over it (a rename must not overwrite a newer rename; the app's siri.js editShows): `siri_conflict`
|
|
4430
|
+
_change(fn, { guard } = {}) {
|
|
4353
4431
|
const generation = this._wb._archiveGeneration
|
|
4354
4432
|
const run = async () => {
|
|
4355
4433
|
if (generation !== this._wb._archiveGeneration) throw sdkError('Account changed before Siri setup', 'account_changed')
|
|
4356
4434
|
let out
|
|
4435
|
+
const guarded = (st) => JSON.stringify((guard || []).map((room) => st.rooms[room] || null))
|
|
4436
|
+
const began = guarded(this._wb._siri)
|
|
4357
4437
|
for (let i = 0; i < 4; i++) {
|
|
4358
4438
|
const account = await this._wb._account(), base = this._wb._siri
|
|
4439
|
+
const conflict = !!(i && guard && guarded(base) !== began) // pushed as it now stands (the Sentinel took this edit's copy), then said
|
|
4359
4440
|
const next = siriStateOf(JSON.parse(JSON.stringify(base)))
|
|
4360
4441
|
const pending = next.pendingRemovals || []
|
|
4361
4442
|
const priorSetup = next.pendingSetup, rotation = next.pendingRotation
|
|
@@ -4374,8 +4455,8 @@ class SiriAccount {
|
|
|
4374
4455
|
if (next.defaultRoom === room) next.defaultRoom = ''
|
|
4375
4456
|
}
|
|
4376
4457
|
if (rotation) next.token = rotation.to
|
|
4377
|
-
out = await fn(next, rotation)
|
|
4378
|
-
if (out === NO_SIRI_CHANGE && !pending.length && !priorSetup && !rotation) return out
|
|
4458
|
+
out = conflict ? NO_SIRI_CHANGE : await fn(next, rotation)
|
|
4459
|
+
if (out === NO_SIRI_CHANGE && !pending.length && !priorSetup && !rotation && !conflict) return out
|
|
4379
4460
|
if (generation !== this._wb._archiveGeneration || account !== await this._wb._account()) throw sdkError('Account changed during Siri setup', 'account_changed')
|
|
4380
4461
|
const removed = Object.keys(base.rooms).filter(room => !next.rooms[room])
|
|
4381
4462
|
const added = Object.entries(next.rooms).filter(([id]) => !base.rooms[id])
|
|
@@ -4405,7 +4486,11 @@ class SiriAccount {
|
|
|
4405
4486
|
}
|
|
4406
4487
|
if (generation !== this._wb._archiveGeneration || account !== await this._wb._account()) throw sdkError('Account changed during Siri setup', 'account_changed')
|
|
4407
4488
|
finish?.(true)
|
|
4408
|
-
if (this._wb._siri === base) {
|
|
4489
|
+
if (this._wb._siri === base) {
|
|
4490
|
+
this._wb._siri = next; this._changed()
|
|
4491
|
+
if (conflict) throw sdkError('Another device changed this Siri setting first — check it and try again.', 'siri_conflict')
|
|
4492
|
+
return out === NO_SIRI_CHANGE ? true : out
|
|
4493
|
+
}
|
|
4409
4494
|
}
|
|
4410
4495
|
throw sdkError('witbitz: the Siri state kept changing while it was being saved — try again', 'siri_busy')
|
|
4411
4496
|
}
|
|
@@ -4467,7 +4552,7 @@ class SpaceSiri {
|
|
|
4467
4552
|
}
|
|
4468
4553
|
if (makeDefault) st.defaultRoom = sp.room; else if (st.defaultRoom === sp.room) st.defaultRoom = ''
|
|
4469
4554
|
return { key: st.token, endpoint: SIRI_ENDPOINT, alias: a }
|
|
4470
|
-
})
|
|
4555
|
+
}, { guard: [sp.room] })
|
|
4471
4556
|
}
|
|
4472
4557
|
/** Disable Siri for this Space (other Spaces keep theirs). A push that fails rejects and keeps it on, here as at the Sentinel. */
|
|
4473
4558
|
async disable({ includeAssistant = false } = {}) {
|