@eloxiv/client 0.0.0-stage → 0.1.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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +6 -2
  3. package/dist/Account.d.ts +131 -0
  4. package/dist/Account.d.ts.map +1 -0
  5. package/dist/Account.js +169 -0
  6. package/dist/Account.js.map +1 -0
  7. package/dist/Agent.d.ts +496 -0
  8. package/dist/Agent.d.ts.map +1 -0
  9. package/dist/Agent.js +228 -0
  10. package/dist/Agent.js.map +1 -0
  11. package/dist/AgentSync.d.ts +990 -0
  12. package/dist/AgentSync.d.ts.map +1 -0
  13. package/dist/AgentSync.js +46 -0
  14. package/dist/AgentSync.js.map +1 -0
  15. package/dist/AppState.d.ts +127 -0
  16. package/dist/AppState.d.ts.map +1 -0
  17. package/dist/AppState.js +145 -0
  18. package/dist/AppState.js.map +1 -0
  19. package/dist/AppStateSync.d.ts +193 -0
  20. package/dist/AppStateSync.d.ts.map +1 -0
  21. package/dist/AppStateSync.js +23 -0
  22. package/dist/AppStateSync.js.map +1 -0
  23. package/dist/Auth.d.ts +95 -0
  24. package/dist/Auth.d.ts.map +1 -0
  25. package/dist/Auth.js +139 -0
  26. package/dist/Auth.js.map +1 -0
  27. package/dist/Avatars.d.ts +53 -0
  28. package/dist/Avatars.d.ts.map +1 -0
  29. package/dist/Avatars.js +121 -0
  30. package/dist/Avatars.js.map +1 -0
  31. package/dist/BrowserAnalytics.d.ts +56 -0
  32. package/dist/BrowserAnalytics.d.ts.map +1 -0
  33. package/dist/BrowserAnalytics.js +94 -0
  34. package/dist/BrowserAnalytics.js.map +1 -0
  35. package/dist/Chat.d.ts +712 -0
  36. package/dist/Chat.d.ts.map +1 -0
  37. package/dist/Chat.js +883 -0
  38. package/dist/Chat.js.map +1 -0
  39. package/dist/ChatIntegrity.d.ts +63 -0
  40. package/dist/ChatIntegrity.d.ts.map +1 -0
  41. package/dist/ChatIntegrity.js +89 -0
  42. package/dist/ChatIntegrity.js.map +1 -0
  43. package/dist/ChatSends.d.ts +103 -0
  44. package/dist/ChatSends.d.ts.map +1 -0
  45. package/dist/ChatSends.js +157 -0
  46. package/dist/ChatSends.js.map +1 -0
  47. package/dist/Client.d.ts +113 -0
  48. package/dist/Client.d.ts.map +1 -0
  49. package/dist/Client.js +189 -0
  50. package/dist/Client.js.map +1 -0
  51. package/dist/Collab.d.ts +138 -0
  52. package/dist/Collab.d.ts.map +1 -0
  53. package/dist/Collab.js +454 -0
  54. package/dist/Collab.js.map +1 -0
  55. package/dist/CollabTools.d.ts +129 -0
  56. package/dist/CollabTools.d.ts.map +1 -0
  57. package/dist/CollabTools.js +277 -0
  58. package/dist/CollabTools.js.map +1 -0
  59. package/dist/Connections.d.ts +288 -0
  60. package/dist/Connections.d.ts.map +1 -0
  61. package/dist/Connections.js +316 -0
  62. package/dist/Connections.js.map +1 -0
  63. package/dist/Consent.d.ts +338 -0
  64. package/dist/Consent.d.ts.map +1 -0
  65. package/dist/Consent.js +142 -0
  66. package/dist/Consent.js.map +1 -0
  67. package/dist/Desktop.d.ts +61 -0
  68. package/dist/Desktop.d.ts.map +1 -0
  69. package/dist/Desktop.js +101 -0
  70. package/dist/Desktop.js.map +1 -0
  71. package/dist/Directory.d.ts +36 -0
  72. package/dist/Directory.d.ts.map +1 -0
  73. package/dist/Directory.js +42 -0
  74. package/dist/Directory.js.map +1 -0
  75. package/dist/ErrorReporter.d.ts +48 -0
  76. package/dist/ErrorReporter.d.ts.map +1 -0
  77. package/dist/ErrorReporter.js +70 -0
  78. package/dist/ErrorReporter.js.map +1 -0
  79. package/dist/ExpoSqlite.d.ts +7 -0
  80. package/dist/ExpoSqlite.d.ts.map +1 -0
  81. package/dist/ExpoSqlite.js +7 -0
  82. package/dist/ExpoSqlite.js.map +1 -0
  83. package/dist/FileSync.d.ts +265 -0
  84. package/dist/FileSync.d.ts.map +1 -0
  85. package/dist/FileSync.js +29 -0
  86. package/dist/FileSync.js.map +1 -0
  87. package/dist/FileTables.gen.d.ts +109 -0
  88. package/dist/FileTables.gen.d.ts.map +1 -0
  89. package/dist/FileTables.gen.js +23 -0
  90. package/dist/FileTables.gen.js.map +1 -0
  91. package/dist/Foldkit.d.ts +487 -0
  92. package/dist/Foldkit.d.ts.map +1 -0
  93. package/dist/Foldkit.js +617 -0
  94. package/dist/Foldkit.js.map +1 -0
  95. package/dist/History.d.ts +133 -0
  96. package/dist/History.d.ts.map +1 -0
  97. package/dist/History.js +210 -0
  98. package/dist/History.js.map +1 -0
  99. package/dist/InboxSync.d.ts +428 -0
  100. package/dist/InboxSync.d.ts.map +1 -0
  101. package/dist/InboxSync.js +37 -0
  102. package/dist/InboxSync.js.map +1 -0
  103. package/dist/KernelTables.gen.d.ts +1522 -0
  104. package/dist/KernelTables.gen.d.ts.map +1 -0
  105. package/dist/KernelTables.gen.js +307 -0
  106. package/dist/KernelTables.gen.js.map +1 -0
  107. package/dist/Make.d.ts +75 -0
  108. package/dist/Make.d.ts.map +1 -0
  109. package/dist/Make.js +70 -0
  110. package/dist/Make.js.map +1 -0
  111. package/dist/Models.d.ts +88 -0
  112. package/dist/Models.d.ts.map +1 -0
  113. package/dist/Models.js +80 -0
  114. package/dist/Models.js.map +1 -0
  115. package/dist/Optimistic.d.ts +120 -0
  116. package/dist/Optimistic.d.ts.map +1 -0
  117. package/dist/Optimistic.js +231 -0
  118. package/dist/Optimistic.js.map +1 -0
  119. package/dist/PlatformSync.d.ts +273 -0
  120. package/dist/PlatformSync.d.ts.map +1 -0
  121. package/dist/PlatformSync.js +92 -0
  122. package/dist/PlatformSync.js.map +1 -0
  123. package/dist/Poll.d.ts +113 -0
  124. package/dist/Poll.d.ts.map +1 -0
  125. package/dist/Poll.js +179 -0
  126. package/dist/Poll.js.map +1 -0
  127. package/dist/Preferences.d.ts +18 -0
  128. package/dist/Preferences.d.ts.map +1 -0
  129. package/dist/Preferences.js +22 -0
  130. package/dist/Preferences.js.map +1 -0
  131. package/dist/Proposals.d.ts +29 -0
  132. package/dist/Proposals.d.ts.map +1 -0
  133. package/dist/Proposals.js +41 -0
  134. package/dist/Proposals.js.map +1 -0
  135. package/dist/React.d.ts +17 -0
  136. package/dist/React.d.ts.map +1 -0
  137. package/dist/React.js +17 -0
  138. package/dist/React.js.map +1 -0
  139. package/dist/Reader.d.ts +35 -0
  140. package/dist/Reader.d.ts.map +1 -0
  141. package/dist/Reader.js +136 -0
  142. package/dist/Reader.js.map +1 -0
  143. package/dist/Resources.d.ts +98 -0
  144. package/dist/Resources.d.ts.map +1 -0
  145. package/dist/Resources.js +161 -0
  146. package/dist/Resources.js.map +1 -0
  147. package/dist/Rows.d.ts +4 -0
  148. package/dist/Rows.d.ts.map +1 -0
  149. package/dist/Rows.js +16 -0
  150. package/dist/Rows.js.map +1 -0
  151. package/dist/Runtime.d.ts +254 -0
  152. package/dist/Runtime.d.ts.map +1 -0
  153. package/dist/Runtime.js +1249 -0
  154. package/dist/Runtime.js.map +1 -0
  155. package/dist/RuntimeRuns.d.ts +74 -0
  156. package/dist/RuntimeRuns.d.ts.map +1 -0
  157. package/dist/RuntimeRuns.js +118 -0
  158. package/dist/RuntimeRuns.js.map +1 -0
  159. package/dist/ServicesSync.d.ts +286 -0
  160. package/dist/ServicesSync.d.ts.map +1 -0
  161. package/dist/ServicesSync.js +40 -0
  162. package/dist/ServicesSync.js.map +1 -0
  163. package/dist/Session.d.ts +226 -0
  164. package/dist/Session.d.ts.map +1 -0
  165. package/dist/Session.js +763 -0
  166. package/dist/Session.js.map +1 -0
  167. package/dist/ShareGrant.d.ts +47 -0
  168. package/dist/ShareGrant.d.ts.map +1 -0
  169. package/dist/ShareGrant.js +20 -0
  170. package/dist/ShareGrant.js.map +1 -0
  171. package/dist/Sharing.d.ts +203 -0
  172. package/dist/Sharing.d.ts.map +1 -0
  173. package/dist/Sharing.js +520 -0
  174. package/dist/Sharing.js.map +1 -0
  175. package/dist/Skew.d.ts +52 -0
  176. package/dist/Skew.d.ts.map +1 -0
  177. package/dist/Skew.js +77 -0
  178. package/dist/Skew.js.map +1 -0
  179. package/dist/SpacesSync.d.ts +247 -0
  180. package/dist/SpacesSync.d.ts.map +1 -0
  181. package/dist/SpacesSync.js +30 -0
  182. package/dist/SpacesSync.js.map +1 -0
  183. package/dist/Storage.d.ts +51 -0
  184. package/dist/Storage.d.ts.map +1 -0
  185. package/dist/Storage.js +107 -0
  186. package/dist/Storage.js.map +1 -0
  187. package/dist/Sync.d.ts +48 -0
  188. package/dist/Sync.d.ts.map +1 -0
  189. package/dist/Sync.js +48 -0
  190. package/dist/Sync.js.map +1 -0
  191. package/dist/SyncTables.d.ts +13 -0
  192. package/dist/SyncTables.d.ts.map +1 -0
  193. package/dist/SyncTables.js +13 -0
  194. package/dist/SyncTables.js.map +1 -0
  195. package/dist/Tab.d.ts +36 -0
  196. package/dist/Tab.d.ts.map +1 -0
  197. package/dist/Tab.js +44 -0
  198. package/dist/Tab.js.map +1 -0
  199. package/dist/Transport.d.ts +139 -0
  200. package/dist/Transport.d.ts.map +1 -0
  201. package/dist/Transport.js +232 -0
  202. package/dist/Transport.js.map +1 -0
  203. package/dist/Upload.d.ts +41 -0
  204. package/dist/Upload.d.ts.map +1 -0
  205. package/dist/Upload.js +93 -0
  206. package/dist/Upload.js.map +1 -0
  207. package/dist/WebMcp.d.ts +78 -0
  208. package/dist/WebMcp.d.ts.map +1 -0
  209. package/dist/WebMcp.js +204 -0
  210. package/dist/WebMcp.js.map +1 -0
  211. package/dist/index.d.ts +27 -0
  212. package/dist/index.d.ts.map +1 -0
  213. package/dist/index.js +27 -0
  214. package/dist/index.js.map +1 -0
  215. package/package.json +97 -3
  216. package/src/Account.ts +249 -0
  217. package/src/Agent.ts +387 -0
  218. package/src/AgentSync.ts +59 -0
  219. package/src/AppState.ts +222 -0
  220. package/src/AppStateSync.ts +26 -0
  221. package/src/Auth.ts +225 -0
  222. package/src/Avatars.ts +144 -0
  223. package/src/BrowserAnalytics.ts +133 -0
  224. package/src/Chat.ts +1150 -0
  225. package/src/ChatIntegrity.ts +130 -0
  226. package/src/ChatSends.ts +209 -0
  227. package/src/Client.ts +319 -0
  228. package/src/Collab.ts +524 -0
  229. package/src/CollabTools.ts +381 -0
  230. package/src/Connections.ts +517 -0
  231. package/src/Consent.ts +176 -0
  232. package/src/Desktop.ts +139 -0
  233. package/src/Directory.ts +71 -0
  234. package/src/ErrorReporter.ts +112 -0
  235. package/src/ExpoSqlite.ts +6 -0
  236. package/src/FileSync.ts +34 -0
  237. package/src/FileTables.gen.ts +23 -0
  238. package/src/Foldkit.ts +960 -0
  239. package/src/History.ts +337 -0
  240. package/src/InboxSync.ts +47 -0
  241. package/src/KernelTables.gen.ts +329 -0
  242. package/src/Make.ts +120 -0
  243. package/src/Models.ts +134 -0
  244. package/src/Optimistic.ts +364 -0
  245. package/src/PlatformSync.ts +156 -0
  246. package/src/Poll.ts +227 -0
  247. package/src/Preferences.ts +42 -0
  248. package/src/Proposals.ts +57 -0
  249. package/src/React.ts +26 -0
  250. package/src/Reader.ts +180 -0
  251. package/src/Resources.ts +257 -0
  252. package/src/Rows.ts +16 -0
  253. package/src/Runtime.ts +1409 -0
  254. package/src/RuntimeRuns.ts +180 -0
  255. package/src/ServicesSync.ts +58 -0
  256. package/src/Session.ts +814 -0
  257. package/src/ShareGrant.ts +20 -0
  258. package/src/Sharing.ts +696 -0
  259. package/src/Skew.ts +97 -0
  260. package/src/SpacesSync.ts +61 -0
  261. package/src/Storage.ts +167 -0
  262. package/src/Sync.ts +125 -0
  263. package/src/SyncTables.ts +12 -0
  264. package/src/Tab.ts +59 -0
  265. package/src/Transport.ts +321 -0
  266. package/src/Upload.ts +125 -0
  267. package/src/WebMcp.ts +279 -0
  268. package/src/index.ts +26 -0
  269. package/src/web-globals.d.ts +103 -0
package/dist/Chat.d.ts ADDED
@@ -0,0 +1,712 @@
1
+ /**
2
+ * The headless chat SDK (decision 11): the state a chat screen, its approval and consent prompts and an inbox
3
+ * render, and the operations they run, with no view code. Any UI (the Foldkit shell's reference chat screen, or an
4
+ * app's own) keeps a `ChatState` in its model, feeds it what the replica and the run's event stream deliver, and
5
+ * renders what it derives; the guarantees that are hard to get right are here, once:
6
+ *
7
+ * - **One conversation at a time, its own rows only.** The transcript holds the conversation's stored messages (from
8
+ * the replica: `agent.messages`, already filtered to the person and the organisation they act in), in order, and
9
+ * the active run's streamed text; nothing of another conversation.
10
+ * - **Streamed text by model step, never twice.** A run's model steps each store one answer, in order. Streamed text
11
+ * names its step (`data.step`) and the model call of that step it comes from (`data.attempt`: a step's call is made
12
+ * again after a restart, from the start); each step's text shows until the replica holds that step's stored
13
+ * answer, which then replaces it, and a new call's text replaces the earlier call's. An earlier step's answer (a
14
+ * tool call) never hides a later step's text, and a later step's text that arrives before the earlier step's
15
+ * stored event (streamed text is pushed at once, stored events are read from the database) is kept.
16
+ * - **Events only from the run they belong to.** A run's events (consent asked and decided, the end) change the state
17
+ * only for the conversation's active run; a late event of a run since finished, or of another conversation's, is
18
+ * dropped. The stream's `run-finished` ends the run at once, whatever the replica still says.
19
+ * - **A send is one send.** The composer sends only a non-empty draft and only when nothing is in flight and no run
20
+ * is going (a run the kernel accepted counts from its answer, before the replica has it). Each send carries an
21
+ * idempotency key, its identity, kept outside any screen (`ChatSends.ts`: written ahead, per person and
22
+ * organisation, settled only by a definitive outcome for its key). A send whose answer was lost may have run: it
23
+ * is resent under its key; one the kernel could not confirm after that is kept, shown, until its receipt is found
24
+ * (`chatClient.lookup`) or the person discards it; one held for an approval or consent is kept, waiting. An answer
25
+ * counts only for the request it answers, and changes the conversation shown only if it came from it. A refusal
26
+ * is kept as its typed error, with the draft.
27
+ * - **Consent and approval are the person's.** Pending consent comes only from the run's `consent-required` events
28
+ * and leaves only on `consent-decided` (or the run's end); approvals come from the replica (`approvals.requests`).
29
+ * Deciding either is an action of the kernel's, which refuses an agent: this SDK never decides on its own. Each
30
+ * decision (and a cancel) carries a key of its own (the consent's or approval's id and the decision; the run's),
31
+ * the same on every retry, so a retry after a lost answer decides once.
32
+ * - **Nothing of the conversation outlives the session or the organisation.** The state is a value: a UI drops it
33
+ * (and its event stream, whose connection closes as soon as it is interrupted, even while silent) when the person
34
+ * signs out or switches organisation, and makes a new one. Outstanding sends are the exception, by design: they are
35
+ * the person's, kept in the outstanding store and fed back to the next state (`withOutstanding`).
36
+ */
37
+ import { EngineReadiness, EntityReference, RunDevice, type RunEvent } from "@eloxiv/contracts";
38
+ import { Duration, Effect, Schema, Stream } from "effect";
39
+ import { ChatError, OutstandingSend } from "./ChatSends.ts";
40
+ export * from "./ChatSends.ts";
41
+ /** What people see an action called, from its recorded title or its readable name (`@eloxiv/contracts`). */
42
+ export { actionLabel, decisionLabel, makeDecisionLabel, readableActionName } from "@eloxiv/contracts";
43
+ export * from "./ChatIntegrity.ts";
44
+ /** A stored message of a conversation, as the replica delivers it (`agent.messages`). */
45
+ export declare const ChatMessage: Schema.Struct<{
46
+ readonly id: Schema.String;
47
+ readonly conversationId: Schema.String;
48
+ readonly runId: Schema.NullOr<Schema.String>;
49
+ readonly seq: Schema.Number;
50
+ readonly role: Schema.Literals<readonly ["user", "assistant", "tool", "summary"]>;
51
+ readonly text: Schema.String;
52
+ /** Set when the message left the conversation: compacted into a summary, or after a restored checkpoint (`restore:`). */
53
+ readonly coveredBy: Schema.optionalKey<Schema.NullOr<Schema.String>>;
54
+ }>;
55
+ export type ChatMessage = typeof ChatMessage.Type;
56
+ /** A run of a conversation, as the replica delivers it (`agent.runs`). */
57
+ export declare const ChatRun: Schema.Struct<{
58
+ readonly id: Schema.String;
59
+ readonly conversationId: Schema.String;
60
+ readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "succeeded", "stopped", "failed", "cancelled"]>;
61
+ readonly error: Schema.NullOr<Schema.String>;
62
+ readonly createdAt: Schema.Number;
63
+ }>;
64
+ export type ChatRun = typeof ChatRun.Type;
65
+ /** A tool call the run holds for the person's consent (from its `consent-required` event). */
66
+ export declare const PendingConsent: Schema.Struct<{
67
+ readonly consentId: Schema.String;
68
+ readonly runId: Schema.String;
69
+ readonly action: Schema.String;
70
+ /**
71
+ * What the person sees the action called: the event's `title` (the action's title as it was when the call was
72
+ * held), or, from a kernel that sends none, the action's readable name; a MAKE action's from its id alone
73
+ * (`decisionLabel`). Never the raw id.
74
+ */
75
+ readonly title: Schema.String;
76
+ }>;
77
+ export type PendingConsent = typeof PendingConsent.Type;
78
+ /** A send: its text, the conversation it was sent from (null for a new one) and its idempotency key. */
79
+ export declare const SendRequest: Schema.Struct<{
80
+ readonly text: Schema.String;
81
+ readonly conversationId: Schema.NullOr<Schema.String>;
82
+ readonly key: Schema.String;
83
+ /** The paired device it runs on (none: the deployment's model). */
84
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
85
+ readonly deviceId: Schema.String;
86
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
87
+ readonly model: Schema.optionalKey<Schema.String>;
88
+ readonly cwd: Schema.optionalKey<Schema.String>;
89
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
90
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
91
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
92
+ readonly followUp: Schema.optionalKey<Schema.String>;
93
+ }>>>;
94
+ }>;
95
+ export type SendRequest = typeof SendRequest.Type;
96
+ /**
97
+ * Named context staged for the next send (a record a screen offered, a selection, a note): sent with it, below the
98
+ * text, then cleared. At most `CONTEXT_LIMIT` items and `CONTEXT_CHARS` characters in all.
99
+ */
100
+ export declare const StagedContext: Schema.Struct<{
101
+ readonly name: Schema.String;
102
+ readonly text: Schema.String;
103
+ /** The record it is about, if any (shown to the agent as a reference; the agent reads it through its tools). */
104
+ readonly reference: Schema.optionalKey<Schema.Struct<{
105
+ readonly module: Schema.String;
106
+ readonly entity: Schema.String;
107
+ readonly id: Schema.String;
108
+ }>>;
109
+ }>;
110
+ export type StagedContext = typeof StagedContext.Type;
111
+ export declare const CONTEXT_LIMIT = 10;
112
+ export declare const CONTEXT_CHARS = 16000;
113
+ export declare const Composer: Schema.Struct<{
114
+ readonly draft: Schema.String;
115
+ /**
116
+ * Where the next send runs: one of the person's paired devices (its harness, on their own subscription; the kernel
117
+ * asks the person's consent to send the turn there), or the deployment's model (none).
118
+ */
119
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
120
+ readonly deviceId: Schema.String;
121
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
122
+ readonly model: Schema.optionalKey<Schema.String>;
123
+ readonly cwd: Schema.optionalKey<Schema.String>;
124
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
125
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
126
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
127
+ readonly followUp: Schema.optionalKey<Schema.String>;
128
+ }>>>;
129
+ /** Context staged for the next send (`stageContext`). */
130
+ readonly context: Schema.optionalKey<Schema.$Array<Schema.Struct<{
131
+ readonly name: Schema.String;
132
+ readonly text: Schema.String;
133
+ /** The record it is about, if any (shown to the agent as a reference; the agent reads it through its tools). */
134
+ readonly reference: Schema.optionalKey<Schema.Struct<{
135
+ readonly module: Schema.String;
136
+ readonly entity: Schema.String;
137
+ readonly id: Schema.String;
138
+ }>>;
139
+ }>>>;
140
+ /** This state's send in flight (one at a time). */
141
+ readonly sending: Schema.NullOr<Schema.Struct<{
142
+ readonly text: Schema.String;
143
+ readonly conversationId: Schema.NullOr<Schema.String>;
144
+ readonly key: Schema.String;
145
+ /** The paired device it runs on (none: the deployment's model). */
146
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
147
+ readonly deviceId: Schema.String;
148
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
149
+ readonly model: Schema.optionalKey<Schema.String>;
150
+ readonly cwd: Schema.optionalKey<Schema.String>;
151
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
152
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
153
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
154
+ readonly followUp: Schema.optionalKey<Schema.String>;
155
+ }>>>;
156
+ }>>;
157
+ /**
158
+ * The person's sends in this organisation whose outcome is not settled, every conversation's: what the outstanding
159
+ * store keeps (`withOutstanding`), with this state's own changes.
160
+ */
161
+ readonly outstanding: Schema.$Array<Schema.Struct<{
162
+ readonly text: Schema.String;
163
+ readonly conversationId: Schema.NullOr<Schema.String>;
164
+ readonly key: Schema.String;
165
+ readonly state: Schema.Literals<readonly ["sending", "uncertain", "unconfirmed", "awaiting-approval", "awaiting-consent"]>;
166
+ readonly doubtful: Schema.Boolean;
167
+ readonly waitingOn: Schema.NullOr<Schema.String>;
168
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
169
+ readonly deviceId: Schema.String;
170
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
171
+ readonly model: Schema.optionalKey<Schema.String>;
172
+ readonly cwd: Schema.optionalKey<Schema.String>;
173
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
174
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
175
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
176
+ readonly followUp: Schema.optionalKey<Schema.String>;
177
+ }>>>;
178
+ }>>;
179
+ /** Why the shown conversation's last send failed, kept with the draft until the next send. */
180
+ readonly error: Schema.NullOr<Schema.Struct<{
181
+ readonly _tag: Schema.String;
182
+ readonly message: Schema.String;
183
+ readonly status: Schema.Number;
184
+ readonly approvalId: Schema.optionalKey<Schema.String>;
185
+ readonly consentId: Schema.optionalKey<Schema.String>;
186
+ }>>;
187
+ }>;
188
+ export type Composer = typeof Composer.Type;
189
+ /** A model step's streamed text, not yet stored, and the model call it comes from (null: the stored text). */
190
+ export declare const StreamedStep: Schema.Struct<{
191
+ readonly step: Schema.Number;
192
+ readonly attempt: Schema.NullOr<Schema.String>;
193
+ readonly text: Schema.String;
194
+ }>;
195
+ export type StreamedStep = typeof StreamedStep.Type;
196
+ /** What the active run's stream delivered that the replica may not hold yet. */
197
+ export declare const Live: Schema.Struct<{
198
+ readonly runId: Schema.String;
199
+ /** The last stored event's sequence number seen: each stored event counts once. */
200
+ readonly after: Schema.Number;
201
+ /** How many model steps the stream reported done (`model-step`): text that names no step is the next one's. */
202
+ readonly steps: Schema.Number;
203
+ readonly streamed: Schema.$Array<Schema.Struct<{
204
+ readonly step: Schema.Number;
205
+ readonly attempt: Schema.NullOr<Schema.String>;
206
+ readonly text: Schema.String;
207
+ }>>;
208
+ }>;
209
+ export type Live = typeof Live.Type;
210
+ export declare const ChatState: Schema.Struct<{
211
+ /** The conversation shown; null for a new one (the first send starts it). */
212
+ readonly conversationId: Schema.NullOr<Schema.String>;
213
+ readonly messages: Schema.$Array<Schema.Struct<{
214
+ readonly id: Schema.String;
215
+ readonly conversationId: Schema.String;
216
+ readonly runId: Schema.NullOr<Schema.String>;
217
+ readonly seq: Schema.Number;
218
+ readonly role: Schema.Literals<readonly ["user", "assistant", "tool", "summary"]>;
219
+ readonly text: Schema.String;
220
+ /** Set when the message left the conversation: compacted into a summary, or after a restored checkpoint (`restore:`). */
221
+ readonly coveredBy: Schema.optionalKey<Schema.NullOr<Schema.String>>;
222
+ }>>;
223
+ readonly runs: Schema.$Array<Schema.Struct<{
224
+ readonly id: Schema.String;
225
+ readonly conversationId: Schema.String;
226
+ readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "succeeded", "stopped", "failed", "cancelled"]>;
227
+ readonly error: Schema.NullOr<Schema.String>;
228
+ readonly createdAt: Schema.Number;
229
+ }>>;
230
+ /** The run a send started, until the replica has it. */
231
+ readonly pendingRun: Schema.NullOr<Schema.Struct<{
232
+ readonly id: Schema.String;
233
+ readonly conversationId: Schema.String;
234
+ readonly status: Schema.Literals<readonly ["queued", "running", "waiting", "succeeded", "stopped", "failed", "cancelled"]>;
235
+ readonly error: Schema.NullOr<Schema.String>;
236
+ readonly createdAt: Schema.Number;
237
+ }>>;
238
+ readonly live: Schema.NullOr<Schema.Struct<{
239
+ readonly runId: Schema.String;
240
+ /** The last stored event's sequence number seen: each stored event counts once. */
241
+ readonly after: Schema.Number;
242
+ /** How many model steps the stream reported done (`model-step`): text that names no step is the next one's. */
243
+ readonly steps: Schema.Number;
244
+ readonly streamed: Schema.$Array<Schema.Struct<{
245
+ readonly step: Schema.Number;
246
+ readonly attempt: Schema.NullOr<Schema.String>;
247
+ readonly text: Schema.String;
248
+ }>>;
249
+ }>>;
250
+ /** Runs whose stream said they ended (`run-finished`), whatever the replica says yet. */
251
+ readonly ended: Schema.$Array<Schema.String>;
252
+ readonly consents: Schema.$Array<Schema.Struct<{
253
+ readonly consentId: Schema.String;
254
+ readonly runId: Schema.String;
255
+ readonly action: Schema.String;
256
+ /**
257
+ * What the person sees the action called: the event's `title` (the action's title as it was when the call was
258
+ * held), or, from a kernel that sends none, the action's readable name; a MAKE action's from its id alone
259
+ * (`decisionLabel`). Never the raw id.
260
+ */
261
+ readonly title: Schema.String;
262
+ }>>;
263
+ readonly composer: Schema.Struct<{
264
+ readonly draft: Schema.String;
265
+ /**
266
+ * Where the next send runs: one of the person's paired devices (its harness, on their own subscription; the kernel
267
+ * asks the person's consent to send the turn there), or the deployment's model (none).
268
+ */
269
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
270
+ readonly deviceId: Schema.String;
271
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
272
+ readonly model: Schema.optionalKey<Schema.String>;
273
+ readonly cwd: Schema.optionalKey<Schema.String>;
274
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
275
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
276
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
277
+ readonly followUp: Schema.optionalKey<Schema.String>;
278
+ }>>>;
279
+ /** Context staged for the next send (`stageContext`). */
280
+ readonly context: Schema.optionalKey<Schema.$Array<Schema.Struct<{
281
+ readonly name: Schema.String;
282
+ readonly text: Schema.String;
283
+ /** The record it is about, if any (shown to the agent as a reference; the agent reads it through its tools). */
284
+ readonly reference: Schema.optionalKey<Schema.Struct<{
285
+ readonly module: Schema.String;
286
+ readonly entity: Schema.String;
287
+ readonly id: Schema.String;
288
+ }>>;
289
+ }>>>;
290
+ /** This state's send in flight (one at a time). */
291
+ readonly sending: Schema.NullOr<Schema.Struct<{
292
+ readonly text: Schema.String;
293
+ readonly conversationId: Schema.NullOr<Schema.String>;
294
+ readonly key: Schema.String;
295
+ /** The paired device it runs on (none: the deployment's model). */
296
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
297
+ readonly deviceId: Schema.String;
298
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
299
+ readonly model: Schema.optionalKey<Schema.String>;
300
+ readonly cwd: Schema.optionalKey<Schema.String>;
301
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
302
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
303
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
304
+ readonly followUp: Schema.optionalKey<Schema.String>;
305
+ }>>>;
306
+ }>>;
307
+ /**
308
+ * The person's sends in this organisation whose outcome is not settled, every conversation's: what the outstanding
309
+ * store keeps (`withOutstanding`), with this state's own changes.
310
+ */
311
+ readonly outstanding: Schema.$Array<Schema.Struct<{
312
+ readonly text: Schema.String;
313
+ readonly conversationId: Schema.NullOr<Schema.String>;
314
+ readonly key: Schema.String;
315
+ readonly state: Schema.Literals<readonly ["sending", "uncertain", "unconfirmed", "awaiting-approval", "awaiting-consent"]>;
316
+ readonly doubtful: Schema.Boolean;
317
+ readonly waitingOn: Schema.NullOr<Schema.String>;
318
+ readonly device: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
319
+ readonly deviceId: Schema.String;
320
+ readonly harness: Schema.optionalKey<Schema.Literals<readonly ["claude-code", "codex", "opencode", "acp"]>>;
321
+ readonly model: Schema.optionalKey<Schema.String>;
322
+ readonly cwd: Schema.optionalKey<Schema.String>;
323
+ readonly timeoutMs: Schema.optionalKey<Schema.Number>;
324
+ readonly workspaceTools: Schema.optionalKey<Schema.Boolean>;
325
+ readonly resumable: Schema.optionalKey<Schema.Boolean>;
326
+ readonly followUp: Schema.optionalKey<Schema.String>;
327
+ }>>>;
328
+ }>>;
329
+ /** Why the shown conversation's last send failed, kept with the draft until the next send. */
330
+ readonly error: Schema.NullOr<Schema.Struct<{
331
+ readonly _tag: Schema.String;
332
+ readonly message: Schema.String;
333
+ readonly status: Schema.Number;
334
+ readonly approvalId: Schema.optionalKey<Schema.String>;
335
+ readonly consentId: Schema.optionalKey<Schema.String>;
336
+ }>>;
337
+ }>;
338
+ /**
339
+ * Whether the agent can answer (`chatClient.readiness`, fed with `withEngine`): while the kernel says `missing` or
340
+ * `unavailable` the composer keeps its draft but does not send; `unknown` (not asked yet, or the probe failed)
341
+ * does not hold a send back, which the kernel then answers itself.
342
+ */
343
+ readonly engine: Schema.Struct<{
344
+ readonly state: Schema.Literals<readonly ["configured", "missing", "unavailable", "unknown"]>;
345
+ readonly provider: Schema.NullOr<Schema.String>;
346
+ readonly model: Schema.NullOr<Schema.String>;
347
+ readonly detail: Schema.String;
348
+ }>;
349
+ }>;
350
+ export type ChatState = typeof ChatState.Type;
351
+ /** The engine before anyone asked: unknown, which holds nothing back. */
352
+ export declare const UNKNOWN_ENGINE: EngineReadiness;
353
+ /** A chat on `conversationId` (or a new conversation). */
354
+ export declare const initialChat: (conversationId?: string | null) => ChatState;
355
+ /** The conversation's run still going (queued, running or waiting for consent, and not ended by its stream). */
356
+ export declare const activeRun: (state: ChatState) => ChatRun | undefined;
357
+ /** One line of the transcript: a stored message, or a model step's streamed text (`live`). */
358
+ export interface TranscriptEntry {
359
+ readonly id: string;
360
+ readonly role: ChatMessage["role"];
361
+ readonly text: string;
362
+ readonly runId: string | null;
363
+ readonly live: boolean;
364
+ /**
365
+ * The kernel's challenge of the run's answer (its final-answer check: a `user` message the person did not write,
366
+ * id `<run>:check:<step>`), to show as the kernel's, not the person's.
367
+ */
368
+ readonly check?: boolean;
369
+ }
370
+ /**
371
+ * What a transcript shows: the conversation's stored messages in order (an answer with no text, a tool call, is not a
372
+ * line), then each model step's streamed text the replica does not hold the stored answer of yet.
373
+ */
374
+ export declare const transcript: (state: ChatState) => ReadonlyArray<TranscriptEntry>;
375
+ /** The shown conversation's outstanding sends, as this state sees them (see `seenBy`). */
376
+ export declare const outstandingSends: (state: ChatState) => ReadonlyArray<OutstandingSend>;
377
+ /** The shown conversation's send whose answer was lost, which the next send resends (under its key). */
378
+ export declare const unresolvedSend: (state: ChatState) => OutstandingSend | undefined;
379
+ /**
380
+ * Whether the agent is known not to be able to answer: the kernel said its model is `missing` (not set up) or
381
+ * `unavailable`. A screen shows `state.engine.detail` and keeps the composer for drafting.
382
+ */
383
+ export declare const engineBlocked: (state: ChatState) => boolean;
384
+ /**
385
+ * Whether the composer may send now: the engine not known to be blocked, nothing in flight, no run going, and a
386
+ * non-empty draft or an unresolved send to resend.
387
+ */
388
+ export declare const canSend: (state: ChatState) => boolean;
389
+ /**
390
+ * Show another conversation (or a new one): a fresh state, nothing of the previous one kept but the composer (its
391
+ * draft, the send in flight and the unresolved ones, each still its own conversation's).
392
+ */
393
+ export declare const openConversation: (state: ChatState, conversationId: string | null) => ChatState;
394
+ /** The replica's messages (any conversation's): the transcript keeps this conversation's, in order. */
395
+ export declare const withMessages: (state: ChatState, rows: ReadonlyArray<ChatMessage>) => ChatState;
396
+ /**
397
+ * The replica's runs (any conversation's): the conversation's, newest first. A run the replica reports ended takes
398
+ * its streamed text (its stored answers are in the replica by then) and its pending consents with it.
399
+ */
400
+ export declare const withRuns: (state: ChatState, rows: ReadonlyArray<ChatRun>) => ChatState;
401
+ /**
402
+ * One event of the active run's stream (the client SDK names each event's run, streamed text included). Only the
403
+ * conversation's active run counts; stored events count once (by sequence number); streamed text is its step's.
404
+ */
405
+ export declare const withEvent: (state: ChatState, event: RunEvent) => ChatState;
406
+ /** What the kernel (or a failed probe) said about the agent's readiness (`chatClient.readiness`). */
407
+ export declare const withEngine: (state: ChatState, engine: EngineReadiness) => ChatState;
408
+ /** The person types (also while the engine is not set up: drafting never waits for it). */
409
+ export declare const edit: (state: ChatState, draft: string) => ChatState;
410
+ /**
411
+ * The person sends. The shown conversation's unresolved send, if any, is resent under its own key (with its own
412
+ * text); otherwise the draft is sent under `key` (fresh for each new send). Nothing happens unless the composer may
413
+ * send. The returned request is what to hand `ChatClient.send`, and `send` what to record in the outstanding store
414
+ * before it leaves.
415
+ */
416
+ /** Where the next send runs: `device`, one of the person's paired devices, or the deployment's model (null). */
417
+ export declare const chooseDevice: (state: ChatState, device: RunDevice | null) => ChatState;
418
+ export declare const submit: (state: ChatState, key: string) => {
419
+ readonly state: ChatState;
420
+ readonly request?: ChatSendRequest;
421
+ readonly send?: OutstandingSend;
422
+ };
423
+ /**
424
+ * The send under `key` was accepted: its conversation (a new one, for a first send) and its run, the draft cleared.
425
+ * It settles the send whatever made the request; it changes what is shown only for this state's request, and only if
426
+ * it was sent from the conversation shown.
427
+ */
428
+ export declare const sent: (state: ChatState, key: string, result: {
429
+ readonly conversationId: string;
430
+ readonly runId: string;
431
+ }) => ChatState;
432
+ /** Stage named context for the next send (replacing an item of the same name), within the bounds. */
433
+ export declare const stageContext: (state: ChatState, item: StagedContext) => {
434
+ readonly state: ChatState;
435
+ readonly staged: boolean;
436
+ readonly reason?: string;
437
+ };
438
+ /** Take a staged item back. */
439
+ export declare const unstageContext: (state: ChatState, name: string) => ChatState;
440
+ /** What is staged for the next send. */
441
+ export declare const stagedContext: (state: ChatState) => ReadonlyArray<StagedContext>;
442
+ /** Put a record's reference into the draft where the person is writing (at the end), as the agent reads one. */
443
+ export declare const insertReference: (state: ChatState, reference: EntityReference, label?: string) => ChatState;
444
+ /**
445
+ * What another surface asks of the chat (a screen's "ask the agent about this", a command, a deep link): fill the
446
+ * draft (`prefill`; never over what the person is typing unless `replace`), fill it and send (`submit`), open a
447
+ * conversation (`open`), or stage context (`stage`). Each has an id, so its outcome can be reported back.
448
+ */
449
+ export type ChatIntent = {
450
+ readonly id: string;
451
+ readonly kind: "prefill";
452
+ readonly text: string;
453
+ readonly replace?: boolean;
454
+ } | {
455
+ readonly id: string;
456
+ readonly kind: "submit";
457
+ readonly text: string;
458
+ } | {
459
+ readonly id: string;
460
+ readonly kind: "open";
461
+ readonly conversationId: string | null;
462
+ } | {
463
+ readonly id: string;
464
+ readonly kind: "stage";
465
+ readonly context: StagedContext;
466
+ };
467
+ /** An intent's outcome, for its sender: applied, or not and why. */
468
+ export interface IntentOutcome {
469
+ readonly id: string;
470
+ readonly applied: boolean;
471
+ readonly reason?: string;
472
+ }
473
+ /**
474
+ * Apply an intent. `submit: true` asks the UI to send now (`submit` with a fresh key), which it does only while
475
+ * the composer may send; a `submit` intent while a send or run is going is not applied, so nothing is sent twice.
476
+ */
477
+ export declare const applyIntent: (state: ChatState, intent: ChatIntent) => {
478
+ readonly state: ChatState;
479
+ readonly outcome: IntentOutcome;
480
+ readonly submit?: true;
481
+ };
482
+ /** The send under `key` was a replay of one already made under that key (its first answer was lost): it ran then. */
483
+ export declare const replayed: (state: ChatState, key: string) => ChatState;
484
+ /**
485
+ * What looking up the send under `key` found: its receipt (it ran: settled), or none (nothing is known yet: kept as it
486
+ * was, since a send still in flight commits its receipt with it).
487
+ */
488
+ export declare const lookedUp: (state: ChatState, key: string, ran: boolean) => ChatState;
489
+ /** The person gives up on an outstanding send (one that could not be confirmed, or waits on someone). */
490
+ export declare const discard: (state: ChatState, key: string) => ChatState;
491
+ /**
492
+ * An attempt of the send under `key` failed (see `settleSend`): refused at its first and only attempt, it did not run
493
+ * and goes; its answer lost, it is resent under its key by the next send from its conversation; refused after that,
494
+ * it is kept as could not confirm; held for an approval or consent, it waits. The error shows (with the draft) only
495
+ * under the conversation it was sent from.
496
+ */
497
+ export declare const sendFailed: (state: ChatState, key: string, error: ChatError) => ChatState;
498
+ /**
499
+ * The person's outstanding sends in this organisation, as the outstanding store has them now (it outlives screens):
500
+ * they replace the state's, but for this state's own send in flight, which stays while its request is out.
501
+ */
502
+ export declare const withOutstanding: (state: ChatState, sends: ReadonlyArray<OutstandingSend>) => ChatState;
503
+ /** An approval request as the replica delivers it (`approvals.requests`). */
504
+ export declare const ApprovalItem: Schema.Struct<{
505
+ readonly id: Schema.String;
506
+ readonly requesterId: Schema.String;
507
+ readonly action: Schema.String;
508
+ /** What people see the action called, as recorded with the request (absent from an older kernel's rows). */
509
+ readonly title: Schema.optionalKey<Schema.NullOr<Schema.String>>;
510
+ readonly status: Schema.Literals<readonly ["pending", "approved", "rejected", "expired"]>;
511
+ readonly createdAt: Schema.Number;
512
+ }>;
513
+ export type ApprovalItem = typeof ApprovalItem.Type;
514
+ /**
515
+ * What a prompt calls an approval request's action: its recorded title, or its readable name; a MAKE action's from its
516
+ * id alone (`decisionLabel`), never a stored title. Never the raw id.
517
+ */
518
+ export declare const approvalLabel: (item: Pick<ApprovalItem, "action" | "title">) => string;
519
+ /**
520
+ * What approval prompts show: pending requests someone else made that the person may decide (the replica holds
521
+ * only the ones they made or may decide), and their own still waiting.
522
+ */
523
+ export declare const approvals: (rows: ReadonlyArray<ApprovalItem>, userId: string) => {
524
+ toDecide: {
525
+ readonly id: string;
526
+ readonly requesterId: string;
527
+ readonly action: string;
528
+ readonly title?: string | null;
529
+ readonly status: "approved" | "expired" | "pending" | "rejected";
530
+ readonly createdAt: number;
531
+ }[];
532
+ waiting: {
533
+ readonly id: string;
534
+ readonly requesterId: string;
535
+ readonly action: string;
536
+ readonly title?: string | null;
537
+ readonly status: "approved" | "expired" | "pending" | "rejected";
538
+ readonly createdAt: number;
539
+ }[];
540
+ };
541
+ /**
542
+ * A work item as the replica delivers it (`inbox.items`): its title, state, when it was raised, and where it comes
543
+ * from (the module's `source`, the record it links to, the view that shows that record, when the source names one),
544
+ * who it is assigned to and when it is due.
545
+ */
546
+ export declare const InboxItem: Schema.Struct<{
547
+ readonly id: Schema.String;
548
+ readonly title: Schema.String;
549
+ readonly state: Schema.String;
550
+ readonly createdAt: Schema.Number;
551
+ readonly source: Schema.optionalKey<Schema.String>;
552
+ readonly linkId: Schema.optionalKey<Schema.String>;
553
+ readonly view: Schema.optionalKey<Schema.NullOr<Schema.String>>;
554
+ readonly assigneeUserId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
555
+ readonly dueAt: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
556
+ }>;
557
+ export type InboxItem = typeof InboxItem.Type;
558
+ /** The inbox: items still to act on (open, in progress, waiting), newest first. */
559
+ export declare const openItems: (rows: ReadonlyArray<InboxItem>) => ReadonlyArray<InboxItem>;
560
+ /** What a person does with a work item: take it, finish it, or close it without doing it (`inbox.<step>`). */
561
+ export declare const WorkItemStep: Schema.Literals<readonly ["claim", "complete", "dismiss"]>;
562
+ export type WorkItemStep = typeof WorkItemStep.Type;
563
+ /**
564
+ * The steps open to the person on an item: claim one not yet claimed (or claimed by someone else of their group),
565
+ * complete or dismiss one they may act on. The kernel's policy decides; this only offers what it would allow.
566
+ */
567
+ export declare const stepsFor: (item: InboxItem, userId: string) => ReadonlyArray<WorkItemStep>;
568
+ /**
569
+ * A catalogue of what to tell people, one per locale, the app's own entries over these defaults (English). `{message}`
570
+ * is the error's own message, `{action}` a tool's label, `{task}` a delegated task.
571
+ */
572
+ export type ChatCatalog = Readonly<Record<string, string>>;
573
+ export declare const CHAT_CATALOG_EN: ChatCatalog;
574
+ /** What to tell the person about a chat error, from the catalogue (the app's locale's, over the defaults). */
575
+ export declare const chatErrorMessage: (error: ChatError, catalog?: ChatCatalog) => string;
576
+ /** One tool call of a run, as a UI lists it. */
577
+ export interface ToolActivity {
578
+ readonly toolCallId: string;
579
+ readonly toolName: string;
580
+ readonly state: "running" | "done" | "failed" | "consent" | "delegated";
581
+ /** The words to show (from the catalogue and `labels`). */
582
+ readonly label: string;
583
+ readonly error?: string;
584
+ /** For a delegation: the child run doing the task. */
585
+ readonly childRunId?: string;
586
+ }
587
+ /**
588
+ * A run's tool calls from its events, in order, each with its state and words: `labels` names tools for people (by the
589
+ * tool's name, `notebook_write`, the agent's), falling back to the name. A delegation shows as one line with its task,
590
+ * not as a tool running (the child run's own calls are the child's).
591
+ */
592
+ export declare const toolActivity: (events: ReadonlyArray<RunEvent>, options?: {
593
+ readonly labels?: Readonly<Record<string, string>>;
594
+ readonly catalog?: ChatCatalog;
595
+ }) => ReadonlyArray<ToolActivity>;
596
+ /** What a send answers: the conversation and run it started, or (a retry of a send already made) a replay. */
597
+ export type ChatSendResult = {
598
+ readonly kind: "sent";
599
+ readonly conversationId: string;
600
+ readonly runId: string;
601
+ } | {
602
+ readonly kind: "replayed";
603
+ readonly invocationId: string;
604
+ };
605
+ export interface ChatSendRequest {
606
+ readonly text: string;
607
+ readonly conversationId: string | null;
608
+ readonly idempotencyKey: string;
609
+ /** The person's paired device the run executes on (none: the deployment's model). */
610
+ readonly device?: RunDevice | null | undefined;
611
+ }
612
+ export interface ChatClientOptions {
613
+ readonly baseUrl: string;
614
+ /** The session's bearer token, read when a request is made. */
615
+ readonly token: () => string | undefined;
616
+ /** The organisation the chat acts in. */
617
+ readonly orgId: string;
618
+ readonly clientVersion?: string | undefined;
619
+ /** How long a send or a decision waits for its answer before it counts as lost (`Timeout`; 30 s). */
620
+ readonly sendTimeout?: Duration.Input | undefined;
621
+ /**
622
+ * How long the run's event stream waits before it reconnects after its connection dropped or failed without a
623
+ * definitive answer: `base` at first, doubling to `max` (0.5 s and 10 s). A connection that delivered events starts
624
+ * the count again.
625
+ */
626
+ readonly reconnect?: {
627
+ readonly base: Duration.Input;
628
+ readonly max: Duration.Input;
629
+ } | undefined;
630
+ }
631
+ /** The key a decision is made under: the same for every retry of it, another for another decision. */
632
+ export declare const decisionKey: {
633
+ consent: (consentId: string, decision: "approve" | "reject", remember?: string) => string;
634
+ approval: (approvalId: string, decision: "approve" | "reject") => string;
635
+ cancel: (runId: string) => string;
636
+ /**
637
+ * One step on a work item, by the operation it is (`operation`: new for each step the person takes, kept only to
638
+ * retry that step). Never by item and step alone: an item closed and opened again (a follow-up flagged once more
639
+ * keeps its id) is a new operation, which a stale key would answer with the old receipt.
640
+ */
641
+ workItem: (itemId: string, step: WorkItemStep, operation: string) => string;
642
+ };
643
+ /**
644
+ * The chat's requests, as Effects (interrupting one aborts its request): send, cancel, the active run's events, and
645
+ * the person's consent and approval decisions (the kernel's actions, which refuse an agent). A send or decision not
646
+ * answered within `sendTimeout` fails with `Timeout` (status 0: its answer was lost, not refused).
647
+ */
648
+ export declare const chatClient: (options: ChatClientOptions) => {
649
+ /**
650
+ * Send a message (`agent.send`) under its idempotency key: the conversation and the run to follow, or, for a retry
651
+ * of a send already made, a replay (the kernel answers a replay with its receipt, never running it again).
652
+ */
653
+ send: (request: ChatSendRequest) => Effect.Effect<ChatSendResult, ChatError>;
654
+ /**
655
+ * Whether the person's send under `idempotencyKey` ran: its receipt is in the kernel's receipt store. `false` means
656
+ * none has committed yet, not that none will (a send still in flight commits its receipt with it).
657
+ */
658
+ lookup: (idempotencyKey: string) => Effect.Effect<{
659
+ readonly ran: boolean;
660
+ }, ChatError>;
661
+ /**
662
+ * Whether the person's agent can answer (AgentRuntime `readiness`), for `withEngine`: the kernel's verdict, or
663
+ * `unknown` when it could not be asked (never `missing` for a failed probe). A refusal of the caller fails.
664
+ */
665
+ readiness: () => Effect.Effect<EngineReadiness, ChatError>;
666
+ /** Cancel the run (`agent.cancel`), under the run's own key. */
667
+ cancel: (runId: string) => Effect.Effect<Record<string, unknown>, {
668
+ readonly _tag: string;
669
+ readonly message: string;
670
+ readonly status: number;
671
+ readonly approvalId?: string;
672
+ readonly consentId?: string;
673
+ }, never>;
674
+ /**
675
+ * The run's events after `after` (exclusive), as they happen, ending after `run-finished`. Each names the run;
676
+ * streamed text has `seq: -1`. A connection that drops or fails without a definitive answer is followed by
677
+ * another (see `reconnect`) from the last stored event delivered, so a consent asked meanwhile, or the run's end,
678
+ * is never missed; a refusal (the session ended, not the person's run) fails the stream. Interrupting the stream
679
+ * aborts its request: the connection closes at once, even while the stream is silent.
680
+ */
681
+ events: (runId: string, after?: number) => Stream.Stream<RunEvent, ChatError>;
682
+ /** The person's decision on a held tool call (`consent.approve` or `consent.reject`), under its own key. */
683
+ decideConsent: (consentId: string, decision: "approve" | "reject", remember?: "once" | "session" | "always") => Effect.Effect<Record<string, unknown>, {
684
+ readonly _tag: string;
685
+ readonly message: string;
686
+ readonly status: number;
687
+ readonly approvalId?: string;
688
+ readonly consentId?: string;
689
+ }, never>;
690
+ /**
691
+ * A step on a work item (`inbox.claim`, `inbox.complete`, `inbox.dismiss`) under `key`, the step's own
692
+ * (`decisionKey.workItem` with an operation id the caller makes when the person chooses the step): the same key
693
+ * for a retry of it acts once; another step, even the same one on the item reopened, takes a new key.
694
+ */
695
+ workItem: (itemId: string, step: WorkItemStep, key: string) => Effect.Effect<Record<string, unknown>, {
696
+ readonly _tag: string;
697
+ readonly message: string;
698
+ readonly status: number;
699
+ readonly approvalId?: string;
700
+ readonly consentId?: string;
701
+ }, never>;
702
+ /** The person's decision on an approval request (`approvals.approve` or `approvals.reject`), under its own key. */
703
+ decideApproval: (approvalId: string, decision: "approve" | "reject", comment?: string) => Effect.Effect<Record<string, unknown>, {
704
+ readonly _tag: string;
705
+ readonly message: string;
706
+ readonly status: number;
707
+ readonly approvalId?: string;
708
+ readonly consentId?: string;
709
+ }, never>;
710
+ };
711
+ export type ChatClient = ReturnType<typeof chatClient>;
712
+ //# sourceMappingURL=Chat.d.ts.map