@witbitz/sdk 0.0.0-stage → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -2
  3. package/a2aCore.js +200 -0
  4. package/a2aShared.js +27 -0
  5. package/accountErase.js +223 -0
  6. package/accountIndexDoc.js +122 -0
  7. package/accountOwner.js +59 -0
  8. package/accountRecord.js +90 -0
  9. package/accountScope.js +114 -0
  10. package/accountSeal.js +42 -0
  11. package/accountStores.js +173 -0
  12. package/acctV2App.js +619 -0
  13. package/acctV2Check.js +29 -0
  14. package/acctV2Client.js +382 -0
  15. package/acctV2Keys.js +43 -0
  16. package/acctV2Legacy.js +14 -0
  17. package/acctV2Switch.js +80 -0
  18. package/acctV2UiCore.js +857 -0
  19. package/acctV2WebAuthn.js +61 -0
  20. package/acctV2Wire.js +59 -0
  21. package/address.js +42 -0
  22. package/attestedBox.js +30 -0
  23. package/attestedRooms.js +78 -0
  24. package/awsKey.js +98 -0
  25. package/backupRecord.js +106 -0
  26. package/backupVault.js +97 -0
  27. package/blocks.js +115 -0
  28. package/blocksPush.js +64 -0
  29. package/browseSeal.js +103 -0
  30. package/cbor.js +225 -0
  31. package/changePush.js +75 -0
  32. package/chatLock.js +149 -0
  33. package/chatLockSw.js +13 -0
  34. package/cloudDeviceBuilds.js +11 -0
  35. package/cloudDevicePins.js +33 -0
  36. package/cloudDeviceSeal.js +53 -0
  37. package/codeBrowse.js +224 -0
  38. package/codeCloud.js +652 -0
  39. package/codeCloudKeys.js +112 -0
  40. package/codeCommands.js +167 -0
  41. package/codeComputers.js +388 -0
  42. package/codeEgress.js +123 -0
  43. package/codeFilesRoutes.js +17 -0
  44. package/codeMkdir.js +8 -0
  45. package/codeModes.js +57 -0
  46. package/codeOrphanKeys.js +42 -0
  47. package/codeOutputs.js +141 -0
  48. package/codeRelay.js +505 -0
  49. package/codeSentinel.js +86 -0
  50. package/codeTransport.js +295 -0
  51. package/codeUndo.js +48 -0
  52. package/compress.js +24 -0
  53. package/config.js +11 -0
  54. package/connCatalog.js +164 -0
  55. package/connDisp.js +76 -0
  56. package/connOtherWays.js +74 -0
  57. package/connPending.js +16 -0
  58. package/connWrap.js +53 -0
  59. package/connectionEntry.js +89 -0
  60. package/connections.js +562 -0
  61. package/credits.js +30 -0
  62. package/csAttest.js +112 -0
  63. package/decrypt.html +384 -0
  64. package/deviceAttest.js +521 -0
  65. package/deviceCall.js +54 -0
  66. package/deviceKeyCore.js +41 -0
  67. package/deviceSeal.js +59 -0
  68. package/e2ee.js +323 -0
  69. package/eat.js +103 -0
  70. package/emailFork.js +275 -0
  71. package/emailSignIn.js +81 -0
  72. package/emptySpaces.js +111 -0
  73. package/encSource.js +55 -0
  74. package/enclaveAccept.js +214 -0
  75. package/enclaveClaim.js +241 -0
  76. package/enclaveRoute.js +102 -0
  77. package/enclaveSnapshotMerge.js +44 -0
  78. package/entrySig.js +165 -0
  79. package/env.js +73 -0
  80. package/eraseFile.js +58 -0
  81. package/followImage.js +86 -0
  82. package/healNames.js +45 -0
  83. package/idb.js +97 -0
  84. package/idbSeal.js +119 -0
  85. package/indexGone.js +12 -0
  86. package/invite.js +51 -0
  87. package/inviteEnroll.js +67 -0
  88. package/inviteSend.js +68 -0
  89. package/jobAgents.js +87 -0
  90. package/keptMerge.js +84 -0
  91. package/l1-worker-src.js +2 -0
  92. package/l1-worker.js +831 -0
  93. package/laneConfig.js +57 -0
  94. package/laneLinkCore.js +177 -0
  95. package/ledgerView.js +64 -0
  96. package/manifest.json +220 -0
  97. package/mcpRecommended.js +25 -0
  98. package/memberChange.js +123 -0
  99. package/mkseal.js +101 -0
  100. package/nativePush.js +153 -0
  101. package/nitroVerify.js +220 -0
  102. package/noble-p256.js +27 -0
  103. package/notice.js +116 -0
  104. package/notifKey.js +58 -0
  105. package/offlineBundle.js +62 -0
  106. package/ohttp.js +177 -0
  107. package/opencodeWire.js +282 -0
  108. package/oprf.js +70 -0
  109. package/ownAgentLink.js +96 -0
  110. package/ownerPolicy.js +117 -0
  111. package/package.json +254 -4
  112. package/pollVerdict.js +33 -0
  113. package/prefetchPoll.js +60 -0
  114. package/protectedLocal.js +410 -0
  115. package/pushCore.js +42 -0
  116. package/recovery.js +107 -0
  117. package/regions.js +42 -0
  118. package/removedMessage.js +11 -0
  119. package/renameRefusal.js +9 -0
  120. package/replyQuote.js +34 -0
  121. package/reqEnvelope.js +126 -0
  122. package/roomDefaultPrefs.js +76 -0
  123. package/roomDelete.js +109 -0
  124. package/roomName.js +177 -0
  125. package/roomPass.js +256 -0
  126. package/roomRoster.js +289 -0
  127. package/roomSettings.js +61 -0
  128. package/roomState.js +58 -0
  129. package/roomStreamClient.js +115 -0
  130. package/rosterCount.js +49 -0
  131. package/rosterHash.js +13 -0
  132. package/rowSchema.js +113 -0
  133. package/safeMedia.js +116 -0
  134. package/safeMediaPins.js +17 -0
  135. package/schedulesDoc.js +78 -0
  136. package/sdkA2A.js +404 -0
  137. package/sdkAccount.js +470 -0
  138. package/sdkAccountDoc.js +81 -0
  139. package/sdkAccountSections.js +223 -0
  140. package/sdkAgui.js +141 -0
  141. package/sdkAttest.js +34 -0
  142. package/sdkBackup.js +480 -0
  143. package/sdkBackupV2.js +630 -0
  144. package/sdkBrowserPrivate.js +28 -0
  145. package/sdkBuilds.js +208 -0
  146. package/sdkCloudDevice.js +215 -0
  147. package/sdkComputers.js +480 -0
  148. package/sdkDictation.js +142 -0
  149. package/sdkErase.js +283 -0
  150. package/sdkExports.js +69 -0
  151. package/sdkInvitations.js +34 -0
  152. package/sdkKeptAgent.js +188 -0
  153. package/sdkLaneLink.js +205 -0
  154. package/sdkPlan.js +94 -0
  155. package/sdkProtect.js +228 -0
  156. package/sdkRedact.js +36 -0
  157. package/sdkRekey.js +307 -0
  158. package/sdkReport.js +68 -0
  159. package/sdkSafeMedia.js +255 -0
  160. package/sdkSchedules.js +39 -0
  161. package/sdkSpeech.js +54 -0
  162. package/sdkTurn.js +117 -0
  163. package/sdkVault.js +124 -0
  164. package/sealShare.js +18 -0
  165. package/sealedNames.js +64 -0
  166. package/sealedReceipt.js +17 -0
  167. package/sentinelRelease.js +154 -0
  168. package/shamir.js +85 -0
  169. package/sharedViews.js +38 -0
  170. package/sheetChrome.js +450 -0
  171. package/siri.js +171 -0
  172. package/spaceClient.js +1418 -0
  173. package/spaceConfig.js +81 -0
  174. package/spaceEmailGate.js +813 -0
  175. package/spaceExport.js +125 -0
  176. package/spaceFork.js +216 -0
  177. package/spaceLock.js +358 -0
  178. package/spacePasskey.js +180 -0
  179. package/speechOut.js +100 -0
  180. package/splitKeyClient.js +90 -0
  181. package/store.js +587 -0
  182. package/streamHint.js +36 -0
  183. package/sttCloud.js +220 -0
  184. package/sttWorklet.js +38 -0
  185. package/sw-notif-core.js +538 -0
  186. package/tempList.js +48 -0
  187. package/tinfoilVerifier.js +78 -0
  188. package/toolBooks.js +31 -0
  189. package/toolRules.js +52 -0
  190. package/turnCerts.js +254 -0
  191. package/turnFeed.js +58 -0
  192. package/turnVerdict.js +36 -0
  193. package/usageReceipts.js +176 -0
  194. package/usageSummary.js +90 -0
  195. package/util.js +181 -0
  196. package/vault-core.js +1958 -0
  197. package/vault-kit.mjs +354 -0
  198. package/vault-screens.js +263 -0
  199. package/vaultAtRest.js +177 -0
  200. package/vaultCoreLock.js +111 -0
  201. package/vaultCorePush.js +140 -0
  202. package/vaultDeviceKey.js +95 -0
  203. package/vaultEnclaveHandoff.js +114 -0
  204. package/vaultKeep.js +281 -0
  205. package/vaultSealedStore.js +77 -0
  206. package/vaultWorkerHost.js +98 -0
  207. package/vcWorker.js +34 -0
  208. package/voiceAttest.js +50 -0
  209. package/voiceCert.js +51 -0
  210. package/witbitz-admin.d.ts +135 -0
  211. package/witbitz-admin.js +529 -0
  212. package/witbitz-admin.mjs +1459 -0
  213. package/witbitz-sdk.d.ts +1106 -0
  214. package/witbitz-sdk.js +3835 -0
  215. package/workerClient.js +16 -0
  216. package/workerLiveness.js +21 -0
  217. package/x509.js +218 -0
@@ -0,0 +1,1106 @@
1
+ // witbitz-sdk.d.ts — types for https://witbitz-spaces.pages.dev/witbitz-sdk.js (written from the SDK's code, 2026-10-05).
2
+ // Held to the code by spaces/test/sdkTypesDrift.test.mjs: every public method here exists, and every public method there is here.
3
+ // Builder (server) calls: witbitz-admin.d.ts.
4
+ // Use it from TypeScript or for editor hints in plain JS:
5
+ // // @ts-check
6
+ // /** @typedef {import('./witbitz-sdk').Message} Message */ (after saving this file beside your code)
7
+ // Prose, examples and the rules behind each field: https://witbitz.chat/docs/sdk.md
8
+
9
+ export type Tier = 'standard' | 'enclave'
10
+ export type ReplyMode = 'auto' | 'always' | 'ondemand'
11
+ export type Effort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'
12
+
13
+ /** Every error the SDK throws or emits carries a `code` (sdk.md § Error codes). */
14
+ export interface WitbitzError extends Error { code?: string; [k: string]: unknown }
15
+
16
+ export interface Media { b64?: string; bytes?: Uint8Array | ArrayBuffer; mime: string; name?: string }
17
+
18
+ // ─── Messages ─────────────────────────────────────────────────────────────────────────────────────────────────────────
19
+ /** What `space.on('message', cb)` delivers and `space.messages` holds: the room's decrypted ledger entry, with `from`
20
+ * copied from `name` when absent. Fields are optional because each kind carries its own. */
21
+ export interface Message {
22
+ id: string
23
+ ts: number
24
+ /** text | media (has images/files) | mcp (an app→agent call) | data (a store write) | fork (the room moved). */
25
+ kind: 'text' | 'media' | 'mcp' | 'data' | 'fork' | string
26
+ /** The sender's display name (the `from` they posted with; the agent's name on its replies; 'system' on system lines). */
27
+ from: string
28
+ name: string
29
+ text: string
30
+ /** Set by the SERVER on the room's own AGENT output only (its replies, its data writes). Never "I sent this". */
31
+ self?: true
32
+ /** A system line (a config change, a connection call). */
33
+ sys?: true
34
+ /** The server's moderation list replaced this message's body and media. */
35
+ removedByWitbitz?: true
36
+ /** A mirrored copy was removed in its source Space; not a platform moderation verdict. */
37
+ sourceRemoved?: true
38
+ /** The sender passed the room's email gate: `user` is their @username, `spk` their device signing key. */
39
+ verified?: true
40
+ user?: string
41
+ /** The signing key the server verified this message against (a public JWK). Each device has its own: compare
42
+ * `m.spk.x` and `m.spk.y` with your session's `sign.pub`, never the objects with `===`. */
43
+ spk?: { kty: string; crv: string; x: string; y: string }
44
+ /** Carried here when the room MOVED (a move an older client made — `space.fork` is retired): the room it was first written in and the marks the server gave it
45
+ * there. `carriedBy` is the verified email of the member who moved the room. Both are the server's stamps. */
46
+ carried?: Carried
47
+ carriedBy?: string
48
+ md?: true
49
+ images?: Media[]
50
+ files?: Media[]
51
+ widgets?: unknown[]
52
+ replyTo?: { key: string; name?: string; excerpt?: string }
53
+ /** Where an entry came from when it was not written here: 'shared' (copied in through the mirror), 'fork', … A lane's
54
+ * copy of its shared room's line also has an `sh:` id — test with `isLaneCopy(m)`: a fork's or a recreated room's own
55
+ * history is copied in with `source: 'shared'` too, and is that room's own. */
56
+ source?: string
57
+ /** A lane's copy only: who wrote the original, as its Space verified them — `user` their @username (show `@` + it in place of an
58
+ * email `from`, as the Spaces app does), `email`, and `room` + `sid` (the Space and the writer's key row, e.g. for a photo). */
59
+ by?: { user?: string; email?: string; room?: string; sid?: string }
60
+ /** A lane's copy only: the original's franking record and its Space — a report of the copy names the ORIGINAL message. */
61
+ fr?: string
62
+ frRoom?: string
63
+ /** Reactions on this message: emoji → the names that reacted (in a verified room, `reactKeys` maps each name to its key). */
64
+ reactions?: Record<string, string[]>
65
+ /** Agent replies: web sources, the turn's usage, and (confidential rooms) the signed turn certificate. */
66
+ sources?: { url: string; title?: string }[]
67
+ usage?: Record<string, unknown>
68
+ cert?: Record<string, unknown>
69
+ certDoc?: string
70
+ /** A dictated message: the speech-to-text certificate. */
71
+ voice?: { model?: string; cert: Record<string, unknown> }
72
+ /** kind 'data': the row operations. */
73
+ ops?: unknown[]
74
+ /** A lane's crossing into the shared room. */
75
+ via?: 'bridge'
76
+ draft?: { by: string }
77
+ stopped?: true
78
+ timedOut?: true
79
+ [k: string]: unknown
80
+ }
81
+
82
+ /** An entry's marks from the room it was first written in (`Message.carried`, a row's `_carried`). */
83
+ export interface Carried { from: string; verified?: true; user?: string; email?: string }
84
+
85
+ export interface DataEvent { ops: unknown[]; from: string; self: boolean; text: string; ts: number }
86
+ export interface PartialEvent { text: string | null; step: { phase?: 'thinking' | 'writing' | 'deciding'; tool?: string; since?: number } | null }
87
+
88
+ // ─── Proposals ────────────────────────────────────────────────────────────────────────────────────────────────────────
89
+ /** A card the agent parked for a human: an action (any tool not in `immediateTools`, e.g. data_put) or, in a lane,
90
+ * a message to cross into the shared room. */
91
+ export interface Proposal {
92
+ id: string
93
+ kind: 'action' | 'message'
94
+ /** The tool name, e.g. 'data_put', or your lane action's name; 'cross_to_shared' for a crossing. */
95
+ action: string
96
+ /** The WHOLE parked action, including `type` (= action). Your lane action's `run()` receives this same object. */
97
+ args: { type: string; [k: string]: unknown }
98
+ text: string
99
+ approve(opts?: DecideOptions): Promise<DecideResult>
100
+ deny(opts?: { from?: string }): Promise<DecideResult>
101
+ }
102
+ export interface DecideOptions { from?: string; recordResult?: boolean }
103
+ /** `continued: true`: the call the server ran left its result in the room and the assistant was asked to go on from it — its reply arrives on 'message'. */
104
+ export interface DecideResult { status: number; result?: unknown; continued?: true; [k: string]: unknown }
105
+ /** 'resolved': `result` is your lane action's run() return value (propose mode), or the server's execution of a room action. */
106
+ export interface ResolvedEvent { id: string; approved: boolean; action: string; result?: unknown }
107
+
108
+ // ─── Agents and actions ───────────────────────────────────────────────────────────────────────────────────────────────
109
+ /** 'builder': the assistant is prompted with YOUR instructions and tools only — no Spaces framing (sdk-assistant.md#builder-mode). */
110
+ export type Framing = 'builder'
111
+ /** `showPrompt: true` on a send: what the model was sent, exactly. */
112
+ export interface SentPrompt { system: string; user: string; model: string; tools: { name: string; description?: string; inputSchema?: unknown }[] }
113
+ /** An app's own tool for the assistant (sdk-assistant.md#tools). The platform tools reach every room without being named;
114
+ * a bare name in `tools` is ignored by the server. */
115
+ export interface ToolDef { name: string; description?: string; inputSchema?: Record<string, unknown>; readOnly?: boolean; autoRun?: boolean }
116
+ export interface AgentSpec { name?: string; instructions?: string; tools?: ToolDef[]; model?: string | ModelPick }
117
+ /** A model choice — the shape the code reads and the server takes (sdk-assistant.md#model-effort): a catalog id from `wb.models()` or a wire name, and optionally its effort. */
118
+ export interface ModelPick { catalog?: string; wire?: string; params?: { reasoning_effort?: Effort } }
119
+ export interface LaneAction {
120
+ name: string
121
+ description?: string
122
+ input?: Record<string, unknown>
123
+ /** 'propose' (default): a card; on approve the SDK calls run(args) on this device and reports its return as `result`.
124
+ * 'await': runs during the turn; the return value goes back to the agent (≤ 25 s). */
125
+ mode?: 'propose' | 'await'
126
+ run(args: { type: string; [k: string]: unknown }): unknown | Promise<unknown>
127
+ }
128
+ /** The email gate a room is created with (createSpace / privateLane / plan / changeMembers). `admins` and `owners` are plain email
129
+ * arrays — an object here was silently dropped (an earlier version of this type said `{ emails }`). */
130
+ export interface Admission {
131
+ emails?: string[]
132
+ domains?: string[]
133
+ /** true: every address is readable to members; an array: just those (each must be in `emails`). Else room-salted hashes. */
134
+ advertise?: boolean | string[]
135
+ /** Admins and owners, by email; each must also be admitted by the gate. */
136
+ admins?: string[]
137
+ owners?: string[]
138
+ }
139
+ /** What `space.admission()` reads back from the room's sealed config. */
140
+ export interface AdmissionInfo {
141
+ gated: boolean
142
+ /** The ADVERTISED entries; `hidden` counts those stored only as a room-salted hash (check one with `space.admits`). */
143
+ emails?: string[]
144
+ domains?: string[]
145
+ hidden?: number
146
+ /** Private invitations still unmatched by a verified sign-in, when the roster could be read. */
147
+ unopenedPrivateInvites?: number
148
+ admins?: string[]
149
+ owners?: string[]
150
+ /** This room is a member's private lane (not a Space). */
151
+ lane?: true
152
+ /** This Space gives every member a private lane (`createSpace({ lanes: true })`, the app's option). */
153
+ lanes?: true
154
+ }
155
+
156
+ // ─── Space ────────────────────────────────────────────────────────────────────────────────────────────────────────────
157
+ /** A room's name (sdk-rooms.md#room-name): the newest rename or generated name in the room's log, else its shared title doc. */
158
+ export interface RoomTitle { title: string; manual: boolean; by: string }
159
+ export interface SpaceEvents {
160
+ /** The room's name changed: a member renamed it (`manual`), or a name was generated. */
161
+ title: RoomTitle
162
+ message: Message
163
+ data: DataEvent
164
+ partial: PartialEvent
165
+ proposal: Proposal
166
+ proposals: Proposal[]
167
+ resolved: ResolvedEvent
168
+ /** A message you already have changed in place (a reaction, an image caption, a reply's cards); `messages` holds `message`. */
169
+ update: { id: string; message: Message; fields: string[] }
170
+ /** Poll errors (the loop keeps going). `code`: no_key, bad_mkseal, enclave_warming, not_found, cannot_open, unavailable, http_<n>, … — after
171
+ * `not_authorized` (`reason` not_on_list) or `gate_unreadable` it reads once a minute (sdk.md). */
172
+ error: WitbitzError
173
+ /** An older client moved the room to a new key (a fork notice): open `link` to follow. */
174
+ moved: { room: string; link: string; from: string; at: number }
175
+ moveRefused: { from: string; room?: string; at: number; reason: string; code?: string }
176
+ /** The room's key changed IN PLACE (a member change or a rotation, sdk-people.md#members) and this Space took the new one: same room,
177
+ * `link` carries the new key (null in a vault). */
178
+ rekeyed: { room: string; epoch: number; link?: string | null }
179
+ /** The room was re-keyed and this account is no longer on its list: nothing written from now on reaches this Space. */
180
+ removed: { room: string }
181
+ /** On the room's list, but no new key this device can open: `reason` 'pending' (no invite key for this app at the change),
182
+ * 'no_invite_key' (this device holds none — restore `wb.invite.state`), … Ask a member for the link again. */
183
+ pending: { room: string; reason?: string }
184
+ /** Safe media was turned on or off for everyone (`from`: who did; sdk-rooms.md#safe-media). On a private lane it fires when
185
+ * its Space's setting moves, with `via: 'space'` (a lane follows its Space). */
186
+ safeMedia: { on: boolean; from: string; ts: number; via?: 'space' }
187
+ /** A safe copy of a photo or a PDF arrived: `for` names its message (`id`) and attachment (`at`, `i`). Read it with `space.safeMedia.copy`. */
188
+ safeCopy: { for: { id: string; at: 'images' | 'files'; i: number } }
189
+ /** An outside agent's message in a solo verified Space or private lane, waiting for the member (sdk-agents.md#a2a). */
190
+ a2a: { taskId: string; peer: { id: string; name: string }; text: string; draft: string; approve(text?: string): Promise<unknown>; askBack(text: string): Promise<unknown>; decline(): Promise<unknown> }
191
+ }
192
+ export interface LaneEvents extends SpaceEvents {}
193
+ /** The tools Witbitz gives every assistant. `cross_to_shared` exists only in a private lane (it posts to the lane's
194
+ * shared Space, after the member approves); `connection_call` only in a room with an API-key connection. Not a closed
195
+ * list: the deployment may add more. */
196
+ export type PlatformTool = 'web_search' | 'fetch_url' | 'read_url' | 'read_file' | 'write_pdf' | 'write_document' | 'write_spreadsheet' | 'look_at_image' | 'show_photo' | 'show_chart' | 'show_diagram' | 'search_places' | 'show_places' | 'add_place' | 'connection_call' | 'cross_to_shared' | (string & {})
197
+ /** Which platform tools the room's assistant gets: `true` / absent = all (the default), `false` = none, a list = only
198
+ * those. Fewer tools = fewer tokens on every model call; your own `tools`, client actions and `data` are not affected. */
199
+ export type PlatformTools = boolean | PlatformTool[]
200
+ export interface WriteResult { ok: true; id: string; ops: unknown[] }
201
+ /** What one turn's model calls used (sdk-assistant.md#turn-usage). `costMicros` is the provider's figure in millionths of a dollar;
202
+ * `source` 'provider-partial' | 'none' = some calls reported no cost, and the total counts only the priced ones. */
203
+ export interface UsageTotals { turns: number; calls: number; in: number; out: number; cached: number; costMicros: number }
204
+ export interface TurnUsage { tokensIn: number; tokensOut: number; tokensCached: number; costMicros: number; costUsd: number; calls: number; models: string[]; source: 'provider' | 'provider-partial' | 'none'; estimated?: true; funded?: true }
205
+ export interface SendResult { /** 0 when the request got no answer (network, enclave unreachable) — such a send MAY have been posted: read the room before resending */ status: number; /** always present: false for any refusal, busy or failure; true when posted, silent or pending */ ok: boolean; /** when !ok: 'busy', 'not_authorized' (with `reason`: not_on_list, grant_required, …), 'gate_unreadable', 'policy_invalid', 'bad_mkseal', 'enclave_warming', 'user_token_required', 'run_needs_payer', 'reply_not_stored', 'unavailable' / 'enclave_unavailable' (status 0), 'enclave_policy_unknown' (503, retryable: nothing was sent — the enclave could not be checked yet), 'answer_unsealed' (502: a sealed request's answer came back unsealed — not from the enclave), 'answer_unopenable' (its sealed answer did not open), 'store_unavailable' (503: the server could not save just now — retry), 'envelope_op_refused' / 'envelope_stale' / 'envelope_replay' / 'bad_envelope' (400: the enclave refused a sealed request; nothing ran), 'aborted' (space.turn()'s abort/timeout while held for busy — not stored), … — sdk-reference.md#errors */ error?: string; reason?: string; /** status 0: what failed */ detail?: string; pending?: true; reply?: string; silent?: true; proposed?: unknown[]; /** absent on a pending turn — read it from space.turn()'s result, or the reply message's `usage` */ usage?: TurnUsage; /** with `showPrompt: true` and a turn that finished inside the request */ prompt?: SentPrompt; [k: string]: unknown }
206
+ export interface DictationResult { readonly text: string; readonly room: string; readonly certificate: Record<string, unknown> | null }
207
+ export interface SendOptions {
208
+ dictation?: DictationResult
209
+ from?: string; mode?: ReplyMode; instructions?: string; images?: Media[]; files?: Media[]
210
+ /** The turn's cancel key (8–64 of A–Z a–z 0–9). `space.turn()` sets one so `t.abort()` can stop the turn — use that. */
211
+ stopKey?: string
212
+ /** Answer with `prompt`: the exact system text, user text, model and tools this turn sent (sdk-assistant.md#builder-mode). */
213
+ showPrompt?: boolean
214
+ /** The message this one answers — it is quoted beside it, as in the app (sdk-rooms.md#replies). */
215
+ replyTo?: Message
216
+ /** Tools the page offers the assistant for THIS question (sdk-assistant.md#page-tools) — the shape a Lane's actions take. */
217
+ tools?: LaneAction[]
218
+ }
219
+ export interface Snapshot { count: number; etag: string; messages: Message[]; /** Safe media: the copies kept beside their photos (never messages) */ safeCopies?: unknown[]; rows: unknown; title?: (RoomTitle & { ts: number | null }) | null; /** a lane's outside-agent tasks waiting for a draft or the member (resume offers them again) */ a2a?: Array<{ taskId: string; peer: { id: string; name: string; reply: 'ask' | 'auto'; job?: true }; text: string; at: number; cursor: number; draft?: string }>; [k: string]: unknown }
220
+ /** What on() returns: call it to remove the listener (it returns the space). It also chains `.on()` / `.off()`. */
221
+ export interface Unsubscribe<S> { (): S; on: S extends { on: infer F } ? F : never; off: S extends { off: infer F } ? F : never }
222
+
223
+ export type TurnStatus = 'running' | 'done' | 'silent' | 'failed' | 'aborted' | 'timeout'
224
+ export interface RunResult { ok: boolean; text?: string; output?: unknown; usage?: TurnUsage; prompt?: Record<string, unknown>; error?: string; detail?: string; /** rate_limited: seconds to wait */ retryAfter?: number }
225
+ export interface TurnResult { status: Exclude<TurnStatus, 'running'>; reply: Message | null; text: string; proposed: unknown[]; usage?: TurnUsage; error?: string; /** with a failed turn: the server's sentence for the person, when it gave one (e.g. not_authorized's `not_on_list`) */ reason?: string }
226
+ /** `space.turn(text)` — one turn's answer (sdk-assistant.md#turn). */
227
+ export interface Turn {
228
+ readonly status: TurnStatus
229
+ /** The reply as streamed so far. */
230
+ readonly text: string
231
+ /** send()'s result once the server answered, else null. */
232
+ readonly result: SendResult | null
233
+ /** Resolves when the turn settles. Never rejects. */
234
+ readonly finished: Promise<TurnResult>
235
+ on(event: 'partial', cb: (e: PartialEvent) => void): () => void
236
+ on(event: 'done', cb: (e: TurnResult) => void): () => void
237
+ /** Stop the reply (op:'stop'); false when it had already settled. */
238
+ abort(): Promise<boolean>
239
+ }
240
+
241
+ /** `space.connections` — what THIS Space's assistant may spend. */
242
+ export interface SpaceConnections {
243
+ grants(): Promise<Array<{ id: string; label: string; host: string; status: 'connected' | 'other_member' | 'detached' | 'unknown' }>>
244
+ /** An MCP connection brings its tools: `tools` (names) to choose them, else the recommended set; `auto` (names) run without asking. */
245
+ grant(conn: Connection | { id: string; callKey: string; host?: string; label?: string; account?: string; mcp?: boolean }, opts?: { from?: string; tools?: string[]; auto?: string[]; reads?: 'auto' | 'ask' }): Promise<unknown>
246
+ revoke(id: string, opts?: { from?: string }): Promise<unknown>
247
+ }
248
+ /** `space.siri` — this Space's Siri alias and its drops. */
249
+ export interface SpaceSiri {
250
+ enable(opts: { alias: string; label?: string; makeDefault?: boolean }): Promise<{ key: string; endpoint: string; alias: string }>
251
+ disable(): Promise<unknown>
252
+ /** `deliver(text, meta)` takes each drop instead of posting it. At-least-once: dedupe on `meta.id`. */
253
+ collect(opts?: { deliver?: (text: string, meta: { id: string; room: string; alias: string; at: number }) => unknown }): Promise<{ delivered: number; more?: boolean; elsewhere: Array<{ room: string; label?: string; alias?: string }>; /** captures this device could not open — left in the inbox for a device that can (not deleted) */ unopened?: number }>
254
+ }
255
+
256
+ /** Which attachment of a message: `at` 'images' | 'files' (default: its first image, else its first file), `i` (default 0). */
257
+ export interface SafeRef { at?: 'images' | 'files'; i?: number }
258
+ /** A safe copy, VERIFIED on this device: JPEGs the tools enclave made, every byte checked against its attestation. */
259
+ export interface SafeCopy { ok: true; versions: Array<{ w: number; h: number; b64: string }>; statement: string; att: string }
260
+ /** `space.safeMedia` — SAFE MEDIA (sdk-rooms.md#safe-media): others' photos and PDFs shown only from copies an attested enclave made safe. */
261
+ export interface SpaceSafeMedia {
262
+ /** The setting as this handle knows it; null until `refresh()`, a send with a photo, or a line that changed it. */
263
+ readonly on: boolean | null
264
+ /** False while this release names no accepted safe-media enclave (nothing would verify). */
265
+ readonly available: boolean
266
+ /** Read the room's sealed settings. */
267
+ refresh(): Promise<boolean>
268
+ /** Turn it on or off for everyone — the room's admins where it names some, any member otherwise; a line says who did. On a private lane: rejects with `lane_follows_space` (a lane follows its Space). */
269
+ set(on: boolean, opts?: { from?: string }): Promise<{ changed: string[] }>
270
+ /** The first copy of that attachment that verifies here, or `{ ok: false, why }`. Draw `versions`, never the original. */
271
+ copy(message: Message, ref?: SafeRef): Promise<SafeCopy | { ok: false; why: string }>
272
+ /** Does the original (`space.attachment(…).b64`) hash to the file `copy` was made from? Check before opening it. */
273
+ isOriginal(copy: SafeCopy, b64: string): Promise<boolean>
274
+ /** Make the copy for everyone (a signed-in session; counted to the account). send() does this by itself while the setting is on. */
275
+ make(message: Message, ref?: SafeRef, opts?: { from?: string }): Promise<{ ok: boolean; error?: string }>
276
+ }
277
+
278
+ export interface PlanResult {
279
+ how: 'none' | 'in_place' | 'new_room' | 'refused'
280
+ /** kept (in place) · carried (a move carries it by default) · not_carried (a new room) */
281
+ history: 'kept' | 'carried' | 'not_carried' | null
282
+ /** The call that makes the change, e.g. "space.configure(…)". */
283
+ call: string | null
284
+ steps: string[]
285
+ reason?: string
286
+ /** With `how: 'refused'`: the error code the change itself would give — e.g. `not_admin`, `sign_in_required`,
287
+ * `governed_room`, `use_change_members`, `lane`, `lane_follows_space`, `unknown_field` (sdk-reference.md#errors). */
288
+ code?: string
289
+ }
290
+
291
+ export declare class Space {
292
+ readonly room: string
293
+ /** Latest key rotation observed by this handle. Null until it observes one. */
294
+ readonly epoch: number | null
295
+ readonly shareLink: string
296
+ /** The room key (base64url). Treat it as a secret: it IS the admission. null over a keyless client. */
297
+ readonly key: string | null
298
+ /** True for a temporary room (createSpace({ temporary })): wiped when idle, never in the account backup. */
299
+ readonly temporary: boolean
300
+ /** True when the room gives every member a private assistant (createSpace({ lanes: true }), or a link that says so). */
301
+ readonly lanes: boolean
302
+ readonly messages: Message[]
303
+ /** The room's name — the same on every device and in the Spaces app; null while it has none. 'title' fires when it changes. */
304
+ readonly title: string | null
305
+ readonly connections: SpaceConnections
306
+ /** Outside agents in a solo verified Space, or in a private Lane. */
307
+ readonly a2a: LaneA2A
308
+ readonly siri: SpaceSiri
309
+ /** Safe media in this Space: the setting, verified safe copies of photos and PDFs, making one. */
310
+ readonly safeMedia: SpaceSafeMedia
311
+ /** What logs and serialisers see: the room, never the key or the link. */
312
+ toJSON(): { room: string; shareLink: '[REDACTED]'; messages: number; lane?: true; sharedRoom?: string | null }
313
+ /** Resolves once the room's whole history has been read (every page of a long room); rejects only with code `cannot_open`, `pass_required` (the room requires a room pass this client cannot get) or `closed`. */
314
+ readonly ready: Promise<this>
315
+ readonly data: {
316
+ /** Each row: its fields plus `id`, `_updated`, `_by`, `_v`, and `_verified` / `_email` / `_user` when a gated member
317
+ * wrote it (`_carried` / `_carriedBy` when it came with a moved room — see {@link Carried}). */
318
+ rows(collection: string): Array<Record<string, unknown> & { id: string; _updated: number; _by: string; _v: string | null; _verified?: true; _email?: string; _user?: string }>
319
+ get(collection: string, id: string): Record<string, unknown> | null
320
+ /** A refused write throws (`code` = the server's error); a conflicting conditional write throws `row_changed`. */
321
+ put(collection: string, row: Record<string, unknown>, opts?: { id?: string; from?: string; ifVersion?: string | null }): Promise<WriteResult>
322
+ delete(collection: string, id: string, opts?: { from?: string; ifVersion?: string }): Promise<WriteResult>
323
+ batch(ops: unknown[], opts?: { from?: string }): Promise<WriteResult>
324
+ }
325
+ /** `{ replay: false }` on 'message': only what arrives after the room's history was read. */
326
+ on<E extends keyof SpaceEvents>(event: E, cb: (e: SpaceEvents[E]) => void, opts?: { replay?: boolean }): Unsubscribe<this>
327
+ /** No `cb`: every listener for the event. */
328
+ off<E extends keyof SpaceEvents>(event: E, cb?: (e: SpaceEvents[E]) => void): this
329
+ send(text: string, opts?: SendOptions): Promise<SendResult>
330
+ /** An emoji on a message, or `{ off: true }` to take yours off (sdk-rooms.md#replies). No new entry, no assistant turn. */
331
+ react(message: Message, emoji: string, opts?: { off?: boolean; from?: string }): Promise<{ ok: boolean; reactions?: Record<string, string[]>; error?: string }>
332
+ /** 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. */
333
+ turn(text: string, opts?: SendOptions & { timeoutMs?: number }): Turn
334
+ /** The assistant as a function (sdk-assistant.md#run): one answer, nothing written to the room. `schema`: `{ field: type }` or a
335
+ * JSON Schema object → `output` fits it, or `error: 'no_structured_output'`. Must finish within ~30 s (`too_slow`). */
336
+ run(input: string, opts?: { instructions?: string; schema?: Record<string, unknown>; images?: Media[]; from?: string; showPrompt?: boolean }): Promise<RunResult>
337
+ /** Rename the room for every member and device (they are notified). Throws `not_admin` in a room with owners or admins
338
+ * for anyone else, and `direct_chat` in a direct chat (it is called by the other person's name); in an email-gated room
339
+ * `not_authorized` with `e.reason` `not_on_list` / `unsigned`. `unavailable` when the room did not answer or failed (nothing stored — try again). `ok` false: an older server took it into the shared doc only. */
340
+ rename(name: string, opts?: { by?: string }): Promise<{ ok: boolean; title: string }>
341
+ setReplyMode(mode: ReplyMode): Promise<{ mode: ReplyMode }>
342
+ replyMode(): Promise<ReplyMode>
343
+ /** Which of the assistant's tools run on their own here, and which ask first (a card a person approves). Enforced by the server
344
+ * on every turn; the same setting as the Witbitz app's ⋯ → Tools. In a room with admins only an admin may set them. */
345
+ readonly toolRules: {
346
+ get(): Promise<{ tools: Array<{ name: string; about: string; default: 'auto' | 'ask'; now: 'auto' | 'ask'; rule?: 'auto' | 'ask' }>; rules: Record<string, 'auto' | 'ask'> }>
347
+ /** 'auto' — runs on its own; 'ask' — asks first; null — back to the tool's default. */
348
+ set(name: string, mode: 'auto' | 'ask' | null): Promise<{ rules: Record<string, 'auto' | 'ask'> }>
349
+ }
350
+ /** Poll now; the proposals waiting for a decision. */
351
+ pending(): Promise<Proposal[]>
352
+ approve(id: string, opts?: DecideOptions): Promise<DecideResult>
353
+ deny(id: string, opts?: { from?: string }): Promise<DecideResult>
354
+ /** Change the assistant or the store in place. Refuses, before sending: `create_time` (tools, immediateTools, tier, key),
355
+ * `use_fork` (admission — change it with changeMembers; `lane` on a lane), `unknown_field` (anything else) — sdk-reference.md#errors. */
356
+ configure(opts: { agent?: Omit<AgentSpec, 'tools'>; data?: Record<string, unknown> | null; platformTools?: PlatformTools; framing?: Framing | null; dataWrites?: boolean | null; /** Private assistants for everyone, on or off in place (members' existing private rooms stay as their own Spaces). */ lanes?: boolean; /** Safe media on/off for everyone (sdk-rooms.md#safe-media) */ safeMedia?: boolean; from?: string }): Promise<{ changed: string[] }>
357
+ /** What a change would require — in place or a new room — and whether the history comes along. Changes nothing.
358
+ * On a lane, `safeMedia` is refused with `lane_follows_space` (set it on the Space). */
359
+ plan(change: { agent?: AgentSpec; data?: Record<string, unknown> | null; history?: 'full' | 'forward'; platformTools?: PlatformTools; framing?: Framing | null; dataWrites?: boolean | null; lanes?: boolean; safeMedia?: boolean; admission?: Admission; tier?: Tier; key?: 'split'; tools?: ToolDef[]; immediateTools?: string[] }): Promise<PlanResult>
360
+ /** A private assistant lane for the current member (sdk-agents.md#lanes). On a Lane: rejects with `lane_of_lane` (ask from its Space). */
361
+ privateLane(opts: { agent?: AgentSpec; actions?: LaneAction[]; tools?: ToolDef[]; immediateTools?: string[]; model?: AgentSpec['model']; data?: Record<string, unknown>; platformTools?: PlatformTools; framing?: Framing; dataWrites?: boolean; admission?: Admission; tier?: Tier; mirror?: boolean | { data?: boolean } }): Promise<Lane>
362
+ /** Change who is in IN PLACE (sdk-people.md#members): the same room, link, history and lanes; a new key that only the people still on
363
+ * the list receive. `admission` is the list stated in full. Needs a signed-in owner or admin. In a vault the person confirms
364
+ * there and `link` is absent. Refuses `not_admin`, `sign_in_required`, `no_invite_key`, `changed_meanwhile`, `lane`, `store_unavailable` (503: not saved — retry). */
365
+ /** `roles: true`: only owners/admins changed — the room kept its key (nobody's access changed). */
366
+ changeMembers(admission: Admission): Promise<MemberChange & { removed: string[]; added: string[]; roles?: true }>
367
+ /** The same members, a new key (a lost phone, a link sent to the wrong place) — sdk-people.md#members. */
368
+ rotateKey(): Promise<MemberChange & { rotated: true }>
369
+ /** Resend the current link through this app's invite directory. Does not add admission. Attested rooms use their native app. */
370
+ resendInvite(recipient: { email: string; username?: never } | { username: string; email?: never }): Promise<{ ok: boolean; reason?: string }>
371
+ /** RETIRED (3.0.0): a Space no longer moves — members change in place (`changeMembers`). Always throws `use_change_members`. */
372
+ fork(opts?: unknown): Promise<never>
373
+ /** A direct chat's other person, from its sealed allow-list; null when this is not a direct chat you are in (sdk-people.md#direct-chats). */
374
+ directPeer(): Promise<{ email: string } | { username: string; handle?: string } | null>
375
+ usage(): Promise<{
376
+ records: { at: number; kind: 'title' | 'reply'; usage: { by?: string; calls?: number; in?: number; out?: number; cached?: number; costMicros?: number; models?: string[]; source?: string } }[]
377
+ summary: { all: UsageTotals; week: UsageTotals; byPerson: (UsageTotals & { name: string })[]; byModel: { model: string; turns: number }[]; partial: boolean; empty: boolean }
378
+ csv: string
379
+ incomplete: boolean
380
+ }>
381
+ roster(): Promise<{
382
+ incomplete: boolean
383
+ gated: boolean
384
+ members: { label: string; address?: string; username?: string; verified: boolean }[]
385
+ pending: { label: string; address?: string; username?: string }[]
386
+ domains: string[]
387
+ unopenedPrivateInvites: number
388
+ }>
389
+ admission(): Promise<AdmissionInfo>
390
+ admits(email: string): Promise<boolean>
391
+ isAdmin(email: string): Promise<boolean>
392
+ isOwner(email: string): Promise<boolean>
393
+ /** Import a public ChatGPT, Claude, Gemini or Grok share URL. The server validates the source. */
394
+ importChat(url: string): Promise<{ imported: number; title: string; entries: number }>
395
+ /** Import the text from a WhatsApp chat export (unzip the export first). */
396
+ importWhatsApp(text: string): Promise<{ imported: number; title: string; entries: number }>
397
+ /** Sealed schedules, shared with the app. Adding/resuming needs an active always-on cloud device. */
398
+ readonly schedules: {
399
+ list(): Promise<Array<{ id: string; when: { every: number } | { at: string; tz: string }; text: string; by: string; at: number; paused?: boolean; pausedAt?: number }>>
400
+ 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 }>
401
+ remove(id: string): Promise<unknown[]>
402
+ pause(id: string, paused?: boolean): Promise<unknown[]>
403
+ }
404
+ readonly alwaysOn: {
405
+ status(): Promise<{ on: boolean; registered: boolean; waiting?: string }>
406
+ /** A backed-up solo Space; disconnectLanes explicitly turns its private assistants off first. */
407
+ enable(opts?: { disconnectLanes?: boolean }): Promise<{ on: true }>
408
+ disable(): Promise<{ on: false }>
409
+ /** Starts a run on the cloud device; the answer arrives in the Space. */
410
+ run(text: string): Promise<{ started: boolean }>
411
+ }
412
+ attachment(att: Media | Record<string, unknown>): Promise<Media>
413
+ /** The newest message carrying a file or image of this name (case-insensitive) — the assistant links files by name. Bytes: attachment(att). */
414
+ fileNamed(name: string): { message: Message; att: Media } | null
415
+ /** 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. */
416
+ isMine(message: Message): boolean
417
+ /** 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). */
418
+ blockIdentity(message: Message): BlockWho | null
419
+ /** 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.
420
+ * Throws `invalid_argument`, `sign_in_required`; in a vault `vault_unsupported`. Refusals are answers (`not_member`, `sign_in`, `budget`). */
421
+ report(message: Message, opts: { reason: ReportReason; note?: string; context?: boolean }): Promise<{ ok: true; id: string; /** Witbitz's own record of the message matched — the report can be acted on alone */ proven: boolean } | { ok: false; error: string; detail?: string }>
422
+ static readonly REPORT_REASONS: readonly ReportReason[]
423
+ /** 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`. */
424
+ attested(): Promise<{ required: boolean; confidential: boolean }>
425
+ exportFile(): Promise<{ count: number }>
426
+ sealedProof(): Promise<Record<string, unknown> | null>
427
+ /** Confidential rooms: verify every reply's turn certificate on this device. */
428
+ 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> }>
429
+ snapshot(): Snapshot
430
+ close(): void
431
+ }
432
+
433
+ /** `lane.link(other)` — two of a member's assistants that ask each other (sdk-agents.md#lane-links). */
434
+ export interface LaneLink {
435
+ readonly a: Lane
436
+ readonly b: Lane
437
+ /** How many lanes a request may cross before it is answered where it is. */
438
+ readonly cap: number
439
+ /** The progress to persist (JSON-safe) — hand it back as `link(other, { resume })` after a reload. */
440
+ readonly state: { cursorA: number | null; cursorB: number | null; sentA: string[]; sentB: string[] }
441
+ /** End the link: neither assistant is offered the other any more. */
442
+ unlink(): void
443
+ /** Forward what is waiting now (it also runs on every new message). */
444
+ run(): Promise<{ forwarded: number }>
445
+ }
446
+ export interface SharedAgentDraft {
447
+ taskId: string; peerId: string; peerName: string; reply: 'ask' | 'auto'; text: string; draft: string; at: number; by: string
448
+ }
449
+ /** Outside agents in a private lane or solo verified Space. */
450
+ export interface LaneA2A {
451
+ readonly cardUrl: string | null
452
+ /** The same door over MCP (tools message_member / get_reply), with the same per-peer token. */
453
+ readonly mcpUrl: string | null
454
+ readonly peers: Array<{ id: string; name: string; reply: 'ask' | 'auto'; job?: true; own?: true; [k: string]: unknown }>
455
+ enable(opts: { name: string; description?: string }): Promise<{ cardUrl: string; mcpUrl: string }>
456
+ /** `job: true` — an agent that takes jobs: it reports and its run ends, reading no reply; its reports are told to the member and a follow-up goes as a new job. */
457
+ /** In a vault (`Witbitz.inVault`) the token is shown on the vault's own screen and never reaches the page: `token` is null and `shown` true. */
458
+ addPeer(name: string, opts?: { reply?: 'ask' | 'auto'; job?: boolean }): Promise<{ id: string; token: string | null; shown?: boolean; cardUrl: string; mcpUrl: string }>
459
+ setReply(peerId: string, reply: 'ask' | 'auto'): Promise<{ id: string; reply: 'ask' | 'auto' }>
460
+ removePeer(peerId: string): Promise<{ removed: boolean }>
461
+ disable(): Promise<{ disabled: boolean }>
462
+ collect(): Promise<{ delivered: number; more?: boolean }> // more: it stopped 45 s after the pull — collect again (state machines pass 9, K#9)
463
+ reply(taskId: string, text: string, opts?: { ask?: boolean; reject?: boolean }): Promise<unknown>
464
+ sharedDrafts(): Promise<SharedAgentDraft[]>
465
+ reviewDraft(draft: SharedAgentDraft, text?: string, opts?: { ask?: boolean; reject?: boolean }): Promise<{ state: string }>
466
+ }
467
+
468
+ export declare class Lane extends Space {
469
+ on<E extends keyof LaneEvents>(event: E, cb: (e: LaneEvents[E]) => void, opts?: { replay?: boolean }): Unsubscribe<this>
470
+ setActions(actions: LaneAction[]): this
471
+ setLinks(links: Array<Space | { space: Space; label?: string }>): this
472
+ send(text: string, opts?: SendOptions & { replace?: boolean; links?: Array<Space | { space: Space; label?: string }> }): Promise<SendResult>
473
+ turn(text: string, opts?: SendOptions & { tools?: LaneAction[]; replace?: boolean; links?: Array<Space | { space: Space; label?: string }>; timeoutMs?: number }): Turn
474
+ /** Synchronous: returns the link's handle. */
475
+ link(other: Lane, opts?: { to?: string; as?: string; cap?: number; resume?: LaneLink['state'] }): LaneLink
476
+ /** Connect a kept always-on Space as a job agent of this private lane. Credentials stay in the vault in vault mode. */
477
+ linkKept(space: Space, opts?: { spaceName?: string; laneName?: string }): Promise<{ lane: string; space: string; connId: string; lPeer: string; sPeer: string }>
478
+ unlinkKept(space: Space, link: { lane: string; space: string; connId: string; lPeer: string; sPeer: string }): Promise<{ disconnected: true }>
479
+ /** Copy the shared room's new messages into this lane now (a lane opened with `mirror`). */
480
+ mirrorNow(): Promise<unknown>
481
+ }
482
+
483
+ // ─── The client ───────────────────────────────────────────────────────────────────────────────────────────────────────
484
+ /** `sign`: this device's signing keypair (JWKs) — the key a verified room stamps on its messages as `spk`. */
485
+ export interface Session { email: string; idToken: string; exp: number; sign?: { pub: { kty: string; crv: string; x: string; y: string }; priv: Record<string, unknown> } }
486
+ export interface WitbitzOptions {
487
+ endpoint?: string
488
+ /** The origin a shareLink opens in: links read `<viewer>/space?room=<id>#mk=<key>`. */
489
+ viewer?: string
490
+ app?: string
491
+ /** Your tenant's PUBLIC id (t_…). Needed to CREATE rooms from your own origin (declared with admin.origins). */
492
+ tenant?: string
493
+ /** Server only — prefer WitbitzAdmin (witbitz-admin.js). A page that passes one logs a warning. */
494
+ tenantKey?: string
495
+ tenantEndpoint?: string
496
+ session?: Session
497
+ userToken?: string | (() => string | Promise<string>)
498
+ live?: boolean
499
+ appShare?: string
500
+ enclaveClaim?: string
501
+ /** The Witbitz dev server's attestation root (base64 DER) — for a local dev server with a confidential tier only. It REPLACES the
502
+ * pinned AWS root for this client's confidential tier, so such a client trusts that local server's enclave and never Witbitz's. */
503
+ devRoot?: string
504
+ backup?: unknown
505
+ /** Device storage protection's Storage (localStorage by default), its config key, and the passkey's site (this host by default). */
506
+ protect?: ProtectOptions | Protect
507
+ /** Native device attestation bridge. `attest: { app }` alone is retired; web pages cannot prove a native app identity. */
508
+ attest?: { bridge: { platform(): string | Promise<string>; enroll(bound: string): unknown | Promise<unknown>; sign(bound: string): unknown | Promise<unknown>; keyId?(): string | Promise<string> }; app?: string; storage?: Storage }
509
+ /** The home region new rooms are made in — a code like `'us'` (docs: multi-region). Default: the default region. A private lane always takes its shared room's. */
510
+ region?: string
511
+ /** Which enclave build a confidential room's key may be sealed to: 'published' (default — any build Witbitz publishes) or
512
+ * 'mine' — the person's own list of accepted builds, as the Witbitz app does (`wb.builds`). `{ mode, state }` hands back a
513
+ * persisted list for a page without an account. */
514
+ builds?: 'published' | 'mine' | { mode?: 'published' | 'mine'; state?: BuildsState }
515
+ deviceName?: string
516
+ vaultApi?: string
517
+ siri?: unknown
518
+ a2a?: unknown
519
+ a2aEndpoint?: string
520
+ /** A persisted `wb.invite.state` (sdk-people.md#members). */
521
+ invite?: unknown
522
+ loginBase?: string
523
+ /** The standing Sentinel that keeps connections' keys. `follow` (2.2.3): `'published'` (default) accepts a new build Witbitz
524
+ * publishes at /sentinel-claim.json; `'ask'` calls `onNewBuild(pcr0)` and accepts on `true`; `'off'` keeps the pins. Your own
525
+ * `pins` (a tenant running its own Sentinel) are never followed. */
526
+ sentinel?: { pins?: string[], follow?: 'published' | 'ask' | 'off', onNewBuild?: (pcr0: string) => boolean | Promise<boolean>, claimUrl?: string, verify?: Function }
527
+ fetchImpl?: typeof fetch
528
+ WebSocketImpl?: unknown
529
+ /** Advanced: a client whose ops take no room key (`keyless: true`) — the keys live where it sends the ops.
530
+ * {@link Witbitz.inVault} plugs one in for you. */
531
+ client?: object
532
+ }
533
+
534
+ /** A vault's lock, as the person set it (a vault started with `lock: true`): `on` — a passkey at every launch; `protect` — its storage encrypted until unlocked. */
535
+ export interface VaultLock { available: true; on: boolean; protect: boolean }
536
+ /** A vault's notifications on this device, as the person set them (a vault started with `push: true`). */
537
+ export interface VaultPush { available: true; on: boolean }
538
+ /** A Space in the vault's list — never its link (the link carries the key). */
539
+ export interface VaultRoom { room: string; title: string; at: number; /** a private lane: the room of its Space */ lane?: string; /** a confidential Space */ tier?: 'enclave'; /** every member gets a private assistant (sdk-agents.md#lanes-for-everyone) */ lanes?: true }
540
+ /** `wb.vault` — the vault this page runs in (docs: § Vault mode). The keys are there; this page never holds one. */
541
+ export declare class VaultSession {
542
+ /** The vault's origin. */
543
+ readonly origin: string
544
+ /** What the vault said when the page connected. */
545
+ 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 }
546
+ /** The Spaces this vault holds, newest first. */
547
+ rooms(): Promise<VaultRoom[]>
548
+ /** A live Space for a room the vault holds; its key stays in the vault (`space.key` and `space.shareLink` are null). A private
549
+ * lane's room id (`rooms()` marks it with `lane`) gives a `Lane` of its Space — `lane_space_gone` once that Space is forgotten. */
550
+ openRoom(room: string, opts?: { resume?: Snapshot }): Promise<Space | Lane>
551
+ /** The vault shows its share screen with the invite link; the link never reaches this page. */
552
+ share(space: Space | string, opts?: { title?: string }): Promise<{ shown: true }>
553
+ /** The vault shows the Siri Shortcut's key in its own screen; the key never reaches this page. */
554
+ showSiriKey(): Promise<{ shown: true }>
555
+ /** The vault shows its LOCK SHEET: the person turns the lock and "Also protect this device's storage" on or off there; resolves
556
+ * with the outcome when they close it. Rejects `vault_unsupported` unless the vault was started with `lock: true`. */
557
+ showLock(): Promise<VaultLock>
558
+ /** The vault asks the person, in its own card, to turn notifications on (or off) on this device; resolves with the outcome. A
559
+ * tapped notification arrives as `on('notifOpen', ({ room }) => …)`. Rejects `vault_unsupported` unless the vault was started
560
+ * with `push: true`. */
561
+ showNotifications(): Promise<VaultPush>
562
+ /** The vault shows its sign-in screen; resolves once signed in. */
563
+ signIn(opts?: { email?: string }): Promise<{ email: string }>
564
+ /** The person confirms in the vault; rejects with code `cancelled` if they do not. */
565
+ signOut(): Promise<{ signedIn: false }>
566
+ whoami(): Promise<{ signedIn: boolean; email?: string; keyId?: string }>
567
+ /** Forget a Space on this device. With account backup enabled the removal syncs to every device. The person confirms in the vault; rejects
568
+ * with code `cancelled` if they do not. */
569
+ forget(space: Space | string): Promise<{ forgotten: boolean }>
570
+ on(event: 'rooms', cb: (e: { rooms: VaultRoom[] }) => void): () => void
571
+ on(event: 'joined', cb: (e: { room: string }) => void): () => void
572
+ on(event: 'signedIn', cb: (e: { email: string }) => void): () => void
573
+ on(event: 'signedOut', cb: (e: object) => void): () => void
574
+ /** This device was signed out of the account (or the account was deleted) from another device: the vault forgot the account, its
575
+ * sign-in and its Spaces here, and `info.signedIn` is false. `reason: 'erased'`: the account was deleted. */
576
+ on(event: 'accountSignedOut', cb: (e: { reason?: 'erased' | 'moved' }) => void): () => void
577
+ /** The vault's account view changed (the backup, the account index): what wb.backup / wb.account read. */
578
+ on(event: 'account', cb: (e: { view: Record<string, unknown> }) => void): () => void
579
+ /** A renewed session: its new key's public id (space.isMine). */
580
+ on(event: 'session', cb: (e: { keyId: string }) => void): () => void
581
+ /** The vault's lock changed (startVault({ lock: true })): whether this device can lock, whether it is on, whether stored data is sealed. */
582
+ on(event: 'lock', cb: (e: { lock: { available: boolean, on: boolean, protect: boolean } }) => void): () => void
583
+ /** The vault's notifications changed (startVault({ push: true })). */
584
+ on(event: 'push', cb: (e: { push: { available: boolean, on: boolean } }) => void): () => void
585
+ /** A notification was tapped: open this Space. */
586
+ on(event: 'notifOpen', cb: (e: { room: string }) => void): () => void
587
+ }
588
+
589
+ /** `wb.protect` — device storage protection: what the app keeps on the device, sealed under a key a platform passkey
590
+ * derives (PRF or largeBlob), nowhere on disk. Off until enable(); seal/open/save/load pass values through while off. */
591
+ export interface ProtectState { on: boolean; locked: boolean; mode: 'prf' | 'largeblob' | null; auto: number }
592
+ /** Its Storage (localStorage by default), its config key, and the passkey's site (this page's host by default). */
593
+ export interface ProtectOptions { storage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>; storeKey?: string; rpId?: string; rpName?: string }
594
+ /** Usable before a client exists: `new Protect()` → unlock → load → `new Witbitz({ protect, session, backup })`. */
595
+ /** What `admin.customers.erase({ email })` needs from the user's devices (docs: § Erasing a user who has left). Every room
596
+ * the SDK creates carries a deletion commitment, every room it opens gets the account's membership mark, and the
597
+ * account's delete list is filed — sealed to Witbitz's attested enclave, for your tenant — automatically after a room is
598
+ * created or opened. Needs `new Witbitz({ tenant })`, a sign-in and `wb.backup` (the key every device of the account shares). */
599
+ export interface BuildEntry { kernel: string; payload?: string; policy?: string; at: number }
600
+ export interface BuildsState { builds: BuildEntry[]; auto?: { on: boolean; at: number } }
601
+ export interface BuildVerdict { ok: boolean; reason?: 'no_attestation' | 'no_platform_claim' | 'kernel' | 'payload' | 'policy' | 'unknown' | 'not_accepted'; live?: { kernel: string; payload?: string; policy?: string } }
602
+ /** `wb.builds` — which enclave build THIS PERSON accepts. In 'mine' mode a confidential room's key is sealed only to a build Witbitz
603
+ * publishes AND that is on their list: the first one is accepted on first use; with `automatic` on (the default) every published
604
+ * build is; off, a new one blocks their confidential rooms (`enclave_not_accepted`, `error.verdict`) until `accept(room)`. */
605
+ export interface Builds {
606
+ readonly mode: 'published' | 'mine'
607
+ /** JSON-safe — persist it for a page without an account; `onState` hands each change. */
608
+ readonly state: BuildsState
609
+ onState: ((state: BuildsState) => void) | null
610
+ list(): BuildEntry[]
611
+ /** Accept new Witbitz builds automatically? On unless the person turned it off. For the account (every device). */
612
+ readonly automatic: boolean
613
+ setAutomatic(on: boolean): Promise<boolean>
614
+ /** Does this person accept the enclave serving `room`? null before it attested. In a vault it throws `vault_unsupported`:
615
+ * the vault meets the enclave and seals the keys, the page never does. */
616
+ verdict(room: string): BuildVerdict | null
617
+ /** Accept the build serving `room` (its region's enclave): `not_published` for a build Witbitz does not publish. */
618
+ accept(room: string): Promise<BuildEntry[]>
619
+ /** Read the account's list now (it is read by itself before the first seal). */
620
+ sync(): Promise<BuildEntry[]>
621
+ }
622
+ export interface Erasure {
623
+ /** True when this page can file: a tenant app, a live sign-in and an enabled backup. */
624
+ readonly available: boolean
625
+ /** File the list now (after a sign-in or a backup restore); an unchanged list is skipped unless `force`. */
626
+ file(opts?: { force?: boolean }): Promise<{ filed: boolean; rooms?: number; skipped?: string }>
627
+ /** Is a list filed for this account in this app, and how many rooms — never the secrets. */
628
+ status(): Promise<{ ok?: boolean; filed: boolean; rooms?: number; updated?: number }>
629
+ /** DELETE MY ACCOUNT, from your page — the Witbitz app's own: rooms only this person used are deleted, shared ones left; the
630
+ * username and directory entry, the filed list, the backup, the account index; then this client forgets the account.
631
+ * Needs a live sign-in and the backup. `names`: the display names they post under in your app. In a vault, its own screens confirm and run deletion.
632
+ * A backup with an email gate (`wb.backup.gated`) needs its emailed code FIRST, before anything is deleted: with the recovery
633
+ * `code` it mails one and rejects `email_code_required` (with `ticket`); call again with `{ code, ticket, emailCode }`.
634
+ * No `code`: `code_required`; a wrong emailed code: `email_code_wrong`. */
635
+ deleteAccount(opts?: { onStep?: (text: string) => void; names?: string[]; code?: string; ticket?: string; emailCode?: string; getCode?: (address: string) => Promise<string> }): Promise<{ deleted: string[]; left: string[]; lapsing: string[]; failed: Array<{ room?: string; what?: string; why: string }>; account: { username?: boolean; directory?: boolean; backup?: boolean } }>
636
+ }
637
+ export declare class Protect {
638
+ constructor(opts?: ProtectOptions)
639
+ readonly state: ProtectState
640
+ /** Can this browser hold a protection passkey (WebAuthn in a secure context)? */
641
+ available(): boolean
642
+ /** One passkey; everything already saved through save() is sealed in place. Refuses `backup_required` while wb.backup is
643
+ * off — a lost passkey loses what it sealed — unless `withoutBackup: true`. */
644
+ enable(opts?: { label?: string; withoutBackup?: boolean }): Promise<ProtectState>
645
+ /** A user-verified passkey assertion brings the key back. Throws `wrong_passkey` for one that opens nothing here. */
646
+ unlock(): Promise<ProtectState>
647
+ /** Drop the key from memory: loads refuse `locked` until unlock(). */
648
+ lock(): ProtectState
649
+ /** Write what save() wrote back in the clear and forget the protection (asks the passkey when locked). */
650
+ disable(): Promise<ProtectState>
651
+ seal<T>(value: T): Promise<T | { v: 1; s: string }>
652
+ open<T = unknown>(stored: unknown): Promise<T>
653
+ save(name: string, value: unknown): Promise<void>
654
+ load<T = unknown>(name: string): Promise<T | undefined>
655
+ remove(name: string): void
656
+ /** Lock when the page returns after being hidden longer than this (0 = only lock() or a new launch). */
657
+ autoLock(minutes: number): ProtectState
658
+ on(event: 'locked' | 'unlocked' | 'change', cb: (state: ProtectState) => void): () => void
659
+ }
660
+
661
+ /** `wb.backup` — the account backup (a recovery code wraps a master secret; the record is sealed in the vault). */
662
+ export interface VaultAccountBackup extends Omit<AccountBackup, 'enable' | 'restore' | 'rooms' | 'protectRecoveryEmail' | 'save' | 'beginEmailMove' | 'finishEmailMove' | 'cancelPendingEmailMove'> {
663
+ beginEmailMove(): Promise<{ ready_at: number; expires: number }>
664
+ finishEmailMove(): Promise<{ enabled: true }>
665
+ cancelPendingEmailMove(): Promise<{ cancelled: true }>
666
+ save(): Promise<{ rooms: number }>
667
+ readonly rooms: VaultAccountIndex['rooms']
668
+ protectRecoveryEmail(): Promise<{ enrolled: true }>
669
+ enable(): Promise<{ enabled: true }>
670
+ restore(): Promise<{ rooms: VaultAccountIndex['rooms'] }>
671
+ }
672
+ export interface AccountBackup {
673
+ readonly enabled: boolean
674
+ /** True when enable() recorded an email: a restore, and deleting the account, then need its emailed code as well. */
675
+ readonly gated: boolean
676
+ /** JSON-safe state to persist (it holds the master secret), or null. */
677
+ readonly state: unknown
678
+ /** 'account' (the Spaces app's record format — every new backup) or 'legacy' (this SDK's original); null when not enabled. */
679
+ readonly format: 'account' | 'legacy' | null
680
+ /** Where the account is kept: 'account' (the Witbitz account service — a new account in a vault that names its tenant),
681
+ * 'legacy' (the backup store every account used before), null when there is none on this client. */
682
+ readonly service: 'account' | 'legacy' | null
683
+ readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; archived?: boolean; pinned?: boolean }>
684
+ onState: ((state: unknown) => void) | null
685
+ enable(opts?: { email?: string }): Promise<{ code: string }>
686
+ restore(opts: { code: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: AccountBackup['rooms'] }>
687
+ save(verification?: { code?: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: number }>
688
+ /** Rewrite a legacy backup in the account format — same code and rooms; an older SDK can then no longer restore it. */
689
+ upgrade(): Promise<{ format: 'account' }>
690
+ /** Record a room in the backup (createSpace / openSpace do this for you). */
691
+ add(spaceOrLane: Space, opts?: { label?: string }): this
692
+ keyFor(room: string): string | null
693
+ /** The account's invite key for this app, kept with the rooms (wb.invite hands it over; a restore gives it back). */
694
+ readonly invite: InviteAccount['state']
695
+ /** In a vault it throws `vault_unsupported` (the vault keeps the invite key and the backup; `invite` reads null). */
696
+ setInvite(state: unknown): this
697
+ /** In a vault: a promise of the same (the vault's answer, or its refusal). */
698
+ remove(room: string): this | Promise<this>
699
+ /** Enroll email protection for an existing legacy recovery code. */
700
+ protectRecoveryEmail(opts: { code: string }): Promise<{ enrolled: true }>
701
+ manageSecurityKeys(): Promise<{ closed: true }>
702
+ /** Sign the other devices out of this account. */
703
+ signOutOthers(): Promise<{ ok: true }>
704
+ /** Request a new, empty account on this device. Dates are Unix seconds. */
705
+ beginEmailMove(opts: { email?: string; getCode: () => Promise<string> }): Promise<{ ready_at: number; expires: number }>
706
+ pendingEmailMove(): Promise<{ ready_at: number; expires: number } | null>
707
+ finishEmailMove(opts: { getCode: () => Promise<string>; showCode: (code: string) => Promise<void> }): Promise<{ enabled: true }>
708
+ cancelPendingEmailMove(opts: { getCode: () => Promise<string> }): Promise<{ cancelled: true }>
709
+ /** The existing account’s view of a pending move. */
710
+ emailMove(): Promise<{ reset: string; ready_at: number; expires: number; objected?: boolean } | null>
711
+ /** Move a legacy account in a tenant-configured builder vault. The vault confirms the move.
712
+ * Eligible devices can rejoin a signed move. An emailed-code move signs other devices out. */
713
+ migrate(opts?: { silent?: boolean; code?: string; getCode?: () => Promise<string> }): Promise<{ migrated: true; trust: string | null }>
714
+ requestMoveTime(): Promise<{ reset: string; ready_at: number; expires: number; objected?: boolean }>
715
+ cancelEmailMove(opts?: { getCode?: () => Promise<string> }): Promise<{ cancelled: true }>
716
+ /** A new recovery code, shown once in the vault; the old one stops working and every other device is signed out. */
717
+ newRecoveryCode(): Promise<{ ok: true }>
718
+ /** Delete the account and its backup (account service or legacy store). The vault asks for the required proof on its own screens and forgets the
719
+ * account as a sign-out does — its Spaces, its sign-in — and the page hears `accountSignedOut` with `reason: 'erased'`. */
720
+ deleteAccount(): Promise<{ deleted: boolean; report?: Awaited<ReturnType<Erasure['deleteAccount']>> }>
721
+ }
722
+
723
+ /** `wb.account` — the account's live index across devices (sdk-accounts.md#account-index). */
724
+ export interface AccountIndex {
725
+ readonly enabled: boolean
726
+ readonly deviceId: string
727
+ readonly rooms: AccountBackup['rooms']
728
+ /** `sdk`: the SDK release a device last synced with (3.24.0 and later; an older device has none). */
729
+ readonly devices: Array<{ id: string; name: string; seenAt: number; signedOut: boolean; current: boolean; sdk?: string }>
730
+ readonly links: Array<{ a: string; b: string; cap?: number }>
731
+ /** Called after a sync changed the index. */
732
+ onChange: ((index: Pick<AccountIndex, 'rooms' | 'devices'>) => void) | null
733
+ /** Called when another device signed THIS one out (it has dropped the account). */
734
+ /** This device was signed out of the account by another device; `reason: 'erased'` when the account was deleted. */
735
+ onSignedOut: ((e?: { reason?: 'erased' | 'moved' }) => void) | null
736
+ /** The last background sync's error, or null. */
737
+ lastError: Error | null
738
+ archive(room: string, on?: boolean): this
739
+ pin(room: string, on?: boolean): this
740
+ rename(room: string, label: string): this
741
+ forget(room: string): this
742
+ /** `reason: 'erased'`: the account was deleted — that device's `onSignedOut` hears `{ reason: 'erased' }`. */
743
+ repairNames(): Promise<number>
744
+ previewEmptySpaces(options?: { detailed?: false }): Promise<Array<{ room: string; title: string }>>
745
+ previewEmptySpaces(options: { detailed: true }): Promise<{ rooms: Array<{ room: string; title: string }>; unreadable: number }>
746
+ removeEmptySpaces(options: { rooms: string[]; confirm: true }): Promise<{ removed: number; forgottenOnly: number; kept: Array<{ title: string; why: string }> }>
747
+ listDevices(): Promise<Array<AccountIndex['devices'][number] & { spk: string | null; state?: string; addedAt?: number }>>
748
+ signOutDevice(deviceId: string, opts?: { getCode?: (address: string) => Promise<string> }): Promise<{ revoked: boolean }>
749
+ signOut(deviceId: string, opts?: { reason?: 'erased' | 'moved' }): this
750
+ /** `signedOut: true` (and empty lists) when another device signed this one out. */
751
+ sync(): Promise<{ ok: boolean; rooms: AccountBackup['rooms']; devices: AccountIndex['devices']; signedOut?: boolean }>
752
+ start(opts?: { every?: number }): this
753
+ stop(): this
754
+ /** What this account's turns cost in a month (UTC, default this one), across its rooms, whoever paid — folded from the
755
+ * receipts every turn carries (docs: #account-usage). Amounts in micro-dollars; `costUsd` in dollars. */
756
+ 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> }>
757
+ /** Optional sections (3.24.0), kept as the Spaces app keeps them: nothing is read until you use one (sdk-accounts.md#account-sections). */
758
+ readonly contacts: AccountContacts
759
+ readonly name: AccountSection<string>
760
+ readonly roomDefaults: AccountSection<RoomDefaults | null, Partial<RoomDefaults>>
761
+ /** The people this account blocked, as the Spaces app keeps them (sdk-people.md#block). */
762
+ readonly blocks: AccountBlocks
763
+ /** Display-lock metadata, shared with the app. Build PIN/display UI with chatLock.js; this does not isolate data. */
764
+ readonly chatLocks: {
765
+ readonly value: Record<string, unknown> | null
766
+ get(): Promise<Record<string, unknown> | null>
767
+ merge(doc: Record<string, unknown>): Promise<Record<string, unknown> | null>
768
+ /** Display controls only. A Code target is '<computerId>/<sessionId>'. Raw PINs are never stored. */
769
+ set(lock: { kind: 'room' | 'code'; target: string; pin: string; title?: string }): Promise<Record<string, unknown> | null>
770
+ remove(lock: { lockId: string }): Promise<Record<string, unknown> | null>
771
+ changePin(lock: { lockId: string; pin: string; newPin: string }): Promise<Record<string, unknown> | null>
772
+ /** Uses the app's synced wrong-PIN backoff. Does not isolate or encrypt room data. */
773
+ check(attempt: { lockId: string; pin: string }): Promise<{ ok: boolean; next: number }>
774
+ on(ev: 'change', fn: (doc: Record<string, unknown> | null) => void): unknown
775
+ off(ev: 'change', fn: Function): unknown
776
+ }
777
+ }
778
+
779
+ /** A person, by what proves who they are: the verified email, the @username, or the key that signed in one Space. */
780
+ export interface BlockWho { email?: string; user?: string; room?: string; sid?: string }
781
+ export type ReportReason = 'harassment' | 'threats' | 'sexual' | 'hate' | 'spam' | 'other'
782
+ /** `wb.account.blocks` — the app's Block list. Errors as AccountSection's. */
783
+ export interface AccountBlocks {
784
+ /** The people blocked, as this device last read (null before the first read). */
785
+ readonly value: Array<BlockWho & { name: string; at: number }> | null
786
+ get(): Promise<Array<BlockWho & { name: string; at: number }>>
787
+ /** Block them on every device of the account (`space.blockIdentity(message)`, plus a `name` to show). */
788
+ block(who: BlockWho & { name?: string }): Promise<Array<BlockWho & { name: string; at: number }>>
789
+ /** Unblock: every entry naming them by any proof goes (kept as a tombstone). */
790
+ unblock(who: BlockWho): Promise<Array<BlockWho & { name: string; at: number }>>
791
+ merge(list: Array<BlockWho & { name?: string; at?: number; gone?: boolean }>): Promise<Array<BlockWho & { name: string; at: number }>>
792
+ /** Is this writer blocked (any one shared proof)? Over what was last read, or over `list` — one you keep yourself. */
793
+ has(who: BlockWho | null, list?: Array<BlockWho & { at?: number; gone?: boolean }>): boolean
794
+ on(ev: 'change', fn: (value: Array<BlockWho & { name: string; at: number }>) => void): this
795
+ off(ev: 'change', fn: (value: Array<BlockWho & { name: string; at: number }>) => void): this
796
+ }
797
+
798
+ /** One optional account section. Errors: `not_enabled`, `unreadable` / `unopenable` (nothing written), `save_failed`, `invalid_argument`. */
799
+ export interface AccountSection<T, P = T> {
800
+ /** What this device last read; null before the first read. */
801
+ readonly value: T | null
802
+ get(): Promise<T>
803
+ set(value: P): Promise<T>
804
+ /** 'change': another device changed it (seen at an account sync — the stream or the minute poll). */
805
+ on(ev: 'change', fn: (value: T) => void): this
806
+ off(ev: 'change', fn: (value: T) => void): this
807
+ }
808
+ /** A person ({ email and/or username }) or a saved assistant ({ kind: 'agent', id, fn }) — the Spaces app's address book row. */
809
+ export interface AccountContact { kind: 'person' | 'agent'; fn: string; email?: string; username?: string; tel?: string; handle?: string; id?: string; persona?: string; agentName?: string; model?: string; color?: string; at?: number }
810
+ export interface AccountContacts extends AccountSection<AccountContact[], Partial<AccountContact>> {
811
+ remove(contact: Partial<AccountContact>): Promise<AccountContact[]>
812
+ /** Fold in a list as the app does on a sync or a restore: each row by its own `at`. */
813
+ merge(list: Array<Partial<AccountContact>>): Promise<AccountContact[]>
814
+ }
815
+ /** The New-Space defaults (the app's Settings → Default room). */
816
+ /** The account's New Space defaults, shared with the Spaces app. `verified` is kept for older apps only: today's app makes every new
817
+ * Space verified and ignores it. */
818
+ export interface RoomDefaults { quick?: boolean; enclave?: boolean; verified?: boolean; lanes?: boolean; temporary?: boolean; assistant?: string; model?: string }
819
+
820
+ /** What a member change in place answers. `unreachable`: members with no invite key for THIS app (they never signed in here) —
821
+ * send them `link`. */
822
+ export interface MemberChange { inPlace: true; epoch: number; link?: string; unreachable: string[] }
823
+
824
+ /** `wb.invite` — this account's invite key for this app (sdk-people.md#members): published at sign-in under the app's own directory scope;
825
+ * a member change seals a Space's new key to it. Persist `state` (a private key) and hand it back as `new Witbitz({ invite })`. */
826
+ export interface InviteAccount {
827
+ readonly state: { boxPub: unknown; boxPriv: unknown; inbox: string; handle?: string; scope?: string; email?: string } | null
828
+ /** 'none' | 'held' | 'enrolled' | 'held_elsewhere' (another device of this account holds the published key — restore its state) | 'failed' | 'vault' (vault mode: the vault keeps and publishes it) */
829
+ readonly status: 'none' | 'held' | 'enrolled' | 'held_elsewhere' | 'failed' | 'vault'
830
+ restore(state: unknown): this
831
+ /** Publish it (signIn and refreshSession do). → the status */
832
+ enroll(): Promise<InviteAccount['status']>
833
+ }
834
+
835
+ /** `wb.a2a` — the account's A2A record. Persist `state` (it holds the lanes' inbox private keys). */
836
+ export interface A2AAccount {
837
+ readonly state: unknown
838
+ readonly endpoint: string
839
+ onState: ((state: unknown) => void) | null
840
+ restore(state: unknown): this
841
+ status(): Promise<unknown>
842
+ revoke(): Promise<unknown>
843
+ }
844
+
845
+ export interface Connection { id: string; label: string; host: string; /** absent in a vault: the vault keeps it (grant by id) */ callKey?: string; account?: string; /** a webhook: its one path (docs/signed-webhooks.md) */ webhook?: string; /** an agent that takes jobs: where the job goes and the fixed headers (outside-agents.md) */ job?: { field: string; headers: Record<string, string> }; /** an MCP server (attachMcp / finishMcp): granting it brings its tools */ mcp?: boolean }
846
+ /** `wb.connections` — credentials the standing Sentinel holds and spends for the account. */
847
+ export interface Connections {
848
+ /** Public picker data shared with the app. Use category 'Agents' for outside agents; no credentials are returned. */
849
+ catalog(opts?: { category?: string }): Array<{ name: string; kind: string; desc: string; cat: string; url?: string; host?: string; registered?: boolean; [k: string]: unknown }>
850
+ spacesUsing(id: string): Promise<{ rooms: string[]; unreadable: string[]; incomplete: boolean }>
851
+ discover(query?: string, options?: { category?: string }): { services: Array<{ name: string; kind: string; desc: string; cat: string; url?: string; host?: string; registered?: boolean; [k: string]: unknown }>; address: string | null; alternatives: Array<'mcp' | 'apiKey'> }
852
+ /** `webhook: true` + `host` = the whole https trigger address: a one-path, POST-only, Bearer connection; `job` makes it an agent that takes jobs. */
853
+ attach(opts: { label?: string; host: string; secret: string; rules?: unknown; limits?: unknown; webhook?: boolean; job?: { field?: string; headers?: Record<string, string> } }): Promise<Connection>
854
+ /** What the Sentinel holds for the account — never a secret. In a vault each also says `grantable`: whether this vault
855
+ * holds its callKey (attached here, or kept from another device with the backup on); `grant` refuses the rest (`not_in_vault`). */
856
+ list(): Promise<Array<{ id: string; label: string; host: string; grantable?: boolean; [k: string]: unknown }>>
857
+ /** Detach everywhere. `spaces`: the Space handles you granted it to — it is dropped from each one's settings too. */
858
+ detach(id: string, opts?: { spaces?: Space[] }): Promise<{ removedFrom: number } & Record<string, unknown>>
859
+ /** Lock the connections the Sentinel still holds in its old form (attached before 2026-11-16, unspent since) under their
860
+ * callKeys — pass the keys your app keeps, as `attach` returned them. No call reaches the service. Refused in a vault: the
861
+ * vault locks what it holds itself when it lists. */
862
+ lock(keys: Record<string, string>): Promise<{ locked: number; failed: number; skipped: number }>
863
+ startConnect(opts: { tenant?: string; providerId: string }): Promise<{ authUrl: string; state: string }>
864
+ finishConnect(opts: { state: string; code: string; label?: string; host?: string }): Promise<Connection>
865
+ /** An MCP server: does it want a sign-in? `needsSignIn: false` → `attachMcp`; else open `authUrl` — `redirectUri` (default
866
+ * `<your origin>/mcp-callback`) receives `?code=&state=` → `finishMcp`. Opens nothing. */
867
+ startMcp(opts: { url: string; label?: string; redirectUri?: string }): Promise<{ needsSignIn: false; host: string } | { needsSignIn: true; authUrl: string; state: string; host: string }>
868
+ /** An MCP server with no sign-in, or with a token you hold (sealed to the Sentinel). */
869
+ attachMcp(opts: { url: string; label?: string; token?: string }): Promise<Connection>
870
+ /** Finish an MCP server's sign-in with your callback's `state` and `code`. */
871
+ finishMcp(opts: { state: string; code: string; label?: string; host?: string }): Promise<Connection>
872
+ /** The tools an MCP connection offers. */
873
+ mcpTools(id: string): Promise<{ tools: Array<{ name: string; title?: string; description?: string; readOnly?: boolean; [k: string]: unknown }>; server: unknown; truncated: boolean }>
874
+ }
875
+
876
+ /** A cloud computer as `wb.computers.list()` shows it — never a secret. */
877
+ export interface ComputerInfo { id: string; name: string; cloud: true; version: number; egress: 'none' | 'trusted' | 'custom' | 'full' | string }
878
+ /** `wb.computers` — the person's cloud computers (docs: § Cloud computers). Kept sealed in this app's account; opened with the
879
+ * same checks as the Witbitz app's Code section; their hours charge the person's AWS key. Not available in vault mode yet
880
+ * (`vault_mode`). Errors carry `code`: not_enabled, sign_in_required, not_found, keys_refused, aws_limit, attestation, declined. */
881
+ export interface Computers {
882
+ list(): Promise<ComputerInfo[]>
883
+ /** Model keys come from the account (capped) unless `keys` brings the person's own. */
884
+ create(opts?: { name?: string; keys?: { trustedRouter: string; tinfoil?: string; github?: string }; egress?: { mode: string; hosts?: string[] }; browsePrivate?: boolean }): Promise<ComputerInfo>
885
+ /** Start or wake it, check it runs the published Witbitz image (a NEW published image: 'auto' accepts it, 'ask' calls
886
+ * `onNewImage(pcr0, role)`), hand it the person's keys sealed, connect. */
887
+ open(id: string, opts?: { onStep?(step: 'requesting' | 'starting' | 'verifying' | 'opening' | 'connecting' | string): void; images?: 'auto' | 'ask'; onNewImage?(pcr0: string, role: 'cloud-computer' | 'sentinel'): boolean | Promise<boolean> }): Promise<Computer>
888
+ /** Closed, its account keys cancelled, then removed from the account. */
889
+ remove(id: string): Promise<void>
890
+ /** This month on the person's AWS key (dollars; show credits: 100 = $1), or null before the first opening. */
891
+ usage(): Promise<{ live: boolean; tier?: 'full' | 'free'; month?: { usd: number; capUsd: number; byKind: Record<string, number> }; resetsAt?: string; why?: string } | null>
892
+ }
893
+ /** One open cloud computer. Every call goes through its connector, which serves only the Code section's own routes. */
894
+ /** Which folder's project a computer call is about: a session's (`session`) or a folder (`dir`). The server scopes by folder. */
895
+ export interface CodePromptOptions {
896
+ model?: string; agent?: string; effort?: string
897
+ files?: Array<{ name?: string; mime?: string; url?: string; path?: string }>
898
+ }
899
+ export interface ComputerScope { session?: string; dir?: string }
900
+
901
+ export interface Computer {
902
+ readonly id: string
903
+ readonly name: string
904
+ readonly status: 'online' | 'connecting' | 'offline'
905
+ readonly sessions: {
906
+ list(): Promise<unknown[]>
907
+ create(opts?: { dir?: string; title?: string }): Promise<{ id: string; [k: string]: unknown }>
908
+ messages(sessionId: string, opts?: { limit?: number }): Promise<unknown[]>
909
+ /** `model`: 'provider/model', e.g. 'trustedrouter/deepseek/deepseek-v4-flash'. */
910
+ prompt(sessionId: string, text: string, opts?: CodePromptOptions): Promise<unknown>
911
+ archive(sessionId: string, archived?: boolean): Promise<unknown>
912
+ undo(sessionId: string): Promise<{ changed: boolean; files: boolean }>
913
+ redo(sessionId: string): Promise<{ changed: boolean; files: boolean }>
914
+ compact(sessionId: string, model: string): Promise<unknown>
915
+ models(sessionId: string): Promise<Array<{ ref: string; label: string; efforts: string[] }>>
916
+ commands(sessionId: string): Promise<Array<{ name: string; description: string; source: string; template: string; agent: string; model: string; needsComputer: boolean }>>
917
+ runCommand(sessionId: string, text: string, opts?: CodePromptOptions): Promise<unknown>
918
+ setApprovalMode(sessionId: string, mode: 'manual' | 'accept' | 'plan' | 'auto'): Promise<{ mode: string }>
919
+ abort(sessionId: string): Promise<unknown>
920
+ rename(sessionId: string, title: string): Promise<unknown>
921
+ remove(sessionId: string): Promise<unknown>
922
+ todo(sessionId: string): Promise<unknown>
923
+ /** { <session id>: status } of every folder the sessions live in, or of one (`session` / `dir`). */
924
+ status(opts?: ComputerScope): Promise<Record<string, unknown>>
925
+ }
926
+ readonly approvals: {
927
+ /** Every approval waiting, in every folder the sessions live in — or in one (`session` / `dir`). */
928
+ pending(opts?: ComputerScope): Promise<unknown[]>
929
+ /** A 'reject' may carry a `message` for the model ("stop and ask me"); otherwise the approval's `session` is needed. */
930
+ answer(id: string, response: 'once' | 'always' | 'reject', opts?: { session?: string; message?: string }): Promise<unknown>
931
+ }
932
+ /** `opts`: the folder the question is in (`session` — the event's sessionID — or `dir`); neither = the computer's default project. */
933
+ readonly questions: { pending(opts?: ComputerScope): Promise<unknown[]>; answer(id: string, answers: string[][], opts?: ComputerScope): Promise<unknown>; dismiss(id: string, opts?: ComputerScope): Promise<unknown> }
934
+ readonly files: {
935
+ mkdir(sessionId: string, relativeParent: string, name: string): Promise<unknown>
936
+ /** In a session's folder (`session`) or `dir`; neither = the computer's default project. */
937
+ list(path?: string, opts?: ComputerScope): Promise<unknown>; changes(opts?: ComputerScope): Promise<unknown>; diff(opts?: ComputerScope): Promise<unknown>
938
+ /** A file of the session's folder (at most 20 MB, nothing that looks like a secret). Rejects `not_supported` on an older connector. */
939
+ download(sessionId: string, path: string): Promise<{ name: string; kind?: string; mime: string; size: number; mtime?: number; b64: string }>
940
+ /** Into folder `dir` (absolute). A name already there: `onExists` 'fail' (rejects `exists`), 'replace' or 'keepBoth' ("name (2).ext"). */
941
+ upload(sessionId: string, file: { dir: string; name: string; data: Blob | ArrayBuffer | Uint8Array | string; onExists?: 'fail' | 'replace' | 'keepBoth' }): Promise<{ ok: boolean; name: string; path: string; size: number }>
942
+ /** A file a reply produced (`computer.outputs`), screenshots included. */
943
+ output(sessionId: string, path: string): Promise<{ name: string; mime: string; size?: number; b64: string }>
944
+ }
945
+ readonly browser: {
946
+ /** Session-scoped viewer, including its private-browser control. The key stays in the URL fragment. */
947
+ url(opts?: { session?: string; take?: boolean }): string | null
948
+ status(): unknown
949
+ /** Is the agent's browser in private mode (nothing it visits is kept)? */
950
+ readonly private: boolean
951
+ /** Where the computer offers it (`status().canPrivate`); otherwise throws `not_supported`. The next report confirms it. */
952
+ setPrivate(on: boolean): true
953
+ /** Set privacy for one session using the encrypted owner channel; waits for confirmation, or rejects with unknown state on timeout. */
954
+ setSessionPrivate(session: string, on: boolean): Promise<true>
955
+ }
956
+ /** What a reply produced: files it wrote, the browser's screenshots, files its answer names that changed. `messages` omitted = the latest reply. */
957
+ outputs(sessionId: string, messages?: unknown[]): Promise<Array<{ path: string; kind: 'pdf' | 'image' | 'table' | 'text' | 'file'; source: 'wrote' | 'shot' | 'named' }>>
958
+ readonly egress: { get(): unknown }
959
+ /** Live events (OpenCode's): a type such as 'message.part.updated', 'permission.asked', 'session.idle', or '*'. → off
960
+ * The computer streams per FOLDER: `{ session }` (its folder is looked up) or `{ dir }`; none = the default folder only. */
961
+ on(type: string, fn: (event: { type: string; properties?: unknown; [k: string]: unknown }) => void, opts?: { session?: string; dir?: string }): () => void
962
+ /** A last save, then it stops — its hours stop counting. */
963
+ close(): Promise<boolean>
964
+ }
965
+
966
+ /** `wb.siri` — the account's Siri inbox. Persist `state` (it holds the inbox private keys). */
967
+ export interface SiriAccount {
968
+ readonly state: unknown
969
+ readonly shortcut: { key: string | null; endpoint: string }
970
+ restore(state: unknown): this
971
+ status(): Promise<unknown>
972
+ /** In a vault: resolves `null` — the new key is shown in the vault's own screen (wb.vault.showSiriKey). */
973
+ rotateKey(): Promise<string | null>
974
+ revoke(): Promise<unknown>
975
+ }
976
+
977
+ /** `wb.usernames` — the signed-in member's global @username. */
978
+ export interface Usernames {
979
+ /** → `{ username }`; whether it is listed in the directory: `mine()`. */
980
+ claim(name: string, opts?: { publish?: boolean; name?: string }): Promise<{ username: string }>
981
+ release(): Promise<unknown>
982
+ mine(): Promise<{ username: string | null; published?: boolean }>
983
+ resolve(name: string): Promise<{ username: string; exists: boolean }>
984
+ }
985
+
986
+ /** wb.speech (sdk-assistant.md#speak). `play` rejects with `no_hebrew`, `empty`, `sign_in_required`, `tts_rate_limited`, `tts_unavailable`, `http_<n>`, `audio`, `play`. */
987
+ export interface Speech {
988
+ readonly playing: boolean
989
+ play(text: string): Promise<void>
990
+ stop(): void
991
+ }
992
+ export interface Dictation {
993
+ readonly listening: boolean
994
+ start(opts?: { room?: string; onPartial?(t: string): void; onLevel?(rms: number): void }): Promise<void>
995
+ stopCertified(): Promise<DictationResult>
996
+ stop(): Promise<string>
997
+ cancel(): void
998
+ close(): void
999
+ }
1000
+
1001
+ import type { Origins, DeclaredHosts, Providers, TenantRooms, Customers, Billing } from './witbitz-admin'
1002
+
1003
+ export type VaultAccountIndex = Omit<AccountIndex, 'rooms' | 'onChange' | 'archive' | 'pin' | 'rename' | 'forget' | 'signOut' | 'sync' | 'start' | 'stop'> & {
1004
+ readonly rooms: ReadonlyArray<Omit<AccountBackup['rooms'][number], 'link'>>
1005
+ onChange: ((index: Pick<VaultAccountIndex, 'rooms' | 'devices'>) => void) | null
1006
+ archive(room: string, on?: boolean): Promise<object>
1007
+ pin(room: string, on?: boolean): Promise<object>
1008
+ rename(room: string, label: string): Promise<object>
1009
+ forget(room: string): Promise<object>
1010
+ signOut(deviceId: string): Promise<{ revoked?: boolean; error?: string }>
1011
+ sync(): Promise<{ ok: boolean; rooms: VaultAccountIndex['rooms']; devices: AccountIndex['devices']; signedOut?: boolean }>
1012
+ start(opts?: { every?: number }): Promise<object>
1013
+ stop(): Promise<object>
1014
+ }
1015
+
1016
+ export declare class Witbitz {
1017
+ constructor(opts?: WitbitzOptions)
1018
+ /** VAULT MODE: this page is framed by a vault you host on another origin, which keeps every room key. Rejects
1019
+ * `not_in_vault` when the page is not framed by that origin. Create, read and send as usual; sign-in and sharing
1020
+ * happen in the vault (`wb.vault`). A link is opened by the vault, not by openSpace. Refuses by name a `session`
1021
+ * (`vault_signs_in`), `attest`, and a persisted `backup` / `siri` / `a2a` / `invite` state (`vault_unsupported`): the vault keeps the account. */
1022
+ static inVault(opts: WitbitzOptions & { vault: string }): Promise<Omit<Witbitz, 'account' | 'backup'> & { readonly account: VaultAccountIndex; readonly backup: VaultAccountBackup }>
1023
+ /** The vault this page runs in — set by {@link Witbitz.inVault}, else null. */
1024
+ readonly vault: VaultSession | null
1025
+ readonly session: Session | null
1026
+ readonly backup: AccountBackup
1027
+ /** Device storage protection for what the app keeps on the device (sdkProtect.js). */
1028
+ readonly protect: Protect
1029
+ readonly account: AccountIndex
1030
+ /** The tenant's erase of a user (`admin.customers.erase`) reaches the rooms this account created (sdkErase.js). */
1031
+ readonly erasure: Erasure
1032
+ /** Which enclave build this person accepts — `new Witbitz({ builds: 'mine' })`. */
1033
+ readonly builds: Builds
1034
+ readonly a2a: A2AAccount
1035
+ readonly invite: InviteAccount
1036
+ readonly connections: Connections
1037
+ readonly cloudDevice: {
1038
+ status(): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string; waiting?: string; last?: Record<string, unknown> }>; builds: unknown }>
1039
+ /** Sign the device into this app; getCode is asked only outside a vault. */
1040
+ enroll(opts?: { getCode?: () => Promise<string> }): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string }>; builds: unknown }>
1041
+ register(opts?: { getCode?: () => Promise<string> }): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string }>; builds: unknown }>
1042
+ setBuilds(state: { builds: unknown[]; auto?: { on: boolean; at: number } }): Promise<unknown>
1043
+ forget(): Promise<{ forgotten: true }>
1044
+ }
1045
+ /** The person's cloud computers (§ Cloud computers). */
1046
+ readonly computers: Computers
1047
+ readonly siri: SiriAccount
1048
+ readonly usernames: Usernames
1049
+ recreateSpace(bundle: { kind: string; entries: unknown[]; config?: Record<string, unknown>; tier?: Tier }, opts?: { tier?: Tier }): Promise<{ space: Space; carried: number; total: number; titleWarning?: string }>
1050
+ saveOfflineReader(): Promise<void>
1051
+ exportOfflineArchive(opts?: { recoveryKeys?: boolean; rooms?: Space[] }): Promise<{ saved: number; unavailable: string[] }>
1052
+ createSpace(opts: { /** @deprecated retired in 4.0.0 — `owner` rejects with `owner_rule_retired` */ owner?: never; 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; 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 }; /** 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>
1053
+ /** `link` is REQUIRED (a share link: `<viewer>/space?room=…#mk=…`); the current page URL is not read for you. */
1054
+ openSpace(link: string, opts?: { resume?: Snapshot; tier?: Tier }): Promise<Space>
1055
+ /** Reopen a member's lane (sdk-reference.md). In a vault `laneLink` is the lane's room id; `lane_space_gone` once its Space is forgotten. */
1056
+ /** Rejects with `lane_of_lane` when `space` is itself a lane (open the lane on its Space). */
1057
+ openLane(laneLink: string, opts: { space: Space; actions?: LaneAction[]; resume?: Snapshot; tier?: Tier; mirror?: boolean | { data?: boolean } }): Promise<Lane>
1058
+ signIn(opts: { email: string; code?: string; ticket?: string; room?: string }): Promise<{ ticket: string; email: string } | Session>
1059
+ refreshSession(): Promise<Session>
1060
+ signOut(): this
1061
+ useSession(session: Session | null): this
1062
+ useUserToken(token: string | (() => string | Promise<string>) | null): this
1063
+ models(opts?: { tier?: Tier }): Promise<Array<{ id: string; efforts?: Effort[] | null; [k: string]: unknown }>>
1064
+ dictation(): Dictation
1065
+ /** Text read aloud (sdk-assistant.md#speak) — the Spaces app's "Play aloud" player. */
1066
+ readonly speech: Speech
1067
+ /** Read `text` aloud → resolves when it has played. */
1068
+ speak(text: string): Promise<void>
1069
+ /** Feature detection: this SDK's version and features, the limits, the tiers and models this deployment serves. */
1070
+ capabilities(): Promise<{ sdk: string; endpoint: string; features: string[]; limits: Record<string, number>; tiers: { standard: true; enclave: boolean }; models: { regular: string[]; confidential: string[] } | null }>
1071
+ toJSON(): { viewer: string; tenant?: string; signedIn: boolean; tenantKey?: '[REDACTED]' }
1072
+ // ── Builder calls (server only). Deprecated here: use WitbitzAdmin (witbitz-admin.js); `users` is `customers` there.
1073
+ /** @deprecated use `new WitbitzAdmin(…).verifyTenantKey()` */
1074
+ verifyTenantKey(): Promise<{ ok: true; tenant: string } | { ok: false; reason: string; code?: string }>
1075
+ /** @deprecated use WitbitzAdmin */ readonly origins: Origins
1076
+ /** @deprecated use WitbitzAdmin */ readonly hosts: DeclaredHosts
1077
+ /** @deprecated use WitbitzAdmin */ readonly providers: Providers
1078
+ /** @deprecated use WitbitzAdmin */ readonly rooms: TenantRooms
1079
+ /** @deprecated use WitbitzAdmin's `customers` */ readonly users: Customers
1080
+ /** @deprecated use WitbitzAdmin */ readonly billing: Billing
1081
+ }
1082
+ export default Witbitz
1083
+
1084
+ // ─── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────
1085
+ export declare const LIMITS: Readonly<Record<string, number>>
1086
+ export declare const EFFORTS: readonly Effort[]
1087
+ /** 'dev' on the live build; the release number in /sdk/<version>/. */
1088
+ export declare const SDK_VERSION: string
1089
+ /** Throws `limit_exceeded` for a list of actions offered to one turn that the server would cut or drop. */
1090
+ export declare function checkActions(actions: LaneAction[]): void
1091
+ /** Throws `invalid_effort` when `model` names a reasoning effort the model does not take. `catalog` = wb.models(). */
1092
+ export declare function checkModelEffort(model: AgentSpec['model'], catalog?: Array<{ id: string; efforts?: Effort[] | null }>): void
1093
+ /** Throws `limit_exceeded` for a `data` schema the server would cut, drop or rename. */
1094
+ export declare function checkDataSchema(data: Record<string, unknown>): void
1095
+ /** Is this message a lane's copy of its shared room's line (`source: 'shared'` and an `sh:` id)? The app draws exactly these as "from the room". */
1096
+ export declare function isLaneCopy(m: Message | Record<string, unknown>): boolean
1097
+
1098
+ // AG-UI 1.0 (sdk-agents.md#ag-ui)
1099
+ 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>>
1100
+ export declare function aguiHistory(space: Space): unknown[]
1101
+ export declare function aguiAgent(lib: { AbstractAgent: unknown; Observable: unknown }, space: Space, opts?: { threadId?: string; agentConfig?: Record<string, unknown>; [k: string]: unknown }): unknown
1102
+
1103
+ // RATS / EAT (sdk-keys.md#eat)
1104
+ export declare const EAT_PROFILE: string
1105
+ export declare function verifyEat(token: string, opts?: { expectedPCRs?: Record<string, string> | null; nonce?: string | null; root?: unknown; now?: number; maxAgeMs?: number; key?: Uint8Array | null; profile?: string }): Promise<{ ok: true; claims: Record<string, unknown>; doc: unknown; userData: unknown; pinned: boolean }>
1106
+ export declare function fetchAndVerifyEat(eatUrl: string, opts?: { expectedPCRs?: Record<string, string> | null; fetchImpl?: typeof fetch; [k: string]: unknown }): Promise<{ ok: true; claims: Record<string, unknown>; doc: unknown; userData: unknown; pinned: boolean }>