@witbitz/sdk 0.0.0-stage → 4.4.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 (236) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -2
  3. package/a2aCore.js +221 -0
  4. package/a2aShared.js +27 -0
  5. package/accountErase.js +228 -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/agentDoorTools.js +28 -0
  23. package/attestedBox.js +30 -0
  24. package/attestedRooms.js +78 -0
  25. package/awsKey.js +98 -0
  26. package/backupRecord.js +106 -0
  27. package/backupVault.js +97 -0
  28. package/blocks.js +115 -0
  29. package/blocksPush.js +64 -0
  30. package/browseSeal.js +103 -0
  31. package/cbor.js +225 -0
  32. package/changePush.js +75 -0
  33. package/chatLock.js +165 -0
  34. package/chatLockSw.js +13 -0
  35. package/cloudDeviceBuilds.js +11 -0
  36. package/cloudDevicePins.js +33 -0
  37. package/cloudDeviceSeal.js +53 -0
  38. package/codeAttachments.js +100 -0
  39. package/codeBrowse.js +224 -0
  40. package/codeCache.js +149 -0
  41. package/codeCloud.js +650 -0
  42. package/codeCloudKeys.js +112 -0
  43. package/codeCommands.js +167 -0
  44. package/codeComputers.js +389 -0
  45. package/codeEgress.js +123 -0
  46. package/codeFilesRoutes.js +17 -0
  47. package/codeFolders.js +116 -0
  48. package/codeHistory.js +76 -0
  49. package/codeLanguage.js +54 -0
  50. package/codeMkdir.js +8 -0
  51. package/codeModes.js +59 -0
  52. package/codeOrphanKeys.js +42 -0
  53. package/codeOutputs.js +141 -0
  54. package/codeProgress.js +54 -0
  55. package/codeRelay.js +505 -0
  56. package/codeSent.js +68 -0
  57. package/codeSentinel.js +86 -0
  58. package/codeSubagents.js +107 -0
  59. package/codeTransport.js +317 -0
  60. package/codeUndo.js +48 -0
  61. package/compress.js +24 -0
  62. package/config.js +11 -0
  63. package/connCatalog.js +164 -0
  64. package/connDisp.js +76 -0
  65. package/connOtherWays.js +74 -0
  66. package/connPending.js +16 -0
  67. package/connWrap.js +53 -0
  68. package/connectionEntry.js +89 -0
  69. package/connections.js +561 -0
  70. package/credits.js +30 -0
  71. package/csAttest.js +112 -0
  72. package/decrypt.html +384 -0
  73. package/deviceAttest.js +527 -0
  74. package/deviceCall.js +54 -0
  75. package/deviceKeyCore.js +41 -0
  76. package/deviceSeal.js +59 -0
  77. package/e2ee.js +323 -0
  78. package/eat.js +103 -0
  79. package/emailFork.js +275 -0
  80. package/emailSignIn.js +81 -0
  81. package/emptySpaces.js +111 -0
  82. package/encSource.js +55 -0
  83. package/enclaveAccept.js +214 -0
  84. package/enclaveClaim.js +241 -0
  85. package/enclaveRoute.js +102 -0
  86. package/enclaveSnapshotMerge.js +44 -0
  87. package/entrySig.js +165 -0
  88. package/env.js +73 -0
  89. package/eraseFile.js +58 -0
  90. package/followImage.js +86 -0
  91. package/healNames.js +45 -0
  92. package/idb.js +113 -0
  93. package/idbSeal.js +119 -0
  94. package/indexGone.js +12 -0
  95. package/invite.js +51 -0
  96. package/inviteEnroll.js +67 -0
  97. package/inviteSend.js +68 -0
  98. package/jobAgents.js +87 -0
  99. package/keptMerge.js +91 -0
  100. package/l1-worker-src.js +2 -0
  101. package/l1-worker.js +894 -0
  102. package/laneAssociation.js +68 -0
  103. package/laneConfig.js +58 -0
  104. package/laneLinkCore.js +177 -0
  105. package/ledgerView.js +64 -0
  106. package/manifest.json +239 -0
  107. package/mcpRecommended.js +25 -0
  108. package/memberChange.js +125 -0
  109. package/mirrorBatch.js +47 -0
  110. package/mkseal.js +101 -0
  111. package/nativePush.js +153 -0
  112. package/nitroVerify.js +220 -0
  113. package/noble-p256.js +27 -0
  114. package/notice.js +116 -0
  115. package/notifKey.js +58 -0
  116. package/offlineBundle.js +62 -0
  117. package/ohttp.js +177 -0
  118. package/opRouting.js +10 -0
  119. package/opencodeWire.js +282 -0
  120. package/oprf.js +70 -0
  121. package/ownAgentLink.js +96 -0
  122. package/ownerPolicy.js +117 -0
  123. package/package.json +273 -4
  124. package/pdfOptions.js +13 -0
  125. package/pdfText.js +107 -0
  126. package/pdfjs.mjs +28 -0
  127. package/pdfjs.worker.mjs +28 -0
  128. package/pollVerdict.js +33 -0
  129. package/prefetchPoll.js +60 -0
  130. package/protectedLocal.js +426 -0
  131. package/pushCore.js +42 -0
  132. package/recovery.js +107 -0
  133. package/regions.js +42 -0
  134. package/removedMessage.js +11 -0
  135. package/renameRefusal.js +9 -0
  136. package/replyQuote.js +34 -0
  137. package/reqEnvelope.js +126 -0
  138. package/roomDefaultPrefs.js +76 -0
  139. package/roomDelete.js +109 -0
  140. package/roomEmbed.js +111 -0
  141. package/roomName.js +177 -0
  142. package/roomPass.js +256 -0
  143. package/roomRoster.js +305 -0
  144. package/roomSettings.js +61 -0
  145. package/roomState.js +58 -0
  146. package/roomStreamClient.js +115 -0
  147. package/rosterCount.js +52 -0
  148. package/rosterHash.js +13 -0
  149. package/rowSchema.js +113 -0
  150. package/safeMedia.js +116 -0
  151. package/safeMediaPins.js +17 -0
  152. package/schedulesDoc.js +78 -0
  153. package/sdkA2A.js +524 -0
  154. package/sdkAccount.js +483 -0
  155. package/sdkAccountDoc.js +89 -0
  156. package/sdkAccountSections.js +332 -0
  157. package/sdkAgui.js +141 -0
  158. package/sdkAttest.js +34 -0
  159. package/sdkBackup.js +507 -0
  160. package/sdkBackupV2.js +630 -0
  161. package/sdkBrowserPrivate.js +28 -0
  162. package/sdkBuilds.js +208 -0
  163. package/sdkCloudDevice.js +221 -0
  164. package/sdkComputers.js +1009 -0
  165. package/sdkDictation.js +232 -0
  166. package/sdkErase.js +288 -0
  167. package/sdkExports.js +71 -0
  168. package/sdkInvitations.js +34 -0
  169. package/sdkKeptAgent.js +188 -0
  170. package/sdkLaneLink.js +205 -0
  171. package/sdkPlan.js +96 -0
  172. package/sdkProtect.js +228 -0
  173. package/sdkRedact.js +36 -0
  174. package/sdkRekey.js +340 -0
  175. package/sdkReport.js +68 -0
  176. package/sdkSafeMedia.js +255 -0
  177. package/sdkSchedules.js +39 -0
  178. package/sdkSpeech.js +71 -0
  179. package/sdkTemporaryRooms.js +123 -0
  180. package/sdkTurn.js +117 -0
  181. package/sdkVault.js +180 -0
  182. package/sealShare.js +18 -0
  183. package/sealedNames.js +64 -0
  184. package/sealedReceipt.js +17 -0
  185. package/sentinelRelease.js +155 -0
  186. package/shamir.js +85 -0
  187. package/sharedViews.js +52 -0
  188. package/sheetChrome.js +450 -0
  189. package/siri.js +278 -0
  190. package/spaceClient.js +1429 -0
  191. package/spaceConfig.js +81 -0
  192. package/spaceEmailGate.js +813 -0
  193. package/spaceExport.js +125 -0
  194. package/spaceFork.js +216 -0
  195. package/spaceLock.js +358 -0
  196. package/spacePasskey.js +180 -0
  197. package/spaceTemplates.js +99 -0
  198. package/speechOut.js +102 -0
  199. package/splitKeyClient.js +90 -0
  200. package/store.js +656 -0
  201. package/streamHint.js +36 -0
  202. package/sttCloud.js +220 -0
  203. package/sttWorklet.js +38 -0
  204. package/sw-notif-core.js +540 -0
  205. package/tempList.js +48 -0
  206. package/tinfoilVerifier.js +78 -0
  207. package/toolBooks.js +31 -0
  208. package/toolRules.js +52 -0
  209. package/turnCerts.js +254 -0
  210. package/turnFeed.js +58 -0
  211. package/turnVerdict.js +37 -0
  212. package/usageReceipts.js +176 -0
  213. package/usageSummary.js +90 -0
  214. package/util.js +181 -0
  215. package/vault-core.js +2326 -0
  216. package/vault-kit.mjs +354 -0
  217. package/vault-screens.js +261 -0
  218. package/vaultAtRest.js +208 -0
  219. package/vaultCoreLock.js +111 -0
  220. package/vaultCorePush.js +140 -0
  221. package/vaultDeviceKey.js +95 -0
  222. package/vaultEnclaveHandoff.js +114 -0
  223. package/vaultKeep.js +287 -0
  224. package/vaultSealedStore.js +77 -0
  225. package/vaultWorkerHost.js +117 -0
  226. package/vcWorker.js +34 -0
  227. package/voiceAttest.js +50 -0
  228. package/voiceCert.js +51 -0
  229. package/witbitz-admin.d.ts +135 -0
  230. package/witbitz-admin.js +529 -0
  231. package/witbitz-admin.mjs +1460 -0
  232. package/witbitz-sdk.d.ts +1197 -0
  233. package/witbitz-sdk.js +4258 -0
  234. package/workerClient.js +16 -0
  235. package/workerLiveness.js +21 -0
  236. package/x509.js +218 -0
@@ -0,0 +1,1197 @@
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 { a2aReceipts?: string[]; 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; includeAssistant?: boolean }): 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; includeAssistant?: boolean }): Promise<{ key: string; endpoint: string; alias: string } | { key: null; hasKey: boolean; endpoint: string; alias: string }>
251
+ disable(opts?: { includeAssistant?: boolean }): 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 | null
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
+ linkPrivateRoom(target: Space, opts?: { allowStandardDestination?: boolean }): Promise<{ room: string; parent: string; linked: boolean }>
330
+ unlinkPrivateRoom(target: Space): Promise<{ room: string; parent: string; linked: boolean }>
331
+ readonly embed: {
332
+ invite(template: string): Promise<string | { shown: true }>
333
+ read(): Promise<Record<string, unknown> | null>
334
+ update(patch: Record<string, unknown>): Promise<void>
335
+ watch(listener: (state: Record<string, unknown> | null) => void): () => void
336
+ setLiveDocument(name: string, text: string | null): void
337
+ }
338
+ invokeSkill(name: string, args?: Record<string, unknown>): Promise<SendResult>
339
+ send(text: string, opts?: SendOptions): Promise<SendResult>
340
+ /** An emoji on a message, or `{ off: true }` to take yours off (sdk-rooms.md#replies). No new entry, no assistant turn. */
341
+ react(message: Message, emoji: string, opts?: { off?: boolean; from?: string }): Promise<{ ok: boolean; reactions?: Record<string, string[]>; error?: string }>
342
+ /** send(), plus a handle on this turn's answer. `timeoutMs` (default 960 000, about 16 minutes — as long as the Spaces app waits; a turn may run 13) stops the turn when it passes; 0 = no timeout. */
343
+ turn(text: string, opts?: SendOptions & { timeoutMs?: number }): Turn
344
+ /** The assistant as a function (sdk-assistant.md#run): one answer, nothing written to the room. `schema`: `{ field: type }` or a
345
+ * JSON Schema object → `output` fits it, or `error: 'no_structured_output'`. Must finish within ~30 s (`too_slow`). */
346
+ run(input: string, opts?: { instructions?: string; schema?: Record<string, unknown>; images?: Media[]; from?: string; showPrompt?: boolean }): Promise<RunResult>
347
+ /** Rename the room for every member and device (they are notified). Throws `not_admin` in a room with owners or admins
348
+ * for anyone else, and `direct_chat` in a direct chat (it is called by the other person's name); in an email-gated room
349
+ * `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. */
350
+ rename(name: string, opts?: { by?: string }): Promise<{ ok: boolean; title: string }>
351
+ setReplyMode(mode: ReplyMode): Promise<{ mode: ReplyMode }>
352
+ replyMode(): Promise<ReplyMode>
353
+ /** Which of the assistant's tools run on their own here, and which ask first (a card a person approves). Enforced by the server
354
+ * on every turn; the same setting as the Witbitz app's ⋯ → Tools. In a room with admins only an admin may set them. */
355
+ readonly toolRules: {
356
+ get(): Promise<{ tools: Array<{ name: string; about: string; default: 'auto' | 'ask'; now: 'auto' | 'ask'; rule?: 'auto' | 'ask' }>; rules: Record<string, 'auto' | 'ask'> }>
357
+ /** 'auto' — runs on its own; 'ask' — asks first; null — back to the tool's default. */
358
+ set(name: string, mode: 'auto' | 'ask' | null): Promise<{ rules: Record<string, 'auto' | 'ask'> }>
359
+ }
360
+ /** Poll now; the proposals waiting for a decision. */
361
+ pending(): Promise<Proposal[]>
362
+ approve(id: string, opts?: DecideOptions): Promise<DecideResult>
363
+ deny(id: string, opts?: { from?: string }): Promise<DecideResult>
364
+ /** Change the assistant or the store in place. Refuses, before sending: `create_time` (tools, immediateTools, tier, key),
365
+ * `use_fork` (admission — change it with changeMembers; `lane` on a lane), `unknown_field` (anything else) — sdk-reference.md#errors. */
366
+ 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[] }>
367
+ /** What a change would require — in place or a new room — and whether the history comes along. Changes nothing.
368
+ * On a lane, `safeMedia` is refused with `lane_follows_space` (set it on the Space). */
369
+ 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>
370
+ /** A private assistant lane for the current member (sdk-agents.md#lanes). On a Lane: rejects with `lane_of_lane` (ask from its Space). */
371
+ 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>
372
+ /** 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
373
+ * the list receive. `admission` is the list stated in full. Needs a signed-in owner or admin. In a vault the person confirms
374
+ * there and `link` is absent. Refuses `not_admin`, `sign_in_required`, `no_invite_key`, `changed_meanwhile`, `lane`, `store_unavailable` (503: not saved — retry). */
375
+ /** `roles: true`: only owners/admins changed — the room kept its key (nobody's access changed). */
376
+ changeMembers(admission: Admission): Promise<MemberChange & { removed: string[]; added: string[]; roles?: true }>
377
+ /** The same members, a new key (a lost phone, a link sent to the wrong place) — sdk-people.md#members. */
378
+ rotateKey(): Promise<MemberChange & { rotated: true }>
379
+ /** Resend the current link through this app's invite directory. Does not add admission. Attested rooms use their native app. */
380
+ resendInvite(recipient: { email: string; username?: never } | { username: string; email?: never }): Promise<{ ok: boolean; reason?: string }>
381
+ /** RETIRED (3.0.0): a Space no longer moves — members change in place (`changeMembers`). Always throws `use_change_members`. */
382
+ fork(opts?: unknown): Promise<never>
383
+ /** 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). */
384
+ directPeer(): Promise<{ email: string } | { username: string; handle?: string } | null>
385
+ usage(): Promise<{
386
+ records: { at: number; kind: 'title' | 'reply'; usage: { by?: string; calls?: number; in?: number; out?: number; cached?: number; costMicros?: number; models?: string[]; source?: string } }[]
387
+ summary: { all: UsageTotals; week: UsageTotals; byPerson: (UsageTotals & { name: string })[]; byModel: { model: string; turns: number }[]; partial: boolean; empty: boolean }
388
+ csv: string
389
+ incomplete: boolean
390
+ }>
391
+ roster(): Promise<{
392
+ incomplete: boolean
393
+ gated: boolean
394
+ members: { label: string; address?: string; username?: string; verified: boolean }[]
395
+ pending: { label: string; address?: string; username?: string }[]
396
+ domains: string[]
397
+ unopenedPrivateInvites: number
398
+ }>
399
+ admission(): Promise<AdmissionInfo>
400
+ admits(email: string): Promise<boolean>
401
+ isAdmin(email: string): Promise<boolean>
402
+ isOwner(email: string): Promise<boolean>
403
+ /** Import a public ChatGPT, Claude, Gemini or Grok share URL. The server validates the source. */
404
+ importChat(url: string): Promise<{ imported: number; title: string; entries: number }>
405
+ /** Import the text from a WhatsApp chat export (unzip the export first). */
406
+ importWhatsApp(text: string): Promise<{ imported: number; title: string; entries: number }>
407
+ /** Sealed schedules, shared with the app. Adding/resuming needs an active always-on cloud device. */
408
+ readonly schedules: {
409
+ list(): Promise<Array<{ id: string; when: { every: number } | { at: string; tz: string }; text: string; by: string; at: number; paused?: boolean; pausedAt?: number }>>
410
+ add(job: { when: { every: number } | { at: string; tz?: string }; text: string }): Promise<{ id: string; when: { every: number } | { at: string; tz: string }; text: string; by: string; at: number }>
411
+ remove(id: string): Promise<unknown[]>
412
+ pause(id: string, paused?: boolean): Promise<unknown[]>
413
+ }
414
+ readonly alwaysOn: {
415
+ status(): Promise<{ on: boolean; registered: boolean; waiting?: string }>
416
+ /** A backed-up solo Space; disconnectLanes explicitly turns its private assistants off first. */
417
+ enable(opts?: { disconnectLanes?: boolean }): Promise<{ on: true }>
418
+ disable(): Promise<{ on: false }>
419
+ /** Starts a run on the cloud device; the answer arrives in the Space. */
420
+ run(text: string): Promise<{ started: boolean }>
421
+ }
422
+ attachment(att: Media | Record<string, unknown>): Promise<Media>
423
+ /** The newest message carrying a file or image of this name (case-insensitive) — the assistant links files by name. Bytes: attachment(att). */
424
+ fileNamed(name: string): { message: Message; att: Media } | null
425
+ /** Did this signed-in session send it? (verified with this session's key; never by a typed name). In a vault: the vault's session. */
426
+ isMine(message: Message): boolean
427
+ /** Who wrote it, as Block knows a person (the server's stamps and the signing key; never a typed name) — null: nothing proves it (sdk-people.md#block). */
428
+ blockIdentity(message: Message): BlockWho | null
429
+ /** 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.
430
+ * Throws `invalid_argument`, `sign_in_required`; in a vault `vault_unsupported`. Refusals are answers (`not_member`, `sign_in`, `budget`). */
431
+ 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 }>
432
+ static readonly REPORT_REASONS: readonly ReportReason[]
433
+ /** Does this Space take only a page proved to be one named app (an attested app)? From its public policy; a failed read throws `policy_unreadable`. In a vault: `vault_unsupported`. */
434
+ attested(): Promise<{ required: boolean; confidential: boolean }>
435
+ exportFile(): Promise<{ count: number }>
436
+ sealedProof(): Promise<Record<string, unknown> | null>
437
+ /** Confidential rooms: verify every reply's turn certificate on this device. */
438
+ 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> }>
439
+ snapshot(): Snapshot
440
+ close(): void
441
+ }
442
+
443
+ /** `lane.link(other)` — two of a member's assistants that ask each other (sdk-agents.md#lane-links). */
444
+ export interface LaneLink {
445
+ readonly a: Lane
446
+ readonly b: Lane
447
+ /** How many lanes a request may cross before it is answered where it is. */
448
+ readonly cap: number
449
+ /** The progress to persist (JSON-safe) — hand it back as `link(other, { resume })` after a reload. */
450
+ readonly state: { cursorA: number | null; cursorB: number | null; sentA: string[]; sentB: string[] }
451
+ /** End the link: neither assistant is offered the other any more. */
452
+ unlink(): void
453
+ /** Forward what is waiting now (it also runs on every new message). */
454
+ run(): Promise<{ forwarded: number }>
455
+ }
456
+ export interface SharedAgentDraft {
457
+ taskId: string; peerId: string; peerName: string; reply: 'ask' | 'auto'; text: string; draft: string; at: number; by: string
458
+ }
459
+ /** Outside agents in a private lane or solo verified Space. */
460
+ export interface LaneA2A {
461
+ readonly cardUrl: string | null
462
+ /** The same door over MCP (tools message_member / get_reply), with the same per-peer token. */
463
+ readonly mcpUrl: string | null
464
+ readonly peers: Array<{ id: string; name: string; reply: 'ask' | 'auto'; job?: true; own?: true; [k: string]: unknown }>
465
+ enable(opts: { name: string; description?: string }): Promise<{ cardUrl: string; mcpUrl: string }>
466
+ /** `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. */
467
+ /** 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. */
468
+ addPeer(name: string, opts?: { reply?: 'ask' | 'auto'; job?: boolean; reconnect?: boolean; previousPeerId?: string; connectionId?: string }): Promise<{ id: string; token: string | null; shown?: boolean; roomListPending?: boolean; cardUrl: string; mcpUrl: string }>
469
+ setReply(peerId: string, reply: 'ask' | 'auto'): Promise<{ id: string; reply: 'ask' | 'auto' }>
470
+ removePeer(peerId: string): Promise<{ removed: boolean }>
471
+ disable(): Promise<{ disabled: boolean }>
472
+ collect(): Promise<{ delivered: number; more?: boolean }> // more: it stopped 45 s after the pull — collect again (state machines pass 9, K#9)
473
+ reply(taskId: string, text: string, opts?: { ask?: boolean; reject?: boolean }): Promise<unknown>
474
+ sharedDrafts(): Promise<SharedAgentDraft[]>
475
+ reviewDraft(draft: SharedAgentDraft, text?: string, opts?: { ask?: boolean; reject?: boolean }): Promise<{ state: string }>
476
+ }
477
+
478
+ export declare class Lane extends Space {
479
+ on<E extends keyof LaneEvents>(event: E, cb: (e: LaneEvents[E]) => void, opts?: { replay?: boolean }): Unsubscribe<this>
480
+ setActions(actions: LaneAction[]): this
481
+ setLinks(links: Array<Space | { space: Space; label?: string }>): this
482
+ send(text: string, opts?: SendOptions & { replace?: boolean; links?: Array<Space | { space: Space; label?: string }> }): Promise<SendResult>
483
+ turn(text: string, opts?: SendOptions & { tools?: LaneAction[]; replace?: boolean; links?: Array<Space | { space: Space; label?: string }>; timeoutMs?: number }): Turn
484
+ /** Synchronous: returns the link's handle. */
485
+ link(other: Lane, opts?: { to?: string; as?: string; cap?: number; resume?: LaneLink['state'] }): LaneLink
486
+ /** Connect a kept always-on Space as a job agent of this private lane. Credentials stay in the vault in vault mode. */
487
+ linkKept(space: Space, opts?: { spaceName?: string; laneName?: string }): Promise<{ lane: string; space: string; connId: string; lPeer: string; sPeer: string }>
488
+ unlinkKept(space: Space, link: { lane: string; space: string; connId: string; lPeer: string; sPeer: string }): Promise<{ disconnected: true }>
489
+ /** Copy the shared room's new messages into this lane now (a lane opened with `mirror`). */
490
+ mirrorNow(): Promise<unknown>
491
+ }
492
+
493
+ // ─── The client ───────────────────────────────────────────────────────────────────────────────────────────────────────
494
+ /** `sign`: this device's signing keypair (JWKs) — the key a verified room stamps on its messages as `spk`. */
495
+ export interface Session { email: string; idToken: string; exp: number; sign?: { pub: { kty: string; crv: string; x: string; y: string }; priv: Record<string, unknown> } }
496
+ export type VaultOptions = Omit<WitbitzOptions, 'session' | 'attest' | 'sentinel' | 'devRoot' | 'enclaveClaim' | 'backup' | 'siri' | 'a2a' | 'invite' | 'builds'> & {
497
+ vault: string
498
+ session?: null
499
+ attest?: never
500
+ sentinel?: never
501
+ devRoot?: never
502
+ enclaveClaim?: never
503
+ backup?: null
504
+ siri?: null
505
+ a2a?: null
506
+ invite?: null
507
+ builds?: 'published' | { mode?: 'published'; state?: BuildsState }
508
+ }
509
+
510
+ export interface WitbitzOptions {
511
+ keepTemporaryRooms?: boolean
512
+ endpoint?: string
513
+ /** The origin a shareLink opens in: links read `<viewer>/space?room=<id>#mk=<key>`. */
514
+ viewer?: string
515
+ app?: string
516
+ /** Your tenant's PUBLIC id (t_…). Needed to CREATE rooms from your own origin (declared with admin.origins). */
517
+ tenant?: string
518
+ /** Server only — prefer WitbitzAdmin (witbitz-admin.js). A page that passes one logs a warning. */
519
+ tenantKey?: string
520
+ tenantEndpoint?: string
521
+ session?: Session
522
+ userToken?: string | (() => string | Promise<string>)
523
+ live?: boolean
524
+ appShare?: string
525
+ enclaveClaim?: string
526
+ /** The Witbitz dev server's attestation root (base64 DER) — for a local dev server with a confidential tier only. It REPLACES the
527
+ * pinned AWS root for this client's confidential tier, so such a client trusts that local server's enclave and never Witbitz's. */
528
+ devRoot?: string
529
+ backup?: unknown
530
+ /** Device storage protection's Storage (localStorage by default), its config key, and the passkey's site (this host by default). */
531
+ protect?: ProtectOptions | Protect
532
+ /** Native device attestation bridge. `attest: { app }` alone is retired; web pages cannot prove a native app identity. */
533
+ 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 }
534
+ /** 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. */
535
+ region?: string
536
+ /** Which enclave build a confidential room's key may be sealed to: 'published' (default — any build Witbitz publishes) or
537
+ * 'mine' — the person's own list of accepted builds, as the Witbitz app does (`wb.builds`). `{ mode, state }` hands back a
538
+ * persisted list for a page without an account. */
539
+ builds?: 'published' | 'mine' | { mode?: 'published' | 'mine'; state?: BuildsState }
540
+ deviceName?: string
541
+ vaultApi?: string
542
+ siri?: unknown
543
+ a2a?: unknown
544
+ a2aEndpoint?: string
545
+ /** A persisted `wb.invite.state` (sdk-people.md#members). */
546
+ invite?: unknown
547
+ loginBase?: string
548
+ /** The standing Sentinel that keeps connections' keys. `follow` (2.2.3): `'published'` (default) accepts a new build Witbitz
549
+ * publishes at /sentinel-claim.json; `'ask'` calls `onNewBuild(pcr0)` and accepts on `true`; `'off'` keeps the pins. Your own
550
+ * `pins` (a tenant running its own Sentinel) are never followed. */
551
+ sentinel?: { pins?: string[], follow?: 'published' | 'ask' | 'off', onNewBuild?: (pcr0: string) => boolean | Promise<boolean>, claimUrl?: string, verify?: Function }
552
+ fetchImpl?: typeof fetch
553
+ WebSocketImpl?: unknown
554
+ /** Advanced: a client whose ops take no room key (`keyless: true`) — the keys live where it sends the ops.
555
+ * {@link Witbitz.inVault} plugs one in for you. */
556
+ client?: object
557
+ }
558
+
559
+ /** 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. */
560
+ export interface VaultLock { available: true; on: boolean; protect: boolean }
561
+ /** A vault's notifications on this device, as the person set them (a vault started with `push: true`). */
562
+ export interface VaultPush { available: true; on: boolean }
563
+ /** A Space in the vault's list — never its link (the link carries the key). */
564
+ export interface VaultRoom { detachedLane?: true; 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 }
565
+ /** `wb.vault` — the vault this page runs in (docs: § Vault mode). The keys are there; this page never holds one. */
566
+ export declare class VaultSession {
567
+ /** The vault's origin. */
568
+ readonly origin: string
569
+ /** Connection details and the latest room, sign-in and account state reported by the vault. */
570
+ readonly info: { v: number; tenant: string; endpoint: string; signedIn: boolean; email: string; /** the vault session key's PUBLIC id (what `space.isMine` compares) — '' when signed out; an older vault sends none */ keyId?: string; rooms: VaultRoom[]; /** the Siri Shortcut: never its key */ siri: { key: null; hasKey: boolean; endpoint: string }; /** the backup and account, as `wb.backup` / `wb.account` read them */ account: { enabled: boolean; format: string | null; /** 'account' (the Witbitz account service) | 'legacy' | null */ service: 'account' | 'legacy' | null; /** a restore and deleting the account need the emailed code as well */ gated: boolean; deviceId: string; rooms: Array<{ room: string; kind: string; label?: string; /** a lane's Space: its room id */ shared?: string; archived?: boolean; pinned?: boolean }>; devices: unknown[]; links: unknown[]; lastError: { message: string; code?: string; status?: number } | string | null; erasure: boolean }; /** only a vault started with `lock: true` says it: the lock (a passkey at every launch) and storage protection, as the person set them */ lock?: VaultLock; /** only a vault started with `push: true` says it: notifications on this device */ push?: VaultPush; /** the Space whose notification the person tapped to open the vault */ notifOpen?: string }
571
+ /** The Spaces this vault holds, newest first. */
572
+ rooms(): Promise<VaultRoom[]>
573
+ /** A live Space for a room the vault holds; its key stays in the vault (`space.key` and `space.shareLink` are null). A private
574
+ * lane's room id (`rooms()` marks it with `lane`) gives a `Lane` of its Space — `lane_space_gone` once that Space is forgotten. */
575
+ openRoom(room: string, opts?: { resume?: Snapshot }): Promise<Space | Lane>
576
+ /** The vault shows its share screen with the invite link; the link never reaches this page. */
577
+ share(space: Space | string, opts?: { title?: string; hostInviteTemplate?: string }): Promise<{ shown: true }>
578
+ /** The vault shows the Siri Shortcut's key in its own screen; the key never reaches this page. */
579
+ showSiriKey(): Promise<{ shown: true }>
580
+ /** The vault shows its LOCK SHEET: the person turns the lock and "Also protect this device's storage" on or off there; resolves
581
+ * with the outcome when they close it. Rejects `vault_unsupported` unless the vault was started with `lock: true`. */
582
+ showLock(): Promise<VaultLock>
583
+ /** The vault asks the person, in its own card, to turn notifications on (or off) on this device; resolves with the outcome. A
584
+ * tapped notification arrives as `on('notifOpen', ({ room }) => …)`. Rejects `vault_unsupported` unless the vault was started
585
+ * with `push: true`. */
586
+ showNotifications(): Promise<VaultPush>
587
+ /** The vault shows its sign-in screen; resolves once signed in. */
588
+ /** The member enters their email in the vault. */
589
+ signIn(): Promise<{ email: string }>
590
+ /** @deprecated The vault ignores the supplied email. Use signIn() and enter the address in the vault. */
591
+ signIn(opts: { email?: string }): Promise<{ email: string }>
592
+ /** The person confirms in the vault; rejects with code `cancelled` if they do not. */
593
+ signOut(): Promise<{ signedIn: false }>
594
+ whoami(): Promise<{ signedIn: boolean; email?: string; keyId?: string }>
595
+ /** Forget a Space on this device. With account backup enabled the removal syncs to every device. The person confirms in the vault; rejects
596
+ * with code `cancelled` if they do not. */
597
+ forget(space: Space | string): Promise<{ forgotten: boolean }>
598
+ on(event: 'rooms', cb: (e: { rooms: VaultRoom[] }) => void): () => void
599
+ on(event: 'joined', cb: (e: { room: string }) => void): () => void
600
+ on(event: 'signedIn', cb: (e: { email: string; keyId?: string }) => void): () => void
601
+ on(event: 'signedOut', cb: (e: object) => void): () => void
602
+ /** This device was signed out of the account (or the account was deleted) from another device: the vault forgot the account, its
603
+ * sign-in and its Spaces here, and `info.signedIn` is false. `reason: 'erased'`: the account was deleted. */
604
+ on(event: 'accountSignedOut', cb: (e: { reason?: 'erased' | 'moved' }) => void): () => void
605
+ /** The vault's account view changed (the backup, the account index): what wb.backup / wb.account read. */
606
+ on(event: 'account', cb: (e: { view: Record<string, unknown> }) => void): () => void
607
+ /** A renewed session: its new key's public id (space.isMine). */
608
+ on(event: 'session', cb: (e: { keyId: string }) => void): () => void
609
+ /** The vault's lock changed (startVault({ lock: true })): whether this device can lock, whether it is on, whether stored data is sealed. */
610
+ on(event: 'lock', cb: (e: { lock: { available: boolean, on: boolean, protect: boolean } }) => void): () => void
611
+ /** The vault's notifications changed (startVault({ push: true })). */
612
+ on(event: 'push', cb: (e: { push: { available: boolean, on: boolean } }) => void): () => void
613
+ /** A notification was tapped: open this Space. */
614
+ on(event: 'notifOpen', cb: (e: { room: string }) => void): () => void
615
+ }
616
+
617
+ /** `wb.protect` — device storage protection: what the app keeps on the device, sealed under a key a platform passkey
618
+ * derives (PRF or largeBlob), nowhere on disk. Off until enable(); seal/open/save/load pass values through while off. */
619
+ export interface ProtectState { on: boolean; locked: boolean; mode: 'prf' | 'largeblob' | null; auto: number }
620
+ /** Its Storage (localStorage by default), its config key, and the passkey's site (this page's host by default). */
621
+ export interface ProtectOptions { storage?: Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>; storeKey?: string; rpId?: string; rpName?: string }
622
+ /** Usable before a client exists: `new Protect()` → unlock → load → `new Witbitz({ protect, session, backup })`. */
623
+ /** What `admin.customers.erase({ email })` needs from the user's devices (docs: § Erasing a user who has left). Every room
624
+ * the SDK creates carries a deletion commitment, every room it opens gets the account's membership mark, and the
625
+ * account's delete list is filed — sealed to Witbitz's attested enclave, for your tenant — automatically after a room is
626
+ * created or opened. Needs `new Witbitz({ tenant })`, a sign-in and `wb.backup` (the key every device of the account shares). */
627
+ export interface BuildEntry { kernel: string; payload?: string; policy?: string; at: number }
628
+ export interface BuildsState { builds: BuildEntry[]; auto?: { on: boolean; at: number } }
629
+ export interface BuildVerdict { ok: boolean; reason?: 'no_attestation' | 'no_platform_claim' | 'kernel' | 'payload' | 'policy' | 'unknown' | 'not_accepted'; live?: { kernel: string; payload?: string; policy?: string } }
630
+ /** `wb.builds` — which enclave build THIS PERSON accepts. In 'mine' mode a confidential room's key is sealed only to a build Witbitz
631
+ * publishes AND that is on their list: the first one is accepted on first use; with `automatic` on (the default) every published
632
+ * build is; off, a new one blocks their confidential rooms (`enclave_not_accepted`, `error.verdict`) until `accept(room)`. */
633
+ export interface Builds {
634
+ readonly mode: 'published' | 'mine'
635
+ /** JSON-safe — persist it for a page without an account; `onState` hands each change. */
636
+ readonly state: BuildsState
637
+ onState: ((state: BuildsState) => void) | null
638
+ list(): BuildEntry[]
639
+ /** Accept new Witbitz builds automatically? On unless the person turned it off. For the account (every device). */
640
+ readonly automatic: boolean
641
+ setAutomatic(on: boolean): Promise<boolean>
642
+ /** Does this person accept the enclave serving `room`? null before it attested. In a vault it throws `vault_unsupported`:
643
+ * the vault meets the enclave and seals the keys, the page never does. */
644
+ verdict(room: string): BuildVerdict | null
645
+ /** Accept the build serving `room` (its region's enclave): `not_published` for a build Witbitz does not publish. */
646
+ accept(room: string): Promise<BuildEntry[]>
647
+ /** Read the account's list now (it is read by itself before the first seal). */
648
+ sync(): Promise<BuildEntry[]>
649
+ }
650
+ export interface Erasure {
651
+ /** True when this page can file: a tenant app, a live sign-in and an enabled backup. */
652
+ readonly available: boolean
653
+ /** File the list now (after a sign-in or a backup restore); an unchanged list is skipped unless `force`. */
654
+ file(opts?: { force?: boolean }): Promise<{ filed: boolean; rooms?: number; skipped?: string }>
655
+ /** Is a list filed for this account in this app, and how many rooms — never the secrets. */
656
+ status(): Promise<{ ok?: boolean; filed: boolean; rooms?: number; updated?: number }>
657
+ /** DELETE MY ACCOUNT, from your page — the Witbitz app's own: rooms only this person used are deleted, shared ones left; the
658
+ * username and directory entry, the filed list, the backup, the account index; then this client forgets the account.
659
+ * 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.
660
+ * A backup with an email gate (`wb.backup.gated`) needs its emailed code FIRST, before anything is deleted: with the recovery
661
+ * `code` it mails one and rejects `email_code_required` (with `ticket`); call again with `{ code, ticket, emailCode }`.
662
+ * No `code`: `code_required`; a wrong emailed code: `email_code_wrong`. */
663
+ 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 } }>
664
+ }
665
+ export declare class Protect {
666
+ constructor(opts?: ProtectOptions)
667
+ readonly state: ProtectState
668
+ /** Can this browser hold a protection passkey (WebAuthn in a secure context)? */
669
+ available(): boolean
670
+ /** One passkey; everything already saved through save() is sealed in place. Refuses `backup_required` while wb.backup is
671
+ * off — a lost passkey loses what it sealed — unless `withoutBackup: true`. */
672
+ enable(opts?: { label?: string; withoutBackup?: boolean }): Promise<ProtectState>
673
+ /** A user-verified passkey assertion brings the key back. Throws `wrong_passkey` for one that opens nothing here. */
674
+ unlock(): Promise<ProtectState>
675
+ /** Drop the key from memory: loads refuse `locked` until unlock(). */
676
+ lock(): ProtectState
677
+ /** Write what save() wrote back in the clear and forget the protection (asks the passkey when locked). */
678
+ disable(): Promise<ProtectState>
679
+ seal<T>(value: T): Promise<T | { v: 1; s: string }>
680
+ open<T = unknown>(stored: unknown): Promise<T>
681
+ save(name: string, value: unknown): Promise<void>
682
+ load<T = unknown>(name: string): Promise<T | undefined>
683
+ remove(name: string): void
684
+ /** Lock when the page returns after being hidden longer than this (0 = only lock() or a new launch). */
685
+ autoLock(minutes: number): ProtectState
686
+ on(event: 'locked' | 'unlocked' | 'change', cb: (state: ProtectState) => void): () => void
687
+ }
688
+
689
+ /** `wb.backup` — the account backup (a recovery code wraps a master secret; the record is sealed in the vault). */
690
+ export interface VaultAccountBackup extends Omit<AccountBackup, 'enable' | 'restore' | 'rooms' | 'protectRecoveryEmail' | 'save' | 'beginEmailMove' | 'finishEmailMove' | 'cancelPendingEmailMove' | 'migrate' | 'cancelEmailMove'> {
691
+ migrate(opts?: { silent?: boolean }): Promise<{ migrated: true; trust: string | null }>
692
+ cancelEmailMove(): Promise<{ cancelled: true }>
693
+ beginEmailMove(): Promise<{ ready_at: number; expires: number }>
694
+ finishEmailMove(): Promise<{ enabled: true }>
695
+ cancelPendingEmailMove(): Promise<{ cancelled: true }>
696
+ save(): Promise<{ rooms: number }>
697
+ readonly rooms: VaultAccountIndex['rooms']
698
+ protectRecoveryEmail(): Promise<{ enrolled: true }>
699
+ enable(): Promise<{ enabled: true }>
700
+ restore(): Promise<{ rooms: VaultAccountIndex['rooms'] }>
701
+ }
702
+ export interface AccountBackup {
703
+ readonly enabled: boolean
704
+ /** True when enable() recorded an email: a restore, and deleting the account, then need its emailed code as well. */
705
+ readonly gated: boolean
706
+ /** JSON-safe state to persist (it holds the master secret), or null. */
707
+ readonly state: unknown
708
+ /** 'account' (the Spaces app's record format — every new backup) or 'legacy' (this SDK's original); null when not enabled. */
709
+ readonly format: 'account' | 'legacy' | null
710
+ /** Where the account is kept: 'account' (the Witbitz account service — a new account in a vault that names its tenant),
711
+ * 'legacy' (the backup store every account used before), null when there is none on this client. */
712
+ readonly service: 'account' | 'legacy' | null
713
+ readonly rooms: Array<{ room: string; link: string; kind: 'space' | 'lane'; label?: string; shared?: string; laneOrigin?: 'minted'; mintedFor?: string; archived?: boolean; pinned?: boolean }>
714
+ onState: ((state: unknown) => void) | null
715
+ enable(opts?: { email?: string }): Promise<{ code: string }>
716
+ restore(opts: { code: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: AccountBackup['rooms'] }>
717
+ save(verification?: { code?: string; email?: string; ticket?: string; emailCode?: string }): Promise<{ rooms: number }>
718
+ /** Rewrite a legacy backup in the account format — same code and rooms; an older SDK can then no longer restore it. */
719
+ upgrade(): Promise<{ format: 'account' }>
720
+ /** Record a room in the backup (createSpace / openSpace do this for you). */
721
+ add(spaceOrLane: Space, opts?: { label?: string }): this
722
+ keyFor(room: string): string | null
723
+ /** The account's invite key for this app, kept with the rooms (wb.invite hands it over; a restore gives it back). */
724
+ readonly invite: InviteAccount['state']
725
+ /** In a vault it throws `vault_unsupported` (the vault keeps the invite key and the backup; `invite` reads null). */
726
+ setInvite(state: unknown): this
727
+ /** In a vault: a promise of the same (the vault's answer, or its refusal). */
728
+ remove(room: string): this | Promise<this>
729
+ /** Enroll email protection for an existing legacy recovery code. */
730
+ protectRecoveryEmail(opts: { code: string }): Promise<{ enrolled: true }>
731
+ manageSecurityKeys(): Promise<{ closed: true }>
732
+ /** Sign the other devices out of this account. */
733
+ signOutOthers(): Promise<{ ok: true }>
734
+ /** Request a new, empty account on this device. Dates are Unix seconds. */
735
+ beginEmailMove(opts: { email?: string; getCode: () => Promise<string> }): Promise<{ ready_at: number; expires: number }>
736
+ pendingEmailMove(): Promise<{ ready_at: number; expires: number } | null>
737
+ finishEmailMove(opts: { getCode: () => Promise<string>; showCode: (code: string) => Promise<void> }): Promise<{ enabled: true }>
738
+ cancelPendingEmailMove(opts: { getCode: () => Promise<string> }): Promise<{ cancelled: true }>
739
+ /** The existing account’s view of a pending move. */
740
+ emailMove(): Promise<{ reset: string; ready_at: number; expires: number; objected?: boolean } | null>
741
+ /** Move a legacy account in a tenant-configured builder vault. The vault confirms the move.
742
+ * Eligible devices can rejoin a signed move. An emailed-code move signs other devices out. */
743
+ migrate(opts?: { silent?: boolean; code?: string; getCode?: () => Promise<string> }): Promise<{ migrated: true; trust: string | null }>
744
+ requestMoveTime(): Promise<{ reset: string; ready_at: number; expires: number; objected?: boolean }>
745
+ cancelEmailMove(opts?: { getCode?: () => Promise<string> }): Promise<{ cancelled: true }>
746
+ /** A new recovery code, shown once in the vault; the old one stops working and every other device is signed out. */
747
+ newRecoveryCode(): Promise<{ ok: true }>
748
+ /** 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
749
+ * account as a sign-out does — its Spaces, its sign-in — and the page hears `accountSignedOut` with `reason: 'erased'`. */
750
+ deleteAccount(): Promise<{ deleted: boolean; report?: Awaited<ReturnType<Erasure['deleteAccount']>> }>
751
+ }
752
+
753
+ /** `wb.account` — the account's live index across devices (sdk-accounts.md#account-index). */
754
+ export interface AccountIndex {
755
+ readonly enabled: boolean
756
+ readonly deviceId: string
757
+ readonly rooms: AccountBackup['rooms']
758
+ /** `sdk`: the SDK release a device last synced with (3.24.0 and later; an older device has none). */
759
+ readonly devices: Array<{ id: string; name: string; seenAt: number; signedOut: boolean; current: boolean; sdk?: string }>
760
+ readonly links: Array<{ a: string; b: string; cap?: number }>
761
+ /** Called after a sync changed the index. */
762
+ onChange: ((index: Pick<AccountIndex, 'rooms' | 'devices'>) => void) | null
763
+ /** Called when another device signed THIS one out (it has dropped the account). */
764
+ /** This device was signed out of the account by another device; `reason: 'erased'` when the account was deleted. */
765
+ onSignedOut: ((e?: { reason?: 'erased' | 'moved' }) => void) | null
766
+ /** The last background sync's error, or null. */
767
+ lastError: Error | null
768
+ archive(room: string, on?: boolean): this
769
+ pin(room: string, on?: boolean): this
770
+ rename(room: string, label: string): this
771
+ forget(room: string): this
772
+ /** `reason: 'erased'`: the account was deleted — that device's `onSignedOut` hears `{ reason: 'erased' }`. */
773
+ repairNames(): Promise<number>
774
+ previewEmptySpaces(options?: { detailed?: false }): Promise<Array<{ room: string; title: string }>>
775
+ previewEmptySpaces(options: { detailed: true }): Promise<{ rooms: Array<{ room: string; title: string }>; unreadable: number }>
776
+ removeEmptySpaces(options: { rooms: string[]; confirm: true }): Promise<{ removed: number; forgottenOnly: number; kept: Array<{ title: string; why: string }> }>
777
+ listDevices(): Promise<Array<AccountIndex['devices'][number] & { spk: string | null; state?: string; addedAt?: number }>>
778
+ signOutDevice(deviceId: string, opts?: { getCode?: (address: string) => Promise<string> }): Promise<{ revoked: boolean }>
779
+ signOut(deviceId: string, opts?: { reason?: 'erased' | 'moved' }): this
780
+ /** `signedOut: true` (and empty lists) when another device signed this one out. */
781
+ sync(): Promise<{ ok: boolean; rooms: AccountBackup['rooms']; devices: AccountIndex['devices']; signedOut?: boolean }>
782
+ start(opts?: { every?: number }): this
783
+ stop(): this
784
+ /** What this account's turns cost in a month (UTC, default this one), across its rooms, whoever paid — folded from the
785
+ * receipts every turn carries (docs: #account-usage). Amounts in micro-dollars; `costUsd` in dollars. */
786
+ usage(opts?: { month?: string }): Promise<{ month: string; replies: number; costMicros: number; costUsd: number; in: number; out: number; byPayer: { you: number; admin: number; app: number; witbitz: number }; byDay: Record<string, number> }>
787
+ /** Optional sections (3.24.0), kept as the Spaces app keeps them: nothing is read until you use one (sdk-accounts.md#account-sections). */
788
+ readonly contacts: AccountContacts
789
+ readonly name: AccountSection<string>
790
+ readonly roomDefaults: AccountSection<RoomDefaults | null, Partial<RoomDefaults>>
791
+ /** The people this account blocked, as the Spaces app keeps them (sdk-people.md#block). */
792
+ readonly blocks: AccountBlocks
793
+ /** Display-lock metadata, shared with the app. Build PIN/display UI with chatLock.js; this does not isolate data. */
794
+ readonly chatLocks: {
795
+ readonly value: Record<string, unknown> | null
796
+ get(): Promise<Record<string, unknown> | null>
797
+ merge(doc: Record<string, unknown>): Promise<Record<string, unknown> | null>
798
+ /** Display controls only. A Code target is '<computerId>/<sessionId>'. Raw PINs are never stored. */
799
+ set(lock: { kind: 'room' | 'code'; target: string; pin: string; title?: string }): Promise<Record<string, unknown> | null>
800
+ remove(lock: { lockId: string }): Promise<Record<string, unknown> | null>
801
+ changePin(lock: { lockId: string; pin: string; newPin: string }): Promise<Record<string, unknown> | null>
802
+ previewDeleteAll(): Promise<{ targets: { lockId: string; kind: 'room' | 'code'; target: string }[]; privateAssistants: { room: string; parent: string; title: string }[] }>
803
+ /** Removes the listed targets without requiring their PIN. */
804
+ deleteAll(opts?: { includePrivateAssistants?: boolean; privateAssistantRooms?: readonly string[] }): Promise<{ lockId: string; kind: 'code' | 'room'; target: string; deleted: boolean }[]>
805
+ /** Uses the app's synced wrong-PIN backoff. Does not isolate or encrypt room data. */
806
+ match(attempt: { pin: string }): Promise<{ ok: boolean; next: number; matches: { lockId: string; kind: 'code' | 'room'; target: string; title: string }[] }>
807
+ /** Uses the app's synced wrong-PIN backoff. Does not isolate or encrypt room data. */
808
+ check(attempt: { lockId: string; pin: string }): Promise<{ ok: boolean; next: number }>
809
+ on(ev: 'change', fn: (doc: Record<string, unknown> | null) => void): unknown
810
+ off(ev: 'change', fn: Function): unknown
811
+ }
812
+ }
813
+
814
+ /** A person, by what proves who they are: the verified email, the @username, or the key that signed in one Space. */
815
+ export interface BlockWho { email?: string; user?: string; room?: string; sid?: string }
816
+ export type ReportReason = 'harassment' | 'threats' | 'sexual' | 'hate' | 'spam' | 'other'
817
+ /** `wb.account.blocks` — the app's Block list. Errors as AccountSection's. */
818
+ export interface AccountBlocks {
819
+ /** The people blocked, as this device last read (null before the first read). */
820
+ readonly value: Array<BlockWho & { name: string; at: number }> | null
821
+ get(): Promise<Array<BlockWho & { name: string; at: number }>>
822
+ /** Block them on every device of the account (`space.blockIdentity(message)`, plus a `name` to show). */
823
+ block(who: BlockWho & { name?: string }): Promise<Array<BlockWho & { name: string; at: number }>>
824
+ /** Unblock: every entry naming them by any proof goes (kept as a tombstone). */
825
+ unblock(who: BlockWho): Promise<Array<BlockWho & { name: string; at: number }>>
826
+ merge(list: Array<BlockWho & { name?: string; at?: number; gone?: boolean }>): Promise<Array<BlockWho & { name: string; at: number }>>
827
+ /** Is this writer blocked (any one shared proof)? Over what was last read, or over `list` — one you keep yourself. */
828
+ has(who: BlockWho | null, list?: Array<BlockWho & { at?: number; gone?: boolean }>): boolean
829
+ on(ev: 'change', fn: (value: Array<BlockWho & { name: string; at: number }>) => void): this
830
+ off(ev: 'change', fn: (value: Array<BlockWho & { name: string; at: number }>) => void): this
831
+ }
832
+
833
+ /** One optional account section. Errors: `not_enabled`, `unreadable` / `unopenable` (nothing written), `save_failed`, `invalid_argument`. */
834
+ export interface AccountSection<T, P = T> {
835
+ /** What this device last read; null before the first read. */
836
+ readonly value: T | null
837
+ get(): Promise<T>
838
+ set(value: P): Promise<T>
839
+ /** 'change': another device changed it (seen at an account sync — the stream or the minute poll). */
840
+ on(ev: 'change', fn: (value: T) => void): this
841
+ off(ev: 'change', fn: (value: T) => void): this
842
+ }
843
+ /** A person ({ email and/or username }) or a saved assistant ({ kind: 'agent', id, fn }) — the Spaces app's address book row. */
844
+ 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 }
845
+ export interface AccountContacts extends AccountSection<AccountContact[], Partial<AccountContact>> {
846
+ remove(contact: Partial<AccountContact>): Promise<AccountContact[]>
847
+ /** Fold in a list as the app does on a sync or a restore: each row by its own `at`. */
848
+ merge(list: Array<Partial<AccountContact>>): Promise<AccountContact[]>
849
+ }
850
+ /** The New-Space defaults (the app's Settings → Default room). */
851
+ /** The account's New Space defaults, shared with the Spaces app. `verified` is kept for older apps only: today's app makes every new
852
+ * Space verified and ignores it. */
853
+ export interface RoomDefaults { quick?: boolean; enclave?: boolean; verified?: boolean; lanes?: boolean; temporary?: boolean; assistant?: string; model?: string }
854
+
855
+ /** What a member change in place answers. `unreachable`: members with no invite key for THIS app (they never signed in here) —
856
+ * send them `link`. */
857
+ export interface MemberChange { inPlace: true; epoch: number; link?: string; unreachable: string[] }
858
+
859
+ /** `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;
860
+ * a member change seals a Space's new key to it. Persist `state` (a private key) and hand it back as `new Witbitz({ invite })`. */
861
+ export interface InviteAccount {
862
+ readonly state: { boxPub: unknown; boxPriv: unknown; inbox: string; handle?: string; scope?: string; email?: string } | null
863
+ /** '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) */
864
+ readonly status: 'none' | 'held' | 'enrolled' | 'held_elsewhere' | 'failed' | 'vault'
865
+ restore(state: unknown): this
866
+ /** Publish it (signIn and refreshSession do). → the status */
867
+ enroll(): Promise<InviteAccount['status']>
868
+ }
869
+
870
+ /** `wb.a2a` — the account's A2A record. Persist `state` (it holds the lanes' inbox private keys). */
871
+ export interface A2AAccount {
872
+ stopJobAgent(name: string): Promise<{ removed: Array<{ source: string; id: string }> }>
873
+ readonly state: unknown
874
+ readonly endpoint: string
875
+ onState: ((state: unknown) => void) | null
876
+ restore(state: unknown): this
877
+ status(): Promise<unknown>
878
+ revoke(): Promise<unknown>
879
+ }
880
+
881
+ 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 }
882
+ /** `wb.connections` — credentials the standing Sentinel holds and spends for the account. */
883
+ export interface Connections {
884
+ recover(id: string): Promise<Connection | null>
885
+ /** Public picker data shared with the app. Use category 'Agents' for outside agents; no credentials are returned. */
886
+ catalog(opts?: { category?: string }): Array<{ name: string; kind: string; desc: string; cat: string; url?: string; host?: string; registered?: boolean; [k: string]: unknown }>
887
+ spacesUsing(id: string): Promise<{ rooms: string[]; unreadable: string[]; incomplete: boolean }>
888
+ 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'> }
889
+ /** `webhook: true` + `host` = the whole https trigger address: a one-path, POST-only, Bearer connection; `job` makes it an agent that takes jobs. */
890
+ attach(opts: { label?: string; host: string; secret: string; rules?: unknown; limits?: unknown; webhook?: boolean; job?: { field?: string; headers?: Record<string, string> } }): Promise<Connection>
891
+ /** What the Sentinel holds for the account — never a secret. In a vault each also says `grantable`: whether this vault
892
+ * holds its callKey (attached here, or kept from another device with the backup on); `grant` refuses the rest (`not_in_vault`). */
893
+ list(): Promise<Array<{ id: string; label: string; host: string; grantable?: boolean; [k: string]: unknown }>>
894
+ /** Detach everywhere. `spaces`: the Space handles you granted it to — it is dropped from each one's settings too. */
895
+ detach(id: string, opts?: { spaces?: Space[] }): Promise<{ removedFrom: number } & Record<string, unknown>>
896
+ /** Lock the connections the Sentinel still holds in its old form (attached before 2026-11-16, unspent since) under their
897
+ * callKeys — pass the keys your app keeps, as `attach` returned them. No call reaches the service. Refused in a vault: the
898
+ * vault locks what it holds itself when it lists. */
899
+ lock(keys: Record<string, string>): Promise<{ locked: number; failed: number; skipped: number }>
900
+ startConnect(opts: { tenant?: string; providerId: string }): Promise<{ authUrl: string; state: string }>
901
+ finishConnect(opts: { state: string; code: string; label?: string; host?: string }): Promise<Connection>
902
+ /** An MCP server: does it want a sign-in? `needsSignIn: false` → `attachMcp`; else open `authUrl` — `redirectUri` (default
903
+ * `<your origin>/mcp-callback`) receives `?code=&state=` → `finishMcp`. Opens nothing. */
904
+ startMcp(opts: { url: string; label?: string; redirectUri?: string }): Promise<{ needsSignIn: false; host: string } | { needsSignIn: true; authUrl: string; state: string; host: string }>
905
+ /** An MCP server with no sign-in, or with a token you hold (sealed to the Sentinel). */
906
+ attachMcp(opts: { url: string; label?: string; token?: string }): Promise<Connection>
907
+ /** Finish an MCP server's sign-in with your callback's `state` and `code`. */
908
+ finishMcp(opts: { state: string; code: string; label?: string; host?: string }): Promise<Connection>
909
+ /** The tools an MCP connection offers. */
910
+ mcpTools(id: string): Promise<{ tools: Array<{ name: string; title?: string; description?: string; readOnly?: boolean; [k: string]: unknown }>; server: unknown; truncated: boolean }>
911
+ }
912
+
913
+ /** A cloud computer as `wb.computers.list()` shows it — never a secret. */
914
+ export interface ComputerInfo { id: string; name: string; cloud: true; version: number; egress: 'none' | 'trusted' | 'custom' | 'full' | string }
915
+ /** `wb.computers` — the person's cloud computers (docs: § Cloud computers). Kept sealed in this app's account; opened with the
916
+ * same checks as the Witbitz app's Code section; their hours charge the person's AWS key. Not available in vault mode yet
917
+ * (`vault_mode`). Errors carry `code`: not_enabled, sign_in_required, not_found, keys_refused, aws_limit, attestation, declined. */
918
+ export interface Computers {
919
+ setDefaultPrivate(id: string, on: boolean): Promise<void>
920
+ connections(id: string): Promise<Computer['connections']>
921
+ list(): Promise<ComputerInfo[]>
922
+ /** Model keys come from the account (capped) unless `keys` brings the person's own. */
923
+ create(opts?: { name?: string; keys?: { trustedRouter: string; tinfoil?: string; github?: string }; egress?: { mode: string; hosts?: string[] }; browsePrivate?: boolean }): Promise<ComputerInfo>
924
+ /** Start or wake it, check it runs the published Witbitz image (a NEW published image: 'auto' accepts it, 'ask' calls
925
+ * `onNewImage(pcr0, role)`), hand it the person's keys sealed, connect. */
926
+ cachedSessions(id: string): Promise<Array<{ id: string; at: number; msgs: number; title: string; dir: string }>>
927
+ cachedDirectory(id: string): Promise<{ at: number; list: Array<{ id: string; title?: string; directory?: string; time: { created?: number; updated?: number; archived?: number } }> } | null>
928
+ cachedSession(id: string, sessionId: string): Promise<{ msgs: unknown[]; at: number; trimmed: boolean; dir?: string } | null>
929
+ open(id: string, opts?: { cache?: boolean; onStep?(step: 'requesting' | 'starting' | 'verifying' | 'opening' | 'connecting' | string): void; images?: 'auto' | 'ask'; onNewImage?(pcr0: string, role: 'cloud-computer' | 'sentinel'): boolean | Promise<boolean> }): Promise<Computer>
930
+ /** Closed, its account keys cancelled, then removed from the account. */
931
+ close(id: string): Promise<boolean>
932
+ remove(id: string): Promise<void>
933
+ /** This month on the person's AWS key (dollars; show credits: 100 = $1), or null before the first opening. */
934
+ usage(): Promise<{ live: boolean; tier?: 'full' | 'free'; month?: { usd: number; capUsd: number; byKind: Record<string, number> }; resetsAt?: string; why?: string } | null>
935
+ }
936
+ /** One open cloud computer. Every call goes through its connector, which serves only the Code section's own routes. */
937
+ /** Which folder's project a computer call is about: a session's (`session`) or a folder (`dir`). The server scopes by folder. */
938
+ export interface CodePromptOptions {
939
+ model?: string; agent?: string; effort?: string
940
+ files?: Array<{ name?: string; mime?: string; url?: string; path?: string }>
941
+ }
942
+ export interface ComputerScope { session?: string; dir?: string }
943
+
944
+ export interface ComputerKeyGuardRequest { readonly id: string; readonly expires: number; readonly summary: Record<string, unknown>; readonly tag: string }
945
+ export interface Computer {
946
+ readonly id: string
947
+ readonly name: string
948
+ readonly status: 'online' | 'connecting' | 'offline'
949
+ preferredAgent(): Promise<string>
950
+ setPreferredAgent(sessionId: string, agent: string): Promise<string>
951
+ onAutoVerdict(sessionId: string, callback: (event: { sessionID: string; id: string; action: string; reason?: string; answered?: boolean | null }) => void, opts?: { family?: boolean }): () => void
952
+ onProgress(sessionId: string, callback: (event: { sessionID: string; phase: string; label: string; attempt: number; tool: string; subject: string; chars: number }) => void): () => void
953
+ preferredEffort(ref: string): string
954
+ setPreferredEffort(sessionId: string, ref: string, effort: string): Promise<void>
955
+ preferredModel(): Promise<string>
956
+ setPreferredModel(sessionId: string, model: string): Promise<string>
957
+ readonly sessions: {
958
+ list(): Promise<unknown[]>
959
+ create(opts?: { dir?: string; title?: string; agent?: string; model?: string }): Promise<{ id: string; [k: string]: unknown }>
960
+ messages(sessionId: string, opts?: { limit?: number; cursor?: string }): Promise<unknown[]>
961
+ messagePage(sessionId: string, opts?: { limit?: number; cursor?: string }): Promise<{ messages: unknown[]; cursor: string | null }>
962
+ agents(sessionId: string): Promise<Array<{ name: string; description: string }>>
963
+ saveDraft(sessionId: string, parts: Array<{ type: string; [key: string]: unknown }>): string
964
+ listDrafts(sessionId: string): Array<{ id: string; reason: string }>
965
+ getDraft(sessionId: string, id: string): { id: string; reason: string; parts: unknown[] } | null
966
+ discardDraft(sessionId: string, id: string): boolean
967
+ promptLanded(sessionId: string, text: string, knownUserIds: string[] | Set<string>): Promise<boolean>
968
+ watchFirstOutput(sessionId: string, userMessageId: string, onStall: (event: { sessionId: string; userMessageId: string }) => void, options?: { timeoutMs?: number }): () => void
969
+ attachments(sessionId: string, message: { parts?: unknown[] }): Array<{ name: string; size: string; session: string; file: string; copy: string; inline: boolean }>
970
+ readAttachment(sessionId: string, file: string): Promise<{ b64: string; [key: string]: unknown }>
971
+ attachmentWarning(sessionId: string, model: string, file: { mime: string }): Promise<string>
972
+ family(sessionId: string): Promise<{ children: string[]; approvals: unknown[]; questions: unknown[] }>
973
+ approvalMode(sessionId: string): Promise<{ mode: string; modes: string[] }>
974
+ /** `model`: 'provider/model', e.g. 'trustedrouter/deepseek/deepseek-v4-flash'. */
975
+ prompt(sessionId: string, text: string, opts?: CodePromptOptions): Promise<unknown>
976
+ archive(sessionId: string, archived?: boolean): Promise<unknown>
977
+ undo(sessionId: string): Promise<{ changed: boolean; files: boolean }>
978
+ redo(sessionId: string): Promise<{ changed: boolean; files: boolean }>
979
+ compact(sessionId: string, model: string): Promise<unknown>
980
+ models(sessionId: string): Promise<Array<{ ref: string; label: string; input?: string[]; efforts: string[] }>>
981
+ commands(sessionId: string): Promise<Array<{ name: string; description: string; source: string; template: string; agent: string; model: string; needsComputer: boolean }>>
982
+ runCommand(sessionId: string, text: string, opts?: CodePromptOptions): Promise<unknown>
983
+ setApprovalMode(sessionId: string, mode: 'manual' | 'accept' | 'plan' | 'auto'): Promise<{ mode: string }>
984
+ abort(sessionId: string): Promise<unknown>
985
+ rename(sessionId: string, title: string): Promise<unknown>
986
+ remove(sessionId: string): Promise<unknown>
987
+ todo(sessionId: string): Promise<unknown>
988
+ /** { <session id>: status } of every folder the sessions live in, or of one (`session` / `dir`). */
989
+ status(opts?: ComputerScope): Promise<Record<string, unknown>>
990
+ }
991
+ readonly connections: {
992
+ list(): Promise<Array<{ id: string; host: string; label: string; tools: string[]; auto: string[] }>>
993
+ grant(connection: Connection, options?: { tools?: string[]; auto?: string[] }): Promise<void>
994
+ revoke(id: string): Promise<void>
995
+ }
996
+ readonly keyGuard: {
997
+ pending(): Promise<ComputerKeyGuardRequest[]>
998
+ decide(request: ComputerKeyGuardRequest, allow: boolean): Promise<unknown>
999
+ }
1000
+ readonly approvals: {
1001
+ refusalOf(error: string): { kind: 'person' | 'auto' | 'other' | 'cancelled'; reason?: string } | null
1002
+ folders(sessionId: string, approvalId: string): Promise<Array<{ path: string }>>
1003
+ allowFolder(sessionId: string, approvalId: string): Promise<unknown>
1004
+ /** Every approval waiting, in every folder the sessions live in — or in one (`session` / `dir`). */
1005
+ pending(opts?: ComputerScope): Promise<unknown[]>
1006
+ /** A 'reject' may carry a `message` for the model ("stop and ask me"); otherwise the approval's `session` is needed. */
1007
+ answer(id: string, response: 'once' | 'always' | 'reject', opts?: { session?: string; message?: string }): Promise<unknown>
1008
+ }
1009
+ /** `opts`: the folder the question is in (`session` — the event's sessionID — or `dir`); neither = the computer's default project. */
1010
+ readonly questions: { pending(opts?: ComputerScope): Promise<unknown[]>; answer(id: string, answers: string[][], opts?: ComputerScope): Promise<unknown>; dismiss(id: string, opts?: ComputerScope): Promise<unknown> }
1011
+ readonly files: {
1012
+ mkdir(sessionId: string | null, relativeParent: string, name: string): Promise<unknown>
1013
+ /** In a session's folder (`session`) or `dir`; neither = the computer's default project. */
1014
+ list(path?: string, opts?: ComputerScope): Promise<unknown>; changes(opts?: ComputerScope): Promise<unknown>; diff(opts?: ComputerScope): Promise<unknown>
1015
+ /** A file of the session's folder (at most 20 MB, nothing that looks like a secret). Rejects `not_supported` on an older connector. */
1016
+ download(sessionId: string, path: string): Promise<{ name: string; kind?: string; mime: string; size: number; mtime?: number; b64: string }>
1017
+ /** Into folder `dir` (absolute). A name already there: `onExists` 'fail' (rejects `exists`), 'replace' or 'keepBoth' ("name (2).ext"). */
1018
+ 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 }>
1019
+ /** A file a reply produced (`computer.outputs`), screenshots included. */
1020
+ output(sessionId: string, path: string): Promise<{ name: string; mime: string; size?: number; b64: string }>
1021
+ }
1022
+ readonly browser: {
1023
+ /** Session-scoped viewer, including its private-browser control. The key stays in the URL fragment. */
1024
+ url(opts?: { session?: string; take?: boolean }): string | null
1025
+ status(): unknown
1026
+ /** Is the agent's browser in private mode (nothing it visits is kept)? */
1027
+ readonly private: boolean
1028
+ /** Where the computer offers it (`status().canPrivate`); otherwise throws `not_supported`. The next report confirms it. */
1029
+ setPrivate(on: boolean): true
1030
+ /** Set privacy for one session using the encrypted owner channel; waits for confirmation, or rejects with unknown state on timeout. */
1031
+ setDefaultPrivate(on: boolean): Promise<void>
1032
+ setSessionPrivate(session: string, on: boolean): Promise<true>
1033
+ }
1034
+ /** What a reply produced: files it wrote, the browser's screenshots, files its answer names that changed. `messages` omitted = the latest reply. */
1035
+ outputs(sessionId: string, messages?: unknown[]): Promise<Array<{ path: string; kind: 'pdf' | 'image' | 'table' | 'text' | 'file'; source: 'wrote' | 'shot' | 'named' }>>
1036
+ readonly egress: { get(): unknown }
1037
+ /** Live events (OpenCode's): a type such as 'message.part.updated', 'permission.asked', 'session.idle', or '*'. → off
1038
+ * The computer streams per FOLDER: `{ session }` (its folder is looked up) or `{ dir }`; none = the default folder only. */
1039
+ on(type: string, fn: (event: { type: string; properties?: unknown; [k: string]: unknown }) => void, opts?: { session?: string; dir?: string }): () => void
1040
+ /** A last save, then it stops — its hours stop counting. */
1041
+ close(): Promise<boolean>
1042
+ }
1043
+
1044
+ /** `wb.siri` — the account's Siri inbox. Persist `state` (it holds the inbox private keys). */
1045
+ export interface SiriAccount {
1046
+ /** Persist each direct-mode state change, including a removal awaiting confirmation. */
1047
+ onState: ((state: unknown) => void) | null
1048
+ readonly state: unknown
1049
+ readonly shortcut: { key: string | null; endpoint: string }
1050
+ restore(state: unknown): this
1051
+ sync(): Promise<{ synced: boolean }>
1052
+ status(): Promise<unknown>
1053
+ /** In a vault: resolves `null` — the new key is shown in the vault's own screen (wb.vault.showSiriKey). */
1054
+ rotateKey(): Promise<string | null>
1055
+ revoke(): Promise<unknown>
1056
+ }
1057
+
1058
+ /** `wb.usernames` — the signed-in member's global @username. */
1059
+ export interface Usernames {
1060
+ /** → `{ username }`; whether it is listed in the directory: `mine()`. */
1061
+ claim(name: string, opts?: { publish?: boolean; name?: string }): Promise<{ username: string }>
1062
+ release(): Promise<unknown>
1063
+ mine(): Promise<{ username: string | null; published?: boolean }>
1064
+ resolve(name: string): Promise<{ username: string; exists: boolean }>
1065
+ }
1066
+
1067
+ /** wb.speech (sdk-assistant.md#speak). `play` rejects with `no_hebrew`, `empty`, `sign_in_required`, `tts_rate_limited`, `tts_unavailable`, `http_<n>`, `audio`, `play`. */
1068
+ export interface Speech {
1069
+ readonly playing: boolean
1070
+ play(text: string): Promise<void>
1071
+ stop(): void
1072
+ }
1073
+ export interface Dictation {
1074
+ readonly listening: boolean
1075
+ start(opts?: { engine?: 'device' | 'cloud'; room?: string; onPartial?(t: string): void; onLevel?(rms: number): void }): Promise<void>
1076
+ stopCertified(): Promise<DictationResult>
1077
+ stop(): Promise<string>
1078
+ cancel(): void
1079
+ close(): void
1080
+ }
1081
+
1082
+ import type { Origins, DeclaredHosts, Providers, TenantRooms, Customers, Billing } from './witbitz-admin'
1083
+
1084
+ export type VaultAccountIndex = Omit<AccountIndex, 'rooms' | 'onChange' | 'archive' | 'pin' | 'rename' | 'forget' | 'signOut' | 'sync' | 'start' | 'stop' | 'signOutDevice' | 'chatLocks'> & {
1085
+ readonly chatLocks: Omit<AccountIndex['chatLocks'], 'deleteAll'> & { deleteAll(): ReturnType<AccountIndex['chatLocks']['deleteAll']> }
1086
+ signOutDevice(deviceId: string): Promise<{ revoked: boolean }>
1087
+ readonly rooms: ReadonlyArray<Omit<AccountBackup['rooms'][number], 'link'>>
1088
+ onChange: ((index: Pick<VaultAccountIndex, 'rooms' | 'devices'>) => void) | null
1089
+ archive(room: string, on?: boolean): Promise<object>
1090
+ pin(room: string, on?: boolean): Promise<object>
1091
+ rename(room: string, label: string): Promise<object>
1092
+ forget(room: string): Promise<object>
1093
+ signOut(deviceId: string): Promise<{ revoked?: boolean; error?: string }>
1094
+ sync(): Promise<{ ok: boolean; rooms: VaultAccountIndex['rooms']; devices: AccountIndex['devices']; signedOut?: boolean }>
1095
+ start(opts?: { every?: number }): Promise<object>
1096
+ stop(): Promise<object>
1097
+ }
1098
+
1099
+ export declare class Witbitz {
1100
+ setAssistantMemory(spaces?: Space[]): void
1101
+ readonly temporaryRooms: {
1102
+ list(): Promise<Array<{ room: string; at: number; title: string; status: 'recent' | 'live' | 'unknown' }>>
1103
+ open(room: string, options?: Parameters<Witbitz['openSpace']>[1]): Promise<Space>
1104
+ }
1105
+ constructor(opts?: WitbitzOptions)
1106
+ /** VAULT MODE: this page is framed by a vault you host on another origin, which keeps every room key. Rejects
1107
+ * `not_in_vault` when the page is not framed by that origin. Create, read and send as usual; sign-in and sharing
1108
+ * happen in the vault (`wb.vault`). A link is opened by the vault, not by openSpace. Refuses by name a `session`
1109
+ * (`vault_signs_in`), `attest`, and a persisted `backup` / `siri` / `a2a` / `invite` state (`vault_unsupported`): the vault keeps the account. */
1110
+ static inVault(opts: VaultOptions): Promise<Omit<Witbitz, 'account' | 'backup' | 'vault'> & { readonly vault: VaultSession; readonly account: VaultAccountIndex; readonly backup: VaultAccountBackup }>
1111
+ /** The vault this page runs in — set by {@link Witbitz.inVault}, else null. */
1112
+ readonly vault: VaultSession | null
1113
+ readonly session: Session | null
1114
+ readonly backup: AccountBackup
1115
+ /** Device storage protection for what the app keeps on the device (sdkProtect.js). */
1116
+ readonly protect: Protect
1117
+ readonly account: AccountIndex
1118
+ /** The tenant's erase of a user (`admin.customers.erase`) reaches the rooms this account created (sdkErase.js). */
1119
+ readonly erasure: Erasure
1120
+ /** Which enclave build this person accepts — `new Witbitz({ builds: 'mine' })`. */
1121
+ readonly builds: Builds
1122
+ readonly a2a: A2AAccount
1123
+ readonly invite: InviteAccount
1124
+ readonly connections: Connections
1125
+ readonly cloudDevice: {
1126
+ status(): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string; waiting?: string; last?: Record<string, unknown> }>; builds: unknown }>
1127
+ /** Sign the device into this app; getCode is asked only outside a vault. */
1128
+ enroll(opts?: { getCode?: () => Promise<string> }): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string }>; builds: unknown }>
1129
+ register(opts?: { getCode?: () => Promise<string> }): Promise<{ email: string | null; registered: boolean; rooms: Array<{ room: string }>; builds: unknown }>
1130
+ setBuilds(state: { builds: unknown[]; auto?: { on: boolean; at: number } }): Promise<unknown>
1131
+ forget(): Promise<{ forgotten: true }>
1132
+ }
1133
+ /** The person's cloud computers (§ Cloud computers). */
1134
+ readonly computers: Computers
1135
+ readonly siri: SiriAccount
1136
+ readonly usernames: Usernames
1137
+ recreateSpace(bundle: { kind: string; entries: unknown[]; config?: Record<string, unknown>; tier?: Tier }, opts?: { tier?: Tier }): Promise<{ space: Space; carried: number; total: number; titleWarning?: string }>
1138
+ saveOfflineReader(): Promise<void>
1139
+ exportOfflineArchive(opts?: { recoveryKeys?: boolean; rooms?: Space[]; destination?: 'download' | 'clipboard' }): Promise<{ saved: number; unavailable: string[] }>
1140
+ createSpace(opts: { /** @deprecated retired in 4.0.0 — `owner` rejects with `owner_rule_retired` */ owner?: never; skills?: Record<string, { in: Record<string, 'string' | 'number' | 'boolean' | 'array' | 'object'>; out?: Record<string, 'string' | 'number' | 'boolean' | 'array' | 'object'> }>; clientTools?: ToolDef[]; agentReplies?: boolean; agent?: AgentSpec; tools?: ToolDef[]; immediateTools?: string[]; model?: AgentSpec['model']; data?: Record<string, unknown>; platformTools?: PlatformTools; framing?: Framing; dataWrites?: boolean; /** a direct chat with this address (sdk-people.md#direct-chats) — instead of admission */ direct?: string; usernames?: boolean; admission?: Admission; tier?: Tier; key?: 'split'; region?: string; /** a room wiped when idle: true (≈30 min), or { days } (1–7) after its last question (sdk-rooms.md#temporary) */ temporary?: true | { days: number; title?: string }; /** others' photos and PDFs shown only from copies an attested enclave made safe (sdk-rooms.md#safe-media) */ safeMedia?: boolean; /** every member gets a private assistant (sdk-agents.md#lanes-for-everyone) */ lanes?: boolean }): Promise<Space>
1141
+ /** `link` is REQUIRED (a share link: `<viewer>/space?room=…#mk=…`); the current page URL is not read for you. */
1142
+ openSpace(link: string, opts?: { resume?: Snapshot; tier?: Tier }): Promise<Space>
1143
+ /** 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. */
1144
+ /** Rejects with `lane_of_lane` when `space` is itself a lane (open the lane on its Space). */
1145
+ openLane(laneLink: string, opts: { space: Space; actions?: LaneAction[]; resume?: Snapshot; tier?: Tier; mirror?: boolean | { data?: boolean } }): Promise<Lane>
1146
+ signIn(opts: { email: string; code?: string; ticket?: string; room?: string }): Promise<{ ticket: string; email: string } | Session>
1147
+ refreshSession(): Promise<Session>
1148
+ signOut(): this
1149
+ useSession(session: Session | null): this
1150
+ useUserToken(token: string | (() => string | Promise<string>) | null): this
1151
+ models(opts?: { tier?: Tier }): Promise<Array<{ id: string; efforts?: Effort[] | null; [k: string]: unknown }>>
1152
+ dictation(): Dictation
1153
+ /** Text read aloud (sdk-assistant.md#speak) — the Spaces app's "Play aloud" player. */
1154
+ readonly speech: Speech
1155
+ /** Read `text` aloud → resolves when it has played. */
1156
+ speak(text: string): Promise<void>
1157
+ /** Feature detection: this SDK's version and features, the limits, the tiers and models this deployment serves. */
1158
+ capabilities(): Promise<{ sdk: string; endpoint: string; features: string[]; limits: Record<string, number>; tiers: { standard: true; enclave: boolean | null }; models: { regular: string[]; confidential: string[] } | null }>
1159
+ toJSON(): { viewer: string; tenant?: string; signedIn: boolean; tenantKey?: '[REDACTED]' }
1160
+ // ── Builder calls (server only). Deprecated here: use WitbitzAdmin (witbitz-admin.js); `users` is `customers` there.
1161
+ /** @deprecated use `new WitbitzAdmin(…).verifyTenantKey()` */
1162
+ verifyTenantKey(): Promise<{ ok: true; tenant: string } | { ok: false; reason: string; code?: string }>
1163
+ /** @deprecated use WitbitzAdmin */ readonly origins: Origins
1164
+ /** @deprecated use WitbitzAdmin */ readonly hosts: DeclaredHosts
1165
+ /** @deprecated use WitbitzAdmin */ readonly providers: Providers
1166
+ /** @deprecated use WitbitzAdmin */ readonly rooms: TenantRooms
1167
+ /** @deprecated use WitbitzAdmin's `customers` */ readonly users: Customers
1168
+ /** @deprecated use WitbitzAdmin */ readonly billing: Billing
1169
+ }
1170
+ export default Witbitz
1171
+
1172
+ // ─── Helpers ──────────────────────────────────────────────────────────────────────────────────────────────────────────
1173
+ export declare const LIMITS: Readonly<Record<string, number>>
1174
+ export declare const EFFORTS: readonly Effort[]
1175
+ /** 'dev' on the live build; the release number in /sdk/<version>/. */
1176
+ export declare const SDK_VERSION: string
1177
+ /** Throws `limit_exceeded` for a list of actions offered to one turn that the server would cut or drop. */
1178
+ export declare function checkActions(actions: LaneAction[]): void
1179
+ /** Throws `invalid_effort` when `model` names a reasoning effort the model does not take. `catalog` = wb.models(). */
1180
+ export declare function checkModelEffort(model: AgentSpec['model'], catalog?: Array<{ id: string; efforts?: Effort[] | null }>): void
1181
+ /** Throws `limit_exceeded` for a `data` schema the server would cut, drop or rename. */
1182
+ export declare function checkDataSchema(data: Record<string, unknown>): void
1183
+ /** 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". */
1184
+ export declare function isLaneCopy(m: Message | Record<string, unknown>): boolean
1185
+
1186
+ // AG-UI 1.0 (sdk-agents.md#ag-ui)
1187
+ export declare function aguiRun(space: Space, input: { threadId?: string; runId?: string; messages?: unknown[]; context?: unknown[]; resume?: unknown }, opts?: { from?: string; mode?: ReplyMode; timeoutMs?: number; graceMs?: number; signal?: AbortSignal }): AsyncIterable<Record<string, unknown>>
1188
+ export declare function aguiHistory(space: Space): unknown[]
1189
+ export declare function aguiAgent(lib: { AbstractAgent: unknown; Observable: unknown }, space: Space, opts?: { threadId?: string; agentConfig?: Record<string, unknown>; [k: string]: unknown }): unknown
1190
+
1191
+ // RATS / EAT (sdk-keys.md#eat)
1192
+ export declare const EAT_PROFILE: string
1193
+ 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 }>
1194
+ 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 }>
1195
+
1196
+ /** Built-in assistant templates, including their reusable instructions. */
1197
+ export function assistantTemplates(): Array<{ id: string; name: string; sub: string; agentName: string; persona: string }>